customformCtrl.js 807 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137
  1. var appFormly = angular.module("formlyExample", [
  2. "formly",
  3. "formlyBootstrap",
  4. "ui.bootstrap",
  5. "ngSanitize",
  6. "ui.select",
  7. "ui.grid",
  8. ]);
  9. app.requires.push("formlyExample");
  10. // var appFormly = angular.module('formlyExample', [
  11. // 'formly', 'formlyBootstrap','ui.bootstrap',
  12. // 'ngSanitize','ui.select','ui.grid'],
  13. // 图片上传
  14. app.factory("fileReader", [
  15. "$q",
  16. "$log",
  17. function ($q, $log) {
  18. var onLoad = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.resolve(reader.result);
  22. });
  23. };
  24. };
  25. var onError = function (reader, deferred, scope) {
  26. return function () {
  27. scope.$apply(function () {
  28. deferred.reject(reader.result);
  29. });
  30. };
  31. };
  32. var getReader = function (deferred, scope) {
  33. var reader = new FileReader(); //fileReader
  34. reader.onload = onLoad(reader, deferred, scope);
  35. reader.onerror = onError(reader, deferred, scope);
  36. return reader;
  37. };
  38. var readAsDataURL = function (file, scope) {
  39. var deferred = $q.defer();
  40. var reader = getReader(deferred, scope);
  41. reader.readAsDataURL(file);
  42. return deferred.promise;
  43. };
  44. return {
  45. readAsDataUrl: readAsDataURL,
  46. };
  47. },
  48. ]);
  49. appFormly.filter("minutesToHours", function () {
  50. //分钟转小时
  51. return function (num) {
  52. var hour = parseInt(num / 60);
  53. var minute = num % 60;
  54. return hour + "小时" + minute + "分钟";
  55. };
  56. });
  57. appFormly.config(function config(formlyConfigProvider) {
  58. //格式转换方法 XXX-XXX转驼峰命名
  59. function camelize(string) {
  60. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  61. return chr ? chr.toUpperCase() : "";
  62. });
  63. // Ensure 1st char is always lowercase
  64. return string.replace(/^([A-Z])/, function (match, chr) {
  65. return chr ? chr.toLowerCase() : "";
  66. });
  67. }
  68. //获取ngModelAttr对象设置
  69. function getNgModelAttr(attrs, bindings) {
  70. var ngModelAttrs = {};
  71. angular.forEach(attrs, function (attr) {
  72. ngModelAttrs[camelize(attr)] = {
  73. attribute: attr,
  74. };
  75. });
  76. angular.forEach(bindings, function (binding) {
  77. ngModelAttrs[camelize(binding)] = {
  78. bound: binding,
  79. };
  80. });
  81. return ngModelAttrs;
  82. }
  83. formlyConfigProvider.setWrapper({
  84. overwriteOk: true,
  85. name: "bootstrapLabel",
  86. templateUrl: "assets/views/customform/tpl/normal-label.html",
  87. });
  88. //流程图
  89. formlyConfigProvider.setType({
  90. name: "ui-process",
  91. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  92. defaultOptions: function (options) {
  93. return {
  94. templateOptions: {
  95. refresh: function () { },
  96. refreshDelay: 0,
  97. },
  98. };
  99. },
  100. controller: [
  101. "$scope",
  102. "$modal",
  103. "SweetAlert",
  104. "api_bpm_domain",
  105. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  106. $scope.processdata = [];
  107. api_bpm_domain
  108. .flowTracing($scope.model.applicationForm.processInstanceId)
  109. .then(function (data) {
  110. console.log(data);
  111. $scope.processdata = data.data;
  112. });
  113. },
  114. ],
  115. });
  116. //出库单详情
  117. formlyConfigProvider.setType({
  118. name: "ui-getoutinform",
  119. extends: "radio",
  120. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  121. defaultOptions: function (options) {
  122. return {
  123. templateOptions: {
  124. refresh: function () { },
  125. refreshDelay: 0,
  126. },
  127. };
  128. },
  129. controller: [
  130. "$scope",
  131. "$modal",
  132. "SweetAlert",
  133. "api_bpm_domain",
  134. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  135. if (
  136. angular.isDefined($scope.model.type.id) &&
  137. !$scope.model.type.name
  138. ) {
  139. if (($scope.model.type.id = 0)) {
  140. $scope.model.type.name = "新资产入库";
  141. } else if (($scope.model.type.id = 1)) {
  142. $scope.model.type.name = "新设备领用出库";
  143. } else if (($scope.model.type.id = 2)) {
  144. $scope.model.type.name = "资产归还";
  145. } else if (($scope.model.type.id = 4)) {
  146. $scope.model.type.name = "设备更换";
  147. }
  148. }
  149. },
  150. ],
  151. });
  152. //多选框组件
  153. formlyConfigProvider.setType({
  154. name: "ui-checkboxmore",
  155. extends: "radio",
  156. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  157. defaultOptions: function (options) {
  158. return {
  159. templateOptions: {
  160. refresh: function () { },
  161. refreshDelay: 0,
  162. },
  163. };
  164. },
  165. controller: [
  166. "$scope",
  167. "$modal",
  168. "SweetAlert",
  169. "api_bpm_domain",
  170. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  171. $scope.options.initialValue = $scope.model[$scope.options.key];
  172. },
  173. ],
  174. });
  175. //入库单详情
  176. formlyConfigProvider.setType({
  177. name: "ui-getininform",
  178. extends: "radio",
  179. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  180. defaultOptions: function (options) {
  181. return {
  182. templateOptions: {
  183. refresh: function () { },
  184. refreshDelay: 0,
  185. },
  186. };
  187. },
  188. controller: [
  189. "$scope",
  190. "$modal",
  191. "SweetAlert",
  192. "api_bpm_domain",
  193. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  194. if (
  195. angular.isDefined($scope.model.type.id) &&
  196. !$scope.model.type.name
  197. ) {
  198. if (($scope.model.type.id = 0)) {
  199. $scope.model.type.name = "新资产入库";
  200. } else if (($scope.model.type.id = 1)) {
  201. $scope.model.type.name = "新设备领用出库";
  202. } else if (($scope.model.type.id = 2)) {
  203. $scope.model.type.name = "资产归还";
  204. } else if (($scope.model.type.id = 4)) {
  205. $scope.model.type.name = "设备更换";
  206. }
  207. }
  208. },
  209. ],
  210. });
  211. //申请人详情
  212. formlyConfigProvider.setType({
  213. name: "ui-requsterinfom",
  214. extends: "radio",
  215. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  216. defaultOptions: function (options) {
  217. return {
  218. templateOptions: {
  219. refresh: function () { },
  220. refreshDelay: 0,
  221. },
  222. };
  223. },
  224. });
  225. //设备耗材list组件
  226. formlyConfigProvider.setType({
  227. name: "ui-uplodchange",
  228. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  229. defaultOptions: function (options) {
  230. return {
  231. templateOptions: {
  232. refresh: function () { },
  233. refreshDelay: 0,
  234. view: function (APIService, contentId) {
  235. return APIService.downloadAttachment(contentId);
  236. },
  237. },
  238. };
  239. },
  240. controller: [
  241. "$scope",
  242. "$filter",
  243. "ngTableParams",
  244. "$rootScope",
  245. "Restangular",
  246. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  247. // var data = { "haodata": [], "shedata": [] };
  248. var haodata = [];
  249. var shedata = [];
  250. if ($scope.model.consumables) {
  251. if (angular.isArray($scope.model.consumables)) {
  252. haodata = $scope.model.consumables;
  253. } else {
  254. haodata = JSON.parse($scope.model.consumables);
  255. }
  256. $scope.model.consumables = haodata;
  257. angular.forEach(haodata, function (item, index) {
  258. haodata[index].item = index + 1;
  259. });
  260. }
  261. if ($scope.model.assets) {
  262. if (angular.isArray($scope.model.assets)) {
  263. shedata = $scope.model.assets;
  264. } else {
  265. shedata = JSON.parse($scope.model.assets);
  266. }
  267. $scope.model.assets = shedata;
  268. angular.forEach(shedata, function (item, index) {
  269. shedata[index].item = index + 1;
  270. });
  271. }
  272. $scope.tableParamshao = new ngTableParams(
  273. {
  274. page: 1,
  275. count: 5,
  276. },
  277. {
  278. total: haodata.length,
  279. getData: function ($defer, params) {
  280. var orderedData = params.sorting()
  281. ? $filter("orderBy")(haodata, params.orderBy())
  282. : haodata;
  283. $defer.resolve(
  284. orderedData.slice(
  285. (params.page() - 1) * params.count(),
  286. params.page() * params.count()
  287. )
  288. );
  289. },
  290. }
  291. );
  292. $scope.tableParamsshe = new ngTableParams(
  293. {
  294. page: 1,
  295. count: 5,
  296. },
  297. {
  298. total: shedata.length,
  299. getData: function ($defer, params) {
  300. var orderedData = params.sorting()
  301. ? $filter("orderBy")(shedata, params.orderBy())
  302. : shedata;
  303. $defer.resolve(
  304. orderedData.slice(
  305. (params.page() - 1) * params.count(),
  306. params.page() * params.count()
  307. )
  308. );
  309. },
  310. }
  311. );
  312. $scope.editId = -1;
  313. $scope.setEditId = function (pid) {
  314. $scope.editId = pid;
  315. };
  316. if (angular.isUndefined($scope.form.dropState)) {
  317. $scope.form.dropState = false;
  318. }
  319. var to = $scope.options.templateOptions;
  320. var bindId = $scope.model.processInstanceId;
  321. //获取附件列表
  322. $scope.listAttachmen = function () {
  323. to.ApiService.listAttachment(
  324. to.listAttachmentUrl,
  325. to.bindType,
  326. bindId
  327. ).then(function (result) {
  328. var myData = Restangular.stripRestangular(result);
  329. // $scope.listAttachmens = myData;
  330. $scope.attachments = myData.data;
  331. });
  332. };
  333. $scope.listAttachmen();
  334. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  335. // $scope.listAttachmen();
  336. // } else if (to.bindType && $scope.model[to.bindType].id) {
  337. // $scope.listAttachmen();
  338. // }
  339. //附件下载
  340. $scope.download = function (token, filename) {
  341. var downUrl = to.ApiService.downloadAttachment(
  342. to.downUrl,
  343. token
  344. ).getRequestedUrl();
  345. // window.open(downUrl);
  346. var a = document.createElement("a");
  347. a.href = downUrl;
  348. a.target = "_blank";
  349. a.download = filename;
  350. document.body.appendChild(a);
  351. a.click();
  352. };
  353. //附件预览
  354. $scope.view = function (id, previewUrl) {
  355. if (previewUrl) {
  356. window.open(previewUrl);
  357. }
  358. };
  359. },
  360. ],
  361. });
  362. //多选框组件
  363. formlyConfigProvider.setType({
  364. name: "ui-nodataimage",
  365. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  366. defaultOptions: function (options) {
  367. return {
  368. templateOptions: {
  369. refresh: function () { },
  370. refreshDelay: 0,
  371. },
  372. };
  373. },
  374. });
  375. //ui-grid list
  376. formlyConfigProvider.setType({
  377. name: "ui-gridtwolist",
  378. // extends: 'input',
  379. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  380. defaultOptions: function (options, $scope) {
  381. return {
  382. templateOptions: {},
  383. };
  384. },
  385. controller: [
  386. "$scope",
  387. "$modal",
  388. "i18nService",
  389. "SweetAlert",
  390. function ($scope, $modal, i18nService, SweetAlert) {
  391. //gridone
  392. $scope.langs = i18nService.getAllLangs();
  393. $scope.lang = "zh-cn";
  394. i18nService.setCurrentLang($scope.lang);
  395. $scope.gridOptions = {};
  396. $scope.gridOptions.data = "myDatagrid";
  397. $scope.gridOptions.enableColumnResizing = true;
  398. $scope.gridOptions.enableFiltering = true;
  399. $scope.gridOptions.enableGridMenu = false;
  400. $scope.gridOptions.enableRowSelection = true;
  401. $scope.gridOptions.showGridFooter = true;
  402. $scope.gridOptions.showColumnFooter = false;
  403. $scope.gridOptions.fastWatch = true;
  404. $scope.gridOptions.useExternalFiltering = false;
  405. $scope.gridOptions.useExternalPagination = true;
  406. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  407. $scope.gridOptions.paginationPageSize = 10;
  408. $scope.gridOptions.multiSelect = false;
  409. $scope.myDatagrid = [];
  410. $scope.myDatagridall = [];
  411. $scope.selected = {
  412. item: {},
  413. };
  414. $scope.memoryfilterDatagrid = {
  415. idx: 0,
  416. sum: 10,
  417. };
  418. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  419. filterData = {
  420. idx: 0,
  421. sum: 10,
  422. };
  423. $scope.gridOptions.columnDefs =
  424. $scope.options.templateOptions.columnDefs;
  425. }
  426. $scope.gridOptions.rowIdentity = function (row) {
  427. return row.id;
  428. };
  429. $scope.gridOptions.getRowIdentity = function (row) {
  430. return row.id;
  431. };
  432. // $scope.gridOptions.columnDefs = items.columnDefs();
  433. $scope.interceptMydata = function (mydate, idx, sum) {
  434. return mydate.slice(idx * sum, (idx + 1) * sum);
  435. };
  436. $scope.gridOptions.onRegisterApi = function (gridApi) {
  437. $scope.gridApi = gridApi;
  438. gridApi.pagination.on.paginationChanged(
  439. $scope,
  440. function (newPage, pageSize) {
  441. $scope.memoryfilterDatagrid.idx = newPage - 1;
  442. $scope.memoryfilterDatagrid.sum = pageSize;
  443. $scope.myDatagrid = $scope.interceptMydata(
  444. $scope.myDatagridall,
  445. $scope.memoryfilterDatagrid.idx,
  446. 10
  447. );
  448. $scope.loadData({
  449. idx: newPage - 1,
  450. sum: pageSize,
  451. });
  452. }
  453. );
  454. gridApi.core.on.filterChanged($scope, function () { });
  455. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  456. $scope.selected.item = data.entity;
  457. //console.log(data);
  458. });
  459. };
  460. $scope.loadData = function (mydate, idx, sum) {
  461. angular.forEach($scope.myDatagrid, function (item, index) {
  462. $scope.myDatagrid[index].item = index;
  463. });
  464. $scope.gridOptions.totalItems = mydate.length;
  465. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  466. };
  467. if ($scope.model.assets) {
  468. $scope.myDatagridall = $scope.model.assets;
  469. $scope.loadData($scope.model.assets, 0, 10);
  470. }
  471. $scope.saveData = function (itemin) {
  472. event.preventDefault();
  473. var modalInstance = $modal.open({
  474. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  475. controller: function ($scope, $modalInstance, SweetAlert) {
  476. // $scope.consumptive = {};
  477. $scope.title = "填写领用设备信息";
  478. // if (items.name) {
  479. // $scope.consumptive.name = items.name.name;
  480. // }
  481. $scope.placechange = angular.copy(itemin);
  482. $scope.ok = function (item) {
  483. if (
  484. item.props &&
  485. item.props.hwnw_area &&
  486. item.props.hwnw_place &&
  487. item.props.hwnw_room &&
  488. item.props.hwnwswt_jiguihao &&
  489. item.props.hwnwswt_Ushu &&
  490. item.props.snnum
  491. ) {
  492. $modalInstance.close(item);
  493. } else {
  494. SweetAlert.swal({
  495. title: "数据填写不完整!",
  496. text: "请检查数据然后提交!",
  497. type: "error",
  498. });
  499. }
  500. };
  501. $scope.cancel = function () {
  502. $modalInstance.dismiss("cancel");
  503. };
  504. },
  505. resolve: {
  506. SweetAlert: function () {
  507. return SweetAlert;
  508. },
  509. },
  510. });
  511. modalInstance.result.then(function (selectedItem) {
  512. angular.forEach($scope.myDatagrid, function (item, index) {
  513. // $scope.myDatagrid[index].props.hw_state = "在线";
  514. if (item.id == selectedItem.id) {
  515. // $scope.myDatagrid[index] = selectedItem;
  516. angular.extend($scope.myDatagrid[index], selectedItem);
  517. }
  518. });
  519. // $scope.myData3.push(selectedItem);
  520. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  521. $scope.myDatagrid[i]["item"] =
  522. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  523. }
  524. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  525. $scope.myDatagridall;
  526. });
  527. };
  528. //gridtwo
  529. $scope.langs = i18nService.getAllLangs();
  530. $scope.lang = "zh-cn";
  531. i18nService.setCurrentLang($scope.lang);
  532. $scope.gridOptions2 = {};
  533. $scope.gridOptions2.data = "myDatagridold";
  534. $scope.gridOptions2.enableColumnResizing = true;
  535. $scope.gridOptions2.enableFiltering = true;
  536. $scope.gridOptions2.enableGridMenu = false;
  537. $scope.gridOptions2.enableRowSelection = true;
  538. $scope.gridOptions2.showGridFooter = true;
  539. $scope.gridOptions2.showColumnFooter = false;
  540. $scope.gridOptions2.fastWatch = true;
  541. $scope.gridOptions2.useExternalFiltering = false;
  542. $scope.gridOptions.useExternalPagination = true;
  543. $scope.gridOptions2.paginationPageSizes = [10];
  544. $scope.gridOptions2.paginationPageSize = 10;
  545. $scope.gridOptions2.multiSelect = false;
  546. $scope.myDatagridold = [];
  547. $scope.myDatagridoldall = [];
  548. $scope.selected = {
  549. item: {},
  550. };
  551. $scope.memoryfilterDatagridold = {
  552. idx: 0,
  553. sum: 10,
  554. };
  555. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  556. filterData = {
  557. idx: 0,
  558. sum: 10,
  559. };
  560. $scope.gridOptions2.columnDefs =
  561. $scope.options.templateOptions.columnDefstwo;
  562. }
  563. $scope.gridOptions2.rowIdentity = function (row) {
  564. return row.id;
  565. };
  566. $scope.gridOptions2.getRowIdentity = function (row) {
  567. return row.id;
  568. };
  569. // $scope.gridOptions.columnDefs = items.columnDefs();
  570. $scope.interceptMydata = function (mydate, idx, sum) {
  571. return mydate.slice(idx * sum, (idx + 1) * sum);
  572. };
  573. if ($scope.model.oldAssets) {
  574. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  575. $scope.myDatagridold = $scope.interceptMydata(
  576. $scope.myDatagridallold,
  577. $scope.memoryfilterDatagridold.idx,
  578. 10
  579. );
  580. }
  581. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  582. $scope.gridApi = gridApi;
  583. gridApi.pagination.on.paginationChanged(
  584. $scope,
  585. function (newPage, pageSize) {
  586. $scope.memoryfilterDatagridold.idx = newPage - 1;
  587. $scope.memoryfilterDatagridold.sum = pageSize;
  588. $scope.myDatagridold = $scope.interceptMydata(
  589. $scope.myDatagridallold,
  590. $scope.memoryfilterDatagridold.idx,
  591. 10
  592. );
  593. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  594. }
  595. );
  596. gridApi.core.on.filterChanged($scope, function () { });
  597. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  598. $scope.selected.item = data.entity;
  599. //console.log(data);
  600. });
  601. };
  602. // $scope.loadData = function(mydate, idx, sum) {
  603. // angular.forEach($scope.myDatagridold, function(item, index) {
  604. // $scope.myDatagridold[index].item = index;
  605. // })
  606. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  607. // }
  608. // if ($scope.model.assets) {
  609. // $scope.myDatagridallold = $scope.model.assets;
  610. // $scope.loadData($scope.model.assets, 0, 10)
  611. // }
  612. // $scope.addoldassets = function(itemin) {
  613. // event.preventDefault();
  614. // var modalInstance = $modal.open({
  615. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  616. // controller: function($scope, $modalInstance, SweetAlert) {
  617. // // $scope.consumptive = {};
  618. // $scope.title = "填写领用设备信息";
  619. // // if (items.name) {
  620. // // $scope.consumptive.name = items.name.name;
  621. // // }
  622. // $scope.placechange = itemin;
  623. // $scope.ok = function(item) {
  624. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  625. // $modalInstance.close(item);
  626. // } else {
  627. // SweetAlert.swal({
  628. // title: "数据填写不完整!",
  629. // text: "请检查数据然后提交!",
  630. // type: "error"
  631. // });
  632. // }
  633. // };
  634. // $scope.cancel = function() {
  635. // $modalInstance.dismiss('cancel');
  636. // };
  637. // },
  638. // resolve: {
  639. // SweetAlert: function() {
  640. // return SweetAlert;
  641. // }
  642. // }
  643. // });
  644. $scope.interceptMydata = function (mydate, idx, sum) {
  645. return mydate.slice(idx * sum, (idx + 1) * sum);
  646. };
  647. $scope.addshebei = function () {
  648. event.preventDefault();
  649. var modalInstance = $modal.open({
  650. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  651. controller: function (
  652. $scope,
  653. i18nService,
  654. $modalInstance,
  655. items,
  656. title,
  657. Restangular,
  658. APIService,
  659. onDataCallback,
  660. parentScope,
  661. api_configure_data,
  662. api_configure_form,
  663. api_cmdb
  664. ) {
  665. $scope.langs = i18nService.getAllLangs();
  666. $scope.lang = "zh-cn";
  667. i18nService.setCurrentLang($scope.lang);
  668. $scope.gridOptions = {};
  669. $scope.gridOptions.data = "myDatatwo";
  670. $scope.gridOptions.enableColumnResizing = true;
  671. $scope.gridOptions.enableFiltering = false;
  672. $scope.gridOptions.enableGridMenu = false;
  673. $scope.gridOptions.showGridFooter = true;
  674. $scope.gridOptions.showColumnFooter = false;
  675. $scope.gridOptions.fastWatch = true;
  676. $scope.gridOptions.useExternalFiltering = true;
  677. $scope.gridOptions.useExternalPagination = true;
  678. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  679. $scope.gridOptions.paginationPageSize = 10;
  680. $scope.gridOptions.multiSelect = true;
  681. $scope.gridOptions.rowIdentity = function (row) {
  682. return row.id;
  683. };
  684. $scope.gridOptions.getRowIdentity = function (row) {
  685. return row.id;
  686. };
  687. $scope.gridOptions.columnDefs = [
  688. {
  689. name: "item",
  690. displayName: "序号",
  691. width: 80,
  692. enableFiltering: false,
  693. },
  694. {
  695. name: "uuid",
  696. displayName: "内部编号",
  697. width: 150,
  698. },
  699. {
  700. name: "props.hw_mingcheng",
  701. displayName: "资产名称",
  702. width: 100,
  703. },
  704. {
  705. name: "props.hw_cifilterClassic",
  706. displayName: "资产类型",
  707. width: 120,
  708. enableFiltering: false,
  709. },
  710. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  711. {
  712. name: "props.hw_state",
  713. displayName: "资产状态",
  714. width: 150,
  715. enableFiltering: false,
  716. },
  717. {
  718. name: "props.hwnw_area",
  719. displayName: "资产地点",
  720. width: 130,
  721. enableFiltering: false,
  722. },
  723. {
  724. name: "createtime",
  725. displayName: "申请时间",
  726. enableFiltering: false,
  727. },
  728. ];
  729. // $scope.selectButtonClick
  730. var defaultFilterData = {
  731. // "assignee":2,
  732. // "applicationForm": { "hw_state": "在线" },
  733. hw_state: "在线",
  734. idx: 0,
  735. sum: 10,
  736. };
  737. $scope.memoryfilterData = {
  738. // "assignee":2,
  739. // "applicationForm": { "hw_state": "在线" },
  740. hw_state: "在线",
  741. idx: 0,
  742. sum: 10,
  743. };
  744. $scope.refreshData = function (style, filterData) {
  745. if (angular.isUndefined(filterData)) {
  746. filterData = defaultFilterData;
  747. }
  748. $scope.myDatatwo = [];
  749. // $scope.gridOptions['sum']=filterData.sum;
  750. api_cmdb.query(filterData).then(
  751. function (data) {
  752. // $scope.callsPending--;
  753. var myDatatwo = Restangular.stripRestangular(data);
  754. $scope.gridOptions["totalItems"] = data.total;
  755. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  756. myDatatwo.data.node[i].createtime = moment(
  757. myDatatwo.data.node[i].createtime
  758. ).format("YYYY-MM-DD");
  759. }
  760. $scope.myDatatwo = myDatatwo.data.node;
  761. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  762. $scope.myDatatwo[i]["item"] =
  763. i + 1 + filterData.idx * filterData.sum;
  764. }
  765. },
  766. function () { }
  767. );
  768. };
  769. $scope.refreshData("expand-right", defaultFilterData);
  770. $scope.gridOptions.onRegisterApi = function (gridApi) {
  771. $scope.gridApi = gridApi;
  772. gridApi.pagination.on.paginationChanged(
  773. $scope,
  774. function (newPage, pageSize) {
  775. var filtersData = $scope.memoryfilterData;
  776. filtersData.idx = newPage - 1;
  777. filtersData.sum = pageSize;
  778. // $scope.loadData(filtersData);
  779. $scope.refreshData("expand-right", filtersData);
  780. //console.log(pageSize);
  781. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  782. }
  783. );
  784. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  785. // $scope.selected.items.push(data.entity);
  786. //console.log(data);
  787. gridApi.selection.on.rowSelectionChanged(
  788. $scope,
  789. function (scope, ect) {
  790. if (scope.isSelected) {
  791. scope.grid.appScope.selected.items.push(scope.entity);
  792. } else {
  793. for (
  794. var i = 0;
  795. i <= scope.grid.appScope.selected.items.length;
  796. i++
  797. ) {
  798. if (
  799. scope.grid.appScope.selected.items[i].id ==
  800. scope.entity.id
  801. ) {
  802. scope.grid.appScope.selected.items.splice(i, 1);
  803. break;
  804. }
  805. }
  806. }
  807. $scope.mySelectedRows =
  808. $scope.gridApi.selection.getSelectedRows();
  809. }
  810. );
  811. // });
  812. gridApi.selection.on.rowSelectionChangedBatch(
  813. $scope,
  814. function (rows) {
  815. // $scope.selected.items = data.entity;
  816. //console.log(data);
  817. var selectitem = [];
  818. selectitem = angular.copy($scope.selected.items);
  819. for (var j = 0; j < rows.length; j++) {
  820. if (rows[j].isSelected == true) {
  821. selectitem.push(rows[j].entity);
  822. } else {
  823. delete selectitem[j];
  824. // rows.splice(j, 1);
  825. }
  826. }
  827. $scope.selected.items = [];
  828. for (var i = 0; i < selectitem.length; i++) {
  829. if (selectitem[i]) {
  830. $scope.selected.items.push(selectitem[i]);
  831. }
  832. }
  833. }
  834. );
  835. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  836. // // if (row.entity.age > 45) {
  837. // row.grid.api.selection.selectRow(row.entity); // 选中行
  838. // // }
  839. // };
  840. gridApi.core.on.filterChanged($scope, function () {
  841. var grid = this.grid;
  842. var filtersData = {
  843. idx: 0,
  844. sum: 10,
  845. user: {
  846. roledata: {
  847. rolecode: "roleset",
  848. },
  849. selectType: "1",
  850. },
  851. };
  852. angular.forEach(grid.columns, function (item) {
  853. if (item.enableFiltering) {
  854. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  855. if (
  856. angular.isDefined(item.filters[0].term) &&
  857. item.filters[0].term != ""
  858. ) {
  859. if (angular.isUndefined(filtersData["user"])) {
  860. filtersData["user"] = {};
  861. }
  862. filtersData["user"][item.field] = item.filters[0].term;
  863. }
  864. }
  865. });
  866. $scope.memoryfilterData = filtersData;
  867. // $scope.loadData(filtersData);
  868. });
  869. };
  870. $scope.onDblClick = function (data, event) {
  871. // $scope.selected.items = data.entity;
  872. $scope.selectButtonClick(data, event);
  873. };
  874. $scope.title = title;
  875. //树形图
  876. var apple_selected, tree, treedata_avm, treedata_geography;
  877. $scope.my_tree_handler = function (branch) {
  878. //var _ref;
  879. var classify = ($scope.classify =
  880. branch.prefix.toLowerCase() + branch.sign);
  881. api_cmdb
  882. .query({
  883. sign: classify,
  884. })
  885. .then(function (data) {
  886. var myDatalingbei = Restangular.stripRestangular(data);
  887. // console.log(myData.data.node);
  888. if (myDatalingbei.data && myDatalingbei.status == 200) {
  889. var ret = myDatalingbei.data;
  890. redrawSvg(myDatalingbei);
  891. }
  892. });
  893. };
  894. $scope.my_data = [];
  895. function convertListToTree(data, treeMap) {
  896. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  897. var root = null; //Initially set our loop to null
  898. var parentNode = null;
  899. //loop over data
  900. for (var i = 0; i < data.length; i++) {
  901. var datum = data[i];
  902. //each node will have children, so let's give it a "children" poperty
  903. datum.children = [];
  904. //add an entry for this node to the map so that any future children can
  905. //lookup the parent
  906. idToNodeMap[datum.id] = datum;
  907. //Does this node have a parent?
  908. if (
  909. typeof datum.parent === "undefined" ||
  910. datum.parent == null
  911. ) {
  912. //Doesn't look like it, so this node is the root of the tree
  913. root = datum;
  914. treeMap[datum.id] = root;
  915. } else {
  916. //This node has a parent, so let's look it up using the id
  917. parentNode = idToNodeMap[datum.parent.id];
  918. //We don't need this property, so let's delete it.
  919. delete datum.parent;
  920. //Let's add the current node as a child of the parent node.
  921. parentNode.children.push(datum);
  922. }
  923. }
  924. return root;
  925. }
  926. function convertParentToChildList(data) {
  927. var treeMap = {};
  928. var list = [];
  929. convertListToTree(data, treeMap);
  930. angular.forEach(treeMap, function (item) {
  931. list.push(item);
  932. });
  933. return list;
  934. }
  935. $scope.my_tree = tree = {};
  936. $scope.try_async_load = function () {
  937. $scope.my_data = [];
  938. $scope.select_treedata = [];
  939. $scope.doing_async = true;
  940. api_configure_data
  941. .fetchDataList("ciclassify", {
  942. idx: 0,
  943. sum: 100,
  944. })
  945. .then(function (result) {
  946. //console.log(result['list']);
  947. $scope.select_treedata = $scope.my_data =
  948. convertParentToChildList(result["list"]);
  949. $scope.doing_async = false;
  950. // tree.expand_all();
  951. //console.log(treelist);
  952. });
  953. };
  954. $scope.select_treedata = [];
  955. $scope.propTypeOptions = [];
  956. $scope.try_async_load();
  957. $scope.onFilterremove = function (item) {
  958. console.log(item);
  959. };
  960. $scope.searchdata = {};
  961. $scope.clear = function () {
  962. $scope.searchdata = {};
  963. $scope.cifilter_classic = {};
  964. $scope.try_async_load();
  965. var fildata = {
  966. idx: 0,
  967. sum: 10,
  968. hw_state: "在线",
  969. };
  970. $scope.memoryfilterData = fildata;
  971. $scope.refreshData("expand-right", fildata);
  972. };
  973. $scope.chiceIncident = function (item) {
  974. var fildata = $scope.memoryfilterData;
  975. // fildata.applicationForm = {};
  976. // if (item.alltitle && item.alldata) {
  977. // fildata.applicationForm[item.alltitle.key] = item.alldata
  978. // }
  979. if (item && item.id) {
  980. var classify = item.prefix.toLowerCase() + item.sign;
  981. fildata.sign = classify;
  982. }
  983. $scope.gridOptions.paginationCurrentPage = 1;
  984. var transitiondata = angular.copy(item);
  985. $scope.refreshData("expand-right", fildata);
  986. };
  987. $scope.applicadata = [];
  988. $scope.onFilterCallback = function (item) {
  989. var tempclassify = item.prefix.toLowerCase() + item.sign;
  990. api_configure_form
  991. .renderTabForm(tempclassify)
  992. .then(function (data) {
  993. var myData = Restangular.stripRestangular(data);
  994. $scope.applicadata = myData[0].form.fields;
  995. });
  996. // }
  997. };
  998. // $scope.loadData({
  999. // idx: 0,
  1000. // sum: 10,
  1001. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1002. // });
  1003. $scope.selected = {
  1004. items: [],
  1005. };
  1006. $scope.ok = function () {
  1007. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1008. // onDataCallback($scope.selected.item, parentScope);
  1009. // }
  1010. $modalInstance.close($scope.selected.items);
  1011. };
  1012. $scope.cancel = function () {
  1013. $modalInstance.dismiss("cancel");
  1014. };
  1015. },
  1016. size: "lg",
  1017. resolve: {
  1018. items: function () {
  1019. return {
  1020. fetchItems: function (filterData, APIService) {
  1021. filterData = filterData || {};
  1022. if (
  1023. angular.isDefined(filterData.idx) &&
  1024. filterData.idx == null
  1025. ) {
  1026. filterData = {
  1027. idx: 0,
  1028. sum: 10,
  1029. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1030. };
  1031. }
  1032. return $scope.options.templateOptions.fetchItems(
  1033. filterData,
  1034. APIService
  1035. );
  1036. },
  1037. };
  1038. },
  1039. title: function () {
  1040. return $scope.options.templateOptions.label;
  1041. },
  1042. Restangular: function () {
  1043. return $scope.options.templateOptions.Restangular;
  1044. },
  1045. APIService: function () {
  1046. return $scope.options.templateOptions.ApiService;
  1047. },
  1048. onDataCallback: function () {
  1049. return $scope.options.templateOptions.callback;
  1050. },
  1051. parentScope: function () {
  1052. return $scope.options.templateOptions.that;
  1053. },
  1054. },
  1055. });
  1056. modalInstance.result.then(function (selectedItem) {
  1057. $scope.myDatagridoldall = selectedItem;
  1058. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1059. $scope.myDatagridoldall[i]["item"] =
  1060. i +
  1061. 1 +
  1062. $scope.memoryfilterDatagridold.idx *
  1063. $scope.memoryfilterDatagridold.sum;
  1064. }
  1065. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1066. $scope.myDatagridold = $scope.interceptMydata(
  1067. $scope.myDatagridoldall,
  1068. 0,
  1069. 10
  1070. );
  1071. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1072. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1073. $scope.myDatagridoldall;
  1074. $scope.options.initialValue = $scope.model.oldAssets;
  1075. });
  1076. // }
  1077. };
  1078. $scope.changestate = function (itemin) {
  1079. event.preventDefault();
  1080. var modalInstance = $modal.open({
  1081. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1082. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1083. $scope.title = "旧设备状态修改";
  1084. $scope.stateshe = [
  1085. {
  1086. id: 2,
  1087. name: "在库",
  1088. },
  1089. {
  1090. id: 4,
  1091. name: "报修",
  1092. },
  1093. {
  1094. id: 3,
  1095. name: "报废",
  1096. },
  1097. ];
  1098. $scope.hw_state = {};
  1099. $scope.ok = function (item) {
  1100. $modalInstance.close(item.id);
  1101. };
  1102. $scope.cancel = function () {
  1103. $modalInstance.dismiss("cancel");
  1104. };
  1105. },
  1106. size: "sm",
  1107. resolve: {
  1108. scope: function () {
  1109. return $scope;
  1110. },
  1111. },
  1112. });
  1113. modalInstance.result.then(function (selectedItem) {
  1114. if (selectedItem) {
  1115. angular.forEach($scope.myDatagridallold, function (item, index) {
  1116. if (item.id == itemin.id) {
  1117. $scope.myDatagridallold[index].props.hw_state =
  1118. selectedItem.name;
  1119. }
  1120. });
  1121. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1122. $scope.myDatagridallold[i]["item"] =
  1123. i +
  1124. 1 +
  1125. $scope.memoryfilterDatagridold.idx *
  1126. $scope.memoryfilterDatagridold.sum;
  1127. }
  1128. $scope.gridOptions2["totalItems"] =
  1129. $scope.myDatagridallold.length;
  1130. $scope.myDatagridold = $scope.interceptMydata(
  1131. $scope.myDatagridallold,
  1132. $scope.memoryfilterDatagridold.idx,
  1133. $scope.memoryfilterDatagridold.sum
  1134. );
  1135. // $scope.model.oldAssets = $scope.myDatagridallold;
  1136. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1137. $scope.myDatagridallold;
  1138. $scope.options.initialValue = $scope.model.oldAssets;
  1139. }
  1140. });
  1141. };
  1142. $scope.savedata = function (data) {
  1143. event.preventDefault();
  1144. var modalInstance = $modal.open({
  1145. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1146. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1147. $scope.title = "设备编辑";
  1148. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1149. $scope.ok = function (item) {
  1150. $modalInstance.close(item);
  1151. };
  1152. $scope.cancel = function () {
  1153. $modalInstance.dismiss("cancel");
  1154. };
  1155. },
  1156. size: "sm",
  1157. resolve: {
  1158. scope: function () {
  1159. return $scope;
  1160. },
  1161. },
  1162. });
  1163. modalInstance.result.then(function (selectedItem) {
  1164. if (selectedItem) {
  1165. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1166. if (item.id == data.id) {
  1167. $scope.myDatagridoldall[index].olddecription =
  1168. selectedItem.olddecription;
  1169. }
  1170. });
  1171. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1172. $scope.myDatagridoldall[i]["item"] =
  1173. i +
  1174. 1 +
  1175. $scope.memoryfilterDatagridold.idx *
  1176. $scope.memoryfilterDatagridold.sum;
  1177. }
  1178. $scope.gridOptions2["totalItems"] =
  1179. $scope.myDatagridoldall.length;
  1180. $scope.myDatagridold = $scope.interceptMydata(
  1181. $scope.myDatagridoldall,
  1182. 0,
  1183. 10
  1184. );
  1185. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1186. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1187. $scope.myDatagridoldall;
  1188. $scope.options.initialValue = $scope.model.oldAssets;
  1189. }
  1190. });
  1191. };
  1192. $scope.removeold = function (data) {
  1193. event.preventDefault();
  1194. var modalInstance = $modal.open({
  1195. templateUrl: "assets/views/delete.html",
  1196. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1197. $scope.title = "设备删除";
  1198. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1199. $scope.ok = function () {
  1200. $modalInstance.close(data);
  1201. };
  1202. $scope.cancel = function () {
  1203. $modalInstance.dismiss("cancel");
  1204. };
  1205. },
  1206. size: "sm",
  1207. resolve: {
  1208. scope: function () {
  1209. return $scope;
  1210. },
  1211. },
  1212. });
  1213. modalInstance.result.then(function (selectedItem) {
  1214. if (selectedItem) {
  1215. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1216. if (item.id == selectedItem.id) {
  1217. $scope.myDatagridoldall.splice(index, 1);
  1218. }
  1219. });
  1220. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1221. $scope.myDatagridoldall[i]["item"] =
  1222. i +
  1223. 1 +
  1224. $scope.memoryfilterDatagridold.idx *
  1225. $scope.memoryfilterDatagridold.sum;
  1226. }
  1227. $scope.gridOptions2["totalItems"] =
  1228. $scope.myDatagridoldall.length;
  1229. $scope.myDatagridold = $scope.interceptMydata(
  1230. $scope.myDatagridoldall,
  1231. 0,
  1232. 10
  1233. );
  1234. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1235. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1236. $scope.myDatagridoldall;
  1237. $scope.options.initialValue = $scope.model.oldAssets;
  1238. }
  1239. });
  1240. };
  1241. },
  1242. ],
  1243. });
  1244. //ui-grid list
  1245. formlyConfigProvider.setType({
  1246. name: "ui-gridlist",
  1247. extends: "input",
  1248. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1249. defaultOptions: function (options, $scope) {
  1250. return {
  1251. templateOptions: {},
  1252. };
  1253. },
  1254. controller: [
  1255. "$scope",
  1256. "$modal",
  1257. "i18nService",
  1258. "SweetAlert",
  1259. function ($scope, $modal, i18nService, SweetAlert) {
  1260. //gridone
  1261. $scope.langs = i18nService.getAllLangs();
  1262. $scope.lang = "zh-cn";
  1263. i18nService.setCurrentLang($scope.lang);
  1264. $scope.gridOptions = {};
  1265. $scope.gridOptions.data = "myDatagrid";
  1266. $scope.gridOptions.enableColumnResizing = true;
  1267. $scope.gridOptions.enableFiltering = true;
  1268. $scope.gridOptions.enableGridMenu = false;
  1269. $scope.gridOptions.enableRowSelection = true;
  1270. $scope.gridOptions.showGridFooter = true;
  1271. $scope.gridOptions.showColumnFooter = false;
  1272. $scope.gridOptions.fastWatch = true;
  1273. $scope.gridOptions.useExternalFiltering = false;
  1274. // $scope.gridOptions.useExternalPagination = true;
  1275. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1276. $scope.gridOptions.paginationPageSize = 10;
  1277. $scope.gridOptions.multiSelect = false;
  1278. $scope.myDatagrid = [];
  1279. $scope.myDatagridall = [];
  1280. $scope.selected = {
  1281. item: {},
  1282. };
  1283. $scope.memoryfilterDatagrid = {
  1284. idx: 0,
  1285. sum: 10,
  1286. };
  1287. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1288. filterData = {
  1289. idx: 0,
  1290. sum: 10,
  1291. };
  1292. $scope.gridOptions.columnDefs =
  1293. $scope.options.templateOptions.columnDefs;
  1294. }
  1295. $scope.gridOptions.rowIdentity = function (row) {
  1296. return row.id;
  1297. };
  1298. $scope.gridOptions.getRowIdentity = function (row) {
  1299. return row.id;
  1300. };
  1301. // $scope.gridOptions.columnDefs = items.columnDefs();
  1302. $scope.interceptMydata = function (mydate, idx, sum) {
  1303. return mydate.slice(idx * sum, (idx + 1) * sum);
  1304. };
  1305. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1306. $scope.gridApi = gridApi;
  1307. gridApi.pagination.on.paginationChanged(
  1308. $scope,
  1309. function (newPage, pageSize) {
  1310. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1311. $scope.memoryfilterDatagrid.sum = pageSize;
  1312. $scope.myDatagrid = $scope.interceptMydata(
  1313. $scope.myDatagridall,
  1314. $scope.memoryfilterDatagrid.idx,
  1315. 10
  1316. );
  1317. $scope.loadData({
  1318. idx: newPage - 1,
  1319. sum: pageSize,
  1320. });
  1321. }
  1322. );
  1323. gridApi.core.on.filterChanged($scope, function () { });
  1324. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1325. $scope.selected.item = data.entity;
  1326. //console.log(data);
  1327. });
  1328. };
  1329. $scope.loadData = function (mydate, idx, sum) {
  1330. angular.forEach($scope.myDatagrid, function (item, index) {
  1331. $scope.myDatagrid[index].item = index;
  1332. });
  1333. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1334. };
  1335. if ($scope.model.assets) {
  1336. $scope.myDatagridall = $scope.model.assets;
  1337. $scope.loadData($scope.model.assets, 0, 10);
  1338. }
  1339. $scope.saveData = function (itemin) {
  1340. event.preventDefault();
  1341. var modalInstance = $modal.open({
  1342. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1343. controller: function ($scope, $modalInstance, SweetAlert) {
  1344. // $scope.consumptive = {};
  1345. $scope.title = "填写领用设备信息";
  1346. // if (items.name) {
  1347. // $scope.consumptive.name = items.name.name;
  1348. // }
  1349. $scope.placechange = angular.copy(itemin);
  1350. $scope.ok = function (item) {
  1351. if (
  1352. item.props &&
  1353. item.props.hwnw_area &&
  1354. item.props.hwnw_place &&
  1355. item.props.hwnw_room &&
  1356. item.props.hwnwswt_jiguihao &&
  1357. item.props.hwnwswt_Ushu &&
  1358. item.props.snnum
  1359. ) {
  1360. $modalInstance.close(item);
  1361. } else {
  1362. SweetAlert.swal({
  1363. title: "数据填写不完整!",
  1364. text: "请检查数据然后提交!",
  1365. type: "error",
  1366. });
  1367. }
  1368. };
  1369. $scope.cancel = function () {
  1370. $modalInstance.dismiss("cancel");
  1371. };
  1372. },
  1373. resolve: {
  1374. SweetAlert: function () {
  1375. return SweetAlert;
  1376. },
  1377. },
  1378. });
  1379. modalInstance.result.then(function (selectedItem) {
  1380. angular.forEach($scope.myDatagrid, function (item, index) {
  1381. if (item.id == selectedItem.id) {
  1382. angular.extend($scope.myDatagrid[index], selectedItem);
  1383. }
  1384. });
  1385. // $scope.myData3.push(selectedItem);
  1386. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1387. $scope.myDatagrid[i]["item"] =
  1388. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1389. }
  1390. // $scope.model.assets = $scope.myDatagridall;
  1391. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1392. $scope.myDatagridall;
  1393. });
  1394. };
  1395. },
  1396. ],
  1397. });
  1398. //设备耗材list组件
  1399. formlyConfigProvider.setType({
  1400. name: "ui-shehaolist",
  1401. // extends: 'radio',
  1402. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1403. defaultOptions: function (options) {
  1404. return {
  1405. templateOptions: {
  1406. refresh: function () { },
  1407. refreshDelay: 0,
  1408. },
  1409. };
  1410. },
  1411. controller: [
  1412. "$scope",
  1413. "$filter",
  1414. "ngTableParams",
  1415. function ($scope, $filter, ngTableParams) {
  1416. // var data = { "haodata": [], "shedata": [] };
  1417. var haodata = [];
  1418. var shedata = [];
  1419. if ($scope.model.consumables) {
  1420. if (angular.isArray($scope.model.consumables)) {
  1421. haodata = $scope.model.consumables;
  1422. } else {
  1423. haodata = JSON.parse($scope.model.consumables);
  1424. }
  1425. $scope.model.consumables = haodata;
  1426. angular.forEach(haodata, function (item, index) {
  1427. haodata[index].item = index + 1;
  1428. });
  1429. }
  1430. if ($scope.model.assets) {
  1431. if (angular.isArray($scope.model.assets)) {
  1432. shedata = $scope.model.assets;
  1433. } else {
  1434. shedata = JSON.parse($scope.model.assets);
  1435. }
  1436. $scope.model.assets = shedata;
  1437. angular.forEach(shedata, function (item, index) {
  1438. shedata[index].item = index + 1;
  1439. });
  1440. }
  1441. $scope.tableParamshao = new ngTableParams(
  1442. {
  1443. page: 1,
  1444. count: 5,
  1445. },
  1446. {
  1447. total: haodata.length,
  1448. getData: function ($defer, params) {
  1449. var orderedData = params.sorting()
  1450. ? $filter("orderBy")(haodata, params.orderBy())
  1451. : haodata;
  1452. $defer.resolve(
  1453. orderedData.slice(
  1454. (params.page() - 1) * params.count(),
  1455. params.page() * params.count()
  1456. )
  1457. );
  1458. },
  1459. }
  1460. );
  1461. $scope.tableParamsshe = new ngTableParams(
  1462. {
  1463. page: 1,
  1464. count: 5,
  1465. },
  1466. {
  1467. total: shedata.length,
  1468. getData: function ($defer, params) {
  1469. var orderedData = params.sorting()
  1470. ? $filter("orderBy")(shedata, params.orderBy())
  1471. : shedata;
  1472. $defer.resolve(
  1473. orderedData.slice(
  1474. (params.page() - 1) * params.count(),
  1475. params.page() * params.count()
  1476. )
  1477. );
  1478. },
  1479. }
  1480. );
  1481. $scope.editId = -1;
  1482. $scope.setEditId = function (pid) {
  1483. $scope.editId = pid;
  1484. };
  1485. if (
  1486. $scope.$parent.$parent.$parent.model.isAgree &&
  1487. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1488. ) {
  1489. $scope.isAgree = "同意";
  1490. } else if (
  1491. $scope.$parent.$parent.$parent.model.isAgree &&
  1492. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1493. ) {
  1494. $scope.isAgree = "同意";
  1495. } else if (
  1496. $scope.$parent.$parent.$parent.model.isAgree &&
  1497. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1498. ) {
  1499. $scope.isAgree = "返回修改";
  1500. }
  1501. },
  1502. ],
  1503. });
  1504. //关联资产出库
  1505. formlyConfigProvider.setType({
  1506. name: "ui-meansmodelselect",
  1507. extends: "input",
  1508. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1509. defaultOptions: function (options) {
  1510. return {
  1511. templateOptions: {},
  1512. };
  1513. },
  1514. controller: [
  1515. "$scope",
  1516. "$modal",
  1517. function ($scope, $modal) {
  1518. $scope.openModal = function (size, options, modal) {
  1519. var modalInstance = $modal.open({
  1520. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1521. controller: function (
  1522. $scope,
  1523. $rootScope,
  1524. $modalInstance,
  1525. items,
  1526. title,
  1527. Restangular,
  1528. APIService,
  1529. api_user_data,
  1530. i18nService,
  1531. api_wechatfile
  1532. ) {
  1533. $scope.langs = i18nService.getAllLangs();
  1534. $scope.lang = "zh-cn";
  1535. i18nService.setCurrentLang($scope.lang);
  1536. $scope.gridOptions = {};
  1537. $scope.gridOptions.data = "myData";
  1538. $scope.gridOptions.enableColumnResizing = true;
  1539. $scope.gridOptions.enableFiltering = false;
  1540. $scope.gridOptions.enableGridMenu = false;
  1541. $scope.gridOptions.showGridFooter = true;
  1542. $scope.gridOptions.showColumnFooter = false;
  1543. $scope.gridOptions.fastWatch = true;
  1544. $scope.gridOptions.useExternalFiltering = true;
  1545. $scope.gridOptions.useExternalPagination = true;
  1546. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1547. $scope.gridOptions.paginationPageSize = 10;
  1548. $scope.gridOptions.multiSelect = false;
  1549. $scope.gridOptions.rowIdentity = function (row) {
  1550. return row.id;
  1551. };
  1552. $scope.gridOptions.getRowIdentity = function (row) {
  1553. return row.id;
  1554. };
  1555. // $scope.states = [{
  1556. // id: 0,
  1557. // name: '待批准'
  1558. // },
  1559. // {
  1560. // id: 1,
  1561. // name: '已驳回'
  1562. // },
  1563. // {
  1564. // id: 2,
  1565. // name: '待出库'
  1566. // },
  1567. // {
  1568. // id: 3,
  1569. // name: '信息更新'
  1570. // },
  1571. // {
  1572. // id: 4,
  1573. // name: '信息确认'
  1574. // },
  1575. // {
  1576. // id: 5,
  1577. // name: '已关闭'
  1578. // }
  1579. // ];
  1580. $scope.getStatesDictionary = function () {
  1581. var data = {
  1582. key: "applicationForm_status",
  1583. type: "list",
  1584. };
  1585. api_wechatfile.getDictionary(data).then(function (res) {
  1586. $scope.states = res;
  1587. });
  1588. };
  1589. $scope.getStatesDictionary();
  1590. $scope.type = [
  1591. {
  1592. id: 1,
  1593. name: "资产入库",
  1594. },
  1595. {
  1596. id: 2,
  1597. name: "资产归还",
  1598. },
  1599. {
  1600. id: 3,
  1601. name: "资产领用",
  1602. },
  1603. {
  1604. id: 4,
  1605. name: "资产更换",
  1606. },
  1607. ];
  1608. $scope.typedata = function (row) {
  1609. if (row.type == 0) {
  1610. return "资产入库";
  1611. } else if (row.type == 2) {
  1612. return "资产归还";
  1613. } else if (row.type == 1) {
  1614. return "资产领用";
  1615. } else if (row.type == 4) {
  1616. return "资产更换";
  1617. }
  1618. };
  1619. $scope.statedata = function (row) {
  1620. if (row.status == 0) {
  1621. return "待批准";
  1622. } else if (row.status == 1) {
  1623. return "已驳回";
  1624. } else if (row.status == 2) {
  1625. return "待出库";
  1626. } else if (row.status == 3) {
  1627. return "信息更新";
  1628. } else if (row.status == 4) {
  1629. return "信息确认";
  1630. } else if (row.status == 5) {
  1631. return "已关闭";
  1632. }
  1633. };
  1634. $scope.transferTime = function (time) {
  1635. return moment(time).format("YYYY-MM-DD HH:mm");
  1636. };
  1637. $scope.application = [
  1638. {
  1639. value: "serialNumbe",
  1640. name: "申请单编号",
  1641. },
  1642. // { value: "proposer", name: '申请人' },
  1643. {
  1644. value: "purpose",
  1645. name: "领用用途",
  1646. },
  1647. // { value: "cmdbsign", name: '设备编号' }
  1648. ];
  1649. $scope.parameters = null;
  1650. $scope.open = function ($event) {
  1651. $event.preventDefault();
  1652. $event.stopPropagation();
  1653. $scope.opened = !$scope.opened;
  1654. };
  1655. $scope.endOpen = function ($event) {
  1656. $event.preventDefault();
  1657. $event.stopPropagation();
  1658. $scope.startOpened = false;
  1659. $scope.endOpened = !$scope.endOpened;
  1660. };
  1661. $scope.startOpen = function ($event) {
  1662. $event.preventDefault();
  1663. $event.stopPropagation();
  1664. $scope.endOpened = false;
  1665. $scope.startOpened = !$scope.startOpened;
  1666. };
  1667. $scope.othcode = {};
  1668. $scope.searchkeys = {};
  1669. $scope.parameters = {};
  1670. $scope.memoryfilterData = {
  1671. assignee: $rootScope.user.id,
  1672. candidateGroups: $rootScope.user.group[0].id,
  1673. searchType: "todo",
  1674. idx: 0,
  1675. sum: 10,
  1676. };
  1677. $scope.clear = function () {
  1678. $scope.searchkeys = {};
  1679. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1680. // $scope.othcode = {};
  1681. $scope.parameters = {};
  1682. var fildata = {
  1683. assignee: $rootScope.user.id,
  1684. candidateGroups: $rootScope.user.group[0].id,
  1685. searchType: "todo",
  1686. idx: 0,
  1687. sum: 10,
  1688. };
  1689. // sessionStorage.removeItem("searchincident");
  1690. $scope.memoryfilterData = fildata;
  1691. $scope.loadData(fildata);
  1692. };
  1693. $scope.chiceIncident = function (parameters, item, stateid) {
  1694. var fildata = {
  1695. assignee: $rootScope.user.id,
  1696. candidateGroups: 1,
  1697. searchType: "todo",
  1698. idx: 0,
  1699. sum: 10,
  1700. };
  1701. if (item) {
  1702. fildata.applicationForm = {};
  1703. if (item.alltitle && item.alldata) {
  1704. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1705. }
  1706. if (item.linkProposer) {
  1707. fildata.applicationForm.linkProposer = item.linkProposer;
  1708. }
  1709. if (item.proposer) {
  1710. fildata.applicationForm.proposer = item.proposer;
  1711. }
  1712. if (item.status) {
  1713. fildata.applicationForm["status"] = {
  1714. id: item.status.id,
  1715. };
  1716. }
  1717. if (item.type) {
  1718. fildata.applicationForm["type"] = {
  1719. id: item.type.id,
  1720. };
  1721. }
  1722. }
  1723. $scope.gridOptions.paginationCurrentPage = 1;
  1724. if (
  1725. parameters &&
  1726. parameters.paramDateFrom &&
  1727. parameters.paramDateTo
  1728. ) {
  1729. angular.extend(fildata, {
  1730. idx: 0,
  1731. sum: $scope.gridOptions.paginationPageSize,
  1732. });
  1733. angular.extend(fildata.applicationForm, {
  1734. startDate: moment(parameters.paramDateFrom).format(
  1735. "YYYY-MM-DD HH:mm:ss"
  1736. ),
  1737. endDate: moment(parameters.paramDateTo).format(
  1738. "YYYY-MM-DD 23:59:59"
  1739. ),
  1740. });
  1741. }
  1742. var transitiondata = angular.copy(item);
  1743. // angular.extend(fildata.applicationForm, transitiondata)
  1744. $scope.loadData(fildata);
  1745. };
  1746. $scope.key = {};
  1747. api_user_data
  1748. .fetchDataList("user", {
  1749. idx: 0,
  1750. sum: 1000,
  1751. flag: -1,
  1752. })
  1753. .then(function (data) {
  1754. $scope.handlingPersonnelUser = data.list;
  1755. });
  1756. $scope.gridOptions.columnDefs = items.columnDefs();
  1757. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1758. $scope.gridApi = gridApi;
  1759. gridApi.pagination.on.paginationChanged(
  1760. $scope,
  1761. function (newPage, pageSize) {
  1762. // console.log(newPage);
  1763. // console.log(pageSize);
  1764. $scope.loadData({
  1765. idx: newPage - 1,
  1766. sum: pageSize,
  1767. });
  1768. }
  1769. );
  1770. gridApi.core.on.filterChanged($scope, function () { });
  1771. gridApi.selection.on.rowSelectionChanged(
  1772. $scope,
  1773. function (data) {
  1774. $scope.selected.item = data.entity;
  1775. //console.log(data);
  1776. }
  1777. );
  1778. };
  1779. $scope.loadData = function (filterData) {
  1780. items.fetchItems(filterData, APIService).then(function (data) {
  1781. var myData = Restangular.stripRestangular(data);
  1782. $scope.gridOptions.totalItems = myData.totalNum;
  1783. $scope.myData = myData.list;
  1784. for (var i = 0; i < $scope.myData.length; i++) {
  1785. $scope.myData[i]["item"] =
  1786. i + 1 + filterData.idx * filterData.sum;
  1787. }
  1788. });
  1789. };
  1790. $scope.title = title;
  1791. $scope.loadData({
  1792. idx: 0,
  1793. sum: 10,
  1794. assignee: $rootScope.user.id,
  1795. candidateGroups: $rootScope.user.group[0].id,
  1796. searchType: "todo",
  1797. });
  1798. $scope.selected = {
  1799. item: {},
  1800. };
  1801. $scope.ok = function () {
  1802. //console.log($scope.selected.item);
  1803. $modalInstance.close($scope.selected.item);
  1804. };
  1805. $scope.cancel = function () {
  1806. $modalInstance.dismiss("cancel");
  1807. };
  1808. },
  1809. size: "lg",
  1810. resolve: {
  1811. items: function () {
  1812. return {
  1813. fetchItems: function (filterData, APIService) {
  1814. filterData = filterData || {};
  1815. // if(!filterData.idx){
  1816. if (
  1817. angular.isDefined(filterData.idx) &&
  1818. filterData.idx == null
  1819. ) {
  1820. filterData = {
  1821. idx: 0,
  1822. sum: 10,
  1823. };
  1824. }
  1825. return options.templateOptions.fetchItems(
  1826. filterData,
  1827. APIService,
  1828. options
  1829. );
  1830. },
  1831. columnDefs: function () {
  1832. return options.templateOptions.columnDefs;
  1833. },
  1834. };
  1835. },
  1836. title: function () {
  1837. return options.templateOptions.modalTitle;
  1838. },
  1839. Restangular: function () {
  1840. return options.templateOptions.Restangular;
  1841. },
  1842. APIService: function () {
  1843. return options.templateOptions.ApiService;
  1844. },
  1845. },
  1846. });
  1847. modalInstance.result.then(
  1848. function (selectedItem) {
  1849. var selectitem = {
  1850. title: selectedItem.title,
  1851. description: selectedItem.description,
  1852. };
  1853. if (options.key == "chuku") {
  1854. if (selectedItem.assets) {
  1855. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1856. selectedItem.assets;
  1857. }
  1858. if (selectedItem.consumables) {
  1859. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1860. selectedItem.consumables;
  1861. }
  1862. angular.extend(
  1863. $scope.$parent.$parent.$parent.model,
  1864. selectitem
  1865. );
  1866. options.value(selectedItem);
  1867. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1868. } else {
  1869. angular.extend(options.model, selectitem);
  1870. options.value(selectedItem);
  1871. }
  1872. },
  1873. function () {
  1874. //console.log('Modal dismissed at: ' + new Date());
  1875. }
  1876. );
  1877. };
  1878. },
  1879. ],
  1880. });
  1881. //文本框
  1882. formlyConfigProvider.setType({
  1883. name: "ui-textcmdb",
  1884. extends: "",
  1885. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1886. defaultOptions: function (options) {
  1887. return {
  1888. templateOptions: {
  1889. transform: function (model, value) {
  1890. return value;
  1891. },
  1892. },
  1893. validation: {
  1894. messages: {
  1895. maxlength: function (viewValue, modelValue, scope) {
  1896. if (viewValue != null) {
  1897. if (viewValue.length > scope.to.maxlength) {
  1898. return (
  1899. scope.to.label +
  1900. " 字数(" +
  1901. viewValue.length +
  1902. ")超限(" +
  1903. scope.to.maxlength +
  1904. ")"
  1905. );
  1906. } else {
  1907. return "";
  1908. }
  1909. }
  1910. },
  1911. },
  1912. },
  1913. };
  1914. },
  1915. controller: [
  1916. "$scope",
  1917. function ($scope) {
  1918. var value = $scope.model[$scope.options.key];
  1919. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1920. $scope.model[$scope.options.key] =
  1921. $scope.options.templateOptions.transform(
  1922. $scope.originalModel,
  1923. value
  1924. );
  1925. }
  1926. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1927. $scope.options.templateOptions.felditem($scope);
  1928. }
  1929. },
  1930. ],
  1931. });
  1932. //设备组件
  1933. formlyConfigProvider.setType({
  1934. name: "ui-applist",
  1935. extends: "radio",
  1936. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1937. defaultOptions: function (options) {
  1938. return {
  1939. templateOptions: {
  1940. refresh: function () { },
  1941. refreshDelay: 0,
  1942. },
  1943. };
  1944. },
  1945. controller: [
  1946. "$scope",
  1947. "$filter",
  1948. "ngTableParams",
  1949. function ($scope, $filter, ngTableParams) {
  1950. var data = [];
  1951. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1952. // data = JSON.parse($scope.model.consumables);
  1953. if (angular.isArray($scope.model.consumables)) {
  1954. data = $scope.model.consumables;
  1955. } else {
  1956. data = JSON.parse($scope.model.consumables);
  1957. }
  1958. $scope.model.consumables = data;
  1959. angular.forEach(data, function (item, index) {
  1960. data[index].item = index + 1;
  1961. });
  1962. }
  1963. if ($scope.model.assets && $scope.options.key == "assets") {
  1964. if (angular.isArray($scope.model.assets)) {
  1965. data = $scope.model.assets;
  1966. } else {
  1967. data = JSON.parse($scope.model.assets);
  1968. }
  1969. // data = JSON.parse($scope.model.assets);
  1970. $scope.model.assets = data;
  1971. angular.forEach(data, function (item, index) {
  1972. data[index].item = index + 1;
  1973. });
  1974. }
  1975. $scope.tableParams = new ngTableParams(
  1976. {
  1977. page: 1,
  1978. count: 5,
  1979. },
  1980. {
  1981. total: data.length,
  1982. getData: function ($defer, params) {
  1983. var orderedData = params.sorting()
  1984. ? $filter("orderBy")(data, params.orderBy())
  1985. : data;
  1986. $defer.resolve(
  1987. orderedData.slice(
  1988. (params.page() - 1) * params.count(),
  1989. params.page() * params.count()
  1990. )
  1991. );
  1992. },
  1993. }
  1994. );
  1995. $scope.editId = -1;
  1996. $scope.setEditId = function (pid) {
  1997. $scope.editId = pid;
  1998. };
  1999. },
  2000. ],
  2001. });
  2002. //list组件
  2003. formlyConfigProvider.setType({
  2004. name: "ui-gudinglist",
  2005. extends: "radio",
  2006. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2007. defaultOptions: function (options) {
  2008. return {
  2009. templateOptions: {
  2010. refresh: function () { },
  2011. refreshDelay: 0,
  2012. },
  2013. };
  2014. },
  2015. controller: [
  2016. "$scope",
  2017. "$filter",
  2018. "ngTableParams",
  2019. function ($scope, $filter, ngTableParams) {
  2020. var data = [];
  2021. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2022. // data = JSON.parse($scope.model.consumables);
  2023. if (angular.isArray($scope.model.consumables)) {
  2024. data = $scope.model.consumables;
  2025. } else {
  2026. data = JSON.parse($scope.model.consumables);
  2027. }
  2028. $scope.model.consumables = data;
  2029. angular.forEach(data, function (item, index) {
  2030. data[index].item = index + 1;
  2031. });
  2032. }
  2033. if ($scope.model.assets && $scope.options.key == "assets") {
  2034. if (angular.isArray($scope.model.assets)) {
  2035. data = $scope.model.assets;
  2036. } else {
  2037. data = JSON.parse($scope.model.assets);
  2038. }
  2039. // data = JSON.parse($scope.model.assets);
  2040. $scope.model.assets = data;
  2041. angular.forEach(data, function (item, index) {
  2042. data[index].item = index + 1;
  2043. });
  2044. }
  2045. $scope.tableParams = new ngTableParams(
  2046. {
  2047. page: 1,
  2048. count: 5,
  2049. },
  2050. {
  2051. total: data.length,
  2052. getData: function ($defer, params) {
  2053. var orderedData = params.sorting()
  2054. ? $filter("orderBy")(data, params.orderBy())
  2055. : data;
  2056. $defer.resolve(
  2057. orderedData.slice(
  2058. (params.page() - 1) * params.count(),
  2059. params.page() * params.count()
  2060. )
  2061. );
  2062. },
  2063. }
  2064. );
  2065. $scope.editId = -1;
  2066. $scope.setEditId = function (pid) {
  2067. $scope.editId = pid;
  2068. };
  2069. },
  2070. ],
  2071. });
  2072. //other list tab组件
  2073. formlyConfigProvider.setType({
  2074. name: "ui-otherlisttab",
  2075. extends: "",
  2076. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2077. defaultOptions: function (options) {
  2078. return {
  2079. templateOptions: {
  2080. refresh: function () { },
  2081. refreshDelay: 0,
  2082. },
  2083. };
  2084. },
  2085. controller: [
  2086. "$scope",
  2087. "$filter",
  2088. "ngTableParams",
  2089. function ($scope, $filter, ngTableParams) { },
  2090. ],
  2091. });
  2092. //审核查看组件
  2093. formlyConfigProvider.setType({
  2094. name: "ui-aprovelist",
  2095. extends: "",
  2096. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2097. defaultOptions: function (options) {
  2098. return {
  2099. templateOptions: {
  2100. refresh: function () { },
  2101. refreshDelay: 0,
  2102. },
  2103. };
  2104. },
  2105. controller: [
  2106. "$scope",
  2107. "$filter",
  2108. "ngTableParams",
  2109. function ($scope, $filter, ngTableParams) {
  2110. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2111. $scope.isAgree = "同意";
  2112. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2113. $scope.isAgree = "同意";
  2114. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2115. $scope.isAgree = "返回修改";
  2116. }
  2117. },
  2118. ],
  2119. });
  2120. //other list组件
  2121. formlyConfigProvider.setType({
  2122. name: "ui-otherlist",
  2123. extends: "",
  2124. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2125. defaultOptions: function (options) {
  2126. return {
  2127. templateOptions: {
  2128. refresh: function () { },
  2129. refreshDelay: 0,
  2130. },
  2131. };
  2132. },
  2133. controller: [
  2134. "$rootScope",
  2135. "$scope",
  2136. "$parse",
  2137. "$injector",
  2138. "$http",
  2139. "$q",
  2140. "$state",
  2141. "$stateParams",
  2142. "$modal",
  2143. "$timeout",
  2144. "$interval",
  2145. "i18nService",
  2146. "SweetAlert",
  2147. "FileUploader",
  2148. "Restangular",
  2149. "UserRestangular",
  2150. "BpmRestangular",
  2151. "api_configure_form",
  2152. "api_configure_data",
  2153. "api_bpm_domain",
  2154. "api_bpm_data",
  2155. "api_user_data",
  2156. "api_cmdb",
  2157. "api_sysinfo",
  2158. function (
  2159. $rootScope,
  2160. $scope,
  2161. $parse,
  2162. $injector,
  2163. $http,
  2164. $q,
  2165. $state,
  2166. $stateParams,
  2167. $modal,
  2168. $timeout,
  2169. $interval,
  2170. i18nService,
  2171. SweetAlert,
  2172. FileUploader,
  2173. Restangular,
  2174. UserRestangular,
  2175. BpmRestangular,
  2176. api_configure_form,
  2177. api_configure_data,
  2178. api_bpm_domain,
  2179. api_bpm_data,
  2180. api_user_data,
  2181. api_cmdb,
  2182. api_sysinfo
  2183. ) {
  2184. console.log("哈哈");
  2185. console.log($scope);
  2186. $scope.langs = i18nService.getAllLangs();
  2187. $scope.lang = "zh-cn";
  2188. i18nService.setCurrentLang($scope.lang);
  2189. var vm = this;
  2190. vm.options = {};
  2191. vm.exampleTitle = ["expressionProperties", "model property"];
  2192. vm.fields = [];
  2193. vm.models = {};
  2194. // vm.models["loginUser"] = $rootScope.user;
  2195. var that = $injector;
  2196. var parse = $parse;
  2197. var formKey = "";
  2198. var pdKey = "";
  2199. if (
  2200. angular.isDefined($state.current.pdKey) &&
  2201. $state.current.pdKey != ""
  2202. ) {
  2203. pdKey = $state.current.pdKey;
  2204. //console.log("pdKey::"+$state.current.pdKey);
  2205. }
  2206. if (
  2207. angular.isDefined($stateParams.formKey) &&
  2208. $stateParams.formKey != ""
  2209. ) {
  2210. formKey = $stateParams.formKey;
  2211. //console.log("formKey::"+$stateParams.formKey);
  2212. }
  2213. //用户测试数据,后续从header的auth中获取
  2214. var userId = 2;
  2215. userId = $rootScope.user.id;
  2216. //==============处理表单设计数据 开始====================
  2217. //处理组件加载后台数据选项的方法
  2218. function refreshSelectOptions(searchVal, field) {
  2219. if (field.templateOptions.optionsUrl) {
  2220. var process = BpmRestangular.all("");
  2221. if (field.templateOptions.ApiService) {
  2222. process = UserRestangular.all("");
  2223. }
  2224. process
  2225. .customPOST(
  2226. {
  2227. idx: 0,
  2228. sum: 1000,
  2229. },
  2230. field.templateOptions.optionsUrl
  2231. )
  2232. .then(function (result) {
  2233. if (!field.templateOptions.options) {
  2234. field.templateOptions.options = [];
  2235. }
  2236. if (field.templateOptions.optionsDataKey) {
  2237. field.templateOptions.options =
  2238. result[field.templateOptions.optionsDataKey];
  2239. } else {
  2240. field.templateOptions.options = result;
  2241. }
  2242. });
  2243. }
  2244. }
  2245. function decodeVMTabForm(model, tabs) {
  2246. var result = {
  2247. model: {},
  2248. tabs: [],
  2249. };
  2250. var mdata = angular.fromJson(model);
  2251. angular.extend(result.model, mdata);
  2252. angular.forEach(tabs, function (tab) {
  2253. tab.form.model = vm.models;
  2254. angular.forEach(tab.form.fields, function (field) {
  2255. if (field.key == "") {
  2256. delete field.key;
  2257. }
  2258. field.type = "ui-otherlisttab";
  2259. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2260. var extObj = angular.fromJson(field.extjson);
  2261. angular.extend(field.templateOptions, extObj.templateOptions);
  2262. delete extObj.templateOptions;
  2263. for (var prop in extObj) {
  2264. if (new RegExp("Expression").test(prop)) {
  2265. //var obj = $scope.$eval(extObj[prop]);
  2266. //extObj[prop] = $scope.$eval(extObj[prop]);
  2267. if (extObj[prop] != null) {
  2268. if (new RegExp("function").test(extObj[prop])) {
  2269. var propValue = eval(extObj[prop]);
  2270. extObj[prop] = propValue;
  2271. } else {
  2272. //console.log(extObj[prop]);
  2273. var obj = $scope.$eval(extObj[prop]);
  2274. extObj[prop] = obj;
  2275. //console.log(obj);
  2276. }
  2277. }
  2278. } else if (new RegExp("expressionProperties").test(prop)) {
  2279. for (var p in extObj[prop]) {
  2280. if (new RegExp("function").test(extObj[prop][p])) {
  2281. var propValue = eval(extObj[prop][p]);
  2282. extObj[prop][p] = propValue;
  2283. } else {
  2284. //if(p.indexOf("'")>=0){
  2285. // var obj = $scope.$eval(extObj[prop][p]);
  2286. // extObj[prop][$scope.$eval(p)]=obj;
  2287. //}
  2288. }
  2289. }
  2290. } else if ("watcher" == prop) {
  2291. if (angular.isArray(extObj[prop])) {
  2292. angular.forEach(extObj[prop], function (item, index) {
  2293. for (var p in item) {
  2294. if (new RegExp("function").test(item[p])) {
  2295. var propValue = eval(item[p]);
  2296. extObj[prop][index][p] = propValue;
  2297. }
  2298. }
  2299. });
  2300. } else if (angular.isObject(extObj[prop])) {
  2301. for (var p in extObj[prop]) {
  2302. if (new RegExp("function").test(extObj[prop][p])) {
  2303. var propValue = eval(extObj[prop][p]);
  2304. extObj[prop][p] = propValue;
  2305. }
  2306. }
  2307. }
  2308. }
  2309. }
  2310. angular.extend(field, extObj);
  2311. delete field.extjson;
  2312. }
  2313. if (field.extjson == "") {
  2314. delete field.extjson;
  2315. }
  2316. if (angular.isDefined(field.templateOptions)) {
  2317. var templateOs = field.templateOptions;
  2318. for (var property in templateOs) {
  2319. //console.log(property);
  2320. if (
  2321. angular.isString(templateOs[property]) &&
  2322. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2323. ) {
  2324. if (new RegExp("function").test(templateOs[property])) {
  2325. var propValue = eval(templateOs[property]);
  2326. field.templateOptions[property] = propValue;
  2327. } else {
  2328. if (that.has(templateOs[property])) {
  2329. field.templateOptions[property] = that.get(
  2330. templateOs[property]
  2331. );
  2332. } else {
  2333. field.templateOptions[property] = templateOs[property];
  2334. }
  2335. }
  2336. } else if (templateOs[property] == null) {
  2337. //delete field.templateOptions[property];
  2338. } else {
  2339. }
  2340. }
  2341. }
  2342. if (
  2343. angular.isDefined(field.templateOptions) &&
  2344. angular.isDefined(field.templateOptions.extjson)
  2345. ) {
  2346. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2347. angular.extend(field.templateOptions, extObj);
  2348. delete field.templateOptions.extjson;
  2349. }
  2350. //...
  2351. if (field.templateOptions) {
  2352. //处理远程获取数据控件方法调用
  2353. if (field.templateOptions.optionsUrl) {
  2354. field.templateOptions.refresh = refreshSelectOptions;
  2355. }
  2356. //处理嵌套属性数据绑定/
  2357. if (field.templateOptions.pkey) {
  2358. var pmodel,
  2359. i = 0;
  2360. angular.forEach(
  2361. field.templateOptions.pkey.split("."),
  2362. function (p) {
  2363. if (i == 0) {
  2364. if (result.model[p] == null) {
  2365. result.model[p] = {};
  2366. }
  2367. pmodel = result.model[p];
  2368. i++;
  2369. } else {
  2370. if (pmodel[p] == null) {
  2371. pmodel[p] = {};
  2372. }
  2373. pmodel = pmodel[p];
  2374. }
  2375. }
  2376. );
  2377. if (pmodel != null) {
  2378. field.model = pmodel;
  2379. if (pmodel[field.key] == null) {
  2380. pmodel[field.key] = null;
  2381. }
  2382. }
  2383. } else {
  2384. if (result.model[field.key] == null) {
  2385. result.model[field.key] = null;
  2386. }
  2387. }
  2388. //处理弹出框组件初始化
  2389. if (field.type == "ui-input-selectmodal") {
  2390. field.templateOptions.modal = $modal;
  2391. //field.templateOptions.Restangular = Restangular;
  2392. } else if (field.type == "ui-userselect") {
  2393. field.templateOptions.modal = $modal;
  2394. //field.templateOptions.Restangular = Restangular;
  2395. } else if (field.type == "ui-multiuserselect") {
  2396. field.templateOptions.modal = $modal;
  2397. } else if (field.type == "ui-modelselect") {
  2398. field.templateOptions.modal = $modal;
  2399. //field.templateOptions.Restangular = Restangular;
  2400. } else if (field.type == "ui-cmdbuplode") {
  2401. $scope.fileUploader = field.templateOptions.fileUploader =
  2402. new FileUploader({
  2403. url: "/uploader",
  2404. queueLimit: 1, //文件个数
  2405. autoUpload: true,
  2406. });
  2407. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2408. } else if (field.type == "ui-dropfile") {
  2409. field.templateOptions.fileUploader = new FileUploader({
  2410. url: "/uploader",
  2411. });
  2412. field.templateOptions.taskId = $stateParams.taskId;
  2413. field.templateOptions.processInstanceId =
  2414. $stateParams.processInstanceId;
  2415. field.templateOptions.userId = $rootScope.user.id;
  2416. //field.ApiService=api_bpm_domain;
  2417. } else if (field.type == "ui-dropfiletable") {
  2418. if (field.templateOptions.processInstanceId) {
  2419. } else {
  2420. field.templateOptions.processInstanceId =
  2421. $stateParams.processInstanceId;
  2422. }
  2423. } else if (field.type == "ui-repeatSection") {
  2424. var repeatForm = {
  2425. model: {},
  2426. fields: field.templateOptions.fields,
  2427. };
  2428. repeatForm.model[field.key] = [];
  2429. decodeVMTabForm(repeatForm);
  2430. }
  2431. }
  2432. // console.log(field);
  2433. //field
  2434. //result.fields.push(field);
  2435. });
  2436. });
  2437. vm.originalTabs = angular.copy(vm.form);
  2438. }
  2439. //======================处理表单设计数据 结束========================
  2440. $scope.ldloading = {};
  2441. function filter(obj) {
  2442. angular.forEach(obj, function (key, value) {
  2443. if (value === "" || value === null) {
  2444. delete obj[key];
  2445. } else if (
  2446. Object.prototype.toString.call(value) === "[object Object]"
  2447. ) {
  2448. filter(value);
  2449. } else if (angular.isArray(value)) {
  2450. angular.forEach(value, function (item) {
  2451. filter(item);
  2452. });
  2453. }
  2454. });
  2455. }
  2456. function invokeOnAllFormOptions(fn) {
  2457. angular.forEach(vm.tabs, function (tab) {
  2458. if (tab.form.options && tab.form.options[fn]) {
  2459. tab.form.options[fn]();
  2460. }
  2461. });
  2462. }
  2463. function encodeCIData(data, ciId) {
  2464. /*
  2465. create/update state:未审核
  2466. create createtime:系统时间
  2467. create/update lastupdatetime : 系统时间
  2468. label:ci分类
  2469. */
  2470. if (ciId) {
  2471. var baseprop = [
  2472. "uuid",
  2473. "name",
  2474. "type",
  2475. "label",
  2476. "status",
  2477. "createtime",
  2478. "lastupdatetime",
  2479. "props",
  2480. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2481. var extraprop = "props";
  2482. data[extraprop] = {};
  2483. for (var key in data) {
  2484. console.log(data[key]);
  2485. if (_.indexOf(baseprop, key) >= 0) {
  2486. continue;
  2487. } else {
  2488. data[extraprop][key] = data[key];
  2489. delete data[key];
  2490. }
  2491. }
  2492. if ($rootScope.user) {
  2493. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2494. data[extraprop]["configperson"] = $rootScope.user.name;
  2495. var isCMAdminFlag = false;
  2496. angular.forEach($rootScope.user.role, function (roleItem) {
  2497. if (roleItem.rolecode == "cmdb charge") {
  2498. isCMAdminFlag = true;
  2499. }
  2500. });
  2501. if (!isCMAdminFlag) {
  2502. data[extraprop]["state"] = "1";
  2503. }
  2504. }
  2505. if (data.props.id) {
  2506. } else {
  2507. data.label = ciId;
  2508. }
  2509. return data;
  2510. }
  2511. return undefined;
  2512. }
  2513. function decodeCIModel(data) {
  2514. var extraprop = "props";
  2515. if (data[extraprop]) {
  2516. for (var key in data[extraprop]) {
  2517. data[key] = data[extraprop][key];
  2518. }
  2519. delete data[extraprop];
  2520. }
  2521. data["iscmadmin"] = false;
  2522. angular.forEach($rootScope.user.role, function (roleItem) {
  2523. if (roleItem.rolecode == "cmdb charge") {
  2524. data["iscmadmin"] = true;
  2525. }
  2526. });
  2527. return data;
  2528. }
  2529. function formValid() {
  2530. angular.forEach(vm.tabs, function (item) {
  2531. //item.
  2532. });
  2533. }
  2534. $scope.vm = vm;
  2535. $scope.refreshcmdbform = function (item) {
  2536. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2537. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2538. var myData = Restangular.stripRestangular(data);
  2539. $scope.propTypeOptions = myData;
  2540. $scope.templateProps = myData;
  2541. $scope.vm.tabs = myData;
  2542. if ($scope.model.assets) {
  2543. vm.models = JSON.parse($scope.model.assets);
  2544. }
  2545. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2546. if (vm.models.vtvmvtm_kaiji) {
  2547. vm.models.vtvmvtm_kaiji = "是";
  2548. } else {
  2549. vm.models.vtvmvtm_kaiji = "否";
  2550. }
  2551. }
  2552. decodeVMTabForm(vm.models, vm.tabs);
  2553. });
  2554. // }
  2555. };
  2556. var cifilterClassic = {};
  2557. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2558. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2559. $scope.refreshcmdbform(
  2560. $scope.$parent.$parent.$parent.model.cifilterClassic
  2561. );
  2562. // } else {}
  2563. },
  2564. ],
  2565. });
  2566. //固定资产下载
  2567. formlyConfigProvider.setType({
  2568. name: "ui-dropupload",
  2569. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2570. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2571. defaultOptions: function (options) {
  2572. return {
  2573. templateOptions: {
  2574. view: function (APIService, contentId) {
  2575. return APIService.downloadAttachment(contentId);
  2576. },
  2577. },
  2578. };
  2579. },
  2580. controller: [
  2581. "$scope",
  2582. "$rootScope",
  2583. "Restangular",
  2584. function ($scope, $rootScope, Restangular) {
  2585. if (angular.isUndefined($scope.form.dropState)) {
  2586. $scope.form.dropState = false;
  2587. }
  2588. var to = $scope.options.templateOptions;
  2589. var bindId = $scope.model[to.bindType].processInstanceId;
  2590. //获取附件列表
  2591. $scope.listAttachmen = function () {
  2592. to.ApiService.listAttachment(
  2593. to.listAttachmentUrl,
  2594. to.bindType,
  2595. bindId
  2596. ).then(function (result) {
  2597. var myData = Restangular.stripRestangular(result);
  2598. // $scope.listAttachmens = myData;
  2599. $scope.attachments = myData.data;
  2600. });
  2601. };
  2602. $scope.listAttachmen();
  2603. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2604. // $scope.listAttachmen();
  2605. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2606. // $scope.listAttachmen();
  2607. // }
  2608. //附件下载
  2609. $scope.download = function (token, filename) {
  2610. var downUrl = to.ApiService.downloadAttachment(
  2611. to.downUrl,
  2612. token
  2613. ).getRequestedUrl();
  2614. var a = document.createElement("a");
  2615. a.href = downUrl;
  2616. a.target = "_blank";
  2617. a.download = filename;
  2618. document.body.appendChild(a);
  2619. a.click();
  2620. };
  2621. //附件预览
  2622. $scope.view = function (id, previewUrl) {
  2623. if (previewUrl) {
  2624. window.open(previewUrl);
  2625. }
  2626. };
  2627. },
  2628. ],
  2629. });
  2630. formlyConfigProvider.setType({
  2631. name: "ui-form",
  2632. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2633. defaultOptions: function (options) {
  2634. return {
  2635. templateOptions: {
  2636. // link: function() {}
  2637. },
  2638. };
  2639. },
  2640. controller: [
  2641. "$rootScope",
  2642. "$scope",
  2643. "$parse",
  2644. "$injector",
  2645. "$http",
  2646. "$q",
  2647. "$state",
  2648. "$stateParams",
  2649. "$modal",
  2650. "$timeout",
  2651. "$interval",
  2652. "i18nService",
  2653. "SweetAlert",
  2654. "FileUploader",
  2655. "Restangular",
  2656. "UserRestangular",
  2657. "BpmRestangular",
  2658. "api_configure_form",
  2659. "api_configure_data",
  2660. "api_bpm_domain",
  2661. "api_bpm_data",
  2662. "api_user_data",
  2663. "api_cmdb",
  2664. "api_sysinfo",
  2665. function (
  2666. $rootScope,
  2667. $scope,
  2668. $parse,
  2669. $injector,
  2670. $http,
  2671. $q,
  2672. $state,
  2673. $stateParams,
  2674. $modal,
  2675. $timeout,
  2676. $interval,
  2677. i18nService,
  2678. SweetAlert,
  2679. FileUploader,
  2680. Restangular,
  2681. UserRestangular,
  2682. BpmRestangular,
  2683. api_configure_form,
  2684. api_configure_data,
  2685. api_bpm_domain,
  2686. api_bpm_data,
  2687. api_user_data,
  2688. api_cmdb,
  2689. api_sysinfo
  2690. ) {
  2691. $scope.langs = i18nService.getAllLangs();
  2692. $scope.lang = "zh-cn";
  2693. i18nService.setCurrentLang($scope.lang);
  2694. var vm = this;
  2695. vm.options = {};
  2696. vm.exampleTitle = ["expressionProperties", "model property"];
  2697. vm.fields = [];
  2698. vm.models = {};
  2699. // vm.models["loginUser"] = $rootScope.user;
  2700. var that = $injector;
  2701. var parse = $parse;
  2702. var formKey = "";
  2703. var pdKey = "";
  2704. if (
  2705. angular.isDefined($state.current.pdKey) &&
  2706. $state.current.pdKey != ""
  2707. ) {
  2708. pdKey = $state.current.pdKey;
  2709. //console.log("pdKey::"+$state.current.pdKey);
  2710. }
  2711. if (
  2712. angular.isDefined($stateParams.formKey) &&
  2713. $stateParams.formKey != ""
  2714. ) {
  2715. formKey = $stateParams.formKey;
  2716. //console.log("formKey::"+$stateParams.formKey);
  2717. }
  2718. //用户测试数据,后续从header的auth中获取
  2719. var userId = 2;
  2720. userId = $rootScope.user.id;
  2721. //==============处理表单设计数据 开始====================
  2722. //处理组件加载后台数据选项的方法
  2723. function refreshSelectOptions(searchVal, field) {
  2724. if (field.templateOptions.optionsUrl) {
  2725. var process = BpmRestangular.all("");
  2726. if (field.templateOptions.ApiService) {
  2727. process = UserRestangular.all("");
  2728. }
  2729. process
  2730. .customPOST(
  2731. {
  2732. idx: 0,
  2733. sum: 1000,
  2734. },
  2735. field.templateOptions.optionsUrl
  2736. )
  2737. .then(function (result) {
  2738. if (!field.templateOptions.options) {
  2739. field.templateOptions.options = [];
  2740. }
  2741. if (field.templateOptions.optionsDataKey) {
  2742. field.templateOptions.options =
  2743. result[field.templateOptions.optionsDataKey];
  2744. } else {
  2745. field.templateOptions.options = result;
  2746. }
  2747. });
  2748. }
  2749. }
  2750. function decodeVMTabForm(model, tabs) {
  2751. var result = {
  2752. model: {},
  2753. tabs: [],
  2754. };
  2755. var mdata = angular.fromJson(model);
  2756. angular.extend(result.model, mdata);
  2757. angular.forEach(tabs, function (tab) {
  2758. tab.form.model = vm.models;
  2759. angular.forEach(tab.form.fields, function (field) {
  2760. if (field.key == "") {
  2761. delete field.key;
  2762. }
  2763. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2764. var extObj = angular.fromJson(field.extjson);
  2765. angular.extend(field.templateOptions, extObj.templateOptions);
  2766. delete extObj.templateOptions;
  2767. for (var prop in extObj) {
  2768. if (new RegExp("Expression").test(prop)) {
  2769. //var obj = $scope.$eval(extObj[prop]);
  2770. //extObj[prop] = $scope.$eval(extObj[prop]);
  2771. if (extObj[prop] != null) {
  2772. if (new RegExp("function").test(extObj[prop])) {
  2773. var propValue = eval(extObj[prop]);
  2774. extObj[prop] = propValue;
  2775. } else {
  2776. //console.log(extObj[prop]);
  2777. var obj = $scope.$eval(extObj[prop]);
  2778. extObj[prop] = obj;
  2779. //console.log(obj);
  2780. }
  2781. }
  2782. } else if (new RegExp("expressionProperties").test(prop)) {
  2783. for (var p in extObj[prop]) {
  2784. if (new RegExp("function").test(extObj[prop][p])) {
  2785. var propValue = eval(extObj[prop][p]);
  2786. extObj[prop][p] = propValue;
  2787. } else {
  2788. //if(p.indexOf("'")>=0){
  2789. // var obj = $scope.$eval(extObj[prop][p]);
  2790. // extObj[prop][$scope.$eval(p)]=obj;
  2791. //}
  2792. }
  2793. }
  2794. } else if ("watcher" == prop) {
  2795. if (angular.isArray(extObj[prop])) {
  2796. angular.forEach(extObj[prop], function (item, index) {
  2797. for (var p in item) {
  2798. if (new RegExp("function").test(item[p])) {
  2799. var propValue = eval(item[p]);
  2800. extObj[prop][index][p] = propValue;
  2801. }
  2802. }
  2803. });
  2804. } else if (angular.isObject(extObj[prop])) {
  2805. for (var p in extObj[prop]) {
  2806. if (new RegExp("function").test(extObj[prop][p])) {
  2807. var propValue = eval(extObj[prop][p]);
  2808. extObj[prop][p] = propValue;
  2809. }
  2810. }
  2811. }
  2812. }
  2813. }
  2814. angular.extend(field, extObj);
  2815. delete field.extjson;
  2816. }
  2817. if (field.extjson == "") {
  2818. delete field.extjson;
  2819. }
  2820. if (angular.isDefined(field.templateOptions)) {
  2821. var templateOs = field.templateOptions;
  2822. for (var property in templateOs) {
  2823. //console.log(property);
  2824. if (
  2825. angular.isString(templateOs[property]) &&
  2826. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2827. ) {
  2828. if (new RegExp("function").test(templateOs[property])) {
  2829. var propValue = eval(templateOs[property]);
  2830. field.templateOptions[property] = propValue;
  2831. } else {
  2832. if (that.has(templateOs[property])) {
  2833. field.templateOptions[property] = that.get(
  2834. templateOs[property]
  2835. );
  2836. } else {
  2837. field.templateOptions[property] = templateOs[property];
  2838. }
  2839. }
  2840. } else if (templateOs[property] == null) {
  2841. //delete field.templateOptions[property];
  2842. } else {
  2843. }
  2844. }
  2845. }
  2846. if (
  2847. angular.isDefined(field.templateOptions) &&
  2848. angular.isDefined(field.templateOptions.extjson)
  2849. ) {
  2850. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2851. angular.extend(field.templateOptions, extObj);
  2852. delete field.templateOptions.extjson;
  2853. }
  2854. //...
  2855. if (field.templateOptions) {
  2856. //处理远程获取数据控件方法调用
  2857. if (field.templateOptions.optionsUrl) {
  2858. field.templateOptions.refresh = refreshSelectOptions;
  2859. }
  2860. //处理嵌套属性数据绑定/
  2861. if (field.templateOptions.pkey) {
  2862. var pmodel,
  2863. i = 0;
  2864. angular.forEach(
  2865. field.templateOptions.pkey.split("."),
  2866. function (p) {
  2867. if (i == 0) {
  2868. if (result.model[p] == null) {
  2869. result.model[p] = {};
  2870. }
  2871. pmodel = result.model[p];
  2872. i++;
  2873. } else {
  2874. if (pmodel[p] == null) {
  2875. pmodel[p] = {};
  2876. }
  2877. pmodel = pmodel[p];
  2878. }
  2879. }
  2880. );
  2881. if (pmodel != null) {
  2882. field.model = pmodel;
  2883. if (pmodel[field.key] == null) {
  2884. pmodel[field.key] = null;
  2885. }
  2886. }
  2887. } else {
  2888. if (result.model[field.key] == null) {
  2889. result.model[field.key] = null;
  2890. }
  2891. }
  2892. //处理弹出框组件初始化
  2893. if (field.type == "ui-input-selectmodal") {
  2894. field.templateOptions.modal = $modal;
  2895. //field.templateOptions.Restangular = Restangular;
  2896. } else if (field.type == "ui-userselect") {
  2897. field.templateOptions.modal = $modal;
  2898. //field.templateOptions.Restangular = Restangular;
  2899. } else if (field.type == "ui-multiuserselect") {
  2900. field.templateOptions.modal = $modal;
  2901. } else if (field.type == "ui-modelselect") {
  2902. field.templateOptions.modal = $modal;
  2903. //field.templateOptions.Restangular = Restangular;
  2904. } else if (field.type == "ui-dropfile") {
  2905. field.templateOptions.fileUploader = new FileUploader({
  2906. url: "/uploader",
  2907. });
  2908. field.templateOptions.taskId = $stateParams.taskId;
  2909. field.templateOptions.processInstanceId =
  2910. $stateParams.processInstanceId;
  2911. field.templateOptions.userId = $rootScope.user.id;
  2912. //field.ApiService=api_bpm_domain;
  2913. // }else if (field.type == "ui-uploadFile") {
  2914. // field.templateOptions.fileUploader = new FileUploader({
  2915. // url: '/uploader'
  2916. // });
  2917. // field.templateOptions.taskId = $stateParams.taskId;
  2918. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2919. // field.templateOptions.userId = $rootScope.user.id;
  2920. //field.ApiService=api_bpm_domain;
  2921. } else if (field.type == "ui-dropfiletable") {
  2922. if (field.templateOptions.processInstanceId) {
  2923. } else {
  2924. field.templateOptions.processInstanceId =
  2925. $stateParams.processInstanceId;
  2926. }
  2927. } else if (field.type == "ui-dropFiles") {
  2928. if (field.templateOptions.processInstanceId) {
  2929. } else {
  2930. field.templateOptions.processInstanceId =
  2931. $stateParams.processInstanceId;
  2932. }
  2933. } else if (field.type == "ui-showImgs") {
  2934. if (field.templateOptions.processInstanceId) {
  2935. } else {
  2936. field.templateOptions.processInstanceId =
  2937. $stateParams.processInstanceId;
  2938. }
  2939. } else if (field.type == "ui-repeatSection") {
  2940. var repeatForm = {
  2941. model: {},
  2942. fields: field.templateOptions.fields,
  2943. };
  2944. repeatForm.model[field.key] = [];
  2945. decodeVMTabForm(repeatForm);
  2946. }
  2947. }
  2948. // console.log(field);
  2949. //field
  2950. //result.fields.push(field);
  2951. });
  2952. });
  2953. vm.originalTabs = angular.copy(vm.form);
  2954. }
  2955. //解析自定义表单设计数据
  2956. function decodeVMForm(vmForm) {
  2957. var result = {
  2958. model: {},
  2959. tabs: [],
  2960. };
  2961. //设置模型实体数据 begin
  2962. // var mdata = vmForm.model;
  2963. //解析数据实体
  2964. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2965. angular.extend(result.model, mdata);
  2966. //设置模型实体数据 end
  2967. //解析设计数据生成表单项 begin
  2968. var fields = [];
  2969. //处理修改设计数据中展示设置
  2970. angular.forEach(vmForm.tabs, function (field) {
  2971. if (field.key == "") {
  2972. delete field.key;
  2973. }
  2974. if (angular.isDefined(field.extjson)) {
  2975. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2976. angular.extend(field.templateOptions, extObj.templateOptions);
  2977. delete extObj.templateOptions;
  2978. for (var prop in extObj) {
  2979. if (new RegExp("Expression").test(prop)) {
  2980. //var obj = $scope.$eval(extObj[prop]);
  2981. //extObj[prop] = $scope.$eval(extObj[prop]);
  2982. if (extObj[prop] != null) {
  2983. if (new RegExp("function").test(extObj[prop])) {
  2984. var propValue = eval(extObj[prop]);
  2985. extObj[prop] = propValue;
  2986. } else {
  2987. //console.log(extObj[prop]);
  2988. var obj = $scope.$eval(extObj[prop]);
  2989. extObj[prop] = obj;
  2990. //console.log(obj);
  2991. }
  2992. }
  2993. } else if (new RegExp("expressionProperties").test(prop)) {
  2994. for (var p in extObj[prop]) {
  2995. if (new RegExp("function").test(extObj[prop][p])) {
  2996. var propValue = eval(extObj[prop][p]);
  2997. extObj[prop][p] = propValue;
  2998. } else {
  2999. //if(p.indexOf("'")>=0){
  3000. // var obj = $scope.$eval(extObj[prop][p]);
  3001. // extObj[prop][$scope.$eval(p)]=obj;
  3002. //}
  3003. }
  3004. }
  3005. } else if ("watcher" == prop) {
  3006. if (angular.isArray(extObj[prop])) {
  3007. angular.forEach(extObj[prop], function (item, index) {
  3008. for (var p in item) {
  3009. if (new RegExp("function").test(item[p])) {
  3010. var propValue = eval(item[p]);
  3011. extObj[prop][index][p] = propValue;
  3012. }
  3013. }
  3014. });
  3015. } else if (angular.isObject(extObj[prop])) {
  3016. for (var p in extObj[prop]) {
  3017. if (new RegExp("function").test(extObj[prop][p])) {
  3018. var propValue = eval(extObj[prop][p]);
  3019. extObj[prop][p] = propValue;
  3020. }
  3021. }
  3022. }
  3023. }
  3024. }
  3025. angular.extend(field, extObj);
  3026. delete field.extjson;
  3027. }
  3028. if (angular.isDefined(field.templateOptions)) {
  3029. var templateOs = field.templateOptions;
  3030. for (var property in templateOs) {
  3031. //console.log(property);
  3032. if (
  3033. angular.isString(templateOs[property]) &&
  3034. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3035. ) {
  3036. if (new RegExp("function").test(templateOs[property])) {
  3037. var propValue = eval(templateOs[property]);
  3038. field.templateOptions[property] = propValue;
  3039. } else {
  3040. if (that.has(templateOs[property])) {
  3041. field.templateOptions[property] = that.get(
  3042. templateOs[property]
  3043. );
  3044. } else {
  3045. field.templateOptions[property] = templateOs[property];
  3046. }
  3047. }
  3048. } else if (templateOs[property] == null) {
  3049. //delete field.templateOptions[property];
  3050. } else {
  3051. }
  3052. }
  3053. }
  3054. if (
  3055. angular.isDefined(field.templateOptions) &&
  3056. angular.isDefined(field.templateOptions.extjson)
  3057. ) {
  3058. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3059. angular.extend(field.templateOptions, extObj);
  3060. delete field.templateOptions.extjson;
  3061. }
  3062. //...
  3063. if (field.templateOptions) {
  3064. //处理远程获取数据控件方法调用
  3065. if (field.templateOptions.optionsUrl) {
  3066. field.templateOptions.refresh = refreshSelectOptions;
  3067. }
  3068. //处理嵌套属性数据绑定/
  3069. if (field.templateOptions.pkey) {
  3070. var pmodel,
  3071. i = 0;
  3072. angular.forEach(
  3073. field.templateOptions.pkey.split("."),
  3074. function (p) {
  3075. if (i == 0) {
  3076. if (result.model[p] == null) {
  3077. result.model[p] = {};
  3078. }
  3079. pmodel = result.model[p];
  3080. i++;
  3081. } else {
  3082. if (pmodel[p] == null) {
  3083. pmodel[p] = {};
  3084. }
  3085. pmodel = pmodel[p];
  3086. }
  3087. }
  3088. );
  3089. if (pmodel != null) {
  3090. field.model = pmodel;
  3091. if (pmodel[field.key] == null) {
  3092. pmodel[field.key] = null;
  3093. }
  3094. }
  3095. } else {
  3096. if (result.model[field.key] == null) {
  3097. result.model[field.key] = null;
  3098. }
  3099. }
  3100. //处理弹出框组件初始化
  3101. if (field.type == "ui-input-selectmodal") {
  3102. field.templateOptions.modal = $modal;
  3103. //field.templateOptions.Restangular = Restangular;
  3104. } else if (field.type == "ui-userselect") {
  3105. field.templateOptions.modal = $modal;
  3106. //field.templateOptions.Restangular = Restangular;
  3107. } else if (field.type == "ui-multiuserselect") {
  3108. field.templateOptions.modal = $modal;
  3109. } else if (field.type == "ui-modelselect") {
  3110. field.templateOptions.modal = $modal;
  3111. //field.templateOptions.Restangular = Restangular;
  3112. } else if (field.type == "ui-dropfile") {
  3113. field.templateOptions.fileUploader = new FileUploader({
  3114. url: "/uploader",
  3115. });
  3116. field.templateOptions.taskId = $stateParams.taskId;
  3117. field.templateOptions.processInstanceId =
  3118. $stateParams.processInstanceId;
  3119. field.templateOptions.userId = $rootScope.user.id;
  3120. //field.ApiService=api_bpm_domain;
  3121. } else if (field.type == "ui-dropfiletable") {
  3122. if (field.templateOptions.processInstanceId) {
  3123. } else {
  3124. field.templateOptions.processInstanceId =
  3125. $stateParams.processInstanceId;
  3126. }
  3127. } else if (field.type == "ui-dropFiles") {
  3128. if (field.templateOptions.processInstanceId) {
  3129. } else {
  3130. field.templateOptions.processInstanceId =
  3131. $stateParams.processInstanceId;
  3132. }
  3133. } else if (field.type == "ui-showImgs") {
  3134. if (field.templateOptions.processInstanceId) {
  3135. } else {
  3136. field.templateOptions.processInstanceId =
  3137. $stateParams.processInstanceId;
  3138. }
  3139. } else if (field.type == "ui-repeatSection") {
  3140. var repeatForm = {
  3141. model: {},
  3142. fields: field.templateOptions.fields,
  3143. };
  3144. repeatForm.model[field.key] = [];
  3145. decodeVMForm(repeatForm);
  3146. }
  3147. }
  3148. // console.log(field);
  3149. result.fields.push(field);
  3150. });
  3151. angular.extend($scope.vm.fields, result.fields);
  3152. angular.extend($scope.vm.models, result.model);
  3153. $scope.formData = vmForm;
  3154. //console.log($scope.vm);
  3155. //解析设计数据生成表单项 end
  3156. return result;
  3157. }
  3158. //======================处理表单设计数据 结束========================
  3159. $scope.ldloading = {};
  3160. function filter(obj) {
  3161. angular.forEach(obj, function (key, value) {
  3162. if (value === "" || value === null) {
  3163. delete obj[key];
  3164. } else if (
  3165. Object.prototype.toString.call(value) === "[object Object]"
  3166. ) {
  3167. filter(value);
  3168. } else if (angular.isArray(value)) {
  3169. angular.forEach(value, function (item) {
  3170. filter(item);
  3171. });
  3172. }
  3173. });
  3174. }
  3175. function invokeOnAllFormOptions(fn) {
  3176. angular.forEach(vm.tabs, function (tab) {
  3177. if (tab.form.options && tab.form.options[fn]) {
  3178. tab.form.options[fn]();
  3179. }
  3180. });
  3181. }
  3182. function encodeCIData(data, ciId) {
  3183. /*
  3184. create/update state:未审核
  3185. create createtime:系统时间
  3186. create/update lastupdatetime : 系统时间
  3187. label:ci分类
  3188. */
  3189. if (ciId) {
  3190. var baseprop = [
  3191. "uuid",
  3192. "name",
  3193. "type",
  3194. "label",
  3195. "status",
  3196. "createtime",
  3197. "lastupdatetime",
  3198. "props",
  3199. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3200. var extraprop = "props";
  3201. data[extraprop] = {};
  3202. for (var key in data) {
  3203. console.log(data[key]);
  3204. if (_.indexOf(baseprop, key) >= 0) {
  3205. continue;
  3206. } else {
  3207. data[extraprop][key] = data[key];
  3208. delete data[key];
  3209. }
  3210. }
  3211. if ($rootScope.user) {
  3212. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3213. data[extraprop]["configperson"] = $rootScope.user.name;
  3214. var isCMAdminFlag = false;
  3215. angular.forEach($rootScope.user.role, function (roleItem) {
  3216. if (roleItem.rolecode == "cmdb charge") {
  3217. isCMAdminFlag = true;
  3218. }
  3219. });
  3220. if (!isCMAdminFlag) {
  3221. data[extraprop]["state"] = "1";
  3222. }
  3223. }
  3224. if (data.props.id) {
  3225. } else {
  3226. data.label = ciId;
  3227. }
  3228. return data;
  3229. }
  3230. return undefined;
  3231. }
  3232. function decodeCIModel(data) {
  3233. var extraprop = "props";
  3234. if (data[extraprop]) {
  3235. for (var key in data[extraprop]) {
  3236. data[key] = data[extraprop][key];
  3237. }
  3238. delete data[extraprop];
  3239. }
  3240. data["iscmadmin"] = false;
  3241. angular.forEach($rootScope.user.role, function (roleItem) {
  3242. if (roleItem.rolecode == "cmdb charge") {
  3243. data["iscmadmin"] = true;
  3244. }
  3245. });
  3246. return data;
  3247. }
  3248. vm.remove = function (data, style) {
  3249. $scope.ldloading[style.replace("-", "_")] = true;
  3250. var modalInstance = $modal.open({
  3251. templateUrl: "assets/views/delete.html",
  3252. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3253. var cidata = {
  3254. label: data.label,
  3255. id: data.id,
  3256. uuid: data.uuid,
  3257. name: data.name,
  3258. props: {},
  3259. };
  3260. if (cidata.id) {
  3261. cidata.props["removeflag"] = true;
  3262. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3263. $scope.ok = function () {
  3264. $modalInstance.close(cidata);
  3265. };
  3266. $scope.cancel = function () {
  3267. $modalInstance.dismiss("cancel");
  3268. };
  3269. }
  3270. },
  3271. size: "sm",
  3272. resolve: {
  3273. scope: function () {
  3274. return $scope;
  3275. },
  3276. },
  3277. });
  3278. modalInstance.result.then(function (selectedItem) {
  3279. if (selectedItem) {
  3280. // if (selectedItem.length > 0) {
  3281. api_cmdb
  3282. .put(selectedItem, selectedItem.id)
  3283. .then(function (response) {
  3284. if (response) {
  3285. var resData = Restangular.stripRestangular(response);
  3286. SweetAlert.swal(
  3287. {
  3288. title: "删除成功!",
  3289. confirmButtonColor: "#007AFF",
  3290. },
  3291. function () {
  3292. $state.go("app.means.list");
  3293. // $scope.refreshform();
  3294. // reinitTabForm($scope.classify);
  3295. }
  3296. );
  3297. } else {
  3298. SweetAlert.swal({
  3299. title: "系统错误",
  3300. text: "系统错误,请稍后重试!",
  3301. type: "error",
  3302. confirmButtonColor: "#DD6B55",
  3303. });
  3304. }
  3305. $scope.ldloading[style.replace("-", "_")] = false;
  3306. });
  3307. }
  3308. });
  3309. };
  3310. function formValid() {
  3311. angular.forEach(vm.tabs, function (item) {
  3312. //item.
  3313. });
  3314. }
  3315. $scope.closeModel = function () {
  3316. console.log($stateParams);
  3317. if (
  3318. angular.isDefined($stateParams.formKey) &&
  3319. $stateParams.formKey != ""
  3320. ) {
  3321. if (
  3322. $stateParams.formKey == "means_editor" ||
  3323. $stateParams.formKey == "means_edit"
  3324. ) {
  3325. $state.go("app.means.list", {});
  3326. }
  3327. event.preventDefault();
  3328. }
  3329. };
  3330. // setInterval(function() {
  3331. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3332. // cifilter_classic = $scope.model.cifilter_classic;
  3333. // $scope.refreshcmdbform(cifilter_classic);
  3334. // } else {}
  3335. // }, 100);
  3336. vm.models = (function filter(obj) {
  3337. var filtered = _.pick(obj, function (v) {
  3338. return (
  3339. angular.isDefined(v) &&
  3340. v !== null &&
  3341. (angular.isArray(v) ? v.length > 0 : true) &&
  3342. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3343. );
  3344. });
  3345. return _.cloneDeep(filtered, function (v) {
  3346. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3347. });
  3348. })(vm.models);
  3349. // setInterval(function() {
  3350. // if ($scope.model.type == 0) {
  3351. // $scope.model[$scope.options.key] = vm.models;
  3352. // }
  3353. // }, 100);
  3354. setInterval(function () {
  3355. if (vm.form && vm.form.$$parentForm.$valid) {
  3356. if (
  3357. $scope.$parent &&
  3358. $scope.$parent.$parent &&
  3359. $scope.$parent.$parent.$parent &&
  3360. $scope.$parent.$parent.$parent.model
  3361. ) {
  3362. vm.models.hw_cifilterClassic =
  3363. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3364. $scope.model[$scope.options.key] = vm.models;
  3365. }
  3366. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3367. // $scope.model[$scope.options.key] = vm.models;
  3368. }
  3369. }, 100);
  3370. vm.submit = function (data, ciId, templateitem, style) {
  3371. // $scope.ldloading[style.replace('-', '_')] = true;
  3372. console.log(vm.form.$$parentForm.$valid);
  3373. if (vm.form.$$parentForm.$valid) {
  3374. invokeOnAllFormOptions("updateInitialValue");
  3375. //alert(JSON.stringify(vm.model), null, 2);
  3376. //vm.options.updateInitialValue();
  3377. //console.log(vm.model);
  3378. var cidata = encodeCIData(vm.models, ciId);
  3379. if (cidata) {
  3380. //var cidata = ;
  3381. if (cidata.props.id) {
  3382. //修改
  3383. api_cmdb.put(cidata, ciId).then(function (response) {
  3384. if (response) {
  3385. var resData = Restangular.stripRestangular(response);
  3386. SweetAlert.swal(
  3387. {
  3388. title: "保存成功!",
  3389. confirmButtonColor: "#007AFF",
  3390. },
  3391. function () {
  3392. $scope.ldloading[style.replace("-", "_")] = false;
  3393. // $scope.refreshform();
  3394. $state.go("app.means.list");
  3395. }
  3396. );
  3397. } else {
  3398. SweetAlert.swal({
  3399. title: "系统错误",
  3400. text: "系统错误,请稍后重试!",
  3401. type: "error",
  3402. confirmButtonColor: "#DD6B55",
  3403. });
  3404. }
  3405. $scope.ldloading[style.replace("-", "_")] = false;
  3406. });
  3407. } else {
  3408. //新建
  3409. var type = 2;
  3410. api_sysinfo
  3411. .getSerialnumber(type, templateitem.id)
  3412. .then(function (data) {
  3413. if (data && data.status == 200) {
  3414. cidata.uuid = data.uuid;
  3415. api_cmdb.create(cidata).then(function (response) {
  3416. if (response) {
  3417. var resData = Restangular.stripRestangular(response);
  3418. SweetAlert.swal(
  3419. {
  3420. title: "保存成功!",
  3421. text: "内部编号:" + cidata.uuid,
  3422. confirmButtonColor: "#007AFF",
  3423. },
  3424. function () {
  3425. $state.go("app.means.list");
  3426. }
  3427. );
  3428. // if(resData.status){
  3429. // resData
  3430. // }
  3431. } else {
  3432. SweetAlert.swal({
  3433. title: "系统错误",
  3434. text: "系统错误,请稍后重试!",
  3435. type: "error",
  3436. confirmButtonColor: "#DD6B55",
  3437. });
  3438. }
  3439. $scope.ldloading[style.replace("-", "_")] = false;
  3440. });
  3441. } else {
  3442. SweetAlert.swal({
  3443. title: "系统错误",
  3444. text: "内部编号生成出错!",
  3445. type: "error",
  3446. confirmButtonColor: "#DD6B55",
  3447. });
  3448. }
  3449. });
  3450. }
  3451. } else {
  3452. SweetAlert.swal({
  3453. title: "错误",
  3454. text: "错误,请选择资产分类!",
  3455. type: "error",
  3456. confirmButtonColor: "#DD6B55",
  3457. });
  3458. }
  3459. //alert(JSON.stringify(cidata), null, 2);
  3460. $scope.ldloading[style.replace("-", "_")] = true;
  3461. return;
  3462. var _ = window._;
  3463. vm.models = (function filter(obj) {
  3464. var filtered = _.pick(obj, function (v) {
  3465. return (
  3466. angular.isDefined(v) &&
  3467. v !== null &&
  3468. (angular.isArray(v) ? v.length > 0 : true) &&
  3469. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3470. );
  3471. });
  3472. return _.cloneDeep(filtered, function (v) {
  3473. return v !== filtered && _.isPlainObject(v)
  3474. ? filter(v)
  3475. : undefined;
  3476. });
  3477. })(vm.models);
  3478. } else {
  3479. if (vm.form.$$parentForm.$error) {
  3480. SweetAlert.swal({
  3481. title: "校验错误",
  3482. text: "请填写必填项!",
  3483. type: "error",
  3484. confirmButtonColor: "#DD6B55",
  3485. });
  3486. angular.forEach(
  3487. vm.form.$$parentForm.$error.required,
  3488. function (item) {
  3489. angular.forEach(vm.tabs, function (tab) {
  3490. angular.forEach(tab.form.fields, function (f) {
  3491. if (f.name == item.$name) {
  3492. f.validation.show = true;
  3493. tab.active = true;
  3494. }
  3495. });
  3496. });
  3497. }
  3498. );
  3499. $scope.ldloading[style.replace("-", "_")] = false;
  3500. }
  3501. }
  3502. };
  3503. $scope.vm = vm;
  3504. $scope.refreshcmdbform = function (item) {
  3505. // if ($stateParams.model) {
  3506. // var modeldata = JSON.parse($stateParams.model)
  3507. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3508. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3509. var myData = Restangular.stripRestangular(data);
  3510. $scope.propTypeOptions = myData;
  3511. $scope.templateProps = myData;
  3512. $scope.vm.tabs = myData;
  3513. if ($scope.model.asset && $scope.model.asset.length != "") {
  3514. vm.models = JSON.parse($scope.model.asset);
  3515. }
  3516. decodeVMTabForm(vm.models, vm.tabs);
  3517. });
  3518. // }
  3519. };
  3520. var cifilterClassic = {};
  3521. setInterval(function () {
  3522. if (
  3523. $scope.$parent.$parent &&
  3524. $scope.$parent.$parent.$parent &&
  3525. $scope.$parent.$parent.$parent.model &&
  3526. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3527. cifilterClassic.id !=
  3528. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3529. ) {
  3530. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3531. cifilterClassic =
  3532. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3533. $scope.refreshcmdbform(cifilterClassic);
  3534. } else {
  3535. }
  3536. }, 100);
  3537. },
  3538. ],
  3539. });
  3540. //请求人信息
  3541. formlyConfigProvider.setType({
  3542. name: "ui-cmdbinformation",
  3543. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3544. wrapper: ["bootstrapHasError"],
  3545. defaultOptions: function (options, $scope) {
  3546. return {
  3547. templateOptions: {
  3548. // checkform: function(options) {
  3549. // if (options.model.requester) {
  3550. // options.value(options.model.requester);
  3551. // }
  3552. // },
  3553. },
  3554. };
  3555. },
  3556. controller: [
  3557. "$scope",
  3558. "api_user_data",
  3559. function ($scope, api_user_data) {
  3560. if ($scope.options.templateOptions.loginUser) {
  3561. if (
  3562. $scope.model[$scope.options.key] &&
  3563. $scope.model[$scope.options.key].id
  3564. ) {
  3565. } else {
  3566. $scope.model[$scope.options.key] =
  3567. $scope.options.templateOptions.loginUser;
  3568. }
  3569. $scope.options.initialValue = $scope.model[$scope.options.key];
  3570. }
  3571. },
  3572. ],
  3573. });
  3574. //资产属性
  3575. formlyConfigProvider.setType({
  3576. name: "ui-cmdbtype",
  3577. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3578. wrapper: ["bootstrapHasError"],
  3579. defaultOptions: function (options, $scope) {
  3580. return {
  3581. templateOptions: {
  3582. // checkform: function(options) {
  3583. // if (options.model.requester) {
  3584. // options.value(options.model.requester);
  3585. // }
  3586. // },
  3587. },
  3588. };
  3589. },
  3590. controller: [
  3591. "$scope",
  3592. "api_user_data",
  3593. function ($scope, api_user_data) {
  3594. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3595. $scope.property = {
  3596. hw_change: $scope.to.loginUser,
  3597. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3598. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3599. };
  3600. if ($scope.$parent.$parent.$parent.model.assets) {
  3601. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3602. }
  3603. },
  3604. ],
  3605. });
  3606. //申请单信息
  3607. formlyConfigProvider.setType({
  3608. name: "ui-cmdbformimform",
  3609. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3610. wrapper: ["bootstrapHasError"],
  3611. defaultOptions: function (options, $scope) {
  3612. return {
  3613. templateOptions: {
  3614. // checkform: function(options) {
  3615. // if (options.model.requester) {
  3616. // options.value(options.model.requester);
  3617. // }
  3618. // },
  3619. },
  3620. };
  3621. },
  3622. controller: [
  3623. "$scope",
  3624. "api_user_data",
  3625. function ($scope, api_user_data) {
  3626. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3627. $scope.getininform = {
  3628. serialNumbe:
  3629. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3630. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3631. };
  3632. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3633. $scope.getininform.types = "新资产入库";
  3634. } else if (
  3635. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3636. ) {
  3637. $scope.getininform.types = "资产归还";
  3638. }
  3639. },
  3640. ],
  3641. });
  3642. //出库单信息
  3643. formlyConfigProvider.setType({
  3644. name: "ui-outinformation",
  3645. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3646. wrapper: ["bootstrapHasError"],
  3647. defaultOptions: function (options, $scope) {
  3648. return {
  3649. templateOptions: {
  3650. // checkform: function(options) {
  3651. // if (options.model.requester) {
  3652. // options.value(options.model.requester);
  3653. // }
  3654. // },
  3655. },
  3656. };
  3657. },
  3658. controller: [
  3659. "$scope",
  3660. "api_user_data",
  3661. function ($scope, api_user_data) {
  3662. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3663. $scope.getininform = {
  3664. serialNumbe:
  3665. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3666. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3667. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3668. sourceId:
  3669. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3670. describe:
  3671. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3672. };
  3673. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3674. $scope.getininform.types = "新设备领用出库";
  3675. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3676. $scope.getininform.types = "设备更换";
  3677. }
  3678. $scope.getininform.source_id =
  3679. $scope.$parent.$parent.$parent.model.source.value;
  3680. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3681. $scope.getininform.source = "事件";
  3682. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3683. $scope.getininform.source = "变更";
  3684. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3685. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3686. $scope.getininform.source = "其它";
  3687. }
  3688. },
  3689. ],
  3690. });
  3691. //资产附件上传
  3692. formlyConfigProvider.setType({
  3693. name: "ui-cmdbuplode",
  3694. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3695. wrapper: ["bootstrapHasError"],
  3696. defaultOptions: function (options, $scope) {
  3697. return {
  3698. templateOptions: {
  3699. // checkform: function(options) {
  3700. // if (options.model.requester) {
  3701. // options.value(options.model.requester);
  3702. // }
  3703. // },
  3704. },
  3705. };
  3706. },
  3707. controller: [
  3708. "$scope",
  3709. "$rootScope",
  3710. "$http",
  3711. "SweetAlert",
  3712. "FileUploader",
  3713. "api_user_data",
  3714. "i18nService",
  3715. "$modal",
  3716. "Restangular",
  3717. "api_configure_data",
  3718. "api_cmdb",
  3719. "api_cmdb_new",
  3720. "api_wechatfile",
  3721. "api_sysinfo",
  3722. function (
  3723. $scope,
  3724. $rootScope,
  3725. $http,
  3726. SweetAlert,
  3727. FileUploader,
  3728. api_user_data,
  3729. i18nService,
  3730. $modal,
  3731. Restangular,
  3732. api_configure_data,
  3733. api_cmdb,
  3734. api_cmdb_new,
  3735. api_wechatfile,
  3736. api_sysinfo
  3737. ) {
  3738. $scope.state = 1;
  3739. $scope.myData3all = [];
  3740. $scope.myData3 = [];
  3741. $scope.memoryfilterDatahao = {
  3742. idx: 0,
  3743. sum: 10,
  3744. };
  3745. $scope.selected = {
  3746. items: [],
  3747. };
  3748. $scope.interceptMydata = function (mydate, idx, sum) {
  3749. return mydate.slice(idx * sum, (idx + 1) * sum);
  3750. };
  3751. // $scope.importnext = function() {
  3752. // $scope.state = 2;
  3753. // event.preventDefault();
  3754. // }
  3755. $scope.workspaces = [];
  3756. $scope.options.templateOptions.getpush = function (item) {
  3757. $scope.workspaces = [];
  3758. if (item.gu) {
  3759. $scope.workspaces.push({
  3760. id: 1,
  3761. name: "固定资产",
  3762. active: true,
  3763. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3764. });
  3765. }
  3766. if (item.hao) {
  3767. $scope.workspaces.push({
  3768. id: 2,
  3769. name: "耗材资产",
  3770. active: true,
  3771. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3772. });
  3773. }
  3774. };
  3775. //获取附件列表
  3776. $scope.listAttachmen = function () {
  3777. to.ApiService.listAttachment(
  3778. to.listAttachmentUrl,
  3779. to.bindType,
  3780. bindId
  3781. ).then(function (result) {
  3782. var myData = Restangular.stripRestangular(result);
  3783. // $scope.listAttachmens = myData;
  3784. $scope.attachments = myData.data;
  3785. });
  3786. };
  3787. //附件列表
  3788. if ($scope.options.templateOptions.bindType) {
  3789. if (angular.isUndefined($scope.form.dropState)) {
  3790. $scope.form.dropState = false;
  3791. }
  3792. var to = $scope.options.templateOptions;
  3793. var bindId = $scope.model[to.bindType].processInstanceId;
  3794. $scope.listAttachmen();
  3795. }
  3796. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3797. // $scope.listAttachmen();
  3798. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3799. // $scope.listAttachmen();
  3800. // }
  3801. //附件下载
  3802. $scope.download = function (token, filename) {
  3803. var downUrl = to.ApiService.downloadAttachment(
  3804. to.downUrl,
  3805. token
  3806. ).getRequestedUrl();
  3807. // window.open(downUrl);
  3808. var a = document.createElement("a");
  3809. a.href = downUrl;
  3810. a.target = "_blank";
  3811. a.download = filename;
  3812. document.body.appendChild(a);
  3813. a.click();
  3814. };
  3815. //附件预览
  3816. $scope.view = function (id, previewUrl) {
  3817. if (previewUrl) {
  3818. window.open(previewUrl);
  3819. }
  3820. };
  3821. //下载资产模版
  3822. $scope.filenum = 0;
  3823. $scope.openmeans = function () {
  3824. var modalInstance = $modal.open({
  3825. templateUrl: "assets/views/means/tpl/meansdown.html",
  3826. controller: function ($scope, scope, $modalInstance) {
  3827. $scope.item = {};
  3828. $scope.title = "选择下载模版";
  3829. $scope.lable = "资产模版下载";
  3830. function foreachdata(my_datas) {
  3831. // angular.forEach(my_datas, function(item, index) {
  3832. // if (item.children && item.children.length > 0) {
  3833. // foreachdata(item.children);
  3834. // } else {
  3835. // my_datas[index].checks = true;
  3836. // }
  3837. // })
  3838. for (var i = 0; i < my_datas.length; i++) {
  3839. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3840. foreachdata(my_datas[i].children);
  3841. console.log($scope);
  3842. } else {
  3843. my_datas[i].checks = true;
  3844. }
  3845. }
  3846. }
  3847. function foreachtree(data) {
  3848. angular.forEach(data, function (item) {
  3849. // if (item.checks != true) {
  3850. item.checks = true;
  3851. item.expanded = true;
  3852. if (item.children && item.children.length > 0) {
  3853. foreachtree(item.children);
  3854. } else {
  3855. $scope.getslowtree.push(item);
  3856. }
  3857. // }
  3858. });
  3859. }
  3860. $scope.getslowtree = [];
  3861. $scope.slowtree = function (tree) {
  3862. foreachtree(tree);
  3863. return $scope.getslowtree;
  3864. };
  3865. $scope.all = function (c, v) {
  3866. //全选
  3867. if (c == true) {
  3868. $scope.formdashboard($scope.slowtree(v));
  3869. } else {
  3870. $scope.my_data_after = [];
  3871. angular.forEach($scope.my_data, function (item, index) {
  3872. $scope.my_data[index].checks = false;
  3873. $scope.my_data[index].expanded = false;
  3874. if (item.children && item.children.length > 0) {
  3875. angular.forEach(
  3876. item.children,
  3877. function (itemone, indexone) {
  3878. $scope.my_data[index].children[
  3879. indexone
  3880. ].checks = false;
  3881. $scope.my_data[index].children[
  3882. indexone
  3883. ].expanded = false;
  3884. if (itemone.children && itemone.children.length > 0) {
  3885. angular.forEach(
  3886. itemone.children,
  3887. function (itemtwo, indextwo) {
  3888. $scope.my_data[index].children[
  3889. indexone
  3890. ].children[indextwo].checks = false;
  3891. }
  3892. );
  3893. } else {
  3894. }
  3895. }
  3896. );
  3897. } else {
  3898. }
  3899. });
  3900. $scope.mydatacate = [];
  3901. $scope.getslowtree = [];
  3902. // }
  3903. }
  3904. };
  3905. // $scope.searchone = function(search) {
  3906. // angular.forEach($scope.my_data, function(item) {
  3907. // if (item.indexOf(search) > 0) {
  3908. // }
  3909. // })
  3910. // }
  3911. $scope.checkall = function () {
  3912. angular.forEach($scope.my_data, function (item, index) {
  3913. scope.my_data[index].checks = true;
  3914. });
  3915. };
  3916. $scope.selectitem = [];
  3917. $scope.choiceitem = function (item) {
  3918. // if (item.checkeds) {
  3919. // item.checkeds = false;
  3920. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3921. // // if ($scope.selectitem[i].id == item.id) {
  3922. // // $scope.selectitem.splice(i, 1)
  3923. // // }
  3924. // // }
  3925. // for (var i = 0; i < $scope.my_data_after; i++) {
  3926. // if ($scope.my_data_after[i].id == item.id) {
  3927. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3928. // // $scope.selectitem.splice(i, 1)
  3929. // }
  3930. // }
  3931. // } else {
  3932. // item.checkeds = true;
  3933. // $scope.selectitem.push(item)
  3934. // }
  3935. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3936. if ($scope.my_data_after[i].id == item.id) {
  3937. $scope.my_data_after[i].checkeds
  3938. ? ($scope.my_data_after[i].checkeds = false)
  3939. : ($scope.my_data_after[i].checkeds = true);
  3940. }
  3941. }
  3942. };
  3943. $scope.remove = function (removeitem) {
  3944. var realdat = angular.copy($scope.my_data_after);
  3945. // angular.extend(realdat, $scope.selectitem);
  3946. $scope.my_data_after = [];
  3947. angular.forEach(realdat, function (item) {
  3948. if (!item.checkeds) {
  3949. $scope.my_data_after.push(item);
  3950. }
  3951. });
  3952. $scope.mydatacate = angular.copy($scope.my_data_after);
  3953. };
  3954. $scope.try_async_loads = function (item, search) {
  3955. var fildatas = {
  3956. idx: 0,
  3957. sum: 1000,
  3958. };
  3959. $scope.my_data = [];
  3960. // $scope.try_async_load = true;
  3961. if (item) {
  3962. angular.extend(fildatas, item);
  3963. }
  3964. api_configure_data
  3965. .fetchDataList("ciclassify", fildatas)
  3966. .then(function (response) {
  3967. if (response.status == 200) {
  3968. var data = response.list;
  3969. var objects = [];
  3970. for (var i = 0; i < data.length; i++) {
  3971. var object = {};
  3972. object.id = data[i].id;
  3973. if (search) {
  3974. delete data[i].parent;
  3975. } else {
  3976. if (data[i].parent && data[i].parent.id != 0) {
  3977. object.parent = data[i].parent.id;
  3978. }
  3979. }
  3980. angular.extend(object, data[i]);
  3981. objects.push(object);
  3982. }
  3983. $scope.my_data = convertParentToChildList(objects);
  3984. $scope.tree_data = angular.copy($scope.my_data);
  3985. if ($scope.my_data.length > 0) {
  3986. $scope.try_async_load = false;
  3987. }
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "系统错误!",
  3991. text: "请刷新重试!",
  3992. type: "error",
  3993. });
  3994. }
  3995. });
  3996. };
  3997. function convertListToTree(data, treeMap) {
  3998. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3999. var root = null; //Initially set our loop to null
  4000. //loop over data
  4001. for (var i = 0; i < data.length; i++) {
  4002. var datum = data[i];
  4003. //each node will have children, so let's give it a "children" poperty
  4004. datum.children = [];
  4005. //add an entry for this node to the map so that any future children can
  4006. //lookup the parent
  4007. idToNodeMap[datum.id] = datum;
  4008. //Does this node have a parent?
  4009. // console.log("datum="+JSON.stringify(datum))
  4010. if (
  4011. typeof datum.parent === "undefined" ||
  4012. datum.parent === null
  4013. ) {
  4014. //Doesn't look like it, so this node is the root of the tree
  4015. root = datum;
  4016. treeMap[datum.id] = root;
  4017. } else {
  4018. //This node has a parent, so let's look it up using the id
  4019. parentNode = idToNodeMap[datum.parent.id];
  4020. //We don't need this property, so let's delete it.
  4021. // delete datum.parent;
  4022. //Let's add the current node as a child of the parent node.
  4023. parentNode.children.push(datum);
  4024. }
  4025. }
  4026. return root;
  4027. }
  4028. function convertParentToChildList(data) {
  4029. var treeMap = {};
  4030. var list = [];
  4031. convertListToTree(data, treeMap);
  4032. angular.forEach(treeMap, function (item) {
  4033. list.push(item);
  4034. });
  4035. return list;
  4036. }
  4037. function convertParentToChild(datato) {
  4038. var treeMapto = {};
  4039. var listto = [];
  4040. convertListToTree(datato, treeMapto);
  4041. angular.forEach(treeMapto, function (items) {
  4042. listto.push(items);
  4043. });
  4044. return listto;
  4045. }
  4046. $scope.try_async_loads();
  4047. $scope.searchdown = function (key) {
  4048. if (key && key != "") {
  4049. $scope.try_async_loads(
  4050. {
  4051. ciclassify: {
  4052. label: key,
  4053. },
  4054. },
  4055. "search"
  4056. );
  4057. } else {
  4058. $scope.try_async_loads();
  4059. }
  4060. // var mydatacatedown = angular.copy($scope.my_data);
  4061. // $scope.my_data = [];
  4062. // var objects = [];
  4063. // angular.forEach(mydatacatedown, function(item) {
  4064. // if (item.label.match(key)) {
  4065. // objects.push(item)
  4066. // } else {
  4067. // // $scope.my_data_after.push(item)
  4068. // }
  4069. // })
  4070. // $scope.my_data = convertParentToChildList(objects);
  4071. // $scope.tree_data = angular.copy($scope.my_data);
  4072. };
  4073. $scope.mydatacate = [];
  4074. $scope.searchup = function (key) {
  4075. // var mydatacate = angular.copy($scope.my_data_after);
  4076. $scope.my_data_after = [];
  4077. angular.forEach($scope.mydatacate, function (item) {
  4078. if (item.label.match(key)) {
  4079. $scope.my_data_after.push(item);
  4080. } else {
  4081. }
  4082. });
  4083. };
  4084. //角色树
  4085. $scope.my_tree = [];
  4086. $scope.tree_data_after = [];
  4087. $scope.my_data = [];
  4088. $scope.my_data_after = [];
  4089. $scope.formdashboard = function (item) {
  4090. $scope.my_data_after = [];
  4091. angular.forEach(item, function (infox) {
  4092. if (infox.children.length == 0) {
  4093. $scope.my_data_after.push(infox);
  4094. }
  4095. });
  4096. $scope.mydatacate = angular.copy($scope.my_data_after);
  4097. };
  4098. $scope.ok = function (item) {
  4099. $modalInstance.close(item);
  4100. };
  4101. $scope.cancel = function () {
  4102. $modalInstance.dismiss("cancel");
  4103. };
  4104. },
  4105. // size: 'sm',
  4106. resolve: {
  4107. scope: function () {
  4108. return $scope;
  4109. },
  4110. },
  4111. });
  4112. modalInstance.result.then(function (selectedItem) {
  4113. // $rootScope.isMask = true;
  4114. if (selectedItem) {
  4115. var type = 1;
  4116. var fildat = {
  4117. configure: selectedItem,
  4118. };
  4119. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4120. // // if (data.errno == 0) {
  4121. // var file = new Blob([data], {
  4122. // // 'Accept': '*/*'
  4123. // type: 'application/octet-stream'
  4124. // // type: 'application/vnd.ms-excel'
  4125. // });
  4126. // //trick to download store a file having its URL
  4127. // var fileURL = URL.createObjectURL(file);
  4128. // var a = document.createElement('a');
  4129. // a.href = fileURL;
  4130. // a.target = '_blank';
  4131. // a.download = "资产导入模版.xlsx";
  4132. // document.body.appendChild(a);
  4133. // a.click();
  4134. // // }
  4135. // })
  4136. $http({
  4137. url: api_configure_data
  4138. .downModels("export/cmdb", fildat)
  4139. .getRequestedUrl(),
  4140. method: "POST",
  4141. data: JSON.stringify(fildat),
  4142. headers: {
  4143. // 'Content-type': 'application/xls',
  4144. Accept: "*/*",
  4145. },
  4146. responseType: "arraybuffer",
  4147. })
  4148. .success(function (data, status, headers, config) {
  4149. $rootScope.isMask = false;
  4150. var file = new Blob([data], {
  4151. type: "application/octet-stream",
  4152. // type : 'application/vnd.ms-excel'
  4153. });
  4154. //trick to download store a file having its URL
  4155. var fileURL = URL.createObjectURL(file);
  4156. var a = document.createElement("a");
  4157. a.href = fileURL;
  4158. a.target = "_blank";
  4159. a.download = "资产导入模版.xlsx";
  4160. document.body.appendChild(a);
  4161. a.click();
  4162. })
  4163. .error(function (data, status, headers, config) {
  4164. // console.log(data);
  4165. $rootScope.isMask = false;
  4166. });
  4167. // break;
  4168. // }
  4169. // }
  4170. // }
  4171. // })
  4172. } else {
  4173. SweetAlert.swal(
  4174. {
  4175. title: "未选择资产分类!",
  4176. text: "请选择资产分类",
  4177. type: "error",
  4178. },
  4179. function () {
  4180. $rootScope.isMask = false;
  4181. }
  4182. );
  4183. }
  4184. // }
  4185. });
  4186. };
  4187. $scope.wrongdata = [];
  4188. var uploader = ($scope.uploader =
  4189. $scope.options.templateOptions.fileUploader);
  4190. var uploadermeans = ($scope.uploadermeans =
  4191. $scope.options.templateOptions.fileUploadermeans);
  4192. $scope.importopen = function () {
  4193. //导入触发事件
  4194. if (angular.isUndefined($scope.form.dropState)) {
  4195. $scope.form.dropState = false;
  4196. }
  4197. //附件上传数据
  4198. //$scope.options.templateOptions.uploader();
  4199. // FILTERS
  4200. uploader.filters.push({
  4201. name: "customFilter",
  4202. fn: function (item /*{File|FileLikeObject}*/, options) {
  4203. return this.queue.length < 2;
  4204. },
  4205. });
  4206. // CALLBACKS
  4207. uploader.onWhenAddingFileFailed = function (
  4208. item /*{File|FileLikeObject}*/,
  4209. filter,
  4210. options
  4211. ) {
  4212. console.info("onWhenAddingFileFailed", item, filter, options);
  4213. };
  4214. uploader.onAfterAddingFile = function (fileItem) {
  4215. console.info("onAfterAddingFile", fileItem);
  4216. };
  4217. uploader.onAfterAddingAll = function (addedFileItems) {
  4218. console.info("onAfterAddingAll", addedFileItems);
  4219. };
  4220. uploader.onBeforeUploadItem = function (item) {
  4221. console.info("onBeforeUploadItem", item);
  4222. };
  4223. uploader.onProgressItem = function (fileItem, progress) {
  4224. console.info("onProgressItem", fileItem, progress);
  4225. };
  4226. uploader.onProgressAll = function (progress) {
  4227. console.info("onProgressAll", progress);
  4228. };
  4229. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4230. // console.info('onSuccessItem', fileItem, response, status, headers);
  4231. // };
  4232. uploader.onErrorItem = function (
  4233. fileItem,
  4234. response,
  4235. status,
  4236. headers
  4237. ) {
  4238. console.info("onErrorItem", fileItem, response, status, headers);
  4239. };
  4240. uploader.onCancelItem = function (
  4241. fileItem,
  4242. response,
  4243. status,
  4244. headers
  4245. ) {
  4246. console.info("onCancelItem", fileItem, response, status, headers);
  4247. };
  4248. uploader.onCompleteItem = function (
  4249. fileItem,
  4250. response,
  4251. status,
  4252. headers
  4253. ) {
  4254. console.info("onCompleteItem", fileItem, response, status, headers);
  4255. };
  4256. uploader.onCompleteAll = function () {
  4257. console.info("onCompleteAll");
  4258. };
  4259. };
  4260. // $scope.importnext = function() {
  4261. // $scope.state = 2;
  4262. // event.preventDefault();
  4263. // }
  4264. $scope.importnext = function () {
  4265. event.preventDefault();
  4266. // $rootScope.isMask = true;
  4267. $rootScope.loading = true;
  4268. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4269. uploader.onBeforeUploadItem = function (item) {
  4270. angular.extend(item.headers, $rootScope.getSession());
  4271. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4272. // if (item.index > 1) {
  4273. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4274. // }
  4275. // item.index = 1;
  4276. item.formData = [
  4277. {
  4278. filename: item.file.name,
  4279. },
  4280. ];
  4281. console.info("onBeforeUploadItem", item);
  4282. };
  4283. uploader.uploadAll();
  4284. uploader.onSuccessItem = function (
  4285. fileItem,
  4286. response,
  4287. status,
  4288. headers
  4289. ) {
  4290. if (response.status == 200) {
  4291. $scope.wrongdata = [];
  4292. $rootScope.loading = false;
  4293. if (response.abnormal) {
  4294. $scope.state = 2;
  4295. angular.forEach(response.msg, function (item) {
  4296. $scope.wrongdata.push({
  4297. name: item.assetName,
  4298. line: item.row,
  4299. cmdbname: item.name,
  4300. errotip: [
  4301. {
  4302. label: item.msg,
  4303. },
  4304. ],
  4305. });
  4306. });
  4307. } else {
  4308. $scope.state = 3;
  4309. }
  4310. } else {
  4311. $rootScope.loading = false;
  4312. $scope.state = 2;
  4313. }
  4314. };
  4315. };
  4316. $scope.clearItems = function () {
  4317. //重新选择文件时,清空队列,达到覆盖文件的效果
  4318. uploader.clearQueue();
  4319. // uploader.remove();
  4320. // uploader.cancel();
  4321. // uploader.onChange();
  4322. };
  4323. uploader.onAfterAddingFile = function (fileItem) {
  4324. $scope.fileItem = fileItem._file;
  4325. // $scope.$apply();
  4326. // $scope.fileItem = filenum;
  4327. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4328. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4329. $scope.filenum++;
  4330. };
  4331. uploader.onSuccessItem = function (
  4332. fileItem,
  4333. response,
  4334. status,
  4335. headers
  4336. ) {
  4337. $scope.uploadStatus = true; //上传成功则把状态改为true
  4338. // alert(response.path);
  4339. };
  4340. $scope.importnext = function () {
  4341. event.preventDefault();
  4342. // uploader.onChange();
  4343. $rootScope.loading = true;
  4344. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4345. uploader.onBeforeUploadItem = function (item) {
  4346. angular.extend(item.headers, $rootScope.getSession());
  4347. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4348. // if (item.index > 1) {
  4349. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4350. // }
  4351. // item.index = 1;
  4352. item.formData = [
  4353. {
  4354. filename: item.file.name,
  4355. },
  4356. ];
  4357. console.info("onBeforeUploadItem", item);
  4358. };
  4359. uploader.uploadAll();
  4360. uploader.onSuccessItem = function (
  4361. fileItem,
  4362. response,
  4363. status,
  4364. headers
  4365. ) {
  4366. if (response.status == 200) {
  4367. $scope.wrongdata = [];
  4368. // uploader.queue = [];
  4369. $rootScope.loading = false;
  4370. if (response.abnormal) {
  4371. $scope.state = 2;
  4372. uploader.clearQueue();
  4373. angular.forEach(response.msg, function (item) {
  4374. $scope.wrongdata.push({
  4375. name: item.assetName,
  4376. line: item.row,
  4377. cmdbname: item.name,
  4378. errotip: [
  4379. {
  4380. label: item.msg,
  4381. },
  4382. ],
  4383. });
  4384. });
  4385. } else {
  4386. $scope.state = 3;
  4387. }
  4388. } else {
  4389. uploader.clearQueue();
  4390. $rootScope.loading = false;
  4391. $scope.state = 2;
  4392. }
  4393. };
  4394. };
  4395. var setAllInactive = function () {
  4396. angular.forEach($scope.workspaces, function (workspace) {
  4397. workspace.active = false;
  4398. });
  4399. };
  4400. //添加
  4401. var addNewWorkspace = function (name, contentUrl) {
  4402. var id = $scope.workspaces.length + 1;
  4403. $scope.workspaces.push({
  4404. id: id,
  4405. name: name,
  4406. active: true,
  4407. contentUrl: "main/html/content.html",
  4408. });
  4409. };
  4410. //关闭
  4411. $scope.closeopen = function (closedata) {
  4412. event.preventDefault();
  4413. angular.forEach($scope.workspaces, function (item, index) {
  4414. if (closedata.id == item.id) {
  4415. if (closedata.id == 1) {
  4416. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4417. } else {
  4418. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4419. }
  4420. $scope.workspaces.splice(index, 1);
  4421. }
  4422. });
  4423. };
  4424. // $scope.workspaces = [
  4425. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4426. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4427. // ];
  4428. $scope.addWorkspace = function (contentUrl, name) {
  4429. setAllInactive();
  4430. addNewWorkspace(name, contentUrl);
  4431. };
  4432. // $rootScope.addWorkspace = $scope.addWorkspace;
  4433. $scope.close = function (idNumber) {
  4434. var index = 0; //记录当前元素下标
  4435. angular.forEach($scope.workspaces, function (workspace) {
  4436. if (workspace.id === idNumber) {
  4437. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4438. }
  4439. index++;
  4440. });
  4441. };
  4442. //grid2
  4443. $scope.langs = i18nService.getAllLangs();
  4444. $scope.lang = "zh-cn";
  4445. i18nService.setCurrentLang($scope.lang);
  4446. $scope.gridOptions2 = {};
  4447. $scope.gridOptions2.data = "myData3";
  4448. $scope.gridOptions2.enableColumnResizing = true;
  4449. $scope.gridOptions2.enableFiltering = false;
  4450. $scope.gridOptions2.enableGridMenu = false;
  4451. $scope.gridOptions2.showGridFooter = true;
  4452. $scope.gridOptions2.showColumnFooter = false;
  4453. $scope.gridOptions2.fastWatch = true;
  4454. $scope.gridOptions2.useExternalFiltering = true;
  4455. $scope.gridOptions2.useExternalPagination = true;
  4456. $scope.gridOptions2.paginationPageSizes = [10];
  4457. $scope.gridOptions2.paginationPageSize = 10;
  4458. $scope.gridOptions2.multiSelect = false;
  4459. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4460. $scope.gridOptions2.columnDefs = [
  4461. {
  4462. name: "item",
  4463. displayName: "序号",
  4464. width: 120,
  4465. },
  4466. {
  4467. name: "name",
  4468. displayName: "耗材名称",
  4469. width: 80,
  4470. enableFiltering: false,
  4471. },
  4472. {
  4473. name: "model",
  4474. displayName: "品牌/型号",
  4475. width: 100,
  4476. enableFiltering: false,
  4477. },
  4478. {
  4479. name: "Specifications",
  4480. displayName: "规格",
  4481. width: 150,
  4482. enableFiltering: false,
  4483. },
  4484. {
  4485. name: "sum",
  4486. displayName: "数量",
  4487. enableFiltering: false,
  4488. },
  4489. {
  4490. name: "操作",
  4491. cellTemplate:
  4492. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4493. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4494. "</div></div>",
  4495. enableFiltering: false,
  4496. },
  4497. ];
  4498. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4499. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4500. $scope.myData3all = JSON.parse(
  4501. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4502. );
  4503. for (var i = 0; i < $scope.myData3all.length; i++) {
  4504. $scope.myData3all[i]["item"] =
  4505. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4506. }
  4507. // $scope.model.consumables = $scope.myDataone;
  4508. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4509. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4510. $scope.model.applicationForm.consumables = $scope.myData3all;
  4511. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4512. $scope.options.templateOptions.getpush({
  4513. hao: true,
  4514. gu: true,
  4515. });
  4516. } else {
  4517. $scope.options.templateOptions.getpush({
  4518. hao: true,
  4519. });
  4520. }
  4521. } else {
  4522. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4523. $scope.options.templateOptions.getpush({
  4524. gu: true,
  4525. });
  4526. }
  4527. }
  4528. }
  4529. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4530. $scope.changecai = function (item) {
  4531. event.preventDefault();
  4532. var modalInstance = $modal.open({
  4533. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4534. controller: function ($scope, $modalInstance) {
  4535. $scope.title = "修改耗材数量";
  4536. $scope.consumptive = angular.copy(item);
  4537. $scope.ok = function () {
  4538. $modalInstance.close($scope.consumptive);
  4539. };
  4540. $scope.cancel = function () {
  4541. $modalInstance.dismiss("cancel");
  4542. };
  4543. },
  4544. size: "sm",
  4545. });
  4546. modalInstance.result.then(function (selectedItem) {
  4547. // angular.forEach($scope.myData3, function(items, index) {
  4548. // if (items.id == selectedItem.id) {
  4549. // $scope.myData3[index] = selectedItem;
  4550. // }
  4551. // })
  4552. // // $scope.myData3.push(selectedItem);
  4553. // $scope.model.applicationForm.consumables = $scope.myData3;
  4554. angular.forEach($scope.myData3all, function (items, index) {
  4555. if (
  4556. items.modelid == selectedItem.modelid &&
  4557. items.nameid == selectedItem.nameid &&
  4558. items.Specificationsid == selectedItem.Specificationsid
  4559. ) {
  4560. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4561. angular.extend($scope.myData3all[index], selectedItem);
  4562. }
  4563. });
  4564. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4565. $scope.myData3 = $scope.interceptMydata(
  4566. $scope.myData3all,
  4567. $scope.memoryfilterDatahao.idx,
  4568. 10
  4569. );
  4570. $scope.model.applicationForm.consumables = $scope.myData3all;
  4571. });
  4572. };
  4573. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4574. $scope.gridApi = gridApi;
  4575. gridApi.pagination.on.paginationChanged(
  4576. $scope,
  4577. function (newPage, pageSize) {
  4578. // var filtersData = $scope.memoryfilterDatahao;
  4579. // filtersData.idx = newPage - 1;
  4580. // filtersData.sum = pageSize;
  4581. // $scope.loadData(filtersData);
  4582. $scope.memoryfilterDatahao.idx = newPage - 1;
  4583. $scope.memoryfilterDatahao.sum = pageSize;
  4584. $scope.myData3 = $scope.interceptMydata(
  4585. $scope.myData3all,
  4586. $scope.memoryfilterDatahao.idx,
  4587. 10
  4588. );
  4589. }
  4590. );
  4591. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4592. $scope.selected.items = data.entity;
  4593. //console.log(data);
  4594. });
  4595. gridApi.selection.on.rowSelectionChangedBatch(
  4596. $scope,
  4597. function (data) {
  4598. $scope.selected.items = data.entity;
  4599. //console.log(data);
  4600. }
  4601. );
  4602. gridApi.core.on.filterChanged($scope, function () {
  4603. var grid = this.grid;
  4604. var filtersData = {
  4605. idx: 0,
  4606. sum: 10,
  4607. };
  4608. $scope.memoryfilterDatahao = filtersData;
  4609. // $scope.loadData(filtersData);
  4610. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4611. // $scope.memoryfilterDatahao.sum = pageSize;
  4612. $scope.myData3 = $scope.interceptMydata(
  4613. $scope.myData3all,
  4614. $scope.memoryfilterDatahao.idx,
  4615. 10
  4616. );
  4617. });
  4618. };
  4619. $scope.haocaiopen = function (items) {
  4620. event.preventDefault();
  4621. var modalInstance = $modal.open({
  4622. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4623. controller: function ($scope, $modalInstance, SweetAlert) {
  4624. $scope.consumptive = {};
  4625. $scope.title = "新增耗材";
  4626. if (items.name) {
  4627. $scope.consumptive.name = items.name.name;
  4628. }
  4629. $scope.clearNoNum = function (obj, attr) {
  4630. //先把非数字的都替换掉,除了数字和.
  4631. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4632. //必须保证第一个为数字而不是.
  4633. obj[attr] = obj[attr].replace(/^\./g, "");
  4634. //保证只有出现一个.而没有多个.
  4635. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4636. //保证.只出现一次,而不能出现两次以上
  4637. obj[attr] = obj[attr]
  4638. .replace(".", "$#$")
  4639. .replace(/\./g, "")
  4640. .replace("$#$", ".");
  4641. //小于最大值
  4642. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4643. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4644. // obj[attr] = '';
  4645. // }
  4646. };
  4647. $scope.ok = function (item) {
  4648. // if (item.name && item.model && item.Specifications && item.sum) {
  4649. if (
  4650. item.name &&
  4651. item.model &&
  4652. JSON.stringify(item.model) != "{}" &&
  4653. item.Specifications &&
  4654. JSON.stringify(item.Specifications) != "{}" &&
  4655. item.sum
  4656. ) {
  4657. $modalInstance.close(item);
  4658. } else {
  4659. SweetAlert.swal({
  4660. title: "数据填写不完整!",
  4661. text: "请检查数据然后提交!",
  4662. type: "error",
  4663. });
  4664. }
  4665. };
  4666. $scope.cancel = function () {
  4667. $modalInstance.dismiss("cancel");
  4668. };
  4669. },
  4670. size: "sm",
  4671. resolve: {
  4672. SweetAlert: function () {
  4673. return SweetAlert;
  4674. },
  4675. },
  4676. });
  4677. modalInstance.result.then(function (selectedItem) {
  4678. api_sysinfo
  4679. .addData("dictionaryTree", {
  4680. // "type": "list",
  4681. key: "haocaifenlei",
  4682. name: selectedItem.name,
  4683. parent: selectedItem.id,
  4684. value: selectedItem.name,
  4685. deleted: false,
  4686. level: 1,
  4687. })
  4688. .then(function (data) {
  4689. // $scope.haocainame.name = data.list;
  4690. api_sysinfo
  4691. .addData("dictionaryTree", {
  4692. // "type": "list",
  4693. key: "pinpai",
  4694. name: selectedItem.model,
  4695. parent: data.id,
  4696. value: selectedItem.model,
  4697. deleted: false,
  4698. level: 2,
  4699. })
  4700. .then(function (data) {
  4701. // $scope.haocainame = data.list;
  4702. });
  4703. api_sysinfo
  4704. .addData({
  4705. // "type": "list",
  4706. key: "guige",
  4707. name: selectedItem.Specifications,
  4708. parent: data.id,
  4709. value: selectedItem.Specifications,
  4710. deleted: false,
  4711. level: 2,
  4712. })
  4713. .then(function (data) {
  4714. // $scope.haocainame = data.list;
  4715. });
  4716. });
  4717. // $scope.myData3.push(selectedItem);
  4718. // for (var i = 0; i < $scope.myData3.length; i++) {
  4719. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4720. // }
  4721. // $scope.model.applicationForm.consumables = $scope.myData3;
  4722. $scope.myData3all.push(selectedItem);
  4723. for (var i = 0; i < $scope.myData3all.length; i++) {
  4724. $scope.myData3all[i]["item"] = i + 1;
  4725. }
  4726. // $scope.model.consumables = $scope.myDataone;
  4727. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4728. $scope.myData3 = $scope.interceptMydata(
  4729. $scope.myData3all,
  4730. $scope.memoryfilterDatahao.idx,
  4731. 10
  4732. );
  4733. $scope.model.applicationForm.consumables = $scope.myData3all;
  4734. });
  4735. };
  4736. $scope.haocaiadd = function () {
  4737. event.preventDefault();
  4738. var modalInstance = $modal.open({
  4739. templateUrl:
  4740. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4741. controller: function (
  4742. $scope,
  4743. scope,
  4744. $modalInstance,
  4745. api_wechatfile,
  4746. SweetAlert,
  4747. api_cmdb3
  4748. ) {
  4749. $scope.haocainame = [];
  4750. $scope.pinpai = [];
  4751. $scope.guige = [];
  4752. $scope.consumptive = {};
  4753. $scope.consumpall = {};
  4754. $scope.title = "添加耗材";
  4755. api_wechatfile
  4756. .getDictionary({
  4757. key: "haocaifenlei",
  4758. type: "tree",
  4759. })
  4760. .then(function (data) {
  4761. $scope.haocainame = data;
  4762. });
  4763. $scope.clearNoNum = function (obj, attr) {
  4764. //先把非数字的都替换掉,除了数字和.
  4765. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4766. //必须保证第一个为数字而不是.
  4767. obj[attr] = obj[attr].replace(/^\./g, "");
  4768. //保证只有出现一个.而没有多个.
  4769. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4770. //保证.只出现一次,而不能出现两次以上
  4771. obj[attr] = obj[attr]
  4772. .replace(".", "$#$")
  4773. .replace(/\./g, "")
  4774. .replace("$#$", ".");
  4775. //小于最大值
  4776. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4777. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4778. // obj[attr] = '';
  4779. // }
  4780. };
  4781. $scope.onChange = function (parent) {
  4782. $scope.consumptive.model = {};
  4783. $scope.consumptive.Specifications = {};
  4784. api_wechatfile
  4785. .getDictionaryForList({
  4786. key: "pinpai",
  4787. parent: parent.id,
  4788. })
  4789. .then(function (data) {
  4790. $scope.pinpai = data;
  4791. });
  4792. api_wechatfile
  4793. .getDictionaryForList({
  4794. key: "guige",
  4795. parent: parent.id,
  4796. })
  4797. .then(function (data) {
  4798. $scope.guige = data;
  4799. });
  4800. };
  4801. $scope.addhaocai = function () {
  4802. $modalInstance.dismiss("cancel");
  4803. scope.haocaiopen($scope.consumptive);
  4804. };
  4805. $scope.ok = function (item) {
  4806. var items = {};
  4807. var submittrue = true;
  4808. if (
  4809. item.name &&
  4810. item.model &&
  4811. JSON.stringify(item.model) != "{}" &&
  4812. item.Specifications &&
  4813. JSON.stringify(item.Specifications) != "{}" &&
  4814. item.sum
  4815. ) {
  4816. items = {
  4817. modelid: item.model.id,
  4818. nameid: item.name.id,
  4819. Specificationsid: item.Specifications.id,
  4820. name: item.name.name,
  4821. model: item.model.name,
  4822. Specifications: item.Specifications.name,
  4823. sum: item.sum,
  4824. };
  4825. angular.forEach(scope.myData3all, function (itemsdata) {
  4826. if (
  4827. item.model.id == itemsdata.modelid &&
  4828. item.name.id == itemsdata.nameid &&
  4829. item.Specifications.id == itemsdata.Specificationsid
  4830. ) {
  4831. submittrue = false;
  4832. }
  4833. });
  4834. if (submittrue) {
  4835. $modalInstance.close(items);
  4836. } else {
  4837. SweetAlert.swal({
  4838. title: "该耗材已有添加",
  4839. text: "请检查数据然后提交!",
  4840. type: "error",
  4841. });
  4842. }
  4843. } else {
  4844. SweetAlert.swal({
  4845. title: "数据填写不完整!",
  4846. text: "请检查数据然后提交!",
  4847. type: "error",
  4848. });
  4849. }
  4850. // var isold = false;
  4851. // if (item.name && item.model && item.Specifications && item.sum) {
  4852. // for (var i = 0; i < scope.myData3all.length; i++) {
  4853. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4854. // isold = true;
  4855. // }
  4856. // }
  4857. // if (isold) {
  4858. // SweetAlert.swal({
  4859. // title: "该耗材已添加!",
  4860. // text: "请不要重复添加耗材!",
  4861. // type: "error"
  4862. // });
  4863. // } else {
  4864. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4865. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4866. // $scope.consumpall.sum = item.sum;
  4867. // delete $scope.consumpall.brandModel;
  4868. // delete $scope.consumpall.specification;
  4869. // $modalInstance.close($scope.consumpall);
  4870. // }
  4871. // } else {
  4872. // SweetAlert.swal({
  4873. // title: "数据填写不完整!",
  4874. // text: "请检查数据然后提交!",
  4875. // type: "error"
  4876. // });
  4877. // }
  4878. };
  4879. $scope.cancel = function () {
  4880. $modalInstance.dismiss("cancel");
  4881. };
  4882. },
  4883. size: "sm",
  4884. resolve: {
  4885. scope: function () {
  4886. return $scope;
  4887. },
  4888. },
  4889. });
  4890. modalInstance.result.then(function (selectedItem) {
  4891. $scope.myData3all.push(selectedItem);
  4892. for (var i = 0; i < $scope.myData3all.length; i++) {
  4893. $scope.myData3all[i]["item"] = i + 1;
  4894. }
  4895. // $scope.model.consumables = $scope.myDataone;
  4896. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4897. $scope.myData3 = $scope.interceptMydata(
  4898. $scope.myData3all,
  4899. $scope.memoryfilterDatahao.idx,
  4900. 10
  4901. );
  4902. $scope.model.applicationForm.consumables = $scope.myData3all;
  4903. });
  4904. };
  4905. $scope.onDblClick = function (data, event) {
  4906. $scope.selectButtonClick(data, event);
  4907. };
  4908. // $scope.memoryfilterDatahao = {
  4909. // "idx": 0,
  4910. // "sum": 10,
  4911. // }
  4912. // $scope.loadData = function(filterData) {};
  4913. // $scope.title = title;
  4914. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4915. $scope.options.templateOptions.transform(
  4916. $scope.options,
  4917. $rootScope,
  4918. $scope
  4919. );
  4920. }
  4921. },
  4922. ],
  4923. });
  4924. //归还设备耗材tab
  4925. formlyConfigProvider.setType({
  4926. name: "ui-cmdbreturntab",
  4927. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4928. wrapper: ["bootstrapHasError"],
  4929. defaultOptions: function (options, $scope) {
  4930. return {
  4931. templateOptions: {
  4932. // checkform: function(options) {
  4933. // if (options.model.requester) {
  4934. // options.value(options.model.requester);
  4935. // }
  4936. // },
  4937. },
  4938. };
  4939. },
  4940. controller: [
  4941. "$scope",
  4942. "$modal",
  4943. "api_user_data",
  4944. "i18nService",
  4945. "api_wechatfile",
  4946. "api_cmdb3",
  4947. function (
  4948. $scope,
  4949. $modal,
  4950. api_user_data,
  4951. i18nService,
  4952. api_wechatfile,
  4953. api_cmdb3
  4954. ) {
  4955. var setAllInactive = function () {
  4956. angular.forEach($scope.workspaces, function (workspace) {
  4957. workspace.active = false;
  4958. });
  4959. };
  4960. $scope.memoryfilterData = {
  4961. idx: 0,
  4962. sum: 10,
  4963. };
  4964. //添加
  4965. var addNewWorkspace = function (name, contentUrl) {
  4966. var id = $scope.workspaces.length + 1;
  4967. $scope.workspaces.push({
  4968. id: id,
  4969. name: name,
  4970. active: true,
  4971. contentUrl: "main/html/content.html",
  4972. });
  4973. };
  4974. $scope.workspaces = [
  4975. {
  4976. id: 1,
  4977. name: "归还设备",
  4978. active: true,
  4979. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4980. },
  4981. {
  4982. id: 2,
  4983. name: "归还耗材",
  4984. active: true,
  4985. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4986. },
  4987. ];
  4988. $scope.addWorkspace = function (contentUrl, name) {
  4989. setAllInactive();
  4990. addNewWorkspace(name, contentUrl);
  4991. };
  4992. // $rootScope.addWorkspace = $scope.addWorkspace;
  4993. $scope.close = function (idNumber) {
  4994. var index = 0; //记录当前元素下标
  4995. angular.forEach($scope.workspaces, function (workspace) {
  4996. if (workspace.id === idNumber) {
  4997. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4998. }
  4999. index++;
  5000. });
  5001. };
  5002. $scope.memoryfilterDataguishe = {
  5003. idx: 0,
  5004. sum: 10,
  5005. };
  5006. //grid1
  5007. $scope.langs = i18nService.getAllLangs();
  5008. $scope.lang = "zh-cn";
  5009. i18nService.setCurrentLang($scope.lang);
  5010. $scope.gridOptions1 = {};
  5011. $scope.gridOptions1.data = "myData1";
  5012. $scope.gridOptions1.enableColumnResizing = true;
  5013. $scope.gridOptions1.enableFiltering = false;
  5014. $scope.gridOptions1.enableGridMenu = false;
  5015. $scope.gridOptions1.showGridFooter = true;
  5016. $scope.gridOptions1.showColumnFooter = false;
  5017. $scope.gridOptions1.fastWatch = true;
  5018. $scope.gridOptions1.useExternalFiltering = true;
  5019. $scope.gridOptions1.useExternalPagination = true;
  5020. $scope.gridOptions1.paginationPageSizes = [10];
  5021. $scope.gridOptions1.paginationPageSize = 10;
  5022. $scope.gridOptions1.multiSelect = false;
  5023. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5024. $scope.gridOptions1.columnDefs = [
  5025. {
  5026. name: "item",
  5027. displayName: "序号",
  5028. width: 120,
  5029. },
  5030. {
  5031. name: "props.hw_cifilterClassic",
  5032. displayName: "设备类型",
  5033. width: 150,
  5034. enableFiltering: false,
  5035. },
  5036. {
  5037. name: "props.hw_mingcheng",
  5038. displayName: "设备名称",
  5039. width: 180,
  5040. enableFiltering: false,
  5041. },
  5042. {
  5043. name: "uuid",
  5044. displayName: "设备编号",
  5045. width: 180,
  5046. enableFiltering: false,
  5047. },
  5048. {
  5049. name: "props.hw_state",
  5050. width: 150,
  5051. displayName: "状态",
  5052. enableFiltering: false,
  5053. },
  5054. {
  5055. name: "操作",
  5056. cellTemplate:
  5057. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5058. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5059. "</div></div>",
  5060. enableFiltering: false,
  5061. },
  5062. ];
  5063. // $scope.selectButtonClick
  5064. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5065. $scope.gridApi = gridApi;
  5066. gridApi.pagination.on.paginationChanged(
  5067. $scope,
  5068. function (newPage, pageSize) {
  5069. // var filtersData = $scope.memoryfilterData;
  5070. // filtersData.idx = newPage - 1;
  5071. // filtersData.sum = pageSize;
  5072. // $scope.loadData(filtersData);
  5073. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5074. $scope.memoryfilterDataguishe.sum = pageSize;
  5075. $scope.myData1 = $scope.interceptMydata(
  5076. $scope.myData2all,
  5077. $scope.memoryfilterDataguishe.idx,
  5078. 10
  5079. );
  5080. }
  5081. );
  5082. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5083. $scope.selected.items = data.entity;
  5084. //console.log(data);
  5085. });
  5086. gridApi.selection.on.rowSelectionChangedBatch(
  5087. $scope,
  5088. function (data) {
  5089. $scope.selected.items = data.entity;
  5090. //console.log(data);
  5091. }
  5092. );
  5093. gridApi.core.on.filterChanged($scope, function () {
  5094. // var grid = this.grid;
  5095. // var filtersData = {
  5096. // idx: 0,
  5097. // sum: 20,
  5098. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5099. // };
  5100. // angular.forEach(grid.columns, function(item) {
  5101. // if (item.enableFiltering) {
  5102. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5103. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5104. // if (angular.isUndefined(filtersData['user'])) {
  5105. // filtersData['user'] = {};
  5106. // }
  5107. // filtersData['user'][item.field] = item.filters[0].term;
  5108. // }
  5109. // }
  5110. // });
  5111. // $scope.memoryfilterData = filtersData;
  5112. // $scope.loadData(filtersData);
  5113. });
  5114. };
  5115. $scope.changegu = function (item) {
  5116. event.preventDefault();
  5117. var modalInstance = $modal.open({
  5118. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5119. controller: function ($scope, $modalInstance) {
  5120. $scope.title = "修改设备状态";
  5121. $scope.hw_state = {};
  5122. if (item.status) {
  5123. $scope.hw_state.name = item.hw_state;
  5124. }
  5125. // $scope.consumptive = item;
  5126. $scope.stateshe = [
  5127. {
  5128. id: 2,
  5129. name: "在库",
  5130. },
  5131. {
  5132. id: 4,
  5133. name: "报修",
  5134. },
  5135. {
  5136. id: 3,
  5137. name: "报废",
  5138. },
  5139. ];
  5140. $scope.ok = function (item) {
  5141. $modalInstance.close($scope.hw_state);
  5142. };
  5143. $scope.cancel = function () {
  5144. $modalInstance.dismiss("cancel");
  5145. };
  5146. },
  5147. size: "sm",
  5148. });
  5149. modalInstance.result.then(function (selectedItem) {
  5150. angular.forEach($scope.myData1, function (items, index) {
  5151. if (items.id == item.id) {
  5152. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5153. }
  5154. });
  5155. $scope.model.assets = $scope.myData1;
  5156. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5157. $scope.model.assets;
  5158. });
  5159. };
  5160. $scope.onDblClick = function (data, event) {
  5161. $scope.selectButtonClick(data, event);
  5162. };
  5163. $scope.memoryfilterData = {
  5164. idx: 0,
  5165. sum: 10,
  5166. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5167. };
  5168. // $scope.myData = {};
  5169. $scope.loadData = function (filterData) { };
  5170. // $scope.title = title;
  5171. $scope.loadData({
  5172. idx: 0,
  5173. sum: 10,
  5174. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5175. });
  5176. $scope.selected = {
  5177. items: [],
  5178. };
  5179. $scope.myData2 = [];
  5180. $scope.consumptive = {};
  5181. $scope.myDataguibeiall = [];
  5182. $scope.haocaiopen = function (items) {
  5183. event.preventDefault();
  5184. var modalInstance = $modal.open({
  5185. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5186. controller: function (
  5187. $scope,
  5188. $modalInstance,
  5189. SweetAlert,
  5190. api_wechatfile,
  5191. api_sysinfo
  5192. ) {
  5193. $scope.consumptive = {};
  5194. $scope.title = "新增耗材";
  5195. if (items.name) {
  5196. $scope.consumptive.name = items.name.name;
  5197. }
  5198. $scope.ok = function (item) {
  5199. if (
  5200. item.name &&
  5201. item.model &&
  5202. JSON.stringify(item.model) != "{}" &&
  5203. item.Specifications &&
  5204. JSON.stringify(item.Specifications) != "{}" &&
  5205. item.sum
  5206. ) {
  5207. $modalInstance.close(item);
  5208. } else {
  5209. SweetAlert.swal({
  5210. title: "数据填写不完整!",
  5211. text: "请检查数据然后提交!",
  5212. type: "error",
  5213. });
  5214. }
  5215. };
  5216. $scope.cancel = function () {
  5217. $modalInstance.dismiss("cancel");
  5218. };
  5219. },
  5220. size: "sm",
  5221. });
  5222. modalInstance.result.then(function (selectedItem) {
  5223. api_sysinfo
  5224. .addData({
  5225. type: "list",
  5226. key: "haocaifenlei",
  5227. name: selectedItem.name,
  5228. parent: selectedItem.id,
  5229. value: "1",
  5230. })
  5231. .then(function (data) {
  5232. // $scope.haocainame.name = data.list;
  5233. api_wechatfile
  5234. .addDictionary({
  5235. type: "list",
  5236. key: "pinpai",
  5237. name: selectedItem.model,
  5238. parent: data.id,
  5239. value: "1",
  5240. })
  5241. .then(function (data) {
  5242. // $scope.haocainame = data.list;
  5243. });
  5244. api_wechatfile
  5245. .addDictionary({
  5246. type: "list",
  5247. key: "guige",
  5248. name: selectedItem.Specifications,
  5249. parent: data.id,
  5250. value: "1",
  5251. })
  5252. .then(function (data) {
  5253. // $scope.haocainame = data.list;
  5254. });
  5255. });
  5256. $scope.myData2.push(selectedItem);
  5257. for (var i = 0; i < $scope.myData2.length; i++) {
  5258. $scope.myData2[i]["item"] =
  5259. i + 1 + $scope.memoryfilterData.idx * 10;
  5260. }
  5261. // $scope.model.applicationForm.consumables = $scope.myData2;
  5262. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5263. if (items.id == selectedItem.id) {
  5264. $scope.myDataguibeiall.splice(index, 1);
  5265. }
  5266. });
  5267. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5268. $scope.model.consumables = $scope.myDataguibeiall;
  5269. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5270. $scope.model.consumables;
  5271. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5272. });
  5273. };
  5274. //grid2
  5275. $scope.langs = i18nService.getAllLangs();
  5276. $scope.lang = "zh-cn";
  5277. i18nService.setCurrentLang($scope.lang);
  5278. $scope.gridOptions2 = {};
  5279. $scope.gridOptions2.data = "myData2";
  5280. $scope.gridOptions2.enableColumnResizing = true;
  5281. $scope.gridOptions2.enableFiltering = false;
  5282. $scope.gridOptions2.enableGridMenu = false;
  5283. $scope.gridOptions2.showGridFooter = true;
  5284. $scope.gridOptions2.showColumnFooter = false;
  5285. $scope.gridOptions2.fastWatch = true;
  5286. $scope.gridOptions2.useExternalFiltering = true;
  5287. $scope.gridOptions2.useExternalPagination = true;
  5288. $scope.gridOptions2.paginationPageSizes = [10];
  5289. $scope.gridOptions2.paginationPageSize = 10;
  5290. $scope.gridOptions2.multiSelect = false;
  5291. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5292. $scope.modelcons = {};
  5293. $scope.modelass = {};
  5294. $scope.myData2all = [];
  5295. $scope.myData1all = [];
  5296. $scope.memoryfilterDatagui = {
  5297. idx: 0,
  5298. sum: 10,
  5299. };
  5300. setInterval(function () {
  5301. if ($scope.model.assets) {
  5302. if (
  5303. $scope.model.assets != $scope.modelass &&
  5304. typeof $scope.model.assets == "string"
  5305. ) {
  5306. $scope.modelass = $scope.model.assets;
  5307. if (JSON.stringify($scope.model.assets) == "{}") {
  5308. $scope.model.assets = [];
  5309. } else {
  5310. $scope.model.assets = JSON.parse($scope.model.assets);
  5311. }
  5312. // $scope.myData1 = $scope.model.assets;
  5313. // for (var i = 0; i < $scope.myData1.length; i++) {
  5314. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5315. // }
  5316. $scope.myData1all = $scope.model.assets;
  5317. for (var i = 0; i < $scope.myData1all.length; i++) {
  5318. $scope.myData1all[i]["item"] =
  5319. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5320. }
  5321. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5322. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5323. }
  5324. }
  5325. if ($scope.model.consumables) {
  5326. if (
  5327. $scope.model.consumables != $scope.modelcons &&
  5328. typeof $scope.model.consumables == "string"
  5329. ) {
  5330. $scope.modelass = $scope.model.consumables;
  5331. if (JSON.stringify($scope.model.consumables) == "{}") {
  5332. $scope.model.consumables = [];
  5333. } else {
  5334. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5335. }
  5336. // $scope.myData2 = $scope.model.consumables;
  5337. // for (var i = 0; i < $scope.myData2.length; i++) {
  5338. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5339. // }
  5340. $scope.myData2all = $scope.model.consumables;
  5341. for (var i = 0; i < $scope.myData2all.length; i++) {
  5342. $scope.myData2all[i]["item"] =
  5343. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5344. }
  5345. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5346. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5347. // $scope.model.consumables = $scope.myData2all;
  5348. }
  5349. }
  5350. }, 100);
  5351. $scope.gridOptions2.columnDefs = [
  5352. {
  5353. name: "item",
  5354. displayName: "序号",
  5355. width: 120,
  5356. },
  5357. {
  5358. name: "name",
  5359. displayName: "耗材名称",
  5360. width: 180,
  5361. enableFiltering: false,
  5362. },
  5363. {
  5364. name: "model",
  5365. displayName: "品牌/型号",
  5366. width: 180,
  5367. enableFiltering: false,
  5368. },
  5369. {
  5370. name: "Specifications",
  5371. displayName: "规格",
  5372. width: 150,
  5373. enableFiltering: false,
  5374. },
  5375. {
  5376. name: "sum",
  5377. width: 150,
  5378. displayName: "数量",
  5379. enableFiltering: false,
  5380. },
  5381. {
  5382. name: "操作",
  5383. cellTemplate:
  5384. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5385. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5386. "</div></div>",
  5387. enableFiltering: false,
  5388. },
  5389. ];
  5390. // $scope.selectButtonClick
  5391. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5392. $scope.gridApi = gridApi;
  5393. gridApi.pagination.on.paginationChanged(
  5394. $scope,
  5395. function (newPage, pageSize) {
  5396. // var filtersData = $scope.memoryfilterDatagui;
  5397. // filtersData.idx = newPage - 1;
  5398. // filtersData.sum = pageSize;
  5399. $scope.memoryfilterDatagui.idx = newPage - 1;
  5400. $scope.memoryfilterDatagui.sum = pageSize;
  5401. $scope.myData2 = $scope.interceptMydata(
  5402. $scope.myData2all,
  5403. $scope.memoryfilterDatagui.idx,
  5404. 10
  5405. );
  5406. }
  5407. );
  5408. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5409. $scope.selected.items = data.entity;
  5410. //console.log(data);
  5411. });
  5412. gridApi.selection.on.rowSelectionChangedBatch(
  5413. $scope,
  5414. function (data) {
  5415. $scope.selected.items = data.entity;
  5416. //console.log(data);
  5417. }
  5418. );
  5419. gridApi.core.on.filterChanged($scope, function () {
  5420. var grid = this.grid;
  5421. var filtersData = {
  5422. idx: 0,
  5423. sum: 10,
  5424. };
  5425. angular.forEach(grid.columns, function (item) {
  5426. if (item.enableFiltering) {
  5427. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5428. if (
  5429. angular.isDefined(item.filters[0].term) &&
  5430. item.filters[0].term != ""
  5431. ) {
  5432. if (angular.isUndefined(filtersData["user"])) {
  5433. filtersData["user"] = {};
  5434. }
  5435. filtersData["user"][item.field] = item.filters[0].term;
  5436. }
  5437. }
  5438. });
  5439. $scope.memoryfilterData = filtersData;
  5440. $scope.loadData(filtersData);
  5441. });
  5442. };
  5443. $scope.changecai = function (item) {
  5444. event.preventDefault();
  5445. var modalInstance = $modal.open({
  5446. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5447. controller: function ($scope, $modalInstance) {
  5448. $scope.title = "修改耗材数量";
  5449. $scope.consumptive = angular.copy(item);
  5450. // $scope.consumptive = item;
  5451. $scope.maxsum = item.inventoryNum;
  5452. $scope.clearNoNum = function (obj, attr) {
  5453. //先把非数字的都替换掉,除了数字和.
  5454. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5455. //必须保证第一个为数字而不是.
  5456. obj[attr] = obj[attr].replace(/^\./g, "");
  5457. //保证只有出现一个.而没有多个.
  5458. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5459. //保证.只出现一次,而不能出现两次以上
  5460. obj[attr] = obj[attr]
  5461. .replace(".", "$#$")
  5462. .replace(/\./g, "")
  5463. .replace("$#$", ".");
  5464. //小于最大值
  5465. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5466. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5467. // obj[attr] = '';
  5468. // }
  5469. };
  5470. $scope.ok = function () {
  5471. $modalInstance.close($scope.consumptive);
  5472. };
  5473. $scope.cancel = function () {
  5474. $modalInstance.dismiss("cancel");
  5475. };
  5476. },
  5477. size: "sm",
  5478. });
  5479. modalInstance.result.then(function (selectedItem) {
  5480. angular.forEach($scope.myData2all, function (items, index) {
  5481. // if (items.id == selectedItem.id) {
  5482. if (
  5483. items.modelid == selectedItem.modelid &&
  5484. items.nameid == selectedItem.nameid &&
  5485. items.Specificationsid == selectedItem.Specificationsid
  5486. ) {
  5487. angular.extend($scope.myData2all[index], selectedItem);
  5488. }
  5489. });
  5490. // $scope.model.consumables = $scope.myData2;
  5491. // $scope.myData2 = $scope.model.consumables;
  5492. // $scope.myData2all.push(selectedItem);
  5493. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5494. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5495. // }
  5496. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5497. $scope.myData2 = $scope.interceptMydata(
  5498. $scope.myData2all,
  5499. $scope.memoryfilterDatagui.idx,
  5500. 10
  5501. );
  5502. $scope.model.consumables = $scope.myData2all;
  5503. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5504. $scope.model.consumables;
  5505. });
  5506. };
  5507. $scope.interceptMydata = function (mydate, idx, sum) {
  5508. return mydate.slice(idx * sum, (idx + 1) * sum);
  5509. };
  5510. $scope.haocaiadd = function () {
  5511. event.preventDefault();
  5512. var modalInstance = $modal.open({
  5513. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5514. controller: function (
  5515. $scope,
  5516. scope,
  5517. $modalInstance,
  5518. api_wechatfile,
  5519. SweetAlert
  5520. ) {
  5521. $scope.haocainame = [];
  5522. $scope.pinpai = [];
  5523. $scope.guige = [];
  5524. $scope.consumptive = {};
  5525. $scope.consumptiveall = {};
  5526. $scope.title = "添加耗材";
  5527. api_wechatfile
  5528. .getDictionaryForList({
  5529. key: "haocaifenlei",
  5530. })
  5531. .then(function (data) {
  5532. $scope.haocainame = data;
  5533. });
  5534. $scope.clearNoNum = function (obj, attr) {
  5535. //先把非数字的都替换掉,除了数字和.
  5536. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5537. //必须保证第一个为数字而不是.
  5538. obj[attr] = obj[attr].replace(/^\./g, "");
  5539. //保证只有出现一个.而没有多个.
  5540. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5541. //保证.只出现一次,而不能出现两次以上
  5542. obj[attr] = obj[attr]
  5543. .replace(".", "$#$")
  5544. .replace(/\./g, "")
  5545. .replace("$#$", ".");
  5546. //小于最大值
  5547. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5548. alert(
  5549. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5550. );
  5551. obj[attr] = "";
  5552. }
  5553. };
  5554. $scope.onChange = function (parent) {
  5555. $scope.consumptive.model = {};
  5556. $scope.consumptive.Specifications = {};
  5557. api_wechatfile
  5558. .getDictionaryForList({
  5559. key: "pinpai",
  5560. parent: parent.id,
  5561. })
  5562. .then(function (data) {
  5563. $scope.pinpai = data;
  5564. });
  5565. api_wechatfile
  5566. .getDictionaryForList({
  5567. key: "guige",
  5568. parent: parent.id,
  5569. })
  5570. .then(function (data) {
  5571. $scope.guige = data;
  5572. });
  5573. };
  5574. // $scope.onChangesum = function(item) {
  5575. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5576. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5577. // $scope.consumptiveall = data1;
  5578. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5579. // // if (data.list && data.list.length != 0) {
  5580. // // var myData = data.list;
  5581. // // $scope.consumptiveall = myData[0];
  5582. // // $scope.maxsum = myData[0].inventoryNum;
  5583. // // } else if (data.list && data.list.length == 0) {
  5584. // // SweetAlert.swal({
  5585. // // title: "库存数据存在问题!",
  5586. // // text: "请检查库存数据!",
  5587. // // type: "error"
  5588. // // });
  5589. // // }
  5590. // // });
  5591. // }
  5592. // }
  5593. $scope.addhaocai = function () {
  5594. $modalInstance.dismiss("cancel");
  5595. scope.haocaiopen($scope.consumptive);
  5596. };
  5597. $scope.ok = function (item) {
  5598. var submittrue = true;
  5599. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5600. var data = {
  5601. modelid: item.model.id,
  5602. nameid: item.name.id,
  5603. Specificationsid: item.Specifications.id,
  5604. name: item.name.name,
  5605. model: item.model.name,
  5606. Specifications: item.Specifications.name,
  5607. sum: item.sum,
  5608. };
  5609. if (
  5610. item.name &&
  5611. item.model &&
  5612. JSON.stringify(item.model) != "{}" &&
  5613. item.Specifications &&
  5614. JSON.stringify(item.Specifications) != "{}" &&
  5615. item.sum
  5616. ) {
  5617. // $modalInstance.close(data);
  5618. angular.forEach(scope.myData2all, function (itemsdata) {
  5619. // if (item.model.id == itemsdata.id) {
  5620. if (
  5621. item.model.id == itemsdata.modelid &&
  5622. item.name.id == itemsdata.nameid &&
  5623. item.Specifications.id == itemsdata.Specificationsid
  5624. ) {
  5625. submittrue = false;
  5626. }
  5627. });
  5628. if (submittrue) {
  5629. $modalInstance.close(data);
  5630. } else {
  5631. SweetAlert.swal({
  5632. title: "该耗材已有添加",
  5633. text: "请检查数据然后提交!",
  5634. type: "error",
  5635. });
  5636. }
  5637. } else {
  5638. SweetAlert.swal({
  5639. title: "数据填写不完整!",
  5640. text: "请检查数据然后提交!",
  5641. type: "error",
  5642. });
  5643. }
  5644. };
  5645. $scope.cancel = function () {
  5646. $modalInstance.dismiss("cancel");
  5647. };
  5648. },
  5649. size: "sm",
  5650. resolve: {
  5651. scope: function () {
  5652. return $scope;
  5653. },
  5654. },
  5655. });
  5656. modalInstance.result.then(function (selectedItem) {
  5657. // $scope.myData2.push(selectedItem);
  5658. // for (var i = 0; i < $scope.myData2.length; i++) {
  5659. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5660. // }
  5661. // $scope.model.consumables = $scope.myData2;
  5662. $scope.myData2all.push(selectedItem);
  5663. for (var i = 0; i < $scope.myData2all.length; i++) {
  5664. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5665. $scope.myData2all[i]["item"] = i + 1;
  5666. }
  5667. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5668. $scope.myData2 = $scope.interceptMydata(
  5669. $scope.myData2all,
  5670. $scope.memoryfilterDatagui.idx,
  5671. 10
  5672. );
  5673. $scope.model.consumables = $scope.myData2all;
  5674. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5675. $scope.model.consumables;
  5676. });
  5677. };
  5678. $scope.onDblClick = function (data, event) {
  5679. $scope.selectButtonClick(data, event);
  5680. };
  5681. $scope.memoryfilterData = {
  5682. idx: 0,
  5683. sum: 20,
  5684. user: {
  5685. roledata: {
  5686. rolecode: "roleset",
  5687. },
  5688. selectType: "1",
  5689. },
  5690. };
  5691. $scope.myData = {};
  5692. $scope.loadData = function (filterData) { };
  5693. // $scope.title = title;
  5694. $scope.loadData({
  5695. idx: 0,
  5696. sum: 20,
  5697. user: {
  5698. roledata: {
  5699. rolecode: "roleset",
  5700. },
  5701. selectType: "1",
  5702. },
  5703. });
  5704. $scope.selected = {
  5705. items: {},
  5706. };
  5707. },
  5708. ],
  5709. });
  5710. //tab 列表
  5711. formlyConfigProvider.setType({
  5712. name: "ui-cmdbtab",
  5713. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5714. wrapper: ["bootstrapHasError"],
  5715. defaultOptions: function (options, $scope) {
  5716. return {
  5717. templateOptions: {},
  5718. };
  5719. },
  5720. controller: [
  5721. "$scope",
  5722. "api_user_data",
  5723. "i18nService",
  5724. "$modal",
  5725. "api_cmdb",
  5726. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5727. $scope.memoryfilterDatashe = {
  5728. idx: 0,
  5729. sum: 10,
  5730. };
  5731. $scope.myDataoneall = [];
  5732. var setAllInactive = function () {
  5733. angular.forEach($scope.workspaces, function (workspace) {
  5734. workspace.active = false;
  5735. });
  5736. };
  5737. //添加
  5738. var addNewWorkspace = function (name, contentUrl) {
  5739. var id = $scope.workspaces.length + 1;
  5740. $scope.workspaces.push({
  5741. id: id,
  5742. name: name,
  5743. active: true,
  5744. contentUrl: "main/html/content.html",
  5745. });
  5746. };
  5747. //关闭
  5748. $scope.remove = function (closedata) {
  5749. event.preventDefault();
  5750. angular.forEach($scope.workspaces, function (item, index) {
  5751. if (closedata.id == item.id) {
  5752. if (closedata.id == 1) {
  5753. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5754. } else {
  5755. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5756. }
  5757. $scope.workspaces.splice(index, 1);
  5758. }
  5759. });
  5760. };
  5761. $scope.workspaces = [];
  5762. $scope.options.templateOptions.getpush = function (item) {
  5763. $scope.workspaces = [];
  5764. if (item.gu) {
  5765. $scope.workspaces.push({
  5766. id: 1,
  5767. name: "领用设备",
  5768. active: true,
  5769. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5770. });
  5771. }
  5772. if (item.hao) {
  5773. $scope.workspaces.push({
  5774. id: 2,
  5775. name: "领用耗材",
  5776. active: true,
  5777. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5778. });
  5779. }
  5780. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5781. };
  5782. $scope.addWorkspace = function (contentUrl, name) {
  5783. setAllInactive();
  5784. addNewWorkspace(name, contentUrl);
  5785. };
  5786. // $rootScope.addWorkspace = $scope.addWorkspace;
  5787. // $scope.remove = function(idNumber) {
  5788. // var index = 0; //记录当前元素下标
  5789. // angular.forEach($scope.workspaces, function(workspace) {
  5790. // if (workspace.id === idNumber.id) {
  5791. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5792. // }
  5793. // index++;
  5794. // });
  5795. // };
  5796. // setInterval(function() {
  5797. // if ($scope.model.assets) {
  5798. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5799. // $scope.modelass = $scope.model.assets;
  5800. // if (JSON.stringify($scope.model.assets) == "{}") {
  5801. // $scope.model.assets = []
  5802. // } else {
  5803. // $scope.model.assets = JSON.parse($scope.model.assets);
  5804. // }
  5805. // $scope.myDatalingbeiall = $scope.model.assets;
  5806. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5807. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5808. // }
  5809. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5810. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5811. // }
  5812. // }
  5813. // if ($scope.model.consumables) {
  5814. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5815. // $scope.modelass = $scope.model.consumables;
  5816. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5817. // $scope.model.consumables = [];
  5818. // } else {
  5819. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5820. // }
  5821. // $scope.myDatalingbeiall = $scope.model.consumables;
  5822. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5823. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5824. // }
  5825. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5826. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5827. // // $scope.model.consumables = $scope.myData2all;
  5828. // }
  5829. // }
  5830. // }, 100);
  5831. //grid1
  5832. $scope.langs = i18nService.getAllLangs();
  5833. $scope.lang = "zh-cn";
  5834. i18nService.setCurrentLang($scope.lang);
  5835. $scope.gridOptions1 = {};
  5836. $scope.gridOptions1.data = "myDatalingbei";
  5837. $scope.gridOptions1.enableColumnResizing = true;
  5838. $scope.gridOptions1.enableFiltering = false;
  5839. $scope.gridOptions1.enableGridMenu = false;
  5840. $scope.gridOptions1.showGridFooter = true;
  5841. $scope.gridOptions1.showColumnFooter = false;
  5842. $scope.gridOptions1.fastWatch = true;
  5843. $scope.gridOptions1.useExternalFiltering = true;
  5844. $scope.gridOptions1.useExternalPagination = true;
  5845. $scope.gridOptions1.paginationPageSizes = [10];
  5846. $scope.gridOptions1.paginationPageSize = 10;
  5847. $scope.gridOptions1.multiSelect = false;
  5848. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5849. $scope.gridOptions1.columnDefs = [
  5850. {
  5851. name: "item",
  5852. displayName: "序号",
  5853. width: 120,
  5854. },
  5855. {
  5856. name: "props.hw_cifilterClassic",
  5857. displayName: "设备类型",
  5858. width: 150,
  5859. enableFiltering: false,
  5860. },
  5861. {
  5862. name: "props.hw_mingcheng",
  5863. displayName: "设备名称",
  5864. width: 100,
  5865. enableFiltering: false,
  5866. },
  5867. {
  5868. name: "uuid",
  5869. displayName: "设备编号",
  5870. enableFiltering: false,
  5871. },
  5872. ];
  5873. $scope.myDatalingbeiall = [];
  5874. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5875. $scope.gridApi = gridApi;
  5876. gridApi.pagination.on.paginationChanged(
  5877. $scope,
  5878. function (newPage, pageSize) {
  5879. // var filtersData = $scope.memoryfilterData;
  5880. // filtersData.idx = newPage - 1;
  5881. // filtersData.sum = pageSize;
  5882. // $scope.loadData(filtersData);
  5883. $scope.memoryfilterDatashe.idx = newPage - 1;
  5884. $scope.memoryfilterDatashe.sum = pageSize;
  5885. $scope.myDatalingbei = $scope.interceptMydata(
  5886. $scope.myDatalingbeiall,
  5887. $scope.memoryfilterDatashe.idx,
  5888. 10
  5889. );
  5890. }
  5891. );
  5892. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5893. $scope.selected.items = data.entity;
  5894. //console.log(data);
  5895. });
  5896. gridApi.selection.on.rowSelectionChangedBatch(
  5897. $scope,
  5898. function (data) {
  5899. $scope.selected.items = data.entity;
  5900. //console.log(data);
  5901. }
  5902. );
  5903. gridApi.core.on.filterChanged($scope, function () {
  5904. var grid = this.grid;
  5905. var filtersData = {
  5906. idx: 0,
  5907. sum: 20,
  5908. user: {
  5909. roledata: {
  5910. rolecode: "roleset",
  5911. },
  5912. selectType: "1",
  5913. },
  5914. };
  5915. angular.forEach(grid.columns, function (item) {
  5916. if (item.enableFiltering) {
  5917. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5918. if (
  5919. angular.isDefined(item.filters[0].term) &&
  5920. item.filters[0].term != ""
  5921. ) {
  5922. if (angular.isUndefined(filtersData["user"])) {
  5923. filtersData["user"] = {};
  5924. }
  5925. filtersData["user"][item.field] = item.filters[0].term;
  5926. }
  5927. }
  5928. });
  5929. $scope.memoryfilterDatashe = filtersData;
  5930. // $scope.loadData(filtersData);
  5931. });
  5932. };
  5933. $scope.interceptMydata = function (mydate, idx, sum) {
  5934. return mydate.slice(idx * sum, (idx + 1) * sum);
  5935. };
  5936. $scope.removeshebei = function (item) {
  5937. event.preventDefault();
  5938. var modalInstance = $modal.open({
  5939. templateUrl: "assets/views/delete.html",
  5940. controller: function ($scope, $modalInstance, scope) {
  5941. $scope.title = "设备移除";
  5942. $scope.connect = "确定要移除此设备?";
  5943. $scope.consumptive = scope.selected.items;
  5944. $scope.ok = function () {
  5945. $modalInstance.close($scope.consumptive);
  5946. };
  5947. $scope.cancel = function () {
  5948. $modalInstance.dismiss("cancel");
  5949. };
  5950. },
  5951. size: "sm",
  5952. resolve: {
  5953. scope: function () {
  5954. return $scope;
  5955. },
  5956. },
  5957. });
  5958. modalInstance.result.then(function (selectedItem) {
  5959. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5960. if (items.id == selectedItem.id) {
  5961. $scope.myDatalingbeiall.splice(index, 1);
  5962. }
  5963. });
  5964. // $scope.myData3.push(selectedItem);
  5965. $scope.model.consumables = $scope.myDatalingbeiall;
  5966. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5967. $scope.myDatalingbeiall;
  5968. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5969. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5970. $scope.myDatalingbeiall[i]["item"] =
  5971. i +
  5972. 1 +
  5973. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5974. }
  5975. $scope.myDatalingbei = $scope.interceptMydata(
  5976. $scope.myDatalingbeiall,
  5977. 0,
  5978. 10
  5979. );
  5980. });
  5981. };
  5982. $scope.addshebei = function () {
  5983. event.preventDefault();
  5984. var modalInstance = $modal.open({
  5985. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5986. controller: function (
  5987. $scope,
  5988. i18nService,
  5989. $modalInstance,
  5990. items,
  5991. title,
  5992. Restangular,
  5993. APIService,
  5994. onDataCallback,
  5995. parentScope,
  5996. api_configure_data,
  5997. api_configure_form
  5998. ) {
  5999. $scope.langs = i18nService.getAllLangs();
  6000. $scope.lang = "zh-cn";
  6001. i18nService.setCurrentLang($scope.lang);
  6002. $scope.gridOptions = {};
  6003. $scope.gridOptions.data = "myDatatwo";
  6004. $scope.gridOptions.enableColumnResizing = true;
  6005. $scope.gridOptions.enableFiltering = false;
  6006. $scope.gridOptions.enableGridMenu = false;
  6007. $scope.gridOptions.showGridFooter = true;
  6008. $scope.gridOptions.showColumnFooter = false;
  6009. $scope.gridOptions.fastWatch = true;
  6010. $scope.gridOptions.useExternalFiltering = true;
  6011. $scope.gridOptions.useExternalPagination = true;
  6012. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  6013. $scope.gridOptions.paginationPageSize = 10;
  6014. $scope.gridOptions.multiSelect = true;
  6015. $scope.gridOptions.rowIdentity = function (row) {
  6016. return row.id;
  6017. };
  6018. $scope.gridOptions.getRowIdentity = function (row) {
  6019. return row.id;
  6020. };
  6021. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6022. $scope.gridOptions.columnDefs = [
  6023. {
  6024. name: "item",
  6025. displayName: "序号",
  6026. width: 80,
  6027. enableFiltering: false,
  6028. },
  6029. {
  6030. name: "uuid",
  6031. displayName: "内部编号",
  6032. width: 175,
  6033. },
  6034. {
  6035. name: "props.hw_mingcheng",
  6036. displayName: "资产名称",
  6037. width: 120,
  6038. },
  6039. {
  6040. name: "props.hw_cifilterClassic",
  6041. displayName: "资产类型",
  6042. width: 80,
  6043. enableFiltering: false,
  6044. },
  6045. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6046. {
  6047. name: "props.hw_state",
  6048. displayName: "资产状态",
  6049. width: 150,
  6050. enableFiltering: false,
  6051. },
  6052. {
  6053. name: "props.hwnw_area",
  6054. displayName: "资产地点",
  6055. width: 130,
  6056. enableFiltering: false,
  6057. },
  6058. {
  6059. name: "createtime",
  6060. displayName: "申请时间",
  6061. enableFiltering: false,
  6062. },
  6063. ];
  6064. // $scope.selectButtonClick
  6065. var defaultFilterData = {
  6066. // "assignee":2,
  6067. // "sign":"basehwitndl",
  6068. // "applicationForm": { "hw_state": "在线" },
  6069. hw_state: "在库",
  6070. idx: 0,
  6071. sum: 10,
  6072. };
  6073. $scope.memoryfilterData = {
  6074. // "assignee":2,
  6075. // "sign":"basehwitndl",
  6076. // "applicationForm": { "hw_state": "在线" },
  6077. hw_state: "在库",
  6078. idx: 0,
  6079. sum: 10,
  6080. };
  6081. $scope.refreshData = function (style, filterData) {
  6082. if (angular.isUndefined(filterData)) {
  6083. filterData = defaultFilterData;
  6084. }
  6085. $scope.myDatatwo = [];
  6086. // $scope.gridOptions['sum']=filterData.sum;
  6087. api_cmdb.query(filterData).then(
  6088. function (data) {
  6089. // $scope.callsPending--;
  6090. var filterData = $scope.memoryfilterData;
  6091. var myDatatwo = Restangular.stripRestangular(data);
  6092. $scope.gridOptions["totalItems"] = data.total;
  6093. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6094. myDatatwo.data.node[i].createtime = moment(
  6095. myDatatwo.data.node[i].createtime
  6096. ).format("YYYY-MM-DD");
  6097. }
  6098. $scope.myDatatwo = myDatatwo.data.node;
  6099. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6100. $scope.myDatatwo[i]["item"] =
  6101. i + 1 + filterData.idx * filterData.sum;
  6102. }
  6103. },
  6104. function () { }
  6105. );
  6106. };
  6107. $scope.refreshData("expand-right", defaultFilterData);
  6108. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6109. $scope.gridApi = gridApi;
  6110. gridApi.pagination.on.paginationChanged(
  6111. $scope,
  6112. function (newPage, pageSize) {
  6113. var filtersData = $scope.memoryfilterData;
  6114. filtersData.idx = newPage - 1;
  6115. filtersData.sum = pageSize;
  6116. // $scope.loadData(filtersData);
  6117. $scope.refreshData("expand-right", filtersData);
  6118. //console.log(pageSize);
  6119. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6120. }
  6121. );
  6122. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6123. // $scope.selected.items.push(data.entity);
  6124. //console.log(data);
  6125. gridApi.selection.on.rowSelectionChanged(
  6126. $scope,
  6127. function (scope, ect) {
  6128. if (scope.isSelected) {
  6129. scope.grid.appScope.selected.items.push(scope.entity);
  6130. } else {
  6131. for (
  6132. var i = 0;
  6133. i <= scope.grid.appScope.selected.items.length;
  6134. i++
  6135. ) {
  6136. if (
  6137. scope.grid.appScope.selected.items[i].id ==
  6138. scope.entity.id
  6139. ) {
  6140. scope.grid.appScope.selected.items.splice(i, 1);
  6141. break;
  6142. }
  6143. }
  6144. }
  6145. $scope.mySelectedRows =
  6146. $scope.gridApi.selection.getSelectedRows();
  6147. }
  6148. );
  6149. // });
  6150. gridApi.selection.on.rowSelectionChangedBatch(
  6151. $scope,
  6152. function (rows) {
  6153. // $scope.selected.items = data.entity;
  6154. //console.log(data);
  6155. var selectitem = [];
  6156. selectitem = angular.copy($scope.selected.items);
  6157. for (var j = 0; j < rows.length; j++) {
  6158. if (rows[j].isSelected == true) {
  6159. selectitem.push(rows[j].entity);
  6160. } else {
  6161. delete selectitem[j];
  6162. // rows.splice(j, 1);
  6163. }
  6164. }
  6165. $scope.selected.items = [];
  6166. for (var i = 0; i < selectitem.length; i++) {
  6167. if (selectitem[i]) {
  6168. $scope.selected.items.push(selectitem[i]);
  6169. }
  6170. }
  6171. }
  6172. );
  6173. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6174. // // if (row.entity.age > 45) {
  6175. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6176. // // }
  6177. // };
  6178. gridApi.core.on.filterChanged($scope, function () {
  6179. var grid = this.grid;
  6180. var filtersData = {
  6181. idx: 0,
  6182. sum: 10,
  6183. user: {
  6184. roledata: {
  6185. rolecode: "roleset",
  6186. },
  6187. selectType: "1",
  6188. },
  6189. };
  6190. angular.forEach(grid.columns, function (item) {
  6191. if (item.enableFiltering) {
  6192. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6193. if (
  6194. angular.isDefined(item.filters[0].term) &&
  6195. item.filters[0].term != ""
  6196. ) {
  6197. if (angular.isUndefined(filtersData["user"])) {
  6198. filtersData["user"] = {};
  6199. }
  6200. filtersData["user"][item.field] = item.filters[0].term;
  6201. }
  6202. }
  6203. });
  6204. $scope.memoryfilterData = filtersData;
  6205. // $scope.loadData(filtersData);
  6206. });
  6207. };
  6208. $scope.onDblClick = function (data, event) {
  6209. // $scope.selected.items = data.entity;
  6210. $scope.selectButtonClick(data, event);
  6211. };
  6212. // $scope.loadData = function(filterData) {
  6213. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6214. // items.fetchItems(filterData, APIService).then(function(data) {
  6215. // var myDatatwo = Restangular.stripRestangular(data);
  6216. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6217. // $scope.myDatatwo = myDatatwo.list;
  6218. // });
  6219. // };
  6220. $scope.title = title;
  6221. //树形图
  6222. var apple_selected, tree, treedata_avm, treedata_geography;
  6223. $scope.my_tree_handler = function (branch) {
  6224. //var _ref;
  6225. var classify = ($scope.classify =
  6226. branch.prefix.toLowerCase() + branch.sign);
  6227. api_cmdb
  6228. .query({
  6229. sign: classify,
  6230. })
  6231. .then(function (data) {
  6232. var myDatalingbei = Restangular.stripRestangular(data);
  6233. // console.log(myData.data.node);
  6234. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6235. var ret = myDatalingbei.data;
  6236. redrawSvg(myDatalingbei);
  6237. }
  6238. });
  6239. };
  6240. $scope.my_data = [];
  6241. function convertListToTree(data, treeMap) {
  6242. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6243. var root = null; //Initially set our loop to null
  6244. var parentNode = null;
  6245. //loop over data
  6246. for (var i = 0; i < data.length; i++) {
  6247. var datum = data[i];
  6248. //each node will have children, so let's give it a "children" poperty
  6249. datum.children = [];
  6250. //add an entry for this node to the map so that any future children can
  6251. //lookup the parent
  6252. idToNodeMap[datum.id] = datum;
  6253. //Does this node have a parent?
  6254. if (
  6255. typeof datum.parent === "undefined" ||
  6256. datum.parent == null
  6257. ) {
  6258. //Doesn't look like it, so this node is the root of the tree
  6259. root = datum;
  6260. treeMap[datum.id] = root;
  6261. } else {
  6262. //This node has a parent, so let's look it up using the id
  6263. parentNode = idToNodeMap[datum.parent.id];
  6264. //We don't need this property, so let's delete it.
  6265. delete datum.parent;
  6266. //Let's add the current node as a child of the parent node.
  6267. parentNode.children.push(datum);
  6268. }
  6269. }
  6270. return root;
  6271. }
  6272. function convertParentToChildList(data) {
  6273. var treeMap = {};
  6274. var list = [];
  6275. convertListToTree(data, treeMap);
  6276. angular.forEach(treeMap, function (item) {
  6277. list.push(item);
  6278. });
  6279. return list;
  6280. }
  6281. $scope.my_tree = tree = {};
  6282. $scope.try_async_load = function () {
  6283. $scope.my_data = [];
  6284. $scope.select_treedata = [];
  6285. $scope.doing_async = true;
  6286. api_configure_data
  6287. .fetchDataList("ciclassify", {
  6288. idx: 0,
  6289. sum: 100,
  6290. })
  6291. .then(function (result) {
  6292. //console.log(result['list']);
  6293. $scope.select_treedata = $scope.my_data =
  6294. convertParentToChildList(result["list"]);
  6295. $scope.doing_async = false;
  6296. // tree.expand_all();
  6297. //console.log(treelist);
  6298. });
  6299. };
  6300. $scope.select_treedata = [];
  6301. $scope.propTypeOptions = [];
  6302. $scope.try_async_load();
  6303. $scope.onFilterremove = function (item) {
  6304. console.log(item);
  6305. };
  6306. $scope.searchdata = {};
  6307. $scope.clear = function () {
  6308. $scope.searchdata = {};
  6309. $scope.cifilter_classic = {};
  6310. $scope.try_async_load();
  6311. var fildata = {
  6312. idx: 0,
  6313. sum: 10,
  6314. hw_state: "在库",
  6315. };
  6316. $scope.memoryfilterData = fildata;
  6317. $scope.refreshData("expand-right", fildata);
  6318. };
  6319. $scope.cifilter_classic = {};
  6320. $scope.chiceIncident = function (item) {
  6321. var fildata = defaultFilterData;
  6322. // fildata.applicationForm = {};
  6323. // sign: basehwnwswt
  6324. if (item && item.id) {
  6325. var classify = item.prefix.toLowerCase() + item.sign;
  6326. fildata.sign = classify;
  6327. } else {
  6328. delete fildata.sign;
  6329. }
  6330. $scope.gridOptions.paginationCurrentPage = 1;
  6331. var transitiondata = angular.copy(item);
  6332. $scope.refreshData("expand-right", fildata);
  6333. };
  6334. $scope.applicadata = [];
  6335. $scope.onFilterCallback = function (item) {
  6336. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6337. api_configure_form
  6338. .renderTabForm(tempclassify)
  6339. .then(function (data) {
  6340. var myData = Restangular.stripRestangular(data);
  6341. $scope.applicadata = myData[0].form.fields;
  6342. });
  6343. // }
  6344. };
  6345. // $scope.loadData({
  6346. // idx: 0,
  6347. // sum: 10,
  6348. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6349. // });
  6350. $scope.selected = {
  6351. items: [],
  6352. };
  6353. $scope.ok = function () {
  6354. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6355. // onDataCallback($scope.selected.item, parentScope);
  6356. // }
  6357. $modalInstance.close($scope.selected.items);
  6358. };
  6359. $scope.cancel = function () {
  6360. $modalInstance.dismiss("cancel");
  6361. };
  6362. },
  6363. size: "lg",
  6364. resolve: {
  6365. items: function () {
  6366. return {
  6367. fetchItems: function (filterData, APIService) {
  6368. filterData = filterData || {};
  6369. if (
  6370. angular.isDefined(filterData.idx) &&
  6371. filterData.idx == null
  6372. ) {
  6373. filterData = {
  6374. idx: 0,
  6375. sum: 10,
  6376. user: {
  6377. roledata: {
  6378. rolecode: "roleset",
  6379. },
  6380. selectType: "1",
  6381. },
  6382. };
  6383. }
  6384. return $scope.options.templateOptions.fetchItems(
  6385. filterData,
  6386. APIService
  6387. );
  6388. },
  6389. };
  6390. },
  6391. title: function () {
  6392. return $scope.options.templateOptions.label;
  6393. },
  6394. Restangular: function () {
  6395. return $scope.options.templateOptions.Restangular;
  6396. },
  6397. APIService: function () {
  6398. return $scope.options.templateOptions.ApiService;
  6399. },
  6400. onDataCallback: function () {
  6401. return $scope.options.templateOptions.callback;
  6402. },
  6403. parentScope: function () {
  6404. return $scope.options.templateOptions.that;
  6405. },
  6406. },
  6407. });
  6408. modalInstance.result.then(
  6409. function (selectedItem) {
  6410. // console.log(selectedItem);
  6411. // options.value(selectedItem);
  6412. var filterData = $scope.memoryfilterDatashe;
  6413. $scope.myDatalingbeiall = selectedItem;
  6414. $scope.gridOptions1["totalItems"] =
  6415. $scope.myDatalingbeiall.length;
  6416. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6417. $scope.myDatalingbeiall[i]["item"] =
  6418. i + 1 + filterData.idx * filterData.sum;
  6419. }
  6420. $scope.myDatalingbei = $scope.interceptMydata(
  6421. $scope.myDatalingbeiall,
  6422. 0,
  6423. 10
  6424. );
  6425. $scope.model.assets = $scope.myDatalingbeiall;
  6426. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6427. $scope.myDatalingbeiall;
  6428. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6429. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6430. // }
  6431. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6432. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6433. // }
  6434. },
  6435. function () {
  6436. //console.log('Modal dismissed at: ' + new Date());
  6437. }
  6438. );
  6439. };
  6440. $scope.onDblClick = function (data, event) {
  6441. $scope.selectButtonClick(data, event);
  6442. };
  6443. // $scope.loadData = function(filterData) {};
  6444. // $scope.title = title;
  6445. // $scope.loadData({
  6446. // idx: 0,
  6447. // sum: 20,
  6448. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6449. // });
  6450. $scope.selected = {
  6451. items: [],
  6452. };
  6453. //grid2
  6454. $scope.langs = i18nService.getAllLangs();
  6455. $scope.lang = "zh-cn";
  6456. i18nService.setCurrentLang($scope.lang);
  6457. $scope.gridOptions2 = {};
  6458. $scope.gridOptions2.data = "myDataone";
  6459. $scope.gridOptions2.enableColumnResizing = true;
  6460. $scope.gridOptions2.enableFiltering = false;
  6461. $scope.gridOptions2.enableGridMenu = false;
  6462. $scope.gridOptions2.showGridFooter = true;
  6463. $scope.gridOptions2.showColumnFooter = false;
  6464. $scope.gridOptions2.fastWatch = true;
  6465. $scope.gridOptions2.useExternalFiltering = true;
  6466. $scope.gridOptions2.useExternalPagination = true;
  6467. $scope.gridOptions2.paginationPageSizes = [10];
  6468. $scope.gridOptions2.paginationPageSize = 10;
  6469. $scope.gridOptions2.multiSelect = false;
  6470. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6471. $scope.gridOptions2.columnDefs = [
  6472. {
  6473. name: "item",
  6474. displayName: "序号",
  6475. width: 120,
  6476. },
  6477. {
  6478. name: "name",
  6479. displayName: "耗材名称",
  6480. width: 150,
  6481. enableFiltering: false,
  6482. },
  6483. {
  6484. name: "model",
  6485. displayName: "品牌/型号",
  6486. width: 100,
  6487. enableFiltering: false,
  6488. },
  6489. {
  6490. name: "Specifications",
  6491. displayName: "规格",
  6492. width: 150,
  6493. enableFiltering: false,
  6494. },
  6495. {
  6496. name: "sum",
  6497. displayName: "领用数量",
  6498. enableFiltering: false,
  6499. },
  6500. ];
  6501. // $scope.selectButtonClick
  6502. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6503. $scope.gridApi = gridApi;
  6504. gridApi.pagination.on.paginationChanged(
  6505. $scope,
  6506. function (newPage, pageSize) {
  6507. // var filtersData = $scope.memoryfilterData;
  6508. // filtersData.idx = newPage - 1;
  6509. // filtersData.sum = pageSize;
  6510. // $scope.loadData(filtersData);
  6511. $scope.memoryfilterDatahao.idx = newPage - 1;
  6512. $scope.memoryfilterDatahao.sum = pageSize;
  6513. $scope.myDataone = $scope.interceptMydata(
  6514. $scope.myDataoneall,
  6515. $scope.memoryfilterDatahao.idx,
  6516. 10
  6517. );
  6518. }
  6519. );
  6520. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6521. $scope.selected.items.push(data.entity);
  6522. //console.log(data);
  6523. });
  6524. gridApi.selection.on.rowSelectionChangedBatch(
  6525. $scope,
  6526. function (data) {
  6527. $scope.selected.items.push(data.entity);
  6528. //console.log(data);
  6529. }
  6530. );
  6531. gridApi.core.on.filterChanged($scope, function () {
  6532. var grid = this.grid;
  6533. var filtersData = {
  6534. idx: 0,
  6535. sum: 10,
  6536. user: {
  6537. roledata: {
  6538. rolecode: "roleset",
  6539. },
  6540. selectType: "1",
  6541. },
  6542. };
  6543. angular.forEach(grid.columns, function (item) {
  6544. if (item.enableFiltering) {
  6545. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6546. if (
  6547. angular.isDefined(item.filters[0].term) &&
  6548. item.filters[0].term != ""
  6549. ) {
  6550. if (angular.isUndefined(filtersData["user"])) {
  6551. filtersData["user"] = {};
  6552. }
  6553. filtersData["user"][item.field] = item.filters[0].term;
  6554. }
  6555. }
  6556. });
  6557. $scope.memoryfilterDatahao = filtersData;
  6558. $scope.loadData(filtersData);
  6559. });
  6560. };
  6561. $scope.removehaocai = function (item) {
  6562. event.preventDefault();
  6563. // var modalInstance = $modal.open({
  6564. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6565. // controller: function($scope, $modalInstance) {
  6566. // $scope.title = "修改耗材数量";
  6567. // $scope.consumptive = item;
  6568. // $scope.ok = function() {
  6569. // $modalInstance.close($scope.consumptive);
  6570. // };
  6571. // $scope.cancel = function() {
  6572. // $modalInstance.dismiss('cancel');
  6573. // };
  6574. // },
  6575. // size: 'sm'
  6576. // });
  6577. var modalInstance = $modal.open({
  6578. templateUrl: "assets/views/delete.html",
  6579. controller: function ($scope, $modalInstance, scope) {
  6580. $scope.title = "耗材移除";
  6581. $scope.connect = "确定要移除此设备?";
  6582. $scope.consumptive = scope.selected.items[0];
  6583. $scope.ok = function () {
  6584. $modalInstance.close($scope.consumptive);
  6585. };
  6586. $scope.cancel = function () {
  6587. $modalInstance.dismiss("cancel");
  6588. };
  6589. },
  6590. size: "sm",
  6591. resolve: {
  6592. scope: function () {
  6593. return $scope;
  6594. },
  6595. },
  6596. });
  6597. modalInstance.result.then(function (selectedItem) {
  6598. // angular.forEach($scope.myData3, function(items, index) {
  6599. // if (items.id == selectedItem.id) {
  6600. // $scope.myData3[index] = selectedItem;
  6601. // }
  6602. // })
  6603. // $scope.model.applicationForm.consumables = $scope.myData3;
  6604. angular.forEach($scope.myDataoneall, function (items, index) {
  6605. if (items.id == selectedItem.id) {
  6606. $scope.myDataoneall.splice(index, 1);
  6607. }
  6608. });
  6609. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6610. $scope.myDataoneall[i]["item"] =
  6611. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6612. }
  6613. $scope.myDataone = $scope.interceptMydata(
  6614. $scope.myDataoneall,
  6615. 0,
  6616. 10
  6617. );
  6618. $scope.model.consumables = $scope.myDataoneall;
  6619. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6620. $scope.myDataoneall;
  6621. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6622. $scope.selected = {
  6623. items: [],
  6624. };
  6625. });
  6626. };
  6627. $scope.haocaiadd = function () {
  6628. event.preventDefault();
  6629. var modalInstance = $modal.open({
  6630. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6631. controller: function (
  6632. $scope,
  6633. scope,
  6634. $modalInstance,
  6635. api_wechatfile,
  6636. SweetAlert,
  6637. api_cmdb3
  6638. ) {
  6639. $scope.haocainame = [];
  6640. $scope.pinpai = [];
  6641. $scope.guige = [];
  6642. $scope.consumptive = {};
  6643. $scope.consumpall = {};
  6644. $scope.title = "添加耗材";
  6645. api_wechatfile
  6646. .getDictionaryForList({
  6647. key: "haocaifenlei",
  6648. })
  6649. .then(function (data) {
  6650. $scope.haocainame = data;
  6651. });
  6652. $scope.clearNoNum = function (obj, attr) {
  6653. //先把非数字的都替换掉,除了数字和.
  6654. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6655. //必须保证第一个为数字而不是.
  6656. obj[attr] = obj[attr].replace(/^\./g, "");
  6657. //保证只有出现一个.而没有多个.
  6658. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6659. //保证.只出现一次,而不能出现两次以上
  6660. obj[attr] = obj[attr]
  6661. .replace(".", "$#$")
  6662. .replace(/\./g, "")
  6663. .replace("$#$", ".");
  6664. //小于最大值
  6665. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6666. alert(
  6667. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6668. );
  6669. obj[attr] = "";
  6670. }
  6671. };
  6672. $scope.onChange = function (parent) {
  6673. $scope.consumptive.model = {};
  6674. $scope.consumptive.Specifications = {};
  6675. api_wechatfile
  6676. .getDictionaryForList({
  6677. key: "pinpai",
  6678. parent: parent.id,
  6679. })
  6680. .then(function (data) {
  6681. $scope.pinpai = data;
  6682. });
  6683. api_wechatfile
  6684. .getDictionaryForList({
  6685. key: "guige",
  6686. parent: parent.id,
  6687. })
  6688. .then(function (data) {
  6689. $scope.guige = data;
  6690. });
  6691. };
  6692. $scope.onChangesum = function (item) {
  6693. if (item.name && item.model.id && item.Specifications.id) {
  6694. $scope.consumptive.sum = "";
  6695. var data1 = {
  6696. idx: 0,
  6697. sum: 10,
  6698. consumable: {
  6699. name: item.name.name,
  6700. brandModel: item.model.name,
  6701. specification: item.Specifications.name,
  6702. },
  6703. };
  6704. api_cmdb3
  6705. .fetchDataList("consumable", data1)
  6706. .then(function (data) {
  6707. if (data.status == 200 && data.list.length > 0) {
  6708. var myData = data.list;
  6709. $scope.consumpall = myData[0];
  6710. $scope.maxsum = myData[0].inventoryNum;
  6711. } else {
  6712. SweetAlert.swal({
  6713. title: "不存在该耗材",
  6714. text: "请检查库存后重新填写!",
  6715. type: "error",
  6716. });
  6717. }
  6718. });
  6719. }
  6720. };
  6721. $scope.addhaocai = function () {
  6722. $modalInstance.dismiss("cancel");
  6723. scope.haocaiopen($scope.consumptive);
  6724. };
  6725. $scope.ok = function (item) {
  6726. var items = {};
  6727. // if (item.name && item.model && item.Specifications && item.sum) {
  6728. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6729. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6730. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6731. // $scope.consumpall.sum = item.sum;
  6732. // delete $scope.consumpall.brandModel;
  6733. // delete $scope.consumpall.specification;
  6734. // $modalInstance.close($scope.consumpall);
  6735. // } else {
  6736. // SweetAlert.swal({
  6737. // title: "数据填写不完整!",
  6738. // text: "请检查数据然后提交!",
  6739. // type: "error"
  6740. // });
  6741. // }
  6742. var isold = false;
  6743. if (
  6744. item.name &&
  6745. item.model &&
  6746. JSON.stringify(item.model) != "{}" &&
  6747. item.Specifications &&
  6748. JSON.stringify(item.Specifications) != "{}" &&
  6749. item.sum
  6750. ) {
  6751. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6752. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6753. isold = true;
  6754. }
  6755. }
  6756. if (isold) {
  6757. SweetAlert.swal({
  6758. title: "该耗材已添加!",
  6759. text: "请不要重复添加耗材!",
  6760. type: "error",
  6761. });
  6762. } else {
  6763. $scope.consumpall.model = $scope.consumpall.brandModel;
  6764. $scope.consumpall.Specifications =
  6765. $scope.consumpall.specification;
  6766. $scope.consumpall.sum = item.sum;
  6767. delete $scope.consumpall.brandModel;
  6768. delete $scope.consumpall.specification;
  6769. $modalInstance.close($scope.consumpall);
  6770. }
  6771. } else {
  6772. SweetAlert.swal({
  6773. title: "数据填写不完整!",
  6774. text: "请检查数据然后提交!",
  6775. type: "error",
  6776. });
  6777. }
  6778. // $modalInstance.close(item);
  6779. };
  6780. $scope.cancel = function () {
  6781. $modalInstance.dismiss("cancel");
  6782. };
  6783. },
  6784. size: "sm",
  6785. resolve: {
  6786. scope: function () {
  6787. return $scope;
  6788. },
  6789. },
  6790. });
  6791. modalInstance.result.then(function (selectedItem) {
  6792. $scope.myDataoneall.push(selectedItem);
  6793. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6794. $scope.myDataoneall[i]["item"] =
  6795. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6796. }
  6797. // $scope.model.consumables = $scope.myDataone;
  6798. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6799. $scope.myDataone = $scope.interceptMydata(
  6800. $scope.myDataoneall,
  6801. 0,
  6802. 10
  6803. );
  6804. $scope.model.consumables = $scope.myDataoneall;
  6805. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6806. $scope.myDataoneall;
  6807. });
  6808. };
  6809. $scope.onDblClick = function (data, event) {
  6810. $scope.selectButtonClick(data, event);
  6811. };
  6812. $scope.memoryfilterDatahao = {
  6813. idx: 0,
  6814. sum: 10,
  6815. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6816. };
  6817. $scope.myDataone = [];
  6818. $scope.loadData = function (filterData) { };
  6819. // $scope.title = title;
  6820. $scope.ldloading = {};
  6821. $scope.selected = {
  6822. items: [],
  6823. };
  6824. if ($scope.$parent.$parent.$parent.model.gettype) {
  6825. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6826. if ($scope.model.assets) {
  6827. if (JSON.stringify($scope.model.assets) == "{}") {
  6828. $scope.model.assets = [];
  6829. } else {
  6830. $scope.model.assets = JSON.parse($scope.model.assets);
  6831. }
  6832. $scope.myDatalingbeiall = $scope.model.assets;
  6833. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6834. $scope.myDatalingbeiall[i]["item"] =
  6835. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6836. }
  6837. $scope.gridOptions1["totalItems"] =
  6838. $scope.myDatalingbeiall.length;
  6839. $scope.myDatalingbei = $scope.interceptMydata(
  6840. $scope.myDatalingbeiall,
  6841. 0,
  6842. 10
  6843. );
  6844. }
  6845. if ($scope.model.consumables) {
  6846. if (JSON.stringify($scope.model.consumables) == "{}") {
  6847. $scope.model.consumables = [];
  6848. } else {
  6849. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6850. }
  6851. $scope.myDataoneall = $scope.model.consumables;
  6852. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6853. $scope.myDataoneall[i]["item"] =
  6854. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6855. }
  6856. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6857. $scope.myDataone = $scope.interceptMydata(
  6858. $scope.myDataoneall,
  6859. 0,
  6860. 10
  6861. );
  6862. }
  6863. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6864. $scope.options.templateOptions.getpush({
  6865. hao: true,
  6866. gu: true,
  6867. });
  6868. } else {
  6869. $scope.options.templateOptions.getpush({
  6870. hao: true,
  6871. });
  6872. }
  6873. } else {
  6874. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6875. $scope.options.templateOptions.getpush({
  6876. gu: true,
  6877. });
  6878. }
  6879. }
  6880. }
  6881. },
  6882. ],
  6883. });
  6884. formlyConfigProvider.setType({
  6885. name: "ui-panel",
  6886. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6887. });
  6888. formlyConfigProvider.setType({
  6889. name: "ui-currentuser",
  6890. extends: "input",
  6891. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6892. defaultOptions: function (options) {
  6893. return {
  6894. templateOptions: {
  6895. // link: function() {}
  6896. },
  6897. };
  6898. },
  6899. controller: [
  6900. "$scope",
  6901. function ($scope) {
  6902. if ($scope.options.templateOptions.user) {
  6903. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6904. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6905. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6906. // }
  6907. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6908. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6909. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6910. }
  6911. $scope.model[$scope.options.key] =
  6912. $scope.options.templateOptions.user;
  6913. $scope.options.initialValue = $scope.model[$scope.options.key];
  6914. }
  6915. },
  6916. ],
  6917. });
  6918. //仪表盘
  6919. //待处理变更列表
  6920. formlyConfigProvider.setType({
  6921. name: "ui-ngpchangetable",
  6922. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6923. defaultOptions: function (options) {
  6924. return {
  6925. templateOptions: {
  6926. // relationAction: function() {
  6927. // options.hideExpression = true
  6928. // }
  6929. },
  6930. };
  6931. },
  6932. controller: [
  6933. "$scope",
  6934. "$modal",
  6935. "$timeout",
  6936. "SweetAlert",
  6937. "api_bpm_domain",
  6938. "$rootScope",
  6939. "ngTableParams",
  6940. "$filter",
  6941. "$state",
  6942. function (
  6943. $scope,
  6944. $modal,
  6945. $timeout,
  6946. SweetAlert,
  6947. api_bpm_domain,
  6948. $rootScope,
  6949. ngTableParams,
  6950. $filter,
  6951. $state
  6952. ) {
  6953. // var filterData = {
  6954. // "assignee": $rootScope.user.id,
  6955. // "searchtype": "all",
  6956. // "idx": "0",
  6957. // "sum": "10"
  6958. // };
  6959. var filterData = {
  6960. idx: "0",
  6961. sum: "10",
  6962. assignee: 2,
  6963. searchType: "todo",
  6964. };
  6965. $scope.incidentprocess = function (item) {
  6966. $state.go("app.wt_change.add", {
  6967. taskId: item.taskId,
  6968. processInstanceId: item.processInstanceId,
  6969. });
  6970. };
  6971. $scope.more = function () {
  6972. $state.go("app.wt_change.list", {});
  6973. };
  6974. api_bpm_domain
  6975. .fetchtask("bpm_change", filterData)
  6976. .then(function (data) {
  6977. if (data.data) {
  6978. $scope.myData = data.data;
  6979. } else {
  6980. SweetAlert.swal({
  6981. title: "操作异常!",
  6982. text: "系统异常,请稍后重试,或者联系管理员!",
  6983. type: "error",
  6984. });
  6985. }
  6986. });
  6987. $scope.removes = function () {
  6988. var modalInstance = $modal.open({
  6989. templateUrl: "assets/views/delete.html",
  6990. controller: function ($scope, $modalInstance) {
  6991. $scope.ok = function () {
  6992. $modalInstance.close();
  6993. };
  6994. $scope.cancel = function () {
  6995. $modalInstance.dismiss("cancel");
  6996. };
  6997. },
  6998. size: "sm",
  6999. });
  7000. modalInstance.result.then(function () {
  7001. console.log($scope.$parent.$parent.$parent.$parent);
  7002. for (
  7003. var i = 0;
  7004. i <
  7005. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7006. i++
  7007. ) {
  7008. if (
  7009. $scope.fields.type ==
  7010. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7011. .type
  7012. ) {
  7013. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7014. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7015. i,
  7016. 1
  7017. );
  7018. break;
  7019. }
  7020. }
  7021. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7022. if (vmForm) {
  7023. //console.log("vmForm>>>");//console.log(vmForm);
  7024. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7025. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7026. }
  7027. });
  7028. };
  7029. },
  7030. ],
  7031. });
  7032. //待处理问题列表
  7033. formlyConfigProvider.setType({
  7034. name: "ui-ngproblemtable",
  7035. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7036. defaultOptions: function (options) {
  7037. return {
  7038. templateOptions: {
  7039. // relationAction: function() {
  7040. // options.hideExpression = true
  7041. // }
  7042. },
  7043. };
  7044. },
  7045. controller: [
  7046. "$scope",
  7047. "$modal",
  7048. "$timeout",
  7049. "SweetAlert",
  7050. "api_bpm_data",
  7051. "$rootScope",
  7052. "ngTableParams",
  7053. "$filter",
  7054. "$state",
  7055. function (
  7056. $scope,
  7057. $modal,
  7058. $timeout,
  7059. SweetAlert,
  7060. api_bpm_data,
  7061. $rootScope,
  7062. ngTableParams,
  7063. $filter,
  7064. $state
  7065. ) {
  7066. var filterData = {
  7067. assignee: $rootScope.user.id,
  7068. candidateGroups: $rootScope.user.group[0].id,
  7069. searchtype: "todo",
  7070. idx: 0,
  7071. sum: 10,
  7072. };
  7073. $scope.incidentprocess = function (item) {
  7074. $state.go("app.wt_change.add", {
  7075. taskId: item.taskId,
  7076. processInstanceId: item.processInstanceId,
  7077. });
  7078. };
  7079. $scope.more = function () {
  7080. $state.go("app.wt_change.list", {});
  7081. };
  7082. api_bpm_data
  7083. .fetchDataList("changeclassify", filterData)
  7084. .then(function (data) {
  7085. if (data.data) {
  7086. $scope.myData = data.data;
  7087. } else {
  7088. SweetAlert.swal({
  7089. title: "操作异常!",
  7090. text: "系统异常,请稍后重试,或者联系管理员!",
  7091. type: "error",
  7092. });
  7093. }
  7094. });
  7095. $scope.removes = function () {
  7096. var modalInstance = $modal.open({
  7097. templateUrl: "assets/views/delete.html",
  7098. controller: function ($scope, $modalInstance) {
  7099. $scope.ok = function () {
  7100. $modalInstance.close();
  7101. };
  7102. $scope.cancel = function () {
  7103. $modalInstance.dismiss("cancel");
  7104. };
  7105. },
  7106. size: "sm",
  7107. });
  7108. modalInstance.result.then(function () {
  7109. console.log($scope.$parent.$parent.$parent.$parent);
  7110. for (
  7111. var i = 0;
  7112. i <
  7113. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7114. i++
  7115. ) {
  7116. if (
  7117. $scope.fields.type ==
  7118. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7119. .type
  7120. ) {
  7121. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7122. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7123. i,
  7124. 1
  7125. );
  7126. break;
  7127. }
  7128. }
  7129. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7130. if (vmForm) {
  7131. //console.log("vmForm>>>");//console.log(vmForm);
  7132. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7133. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7134. }
  7135. });
  7136. };
  7137. },
  7138. ],
  7139. });
  7140. //待处理事件列表
  7141. formlyConfigProvider.setType({
  7142. name: "ui-ngtable",
  7143. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7144. defaultOptions: function (options) {
  7145. return {
  7146. templateOptions: {
  7147. // relationAction: function() {
  7148. // options.hideExpression = true
  7149. // }
  7150. },
  7151. };
  7152. },
  7153. controller: [
  7154. "$scope",
  7155. "$modal",
  7156. "$timeout",
  7157. "SweetAlert",
  7158. "api_bpm_domain",
  7159. "$rootScope",
  7160. "ngTableParams",
  7161. "$filter",
  7162. "$state",
  7163. function (
  7164. $scope,
  7165. $modal,
  7166. $timeout,
  7167. SweetAlert,
  7168. api_bpm_domain,
  7169. $rootScope,
  7170. ngTableParams,
  7171. $filter,
  7172. $state
  7173. ) {
  7174. var filterData = {
  7175. assignee: $rootScope.user.id,
  7176. candidateGroups: $rootScope.user.group[0].id,
  7177. searchtype: "done",
  7178. idx: 0,
  7179. sum: 10,
  7180. };
  7181. $scope.incidentprocess = function (item) {
  7182. $state.go("app.incident.editor", {
  7183. taskId: item.taskId,
  7184. processInstanceId: item.processInstanceId,
  7185. });
  7186. };
  7187. $scope.more = function () {
  7188. $state.go("app.incident.list", {});
  7189. };
  7190. api_bpm_domain
  7191. .fetchtask("bpm_incident", filterData)
  7192. .then(function (data) {
  7193. if (data.data) {
  7194. $scope.myData = data.data;
  7195. } else {
  7196. SweetAlert.swal({
  7197. title: "操作异常!",
  7198. text: "系统异常,请稍后重试,或者联系管理员!",
  7199. type: "error",
  7200. });
  7201. }
  7202. });
  7203. $scope.removes = function () {
  7204. var modalInstance = $modal.open({
  7205. templateUrl: "assets/views/delete.html",
  7206. controller: function ($scope, $modalInstance) {
  7207. $scope.ok = function () {
  7208. $modalInstance.close();
  7209. };
  7210. $scope.cancel = function () {
  7211. $modalInstance.dismiss("cancel");
  7212. };
  7213. },
  7214. size: "sm",
  7215. });
  7216. modalInstance.result.then(function () {
  7217. console.log($scope.$parent.$parent.$parent.$parent);
  7218. for (
  7219. var i = 0;
  7220. i <
  7221. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7222. i++
  7223. ) {
  7224. if (
  7225. $scope.fields.type ==
  7226. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7227. .type
  7228. ) {
  7229. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7230. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7231. i,
  7232. 1
  7233. );
  7234. break;
  7235. }
  7236. }
  7237. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7238. if (vmForm) {
  7239. //console.log("vmForm>>>");//console.log(vmForm);
  7240. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7241. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7242. }
  7243. });
  7244. };
  7245. },
  7246. ],
  7247. });
  7248. //知识库列表
  7249. formlyConfigProvider.setType({
  7250. name: "ui-knowledge",
  7251. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7252. defaultOptions: function (options) {
  7253. return {
  7254. templateOptions: {
  7255. // relationAction: function() {
  7256. // options.hideExpression = true
  7257. // }
  7258. },
  7259. };
  7260. },
  7261. controller: [
  7262. "$scope",
  7263. "$modal",
  7264. "$timeout",
  7265. "api_solution",
  7266. "$rootScope",
  7267. "ngTableParams",
  7268. "$filter",
  7269. "$state",
  7270. function (
  7271. $scope,
  7272. $modal,
  7273. $timeout,
  7274. api_solution,
  7275. $rootScope,
  7276. ngTableParams,
  7277. $filter,
  7278. $state
  7279. ) {
  7280. var filterData = {
  7281. key: "null",
  7282. pageIndex: 0,
  7283. pageSum: 6,
  7284. status: 0,
  7285. userId: $rootScope.user.id,
  7286. };
  7287. $scope.model.removereport = false;
  7288. $scope.removes = function () {
  7289. $scope.model.removereport = true;
  7290. };
  7291. $scope.more = function () {
  7292. $state.go("app.knowledge.manager", {});
  7293. };
  7294. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7295. if (data.status == 200) {
  7296. $scope.myData = data.list;
  7297. }
  7298. });
  7299. $scope.removes = function () {
  7300. var modalInstance = $modal.open({
  7301. templateUrl: "assets/views/delete.html",
  7302. controller: function ($scope, $modalInstance) {
  7303. $scope.ok = function () {
  7304. $modalInstance.close();
  7305. };
  7306. $scope.cancel = function () {
  7307. $modalInstance.dismiss("cancel");
  7308. };
  7309. },
  7310. size: "sm",
  7311. });
  7312. modalInstance.result.then(function () {
  7313. for (
  7314. var i = 0;
  7315. i <
  7316. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7317. i++
  7318. ) {
  7319. if (
  7320. $scope.fields.type ==
  7321. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7322. .type
  7323. ) {
  7324. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7325. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7326. i,
  7327. 1
  7328. );
  7329. break;
  7330. }
  7331. }
  7332. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7333. if (vmForm) {
  7334. //console.log("vmForm>>>");//console.log(vmForm);
  7335. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7336. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7337. }
  7338. });
  7339. };
  7340. },
  7341. ],
  7342. });
  7343. //公告列表
  7344. formlyConfigProvider.setType({
  7345. name: "ui-ngnotice",
  7346. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7347. defaultOptions: function (options) {
  7348. return {
  7349. templateOptions: {
  7350. // relationAction: function() {
  7351. // options.hideExpression = true
  7352. // }
  7353. },
  7354. };
  7355. },
  7356. controller: [
  7357. "$scope",
  7358. "$modal",
  7359. "$timeout",
  7360. "SweetAlert",
  7361. "api_user_data",
  7362. "$rootScope",
  7363. "ngTableParams",
  7364. "$filter",
  7365. "$state",
  7366. function (
  7367. $scope,
  7368. $modal,
  7369. $timeout,
  7370. SweetAlert,
  7371. api_user_data,
  7372. $rootScope,
  7373. ngTableParams,
  7374. $filter,
  7375. $state
  7376. ) {
  7377. var filterData = {
  7378. idx: 0,
  7379. sum: 10,
  7380. };
  7381. // $scope.$scope.model.className = "col-xs-12";
  7382. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7383. if (data) {
  7384. $scope.myData = data.data;
  7385. } else {
  7386. SweetAlert.swal({
  7387. title: "操作异常!",
  7388. text: "系统异常,请稍后重试,或者联系管理员!",
  7389. type: "error",
  7390. });
  7391. }
  7392. });
  7393. $scope.more = function () {
  7394. $state.go("app.system.notice.list", {});
  7395. };
  7396. $scope.removes = function () {
  7397. var modalInstance = $modal.open({
  7398. templateUrl: "assets/views/delete.html",
  7399. controller: function ($scope, $modalInstance) {
  7400. $scope.ok = function () {
  7401. $modalInstance.close();
  7402. };
  7403. $scope.cancel = function () {
  7404. $modalInstance.dismiss("cancel");
  7405. };
  7406. },
  7407. size: "sm",
  7408. });
  7409. modalInstance.result.then(function () {
  7410. for (
  7411. var i = 0;
  7412. i <
  7413. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7414. i++
  7415. ) {
  7416. if (
  7417. $scope.fields.type ==
  7418. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7419. .type
  7420. ) {
  7421. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7422. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7423. i,
  7424. 1
  7425. );
  7426. break;
  7427. }
  7428. }
  7429. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7430. if (vmForm) {
  7431. //console.log("vmForm>>>");//console.log(vmForm);
  7432. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7433. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7434. }
  7435. });
  7436. };
  7437. },
  7438. ],
  7439. });
  7440. //事件统计图
  7441. formlyConfigProvider.setType({
  7442. name: "ui-incidentreport",
  7443. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7444. defaultOptions: function (options) {
  7445. return {
  7446. templateOptions: {
  7447. // relationAction: function() {
  7448. // options.hideExpression = true
  7449. // }
  7450. },
  7451. };
  7452. },
  7453. controller: [
  7454. "$scope",
  7455. "$modal",
  7456. "moment",
  7457. "api_report",
  7458. "$cookieStore",
  7459. function ($scope, $modal, moment, api_report, $cookieStore) {
  7460. api_report.getLicenseKey().then(function (response) {
  7461. $cookieStore.put("Auth-Token", response.token);
  7462. $scope.try_async_load();
  7463. });
  7464. $scope.try_async_load = function () {
  7465. $scope.my_data = [];
  7466. api_report.list().then(function (response) {
  7467. var dataList = response;
  7468. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7469. $scope.repoRoot.name = "事件报表";
  7470. convertRepoObject($scope.repoRoot);
  7471. $scope.my_data.push($scope.repoRoot);
  7472. });
  7473. };
  7474. var workspace = {};
  7475. $scope.repoRoot = null;
  7476. function getRepoRoot(repo, path) {
  7477. angular.forEach(repo, function (value, key) {
  7478. if (value.path == path) {
  7479. $scope.repoRoot = value;
  7480. } else {
  7481. if (
  7482. $scope.repoRoot == null &&
  7483. angular.isDefined(value.repoObjects)
  7484. ) {
  7485. getRepoRoot(value.repoObjects, path);
  7486. } else {
  7487. }
  7488. }
  7489. });
  7490. }
  7491. function convertRepoObject(repo) {
  7492. if (angular.isArray(repo)) {
  7493. angular.forEach(repo, function (value, key) {
  7494. convertRepoObject(value);
  7495. });
  7496. } else {
  7497. if (angular.isDefined(repo.name)) {
  7498. if (repo.name.indexOf(".") >= 0) {
  7499. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7500. } else {
  7501. repo.label = repo.name;
  7502. }
  7503. //delete repo.name;
  7504. }
  7505. if (angular.isDefined(repo.repoObjects)) {
  7506. repo.children = [];
  7507. repo.children = repo.repoObjects;
  7508. delete repo.repoObjects;
  7509. convertRepoObject(repo.children);
  7510. }
  7511. }
  7512. }
  7513. function parseDateParameter(parameters) {
  7514. var result = undefined;
  7515. if (angular.isArray(parameters)) {
  7516. // angular.forEach(parmeters,function(param){
  7517. // param.
  7518. // })
  7519. } else {
  7520. result = {};
  7521. for (var k in parameters) {
  7522. if (k.indexOf("Date") > 0) {
  7523. if (angular.isString(parameters[k])) {
  7524. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7525. "YYYY-MM-DD"
  7526. );
  7527. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7528. }
  7529. }
  7530. }
  7531. }
  7532. return result;
  7533. }
  7534. function ConvertDateParameter(parameters) {
  7535. var result = undefined;
  7536. if (angular.isArray(parameters)) {
  7537. //
  7538. } else {
  7539. result = {};
  7540. for (var k in parameters) {
  7541. if (k.indexOf("Date") > 0) {
  7542. if (angular.isDate(parameters[k])) {
  7543. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7544. } else if (angular.isString(parameters[k])) {
  7545. result[k] = parameters[k];
  7546. }
  7547. }
  7548. }
  7549. }
  7550. return result;
  7551. }
  7552. var incidentchart =
  7553. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7554. var queryUUID;
  7555. function genUUID() {
  7556. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7557. .replace(/[xy]/g, function (c) {
  7558. var r = (Math.random() * 16) | 0,
  7559. v = c == "x" ? r : (r & 0x3) | 0x8;
  7560. return v.toString(16);
  7561. })
  7562. .toUpperCase();
  7563. return uuid;
  7564. }
  7565. queryUUID = genUUID();
  7566. var pathincidenttimekey = [];
  7567. var incidenttime = {
  7568. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7569. "YYYYMMDD"
  7570. ),
  7571. endtimes: moment(new Date()).format("YYYYMMDD"),
  7572. };
  7573. var thisday = moment(new Date().getTime() + 86400000).format(
  7574. "YYYYMMDD"
  7575. );
  7576. var thisdaymine = Date.parse(
  7577. thisday.substr(4, 2) +
  7578. "/" +
  7579. thisday.substr(6, 2) +
  7580. "/" +
  7581. thisday.substr(0, 4)
  7582. );
  7583. var averages = [
  7584. [thisdaymine - 86400000 * 14, 0],
  7585. [thisdaymine - 86400000 * 13, 0],
  7586. [thisdaymine - 86400000 * 12, 0],
  7587. [thisdaymine - 86400000 * 11, 0],
  7588. [thisdaymine - 86400000 * 10, 0],
  7589. [thisdaymine - 86400000 * 9, 0],
  7590. [thisdaymine - 86400000 * 8, 0],
  7591. [thisdaymine - 86400000 * 7, 0],
  7592. [thisdaymine - 86400000 * 6, 0],
  7593. [thisdaymine - 86400000 * 5, 0],
  7594. [thisdaymine - 86400000 * 4, 0],
  7595. [thisdaymine - 86400000 * 3, 0],
  7596. [thisdaymine - 86400000 * 2, 0],
  7597. [thisdaymine - 86400000 * 1, 0],
  7598. [thisdaymine, 0],
  7599. ];
  7600. var getreportdata = function (incidenttime, path) {
  7601. api_report.getMdx(path, queryUUID).then(function (response) {
  7602. var mdxquery = response;
  7603. workspace.query = mdxquery;
  7604. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7605. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7606. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7607. weekuser(mdxquery);
  7608. });
  7609. };
  7610. getreportdata(incidenttime, incidentchart);
  7611. var weekuser = function (mdxquery) {
  7612. var key = [];
  7613. api_report.execute(mdxquery).then(function (data) {
  7614. $scope.rheaders = [];
  7615. $scope.rRows = [];
  7616. var reportData = data;
  7617. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7618. $scope.shows = true;
  7619. $scope.empty = "数据为空!";
  7620. } else {
  7621. angular.forEach(reportData.cellset, function (item, i) {
  7622. angular.forEach(averages, function (index, j) {
  7623. // angular.forEach(averages, function(item, index) {
  7624. if (item.length > 1 && i > 0 && item[1].value != "") {
  7625. if (
  7626. index[0] ==
  7627. Date.parse(
  7628. item[0].value.substr(4, 2) +
  7629. "/" +
  7630. item[0].value.substr(6, 2) +
  7631. "/" +
  7632. item[0].value.substr(0, 4)
  7633. ) +
  7634. 86400000
  7635. ) {
  7636. index[1] = Number(item[1].value);
  7637. }
  7638. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  7639. }
  7640. // })
  7641. });
  7642. });
  7643. incidentchartfun(averages);
  7644. }
  7645. });
  7646. };
  7647. var incidentchartfun = function (incidentchartkey) {
  7648. // $scope.isMaskincident = false;
  7649. Highcharts.chart("incidentchart", {
  7650. title: {
  7651. text: "事件近15天趋势图",
  7652. },
  7653. xAxis: {
  7654. type: "datetime",
  7655. labels: {
  7656. align: "left",
  7657. step: 1,
  7658. },
  7659. },
  7660. yAxis: {
  7661. title: {
  7662. text: null,
  7663. },
  7664. },
  7665. tooltip: {
  7666. crosshairs: true,
  7667. shared: true,
  7668. valueSuffix: "条",
  7669. },
  7670. legend: {},
  7671. series: [
  7672. {
  7673. name: "生成事件",
  7674. data: incidentchartkey,
  7675. zIndex: 1,
  7676. marker: {
  7677. fillColor: "white",
  7678. lineWidth: 2,
  7679. lineColor: Highcharts.getOptions().colors[0],
  7680. },
  7681. },
  7682. ],
  7683. });
  7684. };
  7685. $scope.data = {
  7686. labels: [
  7687. "1号",
  7688. "2号",
  7689. "3号",
  7690. "4号",
  7691. "5号",
  7692. "6号",
  7693. "7号",
  7694. "8号",
  7695. "9号",
  7696. "10号",
  7697. "11号",
  7698. "12号",
  7699. "13号",
  7700. "14号",
  7701. "15号",
  7702. ],
  7703. datasets: [
  7704. {
  7705. label: "新增事件数量",
  7706. fillColor: "rgba(220,220,220,0.2)",
  7707. strokeColor: "rgba(220,220,220,1)",
  7708. pointColor: "rgba(220,220,220,1)",
  7709. pointStrokeColor: "#fff",
  7710. pointHighlightFill: "#fff",
  7711. pointHighlightStroke: "rgba(220,220,220,1)",
  7712. data: [
  7713. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7714. ],
  7715. },
  7716. {
  7717. label: "已解决事件数量",
  7718. fillColor: "rgba(151,187,205,0.2)",
  7719. strokeColor: "rgba(151,187,205,1)",
  7720. pointColor: "rgba(151,187,205,1)",
  7721. pointStrokeColor: "#fff",
  7722. pointHighlightFill: "#fff",
  7723. pointHighlightStroke: "rgba(151,187,205,1)",
  7724. data: [
  7725. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7726. ],
  7727. },
  7728. ],
  7729. };
  7730. $scope.removes = function () {
  7731. var modalInstance = $modal.open({
  7732. templateUrl: "assets/views/delete.html",
  7733. controller: function ($scope, $modalInstance) {
  7734. $scope.ok = function () {
  7735. $modalInstance.close();
  7736. };
  7737. $scope.cancel = function () {
  7738. $modalInstance.dismiss("cancel");
  7739. };
  7740. },
  7741. size: "sm",
  7742. });
  7743. modalInstance.result.then(function () {
  7744. for (
  7745. var i = 0;
  7746. i <
  7747. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7748. i++
  7749. ) {
  7750. if (
  7751. $scope.fields.type ==
  7752. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7753. .type
  7754. ) {
  7755. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7756. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7757. i,
  7758. 1
  7759. );
  7760. break;
  7761. }
  7762. }
  7763. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7764. if (vmForm) {
  7765. //console.log("vmForm>>>");//console.log(vmForm);
  7766. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7767. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7768. }
  7769. });
  7770. };
  7771. var addDatas = 0;
  7772. var resolve = 0;
  7773. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7774. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7775. }
  7776. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7777. resolve = resolve + $scope.data.datasets[1].data[i];
  7778. }
  7779. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7780. $scope.opt = {
  7781. maintainAspectRatio: false,
  7782. // Sets the chart to be responsive
  7783. responsive: true,
  7784. ///Boolean - Whether grid lines are shown across the chart
  7785. scaleShowGridLines: true,
  7786. //String - Colour of the grid lines
  7787. scaleGridLineColor: "rgba(0,0,0,.05)",
  7788. //Number - Width of the grid lines
  7789. scaleGridLineWidth: 1,
  7790. //Boolean - Whether the line is curved between points
  7791. bezierCurve: false,
  7792. //Number - Tension of the bezier curve between points
  7793. bezierCurveTension: 0.4,
  7794. //Boolean - Whether to show a dot for each point
  7795. pointDot: true,
  7796. //Number - Radius of each point dot in pixels
  7797. pointDotRadius: 4,
  7798. //Number - Pixel width of point dot stroke
  7799. pointDotStrokeWidth: 1,
  7800. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7801. pointHitDetectionRadius: 20,
  7802. //Boolean - Whether to show a stroke for datasets
  7803. datasetStroke: true,
  7804. //Number - Pixel width of dataset stroke
  7805. datasetStrokeWidth: 2,
  7806. //Boolean - Whether to fill the dataset with a colour
  7807. datasetFill: true,
  7808. // Function - on animation progress
  7809. onAnimationProgress: function () { },
  7810. // Function - on animation complete
  7811. onAnimationComplete: function () { },
  7812. //String - A legend template
  7813. legendTemplate:
  7814. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7815. };
  7816. angular.extend($scope.options, $scope.opt);
  7817. $scope.datamonth = {
  7818. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7819. datasets: [
  7820. {
  7821. label: "新增事件数量",
  7822. fillColor: "rgba(220,220,220,0.5)",
  7823. strokeColor: "rgba(220,220,220,0.8)",
  7824. highlightFill: "rgba(220,220,220,0.75)",
  7825. highlightStroke: "rgba(220,220,220,1)",
  7826. data: [65, 59, 80, 81, 56, 55],
  7827. },
  7828. {
  7829. label: "已解决事件数量",
  7830. fillColor: "rgba(151,187,205,0.5)",
  7831. strokeColor: "rgba(151,187,205,0.8)",
  7832. highlightFill: "rgba(151,187,205,0.75)",
  7833. highlightStroke: "rgba(151,187,205,1)",
  7834. data: [28, 48, 40, 19, 86, 27],
  7835. },
  7836. ],
  7837. };
  7838. // Chart.js Options
  7839. $scope.taption = {
  7840. maintainAspectRatio: false,
  7841. // Sets the chart to be responsive
  7842. responsive: true,
  7843. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7844. scaleBeginAtZero: true,
  7845. //Boolean - Whether grid lines are shown across the chart
  7846. scaleShowGridLines: true,
  7847. //String - Colour of the grid lines
  7848. scaleGridLineColor: "rgba(0,0,0,.05)",
  7849. //Number - Width of the grid lines
  7850. scaleGridLineWidth: 1,
  7851. //Boolean - If there is a stroke on each bar
  7852. barShowStroke: true,
  7853. //Number - Pixel width of the bar stroke
  7854. barStrokeWidth: 2,
  7855. //Number - Spacing between each of the X value sets
  7856. barValueSpacing: 5,
  7857. //Number - Spacing between data sets within X values
  7858. barDatasetSpacing: 1,
  7859. //String - A legend template
  7860. legendTemplate:
  7861. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7862. };
  7863. },
  7864. ],
  7865. });
  7866. //排版日历
  7867. formlyConfigProvider.setType({
  7868. name: "ui-dashcalendar",
  7869. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7870. defaultOptions: function (options) {
  7871. return {
  7872. templateOptions: {
  7873. // relationAction: function() {
  7874. // options.hideExpression = true
  7875. // }
  7876. },
  7877. };
  7878. },
  7879. controller: [
  7880. "$rootScope",
  7881. "$scope",
  7882. "$modal",
  7883. "$aside",
  7884. "calendarConfig",
  7885. "moment",
  7886. "SweetAlert",
  7887. "Restangular",
  7888. "api_bpm_schedule",
  7889. "api_user_data",
  7890. "$state",
  7891. function (
  7892. $rootScope,
  7893. $scope,
  7894. $modal,
  7895. $aside,
  7896. calendarConfig,
  7897. moment,
  7898. SweetAlert,
  7899. Restangular,
  7900. api_bpm_schedule,
  7901. api_user_data,
  7902. $state
  7903. ) {
  7904. var loginUser = $rootScope.user;
  7905. calendarConfig.dateFormatter = "moment";
  7906. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7907. calendarConfig.i18nStrings.timeLabel = "时间";
  7908. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7909. calendarConfig.allDateFormats = {
  7910. angular: {
  7911. date: {
  7912. hour: "ha",
  7913. day: "d MMM",
  7914. month: "MMMM",
  7915. weekDay: "EEEE",
  7916. time: "HH:mm",
  7917. datetime: "MMM d, h:mm a",
  7918. },
  7919. title: {
  7920. day: "yyyy MMMM EEEE d",
  7921. week: "{year}年第{week}周",
  7922. month: "yyyy MMMM",
  7923. year: "yyyy",
  7924. },
  7925. },
  7926. moment: {
  7927. date: {
  7928. hour: "ha",
  7929. day: "MMMDD日",
  7930. month: "MMMM",
  7931. weekDay: "dddd",
  7932. time: "HH:mm",
  7933. datetime: "MMM D, h:mm a",
  7934. },
  7935. title: {
  7936. day: "YYYY年MMMMDD日, dddd ",
  7937. week: "{year}年第{week}周",
  7938. month: "YYYY年MMMM",
  7939. year: "YYYY",
  7940. },
  7941. },
  7942. };
  7943. moment.locale("zh_cn", {
  7944. months:
  7945. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7946. "_"
  7947. ),
  7948. monthsShort:
  7949. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7950. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7951. "_"
  7952. ),
  7953. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7954. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7955. longDateFormat: {
  7956. LT: "Ah点mm分",
  7957. LTS: "Ah点m分s秒",
  7958. L: "YYYY-MM-DD",
  7959. LL: "YYYY年MMMD日",
  7960. LLL: "YYYY年MMMD日Ah点mm分",
  7961. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7962. l: "YYYY-MM-DD",
  7963. ll: "YYYY年MMMD日",
  7964. lll: "YYYY年MMMD日Ah点mm分",
  7965. llll: "YYYY年MMMD日ddddAh点mm分",
  7966. },
  7967. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7968. meridiemHour: function (hour, meridiem) {
  7969. if (hour === 12) {
  7970. hour = 0;
  7971. }
  7972. if (
  7973. meridiem === "凌晨" ||
  7974. meridiem === "早上" ||
  7975. meridiem === "上午"
  7976. ) {
  7977. return hour;
  7978. } else if (meridiem === "下午" || meridiem === "晚上") {
  7979. return hour + 12;
  7980. } else {
  7981. // '中午'
  7982. return hour >= 11 ? hour : hour + 12;
  7983. }
  7984. },
  7985. meridiem: function (hour, minute, isLower) {
  7986. var hm = hour * 100 + minute;
  7987. if (hm < 600) {
  7988. return "凌晨";
  7989. } else if (hm < 900) {
  7990. return "早上";
  7991. } else if (hm < 1130) {
  7992. return "上午";
  7993. } else if (hm < 1230) {
  7994. return "中午";
  7995. } else if (hm < 1800) {
  7996. return "下午";
  7997. } else {
  7998. return "晚上";
  7999. }
  8000. },
  8001. calendar: {
  8002. sameDay: function () {
  8003. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8004. },
  8005. nextDay: function () {
  8006. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8007. },
  8008. lastDay: function () {
  8009. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8010. },
  8011. nextWeek: function () {
  8012. var startOfWeek, prefix;
  8013. startOfWeek = moment().startOf("week");
  8014. prefix =
  8015. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8016. ? "[下]"
  8017. : "[本]";
  8018. return this.minutes() === 0
  8019. ? prefix + "dddAh点整"
  8020. : prefix + "dddAh点mm";
  8021. },
  8022. lastWeek: function () {
  8023. var startOfWeek, prefix;
  8024. startOfWeek = moment().startOf("week");
  8025. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8026. return this.minutes() === 0
  8027. ? prefix + "dddAh点整"
  8028. : prefix + "dddAh点mm";
  8029. },
  8030. sameElse: "LL",
  8031. },
  8032. ordinalParse: /\d{1,2}(日|月|周)/,
  8033. ordinal: function (number, period) {
  8034. switch (period) {
  8035. case "d":
  8036. case "D":
  8037. case "DDD":
  8038. return number + "日";
  8039. case "M":
  8040. return number + "月";
  8041. case "w":
  8042. case "W":
  8043. return number + "周";
  8044. default:
  8045. return number;
  8046. }
  8047. },
  8048. relativeTime: {
  8049. future: "%s内",
  8050. past: "%s前",
  8051. s: "几秒",
  8052. m: "1 分钟",
  8053. mm: "%d 分钟",
  8054. h: "1 小时",
  8055. hh: "%d 小时",
  8056. d: "1 天",
  8057. dd: "%d 天",
  8058. M: "1 个月",
  8059. MM: "%d 个月",
  8060. y: "1 年",
  8061. yy: "%d 年",
  8062. },
  8063. week: {
  8064. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8065. dow: 1, // Monday is the first day of the week.
  8066. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8067. },
  8068. });
  8069. var date = new Date();
  8070. var d = date.getDate();
  8071. var m = date.getMonth();
  8072. var y = date.getFullYear();
  8073. var filterData = {
  8074. userId: loginUser.id,
  8075. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8076. "YYYY-MM-DD HH:mm:ss"
  8077. ),
  8078. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8079. "YYYY-MM-DD HH:mm:ss"
  8080. ),
  8081. };
  8082. var load = ($scope.load = function (filterData) {
  8083. api_bpm_schedule
  8084. .fetchSchedule(
  8085. filterData.userId,
  8086. filterData.startTime,
  8087. filterData.endTime
  8088. )
  8089. .then(function (response) {
  8090. if (response.status == 200) {
  8091. $scope.events = [];
  8092. var myData = response.list;
  8093. angular.forEach(myData, function (item) {
  8094. var eventTemp = {};
  8095. eventTemp.title = item.description;
  8096. eventTemp.type = item.scheduleClass.code;
  8097. eventTemp.startsAt = moment(
  8098. item["scheduleOrderDTO"].startTime
  8099. ).toDate();
  8100. eventTemp.endsAtTime = moment(
  8101. item["scheduleOrderDTO"].endTime
  8102. ).toDate();
  8103. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8104. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8105. //eventTemp.ends_at = moment(item.endTime).toDate();
  8106. eventTemp.id = item.id;
  8107. eventTemp.deletable = false;
  8108. eventTemp.user = item.user;
  8109. $scope.events.push(eventTemp);
  8110. });
  8111. }
  8112. });
  8113. });
  8114. // var load = $scope.load = function(filterData){
  8115. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8116. // console.log("response="+JSON.stringify(response));
  8117. // if(response.status==200){
  8118. // $scope.events = [];
  8119. // console.log(response.list);
  8120. // var myData = response.list;
  8121. // angular.forEach(myData,function(item){
  8122. // var eventTemp = {};
  8123. // eventTemp.title = item.description;
  8124. // eventTemp.type = item.scheduleClass.code;
  8125. // eventTemp.startsAt = moment(item.startTime).toDate();
  8126. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8127. // eventTemp.startTime = item.startTime;
  8128. // eventTemp.endTime = item.endTime;
  8129. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8130. // eventTemp.id = item.id;
  8131. // eventTemp.deletable = false;
  8132. // eventTemp.users = item.users;
  8133. // $scope.events.push(eventTemp);
  8134. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8135. // })
  8136. // }
  8137. // });
  8138. // }
  8139. $scope.scheduleClass = {};
  8140. var convertEvent = function (scheduleorder) {
  8141. var eventTemp = {};
  8142. eventTemp.title = scheduleorder.description;
  8143. eventTemp.type = scheduleorder.scheduleClass.code;
  8144. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8145. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8146. eventTemp.id = scheduleorder.id;
  8147. eventTemp.user = scheduleorder.user;
  8148. eventTemp.deletable = false;
  8149. return eventTemp;
  8150. };
  8151. // var convertEvent = function(scheduleorder){
  8152. // var eventTemp = {};
  8153. // eventTemp.title = scheduleorder.description;
  8154. // eventTemp.type = scheduleorder.scheduleClass.code;
  8155. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8156. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8157. // eventTemp.id = scheduleorder.id;
  8158. // eventTemp.users = scheduleorder.users;
  8159. // eventTemp.deletable = false;
  8160. // return eventTemp;
  8161. // }
  8162. api_bpm_schedule.getScheduleClass().then(function (response) {
  8163. if (response.status == 200) {
  8164. var scheduleClassList = response.list;
  8165. angular.forEach(scheduleClassList, function (item) {
  8166. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8167. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8168. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8169. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8170. $scope.scheduleClass[item["code"]] = item;
  8171. });
  8172. }
  8173. });
  8174. $scope.events = [];
  8175. $scope.calendarView = "month";
  8176. //$scope.calendarDay = new Date();
  8177. $scope.calendarDate = moment().startOf("month").toDate();
  8178. $scope.timeLabel = "时间";
  8179. $scope.eventLabel = "描述";
  8180. function showModal(action, event) {
  8181. // console.log("action="+JSON.stringify(action))
  8182. var modalInstance = $aside.open({
  8183. templateUrl: "scheduleEvent.html",
  8184. placement: "right",
  8185. size: "sm",
  8186. backdrop: true,
  8187. controller: function (
  8188. $scope,
  8189. $modalInstance,
  8190. scheduleClass,
  8191. APIService,
  8192. MementFormat
  8193. ) {
  8194. $scope.$modalInstance = $modalInstance;
  8195. $scope.action = action;
  8196. $scope.event = event;
  8197. $scope.scheduleClassic = scheduleClass;
  8198. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8199. // if(oldvalue == newvalue) return;
  8200. // if(scheduleClass[newvalue]){
  8201. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8202. var em = MementFormat(scheduleClass[newvalue].endTime);
  8203. console.log("sm=" + JSON.stringify(sm));
  8204. event.starts_at = MementFormat(event.startTime)
  8205. .startOf("day")
  8206. .add(sm.hour(), "hour")
  8207. .add(sm.minute(), "minute")
  8208. .add(sm.second(), "second")
  8209. .toDate();
  8210. console.log(
  8211. "event.starts_at=" + JSON.stringify(event.starts_at)
  8212. );
  8213. if (sm.hour() > em.hour()) {
  8214. event.ends_at = MementFormat(event.startTime)
  8215. .startOf("day")
  8216. .add(1, "day")
  8217. .add(em.hour(), "hour")
  8218. .add(em.minute(), "minute")
  8219. .add(em.second(), "second")
  8220. .toDate();
  8221. console.log(
  8222. "event.ends_at=" + JSON.stringify(event.starts_at)
  8223. );
  8224. } else {
  8225. event.ends_at = MementFormat(event.startTime)
  8226. .startOf("day")
  8227. .add(em.hour(), "hour")
  8228. .add(em.minute(), "minute")
  8229. .add(em.second(), "second")
  8230. .toDate();
  8231. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8232. }
  8233. // }
  8234. });
  8235. // $scope.ok = function (event) {
  8236. // console.log("event="+JSON.stringify(event))
  8237. // event.action = action;
  8238. // $modalInstance.close(event);
  8239. // };
  8240. $scope.cancel = function (event) {
  8241. $modalInstance.dismiss();
  8242. };
  8243. var acUserSelect = ($scope.refreshUser = function (key) {
  8244. //for test
  8245. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  8246. // return;
  8247. var data = {
  8248. idx: "0",
  8249. sum: "5",
  8250. };
  8251. if (key) {
  8252. data["user"] = {
  8253. name: key,
  8254. };
  8255. }
  8256. APIService.fetchDataList("user", data).then(function (
  8257. response
  8258. ) {
  8259. if (response) {
  8260. if ((response.status = 200)) {
  8261. $scope.users = response.list;
  8262. console.log($scope.users);
  8263. }
  8264. }
  8265. });
  8266. });
  8267. if (angular.isDefined(event.users) && event.users.length > 0) {
  8268. }
  8269. $scope.users = [event.user];
  8270. acUserSelect();
  8271. },
  8272. resolve: {
  8273. scheduleClass: function () {
  8274. return $scope.scheduleClass;
  8275. },
  8276. APIService: function () {
  8277. return api_user_data;
  8278. },
  8279. MementFormat: function () {
  8280. return moment;
  8281. },
  8282. },
  8283. });
  8284. modalInstance.result.then(function (selectedEvent) {
  8285. if (selectedEvent.action == "Clicked") {
  8286. // var data = {
  8287. // "scheduleorder":{
  8288. // "id":selectedEvent.id,
  8289. // "description":selectedEvent.title,
  8290. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8291. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8292. // "users":selectedEvent.users,
  8293. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8294. // }
  8295. // };
  8296. // api_bpm_schedule.update(data).then(function(response){
  8297. // if(response.status==200){
  8298. // SweetAlert.swal({
  8299. // title: "操作成功!",
  8300. // text: "排班更新成功!",
  8301. // type: "succes"
  8302. // });
  8303. // angular.forEach($scope.events,function(item){
  8304. // if(item.id==selectedEvent.id){
  8305. // item = selectedEvent;
  8306. // }
  8307. // })
  8308. // }else{
  8309. // SweetAlert.swal({
  8310. // title: "操作失败",
  8311. // text: "排班更新失败,请稍后重试!",
  8312. // type: "error"
  8313. // })
  8314. // }
  8315. // })
  8316. } else {
  8317. //
  8318. }
  8319. });
  8320. }
  8321. $scope.moment = function (string) {
  8322. return moment(string);
  8323. };
  8324. $scope.eventClicked = function (event) {
  8325. // console.log("event="+JSON.stringify(event))
  8326. showModal("Clicked", event);
  8327. };
  8328. $scope.eventEdited = function (event) {
  8329. showModal("Edited", event);
  8330. };
  8331. var updateView = function (newvalue, oldvalue) {
  8332. if (oldvalue == newvalue) return;
  8333. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8334. if ($scope.calendarView == "year") {
  8335. } else if ($scope.calendarView == "month") {
  8336. timeStart = moment(newvalue).startOf("month");
  8337. timeEnd = moment(newvalue).endOf("month");
  8338. } else if ($scope.calendarView == "week") {
  8339. timeStart = moment(newvalue).startOf("week");
  8340. timeEnd = moment(newvalue).endOf("week");
  8341. } else if ($scope.calendarView == "Day") {
  8342. timeStart = moment(newvalue).startOf("day");
  8343. timeEnd = moment(newvalue).endOf("day");
  8344. }
  8345. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8346. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8347. filterData["startTime"] = timeStartSpan;
  8348. filterData["endTime"] = timeEndSpan;
  8349. load(filterData);
  8350. };
  8351. $scope.$watch("calendarDate", updateView);
  8352. $scope.next = function () {
  8353. $scope.calendarControl.next();
  8354. };
  8355. $scope.prev = function () {
  8356. $scope.calendarControl.prev();
  8357. };
  8358. $scope.setCalendarToToday = function () {
  8359. $scope.calendarDay = new Date();
  8360. };
  8361. $scope.toggle = function ($event, field, event) {
  8362. $event.preventDefault();
  8363. $event.stopPropagation();
  8364. event[field] = !event[field];
  8365. };
  8366. $scope.load(filterData);
  8367. $scope.more = function () {
  8368. $state.go("app.scheduling.myscheduling", {});
  8369. };
  8370. $scope.removes = function () {
  8371. var modalInstance = $modal.open({
  8372. templateUrl: "assets/views/delete.html",
  8373. controller: function ($scope, $modalInstance) {
  8374. $scope.ok = function () {
  8375. $modalInstance.close();
  8376. };
  8377. $scope.cancel = function () {
  8378. $modalInstance.dismiss("cancel");
  8379. };
  8380. },
  8381. size: "sm",
  8382. });
  8383. modalInstance.result.then(function () {
  8384. for (
  8385. var i = 0;
  8386. i <
  8387. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8388. i++
  8389. ) {
  8390. if (
  8391. $scope.fields.type ==
  8392. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8393. .type
  8394. ) {
  8395. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8396. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8397. i,
  8398. 1
  8399. );
  8400. break;
  8401. }
  8402. }
  8403. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8404. if (vmForm) {
  8405. //console.log("vmForm>>>");//console.log(vmForm);
  8406. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8407. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8408. }
  8409. });
  8410. };
  8411. },
  8412. ],
  8413. });
  8414. //空格组件
  8415. formlyConfigProvider.setType({
  8416. name: "ui-black",
  8417. /*extends: 'input',*/
  8418. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8419. });
  8420. //请求人最近事件
  8421. formlyConfigProvider.setType({
  8422. name: "ui-recentIncident",
  8423. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8424. controller: [
  8425. "$scope",
  8426. "$modal",
  8427. "api_solution",
  8428. function ($scope, $modal, api_solution) {
  8429. var filterData = {
  8430. incident: {
  8431. requester: {
  8432. id: "",
  8433. },
  8434. },
  8435. idx: 0,
  8436. sum: 3,
  8437. };
  8438. setInterval(function () {
  8439. if (
  8440. filterData.incident.requester.id == "" ||
  8441. filterData.incident.requester.id != $scope.model.requester.id
  8442. ) {
  8443. var requester = $scope.model.requester;
  8444. if (requester != null && angular.isDefined(requester.id)) {
  8445. filterData.incident.requester.id = $scope.model.requester.id;
  8446. $scope.options.templateOptions
  8447. .getWorkernumber(
  8448. $scope.options.templateOptions.ApiService,
  8449. filterData
  8450. )
  8451. .then(function (result) {
  8452. var modelData =
  8453. $scope.options.templateOptions.Restangular.stripRestangular(
  8454. result
  8455. );
  8456. if (modelData.status == 200) {
  8457. $scope.lastrequst = modelData.list;
  8458. }
  8459. });
  8460. requester = null;
  8461. } else {
  8462. }
  8463. } else {
  8464. }
  8465. }, 1000);
  8466. $scope.detail = function (data) {
  8467. var modalInstance = $modal.open({
  8468. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8469. controller: function ($scope, $modalInstance) {
  8470. $scope.entity = {};
  8471. $scope.entity = data;
  8472. $scope.cancel = function () {
  8473. $modalInstance.dismiss("cancel");
  8474. };
  8475. },
  8476. size: "lg",
  8477. });
  8478. };
  8479. },
  8480. ],
  8481. });
  8482. //参数列表
  8483. formlyConfigProvider.setType({
  8484. name: "ui-listinput",
  8485. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8486. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8487. defaultOptions: function (options) {
  8488. return {
  8489. templateOptions: {},
  8490. };
  8491. },
  8492. controller: ["$scope", function ($scope) { }],
  8493. });
  8494. //时间段控件(分)
  8495. formlyConfigProvider.setType({
  8496. name: "ui-timeslot",
  8497. extends: "input",
  8498. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8499. controller: ["$scope", function ($scope) { }],
  8500. });
  8501. //优先级级联-逾期时间
  8502. formlyConfigProvider.setType({
  8503. name: "ui-overtime",
  8504. extends: "input",
  8505. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8506. controller: [
  8507. "$scope",
  8508. "api_bpm_domain",
  8509. function ($scope, api_bpm_domain) {
  8510. var filteData = {};
  8511. var datas = {};
  8512. setInterval(function () {
  8513. if (
  8514. $scope.model.priority &&
  8515. $scope.model.priority.id != null &&
  8516. filteData &&
  8517. datas != $scope.model.priority.id
  8518. ) {
  8519. filteData = "L" + $scope.model.priority.id;
  8520. datas = $scope.model.priority.id;
  8521. // console.log($scope.options.templateOptions)
  8522. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8523. // var overtime=requester.date;
  8524. if (requester.state == 200) {
  8525. // if($scope.options.key=="date"){
  8526. $scope.model[$scope.options.key] = requester.date;
  8527. // }
  8528. }
  8529. });
  8530. }
  8531. }, 1000);
  8532. },
  8533. ],
  8534. });
  8535. formlyConfigProvider.setType({
  8536. name: "ui-responsetime",
  8537. extends: "input",
  8538. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8539. controller: [
  8540. "$scope",
  8541. "api_bpm_domain",
  8542. function ($scope, api_bpm_domain) {
  8543. var filteData = {};
  8544. var datas = {};
  8545. setInterval(function () {
  8546. if (
  8547. $scope.model.priority &&
  8548. $scope.model.priority.id != null &&
  8549. filteData &&
  8550. datas != $scope.model.priority.id
  8551. ) {
  8552. filteData = "L" + $scope.model.priority.id;
  8553. datas = $scope.model.priority.id;
  8554. // console.log($scope.options.templateOptions)
  8555. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8556. // var overtime=requester.date;
  8557. if (requester.state == 200) {
  8558. var keyName = {};
  8559. // $scope.model.overdueTime = requester.date;
  8560. if ($scope.options.key == "expectIntroTime") {
  8561. keyName = "resolveTime";
  8562. } else if ($scope.options.key == "expectResponseTime") {
  8563. keyName = "responseTime";
  8564. }
  8565. $scope.model[$scope.options.key] =
  8566. requester.serviceLevelAgreement[keyName];
  8567. // }
  8568. console.log($scope.$parent.$parent.$parent.model);
  8569. }
  8570. if (requester.date1) {
  8571. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8572. requester.date;
  8573. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8574. requester.date1;
  8575. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8576. requester.serviceLevelAgreement.resolveTime;
  8577. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8578. requester.serviceLevelAgreement.responseTime;
  8579. }
  8580. });
  8581. }
  8582. }, 1000);
  8583. },
  8584. ],
  8585. });
  8586. //知识库按钮组件
  8587. formlyConfigProvider.setType({
  8588. name: "ui-discasecade",
  8589. extends: "input",
  8590. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8591. defaultOptions: function (options) {
  8592. return {
  8593. templateOptions: {
  8594. relationAction: function (fields, modelscope, item) { },
  8595. },
  8596. validators: {
  8597. required: {
  8598. expression: function (viewValue, modelValue) {
  8599. var value = modelValue || viewValue;
  8600. // return value = "true";
  8601. },
  8602. },
  8603. },
  8604. };
  8605. },
  8606. controller: [
  8607. "$scope",
  8608. "$rootScope",
  8609. "$modal",
  8610. "SweetAlert",
  8611. "api_bpm_data",
  8612. "api_solution",
  8613. "$aside",
  8614. "api_zsk",
  8615. "api_bpm_domain",
  8616. function (
  8617. $scope,
  8618. $rootScope,
  8619. $modal,
  8620. SweetAlert,
  8621. api_bpm_data,
  8622. api_solution,
  8623. $aside,
  8624. api_zsk,
  8625. api_bpm_domain
  8626. ) {
  8627. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8628. $scope.searchField = $scope.options.model[$scope.options.key];
  8629. $scope.searchData = "";
  8630. $scope.onChangeadd = function (searchData) {
  8631. $scope.searchKey = searchData.account;
  8632. // $scope.searchDataadd = searchData;
  8633. var requesdata = angular.copy(searchData);
  8634. $scope.requester = requesdata;
  8635. };
  8636. $scope.refreshUseradd = function (searchKey) {
  8637. //主题搜索
  8638. $scope.searchData = searchKey;
  8639. reashdata($scope.searchData);
  8640. };
  8641. $scope.getMydata = function (x) {
  8642. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8643. $scope.searchField = $scope.model[$scope.options.key];
  8644. };
  8645. $scope.getMydataone = function (x) {
  8646. $scope.model[$scope.options.key] = x;
  8647. $scope.searchField = $scope.model[$scope.options.key];
  8648. };
  8649. $scope.fildata = {
  8650. idx: 0,
  8651. sum: 10,
  8652. // 'incident': { 'tilte': item }
  8653. };
  8654. function reashdata(item) {
  8655. if (item && item != "") {
  8656. angular.extend($scope.fildata, {
  8657. incident: {
  8658. title: item,
  8659. },
  8660. });
  8661. } else {
  8662. delete $scope.fildata.incident;
  8663. }
  8664. api_bpm_data
  8665. .fetchDataList("incident", $scope.fildata)
  8666. .then(function (response) {
  8667. if (response) {
  8668. if ((response.status = 200)) {
  8669. var myData = response;
  8670. $scope.myData = myData.list;
  8671. }
  8672. }
  8673. });
  8674. }
  8675. function delHtmlTag(str) {
  8676. return str.replace(/<[^>]+>/g, "");
  8677. }
  8678. // reashdata();
  8679. var changedata = {};
  8680. setInterval(function () {
  8681. if (
  8682. $scope.model.category != null &&
  8683. $scope.model.category.id != changedata.id &&
  8684. $scope.model.titles != $scope.model.category
  8685. ) {
  8686. $scope.searchData = {};
  8687. changedata = angular.copy($scope.model.category);
  8688. if ($scope.options.key == "title") {
  8689. var filterData = {
  8690. idx: 0,
  8691. sum: 1000,
  8692. };
  8693. api_bpm_data
  8694. .fetchDataList("incidentcategory", filterData)
  8695. .then(function (data) {
  8696. var datalist = data.list;
  8697. angular.forEach(datalist, function (item) {
  8698. if (item.id == $scope.model.category.id) {
  8699. $scope.model[$scope.options.key] = item.category;
  8700. $scope.searchField =
  8701. $scope.options.model[$scope.options.key];
  8702. $scope.titles = item.category;
  8703. titles = $scope.model.category;
  8704. }
  8705. });
  8706. });
  8707. }
  8708. }
  8709. }, 1000);
  8710. $scope.open = function (key, options, fildata, $event, model) {
  8711. if (key && key.length > 1) {
  8712. api_zsk
  8713. .solutionData(
  8714. {
  8715. solution: {
  8716. searchWord: key,
  8717. },
  8718. idx: "0",
  8719. sum: "1000",
  8720. },
  8721. "solution"
  8722. )
  8723. .then(function (response) {
  8724. if (response && response.list.length > 0) {
  8725. $scope.dlideboxslide = true;
  8726. angular.forEach(response, function (item) {
  8727. console.log(response);
  8728. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8729. // if (response.status == 200) {
  8730. // var quote = { 'totalNum': response.totalNum }
  8731. // item = angular.extend(item, quote)
  8732. // }
  8733. // })
  8734. $scope.searchData = response.list;
  8735. console.log($scope.searchData);
  8736. });
  8737. $scope.changes = false;
  8738. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8739. // $scope.closepages = function(e) {
  8740. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8741. // event.preventDefault();
  8742. // };
  8743. $scope.shows = false;
  8744. $scope.tempData = {};
  8745. $scope.showpage = function (item) {
  8746. item.content = delHtmlTag(item.content);
  8747. $scope.shows = true;
  8748. $scope.tempData = item;
  8749. if (item.content != null) {
  8750. $scope.tempData.content = $scope.tempData.content
  8751. .replace("<p>", "")
  8752. .replace("</p>", "");
  8753. }
  8754. $scope.knowledgedata = item;
  8755. $scope.pageid = item.id;
  8756. $scope.changes = !$scope.changes;
  8757. api_bpm_domain
  8758. .listAttachments(item.id)
  8759. // api_solution.fetchDataList('file', {
  8760. // "file": {
  8761. // "solutionId": item.id
  8762. // },
  8763. // "idx": "0",
  8764. // "sum": "1000"
  8765. // })
  8766. .then(function (data) {
  8767. if (data) {
  8768. $scope.attachments = data.list;
  8769. $scope.view = function (attachmentId) {
  8770. for (
  8771. var i = 0;
  8772. i < $scope.attachments.length;
  8773. i++
  8774. ) {
  8775. if ($scope.attachments[i].id == attachmentId) {
  8776. window.open($scope.attachments[i].previewUrl);
  8777. }
  8778. }
  8779. };
  8780. $scope.download = function (contentId, filename) {
  8781. api_solution
  8782. .getSolutionDowpath(contentId)
  8783. .then(function (response) {
  8784. var file = new Blob([response], {
  8785. type: "application/octet-stream",
  8786. });
  8787. // var filename = filename;
  8788. var fileURL = URL.createObjectURL(file);
  8789. var a = document.createElement("a");
  8790. a.href = fileURL;
  8791. a.target = "_blank";
  8792. a.download = filename;
  8793. document.body.appendChild(a);
  8794. a.click();
  8795. });
  8796. };
  8797. }
  8798. });
  8799. };
  8800. $scope.related = function (item) {
  8801. if (item.content != null) {
  8802. item.content = item.content
  8803. .replace("<p>", "")
  8804. .replace("</p>", "");
  8805. }
  8806. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8807. options.model.handleDescription = item.content;
  8808. var data = {
  8809. solutionQuote: {
  8810. solutionId: item.id,
  8811. incidentsign: options.model.incidentsign,
  8812. },
  8813. };
  8814. api_zsk.solutionQuote(item.id).then(function (response) {
  8815. if (response.status == 200) {
  8816. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8817. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8818. "close";
  8819. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8820. } else {
  8821. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8822. }
  8823. });
  8824. };
  8825. $scope.close = function () {
  8826. $scope.changes = !$scope.changes;
  8827. event.preventDefault();
  8828. };
  8829. }
  8830. });
  8831. }
  8832. };
  8833. },
  8834. ],
  8835. });
  8836. //侧滑选择重复事件
  8837. formlyConfigProvider.setType({
  8838. name: "ui-repeatIncidentbtn",
  8839. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8840. defaultOptions: function (options) {
  8841. return {
  8842. templateOptions: {
  8843. relationAction: function (fields, modelscope, item) { },
  8844. },
  8845. validators: {
  8846. required: {
  8847. expression: function (viewValue, modelValue) {
  8848. // var value = modelValue || viewValue;
  8849. },
  8850. },
  8851. },
  8852. };
  8853. },
  8854. controller: [
  8855. "$scope",
  8856. "$rootScope",
  8857. "$modal",
  8858. "SweetAlert",
  8859. "api_bpm_data",
  8860. "api_solution",
  8861. "$aside",
  8862. "api_zsk",
  8863. "api_bpm_domain",
  8864. function (
  8865. $scope,
  8866. $rootScope,
  8867. $modal,
  8868. SweetAlert,
  8869. api_bpm_data,
  8870. api_solution,
  8871. $aside,
  8872. api_zsk,
  8873. api_bpm_domain
  8874. ) {
  8875. console.log($scope);
  8876. $scope.selection = {
  8877. id: "",
  8878. };
  8879. //认证计费数据获取
  8880. $scope.sumInfo = {};
  8881. function getSumInfo() {
  8882. api_bpm_data
  8883. .sumInfo($scope.model.incident.account)
  8884. .then(function (data) {
  8885. console.log(data);
  8886. if (data) {
  8887. $scope.sumInfo = data.data || {};
  8888. }
  8889. });
  8890. }
  8891. getSumInfo();
  8892. // 收起重复事件侧滑框
  8893. function reashdata(item) {
  8894. var fildata = {
  8895. idx: 0,
  8896. incident: {
  8897. department: {
  8898. id: $scope.model.incident.department.id,
  8899. },
  8900. },
  8901. sum: 3,
  8902. };
  8903. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8904. console.log(data);
  8905. if (data) {
  8906. $scope.repeatData = data.list;
  8907. }
  8908. });
  8909. }
  8910. reashdata();
  8911. // 确认选中的重复事件
  8912. $scope.repeatIncidentOk = function () {
  8913. if ($scope.selection.id) {
  8914. $scope.model.incident.repeat = $scope.selection;
  8915. $scope.model.isRepeat = true; //隐藏处理信息
  8916. console.log($scope.model);
  8917. }
  8918. angular.element("#repeatIncident").removeClass("active");
  8919. };
  8920. // 取消选中的重复事件
  8921. $scope.repeatIncidentCancle = function () {
  8922. angular.element("#repeatIncident").removeClass("active");
  8923. return;
  8924. };
  8925. },
  8926. ],
  8927. });
  8928. //侧滑选择知识库查询
  8929. formlyConfigProvider.setType({
  8930. name: "ui-knowledgebtn",
  8931. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8932. defaultOptions: function (options) {
  8933. return {
  8934. templateOptions: {
  8935. relationAction: function (fields, modelscope, item) { },
  8936. },
  8937. validators: {
  8938. required: {
  8939. expression: function (viewValue, modelValue) {
  8940. // var value = modelValue || viewValue;
  8941. },
  8942. },
  8943. },
  8944. };
  8945. },
  8946. controller: [
  8947. "$scope",
  8948. "$rootScope",
  8949. "$modal",
  8950. "SweetAlert",
  8951. "api_bpm_data",
  8952. "api_solution",
  8953. "$aside",
  8954. "api_zsk",
  8955. "api_bpm_domain",
  8956. "api_wechatfile",
  8957. "up_down_file",
  8958. function (
  8959. $scope,
  8960. $rootScope,
  8961. $modal,
  8962. SweetAlert,
  8963. api_bpm_data,
  8964. api_solution,
  8965. $aside,
  8966. api_zsk,
  8967. api_bpm_domain,
  8968. api_wechatfile,
  8969. up_down_file
  8970. ) {
  8971. $scope.keypressModel = function (e, key) {
  8972. if (e.keyCode === 13) {
  8973. $scope.openModel(key);
  8974. }
  8975. };
  8976. // 引用知识库点击
  8977. $scope.searchKeyWord = "";
  8978. $scope.openModel = function (key) {
  8979. // alert(1)//重点
  8980. $scope.searchKeyWord = key;
  8981. if (key) {
  8982. api_zsk
  8983. .solutionData(
  8984. {
  8985. solution: {
  8986. threeSearch: key,
  8987. status: { id: 72 }, //已发布
  8988. selectType: "keySearch",
  8989. },
  8990. idx: "0",
  8991. sum: "1000",
  8992. },
  8993. "solution"
  8994. )
  8995. .then(function (response) {
  8996. $scope.searchData = response.list;
  8997. });
  8998. }
  8999. };
  9000. $scope.openModel($scope.model.incident.description);
  9001. // 展开/收起
  9002. $scope.showId = "";
  9003. $scope.ifshow = false;
  9004. $scope.showAll = function (id) {
  9005. $scope.attachments = [];
  9006. if ($scope.showId == id) {
  9007. $scope.ifshow = !$scope.ifshow;
  9008. } else {
  9009. $scope.ifshow = true;
  9010. }
  9011. $scope.showId = id;
  9012. // 获取附件
  9013. api_wechatfile
  9014. .listAttachments("knowledge", $scope.showId)
  9015. .then(function (data) {
  9016. $scope.attachments = data.data;
  9017. $scope.download = function (token, filename) {
  9018. var downUrl = up_down_file
  9019. .downloadAttachment("common/common/downloadAttachment", token)
  9020. .getRequestedUrl();
  9021. // window.open(downUrl);
  9022. var a = document.createElement("a");
  9023. a.href = downUrl;
  9024. a.target = "_blank";
  9025. a.download = filename;
  9026. document.body.appendChild(a);
  9027. a.click();
  9028. };
  9029. });
  9030. };
  9031. // 引用
  9032. $scope.related = function (item) {
  9033. console.log(item, "引用名");
  9034. if (item.content) {
  9035. item.content = item.content
  9036. .replace(/<p>/g, "")
  9037. .replace(/<\/p>/g, "")
  9038. .replace(/&nbsp;/g, "");
  9039. }
  9040. $scope.model.incident.handleDescription = item.content;
  9041. $scope.model.incident.title = $scope.model.incident.description =
  9042. item.title;
  9043. $scope.model.incident.category = item.category;
  9044. if (item.category) {
  9045. $scope.model.incident.priority.id = item.category.priority.id;
  9046. item.category.label = item.category.category;
  9047. }
  9048. var categoryId = item.category ? item.category.id : "";
  9049. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  9050. function getres(nodes) {
  9051. if (!nodes || nodes.length == 0) {
  9052. return;
  9053. }
  9054. nodes.forEach((e) => {
  9055. e.selected = false;
  9056. if (e.id == categoryId) {
  9057. e.selected = true;
  9058. return false;
  9059. }
  9060. getres(e.children);
  9061. });
  9062. }
  9063. var categorys = [];
  9064. $scope.fields.forEach((e, i) => {
  9065. if (e.key == "category") {
  9066. categorys = e.templateOptions.options;
  9067. if (categorys.length) {
  9068. getres(categorys);
  9069. $scope.fields[i].templateOptions.options = categorys;
  9070. $scope.$root.refreshSelectedItems();
  9071. }
  9072. return false;
  9073. }
  9074. });
  9075. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9076. $scope.model.candidateGroups = item.category
  9077. ? item.category.group
  9078. : {};
  9079. // 携带关联优先级,事件工单信息的时间
  9080. if (
  9081. $scope.model &&
  9082. $scope.model.incident &&
  9083. item.category &&
  9084. item.category.priority &&
  9085. item.category.priority.id
  9086. ) {
  9087. api_bpm_domain
  9088. .expectedTime("L" + (item.category.priority.id - 1559))
  9089. .then(function (res) {
  9090. $scope.model.incident.expectResponseTime =
  9091. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9092. res.serviceLevelAgreement.responseTime;
  9093. $scope.model.incident.expectIntroTime =
  9094. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9095. res.serviceLevelAgreement.resolveTime;
  9096. $scope.model.incident.overdueTime =
  9097. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9098. res.date;
  9099. });
  9100. }
  9101. api_zsk.solutionQuote(item.id).then(function (response) {
  9102. if (response.status == 200) {
  9103. $("#seachknowledge").removeClass("active");
  9104. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9105. $scope.$parent.$parent.$parent.model.start_code = "close";
  9106. $scope.$parent.$parent.$parent.model.directClose = 0;
  9107. console.log($scope.model);
  9108. } else {
  9109. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9110. }
  9111. });
  9112. };
  9113. },
  9114. ],
  9115. });
  9116. //下拉输入组件
  9117. formlyConfigProvider.setType({
  9118. name: "ui-selectinput",
  9119. extends: "input",
  9120. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9121. defaultOptions: function (options) {
  9122. return {
  9123. templateOptions: {
  9124. refresh: function () { },
  9125. refreshDelay: 0,
  9126. linkage: function (modelName, data) { },
  9127. },
  9128. };
  9129. },
  9130. controller: [
  9131. "$scope",
  9132. "$rootScope",
  9133. "$modal",
  9134. "SweetAlert",
  9135. "api_bpm_data",
  9136. "api_solution",
  9137. "$aside",
  9138. function (
  9139. $scope,
  9140. $rootScope,
  9141. $modal,
  9142. SweetAlert,
  9143. api_bpm_data,
  9144. api_solution,
  9145. $aside
  9146. ) {
  9147. $scope.searchData = "";
  9148. $scope.onChangeadd = function (searchData) {
  9149. // $scope.searchKey = searchData.account;
  9150. // var requesdata = angular.copy(searchData)
  9151. // $scope.requester = requesdata;
  9152. };
  9153. $scope.refreshUseradd = function (searchKey) {
  9154. //主题搜索
  9155. // $scope.searchData = searchKey;
  9156. // reashdata($scope.searchData);
  9157. };
  9158. $scope.getMydata = function (x) {
  9159. $scope.model[$scope.options.key] =
  9160. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9161. $scope.searchField = $scope.model[$scope.options.key];
  9162. };
  9163. $scope.getMydataone = function (x) {
  9164. $scope.model[$scope.options.key] = x;
  9165. $scope.searchField = $scope.model[$scope.options.key];
  9166. if (
  9167. $scope.model[$scope.options.key] &&
  9168. $scope.model[$scope.options.key] != ""
  9169. ) {
  9170. $scope.hidden = false;
  9171. } else {
  9172. $scope.hidden = true;
  9173. }
  9174. };
  9175. function reashdata(item) {
  9176. $scope.myData = $scope.options.templateOptions.mydata;
  9177. }
  9178. reashdata();
  9179. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9180. $scope.options.templateOptions.fetchItems($scope);
  9181. }
  9182. },
  9183. ],
  9184. });
  9185. //重构组件模板
  9186. //获取当前人
  9187. formlyConfigProvider.setType({
  9188. name: "ui-users",
  9189. extends: "input",
  9190. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9191. defaultOptions: function (options) {
  9192. return {
  9193. templateOptions: {
  9194. translate: "",
  9195. refreshDelay: 0,
  9196. },
  9197. };
  9198. },
  9199. controller: [
  9200. "$scope",
  9201. function ($scope) {
  9202. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9203. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9204. },
  9205. ],
  9206. });
  9207. //只读控件
  9208. formlyConfigProvider.setType({
  9209. name: "ui-label",
  9210. extends: "input",
  9211. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9212. defaultOptions: function (options) {
  9213. return {
  9214. templateOptions: {
  9215. translate: "",
  9216. refreshDelay: 0,
  9217. },
  9218. };
  9219. },
  9220. controller: [
  9221. "$scope",
  9222. "$rootScope",
  9223. function ($scope, $rootScope) {
  9224. // console.log($scope.options.templateOptions)
  9225. // console.log($scope.options,'options1122');
  9226. $scope.isSolutionLabel = false;
  9227. $scope.solutionLabelStr = "";
  9228. // console.log($scope.options.templateOptions.solotinLabel);
  9229. if ($scope.options.templateOptions.solotinLabel) {
  9230. $scope.isSolutionLabel = true;
  9231. if ($scope.model[$scope.options.key]) {
  9232. var solutionArr = $scope.model[$scope.options.key].split("/");
  9233. $scope.solutionLabelStr = solutionArr.join(" ");
  9234. }
  9235. }
  9236. var value = $scope.model[$scope.options.key];
  9237. // ----------------
  9238. // ----------------
  9239. // console.log(value, 'pppp')
  9240. function treeDesc(children, key, label) {
  9241. if (label == "") {
  9242. label = children[key];
  9243. } else {
  9244. label = children[key] + "-" + label;
  9245. }
  9246. if (angular.isDefined(children.parent)) {
  9247. treeDesc(children.parent, key, label);
  9248. } else {
  9249. return label;
  9250. }
  9251. }
  9252. if (angular.isArray(value)) {
  9253. var tempValue = "";
  9254. angular.forEach(value, function (item) {
  9255. if (tempValue != "") {
  9256. tempValue = tempValue + ",";
  9257. }
  9258. tempValue =
  9259. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9260. item;
  9261. });
  9262. $scope.options.templateOptions.translate = tempValue;
  9263. } else if (angular.isObject(value)) {
  9264. if (
  9265. angular.isDefined(value.children) ||
  9266. angular.isDefined(value.parent)
  9267. ) {
  9268. //tree
  9269. // console.log("value.parent="+JSON.stringify(value.parent))
  9270. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9271. nameLabel = treeDesc(
  9272. value.parent,
  9273. $scope.options.templateOptions.labelProp,
  9274. nameLabel
  9275. );
  9276. $scope.options.templateOptions.translate = nameLabel;
  9277. } else {
  9278. $scope.options.templateOptions.translate = value;
  9279. }
  9280. } else if (
  9281. angular.isString(value) &&
  9282. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9283. ) {
  9284. // console.log("value=" + value);
  9285. $scope.options.templateOptions.translate = value;
  9286. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9287. // console.log("value="+value);
  9288. // $scope.options.templateOptions.translate = value;
  9289. } else {
  9290. // var datasdf = JSON.parse(value);
  9291. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9292. $scope.options.templateOptions.translate = value;
  9293. }
  9294. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9295. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9296. $scope.options.templateOptions.translate =
  9297. $scope.options.templateOptions.transform(
  9298. $scope.originalModel,
  9299. value,
  9300. $rootScope,
  9301. $scope
  9302. );
  9303. }
  9304. // console.log($scope.options.templateOptions.translate,99999);
  9305. },
  9306. ],
  9307. });
  9308. //小标题组件
  9309. formlyConfigProvider.setType({
  9310. name: "ui-header",
  9311. template:
  9312. '<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>',
  9313. });
  9314. //标题组件
  9315. formlyConfigProvider.setType({
  9316. name: "ui-title",
  9317. template:
  9318. '<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>',
  9319. });
  9320. //标栏是否展示
  9321. formlyConfigProvider.setType({
  9322. name: "ui-orshow",
  9323. template:
  9324. '<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>',
  9325. controller: [
  9326. "$scope",
  9327. function ($scope) {
  9328. $scope.clickshow = function (key) {
  9329. // $scope.model[$scope.options.key] != key;
  9330. if (key == false) {
  9331. $scope.model[$scope.options.key] = true;
  9332. } else {
  9333. $scope.model[$scope.options.key] = false;
  9334. }
  9335. };
  9336. },
  9337. ],
  9338. });
  9339. //按钮组
  9340. formlyConfigProvider.setType({
  9341. name: "ui-button",
  9342. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9343. defaultOptions: function (options) {
  9344. return {
  9345. noFormControl: true,
  9346. };
  9347. },
  9348. });
  9349. //3d组link
  9350. formlyConfigProvider.setType({
  9351. name: "ui-link",
  9352. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9353. defaultOptions: function (options) {
  9354. return {
  9355. noFormControl: true,
  9356. };
  9357. },
  9358. });
  9359. //隐藏域组件
  9360. formlyConfigProvider.setType({
  9361. name: "ui-hidden",
  9362. extends: "input",
  9363. template:
  9364. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9365. defaultOptions: function (options) {
  9366. return {
  9367. // noFormControl: true
  9368. };
  9369. },
  9370. });
  9371. //文本框组件
  9372. formlyConfigProvider.setType({
  9373. name: "ui-input",
  9374. extends: "input",
  9375. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9376. defaultOptions: function (options) {
  9377. return {
  9378. templateOptions: {
  9379. transform: function (value) { },
  9380. },
  9381. };
  9382. },
  9383. controller: [
  9384. "$scope",
  9385. "$timeout",
  9386. function ($scope, $timeout) {
  9387. // console.log($scope.model[$scope.options.key]);
  9388. // console.log($scope.options)
  9389. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9390. $scope.model[$scope.options.key] =
  9391. $scope.options.templateOptions.linkData($scope.model);
  9392. }
  9393. },
  9394. ],
  9395. });
  9396. //搜索下拉框-故障地点seimin
  9397. formlyConfigProvider.setType({
  9398. name: "ui-select-search",
  9399. extends: "input",
  9400. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9401. defaultOptions: function (options) {
  9402. return {
  9403. templateOptions: {
  9404. transform: function (value) { },
  9405. },
  9406. };
  9407. },
  9408. controller: [
  9409. "$scope",
  9410. "$rootScope",
  9411. "api_search_area",
  9412. function ($scope, $rootScope, api_search_area) {
  9413. // console.log($scope.options, $scope.model)
  9414. // ----------------分割线 start-----------------
  9415. // 故障地点下拉
  9416. $scope.address_arr = []; //故障地点所有数据
  9417. $scope.addressFlag = false; //默认下拉框列表隐藏
  9418. //点击文本框
  9419. $scope.AddressClickHandle = function () {
  9420. $scope.getDepartmentList();
  9421. angular.element("#bx_address_ul").scrollTop(0);
  9422. };
  9423. //修改文字,实时监听
  9424. $scope.ksChangeHandle = _.debounce(function () {
  9425. $scope.model[$scope.options.key] =
  9426. $scope.model[$scope.options.key] === undefined
  9427. ? ""
  9428. : $scope.model[$scope.options.key];
  9429. $scope.getDepartmentList();
  9430. angular.element("#bx_address_ul").scrollTop(0);
  9431. }, 500);
  9432. //获取故障地点seimin
  9433. $scope.getDepartmentList = function () {
  9434. $scope.model[$scope.options.key] =
  9435. $scope.model[$scope.options.key] === null
  9436. ? ""
  9437. : $scope.model[$scope.options.key];
  9438. api_search_area
  9439. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9440. .then((res) => {
  9441. if (res.state == 200) {
  9442. $scope.address_arr = res.result;
  9443. $scope.addressFlag = true; //显示
  9444. }
  9445. })
  9446. .catch((err) => {
  9447. console.log(err);
  9448. });
  9449. };
  9450. // $scope.getDepartmentList();
  9451. // console.log($scope.model[$scope.options.key])
  9452. //下拉框列表选中
  9453. $scope.addressItemClick = function (obj) {
  9454. $scope.addressFlag = false; //隐藏
  9455. $scope.model[$scope.options.key] = obj.place
  9456. ? obj.area.area + obj.place
  9457. : obj.area;
  9458. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9459. $scope.model.selecthouseNumber = obj;
  9460. console.log($scope, 77777);
  9461. $scope.$root.selecthouseNumber = obj;
  9462. };
  9463. //点击空白处隐藏
  9464. angular.element(document).on("click", function (e) {
  9465. if (e.target !== angular.element("#bx_address").get(0)) {
  9466. $scope.addressFlag = false; //隐藏
  9467. //模拟placeholder
  9468. // if ($('#bx_address').val() == '') {
  9469. // $('#bx_address').val('请选择报修科室');
  9470. // }
  9471. }
  9472. });
  9473. // -----------------分割线 end----------------
  9474. },
  9475. ],
  9476. });
  9477. //知识库关键字组件
  9478. formlyConfigProvider.setType({
  9479. name: "ui-knowledgeKeywords",
  9480. extends: "input",
  9481. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9482. defaultOptions: function (options) {
  9483. return {
  9484. templateOptions: {
  9485. transform: function (value) { },
  9486. },
  9487. };
  9488. },
  9489. controller: [
  9490. "$scope",
  9491. "$timeout",
  9492. "SweetAlert",
  9493. function ($scope, $timeout, SweetAlert) {
  9494. $scope.valueLength = [
  9495. {
  9496. value: "",
  9497. },
  9498. ];
  9499. $scope.valueAll = [];
  9500. if ($scope.model[$scope.options.key]) {
  9501. var valueArr = $scope.model[$scope.options.key].split("/");
  9502. $scope.valueLength = [];
  9503. for (var i = 0; i < valueArr.length; i++) {
  9504. $scope.valueLength.push({
  9505. value: valueArr[i],
  9506. });
  9507. }
  9508. }
  9509. $scope.addIpt = function () {
  9510. if ($scope.valueLength.length < 5) {
  9511. $scope.valueLength.push({
  9512. value: "",
  9513. });
  9514. } else {
  9515. SweetAlert.swal({
  9516. title: "添加失败",
  9517. text: "关键字不能超过5个!",
  9518. type: "error",
  9519. confirmButtonColor: "#DD6B55",
  9520. });
  9521. }
  9522. };
  9523. $scope.closeIpt = function (data) {
  9524. $scope.valueLength.splice(data, 1);
  9525. };
  9526. $scope.toOption = function () {
  9527. $scope.valueAll = [];
  9528. for (var i = 0; i < $scope.valueLength.length; i++) {
  9529. if ($scope.valueLength[i].value != "") {
  9530. $scope.valueAll.push($scope.valueLength[i].value);
  9531. }
  9532. }
  9533. $scope.model.label = $scope.valueAll.join("/");
  9534. };
  9535. },
  9536. ],
  9537. });
  9538. //文本框组件
  9539. formlyConfigProvider.setType({
  9540. name: "ui-num",
  9541. extends: "input",
  9542. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9543. defaultOptions: function (options) {
  9544. return {
  9545. templateOptions: {
  9546. transform: function (value) { },
  9547. },
  9548. };
  9549. },
  9550. controller: [
  9551. "$scope",
  9552. "$timeout",
  9553. function ($scope, $timeout) {
  9554. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9555. $scope.model[$scope.options.key] =
  9556. $scope.options.templateOptions.linkData($scope.model);
  9557. }
  9558. $scope.clearNoNum = function (obj, attr) {
  9559. //先把非数字的都替换掉,除了数字和.
  9560. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9561. //必须保证第一个为数字而不是.
  9562. obj[attr] = obj[attr].replace(/^\./g, "");
  9563. //保证只有出现一个.而没有多个.
  9564. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9565. //保证.只出现一次,而不能出现两次以上
  9566. obj[attr] = obj[attr]
  9567. .replace(".", "$#$")
  9568. .replace(/\./g, "")
  9569. .replace("$#$", ".");
  9570. //小于最大值
  9571. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9572. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9573. // obj[attr] = '';
  9574. // }
  9575. };
  9576. },
  9577. ],
  9578. });
  9579. // //关联请求人文本框组件
  9580. // formlyConfigProvider.setType({
  9581. // name: 'ui-requestinput',
  9582. // extends: 'input',
  9583. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9584. // defaultOptions: function(options) {
  9585. // return {
  9586. // templateOptions: {
  9587. // transform: function(value) {},
  9588. // linkData: function(options) {}
  9589. // }
  9590. // };
  9591. // }
  9592. // });
  9593. //只读文本
  9594. formlyConfigProvider.setType({
  9595. name: "ui-disableinput",
  9596. extends: "input",
  9597. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9598. defaultOptions: function (options) {
  9599. return {
  9600. templateOptions: {
  9601. transform: function (value) {
  9602. var ret = "";
  9603. if (value) {
  9604. ret = "已删除";
  9605. } else {
  9606. ret = "正常";
  9607. }
  9608. return ret;
  9609. },
  9610. },
  9611. };
  9612. },
  9613. });
  9614. formlyConfigProvider.setType({
  9615. name: "ui-disinput",
  9616. extends: "input",
  9617. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9618. defaultOptions: function (options) {
  9619. return {
  9620. templateOptions: {},
  9621. };
  9622. },
  9623. });
  9624. //数字组件
  9625. formlyConfigProvider.setType({
  9626. name: "ui-number",
  9627. extends: "input",
  9628. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9629. defaultOptions: function (options) {
  9630. return {
  9631. templateOptions: {},
  9632. };
  9633. },
  9634. controller: ["$scope", function ($scope) { }],
  9635. });
  9636. //含有周的日期
  9637. formlyConfigProvider.setType({
  9638. name: "ui-datepickerweek",
  9639. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9640. extends: "input",
  9641. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9642. defaultOptions: {
  9643. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9644. templateOptions: {
  9645. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9646. },
  9647. },
  9648. controller: [
  9649. "$scope",
  9650. "$filter",
  9651. function ($scope, $filter) {
  9652. $scope.mindata = new Date(
  9653. $scope.options.templateOptions.transform($scope.model).getTime() +
  9654. 5 * 60 * 1000
  9655. );
  9656. if ($scope.model[$scope.options.key]) {
  9657. } else {
  9658. $scope.model[$scope.options.key] = $filter("date")(
  9659. new Date(new Date().getTime()),
  9660. $scope.options.templateOptions.datepickerPopup
  9661. );
  9662. }
  9663. $scope.options.initialValue = $scope.model[$scope.options.key];
  9664. $scope.endOpen = true;
  9665. $scope.datepicker = {};
  9666. $scope.datepicker.opened = false;
  9667. $scope.datepicker.open = function ($event) {
  9668. $scope.datepicker.opened = true;
  9669. };
  9670. },
  9671. ],
  9672. });
  9673. //lmm
  9674. //分配任务列表
  9675. formlyConfigProvider.setType({
  9676. name: "jry_taskDistributionList",
  9677. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9678. wrapper: ["bootstrapHasError"],
  9679. defaultOptions: function (options, $scope) {
  9680. return {
  9681. templateOptions: {},
  9682. };
  9683. },
  9684. controller: function (
  9685. $rootScope,
  9686. $scope,
  9687. api_user_data,
  9688. $modal,
  9689. api_doc_data,
  9690. i18nService,
  9691. SweetAlert,
  9692. api_wechatfile
  9693. ) {
  9694. // 获取状态
  9695. $scope.stateListData = {};
  9696. $scope.getStateData = function () {
  9697. //lyl
  9698. var data = {
  9699. key: "task_sub_state",
  9700. type: "list",
  9701. };
  9702. api_wechatfile.getDictionary(data).then(function (res) {
  9703. angular.forEach(res, function (v, i) {
  9704. $scope.stateListData[v.value] = v.id;
  9705. });
  9706. });
  9707. };
  9708. $scope.getStateData();
  9709. var loginUser = $rootScope.user;
  9710. $scope.langs = i18nService.getAllLangs();
  9711. $scope.lang = "zh-cn";
  9712. i18nService.setCurrentLang($scope.lang);
  9713. $scope.gridOptions = {};
  9714. $scope.gridOptions.data = "myData";
  9715. $scope.gridOptions.enableColumnResizing = true;
  9716. $scope.gridOptions.enableGridMenu = false;
  9717. $scope.gridOptions.enableRowSelection = true;
  9718. $scope.gridOptions.showGridFooter = true;
  9719. $scope.gridOptions.showColumnFooter = false;
  9720. $scope.gridOptions.fastWatch = true;
  9721. $scope.gridOptions.useExternalFiltering = true;
  9722. $scope.gridOptions.useExternalPagination = true;
  9723. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  9724. $scope.gridOptions.paginationPageSize = 10;
  9725. $scope.gridOptions.multiSelect = true;
  9726. $scope.gridOptions.rowIdentity = function (row) {
  9727. return row.id;
  9728. };
  9729. $scope.gridOptions.getRowIdentity = function (row) {
  9730. return row.id;
  9731. };
  9732. // console.log($scope.model);//lmmmm
  9733. $scope.gridOptions.columnDefs = [
  9734. {
  9735. name: "item",
  9736. displayName: "序号",
  9737. width: "10%",
  9738. cellTemplate:
  9739. "<div>" +
  9740. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9741. "</div>",
  9742. },
  9743. {
  9744. name: "taskDescribe",
  9745. displayName: "任务说明",
  9746. width: "25%",
  9747. enableFiltering: false,
  9748. cellTemplate:
  9749. "<div>" +
  9750. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9751. "</div>",
  9752. },
  9753. {
  9754. name: "assign.name",
  9755. displayName: "指派人",
  9756. width: "5%",
  9757. enableFiltering: false,
  9758. cellTemplate:
  9759. "<div>" +
  9760. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9761. "</div>",
  9762. },
  9763. {
  9764. name: "startTime",
  9765. displayName: "开始时间",
  9766. width: "13%",
  9767. enableFiltering: false,
  9768. cellTemplate:
  9769. "<div>" +
  9770. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9771. "</div>",
  9772. },
  9773. {
  9774. name: "endTime",
  9775. displayName: "结束时间",
  9776. width: "13%",
  9777. enableFiltering: false,
  9778. cellTemplate:
  9779. "<div>" +
  9780. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9781. "</div>",
  9782. },
  9783. {
  9784. name: "priority.name",
  9785. displayName: "优先级",
  9786. width: "5%",
  9787. enableFiltering: false,
  9788. cellTemplate:
  9789. "<div>" +
  9790. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9791. "</div>",
  9792. },
  9793. {
  9794. name: "state.name",
  9795. displayName: "状态",
  9796. width: "5%",
  9797. enableFiltering: false,
  9798. cellTemplate:
  9799. "<div>" +
  9800. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9801. "</div>",
  9802. },
  9803. {
  9804. name: "操作", //lmmm
  9805. cellTemplate:
  9806. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9807. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9808. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9809. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9810. '<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>' +
  9811. "</div></div>",
  9812. enableFiltering: false,
  9813. },
  9814. ];
  9815. // 查看
  9816. $scope.see = function (data) {
  9817. $scope.seeData = data;
  9818. var modalInstance = $modal.open({
  9819. backdrop: false,
  9820. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9821. controller: function (
  9822. $scope,
  9823. scope,
  9824. $modalInstance,
  9825. api_doc_data,
  9826. SweetAlert,
  9827. api_user_data,
  9828. api_wechatfile
  9829. ) {
  9830. $scope.personData = {}; //指派人
  9831. $scope.priorityData = {}; //优先级
  9832. $scope.personListData = {}; //指派人下拉数据
  9833. $scope.priorityListData = {}; //优先级下拉数据
  9834. $scope.startTime = ""; //开始时间
  9835. $scope.releaseShow = "no";
  9836. $scope.subShow = "no";
  9837. $scope.onlySee = "ok";
  9838. $scope.endTime = ""; //结束时间
  9839. $scope.taskDescribe = ""; //任务描述
  9840. $scope.taskDescribe = scope.seeData.taskDescribe;
  9841. $scope.personData.data = scope.seeData.assign;
  9842. $scope.priorityData.data = scope.seeData.priority;
  9843. $scope.startTime = scope.seeData.startTime;
  9844. $scope.endTime = scope.seeData.endTime;
  9845. $scope.done = scope.seeData.done;
  9846. $scope.feedback = scope.seeData.feedback;
  9847. $scope.cancel = function () {
  9848. $modalInstance.dismiss("cancel");
  9849. };
  9850. },
  9851. size: "sm",
  9852. resolve: {
  9853. scope: function () {
  9854. return $scope;
  9855. },
  9856. },
  9857. backdrop: true,
  9858. });
  9859. };
  9860. // 编辑
  9861. $scope.edit = function (data) {
  9862. $scope.editData = data;
  9863. var modalInstance = $modal.open({
  9864. backdrop: false,
  9865. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9866. controller: function (
  9867. $scope,
  9868. scope,
  9869. $modalInstance,
  9870. api_doc_data,
  9871. SweetAlert,
  9872. api_user_data,
  9873. api_wechatfile
  9874. ) {
  9875. console.log(scope.editData);
  9876. $scope.personData = {}; //指派人
  9877. $scope.priorityData = {}; //优先级
  9878. $scope.personListData = {}; //指派人下拉数据
  9879. $scope.priorityListData = {}; //优先级下拉数据
  9880. $scope.startTime = ""; //开始时间
  9881. $scope.releaseShow = "no";
  9882. $scope.endTime = ""; //结束时间
  9883. $scope.taskDescribe = ""; //任务描述
  9884. $scope.taskDescribe = scope.editData.taskDescribe;
  9885. $scope.personData.data = scope.editData.assign;
  9886. $scope.priorityData.data = scope.editData.priority;
  9887. $scope.startTime = scope.editData.startTime;
  9888. $scope.endTime = scope.editData.endTime;
  9889. // 指派人下拉框数据
  9890. $scope.getPersonData = function () {
  9891. var data = {
  9892. idx: 0,
  9893. sum: 1000,
  9894. };
  9895. api_user_data.fetchDataList("user", data).then(function (res) {
  9896. $scope.personListData = res.list;
  9897. });
  9898. };
  9899. $scope.getPersonData();
  9900. //优先级下拉数据
  9901. $scope.getPriorityData = function () {
  9902. var data = {
  9903. key: "change_rick_level",
  9904. type: "list",
  9905. };
  9906. api_wechatfile.getDictionary(data).then(function (res) {
  9907. $scope.priorityListData = res;
  9908. });
  9909. };
  9910. $scope.getPriorityData();
  9911. // 获取状态-lmm
  9912. $scope.stateListData = {};
  9913. $scope.getStateData = function () {
  9914. //lyl
  9915. var data = {
  9916. key: "task_sub_state",
  9917. type: "list",
  9918. };
  9919. api_wechatfile.getDictionary(data).then(function (res) {
  9920. angular.forEach(res, function (v, i) {
  9921. $scope.stateListData[v.value] = v.id;
  9922. });
  9923. });
  9924. };
  9925. $scope.getStateData();
  9926. //时间控件
  9927. $scope.open = function ($event) {
  9928. $event.preventDefault();
  9929. $event.stopPropagation();
  9930. $scope.opened = !$scope.opened;
  9931. };
  9932. $scope.endOpen = function ($event) {
  9933. $event.preventDefault();
  9934. $event.stopPropagation();
  9935. $scope.startOpened = false;
  9936. $scope.endOpened = !$scope.endOpened;
  9937. };
  9938. $scope.startOpen = function ($event) {
  9939. $event.preventDefault();
  9940. $event.stopPropagation();
  9941. $scope.endOpened = false;
  9942. $scope.startOpened = !$scope.startOpened;
  9943. };
  9944. // 确定
  9945. $scope.ok = function (item) {
  9946. if (
  9947. $scope.taskDescribe &&
  9948. $scope.personData.data &&
  9949. $scope.priorityData.data &&
  9950. $scope.startTime &&
  9951. $scope.endTime
  9952. ) {
  9953. $scope.startTime = moment(
  9954. new Date($scope.startTime).getTime()
  9955. ).format("YYYY-MM-DD HH:mm:ss");
  9956. $scope.endTime = moment(
  9957. new Date($scope.endTime).getTime()
  9958. ).format("YYYY-MM-DD HH:mm:ss");
  9959. $scope.addData = {
  9960. taskSub: {
  9961. taskDescribe: $scope.taskDescribe,
  9962. assign: $scope.personData.data,
  9963. priority: $scope.priorityData.data,
  9964. startTime: $scope.startTime,
  9965. endTime: $scope.endTime,
  9966. taskMonth: {
  9967. id: scope.model.taskMonth.id,
  9968. },
  9969. id: scope.editData.id,
  9970. },
  9971. };
  9972. $scope.addData.taskSub["state"] = {
  9973. id: $scope.stateListData[1],
  9974. };
  9975. api_user_data
  9976. .updData("taskSub", $scope.addData)
  9977. .then(function (res) {
  9978. if (res.status == 200) {
  9979. SweetAlert.swal({
  9980. title: "修改成功!",
  9981. type: "success",
  9982. confirmButtonColor: "#007AFF",
  9983. });
  9984. scope.refreshData(scope.jry_filterdata);
  9985. $modalInstance.dismiss("cancel");
  9986. } else {
  9987. SweetAlert.swal({
  9988. title: "修改失败",
  9989. text: "系统错误,请重试!",
  9990. type: "error",
  9991. });
  9992. $modalInstance.dismiss("cancel");
  9993. }
  9994. });
  9995. } else {
  9996. SweetAlert.swal({
  9997. title: "修改失败",
  9998. text: "必填项不能为空!",
  9999. type: "error",
  10000. });
  10001. }
  10002. };
  10003. $scope.cancel = function () {
  10004. $modalInstance.dismiss("cancel");
  10005. };
  10006. },
  10007. size: "sm",
  10008. resolve: {
  10009. scope: function () {
  10010. return $scope;
  10011. },
  10012. },
  10013. backdrop: true,
  10014. });
  10015. };
  10016. // 发布
  10017. $scope.release = function (data) {
  10018. SweetAlert.swal(
  10019. {
  10020. title: "确认发布?",
  10021. text: "请确定发布操作!",
  10022. type: "warning",
  10023. showCancelButton: true,
  10024. confirmButtonColor: "#DD6B55",
  10025. confirmButtonText: "确定",
  10026. cancelButtonText: "取消",
  10027. closeOnConfirm: false,
  10028. closeOnCancel: false,
  10029. },
  10030. function (isConfirm) {
  10031. if (isConfirm) {
  10032. data.state.id = $scope.stateListData[2];
  10033. delete data.item;
  10034. api_user_data
  10035. .updData("taskSub", {
  10036. taskSub: data,
  10037. })
  10038. .then(function (res) {
  10039. if (res.status == 200) {
  10040. SweetAlert.swal({
  10041. title: "发布成功!",
  10042. type: "success",
  10043. confirmButtonColor: "#007AFF",
  10044. });
  10045. $scope.refreshData($scope.jry_filterdata);
  10046. } else {
  10047. SweetAlert.swal({
  10048. title: "删除失败",
  10049. text: "系统错误,请重试!",
  10050. type: "error",
  10051. });
  10052. }
  10053. });
  10054. } else {
  10055. SweetAlert.swal("操作取消", "发布取消", "error");
  10056. }
  10057. }
  10058. );
  10059. };
  10060. // 删除
  10061. $scope.remove = function (data) {
  10062. SweetAlert.swal(
  10063. {
  10064. title: "确认删除?",
  10065. text: "删除的数据不可恢复,请确认继续操作!",
  10066. type: "warning",
  10067. showCancelButton: true,
  10068. confirmButtonColor: "#DD6B55",
  10069. confirmButtonText: "继续删除",
  10070. cancelButtonText: "取消操作",
  10071. closeOnConfirm: false,
  10072. closeOnCancel: false,
  10073. },
  10074. function (isConfirm) {
  10075. if (isConfirm) {
  10076. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10077. if (res.status == 200) {
  10078. SweetAlert.swal({
  10079. title: "删除成功!",
  10080. type: "success",
  10081. confirmButtonColor: "#007AFF",
  10082. });
  10083. $scope.refreshData($scope.jry_filterdata);
  10084. } else {
  10085. SweetAlert.swal({
  10086. title: "删除失败",
  10087. text: "系统错误,请重试!",
  10088. type: "error",
  10089. });
  10090. }
  10091. });
  10092. } else {
  10093. SweetAlert.swal("操作取消", "数据安全", "error");
  10094. }
  10095. }
  10096. );
  10097. };
  10098. $scope.refreshData = function (filterData) {
  10099. // $scope.ldloading[style.replace('-', '_')] = true;
  10100. if (angular.isUndefined(filterData)) {
  10101. filterData = defaultFilterData;
  10102. }
  10103. $scope.myData = [];
  10104. $scope.memoryfilterData = filterData;
  10105. api_doc_data.fetchDataList("taskSub", filterData).then(
  10106. function (data) {
  10107. var myData = data;
  10108. $scope.gridOptions.totalItems = myData.totalNum;
  10109. $scope.removeFileNum = myData.totalNum;
  10110. if (angular.isArray(myData.list)) {
  10111. $scope.myData = myData.list;
  10112. for (var i = 0; i < $scope.myData.length; i++) {
  10113. //添加序号
  10114. $scope.myData[i]["item"] =
  10115. i + 1 + filterData.idx * filterData.sum;
  10116. $scope.myData[i].startTime = moment(
  10117. $scope.myData[i].startTime
  10118. ).format("YYYY-MM-DD HH:mm:ss");
  10119. $scope.myData[i].endTime = moment(
  10120. $scope.myData[i].endTime
  10121. ).format("YYYY-MM-DD HH:mm:ss");
  10122. }
  10123. }
  10124. },
  10125. function () {
  10126. // $scope.ldloading[style.replace('-', '_')] = false;
  10127. }
  10128. );
  10129. };
  10130. //分页控制
  10131. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10132. gridApi.pagination.on.paginationChanged(
  10133. $scope,
  10134. function (newPage, pageSize) {
  10135. $scope.jry_filterdata.idx = newPage - 1;
  10136. $scope.fenye = newPage - 1;
  10137. $scope.jry_filterdata.sum = pageSize;
  10138. $scope.refreshData($scope.jry_filterdata);
  10139. }
  10140. );
  10141. };
  10142. $scope.fenye = 0;
  10143. if ($scope.model.label == "分配任务") {
  10144. $scope.jry_filterdata = {
  10145. idx: $scope.fenye,
  10146. sum: 10,
  10147. taskSub: {
  10148. taskMonth: {
  10149. id: $scope.model.taskMonth.id,
  10150. },
  10151. userid: loginUser.id,
  10152. role: loginUser.role,
  10153. },
  10154. };
  10155. } else {
  10156. $scope.jry_filterdata = {
  10157. idx: $scope.fenye,
  10158. sum: 10,
  10159. taskSub: {
  10160. taskMonth: {
  10161. id: $scope.model.taskMonth.id,
  10162. },
  10163. userid: loginUser.id,
  10164. role: loginUser.role,
  10165. type: 1,
  10166. },
  10167. };
  10168. }
  10169. $scope.refreshData($scope.jry_filterdata);
  10170. //新增模态框
  10171. $scope.newDistribution = function () {
  10172. var modalInstance = $modal.open({
  10173. backdrop: false,
  10174. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10175. controller: function (
  10176. $scope,
  10177. scope,
  10178. $modalInstance,
  10179. api_doc_data,
  10180. SweetAlert,
  10181. api_user_data,
  10182. api_wechatfile
  10183. ) {
  10184. $scope.personData = {}; //指派人
  10185. $scope.priorityData = {}; //优先级
  10186. $scope.personListData = {}; //指派人下拉数据
  10187. $scope.priorityListData = {}; //优先级下拉数据
  10188. $scope.startTime = ""; //开始时间
  10189. $scope.endTime = ""; //结束时间
  10190. $scope.taskDescribe = ""; //任务描述
  10191. $scope.motaikuang = "";
  10192. $scope.shijian = "哈哈";
  10193. // 指派人下拉框数据
  10194. $scope.getPersonData = function () {
  10195. var data = {
  10196. idx: 0,
  10197. sum: 1000,
  10198. };
  10199. api_user_data.fetchDataList("user", data).then(function (res) {
  10200. $scope.personListData = res.list;
  10201. });
  10202. };
  10203. $scope.getPersonData();
  10204. //优先级下拉数据
  10205. $scope.getPriorityData = function () {
  10206. var data = {
  10207. key: "change_rick_level",
  10208. type: "list",
  10209. };
  10210. api_wechatfile.getDictionary(data).then(function (res) {
  10211. $scope.priorityListData = res;
  10212. });
  10213. };
  10214. // 控制结束时间的最大时间
  10215. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10216. // 控制结束时间的最小时间
  10217. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10218. $scope.$watch("startTime", function (n, o) {
  10219. if (n) {
  10220. if (n > scope.model.taskMonth.startTime) {
  10221. $scope.jryEndMinTime = n;
  10222. }
  10223. }
  10224. });
  10225. // 控制开始时间的最小时间
  10226. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10227. // 控制开始时间的最大时间
  10228. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10229. $scope.$watch("endTime", function (n, o) {
  10230. if (n) {
  10231. if (n < scope.model.taskMonth.endTime) {
  10232. $scope.jryStartMaxTime = n;
  10233. }
  10234. }
  10235. });
  10236. $scope.getPriorityData();
  10237. //时间控件
  10238. $scope.open = function ($event) {
  10239. $event.preventDefault();
  10240. $event.stopPropagation();
  10241. $scope.opened = !$scope.opened;
  10242. };
  10243. $scope.endOpen = function ($event) {
  10244. $event.preventDefault();
  10245. $event.stopPropagation();
  10246. $scope.startOpened = false;
  10247. $scope.endOpened = !$scope.endOpened;
  10248. };
  10249. $scope.startOpen = function ($event) {
  10250. $event.preventDefault();
  10251. $event.stopPropagation();
  10252. $scope.endOpened = false;
  10253. $scope.startOpened = !$scope.startOpened;
  10254. };
  10255. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10256. // 获取状态-lmm
  10257. $scope.stateListData = {};
  10258. $scope.getStateData = function () {
  10259. //lyl
  10260. var data = {
  10261. key: "task_sub_state",
  10262. type: "list",
  10263. };
  10264. api_wechatfile.getDictionary(data).then(function (res) {
  10265. angular.forEach(res, function (v, i) {
  10266. $scope.stateListData[v.value] = v.id;
  10267. });
  10268. });
  10269. };
  10270. $scope.getStateData();
  10271. // 草稿保存
  10272. $scope.ok = function (item) {
  10273. if (
  10274. $scope.taskDescribe &&
  10275. $scope.personData.data &&
  10276. $scope.priorityData.data &&
  10277. $scope.startTime &&
  10278. $scope.endTime
  10279. ) {
  10280. $scope.startTime = moment(
  10281. new Date($scope.startTime).getTime()
  10282. ).format("YYYY-MM-DD HH:mm:ss");
  10283. $scope.endTime = moment(
  10284. new Date($scope.endTime).getTime()
  10285. ).format("YYYY-MM-DD HH:mm:ss");
  10286. $scope.addData = {
  10287. taskSub: {
  10288. taskDescribe: $scope.taskDescribe,
  10289. assign: $scope.personData.data,
  10290. priority: $scope.priorityData.data,
  10291. startTime: $scope.startTime,
  10292. endTime: $scope.endTime,
  10293. taskMonth: {
  10294. id: scope.model.taskMonth.id,
  10295. },
  10296. },
  10297. };
  10298. $scope.addData.taskSub["state"] = {
  10299. id: $scope.stateListData[1],
  10300. };
  10301. api_user_data
  10302. .addData("taskSub", $scope.addData)
  10303. .then(function (res) {
  10304. if (res.status == 200) {
  10305. SweetAlert.swal({
  10306. title: "保存成功!",
  10307. type: "success",
  10308. confirmButtonColor: "#007AFF",
  10309. });
  10310. scope.refreshData(scope.jry_filterdata);
  10311. $modalInstance.dismiss("cancel");
  10312. } else {
  10313. SweetAlert.swal({
  10314. title: "保存失败",
  10315. text: "系统错误,请重试!",
  10316. type: "error",
  10317. });
  10318. $modalInstance.dismiss("cancel");
  10319. }
  10320. });
  10321. } else {
  10322. SweetAlert.swal({
  10323. title: "保存失败",
  10324. text: "必填项不能为空!",
  10325. type: "error",
  10326. });
  10327. }
  10328. };
  10329. // 发布
  10330. $scope.release = function () {
  10331. if (
  10332. $scope.taskDescribe &&
  10333. $scope.personData.data &&
  10334. $scope.priorityData.data &&
  10335. $scope.startTime &&
  10336. $scope.endTime
  10337. ) {
  10338. $scope.startTime = moment(
  10339. new Date($scope.startTime).getTime()
  10340. ).format("YYYY-MM-DD HH:mm:ss");
  10341. $scope.endTime = moment(
  10342. new Date($scope.endTime).getTime()
  10343. ).format("YYYY-MM-DD HH:mm:ss");
  10344. $scope.addData = {
  10345. taskSub: {
  10346. taskDescribe: $scope.taskDescribe,
  10347. assign: $scope.personData.data,
  10348. priority: $scope.priorityData.data,
  10349. startTime: $scope.startTime,
  10350. endTime: $scope.endTime,
  10351. taskMonth: {
  10352. id: scope.model.taskMonth.id,
  10353. },
  10354. },
  10355. };
  10356. $scope.addData.taskSub["state"] = {
  10357. id: $scope.stateListData[1],
  10358. };
  10359. api_user_data
  10360. .addData("taskSub", $scope.addData)
  10361. .then(function (res) {
  10362. if (res.status == 200) {
  10363. SweetAlert.swal({
  10364. title: "保存成功!",
  10365. type: "success",
  10366. confirmButtonColor: "#007AFF",
  10367. });
  10368. scope.refreshData(scope.jry_filterdata);
  10369. $modalInstance.dismiss("cancel");
  10370. } else {
  10371. SweetAlert.swal({
  10372. title: "保存失败",
  10373. text: "系统错误,请重试!",
  10374. type: "error",
  10375. });
  10376. $modalInstance.dismiss("cancel");
  10377. }
  10378. });
  10379. } else {
  10380. SweetAlert.swal({
  10381. title: "保存失败",
  10382. text: "必填项不能为空!",
  10383. type: "error",
  10384. });
  10385. }
  10386. };
  10387. $scope.cancel = function () {
  10388. $modalInstance.dismiss("cancel");
  10389. };
  10390. },
  10391. size: "sm",
  10392. resolve: {
  10393. scope: function () {
  10394. return $scope;
  10395. },
  10396. },
  10397. backdrop: true,
  10398. });
  10399. };
  10400. },
  10401. });
  10402. // 多次反馈文本域组件--jry
  10403. formlyConfigProvider.setType({
  10404. name: "ui-feedbacktTextarea",
  10405. extends: "textarea",
  10406. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10407. defaultOptions: function (options) {
  10408. return {
  10409. templateOptions: {
  10410. transform: function (model, value) {
  10411. return value;
  10412. },
  10413. },
  10414. validation: {
  10415. messages: {
  10416. maxlength: function (viewValue, modelValue, scope) {
  10417. if (viewValue != null) {
  10418. if (viewValue.length > scope.to.maxlength) {
  10419. return (
  10420. scope.to.label +
  10421. " 字数(" +
  10422. viewValue.length +
  10423. ")超限(" +
  10424. scope.to.maxlength +
  10425. ")"
  10426. );
  10427. } else {
  10428. return "";
  10429. }
  10430. }
  10431. },
  10432. },
  10433. },
  10434. };
  10435. },
  10436. controller: [
  10437. "$scope",
  10438. "moment",
  10439. function ($scope, moment) {
  10440. // console.log($scope);
  10441. var timeKey = $scope.options.templateOptions.time;
  10442. $scope.time = moment($scope.model[timeKey]).format(
  10443. "YYYY-MM-DD HH:mm:ss"
  10444. );
  10445. var value = $scope.model[$scope.options.key];
  10446. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10447. $scope.model[$scope.options.key] =
  10448. $scope.options.templateOptions.transform(
  10449. $scope.originalModel,
  10450. value
  10451. );
  10452. }
  10453. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10454. $scope.options.templateOptions.felditem($scope);
  10455. }
  10456. },
  10457. ],
  10458. });
  10459. //任务管理开始时间--jry
  10460. formlyConfigProvider.setType({
  10461. name: "ui-jryStartdatepicker",
  10462. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10463. extends: "input",
  10464. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10465. defaultOptions: {
  10466. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10467. templateOptions: {
  10468. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10469. },
  10470. },
  10471. controller: [
  10472. "$scope",
  10473. "$filter",
  10474. function ($scope, $filter) {
  10475. // console.log($scope.model[$scope.options.key],'lmm');
  10476. $scope.mindata = new Date(
  10477. $scope.options.templateOptions.transform($scope.model).getTime() +
  10478. 5 * 60 * 1000
  10479. );
  10480. if ($scope.model[$scope.options.key]) {
  10481. $scope.model[$scope.options.key] = $filter("date")(
  10482. $scope.model[$scope.options.key],
  10483. $scope.options.templateOptions.datepickerPopup
  10484. );
  10485. }
  10486. // console.log($scope.model[$scope.options.key],'lmm');
  10487. // console.log($scope.model,'lmm',$scope.options.key);
  10488. $scope.options.initialValue = $scope.model[$scope.options.key];
  10489. $scope.endOpen = true;
  10490. $scope.datepicker = {};
  10491. $scope.datepicker.opened = false;
  10492. $scope.datepicker.open = function ($event) {
  10493. $scope.datepicker.opened = true;
  10494. };
  10495. },
  10496. ],
  10497. });
  10498. //任务管理结束时间--jry
  10499. formlyConfigProvider.setType({
  10500. name: "ui-jryEnddatepicker",
  10501. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10502. extends: "input",
  10503. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10504. defaultOptions: {
  10505. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10506. templateOptions: {
  10507. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10508. },
  10509. },
  10510. controller: [
  10511. "$scope",
  10512. "$filter",
  10513. function ($scope, $filter) {
  10514. $scope.mindata = new Date(
  10515. $scope.options.templateOptions.transform($scope.model).getTime() +
  10516. 5 * 60 * 1000
  10517. );
  10518. if ($scope.model[$scope.options.key]) {
  10519. $scope.model[$scope.options.key] = $filter("date")(
  10520. $scope.model[$scope.options.key],
  10521. $scope.options.templateOptions.datepickerPopup
  10522. );
  10523. }
  10524. $scope.options.initialValue = $scope.model[$scope.options.key];
  10525. $scope.endOpen = true;
  10526. $scope.datepicker = {};
  10527. $scope.datepicker.opened = false;
  10528. $scope.datepicker.open = function ($event) {
  10529. $scope.datepicker.opened = true;
  10530. };
  10531. },
  10532. ],
  10533. });
  10534. //下拉多选框灵活组件--jry
  10535. formlyConfigProvider.setType({
  10536. name: "ui-jry_multiselectplus",
  10537. extends: "multiCheckbox",
  10538. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10539. defaultOptions: function (options) {
  10540. return {
  10541. templateOptions: {
  10542. refreshData: function (search, options, model, that) {
  10543. // var process = options.templateOptions.ApiService.all("");
  10544. if (search) {
  10545. } else {
  10546. }
  10547. var postData = options.templateOptions.optionsPostData;
  10548. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10549. postData = options.templateOptions.optionsPostData(
  10550. options,
  10551. model,
  10552. that
  10553. );
  10554. }
  10555. options.templateOptions.ApiService.fetchDataList(
  10556. options.templateOptions.optionsUrl,
  10557. options.templateOptions.optionsPostData
  10558. ).then(function (result) {
  10559. // if (!options.templateOptions.options) {
  10560. // options.templateOptions.options = [];
  10561. // }
  10562. if (options.templateOptions.optionsDataKey) {
  10563. options.templateOptions.options =
  10564. result[options.templateOptions.optionsDataKey];
  10565. } else {
  10566. options.templateOptions.options = result;
  10567. }
  10568. if (options.templateOptions.optionsChecked) {
  10569. // return options.value = null;
  10570. options.value(options.model[options.key]);
  10571. }
  10572. });
  10573. },
  10574. refreshDelay: 0,
  10575. // },
  10576. validators: {
  10577. required: {
  10578. expression: function (viewValue, modelValue) {
  10579. var value = modelValue || viewValue;
  10580. return value != null;
  10581. // return value.length>=1;
  10582. // if (modelValue && viewValue) {
  10583. // return value != null;
  10584. // } else {
  10585. // var value = modelValue || viewValue;
  10586. // return value.length > 0;
  10587. // }
  10588. },
  10589. },
  10590. },
  10591. },
  10592. };
  10593. },
  10594. controller: [
  10595. "$scope",
  10596. function ($scope) {
  10597. console.log($scope.to);
  10598. if (angular.isArray($scope.model[$scope.options.key])) {
  10599. } else {
  10600. $scope.model[$scope.options.key] = [];
  10601. }
  10602. },
  10603. ],
  10604. });
  10605. //下拉框组件
  10606. formlyConfigProvider.setType({
  10607. name: "ui-select",
  10608. extends: "select",
  10609. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10610. defaultOptions: function (options, scope) {
  10611. return {
  10612. templateOptions: {
  10613. // refresh: function() {},
  10614. getScope: function () {
  10615. return scope;
  10616. },
  10617. refreshDelay: 0,
  10618. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10619. //POST
  10620. console.log(model, "model");
  10621. angular.extend(data, {
  10622. idx: 0,
  10623. sum: 1000,
  10624. });
  10625. options.templateOptions.APIService.fetchDataList(
  10626. modelName,
  10627. data
  10628. ).then(function (response) {
  10629. var myData =
  10630. options.templateOptions.Restangular.stripRestangular(response);
  10631. var list = myData.list;
  10632. console.log(myData);
  10633. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10634. // console.log('balabalabala');
  10635. // console.log(res);
  10636. // })
  10637. if (list.length == 1) {
  10638. if (options.templateOptions.APIport) {
  10639. options.templateOptions.APIport.expectedTime(
  10640. "L" + list[0][key].id
  10641. ).then(function (response) {
  10642. if (response.state == "200") {
  10643. // if (model.$parent.model && model.$parent.model.incident) {
  10644. // } else {
  10645. // model.$parent.model = { 'incident': {} };
  10646. // }
  10647. var myDatas = response.serviceLevelAgreement;
  10648. //逾期
  10649. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10650. response.date;
  10651. //解决
  10652. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10653. myDatas.resolveTime;
  10654. //响应
  10655. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10656. myDatas.responseTime;
  10657. } else {
  10658. }
  10659. });
  10660. }
  10661. angular.forEach(model.fields, function (item) {
  10662. angular.forEach(model.fields, function (item) {
  10663. if (item.templateOptions.pkey == modelKey + "." + key) {
  10664. item.model.id = "";
  10665. if (key == "place") {
  10666. item.templateOptions.options = list;
  10667. } else if (key == "placeDTO") {
  10668. item.templateOptions.options = list;
  10669. } else if (key == "requester") {
  10670. } else {
  10671. item.value(list[0][key][item.key]);
  10672. }
  10673. }
  10674. });
  10675. });
  10676. } else {
  10677. if (model.fields) {
  10678. angular.forEach(model.fields, function (item) {
  10679. angular.forEach(model.fields, function (item) {
  10680. if (item.templateOptions.pkey == modelKey + "." + key) {
  10681. item.model.id = "";
  10682. if (key == "place") {
  10683. item.templateOptions.isnosearch = true;
  10684. item.templateOptions.options = list;
  10685. }
  10686. if (key == "placeDTO") {
  10687. item.templateOptions.options = list;
  10688. }
  10689. if (key == "requester") {
  10690. }
  10691. }
  10692. });
  10693. });
  10694. } else {
  10695. angular.forEach(
  10696. scope.$parent.$parent.$parent.fields,
  10697. function (item) {
  10698. angular.forEach(
  10699. scope.$parent.$parent.$parent.fields,
  10700. function (item) {
  10701. if (
  10702. item.templateOptions.pkey ==
  10703. modelKey + "." + key
  10704. ) {
  10705. if (key == "place") {
  10706. item.templateOptions.isnosearch = true;
  10707. item.templateOptions.options = list;
  10708. scope.$parent.$parent.$parent.model.incident.place =
  10709. model.incident.place;
  10710. }
  10711. if (key == "placeDTO") {
  10712. item.templateOptions.options = list;
  10713. }
  10714. if (key == "requester") {
  10715. }
  10716. }
  10717. }
  10718. );
  10719. }
  10720. );
  10721. }
  10722. }
  10723. console.log(key);
  10724. //报修科室
  10725. if (key == "dept") {
  10726. // 报修科室单选
  10727. scope.$parent.$parent.$parent.model.incident.department =
  10728. response.list[0];
  10729. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10730. response.list[0].phone;
  10731. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10732. // 选择重复事件侧滑框
  10733. scope.$parent.$parent.$parent.model[
  10734. "repeatIncidentShow"
  10735. ] = false;
  10736. setTimeout(() => {
  10737. scope.$parent.$parent.$parent.model[
  10738. "repeatIncidentShow"
  10739. ] = true;
  10740. }, 500);
  10741. }
  10742. // 报修人
  10743. if (key == "requester") {
  10744. // 报修人单选
  10745. scope.$parent.$parent.$parent.model.incident.requester =
  10746. response.list[0];
  10747. console.log(scope.$parent.$parent.$parent.model);
  10748. scope.$parent.$parent.$parent.model.incident.account =
  10749. response.list[0].account;
  10750. var selectedItem = response.list[0];
  10751. var data = {
  10752. requester: selectedItem,
  10753. };
  10754. scope.$parent.$parent.$parent.model["requestershow"] =
  10755. selectedItem;
  10756. console.log(selectedItem, "----------------------");
  10757. // if (selectedItem.dept.place.place) {
  10758. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10759. // }
  10760. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10761. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10762. scope.$parent.$parent.$parent.model.incident.area.id =
  10763. selectedItem.place ? selectedItem.place.area.id : null;
  10764. scope.$parent.$parent.$parent.model.incident.place.id =
  10765. selectedItem.place ? selectedItem.place.id : null;
  10766. console.log(scope, 89898998);
  10767. // console.log(scope.formData,'接单页面');
  10768. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10769. scope.model.selecthouseNumber = selectedItem.place
  10770. ? selectedItem.place
  10771. : {};
  10772. scope.$root.selecthouseNumber = selectedItem.place
  10773. ? selectedItem.place
  10774. : {};
  10775. // options.templateOptions.ApiService.addData(
  10776. // "requester",
  10777. // data
  10778. // ).then(function (response) {
  10779. // if (response.status == 200) {
  10780. if (scope.$parent.$parent.$parent) {
  10781. if (scope.$parent.$parent.$parent.place) {
  10782. scope.$parent.$parent.$parent.place.id = "";
  10783. }
  10784. if (scope.$parent.$parent.$parent.area) {
  10785. scope.$parent.$parent.$parent.area.id = "";
  10786. }
  10787. scope.$parent.$parent.$parent.model.incident.contacts =
  10788. selectedItem.name;
  10789. if (
  10790. selectedItem.mphone &&
  10791. selectedItem.mphone != null &&
  10792. selectedItem.mphone != ""
  10793. ) {
  10794. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10795. selectedItem.mphone;
  10796. } else {
  10797. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10798. selectedItem.telephone;
  10799. }
  10800. if (
  10801. selectedItem.requesterTypeDTO &&
  10802. selectedItem.requesterTypeDTO.id == 2
  10803. ) {
  10804. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10805. }
  10806. }
  10807. // if (!response.data.id) {
  10808. // response.data.id = selectedItem.id;
  10809. // }
  10810. console.log(scope);
  10811. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10812. // if (selectedItem.place && selectedItem.place.id) {
  10813. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10814. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10815. // };
  10816. // } else {
  10817. // if (selectedItem.place && selectedItem.place.id) {
  10818. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10819. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10820. // };
  10821. // }
  10822. // if(scope.$parent.$parent.$parent.model.incident.area){
  10823. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10824. // }
  10825. if (selectedItem.id) {
  10826. scope.$parent.$parent.$parent.model.incident.account =
  10827. selectedItem.account;
  10828. }
  10829. // 选择重复事件侧滑框
  10830. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10831. scope.$parent.$parent.$parent.model[
  10832. "repeatIncidentShow"
  10833. ] = false;
  10834. setTimeout(() => {
  10835. scope.$parent.$parent.$parent.model[
  10836. "repeatIncidentShow"
  10837. ] = true;
  10838. }, 500);
  10839. // }
  10840. // }
  10841. // });
  10842. }
  10843. //新建事件,选择派单,选择工作组查找处理人baba
  10844. if (key == "handlerUser") {
  10845. model.fields.forEach(function (v) {
  10846. if (v.templateOptions.pkey == "incident.handlerUser") {
  10847. v.templateOptions.options = list;
  10848. if (model.model.incident.handlerUser) {
  10849. if (model.model.incident.handlerUser.id) {
  10850. var flag = list.some(function (v) {
  10851. return v.id == model.model.incident.handlerUser.id;
  10852. });
  10853. if (flag) {
  10854. v.model.id = model.model.incident.handlerUser.id;
  10855. }
  10856. }
  10857. }
  10858. }
  10859. });
  10860. }
  10861. });
  10862. },
  10863. validators: {
  10864. required: {
  10865. expression: function (viewValue, modelValue) {
  10866. var value = modelValue || viewValue;
  10867. return value != null;
  10868. // return value.length>=1;
  10869. // if (modelValue && viewValue) {
  10870. // return value != null;
  10871. // } else {
  10872. // var value = modelValue || viewValue;
  10873. // return value.length > 0;
  10874. // }
  10875. },
  10876. },
  10877. },
  10878. },
  10879. controller: [
  10880. "$scope",
  10881. "$rootScope",
  10882. "api_bpm_domain",
  10883. "$stateParams",
  10884. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10885. // $scope.myFilter = function(item) {
  10886. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10887. // }
  10888. console.log($scope, "风浪");
  10889. if($scope.to.onlyKey === 'inspection.dictionary'){
  10890. //巡检列表-新增-巡检类型baba
  10891. console.log(location)
  10892. var loc = location.href.split('api_bpm_data')[1] || '';
  10893. if(loc.length <= 2){
  10894. // 新增轮询计划的时候
  10895. $scope.model.id = 1715;//默认系统默认
  10896. }
  10897. }
  10898. //工作组添加全部选项
  10899. // if($scope.options.templateOptions.label == '工作组'){
  10900. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10901. // $scope.model._group = 0;
  10902. // }
  10903. if (
  10904. $scope.options.templateOptions.pkey &&
  10905. $scope.options.templateOptions.pkey == "incident.place"
  10906. ) {
  10907. if (
  10908. $scope.$parent &&
  10909. $scope.$parent.$parent.$parent.model &&
  10910. $scope.$parent.$parent.$parent.model.incident.area &&
  10911. $scope.$parent.$parent.$parent.model.incident.area.id
  10912. ) {
  10913. $scope.options.templateOptions.linkage(
  10914. "place",
  10915. {
  10916. place: {
  10917. areaId:
  10918. $scope.$parent.$parent.$parent.model.incident.area.id,
  10919. // area:{
  10920. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  10921. // }
  10922. },
  10923. },
  10924. $scope.$parent.$parent.$parent.model,
  10925. "incident",
  10926. "place"
  10927. );
  10928. }
  10929. }
  10930. $scope.myFilter = $scope;
  10931. // console.log($scope.options.templateOptions)
  10932. console.log($scope, 77777);
  10933. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  10934. var paramsModel = JSON.parse($stateParams.model)
  10935. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  10936. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  10937. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  10938. }
  10939. }
  10940. //处理人根据事件分类自动带入baba
  10941. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  10942. console.log($scope.options.templateOptions.pkey);
  10943. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  10944. if (
  10945. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  10946. ) {
  10947. $scope.$parent.$parent.$parent.model.assignee =
  10948. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  10949. $scope.options.model.id =
  10950. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  10951. }
  10952. }
  10953. }
  10954. // 关闭事件页面满意度评价下拉框处理
  10955. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  10956. $scope.model.id =
  10957. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  10958. }
  10959. if ($scope.options.templateOptions.initData == 1) {
  10960. $scope.options.templateOptions.onChange(
  10961. $scope.model.id,
  10962. $scope.options,
  10963. $scope
  10964. );
  10965. }
  10966. if ($scope.options.templateOptions.transform) {
  10967. $scope.options.templateOptions.onChange(
  10968. $scope.model.id,
  10969. $scope.options,
  10970. $scope
  10971. );
  10972. }
  10973. if (angular.isFunction($scope.options.templateOptions.translate)) {
  10974. $scope.model[$scope.options.key] =
  10975. $scope.options.templateOptions.translate(
  10976. $scope.options,
  10977. $rootScope,
  10978. $scope
  10979. );
  10980. }
  10981. if (
  10982. angular.isFunction($scope.options.templateOptions.translatefunc)
  10983. ) {
  10984. $scope.model[$scope.options.key] =
  10985. $scope.options.templateOptions.translatefunc(
  10986. $scope.options,
  10987. $rootScope,
  10988. $scope
  10989. );
  10990. }
  10991. if (
  10992. angular.isFunction($scope.options.templateOptions.onlyfunction)
  10993. ) {
  10994. $scope.options.templateOptions.onlyfunction(
  10995. $scope.options,
  10996. $rootScope,
  10997. $scope
  10998. );
  10999. }
  11000. },
  11001. ],
  11002. };
  11003. },
  11004. });
  11005. //下拉框组件(巡检计划-查看)
  11006. formlyConfigProvider.setType({
  11007. name: "ui-select-xj",
  11008. extends: "select",
  11009. templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
  11010. defaultOptions: function (options, scope) {
  11011. return {
  11012. templateOptions: {
  11013. getScope: function () {
  11014. return scope;
  11015. },
  11016. refreshDelay: 0,
  11017. validators: {
  11018. required: {
  11019. expression: function (viewValue, modelValue) {
  11020. var value = modelValue || viewValue;
  11021. return value != null;
  11022. },
  11023. },
  11024. },
  11025. },
  11026. controller: [
  11027. "$scope",
  11028. "$rootScope",
  11029. "api_bpm_domain",
  11030. "$stateParams",
  11031. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  11032. $scope.model[$scope.options.key] = '0';//默认全部
  11033. var arr = [];
  11034. if(scope.options.key === 'searchParams_batchNos'){
  11035. // 批次号
  11036. if($scope.model.batchNos){
  11037. arr = $scope.model.batchNos.map(v=>({value:v,name:v}));
  11038. }
  11039. arr.unshift({value:'0',name:'全部'});
  11040. $scope.options.templateOptions.options = arr;
  11041. }else if(scope.options.key === 'searchParams_online'){
  11042. // 线上OR线下 liaomingming
  11043. arr.push({value:'0',name:'全部'});
  11044. arr.push({value:'1',name:'线上'});
  11045. arr.push({value:'2',name:'线下'});
  11046. $scope.options.templateOptions.options = arr;
  11047. }else if(scope.options.key === 'searchParams_state'){
  11048. // 状态
  11049. arr.push({value:'0',name:'全部'});
  11050. arr.push({value:'1',name:'执行中'});
  11051. arr.push({value:'2',name:'已完成'});
  11052. $scope.options.templateOptions.options = arr;
  11053. }
  11054. },
  11055. ],
  11056. };
  11057. },
  11058. });
  11059. //下拉多选框组件
  11060. formlyConfigProvider.setType({
  11061. name: "ui-multiselect",
  11062. extends: "select",
  11063. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11064. defaultOptions: function (options) {
  11065. return {
  11066. templateOptions: {
  11067. refresh: function () { },
  11068. refreshDelay: 1000,
  11069. },
  11070. };
  11071. },
  11072. controller: [
  11073. "$scope",
  11074. function ($scope) {
  11075. $scope.model[$scope.options.key] = [];
  11076. },
  11077. ],
  11078. });
  11079. //下拉多选全选组件
  11080. formlyConfigProvider.setType({
  11081. name: "ui-isteven",
  11082. extends: "select",
  11083. templateUrl: "assets/views/customform/tpl/ui-isteven.html",
  11084. defaultOptions: function (options,$scope) {
  11085. return {
  11086. templateOptions: {
  11087. refresh: function () {
  11088. console.log(options)
  11089. options.templateOptions
  11090. .refreshData(options.templateOptions.APIService)
  11091. .then(function (result) {
  11092. if(result.status == 200){
  11093. console.log(result.list)
  11094. //树形结构转换
  11095. function formatDataTree2(json){
  11096. var _json = JSON.parse(JSON.stringify(json));
  11097. return _json.filter(p=>{
  11098. var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
  11099. _arr.length && (p.children = _arr);
  11100. return !p.parent;
  11101. })
  11102. }
  11103. console.log(result.list)
  11104. var list = formatDataTree2(result.list);
  11105. console.log(list)
  11106. // $scope.treeList = angular.copy(list);
  11107. var resultList = [];
  11108. //转换数据
  11109. function trasData(list,obj){
  11110. if(obj){
  11111. //有父级
  11112. list.forEach(v=>{
  11113. var type = "<strong>"+ v.parent.type +"</strong>";//父级type
  11114. var i = resultList.findIndex(c=>c.type == type);
  11115. if(v.children){
  11116. resultList.splice(i+1,0,{
  11117. type: "<strong>"+ v.type +"</strong>",
  11118. msId: v.id,
  11119. msGroup: true,
  11120. },{msGroup: false})
  11121. trasData(v.children,v);
  11122. }else{
  11123. resultList.splice(i+1,0,{...v,...{ticked:false}});
  11124. }
  11125. })
  11126. }else{
  11127. //顶级
  11128. list.forEach(v=>{
  11129. if(v.children){
  11130. resultList.push({
  11131. type: "<strong>"+ v.type +"</strong>",
  11132. msId: v.id,
  11133. msGroup: true,
  11134. },{msGroup: false})
  11135. trasData(v.children,v);
  11136. }else{
  11137. resultList.push(...v,...{ticked:false});
  11138. }
  11139. })
  11140. }
  11141. return resultList;
  11142. }
  11143. var __arr = trasData(list,null);
  11144. // console.log(__arr,options.model.typeIds.split(','))
  11145. if(options.model.typeIds){
  11146. //有巡检类型,则需要回显
  11147. __arr.forEach(w=>{
  11148. w.ticked = options.model.typeIds.split(',').includes(w.id+'');
  11149. })
  11150. }
  11151. $scope.webBrowsersGrouped = __arr;
  11152. console.log($scope.webBrowsersGrouped);
  11153. }
  11154. })
  11155. },
  11156. refreshDelay: 1000,
  11157. },
  11158. };
  11159. },
  11160. controller: [
  11161. "$scope",
  11162. function ($scope) {
  11163. console.log($scope)
  11164. $scope.to.refresh();//获取列表数据
  11165. // $scope.model[$scope.options.key] = [];
  11166. //单项点击或菜单
  11167. $scope.fClick = function(data){
  11168. console.log($scope.outputBrowsers)
  11169. $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
  11170. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11171. // if(data.id){
  11172. // //单项点击
  11173. // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
  11174. // //有巡检类型
  11175. // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
  11176. // if(data.ticked){
  11177. // arr.push(data.id);
  11178. // }else{
  11179. // arr = arr.filter(v=>v != data.id);
  11180. // }
  11181. // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11182. // }else{
  11183. // //无巡检类型
  11184. // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
  11185. // if(data.ticked){
  11186. // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
  11187. // }else{
  11188. // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11189. // }
  11190. // }
  11191. // }else{
  11192. // // 菜单点击
  11193. // console.log($scope.webBrowsersGrouped,data.msId);
  11194. // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
  11195. // return v.parent?v.parent.id == data.msId:false;
  11196. // })
  11197. // if(treeResultArr.every(v=>v.ticked)){
  11198. // //全部都是true的情况下,需要移除,否则增加
  11199. // }
  11200. // console.log(treeResultArr)
  11201. // // --------------------------------------
  11202. // // var treeArr = [];
  11203. // // function findParent(treeList){
  11204. // // treeList.forEach(v=>{
  11205. // // if(v.id == data.msId){
  11206. // // treeArr = v.children;
  11207. // // }else{
  11208. // // if(v.children){
  11209. // // findParent(v.children);
  11210. // // }
  11211. // // }
  11212. // // })
  11213. // // return treeArr;
  11214. // // }
  11215. // // var treeResultArr = findParent($scope.treeList);
  11216. // // console.log(treeResultArr)
  11217. // // -----------------------------------
  11218. // }
  11219. }
  11220. // 全选
  11221. $scope.fSelectAll = function(){
  11222. // console.log($scope.webBrowsersGrouped)
  11223. var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
  11224. // console.log(arr);
  11225. $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11226. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11227. }
  11228. // 全不选
  11229. $scope.fSelectNone = function(){
  11230. $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11231. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11232. }
  11233. // 配置信息
  11234. $scope.outputBrowsers = [];
  11235. $scope.localLang = {
  11236. selectAll: "全选",
  11237. selectNone: "全不选",
  11238. nothingSelected: "请选择"
  11239. }
  11240. },
  11241. ],
  11242. });
  11243. //下拉多选框灵活组件
  11244. formlyConfigProvider.setType({
  11245. name: "ui-multiselectplus",
  11246. extends: "multiCheckbox",
  11247. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11248. defaultOptions: function (options, $scope) {
  11249. return {
  11250. templateOptions: {
  11251. refreshData: function (search, options, model, that) {
  11252. console.log(search, options, model, that)
  11253. var process = options.templateOptions.ApiService.all("");
  11254. if (search) {
  11255. } else {
  11256. }
  11257. var postData = options.templateOptions.optionsPostData;
  11258. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11259. postData = options.templateOptions.optionsPostData(
  11260. options,
  11261. model,
  11262. that
  11263. );
  11264. }
  11265. if (options.templateOptions.modelreasondata) {
  11266. postData = options.templateOptions.modelreasondata;
  11267. }
  11268. process
  11269. .customPOST(postData, options.templateOptions.optionsUrl)
  11270. .then(function (result) {
  11271. // if (!options.templateOptions.options) {
  11272. // options.templateOptions.options = [];
  11273. // }
  11274. // 过滤下拉列表已选择的值
  11275. var modelVal = $scope.model[$scope.options.key];
  11276. var ides = [];
  11277. var rList = result.list || result;
  11278. if ($scope.options.key == "serviceTypeIds") {
  11279. modelVal = modelVal.map(function (v) {
  11280. if (typeof v !== 'object') {
  11281. return { id: v };
  11282. } else {
  11283. return v;
  11284. }
  11285. })
  11286. }
  11287. for (var i = 0; i < modelVal.length; i++) {
  11288. for (var j = 0; j < rList.length; j++) {
  11289. if (rList[j].id == modelVal[i].id) {
  11290. ides.push(rList[j].id);
  11291. }
  11292. }
  11293. }
  11294. ides.forEach(function (v1) {
  11295. rList.forEach(function (v2) {
  11296. if (v1 == v2.id) {
  11297. rList = rList.filter(v => v.id != v2.id);
  11298. }
  11299. })
  11300. })
  11301. options.templateOptions.options = rList;
  11302. // if (options.templateOptions.optionsDataKey) {
  11303. // options.templateOptions.options =
  11304. // result[options.templateOptions.optionsDataKey];
  11305. // } else {
  11306. // options.templateOptions.options = result;
  11307. // }
  11308. if (options.templateOptions.optionsChecked) {
  11309. // return options.value = null;
  11310. options.value(options.model[options.key]);
  11311. }
  11312. });
  11313. },
  11314. refreshDelay: 0,
  11315. // },
  11316. // validators: {
  11317. // required: {
  11318. // expression: function(viewValue, modelValue) {
  11319. // var value = modelValue || viewValue;
  11320. // // return value.length>=1;
  11321. // // if (modelValue && viewValue) {
  11322. // // return value != null;
  11323. // // } else {
  11324. // // var value = modelValue || viewValue;
  11325. // // return value.length > 0;
  11326. // // }
  11327. // }
  11328. // }
  11329. },
  11330. };
  11331. },
  11332. controller: [
  11333. "$scope",
  11334. function ($scope) {
  11335. if (angular.isArray($scope.model[$scope.options.key])) {
  11336. } else {
  11337. $scope.model[$scope.options.key] = [];
  11338. }
  11339. },
  11340. ],
  11341. });
  11342. //下拉树形多选组件
  11343. formlyConfigProvider.setType({
  11344. name: "ui-multiselect-tree",
  11345. extends: "multiCheckbox",
  11346. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11347. defaultOptions: function (options) {
  11348. return {
  11349. templateOptions: {
  11350. linkage: function (modelName, data, model, modelKey, key) {
  11351. angular.extend(data, {
  11352. idx: 0,
  11353. sum: 10,
  11354. });
  11355. options.templateOptions.APIService.fetchDataList(
  11356. modelName,
  11357. data
  11358. ).then(function (response) {
  11359. var myData =
  11360. options.templateOptions.Restangular.stripRestangular(response);
  11361. var list = myData.list;
  11362. if (list.length == 1) {
  11363. angular.forEach(model.fields, function (item) {
  11364. angular.forEach(model.fields, function (item) {
  11365. if (item.templateOptions.pkey == modelKey + "." + key) {
  11366. item.model.id = "";
  11367. if (key == "place") {
  11368. item.templateOptions.options = list;
  11369. } else {
  11370. item.value(list[0][key][item.key]);
  11371. }
  11372. }
  11373. });
  11374. });
  11375. }
  11376. });
  11377. },
  11378. // my_tree_handler : function(items) {
  11379. // },
  11380. // onFilterCallback : function(items) {
  11381. // },
  11382. // onFilterCallback : function(items) {
  11383. // },
  11384. refresh: function (items) {
  11385. var treedata = [];
  11386. function convertListToTree(data, treeMap) {
  11387. treedata = data;
  11388. for (var i = 0; i < data.length; i++) {
  11389. for (var j = 0; j < data.length; j++) {
  11390. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11391. if (data[i].pid == data[j].id) {
  11392. data[i].parent = data[j];
  11393. }
  11394. }
  11395. }
  11396. }
  11397. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11398. var root = null; //Initially set our loop to null
  11399. //loop over data
  11400. for (var i = 0; i < data.length; i++) {
  11401. var datum = data[i];
  11402. //each node will have children, so let's give it a "children" poperty
  11403. datum.children = [];
  11404. //add an entry for this node to the map so that any future children can
  11405. //lookup the parent
  11406. idToNodeMap[datum.id] = datum;
  11407. //Does this node have a parent?
  11408. if (
  11409. typeof datum.parent === "undefined" ||
  11410. datum.parent === null
  11411. ) {
  11412. //Doesn't look like it, so this node is the root of the tree
  11413. root = datum;
  11414. treeMap[datum.id] = root;
  11415. } else {
  11416. //This node has a parent, so let's look it up using the id
  11417. parentNode = idToNodeMap[datum.parent.id];
  11418. //We don't need this property, so let's delete it.
  11419. delete datum.parent;
  11420. //Let's add the current node as a child of the parent node.
  11421. parentNode.children.push(datum);
  11422. }
  11423. }
  11424. return root;
  11425. }
  11426. function convertParentToChildList(data) {
  11427. // console.log("data="+JSON.stringify(data))
  11428. var treeMap = {};
  11429. var list = [];
  11430. convertListToTree(data, treeMap);
  11431. angular.forEach(treeMap, function (item) {
  11432. list.push(item);
  11433. });
  11434. return list;
  11435. }
  11436. function selectItem(pmodel, childrens) {
  11437. if (angular.isArray(pmodel)) {
  11438. angular.forEach(pmodel, function (index) {
  11439. if (index && index.id) {
  11440. angular.forEach(childrens, function (item) {
  11441. if (item.id == index.id) {
  11442. item.selected = true;
  11443. }
  11444. if (item && item.children) {
  11445. selectItem(pmodel, item.children);
  11446. }
  11447. });
  11448. }
  11449. });
  11450. } else {
  11451. if (pmodel && pmodel.id) {
  11452. angular.forEach(childrens, function (item) {
  11453. if (item.id == pmodel.id) {
  11454. item.selected = true;
  11455. }
  11456. if (item && item.children) {
  11457. selectItem(pmodel, item.children);
  11458. }
  11459. });
  11460. }
  11461. }
  11462. }
  11463. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11464. options.templateOptions
  11465. .refreshData(options.templateOptions.APIService)
  11466. .then(function (result) {
  11467. if (result.status == 200) {
  11468. if (!options.templateOptions.options) {
  11469. options.templateOptions.options = [];
  11470. }
  11471. if (options.templateOptions.optionsDataKey) {
  11472. options.templateOptions.options = convertParentToChildList(
  11473. result[options.templateOptions.optionsDataKey]
  11474. );
  11475. } else {
  11476. options.templateOptions.options =
  11477. convertParentToChildList(result);
  11478. }
  11479. //set default value
  11480. var pmodel,
  11481. i = 0;
  11482. if (options.templateOptions.pkey) {
  11483. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11484. angular.forEach(
  11485. options.templateOptions.pkey.split("."),
  11486. function (p) {
  11487. if (i == 0) {
  11488. if (options.model[p] == null) {
  11489. options.model[p] = {};
  11490. }
  11491. pmodel = options.model[p];
  11492. i++;
  11493. } else {
  11494. if (pmodel[p] == null) {
  11495. pmodel[p] = {};
  11496. }
  11497. pmodel = pmodel[p];
  11498. }
  11499. }
  11500. );
  11501. } else {
  11502. pmodel = options.model;
  11503. }
  11504. }
  11505. if (pmodel) {
  11506. pmodel = pmodel[options.key];
  11507. } else if (options.model) {
  11508. pmodel = options.model[options.key];
  11509. } else {
  11510. pmodel = options.templateOptions.options;
  11511. }
  11512. if (angular.isArray(pmodel)) {
  11513. if (pmodel) {
  11514. // if(options.templateOptions.isMultiSelect==true){
  11515. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11516. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11517. // })
  11518. // }else{
  11519. selectItem(pmodel, options.templateOptions.options);
  11520. // }
  11521. }
  11522. } else {
  11523. if (pmodel && pmodel.id) {
  11524. selectItem(pmodel, options.templateOptions.options);
  11525. }
  11526. }
  11527. items.inputModel = options.templateOptions.options;
  11528. }
  11529. });
  11530. },
  11531. },
  11532. validators: {
  11533. required: {
  11534. expression: function (viewValue, modelValue) {
  11535. var value = modelValue || viewValue;
  11536. if (angular.isArray(value)) {
  11537. for (var i = 0; i < value.length; i++) {
  11538. value[i] = {
  11539. id: value[i].id,
  11540. };
  11541. }
  11542. return value.length > 0;
  11543. } else {
  11544. // console.log(options)
  11545. // return value = "true";
  11546. return value != null;
  11547. }
  11548. },
  11549. },
  11550. },
  11551. };
  11552. },
  11553. controller: [
  11554. "$scope",
  11555. "api_configure_form",
  11556. function ($scope, api_configure_form) {
  11557. if ($scope.options.templateOptions.isMultiSelect) {
  11558. // console.log($scope);
  11559. } else {
  11560. if ($scope.model[$scope.options.key]) {
  11561. }
  11562. }
  11563. },
  11564. ],
  11565. });
  11566. //多选下拉框组件
  11567. formlyConfigProvider.setType({
  11568. name: "ui-multi-select-tree",
  11569. extends: "input",
  11570. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11571. defaultOptions: function (options) {
  11572. return {
  11573. templateOptions: {
  11574. linkage: function (modelName, data, model, modelKey, key) {
  11575. angular.extend(data, {
  11576. idx: 0,
  11577. sum: 10,
  11578. });
  11579. options.templateOptions.APIService.fetchDataList(
  11580. modelName,
  11581. data
  11582. ).then(function (response) {
  11583. var myData =
  11584. options.templateOptions.Restangular.stripRestangular(response);
  11585. var list = myData.list;
  11586. if (list.length == 1) {
  11587. angular.forEach(model.fields, function (item) {
  11588. angular.forEach(model.fields, function (item) {
  11589. if (item.templateOptions.pkey == modelKey + "." + key) {
  11590. item.model.id = "";
  11591. if (key == "place") {
  11592. item.templateOptions.options = list;
  11593. } else {
  11594. item.value(list[0][key][item.key]);
  11595. }
  11596. }
  11597. });
  11598. });
  11599. }
  11600. });
  11601. },
  11602. getparentdata: function (items) {
  11603. // console.log(items)
  11604. },
  11605. refresh: function (items, search, fn) {
  11606. console.log(items, options);
  11607. var treedata = [];
  11608. function convertListToTree(data, treeMap) {
  11609. // console.log(data)
  11610. treedata = data;
  11611. for (var i = 0; i < data.length; i++) {
  11612. for (var j = 0; j < data.length; j++) {
  11613. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11614. if (data[i].pid == data[j].id) {
  11615. data[i].parent = data[j];
  11616. }
  11617. }
  11618. // if (data[i].id) {
  11619. // if (data[i].id== data[j].id) {
  11620. // data[i].parent = data[j];
  11621. // }
  11622. // }
  11623. }
  11624. }
  11625. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11626. var root = []; //Initially set our loop to null
  11627. if (search == "search" && items.filterKeyword) {
  11628. function transform(nodes) {
  11629. var treeConverter = {
  11630. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11631. attributeName: "id", //节点唯一标识符
  11632. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11633. transform: function (node) {
  11634. //转化递归函数,参数:一个待插入节点
  11635. if (node.parent != null) {
  11636. //该节点有父节点
  11637. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11638. if (this.needFind) {
  11639. for (var i = 0; i < newNode.children.length; i++) {
  11640. //查找要插入的node子节点是否在newNode这个父节点中存在
  11641. if (
  11642. newNode.children[i][this.attributeName] ===
  11643. node[this.attributeName]
  11644. ) {
  11645. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11646. }
  11647. }
  11648. }
  11649. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11650. // delete node.parent; //删除该节点的parent属性,如果有的话
  11651. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11652. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11653. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11654. } else if (node.parent == null) {
  11655. //该叶节点没有父节点,即为根节点
  11656. // delete node.parent; //删除该节点的parent属性,如果有的话
  11657. if (this.result == null) {
  11658. //根节点不存在
  11659. node.children = []; //给该节点增加children:[]属性
  11660. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11661. } else {
  11662. node.children = [];
  11663. // 顶级去重
  11664. for (
  11665. var i = 0;
  11666. i < this.result.children.length;
  11667. i++
  11668. ) {
  11669. if (
  11670. this.result.children[i][this.attributeName] ===
  11671. node[this.attributeName]
  11672. ) {
  11673. return this.result.children[i];
  11674. }
  11675. }
  11676. this.result.children.push(node);
  11677. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11678. }
  11679. }
  11680. },
  11681. getWhole: function (nodes, attributeName) {
  11682. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11683. var _node = {};
  11684. _node.children = [];
  11685. this.result = _node; //重置根节点
  11686. this.attributeName =
  11687. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11688. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11689. nodes.forEach((item) => {
  11690. //循环调用转化方法
  11691. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11692. this.transform(item);
  11693. });
  11694. return this.result; //返回根节点
  11695. },
  11696. };
  11697. var result = treeConverter.getWhole(nodes); //调用
  11698. return result;
  11699. }
  11700. var li = transform(data).children;
  11701. // li=[...new Set(li)]
  11702. console.log(li);
  11703. treeMap = li;
  11704. fn(li);
  11705. return li;
  11706. } else {
  11707. //loop over data
  11708. for (var i = 0; i < data.length; i++) {
  11709. var datum = data[i];
  11710. //each node will have children, so let's give it a "children" poperty
  11711. datum.children = [];
  11712. //add an entry for this node to the map so that any future children can
  11713. //lookup the parent
  11714. idToNodeMap[datum.id] = datum;
  11715. //Does this node have a parent?
  11716. if (
  11717. typeof datum.parent === "undefined" ||
  11718. datum.parent === null
  11719. ) {
  11720. //Doesn't look like it, so this node is the root of the tree
  11721. root = datum;
  11722. treeMap[datum.id] = root;
  11723. } else {
  11724. //This node has a parent, so let's look it up using the id
  11725. parentNode = idToNodeMap[datum.parent.id];
  11726. //We don't need this property, so let's delete it.
  11727. // delete datum.parent;
  11728. //Let's add the current node as a child of the parent node.
  11729. parentNode.children.push(datum);
  11730. }
  11731. }
  11732. }
  11733. return root;
  11734. }
  11735. function convertParentToChildList(data) {
  11736. var treeMap = {};
  11737. var list = [];
  11738. if (search == "search" && items.filterKeyword) {
  11739. var lis = convertListToTree(data, treeMap);
  11740. return lis;
  11741. } else {
  11742. if (data[0] && data[0].orders) {
  11743. list = data;
  11744. } else {
  11745. convertListToTree(data, treeMap);
  11746. angular.forEach(treeMap, function (item) {
  11747. // console.log("item="+JSON.stringify(item))
  11748. list.push(item);
  11749. });
  11750. }
  11751. return list;
  11752. }
  11753. }
  11754. function selectItem(pmodel, childrens) {
  11755. if (angular.isArray(pmodel)) {
  11756. angular.forEach(pmodel, function (index) {
  11757. if (index && index.id) {
  11758. angular.forEach(childrens, function (item) {
  11759. if (item.id == index.id) {
  11760. item.selected = true;
  11761. }
  11762. if (item && item.children) {
  11763. selectItem(pmodel, item.children);
  11764. }
  11765. });
  11766. // angular.forEach(treedata,function(parentdata){
  11767. // if(parentdata.id == index.id){
  11768. // if(parentdata.parent&&parentdata.parent.id){
  11769. // parentdata.parent.$
  11770. // }
  11771. // item.selected = true;
  11772. // }
  11773. // if (item && item.children) {
  11774. // selectItem(pmodel ,item.children);
  11775. // }
  11776. // });
  11777. }
  11778. });
  11779. } else {
  11780. if (pmodel && pmodel.id) {
  11781. angular.forEach(childrens, function (item, index) {
  11782. if (item.id == pmodel.id) {
  11783. item.selected = true;
  11784. // delete item.children;
  11785. }
  11786. if (item && item.children) {
  11787. selectItem(pmodel, item.children);
  11788. }
  11789. });
  11790. }
  11791. }
  11792. }
  11793. function selectItemchild(pmodel, childrens) {
  11794. if (angular.isArray(pmodel)) {
  11795. angular.forEach(pmodel, function (index) {
  11796. if (index && index.id) {
  11797. angular.forEach(childrens, function (item) {
  11798. if (item.id == index.id) {
  11799. item.selected = true;
  11800. }
  11801. if (item && item.children) {
  11802. selectItem(pmodel, item.children);
  11803. }
  11804. });
  11805. }
  11806. });
  11807. } else {
  11808. if (pmodel && pmodel.id) {
  11809. angular.forEach(childrens, function (item, index) {
  11810. if (item.id == pmodel.id) {
  11811. item.selected = true;
  11812. childrens[index].selected = true;
  11813. }
  11814. if (item && item.children) {
  11815. selectItem(pmodel, item.children);
  11816. }
  11817. });
  11818. }
  11819. }
  11820. }
  11821. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11822. if (search === "search" && items.filterKeyword) {
  11823. // bala:树形模糊搜索
  11824. options.templateOptions
  11825. .bala(options.templateOptions.APIService, items.filterKeyword)
  11826. .then(function (result) {
  11827. result.list = [...new Set(result.list)]; //去重
  11828. if (!options.templateOptions.options) {
  11829. options.templateOptions.options = [];
  11830. }
  11831. if (options.templateOptions.optionsDataKey) {
  11832. options.templateOptions.options = convertParentToChildList(
  11833. result[options.templateOptions.optionsDataKey]
  11834. );
  11835. } else {
  11836. options.templateOptions.options =
  11837. convertParentToChildList(result);
  11838. }
  11839. //set default value
  11840. var pmodel,
  11841. i = 0;
  11842. if (
  11843. options.templateOptions.pkey ||
  11844. options.templateOptions.pkey != ""
  11845. ) {
  11846. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11847. angular.forEach(
  11848. options.templateOptions.pkey.split("."),
  11849. function (p) {
  11850. if (i == 0) {
  11851. if (options.model[p] == null) {
  11852. options.model[p] = {};
  11853. }
  11854. pmodel = options.model[p];
  11855. i++;
  11856. } else {
  11857. if (pmodel[p] == null) {
  11858. pmodel[p] = {};
  11859. }
  11860. pmodel = pmodel[p];
  11861. }
  11862. }
  11863. );
  11864. } else {
  11865. pmodel = options.model;
  11866. }
  11867. }
  11868. var topdata = angular.copy(options.templateOptions.options);
  11869. if (pmodel) {
  11870. pmodel = pmodel[options.key];
  11871. } else if (options.model) {
  11872. pmodel = options.model[options.key];
  11873. }
  11874. if (angular.isArray(pmodel)) {
  11875. if (pmodel) {
  11876. items.inputModel = angular.copy(
  11877. options.templateOptions.options
  11878. );
  11879. selectItem(pmodel, options.templateOptions.options);
  11880. }
  11881. } else {
  11882. if (pmodel && pmodel.id) {
  11883. items.inputModel = angular.copy(
  11884. options.templateOptions.options
  11885. );
  11886. selectItem(pmodel, options.templateOptions.options);
  11887. } else {
  11888. // items.inputModel = options.templateOptions.options;
  11889. }
  11890. }
  11891. // items.inputModel = options.templateOptions.options;
  11892. items.selectModel = options.templateOptions.options;
  11893. // 可在此展开
  11894. if (!items.inputModel) {
  11895. items.inputModel = items.selectModel;
  11896. } else {
  11897. selectItemchild(pmodel, items.inputModel);
  11898. // for (var i = 0; i < items.inputModel.length; i++) {
  11899. // items.inputModel[i].
  11900. // for (var j = 0; j < items.selectModel.length; j++) {
  11901. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11902. // items.inputModel[i].selected = true;
  11903. // }
  11904. // }
  11905. // }
  11906. }
  11907. return items.inputModel;
  11908. // options.templateOptions.options = angular.copy(topdata);
  11909. // console.log(model);
  11910. // console.log(options);
  11911. });
  11912. } else {
  11913. options.templateOptions
  11914. .refreshData(options.templateOptions.APIService)
  11915. .then(function (result) {
  11916. //回显事件分类,带出绑定的人或组start caocao
  11917. if (items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  11918. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  11919. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  11920. return v.id == items.$parent.originalModel.incident.category.id;
  11921. })
  11922. console.log(item)//11615
  11923. if (item) {
  11924. if (item.userOrGroupType === 1) {
  11925. items.$parent.originalModel.start_code = 'assignment';
  11926. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  11927. items.$parent.originalModel.directClose = true;
  11928. items.$parent.originalModel.isHandlerUser = false;
  11929. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  11930. } else if (item.userOrGroupType === 2) {
  11931. items.$parent.originalModel.start_code = 'assignment';
  11932. items.$parent.originalModel.candidateGroups = item.group;
  11933. items.$parent.originalModel.directClose = true;
  11934. items.$parent.originalModel.isHandlerUser = false;
  11935. } else {
  11936. items.$parent.originalModel.start_code = 'close';
  11937. items.$parent.originalModel.directClose = false;
  11938. items.$parent.originalModel.isHandlerUser = false;
  11939. delete items.$parent.originalModel.candidateGroups;
  11940. delete items.$parent.originalModel.incident.handlerUser
  11941. }
  11942. }
  11943. }
  11944. //回显事件分类,带出绑定的人或组end
  11945. if (!options.templateOptions.options) {
  11946. options.templateOptions.options = [];
  11947. }
  11948. if (options.templateOptions.optionsDataKey) {
  11949. options.templateOptions.options = convertParentToChildList(
  11950. result[options.templateOptions.optionsDataKey]
  11951. );
  11952. } else {
  11953. options.templateOptions.options =
  11954. convertParentToChildList(result);
  11955. }
  11956. //set default value
  11957. var pmodel,
  11958. i = 0;
  11959. if (
  11960. options.templateOptions.pkey ||
  11961. options.templateOptions.pkey != ""
  11962. ) {
  11963. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11964. angular.forEach(
  11965. options.templateOptions.pkey.split("."),
  11966. function (p) {
  11967. if (i == 0) {
  11968. if (options.model[p] == null) {
  11969. options.model[p] = {};
  11970. }
  11971. pmodel = options.model[p];
  11972. i++;
  11973. } else {
  11974. if (pmodel[p] == null) {
  11975. pmodel[p] = {};
  11976. }
  11977. pmodel = pmodel[p];
  11978. }
  11979. }
  11980. );
  11981. } else {
  11982. pmodel = options.model;
  11983. }
  11984. }
  11985. var topdata = angular.copy(options.templateOptions.options);
  11986. if (pmodel) {
  11987. pmodel = pmodel[options.key];
  11988. } else if (options.model) {
  11989. pmodel = options.model[options.key];
  11990. }
  11991. if (angular.isArray(pmodel)) {
  11992. if (pmodel) {
  11993. items.inputModel = angular.copy(
  11994. options.templateOptions.options
  11995. );
  11996. selectItem(pmodel, options.templateOptions.options);
  11997. }
  11998. } else {
  11999. if (pmodel && pmodel.id) {
  12000. items.inputModel = angular.copy(
  12001. options.templateOptions.options
  12002. );
  12003. selectItem(pmodel, options.templateOptions.options);//baba
  12004. } else {
  12005. // items.inputModel = options.templateOptions.options;
  12006. }
  12007. }
  12008. // items.inputModel = options.templateOptions.options;
  12009. items.selectModel = options.templateOptions.options;
  12010. if (!items.inputModel) {
  12011. items.inputModel = items.selectModel;
  12012. } else {
  12013. selectItemchild(pmodel, items.inputModel);
  12014. // for (var i = 0; i < items.inputModel.length; i++) {
  12015. // for (var j = 0; j < items.selectModel.length; j++) {
  12016. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12017. // items.inputModel[i].selected = true;
  12018. // }
  12019. // }
  12020. // }
  12021. }
  12022. // options.templateOptions.options = angular.copy(topdata);
  12023. // console.log(model);
  12024. // console.log(options);
  12025. });
  12026. }
  12027. },
  12028. },
  12029. validators: {
  12030. required: {
  12031. expression: function (viewValue, modelValue) {
  12032. var value = modelValue || viewValue;
  12033. if (angular.isArray(value)) {
  12034. return value.length > 0;
  12035. } else {
  12036. // console.log(options)
  12037. if (options.templateOptions.required && !value) {
  12038. // return value != null;
  12039. } else {
  12040. return value;
  12041. }
  12042. // return value = "true";
  12043. }
  12044. },
  12045. },
  12046. },
  12047. };
  12048. },
  12049. controller: [
  12050. "$scope",
  12051. "$rootScope",
  12052. "api_configure_form",
  12053. "api_bpm_domain",
  12054. function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  12055. $rootScope.checkClicked = function (item) {
  12056. angular.forEach($scope.to.options, function (itemone) {
  12057. if (!item.parent) {
  12058. if (item.id == itemone.id) {
  12059. // itemone.isExpanded = true;
  12060. } else {
  12061. itemone.isExpanded = false;
  12062. }
  12063. } else {
  12064. if (item.parent.id == itemone.id) {
  12065. angular.forEach(itemone.children, function (itemtwo) {
  12066. if (item.id == itemtwo.id) {
  12067. } else {
  12068. itemtwo.isExpanded = false;
  12069. }
  12070. });
  12071. }
  12072. }
  12073. });
  12074. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  12075. console.log($scope, "gsm");
  12076. if (
  12077. $scope.originalModel &&
  12078. $scope.originalModel.incident &&
  12079. item.category &&
  12080. (!item.children || !item.children.length) &&
  12081. item.priority &&
  12082. item.priority.id
  12083. ) {
  12084. api_bpm_domain
  12085. .expectedTime("L" + (item.priority.id - 1559))
  12086. .then(function (res) {
  12087. $scope.originalModel.incident.expectResponseTime =
  12088. res.serviceLevelAgreement.responseTime;
  12089. $scope.originalModel.incident.expectIntroTime =
  12090. res.serviceLevelAgreement.resolveTime;
  12091. $scope.originalModel.incident.overdueTime = res.date;
  12092. });
  12093. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  12094. // setTimeout(() => {
  12095. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  12096. // }, 500);
  12097. // console.log($scope.$parent.$parent.$parent)
  12098. }
  12099. };
  12100. if ($scope.options.templateOptions.isMultiSelect) {
  12101. // console.log($scope);
  12102. } else {
  12103. if ($scope.model[$scope.options.key]) {
  12104. }
  12105. }
  12106. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  12107. // console.log(item)
  12108. // // if(){
  12109. // // }
  12110. // // $scope.model[$scope.options.key]=item.id;
  12111. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  12112. // $scope.propTypeOptions = data;
  12113. // });
  12114. // }
  12115. // $scope.model[$scope.options.key]=[];
  12116. // $scope.fn
  12117. $rootScope.bala1 = function (items, fn) {
  12118. // $scope.fn = fn;
  12119. console.log(items);
  12120. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  12121. $scope.options.templateOptions.refresh(items, "search", fn);
  12122. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  12123. // // return res.list;
  12124. // console.log(666)
  12125. // fn(res.list)
  12126. // })
  12127. };
  12128. },
  12129. ],
  12130. });
  12131. //勾选组件
  12132. formlyConfigProvider.setType({
  12133. name: "ui-checkbox",
  12134. extends: "checkbox",
  12135. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  12136. controller: [
  12137. "$scope",
  12138. function ($scope) {
  12139. console.log($scope)
  12140. if($scope.options.templateOptions.isTrue){
  12141. //是否默认打开
  12142. $scope.model[$scope.options.key] = true;
  12143. }
  12144. // 巡检生成事件,默认派单
  12145. if ($scope.model.isInspection) {
  12146. $scope.model[$scope.options.key] = true;
  12147. }
  12148. if ($scope.model[$scope.options.key] == "true") {
  12149. $scope.model[$scope.options.key] = true;
  12150. }
  12151. if ($scope.model[$scope.options.key] == "false") {
  12152. $scope.model[$scope.options.key] = false;
  12153. }
  12154. },
  12155. ],
  12156. });
  12157. //勾选组件(禁用)--yeye
  12158. formlyConfigProvider.setType({
  12159. name: "ui-checkbox-disabled",
  12160. extends: "checkbox",
  12161. templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.html",
  12162. controller: [
  12163. "$scope",
  12164. function ($scope) {
  12165. // 巡检生成事件,默认派单
  12166. // if ($scope.model.isInspection) {
  12167. // $scope.model[$scope.options.key] = true;
  12168. // }
  12169. // if ($scope.model[$scope.options.key] == "true") {
  12170. // $scope.model[$scope.options.key] = true;
  12171. // }
  12172. // if ($scope.model[$scope.options.key] == "false") {
  12173. // $scope.model[$scope.options.key] = false;
  12174. // }
  12175. },
  12176. ],
  12177. });
  12178. //换行组件
  12179. formlyConfigProvider.setType({
  12180. name: "ui-nextLine",
  12181. /*extends: 'input',*/
  12182. template: "<div></div>",
  12183. });
  12184. //多选框组件
  12185. formlyConfigProvider.setType({
  12186. name: "ui-checklist",
  12187. extends: "multiCheckbox",
  12188. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  12189. defaultOptions: function (options) {
  12190. return {
  12191. templateOptions: {
  12192. refresh: function () { },
  12193. refreshDelay: 0,
  12194. },
  12195. };
  12196. },
  12197. });
  12198. //单选框组件
  12199. formlyConfigProvider.setType({
  12200. name: "ui-radio",
  12201. extends: "radio",
  12202. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  12203. defaultOptions: function (options) {
  12204. return {
  12205. templateOptions: {
  12206. refresh: function () {},
  12207. refreshDelay: 0,
  12208. },
  12209. };
  12210. },
  12211. controller: [
  12212. "$scope",
  12213. "api_wechatfile",
  12214. function ($scope,api_wechatfile) {
  12215. // 新增巡检计划-巡检方式baba
  12216. if($scope.to.onlyKey === 'onlineType'){
  12217. api_wechatfile.getDictionary($scope.to.modelreasondata).then(function (result) {
  12218. $scope.to.options = result;
  12219. if(!$scope.model[$scope.options.key]){
  12220. $scope.model[$scope.options.key] = result[0]?result[0].id:null;
  12221. }
  12222. });
  12223. }
  12224. // 巡检生成事件,默认派单
  12225. if ($scope.model.isInspection) {
  12226. $scope.model[$scope.options.key] = true;
  12227. // $scope.model.isHandlerUser=true;
  12228. $scope.model.start_code = "assignment";
  12229. console.log($scope.model);
  12230. }
  12231. //多次暂存配置
  12232. // console.log($scope);
  12233. if ($scope.model.saveAgain) {
  12234. if (
  12235. $scope.model.directClose == "1" ||
  12236. $scope.model.directClose == true
  12237. ) {
  12238. $scope.model[$scope.options.key] = true;
  12239. // if($scope.model.incident.handlingPersonnelUser){
  12240. // delete $scope.model.incident.handlingPersonnelUser;
  12241. // };
  12242. if ($scope.model.incident.handleDescription) {
  12243. delete $scope.model.incident.handleDescription;
  12244. }
  12245. if ($scope.model.incident.closecode) {
  12246. delete $scope.model.incident.closecode;
  12247. }
  12248. if ($scope.model.incident.degree) {
  12249. delete $scope.model.incident.degree;
  12250. }
  12251. } else {
  12252. $scope.model.incident.handlingPersonnelUser =
  12253. $scope.model.incident.acceptUser;
  12254. $scope.model[$scope.options.key] = false;
  12255. }
  12256. }
  12257. },
  12258. ],
  12259. });
  12260. //文本域组件
  12261. formlyConfigProvider.setWrapper({
  12262. name: "validation",
  12263. types: ["ui-textarea"],
  12264. template:
  12265. '<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>',
  12266. });
  12267. formlyConfigProvider.setType({
  12268. name: "ui-textarea",
  12269. extends: "textarea",
  12270. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12271. defaultOptions: function (options) {
  12272. return {
  12273. templateOptions: {
  12274. transform: function (model, value) {
  12275. return value;
  12276. },
  12277. },
  12278. validation: {
  12279. messages: {
  12280. maxlength: function (viewValue, modelValue, scope) {
  12281. if (viewValue != null) {
  12282. if (viewValue.length > scope.to.maxlength) {
  12283. return (
  12284. scope.to.label +
  12285. " 字数(" +
  12286. viewValue.length +
  12287. ")超限(" +
  12288. scope.to.maxlength +
  12289. ")"
  12290. );
  12291. } else {
  12292. return "";
  12293. }
  12294. }
  12295. },
  12296. },
  12297. },
  12298. };
  12299. },
  12300. controller: [
  12301. "$scope",
  12302. function ($scope) {
  12303. var value = $scope.model[$scope.options.key];
  12304. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12305. $scope.model[$scope.options.key] =
  12306. $scope.options.templateOptions.transform(
  12307. $scope.originalModel,
  12308. value
  12309. );
  12310. }
  12311. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12312. $scope.options.templateOptions.felditem($scope);
  12313. }
  12314. },
  12315. ],
  12316. });
  12317. // div版的textarea(展示富文本框内容用)
  12318. formlyConfigProvider.setType({
  12319. name: "ui-divTextarea",
  12320. extends: "textarea",
  12321. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12322. defaultOptions: function (options) {
  12323. return {
  12324. templateOptions: {
  12325. transform: function (model, value) {
  12326. return value;
  12327. },
  12328. },
  12329. validation: {
  12330. messages: {
  12331. // maxlength: function (viewValue, modelValue, scope) {
  12332. // if (viewValue != null) {
  12333. // if (viewValue.length > scope.to.maxlength) {
  12334. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12335. // } else {
  12336. // return "";
  12337. // }
  12338. // }
  12339. // },
  12340. },
  12341. },
  12342. };
  12343. },
  12344. controller: [
  12345. "$scope",
  12346. function ($scope) {
  12347. var value = $scope.model[$scope.options.key];
  12348. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12349. $scope.model[$scope.options.key] =
  12350. $scope.options.templateOptions.transform(
  12351. $scope.originalModel,
  12352. value
  12353. );
  12354. }
  12355. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12356. $scope.options.templateOptions.felditem($scope);
  12357. }
  12358. },
  12359. ],
  12360. });
  12361. // 带有知识库引用的textarea
  12362. formlyConfigProvider.setType({
  12363. name: "ui-textAreaKnowledge",
  12364. // extends: 'textarea',
  12365. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12366. defaultOptions: function (options) {
  12367. return {
  12368. templateOptions: {
  12369. transform: function (model, value) {
  12370. return value;
  12371. },
  12372. },
  12373. validation: {
  12374. messages: {
  12375. maxlength: function (viewValue, modelValue, scope) {
  12376. if (viewValue != null) {
  12377. if (viewValue.length > scope.to.maxlength) {
  12378. return (
  12379. scope.to.label +
  12380. " 字数(" +
  12381. viewValue.length +
  12382. ")超限(" +
  12383. scope.to.maxlength +
  12384. ")"
  12385. );
  12386. } else {
  12387. return "";
  12388. }
  12389. }
  12390. },
  12391. },
  12392. },
  12393. };
  12394. },
  12395. controller: [
  12396. "$scope",
  12397. "$rootScope",
  12398. "$modal",
  12399. "SweetAlert",
  12400. "api_bpm_data",
  12401. "api_bpm_domain",
  12402. "api_solution",
  12403. "$aside",
  12404. "api_zsk",
  12405. "up_down_file",
  12406. "api_wechatfile",
  12407. function (
  12408. $scope,
  12409. $rootScope,
  12410. $modal,
  12411. SweetAlert,
  12412. api_bpm_data,
  12413. api_bpm_domain,
  12414. api_solution,
  12415. $aside,
  12416. api_zsk,
  12417. up_down_file,
  12418. api_wechatfile
  12419. ) {
  12420. // console.log($scope);
  12421. var value = $scope.model[$scope.options.key];
  12422. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12423. $scope.model[$scope.options.key] =
  12424. $scope.options.templateOptions.transform(
  12425. $scope.originalModel,
  12426. value
  12427. );
  12428. }
  12429. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12430. $scope.options.templateOptions.felditem($scope);
  12431. }
  12432. // 引用知识库点击
  12433. $scope.openSolution = function () {
  12434. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12435. setTimeout(() => {
  12436. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12437. }, 100);
  12438. };
  12439. },
  12440. ],
  12441. });
  12442. //常用语句选择textarea
  12443. formlyConfigProvider.setType({
  12444. name: "ui-textselect",
  12445. extends: "textarea",
  12446. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12447. defaultOptions: function (options) {
  12448. return {
  12449. templateOptions: {
  12450. transform: function (model, value) {
  12451. return value;
  12452. },
  12453. },
  12454. validation: {
  12455. messages: {
  12456. maxlength: function (viewValue, modelValue, scope) {
  12457. if (viewValue != null) {
  12458. if (viewValue.length > scope.to.maxlength) {
  12459. return (
  12460. scope.to.label +
  12461. " 字数(" +
  12462. viewValue.length +
  12463. ")超限(" +
  12464. scope.to.maxlength +
  12465. ")"
  12466. );
  12467. } else {
  12468. return "";
  12469. }
  12470. }
  12471. },
  12472. },
  12473. },
  12474. };
  12475. },
  12476. controller: [
  12477. "$scope",
  12478. function ($scope) {
  12479. var value = $scope.model[$scope.options.key];
  12480. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12481. $scope.model[$scope.options.key] =
  12482. $scope.options.templateOptions.transform(
  12483. $scope.originalModel,
  12484. value
  12485. );
  12486. }
  12487. },
  12488. ],
  12489. });
  12490. //改动的组件 ckeditor封装后的组件
  12491. formlyConfigProvider.setType({
  12492. name: "ui-text-check",
  12493. extends: "textarea",
  12494. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12495. defaultOptions: function (options) {
  12496. return {
  12497. templateOptions: {
  12498. extraPlugins: "uploadimage",
  12499. uploadimageConfig: {
  12500. backend: "basic",
  12501. settings: {
  12502. uploadUrl:
  12503. options.templateOptions.APIService.upload().getRequestedUrl(),
  12504. headers: "",
  12505. downloadUrl:
  12506. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12507. },
  12508. },
  12509. refresh: function (APIService, contentId, data) {
  12510. return APIService.fetchDataList(contentId, data);
  12511. },
  12512. downloadUri: function (APIService, contentId) {
  12513. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12514. },
  12515. upload: function (APIService, contentId) {
  12516. return APIService.getSolutionDowpath(contentId);
  12517. },
  12518. view: function (attachmentId) {
  12519. // return APIService.attachmentsPreviewUrl(contentId);
  12520. },
  12521. refreshDelay: 0,
  12522. transform: function (model, value) {
  12523. return value;
  12524. },
  12525. },
  12526. validation: {
  12527. messages: {
  12528. maxlength: function (viewValue, modelValue, scope) {
  12529. if (viewValue != null) {
  12530. if (viewValue.length > scope.to.maxlength) {
  12531. return (
  12532. scope.to.label +
  12533. " 字数(" +
  12534. viewValue.length +
  12535. ")超限(" +
  12536. scope.to.maxlength +
  12537. ")"
  12538. );
  12539. } else {
  12540. return "";
  12541. }
  12542. }
  12543. },
  12544. },
  12545. },
  12546. };
  12547. },
  12548. controller: [
  12549. "$scope",
  12550. "$rootScope",
  12551. function ($scope, $rootScope) {
  12552. var value = $scope.model[$scope.options.key];
  12553. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12554. $scope.model[$scope.options.key] =
  12555. $scope.options.templateOptions.transform(
  12556. $scope.originalModel,
  12557. value
  12558. );
  12559. }
  12560. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12561. $rootScope.getSession();
  12562. //var expiry={'expiry':14804244006};
  12563. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12564. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12565. $scope.upload = function (contentId, filename) {
  12566. var filename = filename;
  12567. $scope.options.templateOptions
  12568. .upload($scope.options.templateOptions.ApiService, contentId)
  12569. .then(function (response) {
  12570. var file = new Blob([response], {
  12571. type: "application/octet-stream",
  12572. });
  12573. // var filename = filename;
  12574. var fileURL = URL.createObjectURL(file);
  12575. var a = document.createElement("a");
  12576. a.href = fileURL;
  12577. a.target = "_blank";
  12578. a.download = filename;
  12579. document.body.appendChild(a);
  12580. a.click();
  12581. });
  12582. };
  12583. },
  12584. ],
  12585. });
  12586. //改动的组件 ckeditor封装后的附文本组件
  12587. formlyConfigProvider.setType({
  12588. name: "ui-fuwenben",
  12589. extends: "textarea",
  12590. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12591. defaultOptions: function (options) {
  12592. return {
  12593. templateOptions: {
  12594. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12595. extraPlugins: "uploadimage",
  12596. uploadimageConfig: {
  12597. backend: "basic",
  12598. settings: {
  12599. uploadUrl:
  12600. options.templateOptions.APIService.upload(
  12601. -110
  12602. ).getRequestedUrl(),
  12603. headers: "",
  12604. downloadUrl:
  12605. options.templateOptions.APIService.uploadResponseUri(),
  12606. },
  12607. },
  12608. refresh: function (APIService, contentId, data) {
  12609. return APIService.fetchDataList(-110, data);
  12610. },
  12611. downloadUri: function (APIService, contentId) {
  12612. return APIService.downloadAttachment(-110).getRequestedUrl();
  12613. },
  12614. upload: function (APIService, contentId) {
  12615. return APIService.getSolutionDowpath(-110);
  12616. },
  12617. view: function (attachmentId) {
  12618. // return APIService.attachmentsPreviewUrl(contentId);
  12619. },
  12620. refreshDelay: 0,
  12621. transform: function (model, value) {
  12622. return value;
  12623. },
  12624. },
  12625. validation: {
  12626. messages: {
  12627. maxlength: function (viewValue, modelValue, scope) {
  12628. if (viewValue != null) {
  12629. if (viewValue.length > scope.to.maxlength) {
  12630. return (
  12631. scope.to.label +
  12632. " 字数(" +
  12633. viewValue.length +
  12634. ")超限(" +
  12635. scope.to.maxlength +
  12636. ")"
  12637. );
  12638. } else {
  12639. return "";
  12640. }
  12641. }
  12642. },
  12643. },
  12644. },
  12645. };
  12646. },
  12647. controller: [
  12648. "$scope",
  12649. "$rootScope",
  12650. function ($scope, $rootScope) {
  12651. var value = $scope.model[$scope.options.key];
  12652. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12653. $scope.model[$scope.options.key] =
  12654. $scope.options.templateOptions.transform(
  12655. $scope.originalModel,
  12656. value
  12657. );
  12658. }
  12659. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12660. $rootScope.getSession();
  12661. //var expiry={'expiry':14804244006};
  12662. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12663. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12664. $scope.upload = function (contentId, filename) {
  12665. var filename = filename;
  12666. $scope.options.templateOptions
  12667. .upload($scope.options.templateOptions.ApiService, -110)
  12668. .then(function (response) {
  12669. var file = new Blob([response], {
  12670. type: "application/octet-stream",
  12671. });
  12672. // var filename = filename;
  12673. var fileURL = URL.createObjectURL(file);
  12674. var a = document.createElement("a");
  12675. a.href = fileURL;
  12676. a.target = "_blank";
  12677. a.download = filename;
  12678. document.body.appendChild(a);
  12679. a.click();
  12680. });
  12681. };
  12682. },
  12683. ],
  12684. });
  12685. //ui-grid展示控件
  12686. formlyConfigProvider.setType({
  12687. name: "ui-grid-show",
  12688. extends: "multiCheckbox",
  12689. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12690. defaultOptions: function (options,scope) {
  12691. return {
  12692. templateOptions: {
  12693. linkage: function () { },
  12694. getScope: function () {
  12695. return scope;
  12696. },
  12697. },
  12698. };
  12699. },
  12700. controller: function (
  12701. $scope,
  12702. $rootScope,
  12703. i18nService,
  12704. Restangular,
  12705. api_bpm_data
  12706. ) {
  12707. var loginUser = $rootScope.user;
  12708. $scope.langs = i18nService.getAllLangs();
  12709. $scope.lang = "zh-cn";
  12710. i18nService.setCurrentLang($scope.lang);
  12711. $scope.gridOptions = {};
  12712. $scope.gridOptions.data = "myData";
  12713. $scope.gridOptions.enableColumnResizing = true;
  12714. // $scope.gridOptions.enableFiltering = true;
  12715. $scope.gridOptions.enableGridMenu = false;
  12716. $scope.gridOptions.enableRowSelection = true;
  12717. $scope.gridOptions.showGridFooter = true;
  12718. $scope.gridOptions.showColumnFooter = false;
  12719. $scope.gridOptions.fastWatch = true;
  12720. $scope.gridOptions.useExternalFiltering = true;
  12721. $scope.gridOptions.useExternalPagination = true;
  12722. $scope.gridOptions.paginationPageSizes = [10];
  12723. $scope.gridOptions.paginationPageSize = 10;
  12724. $scope.gridOptions.multiSelect = true;
  12725. $scope.gridOptions.rowIdentity = function (row) {
  12726. return row.id;
  12727. };
  12728. $scope.gridOptions.getRowIdentity = function (row) {
  12729. return row.id;
  12730. };
  12731. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12732. $scope.gridOptions.columnDefs = [
  12733. // { name:'id', width:80, enableFiltering:false},
  12734. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12735. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12736. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12737. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12738. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12739. {
  12740. name: "inspection.title",
  12741. displayName: "计划主题",
  12742. width: 120,
  12743. enableFiltering: false,
  12744. },
  12745. {
  12746. name: "sign",
  12747. displayName: "单号",
  12748. width: 140,
  12749. enableFiltering: false,
  12750. },
  12751. {
  12752. name: "inspectionType.type",
  12753. displayName: "巡检分类",
  12754. width: 200,
  12755. enableFiltering: false,
  12756. cellTemplate: '<div>' +
  12757. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  12758. '</div>'
  12759. },
  12760. {
  12761. name: "stateName",
  12762. displayName: "状态",
  12763. width: 80,
  12764. enableFiltering: false,
  12765. },
  12766. {
  12767. name: "processUser.name",
  12768. displayName: "处理人/组",
  12769. width: 120,
  12770. enableFiltering: false,
  12771. cellTemplate: '<div>' +
  12772. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  12773. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  12774. '</div>'
  12775. },
  12776. {
  12777. name: "startDate",
  12778. displayName: "开始时间",
  12779. width: 160,
  12780. enableFiltering: false,
  12781. },
  12782. {
  12783. name: "endTime",
  12784. displayName: "结束时间",
  12785. width: 160,
  12786. enableFiltering: false,
  12787. cellTemplate: '<div>' +
  12788. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  12789. '</div>'
  12790. },
  12791. // {
  12792. // name: "batchNo",
  12793. // displayName: "批次号",
  12794. // width: 160,
  12795. // enableFiltering: false,
  12796. // },
  12797. ];
  12798. var defaultFilterData = {
  12799. idx: 0,
  12800. sum: 10,
  12801. };
  12802. $scope.transferTime = function (time) {
  12803. return moment(time).format("YYYY-MM-DD HH:mm");
  12804. };
  12805. //分页控制
  12806. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12807. gridApi.pagination.on.paginationChanged(
  12808. $scope,
  12809. function (newPage, pageSize) {
  12810. var filtersData = $scope.memoryfilterData;
  12811. filtersData.idx = newPage - 1;
  12812. filtersData.sum = pageSize;
  12813. $scope.refreshData("expand-right", filtersData);
  12814. }
  12815. );
  12816. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12817. data.grid.appScope.selected.items = data.entity;
  12818. });
  12819. };
  12820. $scope.s_totalNum = 0;//总数
  12821. $scope.s_completeNum = 0;//已完成数
  12822. $scope.s_completeNum_online = 0;//线上已完成数
  12823. $scope.s_completeNum_offline = 0;//线下已完成数
  12824. $scope.s_completeNum_online_total = 0;//线上总数
  12825. $scope.s_completeNum_offline_total = 0;//线下总数
  12826. //页面获取数据 liaomingming
  12827. $scope.refreshData = function (style, filterData) {
  12828. // $scope.ldloading[style.replace('-', '_')] = true;
  12829. console.log(angular.isUndefined(filterData))
  12830. if (angular.isUndefined(filterData)) {
  12831. filterData = defaultFilterData;
  12832. }
  12833. $scope.myData = [];
  12834. console.log(filterData)
  12835. // var params = angular.copy(filterData.inspectionProcessActual);
  12836. filterData.inspectionProcessActual = {
  12837. inspectionid: $scope.model.id
  12838. }
  12839. if($scope.model && $scope.model.searchParams_batchNos !== '0'){
  12840. filterData.inspectionProcessActual.batchNo = $scope.model.searchParams_batchNos;
  12841. }
  12842. if($scope.model && $scope.model.searchParams_online !== '0'){
  12843. filterData.inspectionProcessActual.online = $scope.model.searchParams_online == 1;
  12844. }
  12845. if($scope.model && $scope.model.searchParams_state !== '0'){
  12846. filterData.inspectionProcessActual.state = $scope.model.searchParams_state == 1 ? 0 : 1;
  12847. }
  12848. console.log(filterData)
  12849. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  12850. function (data) {
  12851. var myData = Restangular.stripRestangular(data);
  12852. $scope.gridOptions.totalItems = myData.totalNum;
  12853. if(filterData.sum == 9999){
  12854. $scope.s_totalNum = myData.list.length;//总数
  12855. $scope.s_completeNum = myData.list.filter(v=>v.state === 1).length;//已完成数
  12856. $scope.s_completeNum_online_total = myData.list.filter(v=>v.online).length;//线上总数
  12857. $scope.s_completeNum_offline_total = myData.list.filter(v=>!v.online).length;//线下总数
  12858. $scope.s_completeNum_online = myData.list.filter(v=>v.online).filter(v=>v.state === 1).length;//线上已完成数
  12859. $scope.s_completeNum_offline = myData.list.filter(v=>!v.online).filter(v=>v.state === 1).length;//线下已完成数
  12860. return;
  12861. }
  12862. $scope.myData = myData.list;
  12863. $scope.memoryfilterData = filterData;
  12864. for (var i = 0; i < $scope.myData.length; i++) {
  12865. //添加序号
  12866. $scope.myData[i]["item"] =
  12867. i + 1 + filterData.idx * filterData.sum;
  12868. }
  12869. // $scope.ldloading[style.replace('-', '_')] = false;
  12870. },
  12871. function () {
  12872. // $scope.ldloading[style.replace('-', '_')] = false;
  12873. }
  12874. );
  12875. };
  12876. $scope.refreshData("expand-right", {
  12877. idx: 0,
  12878. sum: 9999,
  12879. });
  12880. $scope.refreshData("expand-right", defaultFilterData);
  12881. },
  12882. });
  12883. //文本框自定义选择面板组件
  12884. formlyConfigProvider.setType({
  12885. name: "ui-input-selectmodal",
  12886. extends: "input",
  12887. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  12888. defaultOptions: function (options) {
  12889. return {
  12890. templateOptions: {
  12891. openModal: function (size, options, modal) {
  12892. var modalInstance = modal.open({
  12893. templateUrl: "assets/views/customform/tpl/modal-content.html",
  12894. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  12895. size: size,
  12896. resolve: options.templateOptions.modalParam,
  12897. });
  12898. modalInstance.result.then(
  12899. function (selectedItem) {
  12900. options.value(selectedItem);
  12901. },
  12902. function () {
  12903. //console.log('Modal dismissed at: ' + new Date());
  12904. }
  12905. );
  12906. },
  12907. },
  12908. };
  12909. },
  12910. });
  12911. //日期控件
  12912. var datepicker_attr = [
  12913. "date-disabled",
  12914. "custom-class",
  12915. "show-weeks",
  12916. "starting-day",
  12917. "init-date",
  12918. "min-mode",
  12919. "max-mode",
  12920. "format-day",
  12921. "format-month",
  12922. "format-year",
  12923. "format-day-header",
  12924. "format-day-title",
  12925. "format-month-title",
  12926. "year-range",
  12927. "shortcut-propagation",
  12928. "datepicker-popup",
  12929. "show-button-bar",
  12930. "current-text",
  12931. "clear-text",
  12932. "close-text",
  12933. "close-on-date-selection",
  12934. "datepicker-append-to-body",
  12935. ];
  12936. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  12937. formlyConfigProvider.setType({
  12938. name: "ui-datetime",
  12939. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  12940. extends: "input",
  12941. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12942. defaultOptions: {
  12943. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12944. templateOptions: {
  12945. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12946. },
  12947. },
  12948. controller: [
  12949. "$scope",
  12950. "$filter",
  12951. function ($scope, $filter) {
  12952. $scope.model[$scope.options.key] = $filter("date")(
  12953. new Date(),
  12954. $scope.options.templateOptions.datepickerPopup
  12955. );
  12956. $scope.options.initialValue = $scope.model[$scope.options.key];
  12957. },
  12958. ],
  12959. });
  12960. //日期控件
  12961. formlyConfigProvider.setType({
  12962. name: "ui-datepicker",
  12963. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  12964. extends: "input",
  12965. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12966. defaultOptions: {
  12967. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12968. templateOptions: {
  12969. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12970. },
  12971. },
  12972. controller: [
  12973. "$scope",
  12974. "$filter",
  12975. function ($scope, $filter) {
  12976. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  12977. if ($scope.model[$scope.options.key]) {
  12978. } else {
  12979. $scope.model[$scope.options.key] = $filter("date")(
  12980. new Date(),
  12981. $scope.options.templateOptions.datepickerPopup
  12982. );
  12983. }
  12984. $scope.options.initialValue = $scope.model[$scope.options.key];
  12985. $scope.endOpen = true;
  12986. $scope.datepicker = {};
  12987. $scope.datepicker.opened = false;
  12988. $scope.datepicker.open = function ($event) {
  12989. $scope.datepicker.opened = true;
  12990. };
  12991. },
  12992. ],
  12993. });
  12994. //时分控件
  12995. formlyConfigProvider.setType({
  12996. name: "ui-datehourtime",
  12997. extends: "input",
  12998. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  12999. defaultOptions: function (options) {
  13000. return {
  13001. noFormControl: true,
  13002. // validators:{
  13003. // required:{
  13004. // expression:function(viewValue, modelValue){
  13005. // console.log(options)
  13006. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  13007. // // var value = modelValue.getHours() || viewValue.getHours();
  13008. // return value.length>=1;
  13009. // }
  13010. // }
  13011. // }
  13012. };
  13013. },
  13014. controller: [
  13015. "$scope",
  13016. "$log",
  13017. function ($scope, $log) {
  13018. $scope.hstep = new Date(
  13019. Date.parse($scope.model[$scope.options.key])
  13020. ).getHours();
  13021. $scope.minutes = new Date(
  13022. Date.parse($scope.model[$scope.options.key])
  13023. ).getMinutes();
  13024. $scope.model[$scope.options.key] = new Date(
  13025. Date.parse($scope.model[$scope.options.key])
  13026. );
  13027. },
  13028. ],
  13029. });
  13030. //状态追踪
  13031. formlyConfigProvider.setType({
  13032. name: "ui-followStatus",
  13033. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  13034. controller: [
  13035. "$scope",
  13036. "api_bpm_data",
  13037. "Restangular",
  13038. function ($scope, api_bpm_data, Restangular) {
  13039. setTimeout(function () {
  13040. var pkey = $scope.options.templateOptions.pkey;
  13041. var dataId = $scope.model.id;
  13042. if (dataId) {
  13043. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13044. if (response) {
  13045. var myData = Restangular.stripRestangular(response);
  13046. var processInstanceId = myData.data.processInstanceId;
  13047. $scope.options.templateOptions
  13048. .getData(
  13049. $scope.model,
  13050. $scope.options.templateOptions.ApiService,
  13051. processInstanceId
  13052. )
  13053. .then(function (result) {
  13054. if (result.status == 200) {
  13055. var newData = Restangular.stripRestangular(result);
  13056. $scope.followData = newData.data;
  13057. }
  13058. });
  13059. }
  13060. });
  13061. }
  13062. }, 10);
  13063. },
  13064. ],
  13065. });
  13066. //处理日志
  13067. formlyConfigProvider.setType({
  13068. name: "ui-handlerLog",
  13069. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  13070. controller: [
  13071. "$scope",
  13072. "api_bpm_data",
  13073. "Restangular",
  13074. function ($scope, api_bpm_data, Restangular) {
  13075. console.log($scope, 'ui-handlerLog')
  13076. },
  13077. ],
  13078. });
  13079. //资产
  13080. formlyConfigProvider.setType({
  13081. name: "ui-zc",
  13082. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  13083. controller: [
  13084. "$scope",
  13085. "api_bpm_data",
  13086. "Restangular",
  13087. function ($scope, api_bpm_data, Restangular) {
  13088. console.log($scope, 'ui-zc');
  13089. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13090. },
  13091. ],
  13092. });
  13093. //绑定的耗材
  13094. formlyConfigProvider.setType({
  13095. name: "ui-hc",
  13096. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  13097. controller: [
  13098. "$scope",
  13099. "api_cmdb2",
  13100. "Restangular",
  13101. function ($scope, api_cmdb2, Restangular) {
  13102. console.log($scope, 'ui-hc')
  13103. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  13104. $scope.list = [];
  13105. var sjId = $scope.model.incident.id;
  13106. api_cmdb2.getHc(sjId).then(function (response) {
  13107. console.log(response)
  13108. if (response.status == 200) {
  13109. $scope.list = response.data;
  13110. }
  13111. })
  13112. },
  13113. ],
  13114. });
  13115. //历史记录
  13116. formlyConfigProvider.setType({
  13117. name: "ui-history",
  13118. templateUrl: "assets/views/customform/tpl/ui-history.html",
  13119. controller: [
  13120. "$scope",
  13121. "api_bpm_data",
  13122. "Restangular",
  13123. function ($scope, api_bpm_data, Restangular) {
  13124. setTimeout(function () {
  13125. var pkey = $scope.options.templateOptions.pkey;
  13126. var dataId = $scope.model.id;
  13127. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13128. if (response) {
  13129. var myData = Restangular.stripRestangular(response);
  13130. var processInstanceId = myData.data.processInstanceId;
  13131. $scope.options.templateOptions
  13132. .getData(
  13133. $scope.model,
  13134. $scope.options.templateOptions.ApiService,
  13135. processInstanceId
  13136. )
  13137. .then(function (result) {
  13138. if (result.status == 200) {
  13139. var newData = Restangular.stripRestangular(result);
  13140. var long = newData.data.length - 1;
  13141. $scope.followData = newData.data[long];
  13142. }
  13143. });
  13144. }
  13145. });
  13146. }, 10);
  13147. },
  13148. ],
  13149. });
  13150. // //请求人信息显示
  13151. // formlyConfigProvider.setType({
  13152. // name: "ui-disrequester",
  13153. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  13154. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13155. // defaultOptions: function(options) {
  13156. // return {
  13157. // templateOptions: {}
  13158. // };
  13159. // },
  13160. // controller: ['$scope', function($scope) {
  13161. // $scope.options.templateOptions.that = $scope;
  13162. // }]
  13163. // });
  13164. //退回人信息显示
  13165. formlyConfigProvider.setType({
  13166. name: "ui-returnperson",
  13167. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  13168. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13169. defaultOptions: function (options) {
  13170. return {
  13171. templateOptions: {},
  13172. };
  13173. },
  13174. controller: [
  13175. "$scope",
  13176. function ($scope) {
  13177. $scope.group = "";
  13178. $scope.role = "";
  13179. if (
  13180. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13181. $scope.model.handlingPersonnelUser.group.length == 1
  13182. ) {
  13183. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13184. } else {
  13185. for (
  13186. var i = 0;
  13187. i < $scope.model.handlingPersonnelUser.group.length;
  13188. i++
  13189. ) {
  13190. $scope.group +=
  13191. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13192. }
  13193. }
  13194. if (
  13195. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13196. $scope.model.handlingPersonnelUser.role.length == 1
  13197. ) {
  13198. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13199. } else {
  13200. for (
  13201. var i = 0;
  13202. i < $scope.model.handlingPersonnelUser.role.length;
  13203. i++
  13204. ) {
  13205. $scope.role +=
  13206. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13207. }
  13208. }
  13209. $scope.options.templateOptions.that = $scope;
  13210. $scope.options.templateOptions.that = $scope;
  13211. },
  13212. ],
  13213. });
  13214. //退回人信息显示(去掉工作组&角色)
  13215. formlyConfigProvider.setType({
  13216. name: "ui-returnpersonNoGroup",
  13217. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  13218. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13219. defaultOptions: function (options) {
  13220. return {
  13221. templateOptions: {},
  13222. };
  13223. },
  13224. controller: [
  13225. "$scope",
  13226. function ($scope) {
  13227. $scope.group = "";
  13228. $scope.role = "";
  13229. if (
  13230. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13231. $scope.model.handlingPersonnelUser.group.length == 1
  13232. ) {
  13233. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13234. } else {
  13235. for (
  13236. var i = 0;
  13237. i < $scope.model.handlingPersonnelUser.group.length;
  13238. i++
  13239. ) {
  13240. $scope.group +=
  13241. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13242. }
  13243. }
  13244. if (
  13245. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13246. $scope.model.handlingPersonnelUser.role.length == 1
  13247. ) {
  13248. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13249. } else {
  13250. for (
  13251. var i = 0;
  13252. i < $scope.model.handlingPersonnelUser.role.length;
  13253. i++
  13254. ) {
  13255. $scope.role +=
  13256. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13257. }
  13258. }
  13259. $scope.options.templateOptions.that = $scope;
  13260. $scope.options.templateOptions.that = $scope;
  13261. },
  13262. ],
  13263. });
  13264. //指派技术人员
  13265. formlyConfigProvider.setType({
  13266. name: "ui-apiontperson",
  13267. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  13268. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13269. defaultOptions: function (options) {
  13270. return {
  13271. templateOptions: {
  13272. transtlara: function (value, $scope) { },
  13273. },
  13274. };
  13275. },
  13276. controller: [
  13277. "$scope",
  13278. "api_user_data",
  13279. "Restangular",
  13280. function ($scope, api_user_data, Restangular) {
  13281. var filterData = {
  13282. idx: 0,
  13283. sum: 1000,
  13284. };
  13285. api_user_data
  13286. .fetchDataList("group", filterData)
  13287. .then(function (response) {
  13288. if (response.status == 200) {
  13289. $scope.select = {};
  13290. $scope.multipleDemo = {};
  13291. $scope.userdata = {};
  13292. var data = response.list;
  13293. var item = [];
  13294. $scope.multipleDemo = data;
  13295. $scope.multipleDemo;
  13296. }
  13297. });
  13298. $scope.options.templateOptions.onChange = function (
  13299. id,
  13300. options,
  13301. groupdata,
  13302. $event,
  13303. model
  13304. ) {
  13305. if (groupdata.option) {
  13306. $scope.model[$scope.options.key] = {};
  13307. var fildate = {
  13308. idx: 0,
  13309. sum: 1000,
  13310. user: {
  13311. roledata: {
  13312. rolecode: model.currentRole,
  13313. },
  13314. selectType: "1",
  13315. groupdata: {
  13316. id: groupdata.option.id,
  13317. },
  13318. },
  13319. };
  13320. api_user_data
  13321. .fetchDataList("user", fildate)
  13322. .then(function (response) {
  13323. if (response.status == 200) {
  13324. $scope.userdata = {};
  13325. $scope.userdata = response.list;
  13326. }
  13327. });
  13328. } else {
  13329. $scope.model[$scope.options.key] = {
  13330. id: groupdata.id.id,
  13331. };
  13332. $scope.options.templateOptions.transtlara(
  13333. $scope.model[$scope.options.key],
  13334. $scope
  13335. );
  13336. }
  13337. };
  13338. // }
  13339. },
  13340. ],
  13341. });
  13342. //请求科室信息(小蓝框) lmm
  13343. formlyConfigProvider.setType({
  13344. name: "ui-deptinformation",
  13345. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13346. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13347. return {
  13348. templateOptions: {
  13349. checkform: function (options) { },
  13350. },
  13351. };
  13352. },
  13353. controller: [
  13354. "$scope",
  13355. "api_statistic",
  13356. function ($scope, api_statistic) {
  13357. // console.log($scope)
  13358. },
  13359. ],
  13360. });
  13361. //请求人信息
  13362. formlyConfigProvider.setType({
  13363. name: "ui-requesterinformation",
  13364. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13365. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13366. return {
  13367. templateOptions: {
  13368. checkform: function (options) {
  13369. if (options.model.requester) {
  13370. options.value(options.model.requester);
  13371. }
  13372. },
  13373. addRequeter: function (size, options, modal, e) {
  13374. if (e) {
  13375. if (e.clientX === 0) {
  13376. return;
  13377. }
  13378. e.preventDefault();
  13379. }
  13380. var modalInstance = modal.open({
  13381. templateUrl:
  13382. "assets/views/customform/tpl/modal-add-callrequester.html",
  13383. controller: function (
  13384. $scope,
  13385. sco,
  13386. $rootScope,
  13387. $modalInstance,
  13388. items,
  13389. SweetAlert,
  13390. title,
  13391. Restangular,
  13392. APIService,
  13393. UserService,
  13394. api_user_data,
  13395. api_statistic,
  13396. api_wechatfile,
  13397. $stateParams
  13398. ) {
  13399. $modalInstance.SweetAlert = SweetAlert;
  13400. $scope.title = "新增报修人";
  13401. $scope.requester = {};
  13402. $scope.searchData = {};
  13403. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13404. var paramsModel = JSON.parse($stateParams.model)
  13405. //来电-添加报修人-回显电话
  13406. if (paramsModel.model.incident.requester.hjzxPhone) {
  13407. $scope.requester.mphone = paramsModel.model.incident.requester.hjzxPhone;
  13408. }
  13409. }
  13410. $scope.onChangeadd = function (searchData) {
  13411. $scope.searchKey = searchData.account;
  13412. // $scope.searchDataadd = searchData;
  13413. var requesdata = angular.copy(searchData);
  13414. if (requesdata.mphone) {
  13415. delete requesdata.mphone;
  13416. }
  13417. $scope.requester = requesdata;
  13418. console.log($scope.requester);
  13419. };
  13420. $scope.refreshUseradd = function (searchKey) {
  13421. //请求人搜索
  13422. $scope.requester.account = searchKey;
  13423. $scope.searchData = searchKey;
  13424. serchdataadd(searchKey);
  13425. };
  13426. $scope.getMydata = function (x) {
  13427. $scope.searchField = JSON.parse(x[0]).account;
  13428. $scope.requester = JSON.parse(x[0]);
  13429. console.log($scope.requester);
  13430. };
  13431. $scope.getMydataone = function (x) {
  13432. $scope.searchField = x;
  13433. $scope.requester.account = x;
  13434. };
  13435. serchdataadd();
  13436. api_wechatfile
  13437. .getDictionary({
  13438. type: "list",
  13439. key: "male",
  13440. })
  13441. .then(function (data) {
  13442. if (data.status == 200) {
  13443. requester.gender = data.list;
  13444. }
  13445. });
  13446. function serchdataadd(searchKey) {
  13447. if (searchKey) {
  13448. var filterData = {
  13449. requester: {
  13450. searchKey: searchKey,
  13451. },
  13452. idx: 0,
  13453. sum: 10,
  13454. };
  13455. } else {
  13456. var filterData = {
  13457. idx: 0,
  13458. sum: 10,
  13459. };
  13460. }
  13461. api_user_data
  13462. .fetchDataList("requester", filterData)
  13463. .then(function (response) {
  13464. var myData = response;
  13465. $scope.myData = myData.list;
  13466. });
  13467. }
  13468. api_user_data
  13469. .fetchDataList("area", {
  13470. idx: 0,
  13471. sum: 1000,
  13472. })
  13473. .then(function (response) {
  13474. if (response.status == 200) {
  13475. $scope.areas = response.list;
  13476. }
  13477. });
  13478. api_wechatfile
  13479. .getDictionary(
  13480. {
  13481. key: "requester_type",
  13482. type: "list",
  13483. },
  13484. {
  13485. idx: 0,
  13486. sum: 100,
  13487. }
  13488. )
  13489. .then(function (response) {
  13490. if (response) {
  13491. $scope.networktypes = response;
  13492. }
  13493. });
  13494. $scope.requesterAreaid = "";
  13495. $scope.onChange = function (item) {
  13496. $scope.requesterAreaid = item.id;
  13497. api_user_data
  13498. .fetchDataList("place", {
  13499. place: {
  13500. area: {
  13501. id: item.id,
  13502. },
  13503. },
  13504. idx: 0,
  13505. sum: 1000,
  13506. })
  13507. .then(function (response) {
  13508. if (response.status == 200) {
  13509. $scope.places = response.list;
  13510. delete $scope.requester.placeDTO;
  13511. }
  13512. });
  13513. };
  13514. $scope.refresh = function (searchVal) {
  13515. var faildata = {};
  13516. if ($scope.requesterAreaid) {
  13517. faildata = {
  13518. idx: 0,
  13519. sum: 1000,
  13520. place: {
  13521. areaId: $scope.requesterAreaid,
  13522. place: searchVal,
  13523. selectType: "pinyin_qs",
  13524. },
  13525. };
  13526. } else {
  13527. faildata = {
  13528. idx: 0,
  13529. sum: 1000,
  13530. place: {
  13531. place: searchVal,
  13532. selectType: "pinyin_qs",
  13533. },
  13534. };
  13535. }
  13536. api_user_data
  13537. .fetchDataList("place", faildata)
  13538. .then(function (response) {
  13539. $scope.places = response.list;
  13540. delete $scope.requester.placeDTO;
  13541. });
  13542. };
  13543. $scope.refreshDepts = function (key) {
  13544. var filterData = {
  13545. idx: 0,
  13546. sum: 5,
  13547. dept: {
  13548. name: key,
  13549. },
  13550. };
  13551. UserService.fetchDataList("department", filterData).then(
  13552. function (response) {
  13553. if (response.status == 200) {
  13554. $scope.depts = response.list;
  13555. }
  13556. }
  13557. );
  13558. };
  13559. $scope.ok = function () {
  13560. if (
  13561. angular.isUndefined($scope.requester.account) ||
  13562. $scope.requester.account == null ||
  13563. $scope.requester.account == ""
  13564. ) {
  13565. SweetAlert.swal(
  13566. "报修人员编号未填!",
  13567. "请填写报修人员编号",
  13568. "error"
  13569. );
  13570. } else if (
  13571. angular.isUndefined($scope.requester.name) ||
  13572. $scope.requester.name == null ||
  13573. $scope.requester.name == ""
  13574. ) {
  13575. SweetAlert.swal(
  13576. "报修人姓名未填!",
  13577. "请填写报修人姓名",
  13578. "error"
  13579. );
  13580. } else if (
  13581. angular.isUndefined($scope.requester.requesterType) ||
  13582. $scope.requester.requesterType == null ||
  13583. $scope.requester.requesterTypeDTO == ""
  13584. ) {
  13585. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13586. } else if (
  13587. angular.isUndefined($scope.requester.mphone) ||
  13588. $scope.requester.mphone == null ||
  13589. $scope.requester.mphone == ""
  13590. ) {
  13591. SweetAlert.swal(
  13592. "报修人联系电话未填!",
  13593. "请填写报修人联系电话",
  13594. "error"
  13595. );
  13596. } else {
  13597. $scope.requesterId = $scope.requester.id;
  13598. var data = {
  13599. incident: {
  13600. requester: {
  13601. id: $scope.requesterId,
  13602. },
  13603. },
  13604. idx: 0,
  13605. sum: 3,
  13606. };
  13607. api_statistic
  13608. .tableData(data, "incident")
  13609. .then(function (data) {
  13610. sco.$parent.$parent.$parent.model.incident.tableList =
  13611. data.list;
  13612. });
  13613. $scope.$watch(
  13614. sco.$parent.$parent.$parent.model.incident.tableList,
  13615. function (oldObj, newObj) {
  13616. if (newObj != oldObj) {
  13617. sco.$parent.$parent.$parent.model.incident.tableList =
  13618. newObj;
  13619. }
  13620. }
  13621. ); //lmm
  13622. console.log($scope.requester);
  13623. $modalInstance.close($scope.requester);
  13624. }
  13625. };
  13626. $scope.cancel = function () {
  13627. $modalInstance.dismiss("cancel");
  13628. };
  13629. },
  13630. resolve: {
  13631. items: function () {
  13632. return {
  13633. fetchItems: function (filterData, APIService) {
  13634. filterData = filterData || {};
  13635. if (!filterData.idx) {
  13636. filterData = {
  13637. idx: 0,
  13638. sum: 10,
  13639. };
  13640. }
  13641. return options.templateOptions.fetchItems(
  13642. filterData,
  13643. APIService
  13644. );
  13645. },
  13646. };
  13647. },
  13648. title: function () {
  13649. return options.templateOptions.modalTitle;
  13650. },
  13651. Restangular: function () {
  13652. return options.templateOptions.Restangular;
  13653. },
  13654. APIService: function () {
  13655. return options.templateOptions.ApiService;
  13656. },
  13657. UserService: function () {
  13658. return options.templateOptions.UserService;
  13659. },
  13660. sco: function () {
  13661. return $scope;
  13662. },
  13663. },
  13664. });
  13665. modalInstance.result.then(
  13666. function (selectedItem) {
  13667. console.log(selectedItem);
  13668. if (selectedItem) {
  13669. var data = {
  13670. requester: selectedItem,
  13671. };
  13672. $scope.searchKey = selectedItem.account;
  13673. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13674. // if (selectedItem.place && selectedItem.place.place) {
  13675. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13676. // }
  13677. options.templateOptions.UserService.addData(
  13678. "requester",
  13679. data
  13680. ).then(function (response) {
  13681. if (response.status == 200) {
  13682. if (options.model) {
  13683. options.model.requester = response.data;
  13684. $scope.$parent.$parent.$parent.model.incident.requester =
  13685. response.data;
  13686. $scope.$parent.$parent.$parent.model.requestershow =
  13687. response.data;
  13688. if (options.model.place) {
  13689. options.model.place.id = "";
  13690. }
  13691. if (options.model.area) {
  13692. options.model.area.id = "";
  13693. }
  13694. options.model.contacts = selectedItem.name;
  13695. if (
  13696. selectedItem.mphone &&
  13697. selectedItem.mphone != null &&
  13698. selectedItem.mphone != ""
  13699. ) {
  13700. options.model.contactsInformation =
  13701. selectedItem.mphone;
  13702. } else {
  13703. options.model.contactsInformation =
  13704. selectedItem.telephone;
  13705. }
  13706. if (
  13707. selectedItem.requesterTypeDTO &&
  13708. selectedItem.requesterTypeDTO.id == 2
  13709. ) {
  13710. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13711. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13712. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13713. }
  13714. }
  13715. if (!response.data.id) {
  13716. response.data.id = selectedItem.id;
  13717. }
  13718. options.value(response.data);
  13719. options.value(response.data);
  13720. console.log($scope, "0000000");
  13721. //新增报修人带入区域地点2020年4月23日19:48:15
  13722. $scope.model.selecthouseNumber = selectedItem.place
  13723. ? selectedItem.place
  13724. : {};
  13725. $scope.$root.selecthouseNumber = selectedItem.place
  13726. ? selectedItem.place
  13727. : {};
  13728. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13729. if (selectedItem.place && selectedItem.place.id) {
  13730. options.model.place.id = selectedItem.place.id;
  13731. options.model.place.area.id =
  13732. selectedItem.place.area.id;
  13733. }
  13734. } else {
  13735. if (selectedItem.place && selectedItem.place.id) {
  13736. options.model.place.id = selectedItem.place.id;
  13737. options.model.area.id = selectedItem.place.area.id;
  13738. }
  13739. }
  13740. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13741. // options.model.area.id = selectedItem.place.area.id
  13742. // }
  13743. if (selectedItem.houseNumber) {
  13744. options.model.houseNumber = selectedItem.houseNumber;
  13745. }
  13746. // if (selectedItem.id) {
  13747. options.model.account = selectedItem.account;
  13748. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  13749. var baoxiuFields =
  13750. $scope.$parent.$parent.$parent.$parent.$parent.vm
  13751. .fields[1].fields;
  13752. var baoxiurenTo;
  13753. baoxiuFields.forEach((e, i) => {
  13754. if (e.key == "account") {
  13755. baoxiurenTo = e.templateOptions;
  13756. baoxiurenTo.APIService.fetchDataList("requester", {
  13757. idx: 0,
  13758. sum: 20,
  13759. requester: {
  13760. searchKey: selectedItem.account,
  13761. },
  13762. }).then((res) => {
  13763. baoxiurenTo.options = res.list;
  13764. options.model.account = selectedItem.account;
  13765. });
  13766. }
  13767. });
  13768. // }
  13769. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  13770. // 选择重复事件侧滑框
  13771. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  13772. $scope.$parent.$parent.$parent.model[
  13773. "repeatIncidentShow"
  13774. ] = false;
  13775. setTimeout(() => {
  13776. $scope.$parent.$parent.$parent.model[
  13777. "repeatIncidentShow"
  13778. ] = true;
  13779. }, 500);
  13780. // }
  13781. } else {
  13782. modalInstance.SweetAlert.swal({
  13783. title: "系统错误",
  13784. text: "账号重复!",
  13785. type: "error",
  13786. });
  13787. }
  13788. });
  13789. }
  13790. },
  13791. function () { }
  13792. );
  13793. },
  13794. changeRequeter: function (
  13795. size,
  13796. options,
  13797. modal,
  13798. modeldata,
  13799. $rootScope
  13800. ) {
  13801. var modalInstance = modal.open({
  13802. templateUrl:
  13803. "assets/views/customform/tpl/modal-change-requester.html",
  13804. controller: function (
  13805. $scope,
  13806. $modalInstance,
  13807. items,
  13808. SweetAlert,
  13809. title,
  13810. Restangular,
  13811. APIService,
  13812. UserService,
  13813. api_user_data,
  13814. $rootScope
  13815. ) {
  13816. $scope.title = "修改报修人";
  13817. $scope.requester = {
  13818. id: modeldata.requester.id,
  13819. account: modeldata.requester.account,
  13820. name: modeldata.requester.name,
  13821. gender: modeldata.requester.gender,
  13822. email: modeldata.requester.email,
  13823. deptName: modeldata.requester.deptName,
  13824. mphone: modeldata.requester.mphone,
  13825. telephone: modeldata.requester.telephone,
  13826. studentNo: modeldata.requester.studentNo,
  13827. areaDTO: modeldata.requester.areaDTO,
  13828. placeDTO: modeldata.requester.placeDTO,
  13829. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  13830. };
  13831. $scope.onChangeadd = function (searchData) {
  13832. console.log(searchData);
  13833. $scope.searchKey = searchData.account;
  13834. var requesdata = angular.copy(searchData);
  13835. if (requesdata.mphone) {
  13836. delete requesdata.mphone;
  13837. }
  13838. $scope.requester = requesdata;
  13839. };
  13840. $scope.refreshUseradd = function (searchKey) {
  13841. //请求人搜索
  13842. $scope.requester.account = searchKey;
  13843. $scope.searchData = searchKey;
  13844. serchdataadd(searchKey);
  13845. };
  13846. $scope.getMydata = function (x) {
  13847. $scope.searchField = JSON.parse(x[0]).account;
  13848. $scope.requester = JSON.parse(x[0]);
  13849. };
  13850. $scope.getMydataone = function (x) {
  13851. $scope.searchField = x;
  13852. $scope.requester.account = x;
  13853. };
  13854. serchdataadd();
  13855. function serchdataadd(searchKey) {
  13856. if (searchKey) {
  13857. var filterData = {
  13858. requester: {
  13859. searchKey: searchKey,
  13860. },
  13861. idx: 0,
  13862. sum: 10,
  13863. };
  13864. } else {
  13865. var filterData = {
  13866. idx: 0,
  13867. sum: 10,
  13868. };
  13869. }
  13870. api_user_data
  13871. .fetchDataList("requester", filterData)
  13872. .then(function (response) {
  13873. var myData = response;
  13874. $scope.myData = myData.list;
  13875. });
  13876. }
  13877. api_user_data
  13878. .fetchDataList("area", {
  13879. idx: 0,
  13880. sum: 1000,
  13881. })
  13882. .then(function (response) {
  13883. if (response.status == 200) {
  13884. $scope.areas = response.list;
  13885. }
  13886. });
  13887. api_user_data
  13888. .fetchDataList("requesterType", {
  13889. idx: 0,
  13890. sum: 100,
  13891. })
  13892. .then(function (response) {
  13893. if (response.status == 200) {
  13894. $scope.networktypes = response.list;
  13895. }
  13896. });
  13897. if (
  13898. $scope.requester.areaDTO &&
  13899. $scope.requester.areaDTO.id &&
  13900. $scope.requester.areaDTO.id != ""
  13901. ) {
  13902. api_user_data
  13903. .fetchDataList("place", {
  13904. place: {
  13905. areaId: $scope.requester.areaDTO.id,
  13906. },
  13907. idx: 0,
  13908. sum: 1000,
  13909. })
  13910. .then(function (response) {
  13911. if (response.status == 200) {
  13912. $scope.places = response.list;
  13913. }
  13914. });
  13915. }
  13916. $scope.onChange = function (item) {
  13917. $scope.requester.placeDTO = {};
  13918. api_user_data
  13919. .fetchDataList("place", {
  13920. place: {
  13921. areaId: item.id,
  13922. },
  13923. idx: 0,
  13924. sum: 1000,
  13925. })
  13926. .then(function (response) {
  13927. if (response.status == 200) {
  13928. $scope.places = response.list;
  13929. }
  13930. });
  13931. };
  13932. $scope.refreshDepts = function (key) {
  13933. var filterData = {
  13934. idx: 0,
  13935. sum: 5,
  13936. dept: {
  13937. name: key,
  13938. },
  13939. };
  13940. UserService.fetchDataList("department", filterData).then(
  13941. function (response) {
  13942. if (response.status == 200) {
  13943. $scope.depts = response.list;
  13944. }
  13945. }
  13946. );
  13947. };
  13948. $scope.ok = function () {
  13949. if (
  13950. $scope.requester.account == "" ||
  13951. $scope.requester.name == ""
  13952. ) {
  13953. SweetAlert.swal(
  13954. "报修人姓名或人员编号号未填!",
  13955. "请补全报修人信息",
  13956. "error"
  13957. );
  13958. } else {
  13959. $modalInstance.close($scope.requester);
  13960. }
  13961. };
  13962. $scope.cancel = function () {
  13963. $modalInstance.dismiss("cancel");
  13964. };
  13965. },
  13966. resolve: {
  13967. items: function () {
  13968. return {
  13969. fetchItems: function (filterData, APIService) {
  13970. filterData = filterData || {};
  13971. if (!filterData.idx) {
  13972. filterData = {
  13973. idx: 0,
  13974. sum: 10,
  13975. };
  13976. }
  13977. return options.templateOptions.fetchItems(
  13978. filterData,
  13979. APIService
  13980. );
  13981. },
  13982. };
  13983. },
  13984. title: function () {
  13985. return options.templateOptions.modalTitle;
  13986. },
  13987. Restangular: function () {
  13988. return options.templateOptions.Restangular;
  13989. },
  13990. APIService: function () {
  13991. return options.templateOptions.ApiService;
  13992. },
  13993. UserService: function () {
  13994. return options.templateOptions.UserService;
  13995. },
  13996. },
  13997. });
  13998. modalInstance.result.then(
  13999. function (selectedItem) {
  14000. console.log(selectedItem);
  14001. if (selectedItem) {
  14002. if (options.model) {
  14003. if (options.model.place) {
  14004. options.model.place.id = "";
  14005. }
  14006. if (options.model.area) {
  14007. options.model.area.id = "";
  14008. }
  14009. options.model.contacts = selectedItem.name;
  14010. if (
  14011. selectedItem.mphone &&
  14012. selectedItem.mphone != null &&
  14013. selectedItem.mphone != ""
  14014. ) {
  14015. options.model.contactsInformation = selectedItem.mphone;
  14016. } else {
  14017. options.model.contactsInformation =
  14018. selectedItem.telephone;
  14019. }
  14020. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14021. options.model.place.id = selectedItem.placeDTO.id;
  14022. }
  14023. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14024. options.model.area.id = selectedItem.areaDTO.id;
  14025. }
  14026. if (
  14027. selectedItem.requesterTypeDTO &&
  14028. selectedItem.requesterTypeDTO.id == 2
  14029. ) {
  14030. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14031. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14032. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14033. }
  14034. }
  14035. var data = {
  14036. requester: selectedItem,
  14037. };
  14038. options.templateOptions.UserService.addData(
  14039. "requester",
  14040. data
  14041. ).then(function (response) {
  14042. if (response.status == 200) {
  14043. $scope.$parent.$parent.$parent.model["requestershow"] =
  14044. selectedItem;
  14045. options.value(response.data);
  14046. } else {
  14047. }
  14048. });
  14049. }
  14050. },
  14051. function () { }
  14052. );
  14053. event.preventDefault();
  14054. },
  14055. },
  14056. };
  14057. },
  14058. controller: [
  14059. "$scope",
  14060. "api_user_data",
  14061. "api_statistic",
  14062. "$stateParams",
  14063. function ($scope, api_user_data, api_statistic, $stateParams) {
  14064. console.log($stateParams)
  14065. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  14066. var paramsModel = JSON.parse($stateParams.model)
  14067. //来电-添加报修人
  14068. if (paramsModel.model.incident.requester.hjzxPhone) {
  14069. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  14070. }
  14071. }
  14072. $scope.options.initialValue = $scope.model[$scope.options.key];
  14073. $scope.saveReqPlace = false;
  14074. $scope.model.saveReqPlace = false;
  14075. $scope.selectGradeBox = function () {
  14076. $scope.saveReqPlace = !$scope.saveReqPlace;
  14077. console.log($scope);
  14078. $scope.model.saveReqPlace = $scope.saveReqPlace;
  14079. };
  14080. if (
  14081. $scope.model.requester &&
  14082. $scope.model.requester.requesterTypeDTO &&
  14083. $scope.model.requester.requesterTypeDTO.id == 2
  14084. ) {
  14085. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14086. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14087. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14088. }
  14089. },
  14090. ],
  14091. });
  14092. // 请求人选控件
  14093. formlyConfigProvider.setType({
  14094. name: "ui-requesterselect",
  14095. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  14096. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14097. defaultOptions: function (options, $scope) {
  14098. return {
  14099. templateOptions: {
  14100. // checkform: function(options) {
  14101. // if (options.model.requestershow) {
  14102. // options.value(options.model.requestershow);
  14103. // }
  14104. // },
  14105. validators: {
  14106. required: {
  14107. expression: function (viewValue, modelValue) {
  14108. var value = modelValue || viewValue;
  14109. return value.length >= 1;
  14110. },
  14111. },
  14112. },
  14113. openModal: function (size, options, modal) {
  14114. //查找弹出框
  14115. var modelObject = options.value();
  14116. var searchModal = function (filterSearchData) {
  14117. var modalInstance = modal.open({
  14118. templateUrl:
  14119. "assets/views/customform/tpl/checktable-modal-content.html",
  14120. controller: function (
  14121. $scope,
  14122. scope,
  14123. i18nService,
  14124. $modalInstance,
  14125. items,
  14126. title,
  14127. Restangular,
  14128. APIService,
  14129. language,
  14130. searchDatas,
  14131. api_bpm_data
  14132. ) {
  14133. $scope.langs = i18nService.getAllLangs();
  14134. $scope.lang = "zh-cn";
  14135. i18nService.setCurrentLang($scope.lang);
  14136. $scope.gridOptions = {};
  14137. $scope.gridOptions.data = "myData";
  14138. $scope.gridOptions.enableColumnResizing = true;
  14139. $scope.gridOptions.enableFiltering = true;
  14140. $scope.gridOptions.enableGridMenu = false;
  14141. $scope.gridOptions.enableRowSelection = true;
  14142. $scope.gridOptions.showGridFooter = true;
  14143. $scope.gridOptions.showColumnFooter = false;
  14144. $scope.gridOptions.fastWatch = true;
  14145. $scope.gridOptions.useExternalFiltering = true;
  14146. $scope.gridOptions.useExternalPagination = true;
  14147. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14148. $scope.gridOptions.paginationPageSize = 10;
  14149. $scope.gridOptions.multiSelect = false;
  14150. $scope.gridOptions.rowIdentity = function (row) {
  14151. return row.id;
  14152. };
  14153. $scope.gridOptions.getRowIdentity = function (row) {
  14154. return row.id;
  14155. };
  14156. $scope.gridOptions.columnDefs = [
  14157. {
  14158. name: "account",
  14159. displayName: "人员编号",
  14160. width: 140,
  14161. },
  14162. {
  14163. name: "name",
  14164. displayName: "姓名",
  14165. width: 100,
  14166. },
  14167. {
  14168. name: "gender.name",
  14169. displayName: "性别",
  14170. width: 80,
  14171. enableFiltering: false,
  14172. },
  14173. {
  14174. name: "mphone",
  14175. displayName: "电话",
  14176. width: 100,
  14177. enableFiltering: false,
  14178. },
  14179. {
  14180. name: "email",
  14181. displayName: "邮件",
  14182. width: 100,
  14183. },
  14184. {
  14185. name: "areaDTO.area",
  14186. displayName: "区域",
  14187. width: 100,
  14188. enableFiltering: false,
  14189. },
  14190. {
  14191. name: "placeDTO.place",
  14192. displayName: "地点",
  14193. enableFiltering: false,
  14194. },
  14195. ];
  14196. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14197. $scope.gridApi = gridApi;
  14198. // var filtersData = $scope.memoryfilterData;
  14199. // filtersData.idx = newPage - 1;
  14200. // filtersData.sum = pageSize;
  14201. gridApi.pagination.on.paginationChanged(
  14202. $scope,
  14203. function (newPage, pageSize) {
  14204. var filtersData = $scope.memoryfilterData;
  14205. filtersData.idx = newPage - 1;
  14206. filtersData.sum = pageSize;
  14207. $scope.loadData(filtersData);
  14208. }
  14209. );
  14210. gridApi.selection.on.rowSelectionChanged(
  14211. $scope,
  14212. function (data) {
  14213. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  14214. $scope.selected.item = data.entity;
  14215. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  14216. }
  14217. );
  14218. gridApi.core.on.filterChanged($scope, function () {
  14219. var grid = this.grid;
  14220. var filtersData = {
  14221. idx: 0,
  14222. sum: 10,
  14223. // 'requester': { 'userType': 1 }
  14224. };
  14225. angular.forEach(grid.columns, function (item) {
  14226. if (item.enableFiltering) {
  14227. if (
  14228. angular.isDefined(item.filters[0].term) &&
  14229. item.filters[0].term != ""
  14230. ) {
  14231. if (angular.isUndefined(filtersData["requester"])) {
  14232. filtersData["requester"] = {};
  14233. }
  14234. filtersData["requester"][item.field] =
  14235. item.filters[0].term;
  14236. }
  14237. }
  14238. });
  14239. $scope.memoryfilterData = filtersData;
  14240. $scope.loadData(filtersData);
  14241. });
  14242. };
  14243. $scope.memoryfilterData = defaultFilterData = {
  14244. idx: 0,
  14245. sum: 10,
  14246. };
  14247. $scope.loadData = function (filterData) {
  14248. if (!filterData.requester) {
  14249. filterData.requester = {};
  14250. }
  14251. if (scope.roleidcode) {
  14252. angular.extend(filterData["requester"], {
  14253. userType: 1,
  14254. });
  14255. }
  14256. items
  14257. .fetchItems(filterData, APIService)
  14258. .then(function (data) {
  14259. var myData = Restangular.stripRestangular(data);
  14260. $scope.gridOptions.totalItems = myData.totalNum;
  14261. $scope.myData = myData.list;
  14262. });
  14263. };
  14264. // $scope.title = title;
  14265. if (searchDatas) {
  14266. $scope.loadData(searchDatas);
  14267. } else {
  14268. $scope.loadData({
  14269. idx: 0,
  14270. sum: 10,
  14271. });
  14272. }
  14273. $scope.selected = {
  14274. item: {},
  14275. };
  14276. $scope.ok = function () {
  14277. $modalInstance.close($scope.selected.item);
  14278. };
  14279. $scope.cancel = function () {
  14280. $modalInstance.dismiss("cancel");
  14281. };
  14282. },
  14283. size: size,
  14284. resolve: {
  14285. items: function () {
  14286. return {
  14287. fetchItems: function (filterData, APIService) {
  14288. filterData = filterData || {};
  14289. if (
  14290. angular.isUndefined(filterData.idx) ||
  14291. filterData.idx == null
  14292. ) {
  14293. filterData = {
  14294. idx: 0,
  14295. sum: 10,
  14296. };
  14297. }
  14298. return options.templateOptions.fetchItems(
  14299. filterData,
  14300. APIService
  14301. );
  14302. },
  14303. };
  14304. },
  14305. title: function () {
  14306. return options.templateOptions.modalTitle;
  14307. },
  14308. Restangular: function () {
  14309. return options.templateOptions.Restangular;
  14310. },
  14311. APIService: function () {
  14312. return options.templateOptions.ApiService;
  14313. },
  14314. language: function () {
  14315. return options.templateOptions.language;
  14316. },
  14317. searchDatas: function () {
  14318. return filterSearchData;
  14319. },
  14320. scope: function () {
  14321. return $scope;
  14322. },
  14323. },
  14324. });
  14325. modalInstance.result.then(
  14326. function (selectedItem) {
  14327. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14328. selectedItem.telephone =
  14329. $scope.model.incident.contactsInformation;
  14330. }
  14331. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14332. selectedItem;
  14333. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14334. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14335. if ($scope.model) {
  14336. if ($scope.model.incident.place) {
  14337. $scope.model.incident.place.id = "";
  14338. }
  14339. if ($scope.model.area) {
  14340. $scope.model.incident.area.id = "";
  14341. }
  14342. $scope.model.incident.contacts = selectedItem.name;
  14343. if (
  14344. selectedItem.mphone &&
  14345. selectedItem.mphone != null &&
  14346. selectedItem.mphone != ""
  14347. ) {
  14348. $scope.model.incident.contactsInformation =
  14349. selectedItem.mphone;
  14350. } else {
  14351. $scope.model.incident.contactsInformation =
  14352. selectedItem.telephone;
  14353. }
  14354. $scope.model.incident.houseNumber = "";
  14355. if (
  14356. selectedItem.requesterTypeDTO &&
  14357. selectedItem.requesterTypeDTO.id == 2
  14358. ) {
  14359. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14360. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14361. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14362. }
  14363. }
  14364. $scope.options.value(selectedItem);
  14365. $scope.searchData = selectedItem.account;
  14366. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14367. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14368. }
  14369. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14370. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14371. }
  14372. if (selectedItem.houseNumber) {
  14373. $scope.model.incident.houseNumber =
  14374. selectedItem.houseNumber;
  14375. }
  14376. if (
  14377. selectedItem.requesterTypeDTO &&
  14378. selectedItem.requesterTypeDTO.id == 2
  14379. ) {
  14380. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14381. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14382. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14383. }
  14384. if (
  14385. options.templateOptions.callback &&
  14386. angular.isFunction(options.templateOptions.callback)
  14387. ) {
  14388. options.templateOptions.callback(selectedItem, options);
  14389. }
  14390. if (!$scope.roleidcode) {
  14391. $scope.charging(selectedItem, modal);
  14392. }
  14393. $scope.recentlyincident(selectedItem);
  14394. },
  14395. function () {
  14396. //console.log('Modal dismissed at: ' + new Date());
  14397. }
  14398. );
  14399. };
  14400. searchModal();
  14401. // }
  14402. },
  14403. },
  14404. };
  14405. },
  14406. controller: [
  14407. "$rootScope",
  14408. "$scope",
  14409. "ngTableParams",
  14410. "$filter",
  14411. "SweetAlert",
  14412. "moment",
  14413. function (
  14414. $rootScope,
  14415. $scope,
  14416. ngTableParams,
  14417. $filter,
  14418. SweetAlert,
  14419. moment
  14420. ) {
  14421. $scope.roleidcode = true;
  14422. // $scope.options.initialValue = undefined;
  14423. if ($rootScope.user && $rootScope.user.role) {
  14424. angular.forEach($rootScope.user.role, function (item) {
  14425. if (item.rolecode == "call center") {
  14426. $scope.roleidcode = false;
  14427. }
  14428. });
  14429. }
  14430. $scope.recently = false;
  14431. $scope.recentlyincident = function (key, model) {
  14432. //关联事件
  14433. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14434. idx: 0,
  14435. sum: 4,
  14436. incident: {
  14437. requester: {
  14438. id: key.id,
  14439. },
  14440. },
  14441. }).then(function (response) {
  14442. if (response.status == 200) {
  14443. $scope.recently = true;
  14444. $scope.recentincident = response.list;
  14445. } else {
  14446. $scope.recently = false;
  14447. }
  14448. });
  14449. $scope.bodyHeight = window.innerHeight - 100;
  14450. $(window).resize(function () {
  14451. $scope.bodyHeight = window.innerHeight - 100;
  14452. });
  14453. // $scope.shows = false;
  14454. $scope.tempData = {};
  14455. $scope.close = function () {
  14456. $scope.changes = !$scope.changes;
  14457. event.preventDefault();
  14458. };
  14459. };
  14460. $scope.charging = function (key, model) {
  14461. //计费弹出框
  14462. //用户信息
  14463. $scope.information = {};
  14464. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14465. userId: key.account,
  14466. }).then(function (response) {
  14467. // if (response.status == 200) {
  14468. if (response && response.data) {
  14469. angular.extend($scope.information, response.data[0]);
  14470. // $scope.information = response.data[0];
  14471. $scope.information.autologicDestroyTime = moment(
  14472. response.data[0].autologicDestroyTime
  14473. ).format("YYYY-MM-DD");
  14474. $scope.information.periodStartTime = moment(
  14475. response.data[0].periodStartTime
  14476. ).format("YYYY-MM-DD");
  14477. $scope.information.nextBillingTime = moment(
  14478. response.data[0].nextBillingTime
  14479. ).format("YYYY-MM-DD");
  14480. } else if (response.err) {
  14481. SweetAlert.swal(
  14482. "系统错误!",
  14483. "用户信息未取到,请刷新重试",
  14484. "error"
  14485. );
  14486. }
  14487. // }
  14488. });
  14489. //上网明细
  14490. $scope.options.templateOptions.ApiSer.fetchDataList(
  14491. "queryOnlineDetail",
  14492. {
  14493. userId: key.account,
  14494. limit: "10",
  14495. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14496. "YYYY-MM-DD HH:mm:ss"
  14497. ),
  14498. toLogoutTime: moment(new Date().getTime()).format(
  14499. "YYYY-MM-DD HH:mm:ss"
  14500. ),
  14501. }
  14502. ).then(function (response) {
  14503. // if (response.status == 200) {
  14504. if (response && response.data) {
  14505. angular.forEach(response.data, function (item, index) {
  14506. if (item.logoutTime) {
  14507. response.data[index].logoutTime = moment(
  14508. item.logoutTime
  14509. ).format("YYYY-MM-DD HH:mm:ss");
  14510. }
  14511. if (item.loginTime) {
  14512. response.data[index].loginTime = moment(
  14513. item.loginTime
  14514. ).format("YYYY-MM-DD HH:mm:ss");
  14515. }
  14516. });
  14517. $scope.logininform = response.data;
  14518. } else if (response.err) {
  14519. SweetAlert.swal(
  14520. "系统错误!",
  14521. "上网明细未取到,请刷新重试",
  14522. "error"
  14523. );
  14524. }
  14525. });
  14526. //黑名单
  14527. // $scope.information.blacklist = "否"
  14528. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14529. userId: key.account,
  14530. }).then(function (response) {
  14531. // if (response.status == 200) {
  14532. // $scope.logininformation = response.data;
  14533. if (response) {
  14534. if (response.data || response.data != null) {
  14535. $scope.information.blacklist = "是";
  14536. } else {
  14537. if (response.err) {
  14538. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14539. } else {
  14540. $scope.information.blacklist = "否";
  14541. }
  14542. }
  14543. }
  14544. // }
  14545. });
  14546. $scope.bodyHeight = window.innerHeight - 100;
  14547. $(window).resize(function () {
  14548. $scope.bodyHeight = window.innerHeight - 100;
  14549. });
  14550. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14551. // $scope.closepages = function(e) {
  14552. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14553. // event.preventDefault();
  14554. // };
  14555. // $scope.shows = false;
  14556. $scope.tempData = {};
  14557. $scope.close = function () {
  14558. $scope.changes = !$scope.changes;
  14559. event.preventDefault();
  14560. };
  14561. };
  14562. $scope.options.templateOptions.ApiService.fetchDataList(
  14563. "requesterType",
  14564. {
  14565. idx: 0,
  14566. sum: 100,
  14567. }
  14568. ).then(function (response) {
  14569. if (response.status == 200) {
  14570. $scope.networktypes = response.list;
  14571. } else {
  14572. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14573. }
  14574. });
  14575. function serchdata(searchKey) {
  14576. if (searchKey) {
  14577. var filterData = {
  14578. requester: {
  14579. searchKey: searchKey,
  14580. // 'userType': 1
  14581. },
  14582. idx: 0,
  14583. sum: 10,
  14584. };
  14585. } else {
  14586. var filterData = {
  14587. idx: 0,
  14588. requester: {},
  14589. sum: 10,
  14590. };
  14591. }
  14592. if (
  14593. $scope.model.requester &&
  14594. $scope.model.requester.requesterTypeDTO
  14595. ) {
  14596. angular.extend(filterData.requester, {
  14597. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14598. });
  14599. if (!$scope.options.model.contactsInformation) {
  14600. $scope.options.model.contactsInformation =
  14601. $scope.model.requester.mphone;
  14602. }
  14603. }
  14604. if ($scope.roleidcode) {
  14605. angular.extend(filterData["requester"], {
  14606. userType: 1,
  14607. });
  14608. }
  14609. $scope.options.templateOptions.ApiService.fetchDataList(
  14610. "requester",
  14611. filterData
  14612. ).then(function (response) {
  14613. var myData = response;
  14614. $scope.myData = myData.list;
  14615. });
  14616. }
  14617. $scope.searchData = {};
  14618. $scope.refreshUser = function (searchKey) {
  14619. //请求人搜索
  14620. if (searchKey && searchKey != "") {
  14621. serchdata(searchKey);
  14622. }
  14623. };
  14624. if (
  14625. $scope.$parent.$parent.$parent.model.incident.callID ||
  14626. $scope.$parent.$parent.$parent.model.requestershow
  14627. ) {
  14628. if (!$scope.roleidcode) {
  14629. $scope.charging(
  14630. $scope.$parent.$parent.$parent.model.incident.requester
  14631. );
  14632. }
  14633. $scope.recentlyincident(
  14634. $scope.$parent.$parent.$parent.model.incident.requester
  14635. );
  14636. }
  14637. $scope.onChange = function (searchData) {
  14638. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14639. searchData.telephone = $scope.model.incident.contactsInformation;
  14640. }
  14641. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14642. searchData;
  14643. if (!$scope.roleidcode) {
  14644. $scope.charging(searchData);
  14645. }
  14646. $scope.recentlyincident(searchData);
  14647. $scope.accountshow = false;
  14648. if ($scope.model.incident) {
  14649. if ($scope.model.incident.place) {
  14650. $scope.model.incident.place.id = "";
  14651. }
  14652. if ($scope.model.incident.area) {
  14653. $scope.model.incident.area.id = "";
  14654. }
  14655. $scope.model.incident.contacts = searchData.name;
  14656. if (
  14657. searchData.mphone &&
  14658. searchData.mphone != null &&
  14659. searchData.mphone != ""
  14660. ) {
  14661. $scope.model.incident.contactsInformation = searchData.mphone;
  14662. } else {
  14663. $scope.model.incident.contactsInformation = searchData.telephone;
  14664. }
  14665. $scope.model.incident.houseNumber = "";
  14666. if (
  14667. searchData.requesterTypeDTO &&
  14668. searchData.requesterTypeDTO.id == 2
  14669. ) {
  14670. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14671. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14672. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14673. }
  14674. }
  14675. $scope.options.value(searchData);
  14676. $scope.searchKey = searchData.account;
  14677. if (searchData.placeDTO && searchData.placeDTO.id) {
  14678. $scope.model.incident.place.id = searchData.placeDTO.id;
  14679. }
  14680. if (searchData.areaDTO && searchData.areaDTO.id) {
  14681. $scope.model.incident.area.id = searchData.areaDTO.id;
  14682. }
  14683. if (searchData.houseNumber) {
  14684. $scope.model.incident.houseNumber = searchData.houseNumber;
  14685. }
  14686. if (
  14687. searchData.requesterTypeDTO &&
  14688. searchData.requesterTypeDTO.id == 2
  14689. ) {
  14690. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14691. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14692. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14693. }
  14694. };
  14695. },
  14696. ],
  14697. });
  14698. //ui-grid-table展示控件
  14699. formlyConfigProvider.setType({
  14700. name: "ui-grid-table",
  14701. // extends: 'multiCheckbox',//去掉冒号
  14702. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  14703. defaultOptions: function (options) {
  14704. return {
  14705. templateOptions: {
  14706. linkage: function () { },
  14707. },
  14708. };
  14709. },
  14710. controller: function (
  14711. $scope,
  14712. $rootScope,
  14713. i18nService,
  14714. Restangular,
  14715. api_bpm_data,
  14716. api_statistic,
  14717. $rootScope
  14718. ) {
  14719. var loginUser = $rootScope.user;
  14720. $scope.langs = i18nService.getAllLangs();
  14721. $scope.lang = "zh-cn";
  14722. i18nService.setCurrentLang($scope.lang);
  14723. $scope.gridOptions = {};
  14724. $scope.gridOptions.data = "myData";
  14725. $scope.gridOptions.enableColumnResizing = true;
  14726. $scope.gridOptions.enableGridMenu = false;
  14727. $scope.gridOptions.enableRowSelection = true;
  14728. $scope.gridOptions.showGridFooter = false;
  14729. $scope.gridOptions.showColumnFooter = false;
  14730. $scope.gridOptions.fastWatch = true;
  14731. $scope.gridOptions.useExternalFiltering = true;
  14732. $scope.gridOptions.useExternalPagination = false;
  14733. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14734. $scope.gridOptions.paginationPageSize = 3;
  14735. $scope.gridOptions.multiSelect = false;
  14736. $scope.gridOptions.rowIdentity = function (row) {
  14737. return row.id;
  14738. };
  14739. $scope.gridOptions.getRowIdentity = function (row) {
  14740. return row.id;
  14741. };
  14742. $scope.gridOptions.columnDefs = [
  14743. {
  14744. name: "item",
  14745. displayName: "序号",
  14746. width: 80,
  14747. enableFiltering: false,
  14748. },
  14749. {
  14750. name: "incidentsign",
  14751. displayName: "单号",
  14752. width: 80,
  14753. enableFiltering: false,
  14754. },
  14755. {
  14756. name: "description",
  14757. displayName: "主题",
  14758. width: 80,
  14759. enableFiltering: false,
  14760. },
  14761. {
  14762. name: "state.name",
  14763. displayName: "状态",
  14764. width: 110,
  14765. enableFiltering: false,
  14766. },
  14767. {
  14768. name: "acceptDate",
  14769. displayName: "创建时间",
  14770. width: 160,
  14771. enableFiltering: false,
  14772. },
  14773. {
  14774. name: "requester.name",
  14775. displayName: "请求人",
  14776. width: 80,
  14777. enableFiltering: false,
  14778. },
  14779. {
  14780. name: "handlingPersonnelUser.name",
  14781. displayName: "处理人",
  14782. width: 160,
  14783. enableFiltering: false,
  14784. },
  14785. {
  14786. name: "place.place",
  14787. displayName: "区域地点",
  14788. width: 160,
  14789. enableFiltering: false,
  14790. },
  14791. ];
  14792. // var defaultFilterData = {
  14793. // "idx": 0,
  14794. // "sum": 3
  14795. // };
  14796. // // //分页控制
  14797. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14798. gridApi.pagination.on.paginationChanged(
  14799. $scope,
  14800. function (newPage, pageSize) {
  14801. var filtersData = $scope.memoryfilterData;
  14802. filtersData.idx = newPage - 1;
  14803. filtersData.sum = pageSize;
  14804. $scope.refreshData("expand-right", filtersData);
  14805. }
  14806. );
  14807. // 表格单选事件
  14808. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  14809. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  14810. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  14811. data.entity;
  14812. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  14813. data.entity.id;
  14814. var str =
  14815. data.grid.appScope.$parent.$parent.$parent.model.incident
  14816. .description || "";
  14817. str = str.split("").reverse().join("");
  14818. var del = addstr.split("").reverse().join("");
  14819. // console.log(del);
  14820. var reg = new RegExp(del);
  14821. str = str.replace(reg, "");
  14822. str = str.split("").reverse().join("");
  14823. if (
  14824. data.grid.appScope.$parent.$parent.$parent.model.incident
  14825. .associationType == "事件补充"
  14826. ) {
  14827. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  14828. null;
  14829. str += data.entity.description;
  14830. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14831. data.entity.description;
  14832. } else if (
  14833. data.grid.appScope.$parent.$parent.$parent.model.incident
  14834. .associationType == "事件已解决"
  14835. ) {
  14836. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  14837. "close";
  14838. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14839. "";
  14840. }
  14841. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  14842. str;
  14843. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  14844. data.entity.id;
  14845. });
  14846. };
  14847. // 刷新表格
  14848. setInterval(function () {
  14849. // console.log($scope.myData);
  14850. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  14851. // console.log($scope.myData);
  14852. if ($scope.myData != null) {
  14853. for (var i = 0; i < $scope.myData.length; i++) {
  14854. //添加序号
  14855. $scope.myData[i]["item"] = i + 1;
  14856. }
  14857. }
  14858. }, 1000);
  14859. },
  14860. });
  14861. //处理人信息
  14862. formlyConfigProvider.setType({
  14863. name: "ui-userinformation",
  14864. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  14865. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14866. defaultOptions: function (options) {
  14867. return {
  14868. templateOptions: {},
  14869. };
  14870. },
  14871. controller: [
  14872. "$scope",
  14873. function ($scope) {
  14874. $scope.group = "";
  14875. $scope.role = "";
  14876. if (
  14877. angular.isDefined($scope.model.handlingPersonnelUser) &&
  14878. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14879. $scope.model.handlingPersonnelUser.group.length == 1
  14880. ) {
  14881. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14882. } else {
  14883. for (
  14884. var i = 0;
  14885. i < $scope.model.handlingPersonnelUser.group.length;
  14886. i++
  14887. ) {
  14888. $scope.group +=
  14889. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14890. }
  14891. }
  14892. if (
  14893. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  14894. $scope.model.handlingPersonnelUser.role.length == 1
  14895. ) {
  14896. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  14897. } else {
  14898. for (
  14899. var i = 0;
  14900. i < $scope.model.handlingPersonnelUser.role.length;
  14901. i++
  14902. ) {
  14903. $scope.role +=
  14904. $scope.model.handlingPersonnelUser.role[i].role + ",";
  14905. }
  14906. }
  14907. $scope.options.templateOptions.that = $scope;
  14908. },
  14909. ],
  14910. });
  14911. //处理界面处理人信息
  14912. formlyConfigProvider.setType({
  14913. name: "ui-handler",
  14914. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  14915. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14916. defaultOptions: function (options) {
  14917. return {
  14918. templateOptions: {},
  14919. };
  14920. },
  14921. controller: [
  14922. "$scope",
  14923. function ($scope) {
  14924. $scope.group = "";
  14925. // $scope.role="";
  14926. if (
  14927. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14928. $scope.model.handlingPersonnelUser.group.length == 1
  14929. ) {
  14930. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14931. } else {
  14932. for (
  14933. var i = 0;
  14934. i < $scope.model.handlingPersonnelUser.group.length;
  14935. i++
  14936. ) {
  14937. $scope.group +=
  14938. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14939. }
  14940. }
  14941. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  14942. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  14943. // }else{
  14944. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  14945. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  14946. // }
  14947. // }
  14948. $scope.options.templateOptions.that = $scope;
  14949. },
  14950. ],
  14951. });
  14952. //微信事件流程
  14953. formlyConfigProvider.setType({
  14954. name: "ui-wxIncidentProcess",
  14955. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  14956. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14957. defaultOptions: function (options) {
  14958. return {
  14959. templateOptions: {},
  14960. };
  14961. },
  14962. controller: [
  14963. "$scope",
  14964. function ($scope) {
  14965. console.log($scope.model);
  14966. $scope.pingjia = false;
  14967. $scope.jiejue = false;
  14968. if ($scope.model.incidentState.value == "3") {
  14969. $scope.pingjia = true;
  14970. } else if ($scope.model.incidentState.value == "4") {
  14971. $scope.jiejue = true;
  14972. }
  14973. },
  14974. ],
  14975. });
  14976. //打电话
  14977. formlyConfigProvider.setType({
  14978. name: "ui-inputcall",
  14979. extends: "input",
  14980. templateUrl: "assets/views/customform/tpl/inputcall.html",
  14981. defaultOptions: function (options) {
  14982. return {
  14983. templateOptions: {
  14984. transform: function (value) { },
  14985. },
  14986. };
  14987. },
  14988. controller: [
  14989. "$scope",
  14990. "$rootScope",
  14991. "api_text",
  14992. "SweetAlert",
  14993. function ($scope, $rootScope, api_text, SweetAlert) {
  14994. $scope.dialout = function (teleno) {
  14995. // var gid = "@0";
  14996. // var telephone = "9" + teleno;
  14997. $rootScope.callout = 2;
  14998. // var agcount = tlwsa.tlaGetagentcount();
  14999. // var agcountFlag = false;
  15000. // console.log(teleno)
  15001. // // 查询当前话机是否签入
  15002. // for (var i = 0; i < agcount; i++) {
  15003. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  15004. // agcountFlag = true;
  15005. // }
  15006. // }
  15007. if (localStorage.getItem('fenjiNumber')) {
  15008. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  15009. // console.log(sessionStorage.getItem('phones'))
  15010. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  15011. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  15012. // console.log(isHuajihao)
  15013. // if(isHuajihao){
  15014. // tlwsa.tlaCallagc(teleno);
  15015. // }else{
  15016. // tlwsa.tlaCallout(teleno, caller, 0);
  15017. // }
  15018. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  15019. $rootScope.toggle('off-sidebar');
  15020. // tlwsa.tlaCallout(teleno, caller, 0);
  15021. } else {
  15022. SweetAlert.swal({
  15023. title: "呼叫失败",
  15024. text: "请先签入呼叫中心!",
  15025. type: "error",
  15026. confirmButtonColor: "#DD6B55",
  15027. });
  15028. }
  15029. };
  15030. $scope.options.templateOptions.that = $scope;
  15031. },
  15032. ],
  15033. });
  15034. //关闭界面处理人信息
  15035. formlyConfigProvider.setType({
  15036. name: "ui-closehandler",
  15037. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  15038. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15039. defaultOptions: function (options) {
  15040. return {
  15041. templateOptions: {},
  15042. };
  15043. },
  15044. controller: [
  15045. "$scope",
  15046. "$rootScope",
  15047. "api_text",
  15048. function ($scope, $rootScope, api_text) {
  15049. $scope.dialout = function (teleno) {
  15050. var gid = "@0";
  15051. var telephone = "9" + teleno;
  15052. api_text
  15053. .dialout($rootScope.takes, gid, telephone)
  15054. .then(function (data) {
  15055. if (data.errno == 0) {
  15056. $rootScope.status = 6;
  15057. }
  15058. });
  15059. };
  15060. $scope.options.templateOptions.that = $scope;
  15061. },
  15062. ],
  15063. });
  15064. //用户单选控件
  15065. formlyConfigProvider.setType({
  15066. name: "ui-userselect",
  15067. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  15068. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15069. defaultOptions: function (options) {
  15070. return {
  15071. templateOptions: {
  15072. openModal: function (size, options, modal) {
  15073. var modalInstance = modal.open({
  15074. templateUrl:
  15075. "assets/views/customform/tpl/checktable-modal-content.html",
  15076. controller: function (
  15077. $scope,
  15078. i18nService,
  15079. $modalInstance,
  15080. items,
  15081. title,
  15082. Restangular,
  15083. APIService,
  15084. onDataCallback,
  15085. parentScope
  15086. ) {
  15087. $scope.langs = i18nService.getAllLangs();
  15088. $scope.lang = "zh-cn";
  15089. i18nService.setCurrentLang($scope.lang);
  15090. $scope.gridOptions = {};
  15091. $scope.gridOptions.data = "myData";
  15092. $scope.gridOptions.enableColumnResizing = true;
  15093. $scope.gridOptions.enableFiltering = true;
  15094. $scope.gridOptions.enableGridMenu = false;
  15095. $scope.gridOptions.showGridFooter = true;
  15096. $scope.gridOptions.showColumnFooter = false;
  15097. $scope.gridOptions.fastWatch = true;
  15098. $scope.gridOptions.useExternalFiltering = true;
  15099. $scope.gridOptions.useExternalPagination = true;
  15100. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15101. $scope.gridOptions.paginationPageSize = 10;
  15102. $scope.gridOptions.multiSelect = false;
  15103. $scope.gridOptions.rowIdentity = function (row) {
  15104. return row.id;
  15105. };
  15106. $scope.gridOptions.getRowIdentity = function (row) {
  15107. return row.id;
  15108. };
  15109. $scope.gridOptions.rowTemplate =
  15110. '<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>';
  15111. $scope.gridOptions.columnDefs = [
  15112. {
  15113. name: "account",
  15114. displayName: "人员编号",
  15115. width: 120,
  15116. },
  15117. {
  15118. name: "name",
  15119. displayName: "姓名",
  15120. width: 100,
  15121. cellTemplate:
  15122. "<div>" +
  15123. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15124. "</div>",
  15125. },
  15126. // {
  15127. // name: 'gender.name',
  15128. // displayName: '性别',
  15129. // width: 80,
  15130. // enableFiltering: false
  15131. // },
  15132. {
  15133. name: "phone",
  15134. displayName: "电话",
  15135. width: 230,
  15136. enableFiltering: false,
  15137. },
  15138. {
  15139. name: "email",
  15140. displayName: "邮箱",
  15141. width: 180,
  15142. enableFiltering: false,
  15143. },
  15144. {
  15145. name: "dept.dept",
  15146. displayName: "科室",
  15147. width: 130,
  15148. enableFiltering: false,
  15149. },
  15150. {
  15151. name: "taskCount",
  15152. displayName: "处理中事件数",
  15153. enableFiltering: false,
  15154. },
  15155. ];
  15156. // $scope.selectButtonClick
  15157. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15158. $scope.gridApi = gridApi;
  15159. gridApi.pagination.on.paginationChanged(
  15160. $scope,
  15161. function (newPage, pageSize) {
  15162. var filtersData = $scope.memoryfilterData;
  15163. filtersData.idx = newPage - 1;
  15164. filtersData.sum = pageSize;
  15165. $scope.loadData(filtersData);
  15166. //console.log(pageSize);
  15167. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15168. }
  15169. );
  15170. gridApi.selection.on.rowSelectionChanged(
  15171. $scope,
  15172. function (data) {
  15173. $scope.selected.items = data.entity;
  15174. //console.log(data);
  15175. }
  15176. );
  15177. gridApi.selection.on.rowSelectionChangedBatch(
  15178. $scope,
  15179. function (data) {
  15180. $scope.selected.items = data.entity;
  15181. //console.log(data);
  15182. }
  15183. );
  15184. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15185. // // if (row.entity.age > 45) {
  15186. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15187. // // }
  15188. // };
  15189. gridApi.core.on.filterChanged($scope, function () {
  15190. var grid = this.grid;
  15191. var filtersData = {
  15192. idx: 0,
  15193. sum: 10,
  15194. user: {
  15195. roledata: {
  15196. rolecode: "roleset",
  15197. },
  15198. selectType: "1",
  15199. },
  15200. };
  15201. angular.forEach(grid.columns, function (item) {
  15202. if (item.enableFiltering) {
  15203. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15204. if (
  15205. angular.isDefined(item.filters[0].term) &&
  15206. item.filters[0].term != ""
  15207. ) {
  15208. if (angular.isUndefined(filtersData["user"])) {
  15209. filtersData["user"] = {};
  15210. }
  15211. filtersData["user"][item.field] =
  15212. item.filters[0].term;
  15213. }
  15214. }
  15215. });
  15216. $scope.memoryfilterData = filtersData;
  15217. $scope.loadData(filtersData);
  15218. });
  15219. };
  15220. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15221. // if (row.entity.age > 45) {
  15222. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15223. // }
  15224. // },
  15225. $scope.onDblClick = function (data, event) {
  15226. // $scope.selected.items = data.entity;
  15227. $scope.selectButtonClick(data, event);
  15228. };
  15229. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15230. // $scope.selected.items = data.entity;
  15231. // })
  15232. // };
  15233. $scope.memoryfilterData = {
  15234. idx: 0,
  15235. sum: 10,
  15236. user: {
  15237. roledata: {
  15238. rolecode: "roleset",
  15239. },
  15240. selectType: "1",
  15241. },
  15242. };
  15243. $scope.loadData = function (filterData) {
  15244. // console.log("filtersData=111" + JSON.stringify(filterData))
  15245. items
  15246. .fetchItems(filterData, APIService)
  15247. .then(function (data) {
  15248. var myData = Restangular.stripRestangular(data);
  15249. $scope.gridOptions.totalItems = myData.totalNum;
  15250. $scope.myData = myData.list;
  15251. });
  15252. };
  15253. // $scope.title = title;
  15254. $scope.loadData({
  15255. idx: 0,
  15256. sum: 10,
  15257. user: {
  15258. roledata: {
  15259. rolecode: "roleset",
  15260. },
  15261. selectType: "1",
  15262. },
  15263. });
  15264. $scope.selected = {
  15265. items: {},
  15266. };
  15267. $scope.ok = function () {
  15268. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15269. // onDataCallback($scope.selected.item, parentScope);
  15270. // }
  15271. $modalInstance.close($scope.selected.items);
  15272. };
  15273. $scope.cancel = function () {
  15274. $modalInstance.dismiss("cancel");
  15275. };
  15276. },
  15277. size: size,
  15278. resolve: {
  15279. items: function () {
  15280. return {
  15281. fetchItems: function (filterData, APIService) {
  15282. filterData = filterData || {};
  15283. if (
  15284. angular.isDefined(filterData.idx) &&
  15285. filterData.idx == null
  15286. ) {
  15287. filterData = {
  15288. idx: 0,
  15289. sum: 10,
  15290. user: {
  15291. roledata: {
  15292. rolecode: "roleset",
  15293. },
  15294. selectType: "1",
  15295. },
  15296. };
  15297. }
  15298. return options.templateOptions.fetchItems(
  15299. filterData,
  15300. APIService
  15301. );
  15302. },
  15303. };
  15304. },
  15305. title: function () {
  15306. return options.templateOptions.label;
  15307. },
  15308. Restangular: function () {
  15309. return options.templateOptions.Restangular;
  15310. },
  15311. APIService: function () {
  15312. return options.templateOptions.ApiService;
  15313. },
  15314. onDataCallback: function () {
  15315. return options.templateOptions.callback;
  15316. },
  15317. parentScope: function () {
  15318. return options.templateOptions.that;
  15319. },
  15320. },
  15321. });
  15322. modalInstance.result.then(
  15323. function (selectedItem) {
  15324. // console.log(selectedItem);
  15325. options.value(selectedItem);
  15326. if (
  15327. options.templateOptions.callback &&
  15328. angular.isFunction(options.templateOptions.callback)
  15329. ) {
  15330. options.templateOptions.callback(
  15331. selectedItem,
  15332. options.templateOptions.that
  15333. );
  15334. }
  15335. if (
  15336. options.templateOptions.linkData &&
  15337. angular.isFunction(options.templateOptions.linkData)
  15338. ) {
  15339. options.templateOptions.linkData(
  15340. selectedItem,
  15341. options.templateOptions.that
  15342. );
  15343. }
  15344. },
  15345. function () {
  15346. //console.log('Modal dismissed at: ' + new Date());
  15347. }
  15348. );
  15349. },
  15350. },
  15351. };
  15352. },
  15353. controller: [
  15354. "$scope",
  15355. function ($scope) {
  15356. $scope.options.templateOptions.that = $scope;
  15357. // $scope.options.model[$scope.options.key] = {}
  15358. },
  15359. ],
  15360. });
  15361. //用户单选控件(dd 单选input带搜索)
  15362. formlyConfigProvider.setType({
  15363. name: "ui-userselectSearch",
  15364. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15365. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15366. defaultOptions: function (options) {
  15367. return {
  15368. templateOptions: {
  15369. openModal: function (size, options, modal) {
  15370. var modalInstance = modal.open({
  15371. templateUrl:
  15372. "assets/views/customform/tpl/checktable-modal-content.html",
  15373. controller: function (
  15374. $scope,
  15375. i18nService,
  15376. $modalInstance,
  15377. items,
  15378. title,
  15379. Restangular,
  15380. APIService,
  15381. onDataCallback,
  15382. parentScope
  15383. ) {
  15384. $scope.langs = i18nService.getAllLangs();
  15385. $scope.lang = "zh-cn";
  15386. i18nService.setCurrentLang($scope.lang);
  15387. $scope.gridOptions = {};
  15388. $scope.gridOptions.data = "myData";
  15389. $scope.gridOptions.enableColumnResizing = true;
  15390. $scope.gridOptions.enableFiltering = true;
  15391. $scope.gridOptions.enableGridMenu = false;
  15392. $scope.gridOptions.showGridFooter = true;
  15393. $scope.gridOptions.showColumnFooter = false;
  15394. $scope.gridOptions.fastWatch = true;
  15395. $scope.gridOptions.useExternalFiltering = true;
  15396. $scope.gridOptions.useExternalPagination = true;
  15397. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15398. $scope.gridOptions.paginationPageSize = 10;
  15399. $scope.gridOptions.multiSelect = false;
  15400. $scope.gridOptions.rowIdentity = function (row) {
  15401. return row.id;
  15402. };
  15403. $scope.gridOptions.getRowIdentity = function (row) {
  15404. return row.id;
  15405. };
  15406. $scope.gridOptions.rowTemplate =
  15407. '<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>';
  15408. $scope.gridOptions.columnDefs = [
  15409. {
  15410. name: "account",
  15411. displayName: "人员编号",
  15412. width: 120,
  15413. },
  15414. {
  15415. name: "name",
  15416. displayName: "姓名",
  15417. width: 100,
  15418. cellTemplate:
  15419. "<div>" +
  15420. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15421. "</div>",
  15422. },
  15423. // {
  15424. // name: 'gender.name',
  15425. // displayName: '性别',
  15426. // width: 80,
  15427. // enableFiltering: false
  15428. // },
  15429. {
  15430. name: "phone",
  15431. displayName: "电话",
  15432. width: 230,
  15433. enableFiltering: false,
  15434. },
  15435. {
  15436. name: "email",
  15437. displayName: "邮箱",
  15438. width: 180,
  15439. enableFiltering: false,
  15440. },
  15441. {
  15442. name: "dept.dept",
  15443. displayName: "科室",
  15444. width: 130,
  15445. enableFiltering: false,
  15446. },
  15447. {
  15448. name: "taskCount",
  15449. displayName: "处理中事件数",
  15450. enableFiltering: false,
  15451. },
  15452. ];
  15453. // $scope.selectButtonClick
  15454. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15455. $scope.gridApi = gridApi;
  15456. gridApi.pagination.on.paginationChanged(
  15457. $scope,
  15458. function (newPage, pageSize) {
  15459. var filtersData = $scope.memoryfilterData;
  15460. filtersData.idx = newPage - 1;
  15461. filtersData.sum = pageSize;
  15462. $scope.loadData(filtersData);
  15463. //console.log(pageSize);
  15464. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15465. }
  15466. );
  15467. gridApi.selection.on.rowSelectionChanged(
  15468. $scope,
  15469. function (data) {
  15470. $scope.selected.items = data.entity;
  15471. //console.log(data);
  15472. }
  15473. );
  15474. gridApi.selection.on.rowSelectionChangedBatch(
  15475. $scope,
  15476. function (data) {
  15477. $scope.selected.items = data.entity;
  15478. //console.log(data);
  15479. }
  15480. );
  15481. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15482. // // if (row.entity.age > 45) {
  15483. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15484. // // }
  15485. // };
  15486. gridApi.core.on.filterChanged($scope, function () {
  15487. var grid = this.grid;
  15488. var filtersData = {
  15489. idx: 0,
  15490. sum: 10,
  15491. user: {
  15492. roledata: {
  15493. rolecode: "first-line support",
  15494. },
  15495. selectType: "1",
  15496. },
  15497. };
  15498. angular.forEach(grid.columns, function (item) {
  15499. if (item.enableFiltering) {
  15500. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15501. if (
  15502. angular.isDefined(item.filters[0].term) &&
  15503. item.filters[0].term != ""
  15504. ) {
  15505. if (angular.isUndefined(filtersData["user"])) {
  15506. filtersData["user"] = {};
  15507. }
  15508. filtersData["user"][item.field] =
  15509. item.filters[0].term;
  15510. }
  15511. }
  15512. });
  15513. $scope.memoryfilterData = filtersData;
  15514. $scope.loadData(filtersData);
  15515. });
  15516. };
  15517. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15518. // if (row.entity.age > 45) {
  15519. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15520. // }
  15521. // },
  15522. $scope.onDblClick = function (data, event) {
  15523. // $scope.selected.items = data.entity;
  15524. $scope.selectButtonClick(data, event);
  15525. };
  15526. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15527. // $scope.selected.items = data.entity;
  15528. // })
  15529. // };
  15530. $scope.memoryfilterData = {
  15531. idx: 0,
  15532. sum: 10,
  15533. user: {
  15534. roledata: {
  15535. rolecode: "first-line support",
  15536. },
  15537. selectType: "1",
  15538. },
  15539. };
  15540. $scope.loadData = function (filterData) {
  15541. // console.log("filtersData=111" + JSON.stringify(filterData))
  15542. items
  15543. .fetchItems(filterData, APIService)
  15544. .then(function (data) {
  15545. var myData = Restangular.stripRestangular(data);
  15546. $scope.gridOptions.totalItems = myData.totalNum;
  15547. $scope.myData = myData.list;
  15548. });
  15549. };
  15550. $scope.title = title;
  15551. $scope.loadData({
  15552. idx: 0,
  15553. sum: 10,
  15554. user: {
  15555. roledata: {
  15556. rolecode: "first-line support",
  15557. },
  15558. selectType: "1",
  15559. },
  15560. });
  15561. $scope.selected = {
  15562. items: {},
  15563. };
  15564. $scope.ok = function () {
  15565. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15566. // onDataCallback($scope.selected.item, parentScope);
  15567. // }
  15568. $modalInstance.close($scope.selected.items);
  15569. };
  15570. $scope.cancel = function () {
  15571. $modalInstance.dismiss("cancel");
  15572. };
  15573. },
  15574. size: size,
  15575. resolve: {
  15576. items: function () {
  15577. return {
  15578. fetchItems: function (filterData, APIService) {
  15579. filterData = filterData || {};
  15580. if (
  15581. angular.isDefined(filterData.idx) &&
  15582. filterData.idx == null
  15583. ) {
  15584. filterData = {
  15585. idx: 0,
  15586. sum: 10,
  15587. user: {
  15588. roledata: {
  15589. rolecode: "first-line support",
  15590. },
  15591. selectType: "1",
  15592. },
  15593. };
  15594. }
  15595. return options.templateOptions.fetchItems(
  15596. filterData,
  15597. APIService
  15598. );
  15599. },
  15600. };
  15601. },
  15602. title: function () {
  15603. return options.templateOptions.label;
  15604. },
  15605. Restangular: function () {
  15606. return options.templateOptions.Restangular;
  15607. },
  15608. APIService: function () {
  15609. return options.templateOptions.ApiService;
  15610. },
  15611. onDataCallback: function () {
  15612. return options.templateOptions.callback;
  15613. },
  15614. parentScope: function () {
  15615. return options.templateOptions.that;
  15616. },
  15617. },
  15618. });
  15619. modalInstance.result.then(
  15620. function (selectedItem) {
  15621. // console.log(selectedItem);
  15622. options.value(selectedItem);
  15623. if (
  15624. options.templateOptions.callback &&
  15625. angular.isFunction(options.templateOptions.callback)
  15626. ) {
  15627. options.templateOptions.callback(
  15628. selectedItem,
  15629. options.templateOptions.that
  15630. );
  15631. }
  15632. if (
  15633. options.templateOptions.linkData &&
  15634. angular.isFunction(options.templateOptions.linkData)
  15635. ) {
  15636. options.templateOptions.linkData(
  15637. selectedItem,
  15638. options.templateOptions.that
  15639. );
  15640. }
  15641. },
  15642. function () {
  15643. //console.log('Modal dismissed at: ' + new Date());
  15644. }
  15645. );
  15646. },
  15647. },
  15648. };
  15649. },
  15650. controller: [
  15651. "$scope",
  15652. function ($scope) {
  15653. $scope.options.templateOptions.that = $scope;
  15654. },
  15655. ],
  15656. });
  15657. //用户多选控件
  15658. formlyConfigProvider.setType({
  15659. name: "ui-multiuserselect",
  15660. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  15661. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15662. defaultOptions: function (options) {
  15663. return {
  15664. templateOptions: {
  15665. openModal: function (size, options, modal, model) {
  15666. var modalInstance = modal.open({
  15667. templateUrl:
  15668. "assets/views/customform/tpl/checktable-modal-content.html",
  15669. controller: function (
  15670. $scope,
  15671. $modalInstance,
  15672. i18nService,
  15673. $timeout,
  15674. items,
  15675. title,
  15676. Restangular,
  15677. APIService,
  15678. selectItems
  15679. ) {
  15680. $scope.langs = i18nService.getAllLangs();
  15681. $scope.lang = "zh-cn";
  15682. i18nService.setCurrentLang($scope.lang);
  15683. $scope.gridOptions = {};
  15684. $scope.gridOptions.data = "myData";
  15685. $scope.gridOptions.enableColumnResizing = true;
  15686. $scope.gridOptions.enableFiltering = true;
  15687. $scope.gridOptions.enableGridMenu = true;
  15688. $scope.gridOptions.showGridFooter = true;
  15689. $scope.gridOptions.showColumnFooter = true;
  15690. $scope.gridOptions.fastWatch = true;
  15691. $scope.gridOptions.useExternalFiltering = true;
  15692. $scope.gridOptions.useExternalPagination = true;
  15693. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15694. $scope.gridOptions.paginationPageSize = 10;
  15695. $scope.gridOptions.multiSelect = true;
  15696. $scope.gridOptions.rowIdentity = function (row) {
  15697. return row.id;
  15698. };
  15699. $scope.gridOptions.getRowIdentity = function (row) {
  15700. return row.id;
  15701. };
  15702. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  15703. $scope.gridOptions.columnDefs = [
  15704. // { name:'id', width:80, enableFiltering:false},
  15705. {
  15706. name: "account",
  15707. displayName: "账号",
  15708. width: 140,
  15709. },
  15710. {
  15711. name: "name",
  15712. displayName: "名称",
  15713. width: 100,
  15714. },
  15715. {
  15716. name: "gender.name",
  15717. displayName: "性别",
  15718. width: 140,
  15719. enableFiltering: false,
  15720. },
  15721. {
  15722. name: "phone",
  15723. displayName: "电话",
  15724. width: 100,
  15725. enableFiltering: false,
  15726. },
  15727. {
  15728. name: "email",
  15729. displayName: "邮件",
  15730. width: 100,
  15731. enableFiltering: false,
  15732. },
  15733. {
  15734. name: "dept.dept",
  15735. displayName: "科室",
  15736. width: 100,
  15737. enableFiltering: false,
  15738. },
  15739. {
  15740. name: "group[0].groupName",
  15741. displayName: "职位",
  15742. width: 100,
  15743. enableFiltering: false,
  15744. },
  15745. ];
  15746. $scope.selected = {
  15747. items: selectItems,
  15748. };
  15749. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15750. $scope.gridApi = gridApi;
  15751. gridApi.pagination.on.paginationChanged(
  15752. $scope,
  15753. function (newPage, pageSize) {
  15754. var filtersData = $scope.memoryfilterData;
  15755. filtersData.idx = newPage - 1;
  15756. filtersData.sum = pageSize;
  15757. $scope.loadData(filtersData);
  15758. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15759. }
  15760. );
  15761. gridApi.selection.on.rowSelectionChanged(
  15762. $scope,
  15763. function (scope) {
  15764. var j = 0;
  15765. for (
  15766. var i = 0;
  15767. i <= scope.grid.appScope.selected.items.length;
  15768. i++
  15769. ) {
  15770. if (
  15771. scope.grid.appScope.selected.items[i] == scope.entity
  15772. ) {
  15773. j++;
  15774. break;
  15775. }
  15776. }
  15777. if (j == 1) {
  15778. scope.grid.appScope.selected.items.splice(i, 1);
  15779. } else {
  15780. scope.grid.appScope.selected.items.push(scope.entity);
  15781. for (
  15782. var i = 0;
  15783. i < scope.grid.appScope.selected.items.length;
  15784. i++
  15785. ) {
  15786. for (
  15787. var z = 0;
  15788. z < scope.grid.appScope.selected.items.length;
  15789. z++
  15790. ) {
  15791. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  15792. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  15793. if (
  15794. angular.isDefined(
  15795. scope.grid.appScope.selected.items
  15796. ) &&
  15797. scope.grid.appScope.selected.items[i].id ==
  15798. scope.grid.appScope.selected.items[z].id &&
  15799. i != z
  15800. ) {
  15801. scope.grid.appScope.selected.items.splice(i, 1);
  15802. }
  15803. }
  15804. }
  15805. }
  15806. }
  15807. );
  15808. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  15809. // $scope.grid.appScope.selected.items.push($scope.entity);
  15810. // });
  15811. gridApi.core.on.filterChanged($scope, function () {
  15812. var grid = this.grid;
  15813. var filtersData = {
  15814. idx: 0,
  15815. sum: 10,
  15816. user: {
  15817. roledata: {
  15818. rolecode: options.model.currentRole,
  15819. },
  15820. selectType: "1",
  15821. },
  15822. };
  15823. angular.forEach(grid.columns, function (item) {
  15824. if (item.enableFiltering) {
  15825. //console.log("filtersData="+JSON.stringify(filtersData))
  15826. if (
  15827. angular.isDefined(item.filters[0].term) &&
  15828. item.filters[0].term != ""
  15829. ) {
  15830. if (angular.isUndefined(filtersData["user"])) {
  15831. filtersData["user"] = {};
  15832. }
  15833. filtersData["user"][item.field] =
  15834. item.filters[0].term;
  15835. }
  15836. }
  15837. });
  15838. $scope.memoryfilterData = filtersData;
  15839. $scope.loadData(filtersData);
  15840. });
  15841. };
  15842. if (!options.model) {
  15843. var mouse = {
  15844. model: {
  15845. currentRole: "",
  15846. },
  15847. };
  15848. angular.extend(options, mouse);
  15849. }
  15850. $scope.memoryfilterData = {
  15851. idx: 0,
  15852. sum: 10,
  15853. user: {
  15854. roledata: {
  15855. rolecode: options.model.currentRole,
  15856. },
  15857. selectType: "1",
  15858. },
  15859. };
  15860. $scope.loadData = function (filterData) {
  15861. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  15862. items
  15863. .fetchItems(filterData, APIService)
  15864. .then(function (data) {
  15865. var myData = Restangular.stripRestangular(data);
  15866. $scope.gridOptions.totalItems = myData.totalNum;
  15867. $scope.myData = myData.list;
  15868. //console.log($scope.gridOptions.pagination.getTotalPages());
  15869. // if($scope.selected.items){
  15870. // angular.forEach($scope.selected.items,function(selectItem){
  15871. // $scope.gridApi.selection.selectRow(selectItem);
  15872. // });
  15873. // }
  15874. });
  15875. };
  15876. // $scope.title = title;
  15877. $scope.loadData({
  15878. idx: 0,
  15879. sum: 10,
  15880. user: {
  15881. roledata: {
  15882. rolecode: options.model.currentRole,
  15883. },
  15884. selectType: "1",
  15885. },
  15886. });
  15887. // $timeout(function(){
  15888. // if($scope.selected.items){
  15889. // angular.forEach($scope.selected.items,function(selectItem){
  15890. // $scope.gridApi.selection.selectRow(selectItem);
  15891. // });
  15892. // }
  15893. // },2000)
  15894. $scope.ok = function () {
  15895. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  15896. $modalInstance.close($scope.selected.items);
  15897. };
  15898. $scope.cancel = function () {
  15899. $modalInstance.dismiss("cancel");
  15900. };
  15901. },
  15902. size: size,
  15903. resolve: {
  15904. items: function () {
  15905. return {
  15906. fetchItems: function (filterData, APIService) {
  15907. filterData = filterData || {};
  15908. if (
  15909. angular.isDefined(filterData.idx) &&
  15910. filterData.idx == null
  15911. ) {
  15912. filterData = {
  15913. idx: 0,
  15914. sum: 10,
  15915. user: {
  15916. roledata: {
  15917. rolecode: options.model.incident.currentRole,
  15918. },
  15919. selectType: "1",
  15920. },
  15921. };
  15922. }
  15923. return options.templateOptions.fetchItems(
  15924. filterData,
  15925. APIService
  15926. );
  15927. },
  15928. };
  15929. },
  15930. title: function () {
  15931. return options.templateOptions.modalTitle;
  15932. },
  15933. Restangular: function () {
  15934. return options.templateOptions.Restangular;
  15935. },
  15936. APIService: function () {
  15937. return options.templateOptions.ApiService;
  15938. },
  15939. selectItems: function () {
  15940. return model || [];
  15941. },
  15942. },
  15943. });
  15944. modalInstance.result.then(
  15945. function (selectedItem) {
  15946. options.value(selectedItem);
  15947. options.formControl.$validate();
  15948. },
  15949. function () {
  15950. //console.log('Modal dismissed at: ' + new Date());
  15951. }
  15952. );
  15953. },
  15954. },
  15955. validators: {
  15956. required: {
  15957. expression: function (viewValue, modelValue) {
  15958. var value = modelValue || viewValue;
  15959. return value.length >= 1;
  15960. },
  15961. },
  15962. },
  15963. };
  15964. },
  15965. controller: [
  15966. "$scope",
  15967. function ($scope) {
  15968. $scope.model[$scope.options.key] = [];
  15969. $scope.remove = function (itemId) {
  15970. angular.forEach(
  15971. $scope.model[$scope.options.key],
  15972. function (entry, index) {
  15973. if (entry.id == itemId) {
  15974. $scope.model[$scope.options.key].splice(index, 1);
  15975. // console.log($scope.options.formControl)
  15976. $scope.options.formControl.$validate();
  15977. } else {
  15978. }
  15979. }
  15980. );
  15981. };
  15982. },
  15983. ],
  15984. });
  15985. //用户多选控件-字符串展示
  15986. formlyConfigProvider.setType({
  15987. name: "ui-stringuserselect",
  15988. extends: "input",
  15989. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  15990. defaultOptions: function (options) {
  15991. return {
  15992. templateOptions: {
  15993. translate: "",
  15994. refreshDelay: 0,
  15995. },
  15996. };
  15997. },
  15998. controller: [
  15999. "$scope",
  16000. function ($scope) {
  16001. var keydata = "";
  16002. if (angular.isArray($scope.model)) {
  16003. angular.forEach($scope.model, function (item) {
  16004. keydata = keydata + "," + item.name;
  16005. });
  16006. }
  16007. // $scope.model[$scope.options.key] = [];
  16008. },
  16009. ],
  16010. });
  16011. //重复事件
  16012. formlyConfigProvider.setType({
  16013. name: "ui-incidentmodelselect",
  16014. extends: "input",
  16015. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16016. defaultOptions: function (options) {
  16017. return {
  16018. templateOptions: {
  16019. openModal: function (size, options, modal) {
  16020. var modalInstance = modal.open({
  16021. templateUrl:
  16022. "assets/views/customform/tpl/checktable-modal-content.html",
  16023. controller: function (
  16024. $scope,
  16025. $rootScope,
  16026. $modalInstance,
  16027. items,
  16028. title,
  16029. Restangular,
  16030. APIService,
  16031. i18nService,
  16032. api_configure_data,
  16033. api_user_data,
  16034. api_bpm_data
  16035. ) {
  16036. $scope.langs = i18nService.getAllLangs();
  16037. $scope.lang = "zh-cn";
  16038. i18nService.setCurrentLang($scope.lang);
  16039. $scope.gridOptions = {};
  16040. $scope.gridOptions.data = "myData";
  16041. $scope.gridOptions.enableColumnResizing = true;
  16042. $scope.gridOptions.enableFiltering = true;
  16043. $scope.gridOptions.enableGridMenu = false;
  16044. $scope.gridOptions.enableRowSelection = true;
  16045. $scope.gridOptions.showGridFooter = true;
  16046. $scope.gridOptions.showColumnFooter = false;
  16047. $scope.gridOptions.fastWatch = true;
  16048. $scope.gridOptions.useExternalFiltering = true;
  16049. $scope.gridOptions.useExternalPagination = true;
  16050. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16051. $scope.gridOptions.paginationPageSize = 10;
  16052. $scope.gridOptions.multiSelect = false;
  16053. var mun = $scope.gridOptions.paginationPageSize;
  16054. $scope.gridOptions.rowIdentity = function (row) {
  16055. return row.id;
  16056. };
  16057. $scope.gridOptions.getRowIdentity = function (row) {
  16058. return row.id;
  16059. };
  16060. $scope.gridOptions.columnDefs = items.columnDefs();
  16061. $scope.transferTime = function (time) {
  16062. return moment(time).format("YYYY-MM-DD HH:mm");
  16063. };
  16064. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16065. $scope.gridApi = gridApi;
  16066. gridApi.pagination.on.paginationChanged(
  16067. $scope,
  16068. function (newPage, pageSize) {
  16069. // console.log(newPage);
  16070. // console.log(pageSize);
  16071. $scope.loadData({
  16072. idx: newPage - 1,
  16073. sum: pageSize,
  16074. });
  16075. }
  16076. );
  16077. gridApi.core.on.filterChanged($scope, function () {
  16078. var grid = this.grid;
  16079. var filtersData = {
  16080. idx: 0,
  16081. sum: 100,
  16082. };
  16083. angular.forEach(grid.columns, function (item) {
  16084. if (item.enableFiltering) {
  16085. if (
  16086. angular.isDefined(item.filters[0].term) &&
  16087. item.filters[0].term != ""
  16088. ) {
  16089. // console.log("filtersData="+JSON.stringify(filtersData))
  16090. if (angular.isUndefined(filtersData["incident"])) {
  16091. filtersData["incident"] = {};
  16092. }
  16093. filtersData["incident"][item.field] =
  16094. item.filters[0].term;
  16095. if (angular.isUndefined(filtersData["problem"])) {
  16096. filtersData["problem"] = {};
  16097. }
  16098. filtersData["problem"][item.field] =
  16099. item.filters[0].term;
  16100. if (angular.isUndefined(filtersData["change"])) {
  16101. filtersData["change"] = {};
  16102. }
  16103. filtersData["change"][item.field] =
  16104. item.filters[0].term;
  16105. if (angular.isUndefined(filtersData["release"])) {
  16106. filtersData["release"] = {};
  16107. }
  16108. filtersData["release"][item.field] =
  16109. item.filters[0].term;
  16110. }
  16111. }
  16112. });
  16113. $scope.loadData(filtersData);
  16114. });
  16115. gridApi.selection.on.rowSelectionChanged(
  16116. $scope,
  16117. function (data) {
  16118. $scope.selected.item = data.entity;
  16119. //console.log(data);
  16120. }
  16121. );
  16122. };
  16123. //资产
  16124. $scope.cmdb = {};
  16125. //资产状态
  16126. $scope.state_data = [
  16127. {
  16128. name: "全部状态",
  16129. value: "",
  16130. },
  16131. {
  16132. name: "在库",
  16133. value: "1",
  16134. },
  16135. {
  16136. name: "在线",
  16137. value: "2",
  16138. },
  16139. {
  16140. name: "借出",
  16141. value: "3",
  16142. },
  16143. {
  16144. name: "报修",
  16145. value: "4",
  16146. },
  16147. {
  16148. name: "报废",
  16149. value: "5",
  16150. },
  16151. {
  16152. name: "备用",
  16153. value: "6",
  16154. },
  16155. ];
  16156. //资产类型
  16157. $scope.wt_zcfl = function () {
  16158. api_configure_data
  16159. .fetchDataList("ciclassify", {
  16160. idx: 0,
  16161. sum: 100,
  16162. })
  16163. .then(function (data) {
  16164. console.log(data);
  16165. // $scope.wt_zclx = data.list;
  16166. console.log(data);
  16167. $scope.wtData = [];
  16168. if (data.status == 200) {
  16169. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  16170. var root = null; //Initially set our loop to null
  16171. var parentNode = null;
  16172. //loop over data
  16173. // $scope.wtData=data.list;
  16174. data = data.list;
  16175. //知识库分类数据三级处理
  16176. for (var i = 0; i < data.length; i++) {
  16177. // console.log(data[i])
  16178. var datum = data[i];
  16179. //each node will have children, so let's give it a "children" poperty
  16180. // console.log(datum);
  16181. datum.children = [];
  16182. if (!datum.parent) {
  16183. $scope.wtData.push(datum);
  16184. // console.log($scope.wtData)
  16185. } else {
  16186. if ($scope.wtData[0]) {
  16187. if ($scope.wtData[0].id == datum.parent.id) {
  16188. $scope.wtData[0].children.push(datum);
  16189. }
  16190. for (
  16191. var j = 0;
  16192. j < $scope.wtData[0].children.length;
  16193. j++
  16194. ) {
  16195. if (
  16196. $scope.wtData[0].children[j].id ==
  16197. datum.parent.id
  16198. ) {
  16199. $scope.wtData[0].children[j].children.push(
  16200. datum
  16201. );
  16202. }
  16203. }
  16204. }
  16205. if ($scope.wtData[1]) {
  16206. if ($scope.wtData[1].id == datum.parent.id) {
  16207. $scope.wtData[1].children.push(datum);
  16208. }
  16209. for (
  16210. var j = 0;
  16211. j < $scope.wtData[1].children.length;
  16212. j++
  16213. ) {
  16214. if (
  16215. $scope.wtData[1].children[j].id ==
  16216. datum.parent.id
  16217. ) {
  16218. $scope.wtData[1].children[j].children.push(
  16219. datum
  16220. );
  16221. }
  16222. }
  16223. }
  16224. if ($scope.wtData[2]) {
  16225. if ($scope.wtData[2].id == datum.parent.id) {
  16226. $scope.wtData[2].children.push(datum);
  16227. }
  16228. for (
  16229. var j = 0;
  16230. j < $scope.wtData[2].children.length;
  16231. j++
  16232. ) {
  16233. if (
  16234. $scope.wtData[2].children[j].id ==
  16235. datum.parent.id
  16236. ) {
  16237. $scope.wtData[2].children[j].children.push(
  16238. datum
  16239. );
  16240. }
  16241. }
  16242. }
  16243. }
  16244. // console.log($scope.wtData)
  16245. idToNodeMap[datum.id] = datum;
  16246. root = datum;
  16247. // treeMap[datum.id] = root;
  16248. }
  16249. }
  16250. });
  16251. };
  16252. $scope.wt_zcfl();
  16253. //事件
  16254. //受理人,处理人
  16255. $scope.searchkeys = {};
  16256. var fieldata = {
  16257. idx: 0,
  16258. sum: 100,
  16259. flag: -1,
  16260. };
  16261. getUser(fieldata, 3);
  16262. function getUser(fieldatas, it) {
  16263. api_user_data
  16264. .fetchDataList("user", fieldatas)
  16265. .then(function (data) {
  16266. if (it == 1) {
  16267. $scope.acceptUser = data.list;
  16268. } else if (it == 2) {
  16269. $scope.handlingPersonnelUser = data.list;
  16270. } else if (it == 3) {
  16271. $scope.acceptUser = data.list;
  16272. $scope.handlingPersonnelUser = data.list;
  16273. }
  16274. });
  16275. }
  16276. //状态
  16277. $scope.othcode = {};
  16278. api_bpm_data
  16279. .fetchDataList("incidentstatus", {
  16280. idx: 0,
  16281. sum: 100,
  16282. })
  16283. .then(function (response) {
  16284. if (response) {
  16285. if ((response.status = 200)) {
  16286. $scope.state = response.list;
  16287. }
  16288. }
  16289. });
  16290. var defaultFilterData = {
  16291. assignee: $rootScope.user.id,
  16292. searchType: "todo",
  16293. idx: 0,
  16294. sum: mun,
  16295. };
  16296. var defaultFilterData1 = {
  16297. // "searchType": "todo",
  16298. idx: 0,
  16299. sum: mun,
  16300. };
  16301. //搜索
  16302. $scope.chiceIncident = function (parameters, item, stateid) {
  16303. console.log(item, stateid);
  16304. console.log($scope);
  16305. if ($scope.title == "关联资产编号") {
  16306. // alert('222222222222');
  16307. var fildata = defaultFilterData1;
  16308. $scope.gridOptions.paginationCurrentPage = 1;
  16309. var transitiondata = angular.copy(item);
  16310. angular.extend(fildata, transitiondata);
  16311. if (fildata.hw_state) {
  16312. fildata.hw_state = fildata.hw_state.name;
  16313. }
  16314. if (fildata.sign) {
  16315. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  16316. fildata.sign = fildata.sign.split(";");
  16317. fildata.sign = fildata.sign.join("");
  16318. fildata.sign = fildata.sign.toLowerCase();
  16319. }
  16320. if (fildata.keys) {
  16321. fildata["searchCriteria"] = "uuid";
  16322. }
  16323. console.log(fildata);
  16324. $scope.loadData(fildata);
  16325. }
  16326. if ($scope.title == "关联事件工单") {
  16327. // alert('3333333333333333')
  16328. if (stateid && stateid.code) {
  16329. item.statusId = stateid.code;
  16330. }
  16331. var fildata = defaultFilterData;
  16332. // $scope.memoryfilterData = fildata;
  16333. if (!fildata.incident) {
  16334. fildata["incident"] = {};
  16335. }
  16336. $scope.gridOptions.paginationCurrentPage = 1;
  16337. var transitiondata = angular.copy(item);
  16338. angular.extend(fildata.incident, transitiondata);
  16339. console.log(fildata);
  16340. // $scope.loadData(fildata);
  16341. api_bpm_data
  16342. .fetchDataList("incident", fildata)
  16343. .then(function (data) {
  16344. console.log(data);
  16345. if (data) {
  16346. $scope.myData = data.list;
  16347. $scope.gridOptions.totalItems = data.totalNum;
  16348. }
  16349. });
  16350. }
  16351. };
  16352. //重置
  16353. $scope.replacement = function (
  16354. parameters,
  16355. searchkeys,
  16356. othcode
  16357. ) {
  16358. // console.log(parameters, searchkeys, othcode);
  16359. delete defaultFilterData.incident;
  16360. console.log(defaultFilterData);
  16361. $scope.parameters = null;
  16362. $scope.searchkeys = {};
  16363. $scope.othcode = {};
  16364. $scope.wt_zcfl();
  16365. };
  16366. $scope.loadData = function (filterData) {
  16367. items
  16368. .fetchItems(filterData, APIService, $rootScope)
  16369. .then(function (data) {
  16370. var myData = Restangular.stripRestangular(data);
  16371. if (myData.data && myData.data.node) {
  16372. $scope.gridOptions.totalItems = myData.total;
  16373. $scope.myData = myData.data.node;
  16374. } else {
  16375. if (myData.resultCount) {
  16376. $scope.gridOptions["totalItems"] = myData.resultCount;
  16377. } else {
  16378. $scope.gridOptions.totalItems = myData.totalNum;
  16379. }
  16380. if (myData.list) {
  16381. $scope.myData = myData.list;
  16382. } else {
  16383. $scope.myData = myData.data;
  16384. }
  16385. }
  16386. });
  16387. };
  16388. $scope.title = title;
  16389. $scope.loadData({
  16390. idx: 0,
  16391. sum: 10,
  16392. });
  16393. $scope.selected = {
  16394. item: {},
  16395. };
  16396. $scope.ok = function () {
  16397. //console.log($scope.selected.item);
  16398. $modalInstance.close($scope.selected.item);
  16399. };
  16400. $scope.cancel = function () {
  16401. $modalInstance.dismiss("cancel");
  16402. };
  16403. },
  16404. size: size,
  16405. resolve: {
  16406. items: function () {
  16407. return {
  16408. fetchItems: function (filterData, APIService, $rootScope) {
  16409. filterData = filterData || {};
  16410. // if(!filterData.idx){
  16411. if (
  16412. angular.isDefined(filterData.idx) &&
  16413. filterData.idx == null
  16414. ) {
  16415. filterData = {
  16416. idx: 0,
  16417. sum: 10,
  16418. };
  16419. }
  16420. return options.templateOptions.fetchItems(
  16421. filterData,
  16422. APIService,
  16423. $rootScope
  16424. );
  16425. },
  16426. columnDefs: function () {
  16427. return options.templateOptions.columnDefs;
  16428. },
  16429. };
  16430. },
  16431. title: function () {
  16432. return options.templateOptions.modalTitle;
  16433. },
  16434. Restangular: function () {
  16435. return options.templateOptions.Restangular;
  16436. },
  16437. APIService: function () {
  16438. return options.templateOptions.ApiService;
  16439. },
  16440. },
  16441. });
  16442. modalInstance.result.then(
  16443. function (selectedItem) {
  16444. var selectitem = {
  16445. title: selectedItem.title,
  16446. description: selectedItem.description,
  16447. };
  16448. if (options.key == "chuku") {
  16449. if (selectedItem.assets) {
  16450. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  16451. selectedItem.assets;
  16452. }
  16453. if (selectedItem.consumables) {
  16454. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  16455. selectedItem.consumables;
  16456. }
  16457. angular.extend(
  16458. $scope.$parent.$parent.$parent.model,
  16459. selectitem
  16460. );
  16461. options.value(selectedItem);
  16462. // options.model.consumables = JSON.parse(consumables);
  16463. } else if (options.templateOptions.pkey == "change") {
  16464. console.log(options);
  16465. angular.extend(options.model);
  16466. options.value(selectedItem);
  16467. } else if (options.key == "cmdbCode") {
  16468. var zc_selectitem = selectedItem.uuid;
  16469. // angular.extend(options.model,zc_selectitem);
  16470. options.model.cmdbCode = zc_selectitem;
  16471. // angular.extend(options.model,zc_selectitem);
  16472. // options.templateOptions.displayName=zc_selectitem;
  16473. options.value(selectedItem);
  16474. console.log(options.model);
  16475. } else {
  16476. angular.extend(options.model, selectitem);
  16477. options.value(selectedItem);
  16478. }
  16479. },
  16480. function () {
  16481. //console.log('Modal dismissed at: ' + new Date());
  16482. }
  16483. );
  16484. },
  16485. },
  16486. };
  16487. },
  16488. });
  16489. //选项选择控件
  16490. formlyConfigProvider.setType({
  16491. name: "ui-modelselect",
  16492. extends: "input",
  16493. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16494. defaultOptions: function (options) {
  16495. return {
  16496. templateOptions: {
  16497. openModal: function (size, options, modal) {
  16498. var modalInstance = modal.open({
  16499. templateUrl:
  16500. "assets/views/customform/tpl/checktable-modal-content.html",
  16501. controller: function (
  16502. $scope,
  16503. $modalInstance,
  16504. items,
  16505. title,
  16506. Restangular,
  16507. APIService,
  16508. i18nService
  16509. ) {
  16510. $scope.langs = i18nService.getAllLangs();
  16511. $scope.lang = "zh-cn";
  16512. i18nService.setCurrentLang($scope.lang);
  16513. $scope.gridOptions = {};
  16514. $scope.gridOptions.data = "myData";
  16515. $scope.gridOptions.enableColumnResizing = true;
  16516. $scope.gridOptions.enableFiltering = true;
  16517. $scope.gridOptions.enableGridMenu = false;
  16518. $scope.gridOptions.enableRowSelection = true;
  16519. $scope.gridOptions.showGridFooter = true;
  16520. $scope.gridOptions.showColumnFooter = true;
  16521. $scope.gridOptions.fastWatch = true;
  16522. $scope.gridOptions.useExternalFiltering = true;
  16523. $scope.gridOptions.useExternalPagination = true;
  16524. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16525. $scope.gridOptions.paginationPageSize = 10;
  16526. $scope.gridOptions.multiSelect = false;
  16527. $scope.gridOptions.rowIdentity = function (row) {
  16528. return row.id;
  16529. };
  16530. $scope.gridOptions.getRowIdentity = function (row) {
  16531. return row.id;
  16532. };
  16533. $scope.gridOptions.columnDefs = items.columnDefs();
  16534. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16535. $scope.gridApi = gridApi;
  16536. gridApi.pagination.on.paginationChanged(
  16537. $scope,
  16538. function (newPage, pageSize) {
  16539. // console.log(newPage);
  16540. // console.log(pageSize);
  16541. $scope.loadData({
  16542. idx: newPage - 1,
  16543. sum: pageSize,
  16544. });
  16545. }
  16546. );
  16547. gridApi.core.on.filterChanged($scope, function () {
  16548. var grid = this.grid;
  16549. var filtersData = {
  16550. idx: 0,
  16551. sum: 10,
  16552. };
  16553. angular.forEach(grid.columns, function (item) {
  16554. if (item.enableFiltering) {
  16555. if (
  16556. angular.isDefined(item.filters[0].term) &&
  16557. item.filters[0].term != ""
  16558. ) {
  16559. // console.log("filtersData="+JSON.stringify(filtersData))
  16560. if (angular.isUndefined(filtersData["incident"])) {
  16561. filtersData["incident"] = {};
  16562. }
  16563. filtersData["incident"][item.field] =
  16564. item.filters[0].term;
  16565. if (angular.isUndefined(filtersData["problem"])) {
  16566. filtersData["problem"] = {};
  16567. }
  16568. filtersData["problem"][item.field] =
  16569. item.filters[0].term;
  16570. if (angular.isUndefined(filtersData["change"])) {
  16571. filtersData["change"] = {};
  16572. }
  16573. filtersData["change"][item.field] =
  16574. item.filters[0].term;
  16575. if (angular.isUndefined(filtersData["release"])) {
  16576. filtersData["release"] = {};
  16577. }
  16578. filtersData["release"][item.field] =
  16579. item.filters[0].term;
  16580. }
  16581. }
  16582. });
  16583. $scope.loadData(filtersData);
  16584. });
  16585. gridApi.selection.on.rowSelectionChanged(
  16586. $scope,
  16587. function (data) {
  16588. $scope.selected.item = data.entity;
  16589. //console.log(data);
  16590. }
  16591. );
  16592. };
  16593. $scope.loadData = function (filterData) {
  16594. items
  16595. .fetchItems(filterData, APIService)
  16596. .then(function (data) {
  16597. var myData = Restangular.stripRestangular(data);
  16598. $scope.gridOptions.totalItems = myData.totalNum;
  16599. $scope.myData = myData.list;
  16600. });
  16601. };
  16602. $scope.title = title;
  16603. $scope.loadData({
  16604. idx: 0,
  16605. sum: 10,
  16606. });
  16607. $scope.selected = {
  16608. item: {},
  16609. };
  16610. $scope.ok = function () {
  16611. if ($scope.selected.item.scheduleOrder) {
  16612. $scope.selected.item.descriptionData =
  16613. "日期:" +
  16614. $scope.selected.item.watchTime +
  16615. ";" +
  16616. "班次:" +
  16617. $scope.selected.item.scheduleOrder.description +
  16618. ";" +
  16619. "值班人:" +
  16620. $scope.selected.item.scheduleOrder.users[0].name;
  16621. }
  16622. //console.log($scope.selected.item);
  16623. $modalInstance.close($scope.selected.item);
  16624. };
  16625. $scope.cancel = function () {
  16626. $modalInstance.dismiss("cancel");
  16627. };
  16628. },
  16629. size: size,
  16630. resolve: {
  16631. items: function () {
  16632. return {
  16633. fetchItems: function (filterData, APIService) {
  16634. filterData = filterData || {};
  16635. // if(!filterData.idx){
  16636. if (
  16637. angular.isDefined(filterData.idx) &&
  16638. filterData.idx == null
  16639. ) {
  16640. filterData = {
  16641. idx: 0,
  16642. sum: 10,
  16643. };
  16644. }
  16645. return options.templateOptions.fetchItems(
  16646. filterData,
  16647. APIService,
  16648. options
  16649. );
  16650. },
  16651. columnDefs: function () {
  16652. return options.templateOptions.columnDefs;
  16653. },
  16654. };
  16655. },
  16656. title: function () {
  16657. return options.templateOptions.modalTitle;
  16658. },
  16659. Restangular: function () {
  16660. return options.templateOptions.Restangular;
  16661. },
  16662. APIService: function () {
  16663. return options.templateOptions.ApiService;
  16664. },
  16665. },
  16666. });
  16667. modalInstance.result.then(
  16668. function (selectedItem) {
  16669. options.value(selectedItem);
  16670. },
  16671. function () {
  16672. //console.log('Modal dismissed at: ' + new Date());
  16673. }
  16674. );
  16675. },
  16676. },
  16677. };
  16678. },
  16679. });
  16680. formlyConfigProvider.setType({
  16681. name: "ui-requestform",
  16682. extends: "input",
  16683. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  16684. controller: [
  16685. "$scope",
  16686. function ($scope) {
  16687. setTimeout(function () {
  16688. var filterData = {
  16689. idx: 0,
  16690. sum: 5,
  16691. incident: {
  16692. requester: {
  16693. id: "",
  16694. },
  16695. },
  16696. };
  16697. $scope.options.templateOptions
  16698. .getWorkernumber(
  16699. $scope.options.templateOptions.ApiService,
  16700. filterData
  16701. )
  16702. .then(function (result) {
  16703. var modelData =
  16704. $scope.options.templateOptions.Restangular.stripRestangular(
  16705. result
  16706. );
  16707. });
  16708. }, 1000);
  16709. },
  16710. ],
  16711. });
  16712. //报修图片展示
  16713. formlyConfigProvider.setType({
  16714. name: "ui-repair-photos",
  16715. // extends: 'label',
  16716. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  16717. controller: [
  16718. "$scope",
  16719. "api_wechatfile",
  16720. "$stateParams",
  16721. function ($scope, api_wechatfile, $stateParams) {
  16722. console.log($scope);
  16723. $scope.fileUrls = [];
  16724. if ($scope.model.wxFile) {
  16725. api_wechatfile
  16726. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  16727. .then(function (res) {
  16728. $scope.fileUrls = res.data;
  16729. });
  16730. }
  16731. console.log($stateParams);
  16732. if (
  16733. $stateParams &&
  16734. $stateParams.model &&
  16735. JSON.parse($stateParams.model) &&
  16736. JSON.parse($stateParams.model).model &&
  16737. JSON.parse($stateParams.model).model.flow
  16738. ) {
  16739. api_wechatfile
  16740. .listAttachment(
  16741. "wechatRequesterIncident",
  16742. JSON.parse($stateParams.model).model.flow
  16743. )
  16744. .then(function (res) {
  16745. $scope.fileUrls = res.data;
  16746. });
  16747. }
  16748. if ($scope.model.flow) {
  16749. api_wechatfile
  16750. .listAttachment("wechatRequesterIncident", $scope.model.flow)
  16751. .then(function (res) {
  16752. $scope.fileUrls = res.data;
  16753. });
  16754. }
  16755. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  16756. // // setTimeout(function () {
  16757. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  16758. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  16759. // // if (modelData.status == 200) {
  16760. // // $scope.model[$scope.options.key] = modelData.data;
  16761. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  16762. // // }
  16763. // // });
  16764. // // }, 1000);
  16765. // }
  16766. $scope.showBigImg = false;
  16767. $scope.showBigImgCli = function (data) {
  16768. $scope.showBigImg = true;
  16769. $scope.bigImgUrl = data;
  16770. };
  16771. $scope.closeBigImg = function () {
  16772. $scope.showBigImg = false;
  16773. };
  16774. },
  16775. ],
  16776. });
  16777. //图片展示
  16778. formlyConfigProvider.setType({
  16779. name: "ui-showImgs",
  16780. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  16781. defaultOptions: function (options) {
  16782. return {
  16783. templateOptions: {
  16784. refresh: function (APIService, processInstanceId, data) {
  16785. return APIService.listAttachments(processInstanceId);
  16786. },
  16787. downloadUri: function (APIService, contentId) {
  16788. return APIService.downloadAttachment(contentId).getRequestedUrl();
  16789. },
  16790. view: function (APIService, contentId) {
  16791. return APIService.attachmentsPreviewUrl(contentId);
  16792. },
  16793. download: function (APIService, contentId, item) {
  16794. var item = {
  16795. url: APIService.download(contentId),
  16796. headers: headers,
  16797. };
  16798. return item;
  16799. },
  16800. refreshDelay: 0,
  16801. },
  16802. };
  16803. },
  16804. controller: [
  16805. "$scope",
  16806. "$timeout",
  16807. "$modal",
  16808. "$rootScope",
  16809. "$http",
  16810. "up_down_file",
  16811. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  16812. var _refreshDelayPromise;
  16813. /**
  16814. * refresh
  16815. */
  16816. $scope._refresh = function (refreshAttr) {
  16817. $scope.attachments = [];
  16818. if (refreshAttr !== undefined) {
  16819. if (_refreshDelayPromise) {
  16820. $timeout.cancel(_refreshDelayPromise);
  16821. }
  16822. _refreshDelayPromise = $timeout(function () {
  16823. // 暂存附件
  16824. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  16825. $scope.options.templateOptions
  16826. .refresh(
  16827. $scope.options.templateOptions.ApiService,
  16828. $scope.options.templateOptions.processInstanceId,
  16829. {
  16830. idx: 0,
  16831. sum: 1000,
  16832. }
  16833. )
  16834. .then(function (response) {
  16835. var myData =
  16836. $scope.options.templateOptions.Restangular.stripRestangular(
  16837. response
  16838. );
  16839. if (myData) {
  16840. for (var i = 0; i < myData.data.length; i++) {
  16841. $scope.attachments.push(myData.data[i]);
  16842. }
  16843. }
  16844. $scope.options.templateOptions
  16845. .refresh(
  16846. $scope.options.templateOptions.ApiService,
  16847. $scope.$parent.$parent.$parent.model.save_fileId,
  16848. {
  16849. idx: 0,
  16850. sum: 1000,
  16851. }
  16852. )
  16853. .then(function (response2) {
  16854. var myData2 =
  16855. $scope.options.templateOptions.Restangular.stripRestangular(
  16856. response2
  16857. );
  16858. if (myData2) {
  16859. for (var i = 0; i < myData2.data.length; i++) {
  16860. $scope.attachments.push(myData2.data[i]);
  16861. }
  16862. }
  16863. console.log($scope.attachments);
  16864. });
  16865. });
  16866. // 正常附件
  16867. } else {
  16868. $scope.options.templateOptions
  16869. .refresh(
  16870. $scope.options.templateOptions.ApiService,
  16871. $scope.options.templateOptions.processInstanceId,
  16872. {
  16873. idx: 0,
  16874. sum: 1000,
  16875. }
  16876. )
  16877. .then(function (response) {
  16878. var myData =
  16879. $scope.options.templateOptions.Restangular.stripRestangular(
  16880. response
  16881. );
  16882. if (myData) {
  16883. $scope.attachments = [];
  16884. $scope.imgs = [];
  16885. myData.data.forEach((e) => {
  16886. if (
  16887. e.suffix == "jpeg" ||
  16888. e.suffix == "jpg" ||
  16889. e.suffix == "svg" ||
  16890. e.suffix == "png" ||
  16891. e.suffix == "bmp" ||
  16892. e.suffix == "gif" ||
  16893. e.suffix == "tif"
  16894. ) {
  16895. $scope.imgs.push(e);
  16896. }
  16897. });
  16898. $scope.imgs = $scope.imgs.splice(0, 3);
  16899. console.log($scope.imgs);
  16900. }
  16901. });
  16902. }
  16903. }, $scope.options.templateOptions.refreshDelay);
  16904. }
  16905. };
  16906. $scope._refresh({});
  16907. // $scope.attachments = $scope.model[$scope.options.key]
  16908. // 预览
  16909. $scope.preview = function (url, idx) {
  16910. var title = $scope.imgs[idx].title;
  16911. $modal.open({
  16912. backdrop: false,
  16913. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  16914. controller: function ($scope, scope, $modalInstance) {
  16915. $scope.title = title;
  16916. $scope.imageurl = url;
  16917. $scope.cancel = function () {
  16918. $modalInstance.dismiss("cancel");
  16919. };
  16920. },
  16921. resolve: {
  16922. scope: function () {
  16923. return $scope;
  16924. },
  16925. },
  16926. });
  16927. };
  16928. },
  16929. ],
  16930. });
  16931. //工单/受理人控件
  16932. formlyConfigProvider.setType({
  16933. name: "ui-workernumbersign",
  16934. // extends: 'label',
  16935. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  16936. controller: [
  16937. "$scope",
  16938. function ($scope) {
  16939. // 2020年4月24日13:20:40
  16940. console.log($scope, "docu");
  16941. // 左侧事件工单区域地点填充
  16942. $scope.model.selecthouseNumber = $scope.model.place;
  16943. if (
  16944. angular.isUndefined($scope.model[$scope.options.key]) ||
  16945. $scope.model[$scope.options.key] == null
  16946. ) {
  16947. setTimeout(function () {
  16948. $scope.options.templateOptions
  16949. .getWorkernumber($scope.options.templateOptions.ApiService)
  16950. .then(function (result) {
  16951. var modelData =
  16952. $scope.options.templateOptions.Restangular.stripRestangular(
  16953. result
  16954. );
  16955. if (modelData.status == 200) {
  16956. $scope.model[$scope.options.key] = modelData.data;
  16957. $scope.options.initialValue =
  16958. $scope.model[$scope.options.key];
  16959. }
  16960. });
  16961. }, 1000);
  16962. }
  16963. if (
  16964. $scope.options.templateOptions.user &&
  16965. (angular.isUndefined($scope.model.acceptUser) ||
  16966. $scope.model.acceptUser == null)
  16967. ) {
  16968. if (angular.isFunction($scope.options.templateOptions.transform)) {
  16969. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  16970. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  16971. // }
  16972. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16973. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16974. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  16975. }
  16976. $scope.model.acceptUser = $scope.options.templateOptions.user;
  16977. // $scope.options.initialValue = $scope.model.acceptUser;
  16978. }
  16979. },
  16980. ],
  16981. });
  16982. //工单控件-only number
  16983. formlyConfigProvider.setType({
  16984. name: "ui-workernumber",
  16985. extends: "input",
  16986. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  16987. controller: [
  16988. "$scope",
  16989. function ($scope) {
  16990. if (
  16991. angular.isUndefined($scope.model[$scope.options.key]) ||
  16992. $scope.model[$scope.options.key] == null
  16993. ) {
  16994. setTimeout(function () {
  16995. $scope.options.templateOptions
  16996. .getWorkernumber($scope.options.templateOptions.ApiService)
  16997. .then(function (result) {
  16998. var modelData =
  16999. $scope.options.templateOptions.Restangular.stripRestangular(
  17000. result
  17001. );
  17002. if (modelData.status == 200) {
  17003. $scope.model[$scope.options.key] = modelData.data;
  17004. $scope.options.initialValue =
  17005. $scope.model[$scope.options.key];
  17006. }
  17007. });
  17008. }, 1000);
  17009. }
  17010. },
  17011. ],
  17012. });
  17013. //cmdb工单
  17014. formlyConfigProvider.setType({
  17015. name: "ui-cmdbworkernumber",
  17016. extends: "input",
  17017. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17018. controller: [
  17019. "$scope",
  17020. function ($scope) {
  17021. if (
  17022. angular.isUndefined($scope.model[$scope.options.key]) ||
  17023. $scope.model[$scope.options.key] == null
  17024. ) {
  17025. setTimeout(function () {
  17026. $scope.options.templateOptions
  17027. .getWorkernumber(
  17028. $scope.options.templateOptions.ApiService,
  17029. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  17030. .cifilter_classics.id
  17031. )
  17032. .then(function (result) {
  17033. var modelData =
  17034. $scope.options.templateOptions.Restangular.stripRestangular(
  17035. result
  17036. );
  17037. // if(modelData.status==200){
  17038. $scope.model[$scope.options.key] =
  17039. modelData[$scope.options.key];
  17040. $scope.options.initialValue = $scope.model[$scope.options.key];
  17041. // }
  17042. });
  17043. }, 1000);
  17044. }
  17045. },
  17046. ],
  17047. });
  17048. //简易上传图片组件
  17049. formlyConfigProvider.setType({
  17050. name: "ui-uploadImgs",
  17051. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  17052. wrapper: ["bootstrapHasError"],
  17053. controller: [
  17054. "$scope",
  17055. "fileReader",
  17056. "$parse",
  17057. "$modal",
  17058. function ($scope, fileReader, $parse, $modal) {
  17059. $scope.imgshows = [];
  17060. $scope.uploadimgs = [];
  17061. var model = $parse("upload_img");
  17062. var modelSetter = model.assign;
  17063. var uploader = ($scope.uploader =
  17064. $scope.options.templateOptions.fileUploader);
  17065. uploader.filters.push({
  17066. name: "customFilter",
  17067. fn: function (item /*{File|FileLikeObject}*/, options) {
  17068. return this.queue.length < 10;
  17069. },
  17070. });
  17071. // 添加
  17072. $scope.change = function (event) {
  17073. var element = $(".upinp");
  17074. modelSetter($scope, element[0].files[0]);
  17075. //附件预览
  17076. $scope.imgupload = event.files[0];
  17077. getFile($scope.imgupload, $scope);
  17078. //获得预览图地址并且把file对象放入上传合集内
  17079. function getFile(imgupload, $scope) {
  17080. if (!imgupload) {
  17081. return;
  17082. }
  17083. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  17084. $scope.imgshows.push(result);
  17085. var file = document.querySelector("input[type=file]").files[0];
  17086. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  17087. console.log($scope.imgshows, $scope.uploadimgs);
  17088. if ($scope.imgshows.length < 3) {
  17089. $("#upup").show();
  17090. } else {
  17091. $("#upup").hide();
  17092. }
  17093. });
  17094. }
  17095. };
  17096. // 删除
  17097. $scope.uploadimg_del = function (index, imgs) {
  17098. console.log(index, imgs);
  17099. $scope.imgshows.splice(index, 1);
  17100. $scope.uploadimgs.splice(index, 1);
  17101. if ($scope.imgshows.length < 3) {
  17102. $("#upup").show();
  17103. } else {
  17104. $("#upup").hide();
  17105. }
  17106. };
  17107. // 预览
  17108. $scope.preview = function (url, idx) {
  17109. var name = $scope.uploadimgs[idx].name;
  17110. $modal.open({
  17111. backdrop: false,
  17112. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17113. controller: function ($scope, scope, $modalInstance) {
  17114. $scope.title = name;
  17115. $scope.imageurl = url;
  17116. $scope.cancel = function () {
  17117. $modalInstance.dismiss("cancel");
  17118. };
  17119. },
  17120. resolve: {
  17121. scope: function () {
  17122. return $scope;
  17123. },
  17124. },
  17125. });
  17126. };
  17127. if (uploader) {
  17128. uploader.onWhenAddingFileFailed = function (
  17129. item /*{File|FileLikeObject}*/,
  17130. filter,
  17131. options
  17132. ) {
  17133. console.info("onWhenAddingFileFailed", item, filter, options);
  17134. };
  17135. uploader.onAfterAddingFile = function (fileItem) {
  17136. console.info("onAfterAddingFile", fileItem);
  17137. };
  17138. uploader.onAfterAddingAll = function (addedFileItems) {
  17139. console.info("onAfterAddingAll", addedFileItems);
  17140. };
  17141. uploader.onBeforeUploadItem = function (item) {
  17142. console.info("onBeforeUploadItem", item);
  17143. };
  17144. uploader.onProgressItem = function (fileItem, progress) {
  17145. console.info("onProgressItem", fileItem, progress);
  17146. };
  17147. uploader.onProgressAll = function (progress) {
  17148. console.info("onProgressAll", progress);
  17149. };
  17150. uploader.onSuccessItem = function (
  17151. fileItem,
  17152. response,
  17153. status,
  17154. headers
  17155. ) {
  17156. console.info("onSuccessItem", fileItem, response, status, headers);
  17157. };
  17158. uploader.onErrorItem = function (
  17159. fileItem,
  17160. response,
  17161. status,
  17162. headers
  17163. ) {
  17164. console.info("onErrorItem", fileItem, response, status, headers);
  17165. };
  17166. uploader.onCancelItem = function (
  17167. fileItem,
  17168. response,
  17169. status,
  17170. headers
  17171. ) {
  17172. console.info("onCancelItem", fileItem, response, status, headers);
  17173. };
  17174. uploader.onCompleteItem = function (
  17175. fileItem,
  17176. response,
  17177. status,
  17178. headers
  17179. ) {
  17180. console.info("onCompleteItem", fileItem, response, status, headers);
  17181. };
  17182. uploader.onCompleteAll = function () {
  17183. console.info("onCompleteAll");
  17184. };
  17185. }
  17186. // console.log(modelSetter)
  17187. },
  17188. ],
  17189. });
  17190. //jry-上传下载一体
  17191. formlyConfigProvider.setType({
  17192. name: "ui-upDropFile",
  17193. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  17194. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17195. defaultOptions: function (options) {
  17196. return {
  17197. templateOptions: {
  17198. view: function (APIService, contentId) {
  17199. return APIService.downloadAttachment(contentId);
  17200. },
  17201. // ApiService: 'api_wechatfile',
  17202. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  17203. // upUrl: 'common/common/uploadAttachment',
  17204. // listAttachmentUrl: 'common/common/listAttachment',
  17205. // downUrl: 'common/common/downloadAttachment',
  17206. // bindType: 'incident',
  17207. // bindId: 2323
  17208. },
  17209. // validators: {
  17210. // required: {
  17211. // expression: function(viewValue, modelValue) {
  17212. // var value = modelValue || viewValue;
  17213. // return value.length >= 1;
  17214. // }
  17215. // }
  17216. // }
  17217. };
  17218. },
  17219. controller: [
  17220. "$scope",
  17221. "$rootScope",
  17222. "Restangular",
  17223. "up_down_file",
  17224. "$http",
  17225. "api_bpm",
  17226. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  17227. console.log($scope);
  17228. $scope.showFileUp = true;
  17229. if ($scope.model.isKnowledge_detail) {
  17230. $scope.showFileUp = false;
  17231. }
  17232. if (angular.isUndefined($scope.form.dropState)) {
  17233. $scope.form.dropState = false;
  17234. }
  17235. if ($scope.model.incident) {
  17236. if ($scope.model.incident.alarm) {
  17237. console.log($scope);
  17238. if ($scope.model.incident.alarm) {
  17239. if ($scope.model.incident.alarm.alarmExtension) {
  17240. $scope.model.incident.alarm.alarmExtension =
  17241. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  17242. $scope.model.incident.alarm.alarmExtension =
  17243. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  17244. $scope.model.incident.description =
  17245. $scope.model.incident.alarm.alarmExtension;
  17246. console.log($scope.model.incident.description);
  17247. $scope.model.incident.description =
  17248. '"' +
  17249. "告警名称" +
  17250. '":' +
  17251. '"' +
  17252. $scope.model.incident.alarm.alarmSystem +
  17253. '",' +
  17254. '"' +
  17255. "告警状态" +
  17256. '":' +
  17257. '"' +
  17258. $scope.model.incident.alarm.alarmStatus +
  17259. '",' +
  17260. '"' +
  17261. "告警内容" +
  17262. '":' +
  17263. '"' +
  17264. $scope.model.incident.alarm.alarmContent +
  17265. '",' +
  17266. $scope.model.incident.description;
  17267. } else {
  17268. $scope.model.incident.description =
  17269. '"' +
  17270. "告警名称" +
  17271. '":' +
  17272. '"' +
  17273. $scope.model.incident.alarm.alarmSystem +
  17274. '",' +
  17275. '"' +
  17276. "告警状态" +
  17277. '":' +
  17278. '"' +
  17279. $scope.model.incident.alarm.alarmStatus +
  17280. '",' +
  17281. '"' +
  17282. "告警内容" +
  17283. '":' +
  17284. '"' +
  17285. $scope.model.incident.alarm.alarmContent +
  17286. '",';
  17287. }
  17288. $scope.model.incident.description =
  17289. $scope.model.incident.description.replace(/,/g, "\n");
  17290. console.log($scope.model.incident.description);
  17291. }
  17292. }
  17293. api_bpm
  17294. .tellCategory($scope.model.incident.category.id)
  17295. .then(function (wt_data) {
  17296. console.log(wt_data);
  17297. if (wt_data) {
  17298. $rootScope.wt_category = wt_data.data;
  17299. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  17300. $rootScope.wt_child = wt_data.child;
  17301. }
  17302. });
  17303. if ($scope.model.titleName == "接单") {
  17304. $scope.model.receive_code = "handler";
  17305. if (
  17306. $scope.model.incident.groupLeader &&
  17307. !$scope.model.incident.repeat
  17308. ) {
  17309. $scope.model.isHandlerUser = true;
  17310. }
  17311. }
  17312. if ($scope.model.titleName == "事件处理") {
  17313. console.log($scope.model.cmdbCode);
  17314. if ($scope.model.cmdbCode) {
  17315. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  17316. }
  17317. }
  17318. } else {
  17319. $rootScope.wt_category = "";
  17320. }
  17321. //附件上传数据
  17322. if ($scope.options.templateOptions.fileUploader) {
  17323. var uploader = ($scope.uploader =
  17324. $scope.options.templateOptions.fileUploader);
  17325. //$scope.options.templateOptions.uploader();
  17326. console.log(uploader);
  17327. // FILTERS
  17328. uploader.filters.push({
  17329. name: "customFilter",
  17330. fn: function (item /*{File|FileLikeObject}*/, options) {
  17331. return this.queue.length < 10;
  17332. },
  17333. });
  17334. }
  17335. var to = $scope.options.templateOptions;
  17336. // var bindType = $scope.model.bindType;
  17337. if (to.bindType == "incident") {
  17338. var bindId = $scope.model[to.bindType].processInstanceId;
  17339. } else if (to.bindType == "change") {
  17340. var bindId = $scope.model[to.bindType].processInstanceId;
  17341. } else {
  17342. var bindId = $scope.model[to.bindType].id;
  17343. }
  17344. //获取附件列表
  17345. $scope.listAttachmen = function () {
  17346. to.ApiService.listAttachment(
  17347. to.listAttachmentUrl,
  17348. to.bindType,
  17349. bindId
  17350. ).then(function (result) {
  17351. var myData = Restangular.stripRestangular(result);
  17352. // $scope.listAttachmens = myData;
  17353. $scope.attachments = myData.data;
  17354. });
  17355. };
  17356. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  17357. $scope.listAttachmen();
  17358. } else if (to.bindType && $scope.model[to.bindType].id) {
  17359. $scope.listAttachmen();
  17360. }
  17361. //附件上传
  17362. $scope.isUpfload = to.isUpfload;
  17363. $scope.dropfile = function (
  17364. APIService,
  17365. processInstanceId,
  17366. taskId,
  17367. userId
  17368. ) {
  17369. uploader.onBeforeUploadItem = function (item) {
  17370. angular.extend(item.headers, $rootScope.getSession());
  17371. item.url = to.ApiService.saveAttachments(
  17372. to.uploadUrl,
  17373. to.bindType,
  17374. bindId
  17375. ).getRequestedUrl();
  17376. item.formData.push({
  17377. filename: item.file.name,
  17378. });
  17379. };
  17380. uploader.uploadAll();
  17381. };
  17382. //附件下载
  17383. $scope.download = function (token, filename) {
  17384. var downUrl = to.ApiService.downloadAttachment(
  17385. to.downUrl,
  17386. token
  17387. ).getRequestedUrl();
  17388. // window.open(downUrl);
  17389. var a = document.createElement("a");
  17390. a.href = downUrl;
  17391. a.target = "_blank";
  17392. a.download = filename;
  17393. document.body.appendChild(a);
  17394. a.click();
  17395. };
  17396. //附件预览
  17397. $scope.view = function (id, previewUrl) {
  17398. if (previewUrl) {
  17399. window.open(previewUrl);
  17400. }
  17401. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  17402. // if (response.state == 200) {
  17403. // window.open(response.previewUrl);
  17404. // }
  17405. // })
  17406. };
  17407. // CALLBACKS
  17408. if (uploader) {
  17409. uploader.onWhenAddingFileFailed = function (
  17410. item /*{File|FileLikeObject}*/,
  17411. filter,
  17412. options
  17413. ) {
  17414. console.info("onWhenAddingFileFailed", item, filter, options);
  17415. };
  17416. uploader.onAfterAddingFile = function (fileItem) {
  17417. console.info("onAfterAddingFile", fileItem);
  17418. };
  17419. uploader.onAfterAddingAll = function (addedFileItems) {
  17420. console.info("onAfterAddingAll", addedFileItems);
  17421. };
  17422. uploader.onBeforeUploadItem = function (item) {
  17423. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17424. // // $scope.uploader.options.url();
  17425. // $scope.uploader.onBeforeUploadItem = function(item) {
  17426. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17427. // console.info('onBeforeUploadItem', item);
  17428. // };
  17429. // $scope.uploader.uploadAll();
  17430. // }
  17431. console.info("onBeforeUploadItem", item);
  17432. };
  17433. uploader.onProgressItem = function (fileItem, progress) {
  17434. console.info("onProgressItem", fileItem, progress);
  17435. };
  17436. uploader.onProgressAll = function (progress) {
  17437. console.info("onProgressAll", progress);
  17438. };
  17439. uploader.onSuccessItem = function (
  17440. fileItem,
  17441. response,
  17442. status,
  17443. headers
  17444. ) {
  17445. console.info("onSuccessItem", fileItem, response, status, headers);
  17446. if (response.status == 200) {
  17447. $scope.listAttachmen();
  17448. }
  17449. };
  17450. uploader.onErrorItem = function (
  17451. fileItem,
  17452. response,
  17453. status,
  17454. headers
  17455. ) {
  17456. console.info("onErrorItem", fileItem, response, status, headers);
  17457. };
  17458. uploader.onCancelItem = function (
  17459. fileItem,
  17460. response,
  17461. status,
  17462. headers
  17463. ) {
  17464. console.info("onCancelItem", fileItem, response, status, headers);
  17465. };
  17466. uploader.onCompleteItem = function (
  17467. fileItem,
  17468. response,
  17469. status,
  17470. headers
  17471. ) {
  17472. console.info("onCompleteItem", fileItem, response, status, headers);
  17473. };
  17474. uploader.onCompleteAll = function () {
  17475. console.info("onCompleteAll");
  17476. };
  17477. }
  17478. },
  17479. ],
  17480. });
  17481. //简易上传下载附件组件
  17482. formlyConfigProvider.setType({
  17483. name: "ui-upDownFiles",
  17484. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  17485. wrapper: ["bootstrapHasError"],
  17486. defaultOptions: function (options) {
  17487. return {
  17488. templateOptions: {
  17489. refresh: function (APIService, processInstanceId, data) {
  17490. return APIService.listAttachments(processInstanceId);
  17491. },
  17492. downloadUri: function (APIService, contentId) {
  17493. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17494. },
  17495. view: function (APIService, contentId) {
  17496. return APIService.attachmentsPreviewUrl(contentId);
  17497. },
  17498. download: function (APIService, contentId, item) {
  17499. var item = {
  17500. url: APIService.download(contentId),
  17501. headers: headers,
  17502. };
  17503. return item;
  17504. },
  17505. refreshDelay: 0,
  17506. },
  17507. };
  17508. },
  17509. controller: [
  17510. "$scope",
  17511. "$timeout",
  17512. "$modal",
  17513. "$rootScope",
  17514. "$http",
  17515. "up_down_file",
  17516. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17517. if (angular.isUndefined($scope.form.dropState)) {
  17518. $scope.form.dropState = false;
  17519. }
  17520. //附件上传数据
  17521. var uploader = ($scope.uploader =
  17522. $scope.options.templateOptions.fileUploader);
  17523. //$scope.options.templateOptions.uploader();
  17524. // FILTERS
  17525. uploader.filters.push({
  17526. name: "customFilter",
  17527. fn: function (item /*{File|FileLikeObject}*/, options) {
  17528. return this.queue.length < 10;
  17529. },
  17530. });
  17531. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  17532. // uploader.onBeforeUploadItem = function (item) {
  17533. // angular.extend(item.headers, $rootScope.getSession());
  17534. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  17535. // item.formData.push({
  17536. // 'fileName': item.file.name
  17537. // });
  17538. // console.info('onBeforeUploadItem', item);
  17539. // };
  17540. // }
  17541. // CALLBACKS
  17542. uploader.onWhenAddingFileFailed = function (
  17543. item /*{File|FileLikeObject}*/,
  17544. filter,
  17545. options
  17546. ) {
  17547. console.info("onWhenAddingFileFailed", item, filter, options);
  17548. };
  17549. uploader.onAfterAddingFile = function (fileItem) {
  17550. console.info("onAfterAddingFile", fileItem);
  17551. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17552. alert("文件过大");
  17553. fileItem.uploader.queue.pop();
  17554. console.log($scope);
  17555. }
  17556. };
  17557. uploader.onAfterAddingAll = function (addedFileItems) {
  17558. // console.info('onAfterAddingAll', addedFileItems);
  17559. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17560. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17561. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17562. // console.log(123)
  17563. };
  17564. uploader.onBeforeUploadItem = function (item) {
  17565. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17566. // // $scope.uploader.options.url();
  17567. // $scope.uploader.onBeforeUploadItem = function(item) {
  17568. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17569. // console.info('onBeforeUploadItem', item);
  17570. // };
  17571. // $scope.uploader.uploadAll();
  17572. // }
  17573. console.info("onBeforeUploadItem", item);
  17574. };
  17575. uploader.onProgressItem = function (fileItem, progress) {
  17576. console.info("onProgressItem", fileItem, progress);
  17577. };
  17578. uploader.onProgressAll = function (progress) {
  17579. console.info("onProgressAll", progress);
  17580. };
  17581. uploader.onSuccessItem = function (
  17582. fileItem,
  17583. response,
  17584. status,
  17585. headers
  17586. ) {
  17587. console.info("onSuccessItem", fileItem, response, status, headers);
  17588. };
  17589. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17590. console.info("onErrorItem", fileItem, response, status, headers);
  17591. };
  17592. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17593. console.info("onCancelItem", fileItem, response, status, headers);
  17594. };
  17595. uploader.onCompleteItem = function (
  17596. fileItem,
  17597. response,
  17598. status,
  17599. headers
  17600. ) {
  17601. console.info("onCompleteItem", fileItem, response, status, headers);
  17602. };
  17603. uploader.onCompleteAll = function () {
  17604. console.info("onCompleteAll");
  17605. };
  17606. var _refreshDelayPromise;
  17607. // 下载
  17608. $scope.download = function (contentId, filename, token) {
  17609. // console.log(contentId, filename, token)
  17610. //附件下载
  17611. var downUrl = up_down_file
  17612. .downloadAttachment("common/common/downloadAttachment", token)
  17613. .getRequestedUrl();
  17614. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17615. // console.log(downUrl)
  17616. var a = document.createElement("a");
  17617. a.href = downUrl;
  17618. a.target = "_blank";
  17619. a.download = filename;
  17620. document.body.appendChild(a);
  17621. a.click();
  17622. };
  17623. $scope._refresh = function (refreshAttr) {
  17624. $scope.attachments = [];
  17625. if (refreshAttr !== undefined) {
  17626. if (_refreshDelayPromise) {
  17627. $timeout.cancel(_refreshDelayPromise);
  17628. }
  17629. _refreshDelayPromise = $timeout(function () {
  17630. // 暂存附件
  17631. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17632. $scope.options.templateOptions
  17633. .refresh(
  17634. $scope.options.templateOptions.ApiService,
  17635. $scope.options.templateOptions.processInstanceId,
  17636. {
  17637. idx: 0,
  17638. sum: 1000,
  17639. }
  17640. )
  17641. .then(function (response) {
  17642. var myData =
  17643. $scope.options.templateOptions.Restangular.stripRestangular(
  17644. response
  17645. );
  17646. if (myData) {
  17647. for (var i = 0; i < myData.data.length; i++) {
  17648. $scope.attachments.push(myData.data[i]);
  17649. }
  17650. }
  17651. $scope.options.templateOptions
  17652. .refresh(
  17653. $scope.options.templateOptions.ApiService,
  17654. $scope.$parent.$parent.$parent.model.save_fileId,
  17655. {
  17656. idx: 0,
  17657. sum: 1000,
  17658. }
  17659. )
  17660. .then(function (response2) {
  17661. var myData2 =
  17662. $scope.options.templateOptions.Restangular.stripRestangular(
  17663. response2
  17664. );
  17665. if (myData2) {
  17666. for (var i = 0; i < myData2.data.length; i++) {
  17667. $scope.attachments.push(myData2.data[i]);
  17668. }
  17669. // 只展示除图片以外的附件
  17670. var a = [];
  17671. $scope.attachments.forEach((e) => {
  17672. if (
  17673. e.suffix == "jpeg" ||
  17674. e.suffix == "jpg" ||
  17675. e.suffix == "svg" ||
  17676. e.suffix == "png" ||
  17677. e.suffix == "bmp" ||
  17678. e.suffix == "gif" ||
  17679. e.suffix == "tif"
  17680. ) {
  17681. // $scope.imgs.push(e)
  17682. } else {
  17683. a.push(e);
  17684. }
  17685. });
  17686. $scope.attachments = a;
  17687. }
  17688. console.log($scope.attachments);
  17689. });
  17690. });
  17691. // 正常附件
  17692. } else {
  17693. $scope.options.templateOptions
  17694. .refresh(
  17695. $scope.options.templateOptions.ApiService,
  17696. $scope.options.templateOptions.processInstanceId,
  17697. {
  17698. idx: 0,
  17699. sum: 1000,
  17700. }
  17701. )
  17702. .then(function (response) {
  17703. var myData =
  17704. $scope.options.templateOptions.Restangular.stripRestangular(
  17705. response
  17706. );
  17707. if (myData) {
  17708. $scope.attachments = myData.data;
  17709. // 只展示除图片以外的附件
  17710. var a = [];
  17711. $scope.attachments.forEach((e) => {
  17712. if (
  17713. e.suffix == "jpeg" ||
  17714. e.suffix == "jpg" ||
  17715. e.suffix == "svg" ||
  17716. e.suffix == "png" ||
  17717. e.suffix == "bmp" ||
  17718. e.suffix == "gif" ||
  17719. e.suffix == "tif"
  17720. ) {
  17721. // $scope.imgs.push(e)
  17722. } else {
  17723. a.push(e);
  17724. }
  17725. });
  17726. $scope.attachments = a;
  17727. }
  17728. });
  17729. }
  17730. }, $scope.options.templateOptions.refreshDelay);
  17731. }
  17732. };
  17733. $scope._refresh({});
  17734. },
  17735. ],
  17736. });
  17737. //简易上传附件组件
  17738. formlyConfigProvider.setType({
  17739. name: "ui-uploadFiles",
  17740. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  17741. wrapper: ["bootstrapHasError"],
  17742. controller: [
  17743. "$scope",
  17744. function ($scope) {
  17745. if (angular.isUndefined($scope.form.dropState)) {
  17746. $scope.form.dropState = false;
  17747. }
  17748. //附件上传数据
  17749. var uploader = ($scope.uploader =
  17750. $scope.options.templateOptions.fileUploader);
  17751. //$scope.options.templateOptions.uploader();
  17752. // FILTERS
  17753. uploader.filters.push({
  17754. name: "customFilter",
  17755. fn: function (item /*{File|FileLikeObject}*/, options) {
  17756. return this.queue.length < 10;
  17757. },
  17758. });
  17759. $scope.dropfile = function (
  17760. APIService,
  17761. processInstanceId,
  17762. taskId,
  17763. userId
  17764. ) {
  17765. uploader.onBeforeUploadItem = function (item) {
  17766. angular.extend(item.headers, $rootScope.getSession());
  17767. item.url = APIService.saveAttachments(
  17768. processInstanceId,
  17769. taskId,
  17770. userId
  17771. ).getRequestedUrl();
  17772. item.formData.push({
  17773. fileName: item.file.name,
  17774. });
  17775. console.info("onBeforeUploadItem", item);
  17776. };
  17777. };
  17778. // CALLBACKS
  17779. uploader.onWhenAddingFileFailed = function (
  17780. item /*{File|FileLikeObject}*/,
  17781. filter,
  17782. options
  17783. ) {
  17784. console.info("onWhenAddingFileFailed", item, filter, options);
  17785. };
  17786. uploader.onAfterAddingFile = function (fileItem) {
  17787. console.info("onAfterAddingFile", fileItem);
  17788. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17789. alert("文件过大");
  17790. fileItem.uploader.queue.pop();
  17791. console.log($scope);
  17792. }
  17793. };
  17794. uploader.onAfterAddingAll = function (addedFileItems) {
  17795. // console.info('onAfterAddingAll', addedFileItems);
  17796. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17797. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17798. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17799. // console.log(123)
  17800. };
  17801. uploader.onBeforeUploadItem = function (item) {
  17802. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17803. // // $scope.uploader.options.url();
  17804. // $scope.uploader.onBeforeUploadItem = function(item) {
  17805. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17806. // console.info('onBeforeUploadItem', item);
  17807. // };
  17808. // $scope.uploader.uploadAll();
  17809. // }
  17810. console.info("onBeforeUploadItem", item);
  17811. };
  17812. uploader.onProgressItem = function (fileItem, progress) {
  17813. console.info("onProgressItem", fileItem, progress);
  17814. };
  17815. uploader.onProgressAll = function (progress) {
  17816. console.info("onProgressAll", progress);
  17817. };
  17818. uploader.onSuccessItem = function (
  17819. fileItem,
  17820. response,
  17821. status,
  17822. headers
  17823. ) {
  17824. console.info("onSuccessItem", fileItem, response, status, headers);
  17825. };
  17826. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17827. console.info("onErrorItem", fileItem, response, status, headers);
  17828. };
  17829. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17830. console.info("onCancelItem", fileItem, response, status, headers);
  17831. };
  17832. uploader.onCompleteItem = function (
  17833. fileItem,
  17834. response,
  17835. status,
  17836. headers
  17837. ) {
  17838. console.info("onCompleteItem", fileItem, response, status, headers);
  17839. };
  17840. uploader.onCompleteAll = function () {
  17841. console.info("onCompleteAll");
  17842. };
  17843. },
  17844. ],
  17845. });
  17846. //无上传按钮附件上传组件
  17847. formlyConfigProvider.setType({
  17848. name: "ui-dropfilenotup",
  17849. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17850. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17851. controller: [
  17852. "$scope",
  17853. function ($scope) {
  17854. if (angular.isUndefined($scope.form.dropState)) {
  17855. $scope.form.dropState = false;
  17856. }
  17857. //附件上传数据
  17858. var uploader = ($scope.uploader =
  17859. $scope.options.templateOptions.fileUploader);
  17860. //$scope.options.templateOptions.uploader();
  17861. // FILTERS
  17862. uploader.filters.push({
  17863. name: "customFilter",
  17864. fn: function (item /*{File|FileLikeObject}*/, options) {
  17865. return this.queue.length < 10;
  17866. },
  17867. });
  17868. $scope.dropfile = function (
  17869. APIService,
  17870. processInstanceId,
  17871. taskId,
  17872. userId
  17873. ) {
  17874. uploader.onBeforeUploadItem = function (item) {
  17875. angular.extend(item.headers, $rootScope.getSession());
  17876. item.url = APIService.saveAttachments(
  17877. processInstanceId,
  17878. taskId,
  17879. userId
  17880. ).getRequestedUrl();
  17881. item.formData.push({
  17882. fileName: item.file.name,
  17883. });
  17884. console.info("onBeforeUploadItem", item);
  17885. };
  17886. uploader.uploadAll();
  17887. };
  17888. // CALLBACKS
  17889. uploader.onWhenAddingFileFailed = function (
  17890. item /*{File|FileLikeObject}*/,
  17891. filter,
  17892. options
  17893. ) {
  17894. console.info("onWhenAddingFileFailed", item, filter, options);
  17895. };
  17896. uploader.onAfterAddingFile = function (fileItem) {
  17897. console.info("onAfterAddingFile", fileItem);
  17898. };
  17899. uploader.onAfterAddingAll = function (addedFileItems) {
  17900. console.info("onAfterAddingAll", addedFileItems);
  17901. };
  17902. uploader.onBeforeUploadItem = function (item) {
  17903. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17904. // // $scope.uploader.options.url();
  17905. // $scope.uploader.onBeforeUploadItem = function(item) {
  17906. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17907. // console.info('onBeforeUploadItem', item);
  17908. // };
  17909. // $scope.uploader.uploadAll();
  17910. // }
  17911. console.info("onBeforeUploadItem", item);
  17912. };
  17913. uploader.onProgressItem = function (fileItem, progress) {
  17914. console.info("onProgressItem", fileItem, progress);
  17915. };
  17916. uploader.onProgressAll = function (progress) {
  17917. console.info("onProgressAll", progress);
  17918. };
  17919. uploader.onSuccessItem = function (
  17920. fileItem,
  17921. response,
  17922. status,
  17923. headers
  17924. ) {
  17925. console.info("onSuccessItem", fileItem, response, status, headers);
  17926. };
  17927. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17928. console.info("onErrorItem", fileItem, response, status, headers);
  17929. };
  17930. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17931. console.info("onCancelItem", fileItem, response, status, headers);
  17932. };
  17933. uploader.onCompleteItem = function (
  17934. fileItem,
  17935. response,
  17936. status,
  17937. headers
  17938. ) {
  17939. console.info("onCompleteItem", fileItem, response, status, headers);
  17940. };
  17941. uploader.onCompleteAll = function () {
  17942. console.info("onCompleteAll");
  17943. };
  17944. },
  17945. ],
  17946. });
  17947. //无按钮知识库上传
  17948. formlyConfigProvider.setType({
  17949. name: "ui-dropfielkn",
  17950. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17951. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17952. controller: [
  17953. "$scope",
  17954. function ($scope) {
  17955. if (angular.isUndefined($scope.form.dropState)) {
  17956. $scope.form.dropState = false;
  17957. }
  17958. //附件上传数据
  17959. var uploader = ($scope.uploader =
  17960. $scope.options.templateOptions.fileUploader);
  17961. //$scope.options.templateOptions.uploader();
  17962. // FILTERS
  17963. uploader.filters.push({
  17964. name: "customFilter",
  17965. fn: function (item /*{File|FileLikeObject}*/, options) {
  17966. return this.queue.length < 10;
  17967. },
  17968. });
  17969. $scope.dropfile = function (
  17970. APIService,
  17971. processInstanceId,
  17972. taskId,
  17973. userId
  17974. ) {
  17975. uploader.onBeforeUploadItem = function (item) {
  17976. angular.extend(item.headers, $rootScope.getSession());
  17977. item.url = APIService.addFile(
  17978. processInstanceId,
  17979. taskId,
  17980. userId
  17981. ).getRequestedUrl();
  17982. item.formData.push({
  17983. fileName: item.file.name,
  17984. });
  17985. console.info("onBeforeUploadItem", item);
  17986. };
  17987. uploader.uploadAll();
  17988. };
  17989. // CALLBACKS
  17990. uploader.onWhenAddingFileFailed = function (
  17991. item /*{File|FileLikeObject}*/,
  17992. filter,
  17993. options
  17994. ) {
  17995. console.info("onWhenAddingFileFailed", item, filter, options);
  17996. };
  17997. uploader.onAfterAddingFile = function (fileItem) {
  17998. console.info("onAfterAddingFile", fileItem);
  17999. };
  18000. uploader.onAfterAddingAll = function (addedFileItems) {
  18001. console.info("onAfterAddingAll", addedFileItems);
  18002. };
  18003. uploader.onBeforeUploadItem = function (item) {
  18004. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18005. // // $scope.uploader.options.url();
  18006. // $scope.uploader.onBeforeUploadItem = function(item) {
  18007. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18008. // console.info('onBeforeUploadItem', item);
  18009. // };
  18010. // $scope.uploader.uploadAll();
  18011. // }
  18012. console.info("onBeforeUploadItem", item);
  18013. };
  18014. uploader.onProgressItem = function (fileItem, progress) {
  18015. console.info("onProgressItem", fileItem, progress);
  18016. };
  18017. uploader.onProgressAll = function (progress) {
  18018. console.info("onProgressAll", progress);
  18019. };
  18020. uploader.onSuccessItem = function (
  18021. fileItem,
  18022. response,
  18023. status,
  18024. headers
  18025. ) {
  18026. console.info("onSuccessItem", fileItem, response, status, headers);
  18027. };
  18028. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18029. console.info("onErrorItem", fileItem, response, status, headers);
  18030. };
  18031. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18032. console.info("onCancelItem", fileItem, response, status, headers);
  18033. };
  18034. uploader.onCompleteItem = function (
  18035. fileItem,
  18036. response,
  18037. status,
  18038. headers
  18039. ) {
  18040. console.info("onCompleteItem", fileItem, response, status, headers);
  18041. };
  18042. uploader.onCompleteAll = function () {
  18043. console.info("onCompleteAll");
  18044. };
  18045. },
  18046. ],
  18047. });
  18048. //附件上传列表组件
  18049. formlyConfigProvider.setType({
  18050. name: "ui-dropfile",
  18051. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18052. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18053. controller: [
  18054. "$scope",
  18055. "$rootScope",
  18056. function ($scope, $rootScope) {
  18057. if (angular.isUndefined($scope.form.dropState)) {
  18058. $scope.form.dropState = false;
  18059. }
  18060. //附件上传数据
  18061. var uploader = ($scope.uploader =
  18062. $scope.options.templateOptions.fileUploader);
  18063. //$scope.options.templateOptions.uploader();
  18064. // FILTERS
  18065. uploader.filters.push({
  18066. name: "customFilter",
  18067. fn: function (item /*{File|FileLikeObject}*/, options) {
  18068. return this.queue.length < 10;
  18069. },
  18070. });
  18071. $scope.dropfile = function (
  18072. APIService,
  18073. processInstanceId,
  18074. taskId,
  18075. userId
  18076. ) {
  18077. uploader.onBeforeUploadItem = function (item) {
  18078. angular.extend(item.headers, $rootScope.getSession());
  18079. if (
  18080. $scope.options.templateOptions.upservice &&
  18081. $scope.options.templateOptions.formname
  18082. ) {
  18083. // if ($scope.options.templateOptions.formket) {
  18084. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  18085. // } else {
  18086. item.url = APIService[$scope.options.templateOptions.upservice](
  18087. $scope.model[$scope.options.templateOptions.formname].id,
  18088. taskId,
  18089. userId
  18090. ).getRequestedUrl();
  18091. // }
  18092. } else {
  18093. item.url = APIService.saveAttachments(
  18094. processInstanceId,
  18095. taskId,
  18096. userId
  18097. ).getRequestedUrl();
  18098. }
  18099. item.formData.push({
  18100. filename: item.file.name,
  18101. });
  18102. console.info("onBeforeUploadItem", item);
  18103. };
  18104. uploader.uploadAll();
  18105. };
  18106. // CALLBACKS
  18107. uploader.onWhenAddingFileFailed = function (
  18108. item /*{File|FileLikeObject}*/,
  18109. filter,
  18110. options
  18111. ) {
  18112. console.info("onWhenAddingFileFailed", item, filter, options);
  18113. };
  18114. uploader.onAfterAddingFile = function (fileItem) {
  18115. console.info("onAfterAddingFile", fileItem);
  18116. };
  18117. uploader.onAfterAddingAll = function (addedFileItems) {
  18118. console.info("onAfterAddingAll", addedFileItems);
  18119. };
  18120. uploader.onBeforeUploadItem = function (item) {
  18121. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18122. // // $scope.uploader.options.url();
  18123. // $scope.uploader.onBeforeUploadItem = function(item) {
  18124. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18125. // console.info('onBeforeUploadItem', item);
  18126. // };
  18127. // $scope.uploader.uploadAll();
  18128. // }
  18129. console.info("onBeforeUploadItem", item);
  18130. };
  18131. uploader.onProgressItem = function (fileItem, progress) {
  18132. console.info("onProgressItem", fileItem, progress);
  18133. };
  18134. uploader.onProgressAll = function (progress) {
  18135. console.info("onProgressAll", progress);
  18136. };
  18137. uploader.onSuccessItem = function (
  18138. fileItem,
  18139. response,
  18140. status,
  18141. headers
  18142. ) {
  18143. console.info("onSuccessItem", fileItem, response, status, headers);
  18144. };
  18145. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18146. console.info("onErrorItem", fileItem, response, status, headers);
  18147. };
  18148. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18149. console.info("onCancelItem", fileItem, response, status, headers);
  18150. };
  18151. uploader.onCompleteItem = function (
  18152. fileItem,
  18153. response,
  18154. status,
  18155. headers
  18156. ) {
  18157. console.info("onCompleteItem", fileItem, response, status, headers);
  18158. };
  18159. uploader.onCompleteAll = function () {
  18160. console.info("onCompleteAll");
  18161. };
  18162. },
  18163. ],
  18164. });
  18165. //简易附件展示下载列表组件
  18166. formlyConfigProvider.setType({
  18167. name: "ui-dropFiles",
  18168. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  18169. defaultOptions: function (options) {
  18170. return {
  18171. templateOptions: {
  18172. refresh: function (APIService, processInstanceId, data) {
  18173. return APIService.listAttachments(processInstanceId);
  18174. },
  18175. downloadUri: function (APIService, contentId) {
  18176. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18177. },
  18178. view: function (APIService, contentId) {
  18179. return APIService.attachmentsPreviewUrl(contentId);
  18180. },
  18181. download: function (APIService, contentId, item) {
  18182. var item = {
  18183. url: APIService.download(contentId),
  18184. headers: headers,
  18185. };
  18186. return item;
  18187. },
  18188. refreshDelay: 0,
  18189. },
  18190. };
  18191. },
  18192. controller: [
  18193. "$scope",
  18194. "$timeout",
  18195. "$modal",
  18196. "$rootScope",
  18197. "$http",
  18198. "up_down_file",
  18199. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18200. var _refreshDelayPromise;
  18201. // $scope.downloadUrl = function(contentId){
  18202. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18203. // };
  18204. $scope.download = function (contentId, filename, token) {
  18205. // console.log(contentId, filename, token)
  18206. //附件下载
  18207. var downUrl = up_down_file
  18208. .downloadAttachment("common/common/downloadAttachment", token)
  18209. .getRequestedUrl();
  18210. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18211. // console.log(downUrl)
  18212. var a = document.createElement("a");
  18213. a.href = downUrl;
  18214. a.target = "_blank";
  18215. a.download = filename;
  18216. document.body.appendChild(a);
  18217. a.click();
  18218. };
  18219. $scope.view = function (contentId, token, filename, type) {
  18220. $scope.options.templateOptions
  18221. .view($scope.options.templateOptions.ApiService, contentId)
  18222. .then(function (response) {
  18223. if (response.state == 200) {
  18224. window.open(response.previewUrl);
  18225. }
  18226. });
  18227. };
  18228. /**
  18229. * refresh
  18230. */
  18231. $scope._refresh = function (refreshAttr) {
  18232. $scope.attachments = [];
  18233. if (refreshAttr !== undefined) {
  18234. if (_refreshDelayPromise) {
  18235. $timeout.cancel(_refreshDelayPromise);
  18236. }
  18237. _refreshDelayPromise = $timeout(function () {
  18238. // 暂存附件
  18239. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18240. $scope.options.templateOptions
  18241. .refresh(
  18242. $scope.options.templateOptions.ApiService,
  18243. $scope.options.templateOptions.processInstanceId,
  18244. {
  18245. idx: 0,
  18246. sum: 1000,
  18247. }
  18248. )
  18249. .then(function (response) {
  18250. var myData =
  18251. $scope.options.templateOptions.Restangular.stripRestangular(
  18252. response
  18253. );
  18254. if (myData) {
  18255. for (var i = 0; i < myData.data.length; i++) {
  18256. $scope.attachments.push(myData.data[i]);
  18257. }
  18258. }
  18259. $scope.options.templateOptions
  18260. .refresh(
  18261. $scope.options.templateOptions.ApiService,
  18262. $scope.$parent.$parent.$parent.model.save_fileId,
  18263. {
  18264. idx: 0,
  18265. sum: 1000,
  18266. }
  18267. )
  18268. .then(function (response2) {
  18269. var myData2 =
  18270. $scope.options.templateOptions.Restangular.stripRestangular(
  18271. response2
  18272. );
  18273. if (myData2) {
  18274. for (var i = 0; i < myData2.data.length; i++) {
  18275. $scope.attachments.push(myData2.data[i]);
  18276. }
  18277. // 只展示除图片以外的附件
  18278. var a = [];
  18279. $scope.attachments.forEach((e) => {
  18280. if (
  18281. e.suffix == "jpeg" ||
  18282. e.suffix == "jpg" ||
  18283. e.suffix == "svg" ||
  18284. e.suffix == "png" ||
  18285. e.suffix == "bmp" ||
  18286. e.suffix == "gif" ||
  18287. e.suffix == "tif"
  18288. ) {
  18289. // $scope.imgs.push(e)
  18290. } else {
  18291. a.push(e);
  18292. }
  18293. });
  18294. $scope.attachments = a;
  18295. }
  18296. console.log($scope.attachments);
  18297. });
  18298. });
  18299. // 正常附件
  18300. } else {
  18301. $scope.options.templateOptions
  18302. .refresh(
  18303. $scope.options.templateOptions.ApiService,
  18304. $scope.options.templateOptions.processInstanceId,
  18305. {
  18306. idx: 0,
  18307. sum: 1000,
  18308. }
  18309. )
  18310. .then(function (response) {
  18311. var myData =
  18312. $scope.options.templateOptions.Restangular.stripRestangular(
  18313. response
  18314. );
  18315. if (myData) {
  18316. $scope.attachments = myData.data;
  18317. // 只展示除图片以外的附件
  18318. var a = [];
  18319. $scope.attachments.forEach((e) => {
  18320. if (
  18321. e.suffix == "jpeg" ||
  18322. e.suffix == "jpg" ||
  18323. e.suffix == "svg" ||
  18324. e.suffix == "png" ||
  18325. e.suffix == "bmp" ||
  18326. e.suffix == "gif" ||
  18327. e.suffix == "tif"
  18328. ) {
  18329. // $scope.imgs.push(e)
  18330. } else {
  18331. a.push(e);
  18332. }
  18333. });
  18334. $scope.attachments = a;
  18335. console.log($scope.attachments);
  18336. }
  18337. });
  18338. }
  18339. }, $scope.options.templateOptions.refreshDelay);
  18340. }
  18341. };
  18342. $scope._refresh({});
  18343. // $scope.attachments = $scope.model[$scope.options.key]
  18344. },
  18345. ],
  18346. });
  18347. //知识库附件上传
  18348. formlyConfigProvider.setType({
  18349. name: "ui-dropfielknow",
  18350. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18351. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18352. controller: [
  18353. "$scope",
  18354. "$rootScope",
  18355. function ($scope, $rootScope) {
  18356. if (angular.isUndefined($scope.form.dropState)) {
  18357. $scope.form.dropState = false;
  18358. }
  18359. //附件上传数据
  18360. var uploader = ($scope.uploader =
  18361. $scope.options.templateOptions.fileUploader);
  18362. //$scope.options.templateOptions.uploader();
  18363. // FILTERS
  18364. uploader.filters.push({
  18365. name: "customFilter",
  18366. fn: function (item /*{File|FileLikeObject}*/, options) {
  18367. return this.queue.length < 10;
  18368. },
  18369. });
  18370. $scope.dropfile = function (
  18371. APIService,
  18372. processInstanceId,
  18373. taskId,
  18374. userId
  18375. ) {
  18376. uploader.onBeforeUploadItem = function (item) {
  18377. angular.extend(item.headers, $rootScope.getSession());
  18378. item.url = APIService.upload(
  18379. processInstanceId,
  18380. taskId,
  18381. userId
  18382. ).getRequestedUrl();
  18383. item.formData.push({
  18384. fileName: item.file.name,
  18385. type: "solution",
  18386. solutionId: $scope.model.knowledge.id,
  18387. });
  18388. console.info("onBeforeUploadItem", item);
  18389. };
  18390. uploader.uploadAll();
  18391. };
  18392. // CALLBACKS
  18393. uploader.onWhenAddingFileFailed = function (
  18394. item /*{File|FileLikeObject}*/,
  18395. filter,
  18396. options
  18397. ) {
  18398. console.info("onWhenAddingFileFailed", item, filter, options);
  18399. };
  18400. uploader.onAfterAddingFile = function (fileItem) {
  18401. console.info("onAfterAddingFile", fileItem);
  18402. };
  18403. uploader.onAfterAddingAll = function (addedFileItems) {
  18404. console.info("onAfterAddingAll", addedFileItems);
  18405. };
  18406. uploader.onBeforeUploadItem = function (item) {
  18407. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18408. // // $scope.uploader.options.url();
  18409. // $scope.uploader.onBeforeUploadItem = function(item) {
  18410. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18411. // console.info('onBeforeUploadItem', item);
  18412. // };
  18413. // $scope.uploader.uploadAll();
  18414. // }
  18415. console.info("onBeforeUploadItem", item);
  18416. };
  18417. uploader.onProgressItem = function (fileItem, progress) {
  18418. console.info("onProgressItem", fileItem, progress);
  18419. };
  18420. uploader.onProgressAll = function (progress) {
  18421. console.info("onProgressAll", progress);
  18422. };
  18423. uploader.onSuccessItem = function (
  18424. fileItem,
  18425. response,
  18426. status,
  18427. headers
  18428. ) {
  18429. console.info("onSuccessItem", fileItem, response, status, headers);
  18430. };
  18431. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18432. console.info("onErrorItem", fileItem, response, status, headers);
  18433. };
  18434. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18435. console.info("onCancelItem", fileItem, response, status, headers);
  18436. };
  18437. uploader.onCompleteItem = function (
  18438. fileItem,
  18439. response,
  18440. status,
  18441. headers
  18442. ) {
  18443. console.info("onCompleteItem", fileItem, response, status, headers);
  18444. };
  18445. uploader.onCompleteAll = function () {
  18446. console.info("onCompleteAll");
  18447. };
  18448. },
  18449. ],
  18450. });
  18451. //知识库附件下载列表
  18452. formlyConfigProvider.setType({
  18453. name: "ui-dropfileknowledge",
  18454. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  18455. defaultOptions: function (options) {
  18456. return {
  18457. templateOptions: {
  18458. refresh: function (APIService, contentId, data) {
  18459. return APIService.fetchDataList(contentId, data);
  18460. },
  18461. downloadUri: function (APIService, contentId) {
  18462. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18463. },
  18464. download: function (APIService, contentId) {
  18465. return APIService.getSolutionDowpath(contentId);
  18466. },
  18467. view: function (attachmentId) {
  18468. // return APIService.attachmentsPreviewUrl(contentId);
  18469. },
  18470. refreshDelay: 0,
  18471. },
  18472. };
  18473. },
  18474. controller: [
  18475. "$scope",
  18476. "$timeout",
  18477. "$modal",
  18478. "$rootScope",
  18479. "api_solution",
  18480. "$http",
  18481. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  18482. var _refreshDelayPromise;
  18483. $scope.attachments = [];
  18484. $scope.downloadUrl = function (contentId) {
  18485. return (
  18486. $scope.options.templateOptions.downloadUri(
  18487. $scope.options.templateOptions.ApiService,
  18488. contentId
  18489. ) || "#"
  18490. );
  18491. };
  18492. $scope.download = function (contentId, filename) {
  18493. $http({
  18494. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  18495. contentId
  18496. ).getRequestedUrl(),
  18497. method: "GET",
  18498. headers: {
  18499. //'Content-type' : 'application/xls',
  18500. Accept: "*/*",
  18501. },
  18502. responseType: "arraybuffer",
  18503. })
  18504. .success(function (data, status, headers, config) {
  18505. var file = new Blob([data], {
  18506. type: "application/octet-stream",
  18507. });
  18508. //trick to download store a file having its URL
  18509. var fileURL = URL.createObjectURL(file);
  18510. var a = document.createElement("a");
  18511. a.href = fileURL;
  18512. a.target = "_blank";
  18513. a.download = filename;
  18514. document.body.appendChild(a);
  18515. a.click();
  18516. })
  18517. .error(function (data, status, headers, config) {
  18518. // console.log(data);
  18519. });
  18520. };
  18521. $scope.view = function (contentId, filename, attachment) {
  18522. var index = filename.indexOf(".");
  18523. var type = filename.substring(index + 1);
  18524. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18525. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  18526. // var modalInstance = $modal.open({
  18527. // backdrop: false,
  18528. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18529. // controller: function($scope, scope, $modalInstance, filename) {
  18530. // $scope.title = filename;
  18531. // $scope.imageurl = scope.imageurl;
  18532. // $scope.cancel = function() {
  18533. // $modalInstance.dismiss('cancel');
  18534. // }
  18535. // },
  18536. // resolve: {
  18537. // scope: function() {
  18538. // return $scope;
  18539. // },
  18540. // filename: function() {
  18541. // return filename;
  18542. // }
  18543. // }
  18544. // });
  18545. // event.preventDefault();
  18546. // } else {
  18547. // for (var i = 0; i < $scope.attachments.length; i++) {
  18548. // if ($scope.attachments[i].id == attachmentId) {
  18549. window.open(attachment.previewUrl);
  18550. // }
  18551. // }
  18552. // }
  18553. };
  18554. $scope._refresh = function (refreshAttr) {
  18555. if (refreshAttr !== undefined) {
  18556. if (_refreshDelayPromise) {
  18557. $timeout.cancel(_refreshDelayPromise);
  18558. }
  18559. _refreshDelayPromise = $timeout(function () {
  18560. $scope.options.templateOptions
  18561. .refresh($scope.options.templateOptions.ApiService, "file", {
  18562. file: {
  18563. solutionId: $scope.model.knowledge.id,
  18564. },
  18565. idx: "0",
  18566. sum: "1000",
  18567. })
  18568. .then(function (response) {
  18569. var myData =
  18570. $scope.options.templateOptions.Restangular.stripRestangular(
  18571. response
  18572. );
  18573. if (myData) {
  18574. $scope.attachments = myData.list;
  18575. // $scope.view = function(attachmentId) {
  18576. // for (var i = 0; i < $scope.attachments.length; i++) {
  18577. // if ($scope.attachments[i].id == attachmentId) {
  18578. // window.open($scope.attachments[i].previewUrl);
  18579. // // var modalInstance = $modal.open({
  18580. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  18581. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  18582. // // }
  18583. // // });
  18584. // }
  18585. // }
  18586. // };
  18587. }
  18588. });
  18589. }, $scope.options.templateOptions.refreshDelay);
  18590. }
  18591. };
  18592. $scope._refresh({});
  18593. // $scope.attachments = $scope.model[$scope.options.key]
  18594. },
  18595. ],
  18596. });
  18597. //附件图片下载
  18598. formlyConfigProvider.setType({
  18599. name: "ui-downimage",
  18600. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  18601. defaultOptions: function (options) {
  18602. return {
  18603. templateOptions: {
  18604. refresh: function (APIService, processInstanceId, data) {
  18605. return APIService.listAttachments(processInstanceId, data);
  18606. },
  18607. downloadUri: function (APIService, contentId) {
  18608. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18609. },
  18610. view: function (APIService, contentId) {
  18611. return APIService.attachmentsPreviewUrl(contentId);
  18612. },
  18613. download: function (APIService, contentId, item) {
  18614. var item = {
  18615. url: APIService.download(contentId),
  18616. headers: headers,
  18617. };
  18618. return item;
  18619. },
  18620. refreshDelay: 0,
  18621. },
  18622. };
  18623. },
  18624. controller: [
  18625. "$scope",
  18626. "$timeout",
  18627. "$rootScope",
  18628. "$http",
  18629. function ($scope, $timeout, $rootScope, $http) {
  18630. var _refreshDelayPromise;
  18631. // $scope.downloadUrl = function(contentId){
  18632. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18633. // };
  18634. $scope.download = function (contentId, filename) {
  18635. // var headers=
  18636. $http({
  18637. url: $scope.options.templateOptions.ApiService.download(
  18638. contentId
  18639. ).getRequestedUrl(),
  18640. method: "GET",
  18641. headers: {
  18642. //'Content-type' : 'application/xls',
  18643. Accept: "*/*",
  18644. },
  18645. responseType: "arraybuffer",
  18646. })
  18647. .success(function (data, status, headers, config) {
  18648. var file = new Blob([data], {
  18649. type: "application/octet-stream",
  18650. });
  18651. //trick to download store a file having its URL
  18652. var fileURL = URL.createObjectURL(file);
  18653. var a = document.createElement("a");
  18654. a.href = fileURL;
  18655. a.target = "_blank";
  18656. a.download = filename;
  18657. document.body.appendChild(a);
  18658. a.click();
  18659. })
  18660. .error(function (data, status, headers, config) {
  18661. // console.log(data);
  18662. });
  18663. };
  18664. $scope.view = function (contentId) {
  18665. $scope.imageurl =
  18666. $scope.options.templateOptions.ApiService.download(
  18667. contentId
  18668. ).getRequestedUrl();
  18669. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  18670. // if (response.state == 200) {
  18671. // window.open(response.previewUrl);
  18672. // }
  18673. // })
  18674. };
  18675. /**
  18676. * refresh
  18677. */
  18678. $scope._refresh = function (refreshAttr) {
  18679. if (refreshAttr !== undefined) {
  18680. if (_refreshDelayPromise) {
  18681. $timeout.cancel(_refreshDelayPromise);
  18682. }
  18683. _refreshDelayPromise = $timeout(function () {
  18684. $scope.options.templateOptions
  18685. .refresh(
  18686. $scope.options.templateOptions.ApiService,
  18687. $scope.options.templateOptions.processInstanceId,
  18688. {
  18689. idx: 0,
  18690. sum: 1000,
  18691. }
  18692. )
  18693. .then(function (response) {
  18694. var myData =
  18695. $scope.options.templateOptions.Restangular.stripRestangular(
  18696. response
  18697. );
  18698. if (myData) {
  18699. $scope.attachments = myData.data;
  18700. }
  18701. });
  18702. }, $scope.options.templateOptions.refreshDelay);
  18703. }
  18704. };
  18705. $scope._refresh({});
  18706. // $scope.attachments = $scope.model[$scope.options.key]
  18707. },
  18708. ],
  18709. });
  18710. //附件下载列表组件
  18711. formlyConfigProvider.setType({
  18712. name: "ui-dropfiletable",
  18713. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  18714. defaultOptions: function (options) {
  18715. return {
  18716. templateOptions: {
  18717. refresh: function (APIService, processInstanceId, data) {
  18718. return APIService.listAttachments(processInstanceId, data);
  18719. },
  18720. downloadUri: function (APIService, contentId) {
  18721. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18722. },
  18723. view: function (APIService, contentId) {
  18724. return APIService.attachmentsPreviewUrl(contentId);
  18725. },
  18726. download: function (APIService, contentId, item) {
  18727. var item = {
  18728. url: APIService.download(contentId),
  18729. headers: headers,
  18730. };
  18731. return item;
  18732. },
  18733. refreshDelay: 0,
  18734. },
  18735. };
  18736. },
  18737. controller: [
  18738. "$scope",
  18739. "$timeout",
  18740. "$modal",
  18741. "$rootScope",
  18742. "$http",
  18743. function ($scope, $timeout, $modal, $rootScope, $http) {
  18744. var _refreshDelayPromise;
  18745. // $scope.downloadUrl = function(contentId){
  18746. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18747. // };
  18748. $scope.download = function (contentId, filename) {
  18749. // var headers=
  18750. $http({
  18751. url: $scope.options.templateOptions.ApiService.download(
  18752. contentId
  18753. ).getRequestedUrl(),
  18754. method: "GET",
  18755. headers: {
  18756. //'Content-type' : 'application/xls',
  18757. Accept: "*/*",
  18758. },
  18759. responseType: "arraybuffer",
  18760. })
  18761. .success(function (data, status, headers, config) {
  18762. var file = new Blob([data], {
  18763. type: "application/octet-stream",
  18764. });
  18765. //trick to download store a file having its URL
  18766. var fileURL = URL.createObjectURL(file);
  18767. var a = document.createElement("a");
  18768. a.href = fileURL;
  18769. a.target = "_blank";
  18770. a.download = filename;
  18771. document.body.appendChild(a);
  18772. a.click();
  18773. })
  18774. .error(function (data, status, headers, config) {
  18775. // console.log(data);
  18776. });
  18777. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  18778. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  18779. // var file = new Blob([response], {
  18780. // type : 'application/octet-stream'
  18781. // });
  18782. // // var filename = filename;
  18783. // //var file = new Blob([response], {type: 'application/pdf'});
  18784. // var fileURL = URL.createObjectURL(file);
  18785. // var a = document.createElement('a');
  18786. // a.href = fileURL;
  18787. // a.target = '_blank';
  18788. // a.download = filename ;
  18789. // document.body.appendChild(a);
  18790. // a.click();
  18791. // })
  18792. };
  18793. $scope.view = function (contentId, token, filename, type) {
  18794. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18795. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  18796. // var modalInstance = $modal.open({
  18797. // backdrop: false,
  18798. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18799. // controller: function($scope, scope, $modalInstance, filename) {
  18800. // $scope.title = filename;
  18801. // $scope.imageurl = scope.imageurl;
  18802. // $scope.cancel = function() {
  18803. // $modalInstance.dismiss('cancel');
  18804. // }
  18805. // },
  18806. // resolve: {
  18807. // scope: function() {
  18808. // return $scope;
  18809. // },
  18810. // filename: function() {
  18811. // return filename;
  18812. // }
  18813. // }
  18814. // });
  18815. // event.preventDefault();
  18816. // } else {
  18817. $scope.options.templateOptions
  18818. .view($scope.options.templateOptions.ApiService, contentId)
  18819. .then(function (response) {
  18820. if (response.state == 200) {
  18821. window.open(response.previewUrl);
  18822. }
  18823. });
  18824. // }
  18825. };
  18826. /**
  18827. * refresh
  18828. */
  18829. $scope._refresh = function (refreshAttr) {
  18830. if (refreshAttr !== undefined) {
  18831. if (_refreshDelayPromise) {
  18832. $timeout.cancel(_refreshDelayPromise);
  18833. }
  18834. _refreshDelayPromise = $timeout(function () {
  18835. $scope.options.templateOptions
  18836. .refresh(
  18837. $scope.options.templateOptions.ApiService,
  18838. $scope.options.templateOptions.processInstanceId,
  18839. {
  18840. idx: 0,
  18841. sum: 1000,
  18842. }
  18843. )
  18844. .then(function (response) {
  18845. var myData =
  18846. $scope.options.templateOptions.Restangular.stripRestangular(
  18847. response
  18848. );
  18849. if (myData) {
  18850. $scope.attachments = myData.data;
  18851. }
  18852. });
  18853. }, $scope.options.templateOptions.refreshDelay);
  18854. }
  18855. };
  18856. $scope._refresh({});
  18857. // $scope.attachments = $scope.model[$scope.options.key]
  18858. },
  18859. ],
  18860. });
  18861. //微信附件下载列表组件
  18862. formlyConfigProvider.setType({
  18863. name: "ui-dropfilewechat",
  18864. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  18865. defaultOptions: function (options) {
  18866. return {
  18867. templateOptions: {
  18868. // refresh: function(APIService, processInstanceId, data) {
  18869. // return APIService.listAttachments(processInstanceId, data);
  18870. // },
  18871. // downloadUri: function(APIService, contentId) {
  18872. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  18873. // },
  18874. view: function (APIService, contentId) {
  18875. // return APIService.attachmentsPreviewUrl(contentId);
  18876. return APIService.attachmentsPreviewUrl(contentId);
  18877. },
  18878. download: function (APIService, contentId, item) {
  18879. var item = {
  18880. url: APIService.download(contentId),
  18881. headers: headers,
  18882. };
  18883. return item;
  18884. },
  18885. // download: function(APIService, contentId, item) {
  18886. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  18887. // return item;
  18888. // },
  18889. refreshDelay: 0,
  18890. },
  18891. };
  18892. },
  18893. controller: [
  18894. "$scope",
  18895. "$timeout",
  18896. "$modal",
  18897. "$stateParams",
  18898. "$rootScope",
  18899. "$http",
  18900. "api_wechatfile",
  18901. function (
  18902. $scope,
  18903. $timeout,
  18904. $modal,
  18905. $stateParams,
  18906. $rootScope,
  18907. $http,
  18908. api_wechatfile
  18909. ) {
  18910. var _refreshDelayPromise;
  18911. // $scope.downloadUrl = function(contentId){
  18912. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18913. // };
  18914. $scope.attachments = {};
  18915. $scope.previewUrl = "";
  18916. $scope.download = function (token, filename) {
  18917. // var headers=
  18918. console.log($scope);
  18919. $http({
  18920. url: $scope.options.templateOptions.ApiService.jry_download(
  18921. token
  18922. ).getRequestedUrl(),
  18923. method: "GET",
  18924. headers: {
  18925. //'Content-type' : 'application/xls',
  18926. Accept: "*/*",
  18927. },
  18928. responseType: "arraybuffer",
  18929. })
  18930. .success(function (data, status, headers, config) {
  18931. var file = new Blob([data], {
  18932. type: "application/octet-stream",
  18933. });
  18934. //trick to download store a file having its URL
  18935. var fileURL = URL.createObjectURL(file);
  18936. var a = document.createElement("a");
  18937. a.href = fileURL;
  18938. a.target = "_blank";
  18939. a.download = filename;
  18940. document.body.appendChild(a);
  18941. a.click();
  18942. })
  18943. .error(function (data, status, headers, config) {
  18944. // console.log(data);
  18945. });
  18946. };
  18947. $scope.view = function (contentId, token, filename, type, previewUrl) {
  18948. // if (type) {
  18949. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  18950. // var modalInstance = $modal.open({
  18951. // backdrop: false,
  18952. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18953. // controller: function($scope, scope, $modalInstance, filename) {
  18954. // $scope.title = filename;
  18955. // $scope.imageurl = scope.imageurl;
  18956. // $scope.cancel = function() {
  18957. // $modalInstance.dismiss('cancel');
  18958. // }
  18959. // },
  18960. // resolve: {
  18961. // scope: function() {
  18962. // return $scope;
  18963. // },
  18964. // filename: function() {
  18965. // return filename;
  18966. // }
  18967. // }
  18968. // });
  18969. // event.preventDefault();
  18970. // } else {
  18971. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  18972. // if (response.state == 200) {
  18973. // window.open(response.previewUrl);
  18974. // }
  18975. // })
  18976. window.open(previewUrl);
  18977. // }
  18978. };
  18979. /**
  18980. * refresh
  18981. */
  18982. $scope._refresh = function (refreshAttr) {
  18983. if (refreshAttr !== undefined) {
  18984. if (_refreshDelayPromise) {
  18985. $timeout.cancel(_refreshDelayPromise);
  18986. }
  18987. _refreshDelayPromise = $timeout(function () {
  18988. // console.log(JSON.parse($stateParams.model))
  18989. var incidentChart = {};
  18990. if ($stateParams.model) {
  18991. incidentChart = JSON.parse($stateParams.model).model;
  18992. }
  18993. $scope.options.templateOptions
  18994. .refresh(
  18995. $scope.options.templateOptions.ApiService,
  18996. $scope.model
  18997. )
  18998. .then(function (response) {
  18999. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  19000. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  19001. var myData =
  19002. $scope.options.templateOptions.Restangular.stripRestangular(
  19003. response
  19004. );
  19005. if (myData) {
  19006. $scope.attachments = myData.data;
  19007. }
  19008. });
  19009. }, $scope.options.templateOptions.refreshDelay);
  19010. }
  19011. };
  19012. $scope._refresh({});
  19013. // $scope.attachments = $scope.model[$scope.options.key]
  19014. },
  19015. ],
  19016. });
  19017. formlyConfigProvider.setType({
  19018. name: "ui-paralleltask",
  19019. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  19020. defaultOptions: function (options) {
  19021. return {
  19022. templateOptions: {
  19023. refresh: function (APIService, processInstanceId, data) {
  19024. //return APIService.listAttachments(processInstanceId, data);
  19025. },
  19026. refreshDelay: 0,
  19027. },
  19028. };
  19029. },
  19030. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  19031. });
  19032. //repeatSection
  19033. //
  19034. formlyConfigProvider.setType({
  19035. name: "ui-repeatSection",
  19036. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  19037. defaultOptions: function (options) {
  19038. return {
  19039. templateOptions: {
  19040. unique: 1,
  19041. initDisplay: false,
  19042. },
  19043. };
  19044. },
  19045. controller: function ($scope) {
  19046. //$scope.options.templateOptions.unique;
  19047. $scope.formOptions = {
  19048. formState: $scope.formState,
  19049. };
  19050. $scope.addNew = addNew;
  19051. $scope.copyFields = copyFields;
  19052. function copyFields(fields) {
  19053. fields = angular.copy(fields);
  19054. addRandomIds(fields);
  19055. return fields;
  19056. }
  19057. function addNew() {
  19058. $scope.model[$scope.options.key] =
  19059. $scope.model[$scope.options.key] || [];
  19060. var repeatsection = $scope.model[$scope.options.key];
  19061. var lastSection = repeatsection[repeatsection.length - 1];
  19062. var newsection = {};
  19063. repeatsection.push(newsection);
  19064. }
  19065. function addRandomIds(fields) {
  19066. $scope.options.templateOptions.unique++;
  19067. angular.forEach(fields, function (field, index) {
  19068. if (field.fieldGroup) {
  19069. addRandomIds(field.fieldGroup);
  19070. return; // fieldGroups don't need an ID
  19071. }
  19072. if (field.templateOptions && field.templateOptions.fields) {
  19073. addRandomIds(field.templateOptions.fields);
  19074. }
  19075. field.id =
  19076. field.id ||
  19077. field.key +
  19078. "_" +
  19079. index +
  19080. "_" +
  19081. $scope.options.templateOptions.unique +
  19082. getRandomInt(0, 9999);
  19083. });
  19084. }
  19085. function getRandomInt(min, max) {
  19086. return Math.floor(Math.random() * (max - min)) + min;
  19087. }
  19088. if ($scope.options.templateOptions.initDisplay) {
  19089. addNew();
  19090. }
  19091. },
  19092. });
  19093. //时间轴任务列表组件
  19094. //cmdb控件
  19095. formlyConfigProvider.setType({
  19096. name: "ui-cmdb",
  19097. extends: "input",
  19098. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  19099. defaultOptions: function (options) {
  19100. return {
  19101. templateOptions: {
  19102. onClick: function (size, options, modal, event, model) {
  19103. var modalInstance = modal.open({
  19104. templateUrl:
  19105. "assets/views/customform/tpl/cmdb-modal-content.html",
  19106. controller: function (
  19107. $scope,
  19108. $modalInstance,
  19109. title,
  19110. Restangular,
  19111. APIService,
  19112. ConfigDataService,
  19113. ConfigFormService,
  19114. SweetAlert,
  19115. Toaster,
  19116. api_wechatfile
  19117. ) {
  19118. var width = ($scope.width = 600);
  19119. var height = ($scope.height = 400);
  19120. var tree;
  19121. var d3 = window.d3;
  19122. $scope.my_tree_handler = function (branch) {
  19123. //var _ref;
  19124. var classify = ($scope.classify =
  19125. branch.prefix.toLowerCase() + branch.sign);
  19126. APIService.query({
  19127. sign: classify,
  19128. }).then(function (data) {
  19129. var myData = Restangular.stripRestangular(data);
  19130. // console.log(myData.data.node);
  19131. if (myData.data && myData.status == 200) {
  19132. var ret = myData.data;
  19133. redrawSvg(myData);
  19134. }
  19135. });
  19136. };
  19137. $scope.my_data = [];
  19138. function convertListToTree(data, treeMap) {
  19139. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  19140. var root = null; //Initially set our loop to null
  19141. var parentNode = null;
  19142. //loop over data
  19143. for (var i = 0; i < data.length; i++) {
  19144. var datum = data[i];
  19145. //each node will have children, so let's give it a "children" poperty
  19146. datum.children = [];
  19147. //add an entry for this node to the map so that any future children can
  19148. //lookup the parent
  19149. idToNodeMap[datum.id] = datum;
  19150. //Does this node have a parent?
  19151. if (
  19152. typeof datum.parent === "undefined" ||
  19153. datum.parent == null
  19154. ) {
  19155. //Doesn't look like it, so this node is the root of the tree
  19156. root = datum;
  19157. treeMap[datum.id] = root;
  19158. } else {
  19159. //This node has a parent, so let's look it up using the id
  19160. parentNode = idToNodeMap[datum.parent.id];
  19161. //We don't need this property, so let's delete it.
  19162. delete datum.parent;
  19163. //Let's add the current node as a child of the parent node.
  19164. parentNode.children.push(datum);
  19165. }
  19166. }
  19167. return root;
  19168. }
  19169. function convertParentToChildList(data) {
  19170. var treeMap = {};
  19171. var list = [];
  19172. convertListToTree(data, treeMap);
  19173. angular.forEach(treeMap, function (item) {
  19174. list.push(item);
  19175. });
  19176. return list;
  19177. }
  19178. $scope.my_tree = tree = {};
  19179. $scope.try_async_load = function () {
  19180. $scope.my_data = [];
  19181. $scope.select_treedata = [];
  19182. $scope.doing_async = true;
  19183. ConfigDataService.fetchDataList("ciclassify", {
  19184. idx: 0,
  19185. sum: 100,
  19186. }).then(function (result) {
  19187. $scope.select_treedata = $scope.my_data =
  19188. convertParentToChildList(result["list"]);
  19189. $scope.doing_async = false;
  19190. });
  19191. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  19192. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  19193. // $scope.doing_async = false;
  19194. // });
  19195. };
  19196. $scope.select_treedata = [];
  19197. $scope.propTypeOptions = [];
  19198. $scope.try_async_load();
  19199. $scope.onFilterCallback = function (item) {
  19200. //console.log(item);
  19201. if (
  19202. angular.isDefined(item.children) &&
  19203. item.children.length >= 1
  19204. ) {
  19205. //not valid
  19206. } else {
  19207. var tempclassify = item.prefix.toLowerCase() + item.sign;
  19208. $scope.cifilter_classic = tempclassify;
  19209. ConfigFormService.renderTabForm(tempclassify).then(
  19210. function (data) {
  19211. var myData = Restangular.stripRestangular(data);
  19212. $scope.propTypeOptions = myData;
  19213. }
  19214. );
  19215. }
  19216. };
  19217. $scope.onPropTypeChange = function (form) {
  19218. $scope.propOptions = form.fields;
  19219. };
  19220. $scope.onPropChange = function (prop) {
  19221. $scope.cifilter_prop = prop;
  19222. };
  19223. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  19224. //if(searchKey!=null&&searchKey.length>1){
  19225. var searchData = {};
  19226. if (angular.isUndefined(propObj)) {
  19227. propObj = $scope.cifilter_prop;
  19228. }
  19229. if (angular.isUndefined(ciclassify)) {
  19230. ciclassify = $scope.cifilter_classic;
  19231. }
  19232. searchData["sign"] = ciclassify;
  19233. if (angular.isDefined(propObj)) {
  19234. searchData[propObj.key] = searchKey;
  19235. }
  19236. APIService.query(searchData).then(function (response) {
  19237. var data = Restangular.stripRestangular(response);
  19238. //此处不清空nodes
  19239. var node = data.data.node;
  19240. var tempNode = [];
  19241. //nodes 或者links 要去重
  19242. for (var i = 0; i < node.length; i++) {
  19243. var tmp = 0;
  19244. for (var j = 0; j < nodes.length; j++) {
  19245. if (node[i].uuid == nodes[j].uuid) {
  19246. tmp++;
  19247. break;
  19248. }
  19249. }
  19250. if (tmp == 0) {
  19251. tempNode.push(node[i]);
  19252. }
  19253. }
  19254. for (var i = 0; i < tempNode.length; i++) {
  19255. //nodes 不清空
  19256. nodes.push(tempNode[i]);
  19257. }
  19258. restart();
  19259. });
  19260. };
  19261. $scope.refresh = function () {
  19262. nodes.length = 0;
  19263. links.length = 0;
  19264. restart();
  19265. };
  19266. $scope.traversal = function () {
  19267. if ($scope.selected_node == null) {
  19268. SweetAlert.swal({
  19269. title: "错误的操作!",
  19270. text: "没有配置项被选中!",
  19271. type: "error",
  19272. });
  19273. } else {
  19274. var uuid = $scope.selected_node.uuid;
  19275. APIService.traversal(uuid).then(function (response) {
  19276. var d = response.data;
  19277. var node = d.node;
  19278. var link = d.edge;
  19279. var tempNode = [];
  19280. var tempLink = [];
  19281. //nodes 或者links 要去重
  19282. for (var i = 0; i < node.length; i++) {
  19283. var tmp = 0;
  19284. for (var j = 0; j < nodes.length; j++) {
  19285. if (node[i].id == nodes[j].id) {
  19286. tmp++;
  19287. break;
  19288. }
  19289. }
  19290. if (tmp == 0) {
  19291. tempNode.push(node[i]);
  19292. }
  19293. }
  19294. for (var i = 0; i < link.length; i++) {
  19295. var tmp = 0;
  19296. for (var j = 0; j < links.length; j++) {
  19297. if (link[i].id == links[j].id) {
  19298. tmp++;
  19299. break;
  19300. }
  19301. }
  19302. if (tmp == 0) {
  19303. tempLink.push(link[i]);
  19304. }
  19305. }
  19306. //数据写入页面
  19307. for (var i = 0; i < tempNode.length; i++) {
  19308. //nodes 不清空
  19309. nodes.push(tempNode[i]);
  19310. }
  19311. for (var i = 0; i < tempLink.length; i++) {
  19312. //link 不清空
  19313. links.push(tempLink[i]);
  19314. }
  19315. //links转换
  19316. for (var i = 0; i < links.length; i++) {
  19317. for (var j = 0; j < nodes.length; j++) {
  19318. if (links[i].source == nodes[j].id) {
  19319. links[i].source = nodes[j];
  19320. }
  19321. if (links[i].target == nodes[j].id) {
  19322. links[i].target = nodes[j];
  19323. }
  19324. }
  19325. }
  19326. restart();
  19327. });
  19328. }
  19329. };
  19330. var svg;
  19331. var force;
  19332. var drag_line, path, circle;
  19333. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  19334. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19335. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19336. var nodes = [],
  19337. links = [];
  19338. var treeNodes = [];
  19339. //读取labels (node)
  19340. var labels = [];
  19341. function redrawSvg(json) {
  19342. nodes.length = 0; //先清空
  19343. links.length = 0;
  19344. var data = json.data;
  19345. for (var i = 0; i < data.node.length; i++) {
  19346. nodes.push(data.node[i]);
  19347. }
  19348. restart();
  19349. }
  19350. //读取status (节点 连线)
  19351. var statuses = [];
  19352. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  19353. // if (result && result.status == 200) {
  19354. // d3.select('#nodeStatus').selectAll('option')
  19355. // .data(statuses).enter()
  19356. // .append('option')
  19357. // .attr('value', function(d) { return d.code; })
  19358. // .html(function(d) { return d.desc; });
  19359. // } else {
  19360. // SweetAlert.swal({
  19361. // title: "提示!",
  19362. // text: "服务器请求异常!",
  19363. // type: "error"
  19364. // });
  19365. // }
  19366. // });
  19367. api_wechatfile
  19368. .getDictionary({
  19369. key: "cmdb_status",
  19370. type: "list",
  19371. })
  19372. .then(function (result) {
  19373. if (result) {
  19374. d3.select("#nodeStatus")
  19375. .selectAll("option")
  19376. .data(statuses)
  19377. .enter()
  19378. .append("option")
  19379. .attr("value", function (d) {
  19380. return d.code;
  19381. })
  19382. .html(function (d) {
  19383. return d.desc;
  19384. });
  19385. } else {
  19386. SweetAlert.swal({
  19387. title: "提示!",
  19388. text: "服务器请求异常!",
  19389. type: "error",
  19390. });
  19391. }
  19392. });
  19393. //查询relationship_type表 name 为表里的type,label为显示值
  19394. var linkType = [];
  19395. function fetchEdgeTypes() {
  19396. ConfigDataService.fetchDataList("ciedgetype", {
  19397. idx: 0,
  19398. sum: 100,
  19399. }).then(function (response) {
  19400. if (response) {
  19401. if (response["list"]) {
  19402. linkType = response["list"];
  19403. // d3.select('#linkName').selectAll('option')
  19404. // .data(linkType).enter()
  19405. // .append('option')
  19406. // .attr('value',function(d){return d.type;})
  19407. // .html(function(d){ return d.label;});
  19408. } else {
  19409. SweetAlert.swal({
  19410. title: "提示!",
  19411. text: "服务器请求异常!",
  19412. type: "error",
  19413. });
  19414. }
  19415. } else {
  19416. SweetAlert.swal({
  19417. title: "提示!",
  19418. text: "服务器请求异常!",
  19419. type: "error",
  19420. });
  19421. }
  19422. });
  19423. }
  19424. // fetchEdgeTypes();
  19425. /*
  19426. // init D3 force layout
  19427. var force = d3.layout.force()
  19428. .nodes(nodes)
  19429. .links(links)
  19430. .size([width, height])
  19431. .gravity(.05)
  19432. .linkDistance(150)
  19433. .linkStrength(2)
  19434. .charge(-500)
  19435. .on('tick', tick);
  19436. // define arrow markers for graph links
  19437. svg.append('svg:defs').append('svg:marker')
  19438. .attr('id', 'end-arrow')
  19439. .attr('viewBox', '0 -5 10 10')
  19440. .attr('refX', 6)
  19441. .attr('markerWidth', 3)
  19442. .attr('markerHeight', 3)
  19443. .attr('orient', 'auto')
  19444. .append('svg:path')
  19445. .attr('d', 'M0,-5L10,0L0,5')
  19446. .attr('fill', '#000');
  19447. svg.append('svg:defs').append('svg:marker')
  19448. .attr('id', 'start-arrow')
  19449. .attr('viewBox', '0 -5 10 10')
  19450. .attr('refX', 4)
  19451. .attr('markerWidth', 3)
  19452. .attr('markerHeight', 3)
  19453. .attr('orient', 'auto')
  19454. .append('svg:path')
  19455. .attr('d', 'M10,-5L0,0L10,5')
  19456. .attr('fill', '#000');
  19457. // line displayed when dragging new nodes
  19458. var drag_line = svg.append('svg:path')
  19459. .attr('class', 'link dragline hidden')
  19460. .attr('d', 'M0,0L0,0');
  19461. // handles to link and node element groups
  19462. //(1)var path = svg.append('svg:g').selectAll('g')
  19463. var path = svg.append('svg:g').selectAll('g'),
  19464. circle = svg.append('svg:g').selectAll('g');
  19465. */
  19466. // mouse event vars
  19467. var selected_node = null,
  19468. selected_link = null,
  19469. mousedown_link = null,
  19470. mousedown_node = null,
  19471. mouseup_node = null;
  19472. function resetMouseVars() {
  19473. mousedown_node = null;
  19474. mouseup_node = null;
  19475. mousedown_link = null;
  19476. }
  19477. // update force layout (called automatically each iteration)
  19478. function tick() {
  19479. // draw directed edges with proper padding from node centers
  19480. path.selectAll("path").attr("d", function (d) {
  19481. var deltaX = d.target.x - d.source.x,
  19482. deltaY = d.target.y - d.source.y,
  19483. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  19484. normX = deltaX / dist,
  19485. normY = deltaY / dist,
  19486. sourcePadding = d.left ? 27 : 22,
  19487. targetPadding = d.right ? 27 : 22,
  19488. sourceX = d.source.x + sourcePadding * normX,
  19489. sourceY = d.source.y + sourcePadding * normY,
  19490. targetX = d.target.x - targetPadding * normX,
  19491. targetY = d.target.y - targetPadding * normY;
  19492. return (
  19493. "M" +
  19494. sourceX +
  19495. "," +
  19496. sourceY +
  19497. "L" +
  19498. targetX +
  19499. "," +
  19500. targetY
  19501. );
  19502. });
  19503. circle.attr("transform", function (d) {
  19504. return "translate(" + d.x + "," + d.y + ")";
  19505. });
  19506. }
  19507. // update graph (called when needed)
  19508. function restart() {
  19509. //绑定link 数据
  19510. path.datum(links);
  19511. // path (link) group
  19512. path = path.data(links, function (d) {
  19513. return d.id;
  19514. });
  19515. var p = path.enter().append("svg:g");
  19516. //update existing links
  19517. path
  19518. .selectAll("path")
  19519. .classed("selected", function (d) {
  19520. return d === selected_link;
  19521. })
  19522. .style("marker-start", function (d) {
  19523. return d.left ? "url(#start-arrow)" : "";
  19524. })
  19525. .style("marker-end", function (d) {
  19526. return d.right ? "url(#end-arrow)" : "";
  19527. });
  19528. // add new links
  19529. p.append("svg:path")
  19530. .attr("class", "link")
  19531. .attr("id", function (d) {
  19532. return "path_" + d.id;
  19533. })
  19534. // .attr('startOffset', '0%')
  19535. .classed("selected", function (d) {
  19536. return d === selected_link;
  19537. })
  19538. .style("marker-start", function (d) {
  19539. return d.left ? "url(#start-arrow)" : "";
  19540. })
  19541. .style("marker-end", function (d) {
  19542. return d.right ? "url(#end-arrow)" : "";
  19543. })
  19544. .on("mousedown", function (d) {
  19545. if (d3.event.ctrlKey) return;
  19546. //去除没有提交的连线
  19547. for (var i = 0; i < links.length; i++) {
  19548. if (links[i].id == -1 && d.id != -1) {
  19549. links.splice(i, 1);
  19550. }
  19551. }
  19552. // select link
  19553. mousedown_link = d;
  19554. if (mousedown_link === selected_link) {
  19555. selected_link = $scope.selected_link = null;
  19556. selected_node = $scope.selected_node = null;
  19557. // d3.select("#linkDetail").attr('style','display:none');
  19558. //hideLinkForm(true);//return ;
  19559. } else {
  19560. selected_link = $scope.selected_link = mousedown_link;
  19561. selected_node = $scope.selected_node = null;
  19562. }
  19563. selected_node = $scope.selected_node = null;
  19564. restart();
  19565. });
  19566. p.append("svg:text")
  19567. .attr("x", 30)
  19568. .attr("y", 20)
  19569. .attr("class", "fontM")
  19570. .append("textPath")
  19571. .attr("xlink:xlink:href", function (d, i) {
  19572. return "#path_" + d.id;
  19573. })
  19574. .html(function (d) {
  19575. for (var i = 0; i < linkType.length; i++) {
  19576. if (linkType[i].type == d.name) {
  19577. return linkType[i].label;
  19578. }
  19579. }
  19580. });
  19581. // remove old links
  19582. path.exit().remove();
  19583. // circle (node) group
  19584. // NB: the function arg is crucial here! nodes are known by id, not by index!
  19585. circle.datum(nodes);
  19586. circle = circle.data(nodes, function (d) {
  19587. return d.id;
  19588. });
  19589. // update existing nodes (reflexive & selected visual states)
  19590. circle
  19591. .selectAll("circle")
  19592. .style("fill", function (d) {
  19593. return d === selected_node
  19594. ? d3.rgb(colors(d.label)).brighter().toString()
  19595. : colors(d.label);
  19596. })
  19597. .style("fill-opacity", 0.75) // add by xi
  19598. .classed("reflexive", function (d) {
  19599. return d.reflexive;
  19600. });
  19601. // add new nodes
  19602. var g = circle.enter().append("svg:g");
  19603. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  19604. //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');
  19605. g.append("svg:circle")
  19606. .attr("r", 24)
  19607. .style("fill", function (d) {
  19608. return d === selected_node
  19609. ? "rgb(153,153,153)"
  19610. : "rgb(255,255,255)";
  19611. })
  19612. .style("stroke", function (d) {
  19613. return d3.rgb(colors(d.label)).darker().toString();
  19614. })
  19615. .style("stroke-width", "2");
  19616. g.append("svg:circle")
  19617. .attr("class", "node")
  19618. .attr("r", 18)
  19619. .style("fill", function (d) {
  19620. return d === selected_node
  19621. ? d3.rgb(colors(d.label)).brighter().toString()
  19622. : colors(d.label);
  19623. })
  19624. .style("stroke", function (d) {
  19625. return d3.rgb(colors(d.label)).darker().toString();
  19626. })
  19627. .style("fill-opacity", 0.25) //add by xj
  19628. .style("stroke-opacity", 0.5) //add by xj
  19629. .classed("reflexive", function (d) {
  19630. return d.reflexive;
  19631. });
  19632. g.on("mouseover", function (d) {
  19633. //if(!mousedown_node || d === mousedown_node) return;
  19634. // enlarge target node
  19635. //d3.select(this).attr('transform', 'scale(1.1)');
  19636. })
  19637. .on("mouseout", function (d) {
  19638. //if(!mousedown_node || d === mousedown_node) return;
  19639. // unenlarge target node
  19640. //d3.select(this).attr('transform', '');
  19641. })
  19642. .on("mousedown", function (d) {
  19643. if (d3.event.ctrlKey) return;
  19644. //hideLinkForm(true);
  19645. //去除没有提交的连线
  19646. for (var i = 0; i < links.length; i++) {
  19647. if (links[i].id == -1) {
  19648. links.splice(i, 1);
  19649. }
  19650. }
  19651. // select node
  19652. mousedown_node = d;
  19653. if (mousedown_node === selected_node) {
  19654. selected_node = $scope.selected_node = null;
  19655. } else {
  19656. selected_node = $scope.selected_node = mousedown_node;
  19657. selected_link = $scope.selected_link = null;
  19658. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  19659. APIService.findRefById(selected_node.id).then(function (
  19660. result
  19661. ) {
  19662. var d = result.data;
  19663. var node = d.node;
  19664. var link = d.edge;
  19665. var tempNode = [];
  19666. var tempLink = [];
  19667. //nodes 或者links 要去重
  19668. for (var i = 0; i < node.length; i++) {
  19669. var tmp = 0;
  19670. for (var j = 0; j < nodes.length; j++) {
  19671. if (node[i].id == nodes[j].id) {
  19672. tmp++;
  19673. break;
  19674. }
  19675. }
  19676. if (tmp == 0) {
  19677. tempNode.push(node[i]);
  19678. }
  19679. }
  19680. for (var i = 0; i < link.length; i++) {
  19681. var tmp = 0;
  19682. for (var j = 0; j < links.length; j++) {
  19683. if (link[i].id == links[j].id) {
  19684. tmp++;
  19685. break;
  19686. }
  19687. }
  19688. if (tmp == 0) {
  19689. tempLink.push(link[i]);
  19690. }
  19691. }
  19692. //数据写入页面
  19693. for (var i = 0; i < tempNode.length; i++) {
  19694. //nodes 不清空
  19695. nodes.push(tempNode[i]);
  19696. }
  19697. for (var i = 0; i < tempLink.length; i++) {
  19698. //link 不清空
  19699. links.push(tempLink[i]);
  19700. }
  19701. //links转换
  19702. for (var i = 0; i < links.length; i++) {
  19703. for (var j = 0; j < nodes.length; j++) {
  19704. if (links[i].source == nodes[j].id) {
  19705. links[i].source = nodes[j];
  19706. }
  19707. if (links[i].target == nodes[j].id) {
  19708. links[i].target = nodes[j];
  19709. }
  19710. }
  19711. }
  19712. restart();
  19713. });
  19714. }
  19715. // reposition drag line
  19716. drag_line
  19717. .style("marker-end", "url(#end-arrow)")
  19718. .classed("hidden", false)
  19719. .attr(
  19720. "d",
  19721. "M" +
  19722. mousedown_node.x +
  19723. "," +
  19724. mousedown_node.y +
  19725. "L" +
  19726. mousedown_node.x +
  19727. "," +
  19728. mousedown_node.y
  19729. );
  19730. restart();
  19731. })
  19732. .on("mouseup", function (d) {
  19733. if (!mousedown_node) return;
  19734. });
  19735. // show node name
  19736. g.append("svg:text")
  19737. .attr("x", 0)
  19738. .attr("y", 34)
  19739. .attr("class", "id")
  19740. .text(function (d) {
  19741. return d.name;
  19742. }); //TODO 改为 d.name
  19743. //设置图片
  19744. g.append("svg:foreignObject")
  19745. .attr("width", 32)
  19746. .attr("height", 32)
  19747. .attr("x", "-16px")
  19748. .attr("y", "-11px")
  19749. .html(function (d) {
  19750. for (var i = 0; i < labels.length; i++) {
  19751. if (d.label == labels[i].sign) {
  19752. return (
  19753. '<i class="icon iconfont">' +
  19754. labels[i].iconname +
  19755. "</i>"
  19756. );
  19757. }
  19758. }
  19759. });
  19760. // remove old nodes
  19761. circle.exit().remove();
  19762. // set the graph in motion
  19763. force.start();
  19764. }
  19765. function mousedown() {
  19766. // prevent I-bar on drag
  19767. //d3.event.preventDefault();
  19768. // because :active only works in WebKit?
  19769. svg.classed("active", true);
  19770. if (mousedown_node) {
  19771. viewNode(mousedown_node);
  19772. }
  19773. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  19774. return;
  19775. restart();
  19776. }
  19777. function mousemove() {
  19778. if (!mousedown_node) return;
  19779. // update drag line
  19780. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  19781. //restart();
  19782. }
  19783. function mouseup() {
  19784. if (mousedown_node) {
  19785. // hide drag line
  19786. drag_line.classed("hidden", true).style("marker-end", "");
  19787. }
  19788. // because :active only works in WebKit?
  19789. svg.classed("active", false);
  19790. // clear mouse event vars
  19791. resetMouseVars();
  19792. }
  19793. function spliceLinksForNode(node) {
  19794. var toSplice = links.filter(function (l) {
  19795. return l.source === node || l.target === node;
  19796. });
  19797. toSplice.map(function (l) {
  19798. links.splice(links.indexOf(l), 1);
  19799. });
  19800. }
  19801. // only respond once per keydown
  19802. var lastKeyDown = -1;
  19803. function keydown() {
  19804. //d3.event.preventDefault();
  19805. if (lastKeyDown !== -1) return;
  19806. lastKeyDown = d3.event.keyCode;
  19807. // ctrl
  19808. if (d3.event.keyCode === 17) {
  19809. circle.call(force.drag);
  19810. svg.classed("ctrl", true);
  19811. }
  19812. if (!selected_node && !selected_link) return;
  19813. switch (d3.event.keyCode) {
  19814. case 8: // backspace
  19815. case 66: // B
  19816. if (selected_link) {
  19817. // set link direction to both left and right
  19818. selected_link.left = true;
  19819. selected_link.right = true;
  19820. }
  19821. restart();
  19822. break;
  19823. case 76: // L
  19824. if (selected_link) {
  19825. // set link direction to left only
  19826. selected_link.left = true;
  19827. selected_link.right = false;
  19828. }
  19829. restart();
  19830. break;
  19831. case 82: // R
  19832. if (selected_node) {
  19833. // toggle node reflexivity
  19834. selected_node.reflexive = !selected_node.reflexive;
  19835. } else if (selected_link) {
  19836. // set link direction to right only
  19837. selected_link.left = false;
  19838. selected_link.right = true;
  19839. }
  19840. restart();
  19841. break;
  19842. }
  19843. }
  19844. function keyup() {
  19845. lastKeyDown = -1;
  19846. // ctrl
  19847. if (d3.event.keyCode === 17) {
  19848. circle
  19849. .on("mousedown.drag", null)
  19850. .on("touchstart.drag", null);
  19851. svg.classed("ctrl", false);
  19852. }
  19853. }
  19854. function viewNode(node) {
  19855. // console.log(svg.attr('left'));
  19856. //var el = angular.element('div.modal-dialog')[0];
  19857. var title =
  19858. $scope.selected_node.name +
  19859. "-[" +
  19860. $scope.selected_node.uuid +
  19861. "]";
  19862. if (!$scope.selected_node.props.state) {
  19863. $scope.selected_node.props.state = "空";
  19864. } else if ($scope.selected_node.props.state) {
  19865. if ($scope.selected_node.props.state == "1") {
  19866. $scope.selected_node.props.state = "未审核";
  19867. } else if ($scope.selected_node.props.state == "2") {
  19868. $scope.selected_node.props.state = "已审核";
  19869. } else if ($scope.selected_node.props.state == "3") {
  19870. $scope.selected_node.props.state = "不匹配";
  19871. } else if ($scope.selected_node.props.state == "4") {
  19872. $scope.selected_node.props.state = "丢失";
  19873. }
  19874. }
  19875. if (!$scope.selected_node.name) {
  19876. $scope.selected_node.name = "空";
  19877. }
  19878. if (!$scope.selected_node.status) {
  19879. $scope.selected_node.statu = "空";
  19880. }
  19881. if (!$scope.selected_node.props.useradmin) {
  19882. $scope.selected_node.props.useradmin = "空";
  19883. }
  19884. Toaster.pop({
  19885. // type: 'info',
  19886. // title: title,
  19887. body:
  19888. "<br/><p>搜索代码:" +
  19889. $scope.selected_node.uuid +
  19890. "</p>" +
  19891. "<p>配置标题:" +
  19892. $scope.selected_node.name +
  19893. "</p>" +
  19894. "<p>状态:" +
  19895. $scope.selected_node.status +
  19896. "</p>" +
  19897. "<p>审核状态:" +
  19898. $scope.selected_node.props.state +
  19899. "</p>" +
  19900. "<p>维护人员:" +
  19901. $scope.selected_node.props.useradmin +
  19902. "</p>",
  19903. bodyOutputType: "trustedHtml",
  19904. timeout: 3000,
  19905. });
  19906. }
  19907. //GT 颜色与数值对照表
  19908. function colors(sign) {
  19909. //num=num>20?num%20:parseInt(num);
  19910. for (var i = 0; i < labels.length; i++) {
  19911. var entity = labels[i];
  19912. if (sign == entity.sign) {
  19913. return entity.color;
  19914. }
  19915. if (i == labels.length - 1 && sign != entity.sign) {
  19916. return "#ffeeee";
  19917. }
  19918. }
  19919. }
  19920. $scope.init = function () {
  19921. svg = d3
  19922. .select("#cmdbSVG")
  19923. .append("svg")
  19924. .attr("width", width)
  19925. .attr("height", height);
  19926. // init D3 force layout
  19927. force = d3.layout
  19928. .force()
  19929. .nodes(nodes)
  19930. .links(links)
  19931. .size([width, height])
  19932. .gravity(0.05)
  19933. .linkDistance(150)
  19934. .linkStrength(2)
  19935. .charge(-500)
  19936. .on("tick", tick);
  19937. // define arrow markers for graph links
  19938. svg
  19939. .append("svg:defs")
  19940. .append("svg:marker")
  19941. .attr("id", "end-arrow")
  19942. .attr("viewBox", "0 -5 10 10")
  19943. .attr("refX", 6)
  19944. .attr("markerWidth", 3)
  19945. .attr("markerHeight", 3)
  19946. .attr("orient", "auto")
  19947. .append("svg:path")
  19948. .attr("d", "M0,-5L10,0L0,5")
  19949. .attr("fill", "#000");
  19950. svg
  19951. .append("svg:defs")
  19952. .append("svg:marker")
  19953. .attr("id", "start-arrow")
  19954. .attr("viewBox", "0 -5 10 10")
  19955. .attr("refX", 4)
  19956. .attr("markerWidth", 3)
  19957. .attr("markerHeight", 3)
  19958. .attr("orient", "auto")
  19959. .append("svg:path")
  19960. .attr("d", "M10,-5L0,0L10,5")
  19961. .attr("fill", "#000");
  19962. // line displayed when dragging new nodes
  19963. drag_line = svg
  19964. .append("svg:path")
  19965. .attr("class", "link dragline hidden")
  19966. .attr("d", "M0,0L0,0");
  19967. // handles to link and node element groups
  19968. //(1)var path = svg.append('svg:g').selectAll('g')
  19969. path = svg.append("svg:g").selectAll("g");
  19970. circle = svg.append("svg:g").selectAll("g");
  19971. svg
  19972. .on("mousedown", mousedown)
  19973. .on("mousemove", mousemove)
  19974. .on("mouseup", mouseup);
  19975. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  19976. };
  19977. var CI = {};
  19978. window.CI = CI;
  19979. $scope.ok = function () {
  19980. $modalInstance.close($scope.selected_node);
  19981. };
  19982. $scope.cancel = function () {
  19983. $modalInstance.dismiss("cancel");
  19984. };
  19985. },
  19986. size: size,
  19987. resolve: {
  19988. title: function () {
  19989. return options.templateOptions.title;
  19990. },
  19991. Restangular: function () {
  19992. return options.templateOptions.Restangular;
  19993. },
  19994. APIService: function () {
  19995. return options.templateOptions.ApiService;
  19996. },
  19997. ConfigDataService: function () {
  19998. return options.templateOptions.ConfigDataService;
  19999. },
  20000. ConfigFormService: function () {
  20001. return options.templateOptions.ConfigFormService;
  20002. },
  20003. SweetAlert: function () {
  20004. return options.templateOptions.Alert;
  20005. },
  20006. Toaster: function () {
  20007. return options.templateOptions.toaster;
  20008. },
  20009. },
  20010. });
  20011. modalInstance.result.then(
  20012. function (selectedItem) {
  20013. options.value(selectedItem.name + "-" + selectedItem.uuid);
  20014. },
  20015. function () {
  20016. //console.log('Modal dismissed at: ' + new Date());
  20017. }
  20018. );
  20019. },
  20020. },
  20021. };
  20022. },
  20023. controller: [
  20024. "$scope",
  20025. function ($scope) {
  20026. // setTimeout(function(){
  20027. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  20028. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  20029. // if(modelData.status==200){
  20030. // $scope.model[$scope.options.key] = modelData.data;
  20031. // $scope.options.initialValue = $scope.model[$scope.options.key];
  20032. // }
  20033. // });
  20034. // },1000);
  20035. },
  20036. ],
  20037. });
  20038. });
  20039. appFormly.run(function (formlyConfig, $parse) {
  20040. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  20041. var removeOnHideTransformer = function (fields, model) {
  20042. return fields.map(function (field) {
  20043. if (
  20044. field.hideExpression &&
  20045. (!field.data || !field.data.dontRemoveOnHidden)
  20046. ) {
  20047. addFieldRemoveOnHideWatcher(field);
  20048. }
  20049. if (field.type == "ui-title") {
  20050. addFieldRemoveOnHideWatcher(field);
  20051. }
  20052. return field;
  20053. });
  20054. };
  20055. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  20056. function addFieldRemoveOnHideWatcher(field) {
  20057. var watcher = getWatcher();
  20058. if (field.watcher) {
  20059. if (!angular.isArray(field.watcher)) {
  20060. field.watcher = [field.watcher];
  20061. }
  20062. field.watcher.push(watcher);
  20063. } else {
  20064. field.watcher = watcher;
  20065. }
  20066. }
  20067. function getWatcher() {
  20068. return {
  20069. expression: function (field) {
  20070. return field.hide;
  20071. },
  20072. listener: function (field, newHide, oldHide, scope) {
  20073. if (field.hide) {
  20074. if (field.templateOptions.pkey) {
  20075. if (field.key == "transferuser") {
  20076. $parse(field.templateOptions.pkey + "." + field.key).assign(
  20077. scope.model,
  20078. undefined
  20079. );
  20080. }
  20081. } else {
  20082. $parse(field.key).assign(scope.model, undefined);
  20083. }
  20084. }
  20085. if (field.type == "ui-title") {
  20086. $parse(field.key).assign(scope.model, undefined);
  20087. }
  20088. },
  20089. };
  20090. }
  20091. });
  20092. appFormly.controller("CustomformCtrl", [
  20093. "$rootScope",
  20094. "$scope",
  20095. "$parse",
  20096. "$injector",
  20097. "$http",
  20098. "$q",
  20099. "$state",
  20100. "$stateParams",
  20101. "$modal",
  20102. "$timeout",
  20103. "$interval",
  20104. "SweetAlert",
  20105. "FileUploader",
  20106. "i18nService",
  20107. "Restangular",
  20108. "UserRestangular",
  20109. "BpmRestangular",
  20110. "WechatRestangular",
  20111. "api_configure_form",
  20112. "api_bpm_domain",
  20113. "api_bpm_domain1",
  20114. "api_bpm",
  20115. "api_bpm_data",
  20116. "api_user_data",
  20117. "api_statistic",
  20118. "up_down_file",
  20119. "fileReader",
  20120. function (
  20121. $rootScope,
  20122. $scope,
  20123. $parse,
  20124. $injector,
  20125. $http,
  20126. $q,
  20127. $state,
  20128. $stateParams,
  20129. $modal,
  20130. $timeout,
  20131. $interval,
  20132. SweetAlert,
  20133. FileUploader,
  20134. i18nService,
  20135. Restangular,
  20136. UserRestangular,
  20137. BpmRestangular,
  20138. WechatRestangular,
  20139. api_configure_form,
  20140. api_bpm_domain,
  20141. api_bpm_domain1,
  20142. api_bpm,
  20143. api_bpm_data,
  20144. api_user_data,
  20145. api_statistic,
  20146. up_down_file,
  20147. fileReader
  20148. ) {
  20149. //console.log($parse('Restangular')($scope));
  20150. //console.log($injector.get('Restangular'));
  20151. //console.log($stateParams);
  20152. //保存报修主体
  20153. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  20154. $scope.imgUrlList = [];
  20155. $scope.uploadimg_del = function () {
  20156. console.log(123);
  20157. };
  20158. var vm = this;
  20159. vm.options = {};
  20160. vm.exampleTitle = ["expressionProperties", "model property"];
  20161. vm.fields = [];
  20162. vm.model = {};
  20163. $scope.langs = i18nService.getAllLangs();
  20164. $scope.lang = "zh-cn";
  20165. i18nService.setCurrentLang($scope.lang);
  20166. //alert($rootScope.user.id,null,2);
  20167. vm.model["loginUser"] = $rootScope.user;
  20168. var loginUser = $rootScope.user;
  20169. // console.log(vm);
  20170. var that = $injector;
  20171. var parse = $parse;
  20172. var formKey = "";
  20173. var pdKey = "";
  20174. var modelWatch = "";
  20175. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20176. modelWatch = JSON.parse($stateParams.model);
  20177. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  20178. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  20179. console.log(modelWatch, $rootScope);
  20180. // if(modelWatch.model.incident){
  20181. // if(modelWatch.model.incident.place){
  20182. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  20183. // }else{
  20184. // $rootScope.selecthouseNumber = undefined;
  20185. // }
  20186. // }
  20187. }
  20188. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  20189. pdKey = $state.current.pdKey;
  20190. } else if ($stateParams.pdKey) {
  20191. pdKey = $stateParams.pdKey;
  20192. }
  20193. // console.log("pdKey::" + JSON.stringify($state.current.title));
  20194. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  20195. formKey = $stateParams.formKey;
  20196. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  20197. }
  20198. if (angular.isDefined($stateParams.model)) {
  20199. var formModel = $stateParams.model;
  20200. }
  20201. //用户测试数据,后续从header的auth中获取
  20202. var userId = 2;
  20203. userId = $rootScope.user.id;
  20204. //==============处理表单设计数据 开始====================
  20205. //处理组件加载后台数据选项的方法
  20206. function refreshSelectOptions(searchVal, field) {
  20207. if (
  20208. field.templateOptions.optionsUrl &&
  20209. !field.templateOptions.isnosearch
  20210. ) {
  20211. var process = BpmRestangular.all("");
  20212. if (field.templateOptions.ApiService) {
  20213. process = UserRestangular.all("");
  20214. }
  20215. if (field.templateOptions.Apicommon) {
  20216. process = WechatRestangular.all("");
  20217. }
  20218. var datakey = {
  20219. idx: 0,
  20220. sum: 1000,
  20221. };
  20222. if (field.templateOptions.modelreasondata) {
  20223. datakey = field.templateOptions.modelreasondata;
  20224. }
  20225. process
  20226. .customPOST(datakey, field.templateOptions.optionsUrl)
  20227. .then(function (result) {
  20228. if (!field.templateOptions.options) {
  20229. field.templateOptions.options = [];
  20230. }
  20231. if (field.templateOptions.optionsDataKey) {
  20232. field.templateOptions.options =
  20233. result[field.templateOptions.optionsDataKey];
  20234. } else {
  20235. field.templateOptions.options = result;
  20236. }
  20237. });
  20238. }
  20239. }
  20240. //获取表单后数据处理
  20241. function formfield(field, result) {
  20242. // angular.forEach(fields.fields, function(field) {
  20243. if (field.key == "") {
  20244. delete field.key;
  20245. }
  20246. if (angular.isDefined(field.extjson)) {
  20247. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  20248. angular.extend(field.templateOptions, extObj.templateOptions);
  20249. delete extObj.templateOptions;
  20250. for (var prop in extObj) {
  20251. if (new RegExp("Expression").test(prop)) {
  20252. //var obj = $scope.$eval(extObj[prop]);
  20253. //extObj[prop] = $scope.$eval(extObj[prop]);
  20254. if (extObj[prop] != null) {
  20255. if (new RegExp("function").test(extObj[prop])) {
  20256. var propValue = eval(extObj[prop]);
  20257. extObj[prop] = propValue;
  20258. } else {
  20259. //console.log(extObj[prop]);
  20260. var obj = $scope.$eval(extObj[prop]);
  20261. extObj[prop] = obj;
  20262. //console.log(obj);
  20263. }
  20264. }
  20265. } else if (new RegExp("expressionProperties").test(prop)) {
  20266. for (var p in extObj[prop]) {
  20267. if (new RegExp("function").test(extObj[prop][p])) {
  20268. var propValue = eval(extObj[prop][p]);
  20269. extObj[prop][p] = propValue;
  20270. } else {
  20271. //if(p.indexOf("'")>=0){
  20272. // var obj = $scope.$eval(extObj[prop][p]);
  20273. // extObj[prop][$scope.$eval(p)]=obj;
  20274. //}
  20275. }
  20276. }
  20277. } else if ("watcher" == prop) {
  20278. if (angular.isArray(extObj[prop])) {
  20279. angular.forEach(extObj[prop], function (item, index) {
  20280. for (var p in item) {
  20281. if (new RegExp("function").test(item[p])) {
  20282. var propValue = eval(item[p]);
  20283. extObj[prop][index][p] = propValue;
  20284. }
  20285. }
  20286. });
  20287. } else if (angular.isObject(extObj[prop])) {
  20288. for (var p in extObj[prop]) {
  20289. if (new RegExp("function").test(extObj[prop][p])) {
  20290. var propValue = eval(extObj[prop][p]);
  20291. extObj[prop][p] = propValue;
  20292. }
  20293. }
  20294. }
  20295. }
  20296. }
  20297. angular.extend(field, extObj);
  20298. delete field.extjson;
  20299. }
  20300. if (angular.isDefined(field.templateOptions)) {
  20301. var templateOs = field.templateOptions;
  20302. // console.log(templateOs,'come')
  20303. for (var property in templateOs) {
  20304. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  20305. if (angular.isString(templateOs[property])) {
  20306. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  20307. if (new RegExp("function").test(templateOs[property])) {
  20308. var propValue = eval(templateOs[property]);
  20309. field.templateOptions[property] = propValue;
  20310. } else {
  20311. if (that.has(templateOs[property])) {
  20312. field.templateOptions[property] = that.get(
  20313. templateOs[property]
  20314. );
  20315. } else {
  20316. field.templateOptions[property] = templateOs[property];
  20317. }
  20318. }
  20319. } else if (templateOs[property] == null) {
  20320. //delete field.templateOptions[property];
  20321. } else {
  20322. }
  20323. }
  20324. }
  20325. if (
  20326. angular.isDefined(field.templateOptions) &&
  20327. angular.isDefined(field.templateOptions.extjson)
  20328. ) {
  20329. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  20330. angular.extend(field.templateOptions, extObj);
  20331. delete field.templateOptions.extjson;
  20332. }
  20333. // ...
  20334. if (field.templateOptions) {
  20335. //处理远程获取数据控件方法调用
  20336. if (
  20337. field.templateOptions.optionsUrl &&
  20338. !field.templateOptions.refresh
  20339. ) {
  20340. // if (!field.templateOptions.isnoreash) {
  20341. field.templateOptions.refresh = refreshSelectOptions;
  20342. // }
  20343. }
  20344. //处理嵌套属性数据绑定/
  20345. if (field.templateOptions.pkey) {
  20346. var pmodel,
  20347. i = 0;
  20348. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  20349. if (i == 0) {
  20350. if (result.model[p] == null) {
  20351. result.model[p] = {};
  20352. }
  20353. pmodel = result.model[p];
  20354. i++;
  20355. } else {
  20356. if (pmodel[p] == null) {
  20357. pmodel[p] = {};
  20358. }
  20359. pmodel = pmodel[p];
  20360. }
  20361. });
  20362. if (pmodel != null) {
  20363. field.model = pmodel;
  20364. if (pmodel[field.key] == null) {
  20365. pmodel[field.key] = null;
  20366. }
  20367. }
  20368. } else {
  20369. if (result.model[field.key] == null) {
  20370. result.model[field.key] = null;
  20371. }
  20372. }
  20373. //处理弹出框组件初始化
  20374. if (field.type == "ui-input-selectmodal") {
  20375. field.templateOptions.modal = $modal;
  20376. //field.templateOptions.Restangular = Restangular;
  20377. } else if (field.type == "ui-requesterselect") {
  20378. //field.templateOptions.language = $scope.lang;
  20379. field.templateOptions.modal = $modal;
  20380. field.templateOptions.UserService = api_user_data;
  20381. } else if (field.type == "ui-deptinformation") {
  20382. field.templateOptions.modal = $modal;
  20383. field.templateOptions.UserService = api_user_data;
  20384. } else if (field.type == "ui-requesterinformation") {
  20385. field.templateOptions.modal = $modal;
  20386. field.templateOptions.UserService = api_user_data;
  20387. } else if (field.type == "ui-userselect") {
  20388. field.templateOptions.modal = $modal;
  20389. //field.templateOptions.Restangular = Restangular;
  20390. } else if (field.type == "ui-userselectSearch") {
  20391. field.templateOptions.modal = $modal;
  20392. //field.templateOptions.Restangular = Restangular;
  20393. } else if (field.type == "ui-multiuserselect") {
  20394. field.templateOptions.modal = $modal;
  20395. } else if (field.type == "ui-stringuserselect") {
  20396. field.templateOptions.modal = $modal;
  20397. } else if (field.type == "ui-search") {
  20398. field.templateOptions.modal = $modal;
  20399. } else if (field.type == "ui-modelselect") {
  20400. field.templateOptions.modal = $modal;
  20401. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20402. field.templateOptions.loginUser = $rootScope.user;
  20403. //field.templateOptions.Restangular = Restangular;
  20404. } else if (field.type == "ui-incidentmodelselect") {
  20405. field.templateOptions.modal = $modal;
  20406. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20407. field.templateOptions.loginUser = $rootScope.user;
  20408. //field.templateOptions.Restangular = Restangular;
  20409. } else if (field.type == "ui-dropfile") {
  20410. $scope.fileUploader = field.templateOptions.fileUploader =
  20411. new FileUploader({
  20412. url: "/uploader",
  20413. });
  20414. field.templateOptions.taskId = $stateParams.taskId;
  20415. field.templateOptions.processInstanceId =
  20416. $stateParams.processInstanceId;
  20417. field.templateOptions.userId = $rootScope.user.id;
  20418. } else if (field.type == "ui-dropfielknow") {
  20419. $scope.fileUploader = field.templateOptions.fileUploader =
  20420. new FileUploader({
  20421. url: "/uploader",
  20422. });
  20423. field.templateOptions.taskId = $stateParams.taskId;
  20424. field.templateOptions.processInstanceId =
  20425. $stateParams.processInstanceId;
  20426. field.templateOptions.userId = $rootScope.user.id;
  20427. } else if (field.type == "ui-upDropFile") {
  20428. $scope.fileUploader = field.templateOptions.fileUploader =
  20429. new FileUploader({
  20430. url: "/uploader",
  20431. });
  20432. field.templateOptions.taskId = $stateParams.taskId;
  20433. field.templateOptions.processInstanceId =
  20434. $stateParams.processInstanceId;
  20435. field.templateOptions.userId = $rootScope.user.id;
  20436. } else if (field.type == "ui-dropfilenotup") {
  20437. $scope.fileUploader = field.templateOptions.fileUploader =
  20438. new FileUploader({
  20439. url: "/uploader",
  20440. });
  20441. field.templateOptions.taskId = $stateParams.taskId;
  20442. field.templateOptions.processInstanceId =
  20443. $stateParams.processInstanceId;
  20444. field.templateOptions.userId = $rootScope.user.id;
  20445. //field.ApiService=api_bpm_domain;
  20446. } else if (field.type == "ui-uploadFiles") {
  20447. $scope.fileUploader = field.templateOptions.fileUploader =
  20448. new FileUploader({
  20449. url: "/uploader",
  20450. });
  20451. field.templateOptions.taskId = $stateParams.taskId;
  20452. field.templateOptions.processInstanceId =
  20453. $stateParams.processInstanceId;
  20454. field.templateOptions.userId = $rootScope.user.id;
  20455. //field.ApiService=api_bpm_domain;
  20456. } else if (field.type == "ui-upDownFiles") {
  20457. $scope.fileUploader = field.templateOptions.fileUploader =
  20458. new FileUploader({
  20459. url: "/uploader",
  20460. });
  20461. field.templateOptions.taskId = $stateParams.taskId;
  20462. field.templateOptions.processInstanceId =
  20463. $stateParams.processInstanceId;
  20464. field.templateOptions.userId = $rootScope.user.id;
  20465. //field.ApiService=api_bpm_domain;
  20466. } else if (field.type == "ui-uploadImgs") {
  20467. $scope.fileUploader = field.templateOptions.fileUploader =
  20468. new FileUploader({
  20469. url: "/uploader",
  20470. });
  20471. field.templateOptions.taskId = $stateParams.taskId;
  20472. field.templateOptions.processInstanceId =
  20473. $stateParams.processInstanceId;
  20474. field.templateOptions.userId = $rootScope.user.id;
  20475. //field.ApiService=api_bpm_domain;
  20476. } else if (field.type == "ui-dropfiletable") {
  20477. if (field.templateOptions.processInstanceId) {
  20478. } else {
  20479. field.templateOptions.processInstanceId =
  20480. $stateParams.processInstanceId;
  20481. }
  20482. } else if (field.type == "ui-dropFiles") {
  20483. if (field.templateOptions.processInstanceId) {
  20484. } else {
  20485. field.templateOptions.processInstanceId =
  20486. $stateParams.processInstanceId;
  20487. }
  20488. } else if (field.type == "ui-showImgs") {
  20489. if (field.templateOptions.processInstanceId) {
  20490. } else {
  20491. field.templateOptions.processInstanceId =
  20492. $stateParams.processInstanceId;
  20493. }
  20494. } else if (field.type == "ui-repeatSection") {
  20495. var repeatForm = {
  20496. model: {},
  20497. fields: field.templateOptions.fields,
  20498. };
  20499. repeatForm.model[field.key] = [];
  20500. decodeVMForm(repeatForm);
  20501. } else if (field.type == "ui-currentuser") {
  20502. field.templateOptions.user = vm.model["loginUser"];
  20503. } else if (field.type == "ui-workernumbersign") {
  20504. field.templateOptions.user = vm.model["loginUser"];
  20505. } else if (field.type == "ui-repair-photos") {
  20506. field.templateOptions.user = vm.model["loginUser"];
  20507. }
  20508. }
  20509. }
  20510. //解析自定义表单设计数据
  20511. $scope.oldfromtype = true;
  20512. function decodeVMForm(vmForm) {
  20513. if (vmForm.formType == "1") {
  20514. $scope.oldfromtype = false;
  20515. } else {
  20516. $scope.oldfromtype = true;
  20517. }
  20518. var result = {
  20519. model: {},
  20520. fields: [],
  20521. };
  20522. //设置模型实体数据 begin
  20523. // var mdata = vmForm.model;
  20524. //解析数据实体
  20525. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  20526. angular.extend(result.model, mdata);
  20527. if (modelWatch != null && modelWatch != "") {
  20528. //angular.extend(result.model.incident,modelWatch.incident);
  20529. //result.model.alarmType = modelWatch.alarmType;
  20530. // vmForm.cancelUrl = modelWatch.cancelUrl;
  20531. // console.log(modelWatch.cancelUrl)
  20532. for (var index in modelWatch.model) {
  20533. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  20534. if (result.model[index] != null) {
  20535. angular.extend(result.model[index], modelWatch.model[index]);
  20536. } else {
  20537. result.model[index] = modelWatch.model[index];
  20538. }
  20539. }
  20540. }
  20541. //设置模型实体数据 end
  20542. //解析设计数据生成表单项 begin
  20543. var fields = [];
  20544. //处理修改设计数据中展示设置
  20545. angular.forEach(vmForm.fields, function (fields) {
  20546. if (vmForm.formType == "1") {
  20547. angular.forEach(fields.fields, function (field) {
  20548. formfield(field, result);
  20549. });
  20550. } else {
  20551. formfield(fields, result);
  20552. }
  20553. // console.log(field);
  20554. result.fields.push(fields);
  20555. });
  20556. angular.extend($scope.vm.fields, result.fields);
  20557. angular.extend($scope.vm.model, result.model);
  20558. vm.model["loginUser"] = $rootScope.user;
  20559. //增加识别报修主体seimin
  20560. vm.model.repairType = $scope.repairMain.valueconfig;
  20561. if (vm.model.incident) {
  20562. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  20563. }
  20564. console.log(vm, "repairType"); //lmm
  20565. if (
  20566. modelWatch != null &&
  20567. modelWatch != "" &&
  20568. modelWatch.cancelUrl != null &&
  20569. modelWatch.cancelUrl != ""
  20570. ) {
  20571. vmForm.cancelUrl = modelWatch.cancelUrl;
  20572. }
  20573. $scope.formData = vmForm;
  20574. console.log($scope.formData, 4444444);
  20575. // console.log($scope.formData.url);
  20576. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  20577. if ($scope.formData.url == "start") {
  20578. $scope.Reset = true;
  20579. $scope.close = true;
  20580. $rootScope.isMask = false;
  20581. } else if ($scope.formData.url == "complete") {
  20582. $scope.Reset = false;
  20583. $scope.close = true;
  20584. }
  20585. //解析设计数据生成表单项 end
  20586. return result;
  20587. }
  20588. //======================处理表单设计数据 结束========================
  20589. $scope.ldloading = {};
  20590. function filter(obj) {
  20591. angular.forEach(obj, function (key, value) {
  20592. if (value === "" || value === null) {
  20593. delete obj[key];
  20594. } else if (
  20595. Object.prototype.toString.call(value) === "[object Object]"
  20596. ) {
  20597. filter(value);
  20598. } else if (angular.isArray(value)) {
  20599. angular.forEach(value, function (item) {
  20600. filter(item);
  20601. });
  20602. }
  20603. });
  20604. }
  20605. $scope.closeModel = function () {
  20606. // console.log($stateParams);
  20607. $state.go($scope.formData.cancelUrl, {});
  20608. event.preventDefault();
  20609. };
  20610. // console.log(vm);
  20611. // 暂存
  20612. $scope.save = function (data) {
  20613. console.log(vm);
  20614. if (vm.model.startSave) {
  20615. vm.model["initUser"] = $rootScope.user.id;
  20616. vm.model.start_code = "temporary";
  20617. //处理请求数据0327
  20618. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20619. delete data0327.repairType;
  20620. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20621. if (
  20622. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20623. .selecthouseNumber
  20624. ) {
  20625. data0327.incident.place = {
  20626. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20627. .selecthouseNumber.id,
  20628. };
  20629. }
  20630. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  20631. if (response) {
  20632. var resData = Restangular.stripRestangular(response);
  20633. if (resData) {
  20634. if (
  20635. $scope.fileUploader != null &&
  20636. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  20637. resData.id
  20638. ) {
  20639. $scope.fileUploader.onBeforeUploadItem = function (item) {
  20640. angular.extend(item.headers, $rootScope.getSession());
  20641. item.url = api_bpm_domain
  20642. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  20643. .getRequestedUrl();
  20644. item.formData.push({
  20645. fileName: item.file.name,
  20646. });
  20647. //console.log();
  20648. };
  20649. $scope.fileUploader.uploadAll();
  20650. }
  20651. }
  20652. SweetAlert.swal(
  20653. {
  20654. title: "提交成功!",
  20655. type: "success",
  20656. confirmButtonColor: "#007AFF",
  20657. },
  20658. function () {
  20659. $state.go($scope.formData.cancelUrl);
  20660. }
  20661. );
  20662. } else {
  20663. SweetAlert.swal({
  20664. title: "系统错误",
  20665. text: "系统错误,请稍后重试!",
  20666. type: "error",
  20667. confirmButtonColor: "#DD6B55",
  20668. });
  20669. }
  20670. $scope.ldloading[style.replace("-", "_")] = false;
  20671. });
  20672. event.preventDefault();
  20673. } else if (vm.model.saveAgain) {
  20674. var toData = {
  20675. incident: vm.model.incident,
  20676. };
  20677. api_user_data.updData("incident", toData).then(function (response) {
  20678. if (response) {
  20679. var resData = Restangular.stripRestangular(response);
  20680. SweetAlert.swal(
  20681. {
  20682. title: "提交成功!",
  20683. type: "success",
  20684. confirmButtonColor: "#007AFF",
  20685. },
  20686. function () {
  20687. $state.go($scope.formData.cancelUrl);
  20688. }
  20689. );
  20690. } else {
  20691. SweetAlert.swal({
  20692. title: "系统错误",
  20693. text: "系统错误,请稍后重试!",
  20694. type: "error",
  20695. confirmButtonColor: "#DD6B55",
  20696. });
  20697. }
  20698. $scope.ldloading[style.replace("-", "_")] = false;
  20699. });
  20700. event.preventDefault();
  20701. } else {
  20702. SweetAlert.swal({
  20703. title: "系统错误",
  20704. text: "系统错误,请稍后重试!",
  20705. type: "error",
  20706. confirmButtonColor: "#DD6B55",
  20707. });
  20708. }
  20709. };
  20710. // 巡检生成事件
  20711. $scope.inspectionToIncident = function () {
  20712. var userData = {
  20713. idx: 0,
  20714. sum: 10,
  20715. requester: {
  20716. name: loginUser.name,
  20717. },
  20718. };
  20719. api_user_data.fetchDataList("requester", userData).then(function (res) {
  20720. console.log(res);
  20721. var toUser = {};
  20722. if (res.list.length > 0) {
  20723. toUser = res.list[0];
  20724. } else {
  20725. toUser = loginUser;
  20726. }
  20727. console.log(vm);
  20728. var incidentDescription = "";
  20729. console.log($stateParams.formUiEdit);
  20730. if ($stateParams.formUiEdit == "inspection_LinHu_confirm") {
  20731. var fields = vm.fields
  20732. .filter((v) => {
  20733. v.key = (v.key || "").toString();
  20734. return v.key.indexOf("sdCheckEnable") > -1;
  20735. })
  20736. .map((v) => ({
  20737. key: v.key,
  20738. name: v.templateOptions.label,
  20739. value: vm.model[v.key],
  20740. }));
  20741. fields.forEach(v=>{
  20742. if (vm.model[v.key]) {
  20743. incidentDescription =
  20744. incidentDescription.concat(v.name);
  20745. }
  20746. })
  20747. if (vm.model.descriptionTextarea) {
  20748. incidentDescription = incidentDescription.concat(
  20749. " " + "整改意见:" + vm.model.descriptionTextarea
  20750. );
  20751. }
  20752. }
  20753. // console.log(incidentDescription)
  20754. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  20755. var formdata = {
  20756. model: {
  20757. // 'isInspection': true,
  20758. // 'start_code':'assignment',
  20759. // 'isHandlerUser':false,
  20760. incident: {
  20761. requester: bxr,
  20762. area: bxr.place.area,
  20763. place: bxr.place,
  20764. houseNumber: bxr.houseNumber,
  20765. contacts: bxr.name,
  20766. contactsInformation: bxr.mphone,
  20767. // 'category': data.wxIncidentClassifyDTO.category,
  20768. description: incidentDescription,
  20769. source: {
  20770. id: 1552,
  20771. },
  20772. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  20773. // 'sourceType': data.incident.sourceType,
  20774. // 'fileUrl': data.incident.fileUrl
  20775. },
  20776. // 'requestershow': toUser,//2020年4月27日22:29:15
  20777. // 'flow': data.incident.id
  20778. // 'assignee': loginUser.id//2020年4月27日22:29:25
  20779. },
  20780. };
  20781. // console.log(formdata,toUser,'1111');
  20782. console.log(formdata, "1111");
  20783. // return;
  20784. $state.go("app.incident.chart", {
  20785. model: JSON.stringify(formdata),
  20786. });
  20787. });
  20788. // var formdata = {
  20789. // model:$rootScope.login_requester
  20790. // };
  20791. // console.log(formdata,'00000')
  20792. // return;
  20793. // $state.go("app.incident.chart", {
  20794. // 'model': JSON.stringify(formdata)
  20795. // });
  20796. event.preventDefault();
  20797. };
  20798. // console.log(vm);
  20799. // 创建事件seimin
  20800. vm.submit = function (data, style) {
  20801. console.log(vm, 22222);
  20802. // return;
  20803. if (vm.model.handler_code == undefined) {
  20804. vm.model.handler_code = "resolve";
  20805. }
  20806. if (
  20807. vm.model.change &&
  20808. vm.model.change.requestingPerson &&
  20809. vm.model.change.requestingPerson.menu
  20810. ) {
  20811. delete vm.model.change.requestingPerson.menu;
  20812. }
  20813. // var pdKey = $stateParams.pdKey;
  20814. if (vm.form.$valid) {
  20815. if (data.incident && data.incident.synergetic) {
  20816. console.log(data.incident.synergetic);
  20817. var synergetic = [];
  20818. for (var i = 0; i < data.incident.synergetic.length; i++) {
  20819. synergetic.push({
  20820. id: data.incident.synergetic[i],
  20821. });
  20822. }
  20823. data.incident.synergetic = synergetic;
  20824. vm.model.incident.synergetic = synergetic;
  20825. }
  20826. $scope.ldloading[style.replace("-", "_")] = true;
  20827. var startsub = true;
  20828. if (pdKey == "bpm_incident") {
  20829. angular.forEach(vm.fields, function (item) {
  20830. angular.forEach(item.fields, function (index) {
  20831. if (index.templateOptions.required && !index.hide) {
  20832. if (index.model) {
  20833. if (
  20834. angular.isDefined(index.model[index.key]) &&
  20835. index.model[index.key] != null
  20836. ) {
  20837. if (
  20838. index.model[index.key].id &&
  20839. index.model[index.key].id == ""
  20840. ) {
  20841. startsub = false;
  20842. $scope.ldloading.expand_right = false;
  20843. SweetAlert.swal({
  20844. title: index.templateOptions.label + "未填",
  20845. text: "请填写此项!",
  20846. type: "error",
  20847. confirmButtonColor: "#DD6B55",
  20848. });
  20849. } else {
  20850. }
  20851. } else {
  20852. startsub = false;
  20853. $scope.ldloading.expand_right = false;
  20854. console.log(vm);
  20855. SweetAlert.swal({
  20856. title: index.templateOptions.label + "未填",
  20857. text: "请填写此项!",
  20858. type: "error",
  20859. confirmButtonColor: "#DD6B55",
  20860. });
  20861. }
  20862. } else {
  20863. if (
  20864. data[index.key] &&
  20865. data[index.key] != "" &&
  20866. data[index.key] != null
  20867. ) {
  20868. } else {
  20869. startsub = false;
  20870. $scope.ldloading.expand_right = false;
  20871. SweetAlert.swal({
  20872. title: index.templateOptions.label + "未填",
  20873. text: "请填写此项!",
  20874. type: "error",
  20875. confirmButtonColor: "#DD6B55",
  20876. });
  20877. }
  20878. }
  20879. }
  20880. });
  20881. });
  20882. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  20883. // startsub = false;
  20884. // $scope.ldloading.expand_right = false;
  20885. // SweetAlert.swal({
  20886. // title: '保修人未填',
  20887. // text: "请填写此项!",
  20888. // type: "error",
  20889. // confirmButtonColor: "#DD6B55"
  20890. // });
  20891. // }
  20892. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  20893. // } else {
  20894. // startsub = false;
  20895. // $scope.ldloading.expand_right = false;
  20896. // SweetAlert.swal({
  20897. // title: '事件分类未填',
  20898. // text: "请填写此项!",
  20899. // type: "error",
  20900. // confirmButtonColor: "#DD6B55"
  20901. // });
  20902. // }
  20903. }
  20904. if (startsub) {
  20905. $scope.ldloading[style.replace("-", "_")] = true;
  20906. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  20907. // console.log("vm.options:"+ JSON.stringify(vm.options));
  20908. vm.options.updateInitialValue();
  20909. // console.log("dfjkasdhfkhskjf ")
  20910. var _ = window._;
  20911. vm.model = (function filter(obj) {
  20912. var dateTransKeys = [];
  20913. var filtered = _.pick(obj, function (v, k, obj) {
  20914. if (_.isDate(v)) {
  20915. dateTransKeys.push(k);
  20916. }
  20917. return (
  20918. angular.isDefined(v) &&
  20919. v !== null &&
  20920. (angular.isArray(v) ? v.length > 0 : true) &&
  20921. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  20922. );
  20923. });
  20924. return _.cloneDeep(filtered, function (v, index, object) {
  20925. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  20926. angular.forEach(dateTransKeys, function (item) {
  20927. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  20928. });
  20929. dateTransKey = [];
  20930. return v;
  20931. }
  20932. return !_.isEmpty(filtered) &&
  20933. v !== filtered &&
  20934. _.isPlainObject(v)
  20935. ? filter(v)
  20936. : undefined;
  20937. });
  20938. })(vm.model);
  20939. if (pdKey != "") {
  20940. if ($scope.oprcode == "save") {
  20941. //保存
  20942. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  20943. if (response) {
  20944. var resData = Restangular.stripRestangular(response);
  20945. SweetAlert.swal(
  20946. {
  20947. title: "保存成功!",
  20948. confirmButtonColor: "#007AFF",
  20949. },
  20950. function () {
  20951. $state.go($scope.formData.cancelUri);
  20952. }
  20953. );
  20954. // if(resData.status){
  20955. // resData
  20956. // }
  20957. } else {
  20958. SweetAlert.swal({
  20959. title: "系统错误",
  20960. text: "系统错误,请稍后重试!",
  20961. type: "error",
  20962. confirmButtonColor: "#DD6B55",
  20963. });
  20964. }
  20965. $scope.ldloading[style.replace("-", "_")] = false;
  20966. });
  20967. } else {
  20968. console.log($scope.formData.url, "zzzz");
  20969. switch ($scope.formData.url) {
  20970. case "start":
  20971. vm.model["initUser"] = $rootScope.user.id;
  20972. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  20973. } else {
  20974. vm.model["assignee"] = $rootScope.user.id;
  20975. }
  20976. if (
  20977. vm.model["candidateGroups"] &&
  20978. vm.model.candidateGroups.id
  20979. ) {
  20980. vm.model.candidateGroups = vm.model.candidateGroups.id;
  20981. }
  20982. if (pdKey == "bpm_service_request") {
  20983. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  20984. angular.extend(vm.model.serviceCatalogueProcessActual, {
  20985. category: {
  20986. id: $stateParams.userId,
  20987. },
  20988. });
  20989. }
  20990. if (vm.model.schedule && vm.model.schedule.initUser) {
  20991. delete vm.model.schedule.initUser.menu;
  20992. }
  20993. if (
  20994. vm.model.isHandlerUser == "true" ||
  20995. vm.model.isHandlerUser == true
  20996. ) {
  20997. delete vm.model.candidateGroups;
  20998. }
  20999. if (vm.model.start_code == "close") {
  21000. // 直接处理
  21001. vm.model.incident.handlingPersonnelUser =
  21002. vm.model.incident.acceptUser;
  21003. delete vm.model.incident.handlerUser;
  21004. delete vm.model.candidateGroups;
  21005. } else if (vm.model.start_code == "assignment") {
  21006. // 派单
  21007. delete vm.model.incident.handlingPersonnelUser;
  21008. }
  21009. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  21010. $scope.jry_processInstanceId =
  21011. $stateParams.processInstanceId;
  21012. }
  21013. if ($scope.jry_processInstanceId) {
  21014. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  21015. }
  21016. //事件暂存判断
  21017. if (vm.model.saveAgain) {
  21018. if (
  21019. vm.model.directClose == "1" ||
  21020. vm.model.directClose == true
  21021. ) {
  21022. vm.model.start_code = "assignment";
  21023. vm.model.temporary_code = "assignment";
  21024. } else {
  21025. vm.model.start_code = "close";
  21026. vm.model.temporary_code = "close";
  21027. }
  21028. if (
  21029. vm.model.isHandlerUser == "true" ||
  21030. vm.model.isHandlerUser == true
  21031. ) {
  21032. delete vm.model.candidateGroups;
  21033. }
  21034. }
  21035. //处理请求数据0327
  21036. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21037. delete data0327.repairType;
  21038. // 增加地点的请求参数2020年4月24日10:44:36
  21039. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  21040. // if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  21041. // data0327.incident.place = {
  21042. // id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  21043. // }
  21044. // }
  21045. if (data0327.start_code == "close") {
  21046. data0327.incident.directProcess = 1;
  21047. }
  21048. console.log(vm);
  21049. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  21050. var paramsModel = JSON.parse($stateParams.model)
  21051. //来电-传话机id
  21052. if (paramsModel.model.incident.sockid) {
  21053. data0327.incident.callID = paramsModel.model.incident.sockid;
  21054. }
  21055. }
  21056. api_bpm_domain
  21057. .start(pdKey, data0327)
  21058. .then(function (response) {
  21059. // console.log("response="+JSON.stringify(response));
  21060. if (response) {
  21061. var resData = Restangular.stripRestangular(response);
  21062. if (resData) {
  21063. if (resData) {
  21064. if (
  21065. $scope.fileUploader != null &&
  21066. $scope.fileUploader.getNotUploadedItems().length >
  21067. 0 &&
  21068. resData.id
  21069. ) {
  21070. $scope.fileUploader.onBeforeUploadItem =
  21071. function (item) {
  21072. angular.extend(
  21073. item.headers,
  21074. $rootScope.getSession()
  21075. );
  21076. item.url = api_bpm_domain
  21077. .uploadAttachment(
  21078. resData.id,
  21079. "00000",
  21080. $rootScope.user.id
  21081. )
  21082. .getRequestedUrl();
  21083. item.formData.push({
  21084. fileName: item.file.name,
  21085. });
  21086. //console.log();
  21087. };
  21088. $scope.fileUploader.uploadAll();
  21089. }
  21090. }
  21091. }
  21092. SweetAlert.swal(
  21093. {
  21094. title: "提交成功!",
  21095. type: "success",
  21096. confirmButtonColor: "#007AFF",
  21097. },
  21098. function () {
  21099. if (
  21100. vm.model.incident &&
  21101. vm.model.incident.callID &&
  21102. vm.model.incident.callID != ""
  21103. ) {
  21104. $rootScope.app.layout.isSidebarClosed = false;
  21105. if ($scope.login && !$rootScope.busy) {
  21106. $rootScope.setidle();
  21107. }
  21108. }
  21109. $state.go($scope.formData.cancelUrl);
  21110. }
  21111. );
  21112. } else {
  21113. SweetAlert.swal({
  21114. title: "系统错误",
  21115. text: "系统错误,请稍后重试!",
  21116. type: "error",
  21117. confirmButtonColor: "#DD6B55",
  21118. });
  21119. }
  21120. $scope.ldloading[style.replace("-", "_")] = false;
  21121. });
  21122. break;
  21123. case "complete":
  21124. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  21125. //console.log("complete taskId::"+$stateParams.taskId);
  21126. if (
  21127. $scope.formData.name == "transferform" &&
  21128. vm.model.ishandlers &&
  21129. !vm.model.incident.handlerUser
  21130. ) {
  21131. SweetAlert.swal({
  21132. title: "处理人未填",
  21133. text: "请填写此项!",
  21134. type: "error",
  21135. confirmButtonColor: "#DD6B55",
  21136. });
  21137. return;
  21138. }
  21139. console.log(vm);
  21140. //处理日志
  21141. // 处理日志不为空并且事件是处理中状态
  21142. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  21143. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  21144. baseHandler();
  21145. })
  21146. } else {
  21147. if($stateParams.formUiEdit === 'inspection_LinHu_confirm'){
  21148. //巡检计划
  21149. if(vm.model.inspectionProcessActual.group&&vm.model.inspectionProcessActual.group.id){
  21150. api_bpm.assign({ids:$stateParams.dataId.toString(),userId:$rootScope.user.id}).then(function (response) {
  21151. if (response.status == 200) {
  21152. baseHandler();
  21153. } else {
  21154. Alert.swal({
  21155. title: "操作失败",
  21156. text: "操作失败, 请稍后再试!",
  21157. type: "error"
  21158. });
  21159. }
  21160. });
  21161. }else{
  21162. baseHandler();
  21163. }
  21164. }else{
  21165. baseHandler();
  21166. }
  21167. }
  21168. // return;
  21169. function baseHandler() {
  21170. api_bpm_domain
  21171. .complete($stateParams.taskId, userId, vm.model)
  21172. .then(function (response) {
  21173. if (response) {
  21174. var resData = Restangular.stripRestangular(response);
  21175. SweetAlert.swal(
  21176. {
  21177. title: "提交成功!",
  21178. type: "success",
  21179. confirmButtonColor: "#007AFF",
  21180. },
  21181. function () {
  21182. if (
  21183. $scope.fileUploader != null &&
  21184. $scope.fileUploader.getNotUploadedItems().length >
  21185. 0
  21186. ) {
  21187. console.log(vm);
  21188. if (vm.model.incident) {
  21189. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  21190. // angular.extend(item.headers, $rootScope.getSession());
  21191. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  21192. // item.formData.push({
  21193. // 'fileName': item.file.name
  21194. // });
  21195. // };
  21196. // $scope.fileUploader.uploadAll();
  21197. $scope.fileUploader.onBeforeUploadItem =
  21198. function (item) {
  21199. angular.extend(
  21200. item.headers,
  21201. $rootScope.getSession()
  21202. );
  21203. item.url = api_bpm_domain
  21204. .uploadAttachment(
  21205. vm.model.incident.processInstanceId,
  21206. "00000",
  21207. $rootScope.user.id
  21208. )
  21209. .getRequestedUrl();
  21210. item.formData.push({
  21211. fileName: item.file.name,
  21212. });
  21213. //console.log();
  21214. };
  21215. $scope.fileUploader.uploadAll();
  21216. } else if (vm.model.problem) {
  21217. $scope.fileUploader.onBeforeUploadItem =
  21218. function (item) {
  21219. angular.extend(
  21220. item.headers,
  21221. $rootScope.getSession()
  21222. );
  21223. item.url = api_bpm_domain
  21224. .uploadAttachmentJryModel(
  21225. "problem",
  21226. vm.model.problem.id,
  21227. "00000",
  21228. $rootScope.user.id
  21229. )
  21230. .getRequestedUrl();
  21231. item.formData.push({
  21232. fileName: item.file.name,
  21233. });
  21234. };
  21235. $scope.fileUploader.uploadAll();
  21236. } else if (vm.model.change) {
  21237. }else if(vm.model.inspectionProcessActual){
  21238. //巡检图片上传yeye
  21239. $scope.fileUploader.onBeforeUploadItem =
  21240. function (item) {
  21241. angular.extend(
  21242. item.headers,
  21243. $rootScope.getSession()
  21244. );
  21245. item.url = api_bpm_domain1
  21246. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  21247. .getRequestedUrl();
  21248. item.formData.push({
  21249. fileName: item.file.name,
  21250. });
  21251. //console.log();
  21252. };
  21253. $scope.fileUploader.uploadAll();
  21254. }
  21255. }
  21256. $state.go($scope.formData.cancelUrl);
  21257. }
  21258. );
  21259. } else {
  21260. SweetAlert.swal({
  21261. title: "系统错误",
  21262. text: "系统错误,请稍后重试!",
  21263. type: "error",
  21264. confirmButtonColor: "#DD6B55",
  21265. });
  21266. }
  21267. $scope.ldloading[style.replace("-", "_")] = false;
  21268. });
  21269. }
  21270. break;
  21271. case "back":
  21272. $state.go($scope.formData.cancelUrl);
  21273. break;
  21274. default:
  21275. $scope.ldloading[style.replace("-", "_")] = false;
  21276. break;
  21277. }
  21278. }
  21279. // var submitFunc = api_bpm_domain[$scope.formData.url]
  21280. // if(anuglar.isFunction(submitFunc)){
  21281. // submitFunc.apply(null, pdKey)
  21282. // }
  21283. }
  21284. }
  21285. } else {
  21286. // console.log(data)
  21287. // angular.forEach(vm.form.$error.required, function(item){
  21288. // var i=(item.$name).substring(item.$name.length-2)
  21289. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  21290. // for(var i=0;i<vm.fields.length;i++){
  21291. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  21292. SweetAlert.swal({
  21293. title: vm.fields[i].templateOptions.label + "未填",
  21294. text: "请填写此项!",
  21295. type: "error",
  21296. confirmButtonColor: "#DD6B55",
  21297. });
  21298. }
  21299. // }
  21300. // angular.forEach(vm.fields,function(f){
  21301. // if(f.name == item.$name){
  21302. // f.validation.show = true;
  21303. // SweetAlert.swal({
  21304. // title: f.templateOptions.label+'未填',
  21305. // text: "请填写此项!",
  21306. // type: "error",
  21307. // confirmButtonColor: "#DD6B55"
  21308. // });
  21309. // }
  21310. // });
  21311. // })
  21312. }
  21313. };
  21314. $scope.vm = vm;
  21315. console.log($stateParams, pdKey, 88888);
  21316. console.log($scope.vm, "assdfsdf");
  21317. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  21318. var processInstanceId = $stateParams.processInstanceId;
  21319. var itemId = $stateParams.dataId;
  21320. console.log($stateParams);
  21321. if (
  21322. angular.isDefined($stateParams.pdKey) &&
  21323. $stateParams.pdKey == "bpm_inspection"
  21324. ) {
  21325. api_configure_form
  21326. .renderForm(
  21327. $stateParams.formUiEdit,
  21328. userId,
  21329. processInstanceId,
  21330. itemId
  21331. )
  21332. .then(function (responseData) {
  21333. if (responseData) {
  21334. //console.log("responseData>>>");//console.log(responseData);
  21335. var vmForm = Restangular.stripRestangular(responseData);
  21336. if (vmForm) {
  21337. //console.log("vmForm>>>");//console.log(vmForm);
  21338. decodeVMForm(vmForm);
  21339. }
  21340. }
  21341. });
  21342. } else if (
  21343. angular.isDefined($stateParams.pdKey) &&
  21344. $stateParams.pdKey == "bpm_service_request"
  21345. ) {
  21346. api_configure_form
  21347. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  21348. .then(function (responseData) {
  21349. if (responseData) {
  21350. //console.log("responseData>>>");//console.log(responseData);
  21351. var vmForm = Restangular.stripRestangular(responseData);
  21352. if (vmForm) {
  21353. //console.log("vmForm>>>");//console.log(vmForm);
  21354. decodeVMForm(vmForm);
  21355. }
  21356. }
  21357. });
  21358. } else {
  21359. api_bpm_domain
  21360. .taskformkey($stateParams.taskId)
  21361. .then(function (response) {
  21362. if (response) {
  21363. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  21364. api_configure_form
  21365. .renderForm(myData.data, userId, processInstanceId, itemId)
  21366. .then(function (responseData) {
  21367. if (responseData) {
  21368. //console.log("responseData>>>");//console.log(responseData);
  21369. var vmForm = Restangular.stripRestangular(responseData);
  21370. if (vmForm) {
  21371. //console.log("vmForm>>>");//console.log(vmForm);
  21372. decodeVMForm(vmForm);
  21373. console.log(vmForm, 111111);
  21374. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  21375. console.log($scope, "今天"); //2020年4月24日11:40:55
  21376. }
  21377. }
  21378. });
  21379. }
  21380. });
  21381. }
  21382. } else {
  21383. // create process instance
  21384. if (pdKey != "") {
  21385. //for process
  21386. if (pdKey == "bpm_service_request") {
  21387. api_configure_form
  21388. .renderForm($stateParams.formUiStart, userId)
  21389. .then(function (responseData) {
  21390. if (responseData) {
  21391. var vmForm = Restangular.stripRestangular(responseData);
  21392. if (vmForm) {
  21393. decodeVMForm(vmForm);
  21394. }
  21395. }
  21396. });
  21397. } else {
  21398. api_bpm_domain.startformkey(pdKey).then(function (response) {
  21399. if (response) {
  21400. var myData = Restangular.stripRestangular(response);
  21401. //myData.data = "arrangeform";
  21402. api_configure_form
  21403. .renderForm(myData.data, userId)
  21404. .then(function (responseData) {
  21405. if (responseData) {
  21406. var vmForm = Restangular.stripRestangular(responseData);
  21407. if (vmForm) {
  21408. decodeVMForm(vmForm);
  21409. }
  21410. }
  21411. });
  21412. }
  21413. });
  21414. }
  21415. } else {
  21416. //for form
  21417. //TODO
  21418. //测试数据 开始
  21419. var testJson = {
  21420. fields: [
  21421. {
  21422. fields: [
  21423. {
  21424. className: "col-xs-12",
  21425. noFormControl: true,
  21426. key: "formtitle",
  21427. templateOptions: {
  21428. readOnly: false,
  21429. placeholder: "新建事件单",
  21430. hidden: false,
  21431. label: "事件工单",
  21432. required: false,
  21433. },
  21434. type: "ui-title",
  21435. },
  21436. ],
  21437. },
  21438. {
  21439. fields: [
  21440. {
  21441. key: "selectUser",
  21442. type: "ui-deptinformation",
  21443. className: "col-xs-12",
  21444. templateOptions: {
  21445. label: "请求人信息",
  21446. modalTitle: "请求人列表",
  21447. fetchItems: function (filterData, APIService) {
  21448. return APIService.fetchDataList("requester", filterData);
  21449. },
  21450. Restangular: Restangular,
  21451. ApiService: api_user_data,
  21452. // onClick:function(val, options, field, event , model){
  21453. // console.log(options);
  21454. // }
  21455. },
  21456. },
  21457. ],
  21458. },
  21459. {
  21460. fields: [
  21461. {
  21462. key: "first",
  21463. type: "ui-workernumber",
  21464. className: "col-xs-12",
  21465. templateOptions: {
  21466. type: "input",
  21467. label: "事件单号",
  21468. pkey: "name",
  21469. },
  21470. },
  21471. ],
  21472. },
  21473. {
  21474. fields: [
  21475. {
  21476. type: "ui-header",
  21477. key: "title",
  21478. className: "col-xs-12",
  21479. templateOptions: {
  21480. label: "报修人",
  21481. pkey: "change",
  21482. },
  21483. },
  21484. {
  21485. type: "ui-input",
  21486. key: "title",
  21487. className: "col-xs-4",
  21488. templateOptions: {
  21489. label: "报修人",
  21490. pkey: "change",
  21491. },
  21492. },
  21493. {
  21494. type: "ui-input",
  21495. key: "title",
  21496. className: "col-xs-4",
  21497. templateOptions: {
  21498. label: "联系人",
  21499. pkey: "change",
  21500. },
  21501. },
  21502. {
  21503. type: "ui-input",
  21504. key: "title",
  21505. className: "col-xs-4",
  21506. templateOptions: {
  21507. label: "联系电话",
  21508. pkey: "change",
  21509. },
  21510. },
  21511. ],
  21512. },
  21513. {
  21514. fields: [
  21515. {
  21516. type: "ui-header",
  21517. key: "title1",
  21518. className: "col-xs-12",
  21519. templateOptions: {
  21520. label: "报修人",
  21521. pkey: "change",
  21522. },
  21523. },
  21524. {
  21525. type: "ui-input",
  21526. key: "title2",
  21527. className: "col-xs-4",
  21528. templateOptions: {
  21529. label: "报修人",
  21530. pkey: "change",
  21531. },
  21532. },
  21533. {
  21534. type: "ui-input",
  21535. key: "title3",
  21536. className: "col-xs-4",
  21537. templateOptions: {
  21538. label: "联系人",
  21539. pkey: "change",
  21540. },
  21541. },
  21542. {
  21543. type: "ui-input",
  21544. key: "title4",
  21545. className: "col-xs-4",
  21546. templateOptions: {
  21547. label: "联系电话",
  21548. pkey: "change",
  21549. },
  21550. },
  21551. ],
  21552. },
  21553. ],
  21554. model: [
  21555. {
  21556. username: "robin lau",
  21557. password: "123456",
  21558. chkme: false,
  21559. start_code: 0,
  21560. formtitle: "Hey!I am title value!",
  21561. name: {
  21562. first: "robin",
  21563. last: "lau",
  21564. },
  21565. multiselectItem: [],
  21566. //date:"2015-09-15 00:00:00"
  21567. },
  21568. ],
  21569. // }
  21570. };
  21571. setTimeout(function () {
  21572. decodeVMForm(testJson);
  21573. $scope.$apply();
  21574. }, 500);
  21575. //测试数据结束
  21576. }
  21577. }
  21578. //console.log("end decode");
  21579. },
  21580. ]);