customformCtrl.js 785 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619
  1. var appFormly = angular.module("formlyExample", [
  2. "formly",
  3. "formlyBootstrap",
  4. "ui.bootstrap",
  5. "ngSanitize",
  6. "ui.select",
  7. "ui.grid",
  8. ]);
  9. app.requires.push("formlyExample");
  10. // var appFormly = angular.module('formlyExample', [
  11. // 'formly', 'formlyBootstrap','ui.bootstrap',
  12. // 'ngSanitize','ui.select','ui.grid'],
  13. // 图片上传
  14. app.factory("fileReader", [
  15. "$q",
  16. "$log",
  17. function ($q, $log) {
  18. var onLoad = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.resolve(reader.result);
  22. });
  23. };
  24. };
  25. var onError = function (reader, deferred, scope) {
  26. return function () {
  27. scope.$apply(function () {
  28. deferred.reject(reader.result);
  29. });
  30. };
  31. };
  32. var getReader = function (deferred, scope) {
  33. var reader = new FileReader(); //fileReader
  34. reader.onload = onLoad(reader, deferred, scope);
  35. reader.onerror = onError(reader, deferred, scope);
  36. return reader;
  37. };
  38. var readAsDataURL = function (file, scope) {
  39. var deferred = $q.defer();
  40. var reader = getReader(deferred, scope);
  41. reader.readAsDataURL(file);
  42. return deferred.promise;
  43. };
  44. return {
  45. readAsDataUrl: readAsDataURL,
  46. };
  47. },
  48. ]);
  49. appFormly.filter("minutesToHours", function () {
  50. //分钟转小时
  51. return function (num) {
  52. var hour = parseInt(num / 60);
  53. var minute = num % 60;
  54. return hour + "小时" + minute + "分钟";
  55. };
  56. });
  57. appFormly.config(function config(formlyConfigProvider) {
  58. //格式转换方法 XXX-XXX转驼峰命名
  59. function camelize(string) {
  60. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  61. return chr ? chr.toUpperCase() : "";
  62. });
  63. // Ensure 1st char is always lowercase
  64. return string.replace(/^([A-Z])/, function (match, chr) {
  65. return chr ? chr.toLowerCase() : "";
  66. });
  67. }
  68. //获取ngModelAttr对象设置
  69. function getNgModelAttr(attrs, bindings) {
  70. var ngModelAttrs = {};
  71. angular.forEach(attrs, function (attr) {
  72. ngModelAttrs[camelize(attr)] = {
  73. attribute: attr,
  74. };
  75. });
  76. angular.forEach(bindings, function (binding) {
  77. ngModelAttrs[camelize(binding)] = {
  78. bound: binding,
  79. };
  80. });
  81. return ngModelAttrs;
  82. }
  83. formlyConfigProvider.setWrapper({
  84. name: "bootstrapLabel",
  85. templateUrl: "assets/views/customform/tpl/normal-label.html",
  86. });
  87. //流程图
  88. formlyConfigProvider.setType({
  89. name: "ui-process",
  90. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  91. defaultOptions: function (options) {
  92. return {
  93. templateOptions: {
  94. refresh: function () {},
  95. refreshDelay: 0,
  96. },
  97. };
  98. },
  99. controller: [
  100. "$scope",
  101. "$modal",
  102. "SweetAlert",
  103. "api_bpm_domain",
  104. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  105. $scope.processdata = [];
  106. api_bpm_domain
  107. .flowTracing($scope.model.applicationForm.processInstanceId)
  108. .then(function (data) {
  109. console.log(data);
  110. $scope.processdata = data.data;
  111. });
  112. },
  113. ],
  114. });
  115. //出库单详情
  116. formlyConfigProvider.setType({
  117. name: "ui-getoutinform",
  118. extends: "radio",
  119. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  120. defaultOptions: function (options) {
  121. return {
  122. templateOptions: {
  123. refresh: function () {},
  124. refreshDelay: 0,
  125. },
  126. };
  127. },
  128. controller: [
  129. "$scope",
  130. "$modal",
  131. "SweetAlert",
  132. "api_bpm_domain",
  133. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  134. if (
  135. angular.isDefined($scope.model.type.id) &&
  136. !$scope.model.type.name
  137. ) {
  138. if (($scope.model.type.id = 0)) {
  139. $scope.model.type.name = "新资产入库";
  140. } else if (($scope.model.type.id = 1)) {
  141. $scope.model.type.name = "新设备领用出库";
  142. } else if (($scope.model.type.id = 2)) {
  143. $scope.model.type.name = "资产归还";
  144. } else if (($scope.model.type.id = 4)) {
  145. $scope.model.type.name = "设备更换";
  146. }
  147. }
  148. },
  149. ],
  150. });
  151. //多选框组件
  152. formlyConfigProvider.setType({
  153. name: "ui-checkboxmore",
  154. extends: "radio",
  155. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  156. defaultOptions: function (options) {
  157. return {
  158. templateOptions: {
  159. refresh: function () {},
  160. refreshDelay: 0,
  161. },
  162. };
  163. },
  164. controller: [
  165. "$scope",
  166. "$modal",
  167. "SweetAlert",
  168. "api_bpm_domain",
  169. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  170. $scope.options.initialValue = $scope.model[$scope.options.key];
  171. },
  172. ],
  173. });
  174. //入库单详情
  175. formlyConfigProvider.setType({
  176. name: "ui-getininform",
  177. extends: "radio",
  178. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  179. defaultOptions: function (options) {
  180. return {
  181. templateOptions: {
  182. refresh: function () {},
  183. refreshDelay: 0,
  184. },
  185. };
  186. },
  187. controller: [
  188. "$scope",
  189. "$modal",
  190. "SweetAlert",
  191. "api_bpm_domain",
  192. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  193. if (
  194. angular.isDefined($scope.model.type.id) &&
  195. !$scope.model.type.name
  196. ) {
  197. if (($scope.model.type.id = 0)) {
  198. $scope.model.type.name = "新资产入库";
  199. } else if (($scope.model.type.id = 1)) {
  200. $scope.model.type.name = "新设备领用出库";
  201. } else if (($scope.model.type.id = 2)) {
  202. $scope.model.type.name = "资产归还";
  203. } else if (($scope.model.type.id = 4)) {
  204. $scope.model.type.name = "设备更换";
  205. }
  206. }
  207. },
  208. ],
  209. });
  210. //申请人详情
  211. formlyConfigProvider.setType({
  212. name: "ui-requsterinfom",
  213. extends: "radio",
  214. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  215. defaultOptions: function (options) {
  216. return {
  217. templateOptions: {
  218. refresh: function () {},
  219. refreshDelay: 0,
  220. },
  221. };
  222. },
  223. });
  224. //设备耗材list组件
  225. formlyConfigProvider.setType({
  226. name: "ui-uplodchange",
  227. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  228. defaultOptions: function (options) {
  229. return {
  230. templateOptions: {
  231. refresh: function () {},
  232. refreshDelay: 0,
  233. view: function (APIService, contentId) {
  234. return APIService.downloadAttachment(contentId);
  235. },
  236. },
  237. };
  238. },
  239. controller: [
  240. "$scope",
  241. "$filter",
  242. "ngTableParams",
  243. "$rootScope",
  244. "Restangular",
  245. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  246. // var data = { "haodata": [], "shedata": [] };
  247. var haodata = [];
  248. var shedata = [];
  249. if ($scope.model.consumables) {
  250. if (angular.isArray($scope.model.consumables)) {
  251. haodata = $scope.model.consumables;
  252. } else {
  253. haodata = JSON.parse($scope.model.consumables);
  254. }
  255. $scope.model.consumables = haodata;
  256. angular.forEach(haodata, function (item, index) {
  257. haodata[index].item = index + 1;
  258. });
  259. }
  260. if ($scope.model.assets) {
  261. if (angular.isArray($scope.model.assets)) {
  262. shedata = $scope.model.assets;
  263. } else {
  264. shedata = JSON.parse($scope.model.assets);
  265. }
  266. $scope.model.assets = shedata;
  267. angular.forEach(shedata, function (item, index) {
  268. shedata[index].item = index + 1;
  269. });
  270. }
  271. $scope.tableParamshao = new ngTableParams(
  272. {
  273. page: 1,
  274. count: 5,
  275. },
  276. {
  277. total: haodata.length,
  278. getData: function ($defer, params) {
  279. var orderedData = params.sorting()
  280. ? $filter("orderBy")(haodata, params.orderBy())
  281. : haodata;
  282. $defer.resolve(
  283. orderedData.slice(
  284. (params.page() - 1) * params.count(),
  285. params.page() * params.count()
  286. )
  287. );
  288. },
  289. }
  290. );
  291. $scope.tableParamsshe = new ngTableParams(
  292. {
  293. page: 1,
  294. count: 5,
  295. },
  296. {
  297. total: shedata.length,
  298. getData: function ($defer, params) {
  299. var orderedData = params.sorting()
  300. ? $filter("orderBy")(shedata, params.orderBy())
  301. : shedata;
  302. $defer.resolve(
  303. orderedData.slice(
  304. (params.page() - 1) * params.count(),
  305. params.page() * params.count()
  306. )
  307. );
  308. },
  309. }
  310. );
  311. $scope.editId = -1;
  312. $scope.setEditId = function (pid) {
  313. $scope.editId = pid;
  314. };
  315. if (angular.isUndefined($scope.form.dropState)) {
  316. $scope.form.dropState = false;
  317. }
  318. var to = $scope.options.templateOptions;
  319. var bindId = $scope.model.processInstanceId;
  320. //获取附件列表
  321. $scope.listAttachmen = function () {
  322. to.ApiService.listAttachment(
  323. to.listAttachmentUrl,
  324. to.bindType,
  325. bindId
  326. ).then(function (result) {
  327. var myData = Restangular.stripRestangular(result);
  328. // $scope.listAttachmens = myData;
  329. $scope.attachments = myData.data;
  330. });
  331. };
  332. $scope.listAttachmen();
  333. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  334. // $scope.listAttachmen();
  335. // } else if (to.bindType && $scope.model[to.bindType].id) {
  336. // $scope.listAttachmen();
  337. // }
  338. //附件下载
  339. $scope.download = function (token, filename) {
  340. var downUrl = to.ApiService.downloadAttachment(
  341. to.downUrl,
  342. token
  343. ).getRequestedUrl();
  344. // window.open(downUrl);
  345. var a = document.createElement("a");
  346. a.href = downUrl;
  347. a.target = "_blank";
  348. a.download = filename;
  349. document.body.appendChild(a);
  350. a.click();
  351. };
  352. //附件预览
  353. $scope.view = function (id, previewUrl) {
  354. if (previewUrl) {
  355. window.open(previewUrl);
  356. }
  357. };
  358. },
  359. ],
  360. });
  361. //多选框组件
  362. formlyConfigProvider.setType({
  363. name: "ui-nodataimage",
  364. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  365. defaultOptions: function (options) {
  366. return {
  367. templateOptions: {
  368. refresh: function () {},
  369. refreshDelay: 0,
  370. },
  371. };
  372. },
  373. });
  374. //ui-grid list
  375. formlyConfigProvider.setType({
  376. name: "ui-gridtwolist",
  377. // extends: 'input',
  378. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  379. defaultOptions: function (options, $scope) {
  380. return {
  381. templateOptions: {},
  382. };
  383. },
  384. controller: [
  385. "$scope",
  386. "$modal",
  387. "i18nService",
  388. "SweetAlert",
  389. function ($scope, $modal, i18nService, SweetAlert) {
  390. //gridone
  391. $scope.langs = i18nService.getAllLangs();
  392. $scope.lang = "zh-cn";
  393. i18nService.setCurrentLang($scope.lang);
  394. $scope.gridOptions = {};
  395. $scope.gridOptions.data = "myDatagrid";
  396. $scope.gridOptions.enableColumnResizing = true;
  397. $scope.gridOptions.enableFiltering = true;
  398. $scope.gridOptions.enableGridMenu = false;
  399. $scope.gridOptions.enableRowSelection = true;
  400. $scope.gridOptions.showGridFooter = true;
  401. $scope.gridOptions.showColumnFooter = false;
  402. $scope.gridOptions.fastWatch = true;
  403. $scope.gridOptions.useExternalFiltering = false;
  404. $scope.gridOptions.useExternalPagination = true;
  405. $scope.gridOptions.paginationPageSizes = [10];
  406. $scope.gridOptions.paginationPageSize = 10;
  407. $scope.gridOptions.multiSelect = false;
  408. $scope.myDatagrid = [];
  409. $scope.myDatagridall = [];
  410. $scope.selected = {
  411. item: {},
  412. };
  413. $scope.memoryfilterDatagrid = {
  414. idx: 0,
  415. sum: 10,
  416. };
  417. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  418. filterData = {
  419. idx: 0,
  420. sum: 10,
  421. };
  422. $scope.gridOptions.columnDefs =
  423. $scope.options.templateOptions.columnDefs;
  424. }
  425. $scope.gridOptions.rowIdentity = function (row) {
  426. return row.id;
  427. };
  428. $scope.gridOptions.getRowIdentity = function (row) {
  429. return row.id;
  430. };
  431. // $scope.gridOptions.columnDefs = items.columnDefs();
  432. $scope.interceptMydata = function (mydate, idx, sum) {
  433. return mydate.slice(idx * sum, (idx + 1) * sum);
  434. };
  435. $scope.gridOptions.onRegisterApi = function (gridApi) {
  436. $scope.gridApi = gridApi;
  437. gridApi.pagination.on.paginationChanged(
  438. $scope,
  439. function (newPage, pageSize) {
  440. $scope.memoryfilterDatagrid.idx = newPage - 1;
  441. $scope.memoryfilterDatagrid.sum = pageSize;
  442. $scope.myDatagrid = $scope.interceptMydata(
  443. $scope.myDatagridall,
  444. $scope.memoryfilterDatagrid.idx,
  445. 10
  446. );
  447. $scope.loadData({
  448. idx: newPage - 1,
  449. sum: pageSize,
  450. });
  451. }
  452. );
  453. gridApi.core.on.filterChanged($scope, function () {});
  454. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  455. $scope.selected.item = data.entity;
  456. //console.log(data);
  457. });
  458. };
  459. $scope.loadData = function (mydate, idx, sum) {
  460. angular.forEach($scope.myDatagrid, function (item, index) {
  461. $scope.myDatagrid[index].item = index;
  462. });
  463. $scope.gridOptions.totalItems = mydate.length;
  464. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  465. };
  466. if ($scope.model.assets) {
  467. $scope.myDatagridall = $scope.model.assets;
  468. $scope.loadData($scope.model.assets, 0, 10);
  469. }
  470. $scope.saveData = function (itemin) {
  471. event.preventDefault();
  472. var modalInstance = $modal.open({
  473. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  474. controller: function ($scope, $modalInstance, SweetAlert) {
  475. // $scope.consumptive = {};
  476. $scope.title = "填写领用设备信息";
  477. // if (items.name) {
  478. // $scope.consumptive.name = items.name.name;
  479. // }
  480. $scope.placechange = angular.copy(itemin);
  481. $scope.ok = function (item) {
  482. if (
  483. item.props &&
  484. item.props.hwnw_area &&
  485. item.props.hwnw_place &&
  486. item.props.hwnw_room &&
  487. item.props.hwnwswt_jiguihao &&
  488. item.props.hwnwswt_Ushu &&
  489. item.props.snnum
  490. ) {
  491. $modalInstance.close(item);
  492. } else {
  493. SweetAlert.swal({
  494. title: "数据填写不完整!",
  495. text: "请检查数据然后提交!",
  496. type: "error",
  497. });
  498. }
  499. };
  500. $scope.cancel = function () {
  501. $modalInstance.dismiss("cancel");
  502. };
  503. },
  504. resolve: {
  505. SweetAlert: function () {
  506. return SweetAlert;
  507. },
  508. },
  509. });
  510. modalInstance.result.then(function (selectedItem) {
  511. angular.forEach($scope.myDatagrid, function (item, index) {
  512. // $scope.myDatagrid[index].props.hw_state = "在线";
  513. if (item.id == selectedItem.id) {
  514. // $scope.myDatagrid[index] = selectedItem;
  515. angular.extend($scope.myDatagrid[index], selectedItem);
  516. }
  517. });
  518. // $scope.myData3.push(selectedItem);
  519. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  520. $scope.myDatagrid[i]["item"] =
  521. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  522. }
  523. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  524. $scope.myDatagridall;
  525. });
  526. };
  527. //gridtwo
  528. $scope.langs = i18nService.getAllLangs();
  529. $scope.lang = "zh-cn";
  530. i18nService.setCurrentLang($scope.lang);
  531. $scope.gridOptions2 = {};
  532. $scope.gridOptions2.data = "myDatagridold";
  533. $scope.gridOptions2.enableColumnResizing = true;
  534. $scope.gridOptions2.enableFiltering = true;
  535. $scope.gridOptions2.enableGridMenu = false;
  536. $scope.gridOptions2.enableRowSelection = true;
  537. $scope.gridOptions2.showGridFooter = true;
  538. $scope.gridOptions2.showColumnFooter = false;
  539. $scope.gridOptions2.fastWatch = true;
  540. $scope.gridOptions2.useExternalFiltering = false;
  541. $scope.gridOptions.useExternalPagination = true;
  542. $scope.gridOptions2.paginationPageSizes = [10];
  543. $scope.gridOptions2.paginationPageSize = 10;
  544. $scope.gridOptions2.multiSelect = false;
  545. $scope.myDatagridold = [];
  546. $scope.myDatagridoldall = [];
  547. $scope.selected = {
  548. item: {},
  549. };
  550. $scope.memoryfilterDatagridold = {
  551. idx: 0,
  552. sum: 10,
  553. };
  554. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  555. filterData = {
  556. idx: 0,
  557. sum: 10,
  558. };
  559. $scope.gridOptions2.columnDefs =
  560. $scope.options.templateOptions.columnDefstwo;
  561. }
  562. $scope.gridOptions2.rowIdentity = function (row) {
  563. return row.id;
  564. };
  565. $scope.gridOptions2.getRowIdentity = function (row) {
  566. return row.id;
  567. };
  568. // $scope.gridOptions.columnDefs = items.columnDefs();
  569. $scope.interceptMydata = function (mydate, idx, sum) {
  570. return mydate.slice(idx * sum, (idx + 1) * sum);
  571. };
  572. if ($scope.model.oldAssets) {
  573. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  574. $scope.myDatagridold = $scope.interceptMydata(
  575. $scope.myDatagridallold,
  576. $scope.memoryfilterDatagridold.idx,
  577. 10
  578. );
  579. }
  580. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  581. $scope.gridApi = gridApi;
  582. gridApi.pagination.on.paginationChanged(
  583. $scope,
  584. function (newPage, pageSize) {
  585. $scope.memoryfilterDatagridold.idx = newPage - 1;
  586. $scope.memoryfilterDatagridold.sum = pageSize;
  587. $scope.myDatagridold = $scope.interceptMydata(
  588. $scope.myDatagridallold,
  589. $scope.memoryfilterDatagridold.idx,
  590. 10
  591. );
  592. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  593. }
  594. );
  595. gridApi.core.on.filterChanged($scope, function () {});
  596. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  597. $scope.selected.item = data.entity;
  598. //console.log(data);
  599. });
  600. };
  601. // $scope.loadData = function(mydate, idx, sum) {
  602. // angular.forEach($scope.myDatagridold, function(item, index) {
  603. // $scope.myDatagridold[index].item = index;
  604. // })
  605. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  606. // }
  607. // if ($scope.model.assets) {
  608. // $scope.myDatagridallold = $scope.model.assets;
  609. // $scope.loadData($scope.model.assets, 0, 10)
  610. // }
  611. // $scope.addoldassets = function(itemin) {
  612. // event.preventDefault();
  613. // var modalInstance = $modal.open({
  614. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  615. // controller: function($scope, $modalInstance, SweetAlert) {
  616. // // $scope.consumptive = {};
  617. // $scope.title = "填写领用设备信息";
  618. // // if (items.name) {
  619. // // $scope.consumptive.name = items.name.name;
  620. // // }
  621. // $scope.placechange = itemin;
  622. // $scope.ok = function(item) {
  623. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  624. // $modalInstance.close(item);
  625. // } else {
  626. // SweetAlert.swal({
  627. // title: "数据填写不完整!",
  628. // text: "请检查数据然后提交!",
  629. // type: "error"
  630. // });
  631. // }
  632. // };
  633. // $scope.cancel = function() {
  634. // $modalInstance.dismiss('cancel');
  635. // };
  636. // },
  637. // resolve: {
  638. // SweetAlert: function() {
  639. // return SweetAlert;
  640. // }
  641. // }
  642. // });
  643. $scope.interceptMydata = function (mydate, idx, sum) {
  644. return mydate.slice(idx * sum, (idx + 1) * sum);
  645. };
  646. $scope.addshebei = function () {
  647. event.preventDefault();
  648. var modalInstance = $modal.open({
  649. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  650. controller: function (
  651. $scope,
  652. i18nService,
  653. $modalInstance,
  654. items,
  655. title,
  656. Restangular,
  657. APIService,
  658. onDataCallback,
  659. parentScope,
  660. api_configure_data,
  661. api_configure_form,
  662. api_cmdb
  663. ) {
  664. $scope.langs = i18nService.getAllLangs();
  665. $scope.lang = "zh-cn";
  666. i18nService.setCurrentLang($scope.lang);
  667. $scope.gridOptions = {};
  668. $scope.gridOptions.data = "myDatatwo";
  669. $scope.gridOptions.enableColumnResizing = true;
  670. $scope.gridOptions.enableFiltering = false;
  671. $scope.gridOptions.enableGridMenu = false;
  672. $scope.gridOptions.showGridFooter = true;
  673. $scope.gridOptions.showColumnFooter = false;
  674. $scope.gridOptions.fastWatch = true;
  675. $scope.gridOptions.useExternalFiltering = true;
  676. $scope.gridOptions.useExternalPagination = true;
  677. $scope.gridOptions.paginationPageSizes = [10];
  678. $scope.gridOptions.paginationPageSize = 10;
  679. $scope.gridOptions.multiSelect = true;
  680. $scope.gridOptions.rowIdentity = function (row) {
  681. return row.id;
  682. };
  683. $scope.gridOptions.getRowIdentity = function (row) {
  684. return row.id;
  685. };
  686. $scope.gridOptions.columnDefs = [
  687. {
  688. name: "item",
  689. displayName: "序号",
  690. width: 80,
  691. enableFiltering: false,
  692. },
  693. {
  694. name: "uuid",
  695. displayName: "内部编号",
  696. width: 150,
  697. },
  698. {
  699. name: "props.hw_mingcheng",
  700. displayName: "资产名称",
  701. width: 100,
  702. },
  703. {
  704. name: "props.hw_cifilterClassic",
  705. displayName: "资产类型",
  706. width: 120,
  707. enableFiltering: false,
  708. },
  709. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  710. {
  711. name: "props.hw_state",
  712. displayName: "资产状态",
  713. width: 150,
  714. enableFiltering: false,
  715. },
  716. {
  717. name: "props.hwnw_area",
  718. displayName: "资产地点",
  719. width: 130,
  720. enableFiltering: false,
  721. },
  722. {
  723. name: "createtime",
  724. displayName: "申请时间",
  725. enableFiltering: false,
  726. },
  727. ];
  728. // $scope.selectButtonClick
  729. var defaultFilterData = {
  730. // "assignee":2,
  731. // "applicationForm": { "hw_state": "在线" },
  732. hw_state: "在线",
  733. idx: 0,
  734. sum: 10,
  735. };
  736. $scope.memoryfilterData = {
  737. // "assignee":2,
  738. // "applicationForm": { "hw_state": "在线" },
  739. hw_state: "在线",
  740. idx: 0,
  741. sum: 10,
  742. };
  743. $scope.refreshData = function (style, filterData) {
  744. if (angular.isUndefined(filterData)) {
  745. filterData = defaultFilterData;
  746. }
  747. $scope.myDatatwo = [];
  748. // $scope.gridOptions['sum']=filterData.sum;
  749. api_cmdb.query(filterData).then(
  750. function (data) {
  751. // $scope.callsPending--;
  752. var myDatatwo = Restangular.stripRestangular(data);
  753. $scope.gridOptions["totalItems"] = data.total;
  754. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  755. myDatatwo.data.node[i].createtime = moment(
  756. myDatatwo.data.node[i].createtime
  757. ).format("YYYY-MM-DD");
  758. }
  759. $scope.myDatatwo = myDatatwo.data.node;
  760. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  761. $scope.myDatatwo[i]["item"] =
  762. i + 1 + filterData.idx * filterData.sum;
  763. }
  764. },
  765. function () {}
  766. );
  767. };
  768. $scope.refreshData("expand-right", defaultFilterData);
  769. $scope.gridOptions.onRegisterApi = function (gridApi) {
  770. $scope.gridApi = gridApi;
  771. gridApi.pagination.on.paginationChanged(
  772. $scope,
  773. function (newPage, pageSize) {
  774. var filtersData = $scope.memoryfilterData;
  775. filtersData.idx = newPage - 1;
  776. filtersData.sum = pageSize;
  777. // $scope.loadData(filtersData);
  778. $scope.refreshData("expand-right", filtersData);
  779. //console.log(pageSize);
  780. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  781. }
  782. );
  783. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  784. // $scope.selected.items.push(data.entity);
  785. //console.log(data);
  786. gridApi.selection.on.rowSelectionChanged(
  787. $scope,
  788. function (scope, ect) {
  789. if (scope.isSelected) {
  790. scope.grid.appScope.selected.items.push(scope.entity);
  791. } else {
  792. for (
  793. var i = 0;
  794. i <= scope.grid.appScope.selected.items.length;
  795. i++
  796. ) {
  797. if (
  798. scope.grid.appScope.selected.items[i].id ==
  799. scope.entity.id
  800. ) {
  801. scope.grid.appScope.selected.items.splice(i, 1);
  802. break;
  803. }
  804. }
  805. }
  806. $scope.mySelectedRows =
  807. $scope.gridApi.selection.getSelectedRows();
  808. }
  809. );
  810. // });
  811. gridApi.selection.on.rowSelectionChangedBatch(
  812. $scope,
  813. function (rows) {
  814. // $scope.selected.items = data.entity;
  815. //console.log(data);
  816. var selectitem = [];
  817. selectitem = angular.copy($scope.selected.items);
  818. for (var j = 0; j < rows.length; j++) {
  819. if (rows[j].isSelected == true) {
  820. selectitem.push(rows[j].entity);
  821. } else {
  822. delete selectitem[j];
  823. // rows.splice(j, 1);
  824. }
  825. }
  826. $scope.selected.items = [];
  827. for (var i = 0; i < selectitem.length; i++) {
  828. if (selectitem[i]) {
  829. $scope.selected.items.push(selectitem[i]);
  830. }
  831. }
  832. }
  833. );
  834. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  835. // // if (row.entity.age > 45) {
  836. // row.grid.api.selection.selectRow(row.entity); // 选中行
  837. // // }
  838. // };
  839. gridApi.core.on.filterChanged($scope, function () {
  840. var grid = this.grid;
  841. var filtersData = {
  842. idx: 0,
  843. sum: 10,
  844. user: {
  845. roledata: {
  846. rolecode: "roleset",
  847. },
  848. selectType: "1",
  849. },
  850. };
  851. angular.forEach(grid.columns, function (item) {
  852. if (item.enableFiltering) {
  853. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  854. if (
  855. angular.isDefined(item.filters[0].term) &&
  856. item.filters[0].term != ""
  857. ) {
  858. if (angular.isUndefined(filtersData["user"])) {
  859. filtersData["user"] = {};
  860. }
  861. filtersData["user"][item.field] = item.filters[0].term;
  862. }
  863. }
  864. });
  865. $scope.memoryfilterData = filtersData;
  866. // $scope.loadData(filtersData);
  867. });
  868. };
  869. $scope.onDblClick = function (data, event) {
  870. // $scope.selected.items = data.entity;
  871. $scope.selectButtonClick(data, event);
  872. };
  873. $scope.title = title;
  874. //树形图
  875. var apple_selected, tree, treedata_avm, treedata_geography;
  876. $scope.my_tree_handler = function (branch) {
  877. //var _ref;
  878. var classify = ($scope.classify =
  879. branch.prefix.toLowerCase() + branch.sign);
  880. api_cmdb
  881. .query({
  882. sign: classify,
  883. })
  884. .then(function (data) {
  885. var myDatalingbei = Restangular.stripRestangular(data);
  886. // console.log(myData.data.node);
  887. if (myDatalingbei.data && myDatalingbei.status == 200) {
  888. var ret = myDatalingbei.data;
  889. redrawSvg(myDatalingbei);
  890. }
  891. });
  892. };
  893. $scope.my_data = [];
  894. function convertListToTree(data, treeMap) {
  895. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  896. var root = null; //Initially set our loop to null
  897. var parentNode = null;
  898. //loop over data
  899. for (var i = 0; i < data.length; i++) {
  900. var datum = data[i];
  901. //each node will have children, so let's give it a "children" poperty
  902. datum.children = [];
  903. //add an entry for this node to the map so that any future children can
  904. //lookup the parent
  905. idToNodeMap[datum.id] = datum;
  906. //Does this node have a parent?
  907. if (
  908. typeof datum.parent === "undefined" ||
  909. datum.parent == null
  910. ) {
  911. //Doesn't look like it, so this node is the root of the tree
  912. root = datum;
  913. treeMap[datum.id] = root;
  914. } else {
  915. //This node has a parent, so let's look it up using the id
  916. parentNode = idToNodeMap[datum.parent.id];
  917. //We don't need this property, so let's delete it.
  918. delete datum.parent;
  919. //Let's add the current node as a child of the parent node.
  920. parentNode.children.push(datum);
  921. }
  922. }
  923. return root;
  924. }
  925. function convertParentToChildList(data) {
  926. var treeMap = {};
  927. var list = [];
  928. convertListToTree(data, treeMap);
  929. angular.forEach(treeMap, function (item) {
  930. list.push(item);
  931. });
  932. return list;
  933. }
  934. $scope.my_tree = tree = {};
  935. $scope.try_async_load = function () {
  936. $scope.my_data = [];
  937. $scope.select_treedata = [];
  938. $scope.doing_async = true;
  939. api_configure_data
  940. .fetchDataList("ciclassify", {
  941. idx: 0,
  942. sum: 100,
  943. })
  944. .then(function (result) {
  945. //console.log(result['list']);
  946. $scope.select_treedata = $scope.my_data =
  947. convertParentToChildList(result["list"]);
  948. $scope.doing_async = false;
  949. // tree.expand_all();
  950. //console.log(treelist);
  951. });
  952. };
  953. $scope.select_treedata = [];
  954. $scope.propTypeOptions = [];
  955. $scope.try_async_load();
  956. $scope.onFilterremove = function (item) {
  957. console.log(item);
  958. };
  959. $scope.searchdata = {};
  960. $scope.clear = function () {
  961. $scope.searchdata = {};
  962. $scope.cifilter_classic = {};
  963. $scope.try_async_load();
  964. var fildata = {
  965. idx: 0,
  966. sum: 10,
  967. hw_state: "在线",
  968. };
  969. $scope.memoryfilterData = fildata;
  970. $scope.refreshData("expand-right", fildata);
  971. };
  972. $scope.chiceIncident = function (item) {
  973. var fildata = $scope.memoryfilterData;
  974. // fildata.applicationForm = {};
  975. // if (item.alltitle && item.alldata) {
  976. // fildata.applicationForm[item.alltitle.key] = item.alldata
  977. // }
  978. if (item && item.id) {
  979. var classify = item.prefix.toLowerCase() + item.sign;
  980. fildata.sign = classify;
  981. }
  982. $scope.gridOptions.paginationCurrentPage = 1;
  983. var transitiondata = angular.copy(item);
  984. $scope.refreshData("expand-right", fildata);
  985. };
  986. $scope.applicadata = [];
  987. $scope.onFilterCallback = function (item) {
  988. var tempclassify = item.prefix.toLowerCase() + item.sign;
  989. api_configure_form
  990. .renderTabForm(tempclassify)
  991. .then(function (data) {
  992. var myData = Restangular.stripRestangular(data);
  993. $scope.applicadata = myData[0].form.fields;
  994. });
  995. // }
  996. };
  997. // $scope.loadData({
  998. // idx: 0,
  999. // sum: 10,
  1000. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1001. // });
  1002. $scope.selected = {
  1003. items: [],
  1004. };
  1005. $scope.ok = function () {
  1006. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1007. // onDataCallback($scope.selected.item, parentScope);
  1008. // }
  1009. $modalInstance.close($scope.selected.items);
  1010. };
  1011. $scope.cancel = function () {
  1012. $modalInstance.dismiss("cancel");
  1013. };
  1014. },
  1015. size: "lg",
  1016. resolve: {
  1017. items: function () {
  1018. return {
  1019. fetchItems: function (filterData, APIService) {
  1020. filterData = filterData || {};
  1021. if (
  1022. angular.isDefined(filterData.idx) &&
  1023. filterData.idx == null
  1024. ) {
  1025. filterData = {
  1026. idx: 0,
  1027. sum: 10,
  1028. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1029. };
  1030. }
  1031. return $scope.options.templateOptions.fetchItems(
  1032. filterData,
  1033. APIService
  1034. );
  1035. },
  1036. };
  1037. },
  1038. title: function () {
  1039. return $scope.options.templateOptions.label;
  1040. },
  1041. Restangular: function () {
  1042. return $scope.options.templateOptions.Restangular;
  1043. },
  1044. APIService: function () {
  1045. return $scope.options.templateOptions.ApiService;
  1046. },
  1047. onDataCallback: function () {
  1048. return $scope.options.templateOptions.callback;
  1049. },
  1050. parentScope: function () {
  1051. return $scope.options.templateOptions.that;
  1052. },
  1053. },
  1054. });
  1055. modalInstance.result.then(function (selectedItem) {
  1056. $scope.myDatagridoldall = selectedItem;
  1057. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1058. $scope.myDatagridoldall[i]["item"] =
  1059. i +
  1060. 1 +
  1061. $scope.memoryfilterDatagridold.idx *
  1062. $scope.memoryfilterDatagridold.sum;
  1063. }
  1064. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1065. $scope.myDatagridold = $scope.interceptMydata(
  1066. $scope.myDatagridoldall,
  1067. 0,
  1068. 10
  1069. );
  1070. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1071. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1072. $scope.myDatagridoldall;
  1073. $scope.options.initialValue = $scope.model.oldAssets;
  1074. });
  1075. // }
  1076. };
  1077. $scope.changestate = function (itemin) {
  1078. event.preventDefault();
  1079. var modalInstance = $modal.open({
  1080. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1081. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1082. $scope.title = "旧设备状态修改";
  1083. $scope.stateshe = [
  1084. {
  1085. id: 2,
  1086. name: "在库",
  1087. },
  1088. {
  1089. id: 4,
  1090. name: "报修",
  1091. },
  1092. {
  1093. id: 3,
  1094. name: "报废",
  1095. },
  1096. ];
  1097. $scope.hw_state = {};
  1098. $scope.ok = function (item) {
  1099. $modalInstance.close(item.id);
  1100. };
  1101. $scope.cancel = function () {
  1102. $modalInstance.dismiss("cancel");
  1103. };
  1104. },
  1105. size: "sm",
  1106. resolve: {
  1107. scope: function () {
  1108. return $scope;
  1109. },
  1110. },
  1111. });
  1112. modalInstance.result.then(function (selectedItem) {
  1113. if (selectedItem) {
  1114. angular.forEach($scope.myDatagridallold, function (item, index) {
  1115. if (item.id == itemin.id) {
  1116. $scope.myDatagridallold[index].props.hw_state =
  1117. selectedItem.name;
  1118. }
  1119. });
  1120. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1121. $scope.myDatagridallold[i]["item"] =
  1122. i +
  1123. 1 +
  1124. $scope.memoryfilterDatagridold.idx *
  1125. $scope.memoryfilterDatagridold.sum;
  1126. }
  1127. $scope.gridOptions2["totalItems"] =
  1128. $scope.myDatagridallold.length;
  1129. $scope.myDatagridold = $scope.interceptMydata(
  1130. $scope.myDatagridallold,
  1131. $scope.memoryfilterDatagridold.idx,
  1132. $scope.memoryfilterDatagridold.sum
  1133. );
  1134. // $scope.model.oldAssets = $scope.myDatagridallold;
  1135. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1136. $scope.myDatagridallold;
  1137. $scope.options.initialValue = $scope.model.oldAssets;
  1138. }
  1139. });
  1140. };
  1141. $scope.savedata = function (data) {
  1142. event.preventDefault();
  1143. var modalInstance = $modal.open({
  1144. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1145. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1146. $scope.title = "设备编辑";
  1147. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1148. $scope.ok = function (item) {
  1149. $modalInstance.close(item);
  1150. };
  1151. $scope.cancel = function () {
  1152. $modalInstance.dismiss("cancel");
  1153. };
  1154. },
  1155. size: "sm",
  1156. resolve: {
  1157. scope: function () {
  1158. return $scope;
  1159. },
  1160. },
  1161. });
  1162. modalInstance.result.then(function (selectedItem) {
  1163. if (selectedItem) {
  1164. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1165. if (item.id == data.id) {
  1166. $scope.myDatagridoldall[index].olddecription =
  1167. selectedItem.olddecription;
  1168. }
  1169. });
  1170. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1171. $scope.myDatagridoldall[i]["item"] =
  1172. i +
  1173. 1 +
  1174. $scope.memoryfilterDatagridold.idx *
  1175. $scope.memoryfilterDatagridold.sum;
  1176. }
  1177. $scope.gridOptions2["totalItems"] =
  1178. $scope.myDatagridoldall.length;
  1179. $scope.myDatagridold = $scope.interceptMydata(
  1180. $scope.myDatagridoldall,
  1181. 0,
  1182. 10
  1183. );
  1184. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1185. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1186. $scope.myDatagridoldall;
  1187. $scope.options.initialValue = $scope.model.oldAssets;
  1188. }
  1189. });
  1190. };
  1191. $scope.removeold = function (data) {
  1192. event.preventDefault();
  1193. var modalInstance = $modal.open({
  1194. templateUrl: "assets/views/delete.html",
  1195. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1196. $scope.title = "设备删除";
  1197. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1198. $scope.ok = function () {
  1199. $modalInstance.close(data);
  1200. };
  1201. $scope.cancel = function () {
  1202. $modalInstance.dismiss("cancel");
  1203. };
  1204. },
  1205. size: "sm",
  1206. resolve: {
  1207. scope: function () {
  1208. return $scope;
  1209. },
  1210. },
  1211. });
  1212. modalInstance.result.then(function (selectedItem) {
  1213. if (selectedItem) {
  1214. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1215. if (item.id == selectedItem.id) {
  1216. $scope.myDatagridoldall.splice(index, 1);
  1217. }
  1218. });
  1219. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1220. $scope.myDatagridoldall[i]["item"] =
  1221. i +
  1222. 1 +
  1223. $scope.memoryfilterDatagridold.idx *
  1224. $scope.memoryfilterDatagridold.sum;
  1225. }
  1226. $scope.gridOptions2["totalItems"] =
  1227. $scope.myDatagridoldall.length;
  1228. $scope.myDatagridold = $scope.interceptMydata(
  1229. $scope.myDatagridoldall,
  1230. 0,
  1231. 10
  1232. );
  1233. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1234. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1235. $scope.myDatagridoldall;
  1236. $scope.options.initialValue = $scope.model.oldAssets;
  1237. }
  1238. });
  1239. };
  1240. },
  1241. ],
  1242. });
  1243. //ui-grid list
  1244. formlyConfigProvider.setType({
  1245. name: "ui-gridlist",
  1246. extends: "input",
  1247. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1248. defaultOptions: function (options, $scope) {
  1249. return {
  1250. templateOptions: {},
  1251. };
  1252. },
  1253. controller: [
  1254. "$scope",
  1255. "$modal",
  1256. "i18nService",
  1257. "SweetAlert",
  1258. function ($scope, $modal, i18nService, SweetAlert) {
  1259. //gridone
  1260. $scope.langs = i18nService.getAllLangs();
  1261. $scope.lang = "zh-cn";
  1262. i18nService.setCurrentLang($scope.lang);
  1263. $scope.gridOptions = {};
  1264. $scope.gridOptions.data = "myDatagrid";
  1265. $scope.gridOptions.enableColumnResizing = true;
  1266. $scope.gridOptions.enableFiltering = true;
  1267. $scope.gridOptions.enableGridMenu = false;
  1268. $scope.gridOptions.enableRowSelection = true;
  1269. $scope.gridOptions.showGridFooter = true;
  1270. $scope.gridOptions.showColumnFooter = false;
  1271. $scope.gridOptions.fastWatch = true;
  1272. $scope.gridOptions.useExternalFiltering = false;
  1273. // $scope.gridOptions.useExternalPagination = true;
  1274. $scope.gridOptions.paginationPageSizes = [10];
  1275. $scope.gridOptions.paginationPageSize = 10;
  1276. $scope.gridOptions.multiSelect = false;
  1277. $scope.myDatagrid = [];
  1278. $scope.myDatagridall = [];
  1279. $scope.selected = {
  1280. item: {},
  1281. };
  1282. $scope.memoryfilterDatagrid = {
  1283. idx: 0,
  1284. sum: 10,
  1285. };
  1286. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1287. filterData = {
  1288. idx: 0,
  1289. sum: 10,
  1290. };
  1291. $scope.gridOptions.columnDefs =
  1292. $scope.options.templateOptions.columnDefs;
  1293. }
  1294. $scope.gridOptions.rowIdentity = function (row) {
  1295. return row.id;
  1296. };
  1297. $scope.gridOptions.getRowIdentity = function (row) {
  1298. return row.id;
  1299. };
  1300. // $scope.gridOptions.columnDefs = items.columnDefs();
  1301. $scope.interceptMydata = function (mydate, idx, sum) {
  1302. return mydate.slice(idx * sum, (idx + 1) * sum);
  1303. };
  1304. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1305. $scope.gridApi = gridApi;
  1306. gridApi.pagination.on.paginationChanged(
  1307. $scope,
  1308. function (newPage, pageSize) {
  1309. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1310. $scope.memoryfilterDatagrid.sum = pageSize;
  1311. $scope.myDatagrid = $scope.interceptMydata(
  1312. $scope.myDatagridall,
  1313. $scope.memoryfilterDatagrid.idx,
  1314. 10
  1315. );
  1316. $scope.loadData({
  1317. idx: newPage - 1,
  1318. sum: pageSize,
  1319. });
  1320. }
  1321. );
  1322. gridApi.core.on.filterChanged($scope, function () {});
  1323. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1324. $scope.selected.item = data.entity;
  1325. //console.log(data);
  1326. });
  1327. };
  1328. $scope.loadData = function (mydate, idx, sum) {
  1329. angular.forEach($scope.myDatagrid, function (item, index) {
  1330. $scope.myDatagrid[index].item = index;
  1331. });
  1332. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1333. };
  1334. if ($scope.model.assets) {
  1335. $scope.myDatagridall = $scope.model.assets;
  1336. $scope.loadData($scope.model.assets, 0, 10);
  1337. }
  1338. $scope.saveData = function (itemin) {
  1339. event.preventDefault();
  1340. var modalInstance = $modal.open({
  1341. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1342. controller: function ($scope, $modalInstance, SweetAlert) {
  1343. // $scope.consumptive = {};
  1344. $scope.title = "填写领用设备信息";
  1345. // if (items.name) {
  1346. // $scope.consumptive.name = items.name.name;
  1347. // }
  1348. $scope.placechange = angular.copy(itemin);
  1349. $scope.ok = function (item) {
  1350. if (
  1351. item.props &&
  1352. item.props.hwnw_area &&
  1353. item.props.hwnw_place &&
  1354. item.props.hwnw_room &&
  1355. item.props.hwnwswt_jiguihao &&
  1356. item.props.hwnwswt_Ushu &&
  1357. item.props.snnum
  1358. ) {
  1359. $modalInstance.close(item);
  1360. } else {
  1361. SweetAlert.swal({
  1362. title: "数据填写不完整!",
  1363. text: "请检查数据然后提交!",
  1364. type: "error",
  1365. });
  1366. }
  1367. };
  1368. $scope.cancel = function () {
  1369. $modalInstance.dismiss("cancel");
  1370. };
  1371. },
  1372. resolve: {
  1373. SweetAlert: function () {
  1374. return SweetAlert;
  1375. },
  1376. },
  1377. });
  1378. modalInstance.result.then(function (selectedItem) {
  1379. angular.forEach($scope.myDatagrid, function (item, index) {
  1380. if (item.id == selectedItem.id) {
  1381. angular.extend($scope.myDatagrid[index], selectedItem);
  1382. }
  1383. });
  1384. // $scope.myData3.push(selectedItem);
  1385. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1386. $scope.myDatagrid[i]["item"] =
  1387. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1388. }
  1389. // $scope.model.assets = $scope.myDatagridall;
  1390. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1391. $scope.myDatagridall;
  1392. });
  1393. };
  1394. },
  1395. ],
  1396. });
  1397. //设备耗材list组件
  1398. formlyConfigProvider.setType({
  1399. name: "ui-shehaolist",
  1400. // extends: 'radio',
  1401. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1402. defaultOptions: function (options) {
  1403. return {
  1404. templateOptions: {
  1405. refresh: function () {},
  1406. refreshDelay: 0,
  1407. },
  1408. };
  1409. },
  1410. controller: [
  1411. "$scope",
  1412. "$filter",
  1413. "ngTableParams",
  1414. function ($scope, $filter, ngTableParams) {
  1415. // var data = { "haodata": [], "shedata": [] };
  1416. var haodata = [];
  1417. var shedata = [];
  1418. if ($scope.model.consumables) {
  1419. if (angular.isArray($scope.model.consumables)) {
  1420. haodata = $scope.model.consumables;
  1421. } else {
  1422. haodata = JSON.parse($scope.model.consumables);
  1423. }
  1424. $scope.model.consumables = haodata;
  1425. angular.forEach(haodata, function (item, index) {
  1426. haodata[index].item = index + 1;
  1427. });
  1428. }
  1429. if ($scope.model.assets) {
  1430. if (angular.isArray($scope.model.assets)) {
  1431. shedata = $scope.model.assets;
  1432. } else {
  1433. shedata = JSON.parse($scope.model.assets);
  1434. }
  1435. $scope.model.assets = shedata;
  1436. angular.forEach(shedata, function (item, index) {
  1437. shedata[index].item = index + 1;
  1438. });
  1439. }
  1440. $scope.tableParamshao = new ngTableParams(
  1441. {
  1442. page: 1,
  1443. count: 5,
  1444. },
  1445. {
  1446. total: haodata.length,
  1447. getData: function ($defer, params) {
  1448. var orderedData = params.sorting()
  1449. ? $filter("orderBy")(haodata, params.orderBy())
  1450. : haodata;
  1451. $defer.resolve(
  1452. orderedData.slice(
  1453. (params.page() - 1) * params.count(),
  1454. params.page() * params.count()
  1455. )
  1456. );
  1457. },
  1458. }
  1459. );
  1460. $scope.tableParamsshe = new ngTableParams(
  1461. {
  1462. page: 1,
  1463. count: 5,
  1464. },
  1465. {
  1466. total: shedata.length,
  1467. getData: function ($defer, params) {
  1468. var orderedData = params.sorting()
  1469. ? $filter("orderBy")(shedata, params.orderBy())
  1470. : shedata;
  1471. $defer.resolve(
  1472. orderedData.slice(
  1473. (params.page() - 1) * params.count(),
  1474. params.page() * params.count()
  1475. )
  1476. );
  1477. },
  1478. }
  1479. );
  1480. $scope.editId = -1;
  1481. $scope.setEditId = function (pid) {
  1482. $scope.editId = pid;
  1483. };
  1484. if (
  1485. $scope.$parent.$parent.$parent.model.isAgree &&
  1486. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1487. ) {
  1488. $scope.isAgree = "同意";
  1489. } else if (
  1490. $scope.$parent.$parent.$parent.model.isAgree &&
  1491. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1492. ) {
  1493. $scope.isAgree = "同意";
  1494. } else if (
  1495. $scope.$parent.$parent.$parent.model.isAgree &&
  1496. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1497. ) {
  1498. $scope.isAgree = "返回修改";
  1499. }
  1500. },
  1501. ],
  1502. });
  1503. //关联资产出库
  1504. formlyConfigProvider.setType({
  1505. name: "ui-meansmodelselect",
  1506. extends: "input",
  1507. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1508. defaultOptions: function (options) {
  1509. return {
  1510. templateOptions: {},
  1511. };
  1512. },
  1513. controller: [
  1514. "$scope",
  1515. "$modal",
  1516. function ($scope, $modal) {
  1517. $scope.openModal = function (size, options, modal) {
  1518. var modalInstance = $modal.open({
  1519. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1520. controller: function (
  1521. $scope,
  1522. $rootScope,
  1523. $modalInstance,
  1524. items,
  1525. title,
  1526. Restangular,
  1527. APIService,
  1528. api_user_data,
  1529. i18nService,
  1530. api_wechatfile
  1531. ) {
  1532. $scope.langs = i18nService.getAllLangs();
  1533. $scope.lang = "zh-cn";
  1534. i18nService.setCurrentLang($scope.lang);
  1535. $scope.gridOptions = {};
  1536. $scope.gridOptions.data = "myData";
  1537. $scope.gridOptions.enableColumnResizing = true;
  1538. $scope.gridOptions.enableFiltering = false;
  1539. $scope.gridOptions.enableGridMenu = false;
  1540. $scope.gridOptions.showGridFooter = true;
  1541. $scope.gridOptions.showColumnFooter = false;
  1542. $scope.gridOptions.fastWatch = true;
  1543. $scope.gridOptions.useExternalFiltering = true;
  1544. $scope.gridOptions.useExternalPagination = true;
  1545. $scope.gridOptions.paginationPageSizes = [10];
  1546. $scope.gridOptions.paginationPageSize = 10;
  1547. $scope.gridOptions.multiSelect = false;
  1548. $scope.gridOptions.rowIdentity = function (row) {
  1549. return row.id;
  1550. };
  1551. $scope.gridOptions.getRowIdentity = function (row) {
  1552. return row.id;
  1553. };
  1554. // $scope.states = [{
  1555. // id: 0,
  1556. // name: '待批准'
  1557. // },
  1558. // {
  1559. // id: 1,
  1560. // name: '已驳回'
  1561. // },
  1562. // {
  1563. // id: 2,
  1564. // name: '待出库'
  1565. // },
  1566. // {
  1567. // id: 3,
  1568. // name: '信息更新'
  1569. // },
  1570. // {
  1571. // id: 4,
  1572. // name: '信息确认'
  1573. // },
  1574. // {
  1575. // id: 5,
  1576. // name: '已关闭'
  1577. // }
  1578. // ];
  1579. $scope.getStatesDictionary = function () {
  1580. var data = {
  1581. key: "applicationForm_status",
  1582. type: "list",
  1583. };
  1584. api_wechatfile.getDictionary(data).then(function (res) {
  1585. $scope.states = res;
  1586. });
  1587. };
  1588. $scope.getStatesDictionary();
  1589. $scope.type = [
  1590. {
  1591. id: 1,
  1592. name: "资产入库",
  1593. },
  1594. {
  1595. id: 2,
  1596. name: "资产归还",
  1597. },
  1598. {
  1599. id: 3,
  1600. name: "资产领用",
  1601. },
  1602. {
  1603. id: 4,
  1604. name: "资产更换",
  1605. },
  1606. ];
  1607. $scope.typedata = function (row) {
  1608. if (row.type == 0) {
  1609. return "资产入库";
  1610. } else if (row.type == 2) {
  1611. return "资产归还";
  1612. } else if (row.type == 1) {
  1613. return "资产领用";
  1614. } else if (row.type == 4) {
  1615. return "资产更换";
  1616. }
  1617. };
  1618. $scope.statedata = function (row) {
  1619. if (row.status == 0) {
  1620. return "待批准";
  1621. } else if (row.status == 1) {
  1622. return "已驳回";
  1623. } else if (row.status == 2) {
  1624. return "待出库";
  1625. } else if (row.status == 3) {
  1626. return "信息更新";
  1627. } else if (row.status == 4) {
  1628. return "信息确认";
  1629. } else if (row.status == 5) {
  1630. return "已关闭";
  1631. }
  1632. };
  1633. $scope.transferTime = function (time) {
  1634. return moment(time).format("YYYY-MM-DD HH:mm");
  1635. };
  1636. $scope.application = [
  1637. {
  1638. value: "serialNumbe",
  1639. name: "申请单编号",
  1640. },
  1641. // { value: "proposer", name: '申请人' },
  1642. {
  1643. value: "purpose",
  1644. name: "领用用途",
  1645. },
  1646. // { value: "cmdbsign", name: '设备编号' }
  1647. ];
  1648. $scope.parameters = null;
  1649. $scope.open = function ($event) {
  1650. $event.preventDefault();
  1651. $event.stopPropagation();
  1652. $scope.opened = !$scope.opened;
  1653. };
  1654. $scope.endOpen = function ($event) {
  1655. $event.preventDefault();
  1656. $event.stopPropagation();
  1657. $scope.startOpened = false;
  1658. $scope.endOpened = !$scope.endOpened;
  1659. };
  1660. $scope.startOpen = function ($event) {
  1661. $event.preventDefault();
  1662. $event.stopPropagation();
  1663. $scope.endOpened = false;
  1664. $scope.startOpened = !$scope.startOpened;
  1665. };
  1666. $scope.othcode = {};
  1667. $scope.searchkeys = {};
  1668. $scope.parameters = {};
  1669. $scope.memoryfilterData = {
  1670. assignee: $rootScope.user.id,
  1671. candidateGroups: $rootScope.user.group[0].id,
  1672. searchType: "todo",
  1673. idx: 0,
  1674. sum: 10,
  1675. };
  1676. $scope.clear = function () {
  1677. $scope.searchkeys = {};
  1678. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1679. // $scope.othcode = {};
  1680. $scope.parameters = {};
  1681. var fildata = {
  1682. assignee: $rootScope.user.id,
  1683. candidateGroups: $rootScope.user.group[0].id,
  1684. searchType: "todo",
  1685. idx: 0,
  1686. sum: 10,
  1687. };
  1688. // sessionStorage.removeItem("searchincident");
  1689. $scope.memoryfilterData = fildata;
  1690. $scope.loadData(fildata);
  1691. };
  1692. $scope.chiceIncident = function (parameters, item, stateid) {
  1693. var fildata = {
  1694. assignee: $rootScope.user.id,
  1695. candidateGroups: 1,
  1696. searchType: "todo",
  1697. idx: 0,
  1698. sum: 10,
  1699. };
  1700. if (item) {
  1701. fildata.applicationForm = {};
  1702. if (item.alltitle && item.alldata) {
  1703. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1704. }
  1705. if (item.linkProposer) {
  1706. fildata.applicationForm.linkProposer = item.linkProposer;
  1707. }
  1708. if (item.proposer) {
  1709. fildata.applicationForm.proposer = item.proposer;
  1710. }
  1711. if (item.status) {
  1712. fildata.applicationForm["status"] = {
  1713. id: item.status.id,
  1714. };
  1715. }
  1716. if (item.type) {
  1717. fildata.applicationForm["type"] = {
  1718. id: item.type.id,
  1719. };
  1720. }
  1721. }
  1722. $scope.gridOptions.paginationCurrentPage = 1;
  1723. if (
  1724. parameters &&
  1725. parameters.paramDateFrom &&
  1726. parameters.paramDateTo
  1727. ) {
  1728. angular.extend(fildata, {
  1729. idx: 0,
  1730. sum: $scope.gridOptions.paginationPageSize,
  1731. });
  1732. angular.extend(fildata.applicationForm, {
  1733. startDate: moment(parameters.paramDateFrom).format(
  1734. "YYYY-MM-DD HH:mm:ss"
  1735. ),
  1736. endDate: moment(parameters.paramDateTo).format(
  1737. "YYYY-MM-DD 23:59:59"
  1738. ),
  1739. });
  1740. }
  1741. var transitiondata = angular.copy(item);
  1742. // angular.extend(fildata.applicationForm, transitiondata)
  1743. $scope.loadData(fildata);
  1744. };
  1745. $scope.key = {};
  1746. api_user_data
  1747. .fetchDataList("user", {
  1748. idx: 0,
  1749. sum: 1000,
  1750. flag: -1,
  1751. })
  1752. .then(function (data) {
  1753. $scope.handlingPersonnelUser = data.list;
  1754. });
  1755. $scope.gridOptions.columnDefs = items.columnDefs();
  1756. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1757. $scope.gridApi = gridApi;
  1758. gridApi.pagination.on.paginationChanged(
  1759. $scope,
  1760. function (newPage, pageSize) {
  1761. // console.log(newPage);
  1762. // console.log(pageSize);
  1763. $scope.loadData({
  1764. idx: newPage - 1,
  1765. sum: pageSize,
  1766. });
  1767. }
  1768. );
  1769. gridApi.core.on.filterChanged($scope, function () {});
  1770. gridApi.selection.on.rowSelectionChanged(
  1771. $scope,
  1772. function (data) {
  1773. $scope.selected.item = data.entity;
  1774. //console.log(data);
  1775. }
  1776. );
  1777. };
  1778. $scope.loadData = function (filterData) {
  1779. items.fetchItems(filterData, APIService).then(function (data) {
  1780. var myData = Restangular.stripRestangular(data);
  1781. $scope.gridOptions.totalItems = myData.totalNum;
  1782. $scope.myData = myData.list;
  1783. for (var i = 0; i < $scope.myData.length; i++) {
  1784. $scope.myData[i]["item"] =
  1785. i + 1 + filterData.idx * filterData.sum;
  1786. }
  1787. });
  1788. };
  1789. $scope.title = title;
  1790. $scope.loadData({
  1791. idx: 0,
  1792. sum: 10,
  1793. assignee: $rootScope.user.id,
  1794. candidateGroups: $rootScope.user.group[0].id,
  1795. searchType: "todo",
  1796. });
  1797. $scope.selected = {
  1798. item: {},
  1799. };
  1800. $scope.ok = function () {
  1801. //console.log($scope.selected.item);
  1802. $modalInstance.close($scope.selected.item);
  1803. };
  1804. $scope.cancel = function () {
  1805. $modalInstance.dismiss("cancel");
  1806. };
  1807. },
  1808. size: "lg",
  1809. resolve: {
  1810. items: function () {
  1811. return {
  1812. fetchItems: function (filterData, APIService) {
  1813. filterData = filterData || {};
  1814. // if(!filterData.idx){
  1815. if (
  1816. angular.isDefined(filterData.idx) &&
  1817. filterData.idx == null
  1818. ) {
  1819. filterData = {
  1820. idx: 0,
  1821. sum: 10,
  1822. };
  1823. }
  1824. return options.templateOptions.fetchItems(
  1825. filterData,
  1826. APIService,
  1827. options
  1828. );
  1829. },
  1830. columnDefs: function () {
  1831. return options.templateOptions.columnDefs;
  1832. },
  1833. };
  1834. },
  1835. title: function () {
  1836. return options.templateOptions.modalTitle;
  1837. },
  1838. Restangular: function () {
  1839. return options.templateOptions.Restangular;
  1840. },
  1841. APIService: function () {
  1842. return options.templateOptions.ApiService;
  1843. },
  1844. },
  1845. });
  1846. modalInstance.result.then(
  1847. function (selectedItem) {
  1848. var selectitem = {
  1849. title: selectedItem.title,
  1850. description: selectedItem.description,
  1851. };
  1852. if (options.key == "chuku") {
  1853. if (selectedItem.assets) {
  1854. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1855. selectedItem.assets;
  1856. }
  1857. if (selectedItem.consumables) {
  1858. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1859. selectedItem.consumables;
  1860. }
  1861. angular.extend(
  1862. $scope.$parent.$parent.$parent.model,
  1863. selectitem
  1864. );
  1865. options.value(selectedItem);
  1866. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1867. } else {
  1868. angular.extend(options.model, selectitem);
  1869. options.value(selectedItem);
  1870. }
  1871. },
  1872. function () {
  1873. //console.log('Modal dismissed at: ' + new Date());
  1874. }
  1875. );
  1876. };
  1877. },
  1878. ],
  1879. });
  1880. //文本框
  1881. formlyConfigProvider.setType({
  1882. name: "ui-textcmdb",
  1883. extends: "",
  1884. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1885. defaultOptions: function (options) {
  1886. return {
  1887. templateOptions: {
  1888. transform: function (model, value) {
  1889. return value;
  1890. },
  1891. },
  1892. validation: {
  1893. messages: {
  1894. maxlength: function (viewValue, modelValue, scope) {
  1895. if (viewValue != null) {
  1896. if (viewValue.length > scope.to.maxlength) {
  1897. return (
  1898. scope.to.label +
  1899. " 字数(" +
  1900. viewValue.length +
  1901. ")超限(" +
  1902. scope.to.maxlength +
  1903. ")"
  1904. );
  1905. } else {
  1906. return "";
  1907. }
  1908. }
  1909. },
  1910. },
  1911. },
  1912. };
  1913. },
  1914. controller: [
  1915. "$scope",
  1916. function ($scope) {
  1917. var value = $scope.model[$scope.options.key];
  1918. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1919. $scope.model[$scope.options.key] =
  1920. $scope.options.templateOptions.transform(
  1921. $scope.originalModel,
  1922. value
  1923. );
  1924. }
  1925. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1926. $scope.options.templateOptions.felditem($scope);
  1927. }
  1928. },
  1929. ],
  1930. });
  1931. //设备组件
  1932. formlyConfigProvider.setType({
  1933. name: "ui-applist",
  1934. extends: "radio",
  1935. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1936. defaultOptions: function (options) {
  1937. return {
  1938. templateOptions: {
  1939. refresh: function () {},
  1940. refreshDelay: 0,
  1941. },
  1942. };
  1943. },
  1944. controller: [
  1945. "$scope",
  1946. "$filter",
  1947. "ngTableParams",
  1948. function ($scope, $filter, ngTableParams) {
  1949. var data = [];
  1950. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1951. // data = JSON.parse($scope.model.consumables);
  1952. if (angular.isArray($scope.model.consumables)) {
  1953. data = $scope.model.consumables;
  1954. } else {
  1955. data = JSON.parse($scope.model.consumables);
  1956. }
  1957. $scope.model.consumables = data;
  1958. angular.forEach(data, function (item, index) {
  1959. data[index].item = index + 1;
  1960. });
  1961. }
  1962. if ($scope.model.assets && $scope.options.key == "assets") {
  1963. if (angular.isArray($scope.model.assets)) {
  1964. data = $scope.model.assets;
  1965. } else {
  1966. data = JSON.parse($scope.model.assets);
  1967. }
  1968. // data = JSON.parse($scope.model.assets);
  1969. $scope.model.assets = data;
  1970. angular.forEach(data, function (item, index) {
  1971. data[index].item = index + 1;
  1972. });
  1973. }
  1974. $scope.tableParams = new ngTableParams(
  1975. {
  1976. page: 1,
  1977. count: 5,
  1978. },
  1979. {
  1980. total: data.length,
  1981. getData: function ($defer, params) {
  1982. var orderedData = params.sorting()
  1983. ? $filter("orderBy")(data, params.orderBy())
  1984. : data;
  1985. $defer.resolve(
  1986. orderedData.slice(
  1987. (params.page() - 1) * params.count(),
  1988. params.page() * params.count()
  1989. )
  1990. );
  1991. },
  1992. }
  1993. );
  1994. $scope.editId = -1;
  1995. $scope.setEditId = function (pid) {
  1996. $scope.editId = pid;
  1997. };
  1998. },
  1999. ],
  2000. });
  2001. //list组件
  2002. formlyConfigProvider.setType({
  2003. name: "ui-gudinglist",
  2004. extends: "radio",
  2005. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2006. defaultOptions: function (options) {
  2007. return {
  2008. templateOptions: {
  2009. refresh: function () {},
  2010. refreshDelay: 0,
  2011. },
  2012. };
  2013. },
  2014. controller: [
  2015. "$scope",
  2016. "$filter",
  2017. "ngTableParams",
  2018. function ($scope, $filter, ngTableParams) {
  2019. var data = [];
  2020. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2021. // data = JSON.parse($scope.model.consumables);
  2022. if (angular.isArray($scope.model.consumables)) {
  2023. data = $scope.model.consumables;
  2024. } else {
  2025. data = JSON.parse($scope.model.consumables);
  2026. }
  2027. $scope.model.consumables = data;
  2028. angular.forEach(data, function (item, index) {
  2029. data[index].item = index + 1;
  2030. });
  2031. }
  2032. if ($scope.model.assets && $scope.options.key == "assets") {
  2033. if (angular.isArray($scope.model.assets)) {
  2034. data = $scope.model.assets;
  2035. } else {
  2036. data = JSON.parse($scope.model.assets);
  2037. }
  2038. // data = JSON.parse($scope.model.assets);
  2039. $scope.model.assets = data;
  2040. angular.forEach(data, function (item, index) {
  2041. data[index].item = index + 1;
  2042. });
  2043. }
  2044. $scope.tableParams = new ngTableParams(
  2045. {
  2046. page: 1,
  2047. count: 5,
  2048. },
  2049. {
  2050. total: data.length,
  2051. getData: function ($defer, params) {
  2052. var orderedData = params.sorting()
  2053. ? $filter("orderBy")(data, params.orderBy())
  2054. : data;
  2055. $defer.resolve(
  2056. orderedData.slice(
  2057. (params.page() - 1) * params.count(),
  2058. params.page() * params.count()
  2059. )
  2060. );
  2061. },
  2062. }
  2063. );
  2064. $scope.editId = -1;
  2065. $scope.setEditId = function (pid) {
  2066. $scope.editId = pid;
  2067. };
  2068. },
  2069. ],
  2070. });
  2071. //other list tab组件
  2072. formlyConfigProvider.setType({
  2073. name: "ui-otherlisttab",
  2074. extends: "",
  2075. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2076. defaultOptions: function (options) {
  2077. return {
  2078. templateOptions: {
  2079. refresh: function () {},
  2080. refreshDelay: 0,
  2081. },
  2082. };
  2083. },
  2084. controller: [
  2085. "$scope",
  2086. "$filter",
  2087. "ngTableParams",
  2088. function ($scope, $filter, ngTableParams) {},
  2089. ],
  2090. });
  2091. //审核查看组件
  2092. formlyConfigProvider.setType({
  2093. name: "ui-aprovelist",
  2094. extends: "",
  2095. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2096. defaultOptions: function (options) {
  2097. return {
  2098. templateOptions: {
  2099. refresh: function () {},
  2100. refreshDelay: 0,
  2101. },
  2102. };
  2103. },
  2104. controller: [
  2105. "$scope",
  2106. "$filter",
  2107. "ngTableParams",
  2108. function ($scope, $filter, ngTableParams) {
  2109. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2110. $scope.isAgree = "同意";
  2111. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2112. $scope.isAgree = "同意";
  2113. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2114. $scope.isAgree = "返回修改";
  2115. }
  2116. },
  2117. ],
  2118. });
  2119. //other list组件
  2120. formlyConfigProvider.setType({
  2121. name: "ui-otherlist",
  2122. extends: "",
  2123. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2124. defaultOptions: function (options) {
  2125. return {
  2126. templateOptions: {
  2127. refresh: function () {},
  2128. refreshDelay: 0,
  2129. },
  2130. };
  2131. },
  2132. controller: [
  2133. "$rootScope",
  2134. "$scope",
  2135. "$parse",
  2136. "$injector",
  2137. "$http",
  2138. "$q",
  2139. "$state",
  2140. "$stateParams",
  2141. "$modal",
  2142. "$timeout",
  2143. "$interval",
  2144. "i18nService",
  2145. "SweetAlert",
  2146. "FileUploader",
  2147. "Restangular",
  2148. "UserRestangular",
  2149. "BpmRestangular",
  2150. "api_configure_form",
  2151. "api_configure_data",
  2152. "api_bpm_domain",
  2153. "api_bpm_data",
  2154. "api_user_data",
  2155. "api_cmdb",
  2156. "api_sysinfo",
  2157. function (
  2158. $rootScope,
  2159. $scope,
  2160. $parse,
  2161. $injector,
  2162. $http,
  2163. $q,
  2164. $state,
  2165. $stateParams,
  2166. $modal,
  2167. $timeout,
  2168. $interval,
  2169. i18nService,
  2170. SweetAlert,
  2171. FileUploader,
  2172. Restangular,
  2173. UserRestangular,
  2174. BpmRestangular,
  2175. api_configure_form,
  2176. api_configure_data,
  2177. api_bpm_domain,
  2178. api_bpm_data,
  2179. api_user_data,
  2180. api_cmdb,
  2181. api_sysinfo
  2182. ) {
  2183. console.log("哈哈");
  2184. console.log($scope);
  2185. $scope.langs = i18nService.getAllLangs();
  2186. $scope.lang = "zh-cn";
  2187. i18nService.setCurrentLang($scope.lang);
  2188. var vm = this;
  2189. vm.options = {};
  2190. vm.exampleTitle = ["expressionProperties", "model property"];
  2191. vm.fields = [];
  2192. vm.models = {};
  2193. // vm.models["loginUser"] = $rootScope.user;
  2194. var that = $injector;
  2195. var parse = $parse;
  2196. var formKey = "";
  2197. var pdKey = "";
  2198. if (
  2199. angular.isDefined($state.current.pdKey) &&
  2200. $state.current.pdKey != ""
  2201. ) {
  2202. pdKey = $state.current.pdKey;
  2203. //console.log("pdKey::"+$state.current.pdKey);
  2204. }
  2205. if (
  2206. angular.isDefined($stateParams.formKey) &&
  2207. $stateParams.formKey != ""
  2208. ) {
  2209. formKey = $stateParams.formKey;
  2210. //console.log("formKey::"+$stateParams.formKey);
  2211. }
  2212. //用户测试数据,后续从header的auth中获取
  2213. var userId = 2;
  2214. userId = $rootScope.user.id;
  2215. //==============处理表单设计数据 开始====================
  2216. //处理组件加载后台数据选项的方法
  2217. function refreshSelectOptions(searchVal, field) {
  2218. if (field.templateOptions.optionsUrl) {
  2219. var process = BpmRestangular.all("");
  2220. if (field.templateOptions.ApiService) {
  2221. process = UserRestangular.all("");
  2222. }
  2223. process
  2224. .customPOST(
  2225. {
  2226. idx: 0,
  2227. sum: 1000,
  2228. },
  2229. field.templateOptions.optionsUrl
  2230. )
  2231. .then(function (result) {
  2232. if (!field.templateOptions.options) {
  2233. field.templateOptions.options = [];
  2234. }
  2235. if (field.templateOptions.optionsDataKey) {
  2236. field.templateOptions.options =
  2237. result[field.templateOptions.optionsDataKey];
  2238. } else {
  2239. field.templateOptions.options = result;
  2240. }
  2241. });
  2242. }
  2243. }
  2244. function decodeVMTabForm(model, tabs) {
  2245. var result = {
  2246. model: {},
  2247. tabs: [],
  2248. };
  2249. var mdata = angular.fromJson(model);
  2250. angular.extend(result.model, mdata);
  2251. angular.forEach(tabs, function (tab) {
  2252. tab.form.model = vm.models;
  2253. angular.forEach(tab.form.fields, function (field) {
  2254. if (field.key == "") {
  2255. delete field.key;
  2256. }
  2257. field.type = "ui-otherlisttab";
  2258. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2259. var extObj = angular.fromJson(field.extjson);
  2260. angular.extend(field.templateOptions, extObj.templateOptions);
  2261. delete extObj.templateOptions;
  2262. for (var prop in extObj) {
  2263. if (new RegExp("Expression").test(prop)) {
  2264. //var obj = $scope.$eval(extObj[prop]);
  2265. //extObj[prop] = $scope.$eval(extObj[prop]);
  2266. if (extObj[prop] != null) {
  2267. if (new RegExp("function").test(extObj[prop])) {
  2268. var propValue = eval(extObj[prop]);
  2269. extObj[prop] = propValue;
  2270. } else {
  2271. //console.log(extObj[prop]);
  2272. var obj = $scope.$eval(extObj[prop]);
  2273. extObj[prop] = obj;
  2274. //console.log(obj);
  2275. }
  2276. }
  2277. } else if (new RegExp("expressionProperties").test(prop)) {
  2278. for (var p in extObj[prop]) {
  2279. if (new RegExp("function").test(extObj[prop][p])) {
  2280. var propValue = eval(extObj[prop][p]);
  2281. extObj[prop][p] = propValue;
  2282. } else {
  2283. //if(p.indexOf("'")>=0){
  2284. // var obj = $scope.$eval(extObj[prop][p]);
  2285. // extObj[prop][$scope.$eval(p)]=obj;
  2286. //}
  2287. }
  2288. }
  2289. } else if ("watcher" == prop) {
  2290. if (angular.isArray(extObj[prop])) {
  2291. angular.forEach(extObj[prop], function (item, index) {
  2292. for (var p in item) {
  2293. if (new RegExp("function").test(item[p])) {
  2294. var propValue = eval(item[p]);
  2295. extObj[prop][index][p] = propValue;
  2296. }
  2297. }
  2298. });
  2299. } else if (angular.isObject(extObj[prop])) {
  2300. for (var p in extObj[prop]) {
  2301. if (new RegExp("function").test(extObj[prop][p])) {
  2302. var propValue = eval(extObj[prop][p]);
  2303. extObj[prop][p] = propValue;
  2304. }
  2305. }
  2306. }
  2307. }
  2308. }
  2309. angular.extend(field, extObj);
  2310. delete field.extjson;
  2311. }
  2312. if (field.extjson == "") {
  2313. delete field.extjson;
  2314. }
  2315. if (angular.isDefined(field.templateOptions)) {
  2316. var templateOs = field.templateOptions;
  2317. for (var property in templateOs) {
  2318. //console.log(property);
  2319. if (
  2320. angular.isString(templateOs[property]) &&
  2321. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2322. ) {
  2323. if (new RegExp("function").test(templateOs[property])) {
  2324. var propValue = eval(templateOs[property]);
  2325. field.templateOptions[property] = propValue;
  2326. } else {
  2327. if (that.has(templateOs[property])) {
  2328. field.templateOptions[property] = that.get(
  2329. templateOs[property]
  2330. );
  2331. } else {
  2332. field.templateOptions[property] = templateOs[property];
  2333. }
  2334. }
  2335. } else if (templateOs[property] == null) {
  2336. //delete field.templateOptions[property];
  2337. } else {
  2338. }
  2339. }
  2340. }
  2341. if (
  2342. angular.isDefined(field.templateOptions) &&
  2343. angular.isDefined(field.templateOptions.extjson)
  2344. ) {
  2345. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2346. angular.extend(field.templateOptions, extObj);
  2347. delete field.templateOptions.extjson;
  2348. }
  2349. //...
  2350. if (field.templateOptions) {
  2351. //处理远程获取数据控件方法调用
  2352. if (field.templateOptions.optionsUrl) {
  2353. field.templateOptions.refresh = refreshSelectOptions;
  2354. }
  2355. //处理嵌套属性数据绑定/
  2356. if (field.templateOptions.pkey) {
  2357. var pmodel,
  2358. i = 0;
  2359. angular.forEach(
  2360. field.templateOptions.pkey.split("."),
  2361. function (p) {
  2362. if (i == 0) {
  2363. if (result.model[p] == null) {
  2364. result.model[p] = {};
  2365. }
  2366. pmodel = result.model[p];
  2367. i++;
  2368. } else {
  2369. if (pmodel[p] == null) {
  2370. pmodel[p] = {};
  2371. }
  2372. pmodel = pmodel[p];
  2373. }
  2374. }
  2375. );
  2376. if (pmodel != null) {
  2377. field.model = pmodel;
  2378. if (pmodel[field.key] == null) {
  2379. pmodel[field.key] = null;
  2380. }
  2381. }
  2382. } else {
  2383. if (result.model[field.key] == null) {
  2384. result.model[field.key] = null;
  2385. }
  2386. }
  2387. //处理弹出框组件初始化
  2388. if (field.type == "ui-input-selectmodal") {
  2389. field.templateOptions.modal = $modal;
  2390. //field.templateOptions.Restangular = Restangular;
  2391. } else if (field.type == "ui-userselect") {
  2392. field.templateOptions.modal = $modal;
  2393. //field.templateOptions.Restangular = Restangular;
  2394. } else if (field.type == "ui-multiuserselect") {
  2395. field.templateOptions.modal = $modal;
  2396. } else if (field.type == "ui-modelselect") {
  2397. field.templateOptions.modal = $modal;
  2398. //field.templateOptions.Restangular = Restangular;
  2399. } else if (field.type == "ui-cmdbuplode") {
  2400. $scope.fileUploader = field.templateOptions.fileUploader =
  2401. new FileUploader({
  2402. url: "/uploader",
  2403. queueLimit: 1, //文件个数
  2404. autoUpload: true,
  2405. });
  2406. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2407. } else if (field.type == "ui-dropfile") {
  2408. field.templateOptions.fileUploader = new FileUploader({
  2409. url: "/uploader",
  2410. });
  2411. field.templateOptions.taskId = $stateParams.taskId;
  2412. field.templateOptions.processInstanceId =
  2413. $stateParams.processInstanceId;
  2414. field.templateOptions.userId = $rootScope.user.id;
  2415. //field.ApiService=api_bpm_domain;
  2416. } else if (field.type == "ui-dropfiletable") {
  2417. if (field.templateOptions.processInstanceId) {
  2418. } else {
  2419. field.templateOptions.processInstanceId =
  2420. $stateParams.processInstanceId;
  2421. }
  2422. } else if (field.type == "ui-repeatSection") {
  2423. var repeatForm = {
  2424. model: {},
  2425. fields: field.templateOptions.fields,
  2426. };
  2427. repeatForm.model[field.key] = [];
  2428. decodeVMTabForm(repeatForm);
  2429. }
  2430. }
  2431. // console.log(field);
  2432. //field
  2433. //result.fields.push(field);
  2434. });
  2435. });
  2436. vm.originalTabs = angular.copy(vm.form);
  2437. }
  2438. //======================处理表单设计数据 结束========================
  2439. $scope.ldloading = {};
  2440. function filter(obj) {
  2441. angular.forEach(obj, function (key, value) {
  2442. if (value === "" || value === null) {
  2443. delete obj[key];
  2444. } else if (
  2445. Object.prototype.toString.call(value) === "[object Object]"
  2446. ) {
  2447. filter(value);
  2448. } else if (angular.isArray(value)) {
  2449. angular.forEach(value, function (item) {
  2450. filter(item);
  2451. });
  2452. }
  2453. });
  2454. }
  2455. function invokeOnAllFormOptions(fn) {
  2456. angular.forEach(vm.tabs, function (tab) {
  2457. if (tab.form.options && tab.form.options[fn]) {
  2458. tab.form.options[fn]();
  2459. }
  2460. });
  2461. }
  2462. function encodeCIData(data, ciId) {
  2463. /*
  2464. create/update state:未审核
  2465. create createtime:系统时间
  2466. create/update lastupdatetime : 系统时间
  2467. label:ci分类
  2468. */
  2469. if (ciId) {
  2470. var baseprop = [
  2471. "uuid",
  2472. "name",
  2473. "type",
  2474. "label",
  2475. "status",
  2476. "createtime",
  2477. "lastupdatetime",
  2478. "props",
  2479. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2480. var extraprop = "props";
  2481. data[extraprop] = {};
  2482. for (var key in data) {
  2483. console.log(data[key]);
  2484. if (_.indexOf(baseprop, key) >= 0) {
  2485. continue;
  2486. } else {
  2487. data[extraprop][key] = data[key];
  2488. delete data[key];
  2489. }
  2490. }
  2491. if ($rootScope.user) {
  2492. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2493. data[extraprop]["configperson"] = $rootScope.user.name;
  2494. var isCMAdminFlag = false;
  2495. angular.forEach($rootScope.user.role, function (roleItem) {
  2496. if (roleItem.rolecode == "cmdb charge") {
  2497. isCMAdminFlag = true;
  2498. }
  2499. });
  2500. if (!isCMAdminFlag) {
  2501. data[extraprop]["state"] = "1";
  2502. }
  2503. }
  2504. if (data.props.id) {
  2505. } else {
  2506. data.label = ciId;
  2507. }
  2508. return data;
  2509. }
  2510. return undefined;
  2511. }
  2512. function decodeCIModel(data) {
  2513. var extraprop = "props";
  2514. if (data[extraprop]) {
  2515. for (var key in data[extraprop]) {
  2516. data[key] = data[extraprop][key];
  2517. }
  2518. delete data[extraprop];
  2519. }
  2520. data["iscmadmin"] = false;
  2521. angular.forEach($rootScope.user.role, function (roleItem) {
  2522. if (roleItem.rolecode == "cmdb charge") {
  2523. data["iscmadmin"] = true;
  2524. }
  2525. });
  2526. return data;
  2527. }
  2528. function formValid() {
  2529. angular.forEach(vm.tabs, function (item) {
  2530. //item.
  2531. });
  2532. }
  2533. $scope.vm = vm;
  2534. $scope.refreshcmdbform = function (item) {
  2535. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2536. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2537. var myData = Restangular.stripRestangular(data);
  2538. $scope.propTypeOptions = myData;
  2539. $scope.templateProps = myData;
  2540. $scope.vm.tabs = myData;
  2541. if ($scope.model.assets) {
  2542. vm.models = JSON.parse($scope.model.assets);
  2543. }
  2544. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2545. if (vm.models.vtvmvtm_kaiji) {
  2546. vm.models.vtvmvtm_kaiji = "是";
  2547. } else {
  2548. vm.models.vtvmvtm_kaiji = "否";
  2549. }
  2550. }
  2551. decodeVMTabForm(vm.models, vm.tabs);
  2552. });
  2553. // }
  2554. };
  2555. var cifilterClassic = {};
  2556. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2557. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2558. $scope.refreshcmdbform(
  2559. $scope.$parent.$parent.$parent.model.cifilterClassic
  2560. );
  2561. // } else {}
  2562. },
  2563. ],
  2564. });
  2565. //固定资产下载
  2566. formlyConfigProvider.setType({
  2567. name: "ui-dropupload",
  2568. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2569. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2570. defaultOptions: function (options) {
  2571. return {
  2572. templateOptions: {
  2573. view: function (APIService, contentId) {
  2574. return APIService.downloadAttachment(contentId);
  2575. },
  2576. },
  2577. };
  2578. },
  2579. controller: [
  2580. "$scope",
  2581. "$rootScope",
  2582. "Restangular",
  2583. function ($scope, $rootScope, Restangular) {
  2584. if (angular.isUndefined($scope.form.dropState)) {
  2585. $scope.form.dropState = false;
  2586. }
  2587. var to = $scope.options.templateOptions;
  2588. var bindId = $scope.model[to.bindType].processInstanceId;
  2589. //获取附件列表
  2590. $scope.listAttachmen = function () {
  2591. to.ApiService.listAttachment(
  2592. to.listAttachmentUrl,
  2593. to.bindType,
  2594. bindId
  2595. ).then(function (result) {
  2596. var myData = Restangular.stripRestangular(result);
  2597. // $scope.listAttachmens = myData;
  2598. $scope.attachments = myData.data;
  2599. });
  2600. };
  2601. $scope.listAttachmen();
  2602. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2603. // $scope.listAttachmen();
  2604. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2605. // $scope.listAttachmen();
  2606. // }
  2607. //附件下载
  2608. $scope.download = function (token, filename) {
  2609. var downUrl = to.ApiService.downloadAttachment(
  2610. to.downUrl,
  2611. token
  2612. ).getRequestedUrl();
  2613. var a = document.createElement("a");
  2614. a.href = downUrl;
  2615. a.target = "_blank";
  2616. a.download = filename;
  2617. document.body.appendChild(a);
  2618. a.click();
  2619. };
  2620. //附件预览
  2621. $scope.view = function (id, previewUrl) {
  2622. if (previewUrl) {
  2623. window.open(previewUrl);
  2624. }
  2625. };
  2626. },
  2627. ],
  2628. });
  2629. formlyConfigProvider.setType({
  2630. name: "ui-form",
  2631. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2632. defaultOptions: function (options) {
  2633. return {
  2634. templateOptions: {
  2635. // link: function() {}
  2636. },
  2637. };
  2638. },
  2639. controller: [
  2640. "$rootScope",
  2641. "$scope",
  2642. "$parse",
  2643. "$injector",
  2644. "$http",
  2645. "$q",
  2646. "$state",
  2647. "$stateParams",
  2648. "$modal",
  2649. "$timeout",
  2650. "$interval",
  2651. "i18nService",
  2652. "SweetAlert",
  2653. "FileUploader",
  2654. "Restangular",
  2655. "UserRestangular",
  2656. "BpmRestangular",
  2657. "api_configure_form",
  2658. "api_configure_data",
  2659. "api_bpm_domain",
  2660. "api_bpm_data",
  2661. "api_user_data",
  2662. "api_cmdb",
  2663. "api_sysinfo",
  2664. function (
  2665. $rootScope,
  2666. $scope,
  2667. $parse,
  2668. $injector,
  2669. $http,
  2670. $q,
  2671. $state,
  2672. $stateParams,
  2673. $modal,
  2674. $timeout,
  2675. $interval,
  2676. i18nService,
  2677. SweetAlert,
  2678. FileUploader,
  2679. Restangular,
  2680. UserRestangular,
  2681. BpmRestangular,
  2682. api_configure_form,
  2683. api_configure_data,
  2684. api_bpm_domain,
  2685. api_bpm_data,
  2686. api_user_data,
  2687. api_cmdb,
  2688. api_sysinfo
  2689. ) {
  2690. $scope.langs = i18nService.getAllLangs();
  2691. $scope.lang = "zh-cn";
  2692. i18nService.setCurrentLang($scope.lang);
  2693. var vm = this;
  2694. vm.options = {};
  2695. vm.exampleTitle = ["expressionProperties", "model property"];
  2696. vm.fields = [];
  2697. vm.models = {};
  2698. // vm.models["loginUser"] = $rootScope.user;
  2699. var that = $injector;
  2700. var parse = $parse;
  2701. var formKey = "";
  2702. var pdKey = "";
  2703. if (
  2704. angular.isDefined($state.current.pdKey) &&
  2705. $state.current.pdKey != ""
  2706. ) {
  2707. pdKey = $state.current.pdKey;
  2708. //console.log("pdKey::"+$state.current.pdKey);
  2709. }
  2710. if (
  2711. angular.isDefined($stateParams.formKey) &&
  2712. $stateParams.formKey != ""
  2713. ) {
  2714. formKey = $stateParams.formKey;
  2715. //console.log("formKey::"+$stateParams.formKey);
  2716. }
  2717. //用户测试数据,后续从header的auth中获取
  2718. var userId = 2;
  2719. userId = $rootScope.user.id;
  2720. //==============处理表单设计数据 开始====================
  2721. //处理组件加载后台数据选项的方法
  2722. function refreshSelectOptions(searchVal, field) {
  2723. if (field.templateOptions.optionsUrl) {
  2724. var process = BpmRestangular.all("");
  2725. if (field.templateOptions.ApiService) {
  2726. process = UserRestangular.all("");
  2727. }
  2728. process
  2729. .customPOST(
  2730. {
  2731. idx: 0,
  2732. sum: 1000,
  2733. },
  2734. field.templateOptions.optionsUrl
  2735. )
  2736. .then(function (result) {
  2737. if (!field.templateOptions.options) {
  2738. field.templateOptions.options = [];
  2739. }
  2740. if (field.templateOptions.optionsDataKey) {
  2741. field.templateOptions.options =
  2742. result[field.templateOptions.optionsDataKey];
  2743. } else {
  2744. field.templateOptions.options = result;
  2745. }
  2746. });
  2747. }
  2748. }
  2749. function decodeVMTabForm(model, tabs) {
  2750. var result = {
  2751. model: {},
  2752. tabs: [],
  2753. };
  2754. var mdata = angular.fromJson(model);
  2755. angular.extend(result.model, mdata);
  2756. angular.forEach(tabs, function (tab) {
  2757. tab.form.model = vm.models;
  2758. angular.forEach(tab.form.fields, function (field) {
  2759. if (field.key == "") {
  2760. delete field.key;
  2761. }
  2762. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2763. var extObj = angular.fromJson(field.extjson);
  2764. angular.extend(field.templateOptions, extObj.templateOptions);
  2765. delete extObj.templateOptions;
  2766. for (var prop in extObj) {
  2767. if (new RegExp("Expression").test(prop)) {
  2768. //var obj = $scope.$eval(extObj[prop]);
  2769. //extObj[prop] = $scope.$eval(extObj[prop]);
  2770. if (extObj[prop] != null) {
  2771. if (new RegExp("function").test(extObj[prop])) {
  2772. var propValue = eval(extObj[prop]);
  2773. extObj[prop] = propValue;
  2774. } else {
  2775. //console.log(extObj[prop]);
  2776. var obj = $scope.$eval(extObj[prop]);
  2777. extObj[prop] = obj;
  2778. //console.log(obj);
  2779. }
  2780. }
  2781. } else if (new RegExp("expressionProperties").test(prop)) {
  2782. for (var p in extObj[prop]) {
  2783. if (new RegExp("function").test(extObj[prop][p])) {
  2784. var propValue = eval(extObj[prop][p]);
  2785. extObj[prop][p] = propValue;
  2786. } else {
  2787. //if(p.indexOf("'")>=0){
  2788. // var obj = $scope.$eval(extObj[prop][p]);
  2789. // extObj[prop][$scope.$eval(p)]=obj;
  2790. //}
  2791. }
  2792. }
  2793. } else if ("watcher" == prop) {
  2794. if (angular.isArray(extObj[prop])) {
  2795. angular.forEach(extObj[prop], function (item, index) {
  2796. for (var p in item) {
  2797. if (new RegExp("function").test(item[p])) {
  2798. var propValue = eval(item[p]);
  2799. extObj[prop][index][p] = propValue;
  2800. }
  2801. }
  2802. });
  2803. } else if (angular.isObject(extObj[prop])) {
  2804. for (var p in extObj[prop]) {
  2805. if (new RegExp("function").test(extObj[prop][p])) {
  2806. var propValue = eval(extObj[prop][p]);
  2807. extObj[prop][p] = propValue;
  2808. }
  2809. }
  2810. }
  2811. }
  2812. }
  2813. angular.extend(field, extObj);
  2814. delete field.extjson;
  2815. }
  2816. if (field.extjson == "") {
  2817. delete field.extjson;
  2818. }
  2819. if (angular.isDefined(field.templateOptions)) {
  2820. var templateOs = field.templateOptions;
  2821. for (var property in templateOs) {
  2822. //console.log(property);
  2823. if (
  2824. angular.isString(templateOs[property]) &&
  2825. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2826. ) {
  2827. if (new RegExp("function").test(templateOs[property])) {
  2828. var propValue = eval(templateOs[property]);
  2829. field.templateOptions[property] = propValue;
  2830. } else {
  2831. if (that.has(templateOs[property])) {
  2832. field.templateOptions[property] = that.get(
  2833. templateOs[property]
  2834. );
  2835. } else {
  2836. field.templateOptions[property] = templateOs[property];
  2837. }
  2838. }
  2839. } else if (templateOs[property] == null) {
  2840. //delete field.templateOptions[property];
  2841. } else {
  2842. }
  2843. }
  2844. }
  2845. if (
  2846. angular.isDefined(field.templateOptions) &&
  2847. angular.isDefined(field.templateOptions.extjson)
  2848. ) {
  2849. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2850. angular.extend(field.templateOptions, extObj);
  2851. delete field.templateOptions.extjson;
  2852. }
  2853. //...
  2854. if (field.templateOptions) {
  2855. //处理远程获取数据控件方法调用
  2856. if (field.templateOptions.optionsUrl) {
  2857. field.templateOptions.refresh = refreshSelectOptions;
  2858. }
  2859. //处理嵌套属性数据绑定/
  2860. if (field.templateOptions.pkey) {
  2861. var pmodel,
  2862. i = 0;
  2863. angular.forEach(
  2864. field.templateOptions.pkey.split("."),
  2865. function (p) {
  2866. if (i == 0) {
  2867. if (result.model[p] == null) {
  2868. result.model[p] = {};
  2869. }
  2870. pmodel = result.model[p];
  2871. i++;
  2872. } else {
  2873. if (pmodel[p] == null) {
  2874. pmodel[p] = {};
  2875. }
  2876. pmodel = pmodel[p];
  2877. }
  2878. }
  2879. );
  2880. if (pmodel != null) {
  2881. field.model = pmodel;
  2882. if (pmodel[field.key] == null) {
  2883. pmodel[field.key] = null;
  2884. }
  2885. }
  2886. } else {
  2887. if (result.model[field.key] == null) {
  2888. result.model[field.key] = null;
  2889. }
  2890. }
  2891. //处理弹出框组件初始化
  2892. if (field.type == "ui-input-selectmodal") {
  2893. field.templateOptions.modal = $modal;
  2894. //field.templateOptions.Restangular = Restangular;
  2895. } else if (field.type == "ui-userselect") {
  2896. field.templateOptions.modal = $modal;
  2897. //field.templateOptions.Restangular = Restangular;
  2898. } else if (field.type == "ui-multiuserselect") {
  2899. field.templateOptions.modal = $modal;
  2900. } else if (field.type == "ui-modelselect") {
  2901. field.templateOptions.modal = $modal;
  2902. //field.templateOptions.Restangular = Restangular;
  2903. } else if (field.type == "ui-dropfile") {
  2904. field.templateOptions.fileUploader = new FileUploader({
  2905. url: "/uploader",
  2906. });
  2907. field.templateOptions.taskId = $stateParams.taskId;
  2908. field.templateOptions.processInstanceId =
  2909. $stateParams.processInstanceId;
  2910. field.templateOptions.userId = $rootScope.user.id;
  2911. //field.ApiService=api_bpm_domain;
  2912. // }else if (field.type == "ui-uploadFile") {
  2913. // field.templateOptions.fileUploader = new FileUploader({
  2914. // url: '/uploader'
  2915. // });
  2916. // field.templateOptions.taskId = $stateParams.taskId;
  2917. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2918. // field.templateOptions.userId = $rootScope.user.id;
  2919. //field.ApiService=api_bpm_domain;
  2920. } else if (field.type == "ui-dropfiletable") {
  2921. if (field.templateOptions.processInstanceId) {
  2922. } else {
  2923. field.templateOptions.processInstanceId =
  2924. $stateParams.processInstanceId;
  2925. }
  2926. } else if (field.type == "ui-dropFiles") {
  2927. if (field.templateOptions.processInstanceId) {
  2928. } else {
  2929. field.templateOptions.processInstanceId =
  2930. $stateParams.processInstanceId;
  2931. }
  2932. } else if (field.type == "ui-showImgs") {
  2933. if (field.templateOptions.processInstanceId) {
  2934. } else {
  2935. field.templateOptions.processInstanceId =
  2936. $stateParams.processInstanceId;
  2937. }
  2938. } else if (field.type == "ui-repeatSection") {
  2939. var repeatForm = {
  2940. model: {},
  2941. fields: field.templateOptions.fields,
  2942. };
  2943. repeatForm.model[field.key] = [];
  2944. decodeVMTabForm(repeatForm);
  2945. }
  2946. }
  2947. // console.log(field);
  2948. //field
  2949. //result.fields.push(field);
  2950. });
  2951. });
  2952. vm.originalTabs = angular.copy(vm.form);
  2953. }
  2954. //解析自定义表单设计数据
  2955. function decodeVMForm(vmForm) {
  2956. var result = {
  2957. model: {},
  2958. tabs: [],
  2959. };
  2960. //设置模型实体数据 begin
  2961. // var mdata = vmForm.model;
  2962. //解析数据实体
  2963. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2964. angular.extend(result.model, mdata);
  2965. //设置模型实体数据 end
  2966. //解析设计数据生成表单项 begin
  2967. var fields = [];
  2968. //处理修改设计数据中展示设置
  2969. angular.forEach(vmForm.tabs, function (field) {
  2970. if (field.key == "") {
  2971. delete field.key;
  2972. }
  2973. if (angular.isDefined(field.extjson)) {
  2974. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2975. angular.extend(field.templateOptions, extObj.templateOptions);
  2976. delete extObj.templateOptions;
  2977. for (var prop in extObj) {
  2978. if (new RegExp("Expression").test(prop)) {
  2979. //var obj = $scope.$eval(extObj[prop]);
  2980. //extObj[prop] = $scope.$eval(extObj[prop]);
  2981. if (extObj[prop] != null) {
  2982. if (new RegExp("function").test(extObj[prop])) {
  2983. var propValue = eval(extObj[prop]);
  2984. extObj[prop] = propValue;
  2985. } else {
  2986. //console.log(extObj[prop]);
  2987. var obj = $scope.$eval(extObj[prop]);
  2988. extObj[prop] = obj;
  2989. //console.log(obj);
  2990. }
  2991. }
  2992. } else if (new RegExp("expressionProperties").test(prop)) {
  2993. for (var p in extObj[prop]) {
  2994. if (new RegExp("function").test(extObj[prop][p])) {
  2995. var propValue = eval(extObj[prop][p]);
  2996. extObj[prop][p] = propValue;
  2997. } else {
  2998. //if(p.indexOf("'")>=0){
  2999. // var obj = $scope.$eval(extObj[prop][p]);
  3000. // extObj[prop][$scope.$eval(p)]=obj;
  3001. //}
  3002. }
  3003. }
  3004. } else if ("watcher" == prop) {
  3005. if (angular.isArray(extObj[prop])) {
  3006. angular.forEach(extObj[prop], function (item, index) {
  3007. for (var p in item) {
  3008. if (new RegExp("function").test(item[p])) {
  3009. var propValue = eval(item[p]);
  3010. extObj[prop][index][p] = propValue;
  3011. }
  3012. }
  3013. });
  3014. } else if (angular.isObject(extObj[prop])) {
  3015. for (var p in extObj[prop]) {
  3016. if (new RegExp("function").test(extObj[prop][p])) {
  3017. var propValue = eval(extObj[prop][p]);
  3018. extObj[prop][p] = propValue;
  3019. }
  3020. }
  3021. }
  3022. }
  3023. }
  3024. angular.extend(field, extObj);
  3025. delete field.extjson;
  3026. }
  3027. if (angular.isDefined(field.templateOptions)) {
  3028. var templateOs = field.templateOptions;
  3029. for (var property in templateOs) {
  3030. //console.log(property);
  3031. if (
  3032. angular.isString(templateOs[property]) &&
  3033. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3034. ) {
  3035. if (new RegExp("function").test(templateOs[property])) {
  3036. var propValue = eval(templateOs[property]);
  3037. field.templateOptions[property] = propValue;
  3038. } else {
  3039. if (that.has(templateOs[property])) {
  3040. field.templateOptions[property] = that.get(
  3041. templateOs[property]
  3042. );
  3043. } else {
  3044. field.templateOptions[property] = templateOs[property];
  3045. }
  3046. }
  3047. } else if (templateOs[property] == null) {
  3048. //delete field.templateOptions[property];
  3049. } else {
  3050. }
  3051. }
  3052. }
  3053. if (
  3054. angular.isDefined(field.templateOptions) &&
  3055. angular.isDefined(field.templateOptions.extjson)
  3056. ) {
  3057. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3058. angular.extend(field.templateOptions, extObj);
  3059. delete field.templateOptions.extjson;
  3060. }
  3061. //...
  3062. if (field.templateOptions) {
  3063. //处理远程获取数据控件方法调用
  3064. if (field.templateOptions.optionsUrl) {
  3065. field.templateOptions.refresh = refreshSelectOptions;
  3066. }
  3067. //处理嵌套属性数据绑定/
  3068. if (field.templateOptions.pkey) {
  3069. var pmodel,
  3070. i = 0;
  3071. angular.forEach(
  3072. field.templateOptions.pkey.split("."),
  3073. function (p) {
  3074. if (i == 0) {
  3075. if (result.model[p] == null) {
  3076. result.model[p] = {};
  3077. }
  3078. pmodel = result.model[p];
  3079. i++;
  3080. } else {
  3081. if (pmodel[p] == null) {
  3082. pmodel[p] = {};
  3083. }
  3084. pmodel = pmodel[p];
  3085. }
  3086. }
  3087. );
  3088. if (pmodel != null) {
  3089. field.model = pmodel;
  3090. if (pmodel[field.key] == null) {
  3091. pmodel[field.key] = null;
  3092. }
  3093. }
  3094. } else {
  3095. if (result.model[field.key] == null) {
  3096. result.model[field.key] = null;
  3097. }
  3098. }
  3099. //处理弹出框组件初始化
  3100. if (field.type == "ui-input-selectmodal") {
  3101. field.templateOptions.modal = $modal;
  3102. //field.templateOptions.Restangular = Restangular;
  3103. } else if (field.type == "ui-userselect") {
  3104. field.templateOptions.modal = $modal;
  3105. //field.templateOptions.Restangular = Restangular;
  3106. } else if (field.type == "ui-multiuserselect") {
  3107. field.templateOptions.modal = $modal;
  3108. } else if (field.type == "ui-modelselect") {
  3109. field.templateOptions.modal = $modal;
  3110. //field.templateOptions.Restangular = Restangular;
  3111. } else if (field.type == "ui-dropfile") {
  3112. field.templateOptions.fileUploader = new FileUploader({
  3113. url: "/uploader",
  3114. });
  3115. field.templateOptions.taskId = $stateParams.taskId;
  3116. field.templateOptions.processInstanceId =
  3117. $stateParams.processInstanceId;
  3118. field.templateOptions.userId = $rootScope.user.id;
  3119. //field.ApiService=api_bpm_domain;
  3120. } else if (field.type == "ui-dropfiletable") {
  3121. if (field.templateOptions.processInstanceId) {
  3122. } else {
  3123. field.templateOptions.processInstanceId =
  3124. $stateParams.processInstanceId;
  3125. }
  3126. } else if (field.type == "ui-dropFiles") {
  3127. if (field.templateOptions.processInstanceId) {
  3128. } else {
  3129. field.templateOptions.processInstanceId =
  3130. $stateParams.processInstanceId;
  3131. }
  3132. } else if (field.type == "ui-showImgs") {
  3133. if (field.templateOptions.processInstanceId) {
  3134. } else {
  3135. field.templateOptions.processInstanceId =
  3136. $stateParams.processInstanceId;
  3137. }
  3138. } else if (field.type == "ui-repeatSection") {
  3139. var repeatForm = {
  3140. model: {},
  3141. fields: field.templateOptions.fields,
  3142. };
  3143. repeatForm.model[field.key] = [];
  3144. decodeVMForm(repeatForm);
  3145. }
  3146. }
  3147. // console.log(field);
  3148. result.fields.push(field);
  3149. });
  3150. angular.extend($scope.vm.fields, result.fields);
  3151. angular.extend($scope.vm.models, result.model);
  3152. $scope.formData = vmForm;
  3153. //console.log($scope.vm);
  3154. //解析设计数据生成表单项 end
  3155. return result;
  3156. }
  3157. //======================处理表单设计数据 结束========================
  3158. $scope.ldloading = {};
  3159. function filter(obj) {
  3160. angular.forEach(obj, function (key, value) {
  3161. if (value === "" || value === null) {
  3162. delete obj[key];
  3163. } else if (
  3164. Object.prototype.toString.call(value) === "[object Object]"
  3165. ) {
  3166. filter(value);
  3167. } else if (angular.isArray(value)) {
  3168. angular.forEach(value, function (item) {
  3169. filter(item);
  3170. });
  3171. }
  3172. });
  3173. }
  3174. function invokeOnAllFormOptions(fn) {
  3175. angular.forEach(vm.tabs, function (tab) {
  3176. if (tab.form.options && tab.form.options[fn]) {
  3177. tab.form.options[fn]();
  3178. }
  3179. });
  3180. }
  3181. function encodeCIData(data, ciId) {
  3182. /*
  3183. create/update state:未审核
  3184. create createtime:系统时间
  3185. create/update lastupdatetime : 系统时间
  3186. label:ci分类
  3187. */
  3188. if (ciId) {
  3189. var baseprop = [
  3190. "uuid",
  3191. "name",
  3192. "type",
  3193. "label",
  3194. "status",
  3195. "createtime",
  3196. "lastupdatetime",
  3197. "props",
  3198. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3199. var extraprop = "props";
  3200. data[extraprop] = {};
  3201. for (var key in data) {
  3202. console.log(data[key]);
  3203. if (_.indexOf(baseprop, key) >= 0) {
  3204. continue;
  3205. } else {
  3206. data[extraprop][key] = data[key];
  3207. delete data[key];
  3208. }
  3209. }
  3210. if ($rootScope.user) {
  3211. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3212. data[extraprop]["configperson"] = $rootScope.user.name;
  3213. var isCMAdminFlag = false;
  3214. angular.forEach($rootScope.user.role, function (roleItem) {
  3215. if (roleItem.rolecode == "cmdb charge") {
  3216. isCMAdminFlag = true;
  3217. }
  3218. });
  3219. if (!isCMAdminFlag) {
  3220. data[extraprop]["state"] = "1";
  3221. }
  3222. }
  3223. if (data.props.id) {
  3224. } else {
  3225. data.label = ciId;
  3226. }
  3227. return data;
  3228. }
  3229. return undefined;
  3230. }
  3231. function decodeCIModel(data) {
  3232. var extraprop = "props";
  3233. if (data[extraprop]) {
  3234. for (var key in data[extraprop]) {
  3235. data[key] = data[extraprop][key];
  3236. }
  3237. delete data[extraprop];
  3238. }
  3239. data["iscmadmin"] = false;
  3240. angular.forEach($rootScope.user.role, function (roleItem) {
  3241. if (roleItem.rolecode == "cmdb charge") {
  3242. data["iscmadmin"] = true;
  3243. }
  3244. });
  3245. return data;
  3246. }
  3247. vm.remove = function (data, style) {
  3248. $scope.ldloading[style.replace("-", "_")] = true;
  3249. var modalInstance = $modal.open({
  3250. templateUrl: "assets/views/delete.html",
  3251. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3252. var cidata = {
  3253. label: data.label,
  3254. id: data.id,
  3255. uuid: data.uuid,
  3256. name: data.name,
  3257. props: {},
  3258. };
  3259. if (cidata.id) {
  3260. cidata.props["removeflag"] = true;
  3261. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3262. $scope.ok = function () {
  3263. $modalInstance.close(cidata);
  3264. };
  3265. $scope.cancel = function () {
  3266. $modalInstance.dismiss("cancel");
  3267. };
  3268. }
  3269. },
  3270. size: "sm",
  3271. resolve: {
  3272. scope: function () {
  3273. return $scope;
  3274. },
  3275. },
  3276. });
  3277. modalInstance.result.then(function (selectedItem) {
  3278. if (selectedItem) {
  3279. // if (selectedItem.length > 0) {
  3280. api_cmdb
  3281. .put(selectedItem, selectedItem.id)
  3282. .then(function (response) {
  3283. if (response) {
  3284. var resData = Restangular.stripRestangular(response);
  3285. SweetAlert.swal(
  3286. {
  3287. title: "删除成功!",
  3288. confirmButtonColor: "#007AFF",
  3289. },
  3290. function () {
  3291. $state.go("app.means.list");
  3292. // $scope.refreshform();
  3293. // reinitTabForm($scope.classify);
  3294. }
  3295. );
  3296. } else {
  3297. SweetAlert.swal({
  3298. title: "系统错误",
  3299. text: "系统错误,请稍后重试!",
  3300. type: "error",
  3301. confirmButtonColor: "#DD6B55",
  3302. });
  3303. }
  3304. $scope.ldloading[style.replace("-", "_")] = false;
  3305. });
  3306. }
  3307. });
  3308. };
  3309. function formValid() {
  3310. angular.forEach(vm.tabs, function (item) {
  3311. //item.
  3312. });
  3313. }
  3314. $scope.closeModel = function () {
  3315. console.log($stateParams);
  3316. if (
  3317. angular.isDefined($stateParams.formKey) &&
  3318. $stateParams.formKey != ""
  3319. ) {
  3320. if (
  3321. $stateParams.formKey == "means_editor" ||
  3322. $stateParams.formKey == "means_edit"
  3323. ) {
  3324. $state.go("app.means.list", {});
  3325. }
  3326. event.preventDefault();
  3327. }
  3328. };
  3329. // setInterval(function() {
  3330. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3331. // cifilter_classic = $scope.model.cifilter_classic;
  3332. // $scope.refreshcmdbform(cifilter_classic);
  3333. // } else {}
  3334. // }, 100);
  3335. vm.models = (function filter(obj) {
  3336. var filtered = _.pick(obj, function (v) {
  3337. return (
  3338. angular.isDefined(v) &&
  3339. v !== null &&
  3340. (angular.isArray(v) ? v.length > 0 : true) &&
  3341. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3342. );
  3343. });
  3344. return _.cloneDeep(filtered, function (v) {
  3345. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3346. });
  3347. })(vm.models);
  3348. // setInterval(function() {
  3349. // if ($scope.model.type == 0) {
  3350. // $scope.model[$scope.options.key] = vm.models;
  3351. // }
  3352. // }, 100);
  3353. setInterval(function () {
  3354. if (vm.form && vm.form.$$parentForm.$valid) {
  3355. if (
  3356. $scope.$parent &&
  3357. $scope.$parent.$parent &&
  3358. $scope.$parent.$parent.$parent &&
  3359. $scope.$parent.$parent.$parent.model
  3360. ) {
  3361. vm.models.hw_cifilterClassic =
  3362. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3363. $scope.model[$scope.options.key] = vm.models;
  3364. }
  3365. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3366. // $scope.model[$scope.options.key] = vm.models;
  3367. }
  3368. }, 100);
  3369. vm.submit = function (data, ciId, templateitem, style) {
  3370. // $scope.ldloading[style.replace('-', '_')] = true;
  3371. console.log(vm.form.$$parentForm.$valid);
  3372. if (vm.form.$$parentForm.$valid) {
  3373. invokeOnAllFormOptions("updateInitialValue");
  3374. //alert(JSON.stringify(vm.model), null, 2);
  3375. //vm.options.updateInitialValue();
  3376. //console.log(vm.model);
  3377. var cidata = encodeCIData(vm.models, ciId);
  3378. if (cidata) {
  3379. //var cidata = ;
  3380. if (cidata.props.id) {
  3381. //修改
  3382. api_cmdb.put(cidata, ciId).then(function (response) {
  3383. if (response) {
  3384. var resData = Restangular.stripRestangular(response);
  3385. SweetAlert.swal(
  3386. {
  3387. title: "保存成功!",
  3388. confirmButtonColor: "#007AFF",
  3389. },
  3390. function () {
  3391. $scope.ldloading[style.replace("-", "_")] = false;
  3392. // $scope.refreshform();
  3393. $state.go("app.means.list");
  3394. }
  3395. );
  3396. } else {
  3397. SweetAlert.swal({
  3398. title: "系统错误",
  3399. text: "系统错误,请稍后重试!",
  3400. type: "error",
  3401. confirmButtonColor: "#DD6B55",
  3402. });
  3403. }
  3404. $scope.ldloading[style.replace("-", "_")] = false;
  3405. });
  3406. } else {
  3407. //新建
  3408. var type = 2;
  3409. api_sysinfo
  3410. .getSerialnumber(type, templateitem.id)
  3411. .then(function (data) {
  3412. if (data && data.status == 200) {
  3413. cidata.uuid = data.uuid;
  3414. api_cmdb.create(cidata).then(function (response) {
  3415. if (response) {
  3416. var resData = Restangular.stripRestangular(response);
  3417. SweetAlert.swal(
  3418. {
  3419. title: "保存成功!",
  3420. text: "内部编号:" + cidata.uuid,
  3421. confirmButtonColor: "#007AFF",
  3422. },
  3423. function () {
  3424. $state.go("app.means.list");
  3425. }
  3426. );
  3427. // if(resData.status){
  3428. // resData
  3429. // }
  3430. } else {
  3431. SweetAlert.swal({
  3432. title: "系统错误",
  3433. text: "系统错误,请稍后重试!",
  3434. type: "error",
  3435. confirmButtonColor: "#DD6B55",
  3436. });
  3437. }
  3438. $scope.ldloading[style.replace("-", "_")] = false;
  3439. });
  3440. } else {
  3441. SweetAlert.swal({
  3442. title: "系统错误",
  3443. text: "内部编号生成出错!",
  3444. type: "error",
  3445. confirmButtonColor: "#DD6B55",
  3446. });
  3447. }
  3448. });
  3449. }
  3450. } else {
  3451. SweetAlert.swal({
  3452. title: "错误",
  3453. text: "错误,请选择资产分类!",
  3454. type: "error",
  3455. confirmButtonColor: "#DD6B55",
  3456. });
  3457. }
  3458. //alert(JSON.stringify(cidata), null, 2);
  3459. $scope.ldloading[style.replace("-", "_")] = true;
  3460. return;
  3461. var _ = window._;
  3462. vm.models = (function filter(obj) {
  3463. var filtered = _.pick(obj, function (v) {
  3464. return (
  3465. angular.isDefined(v) &&
  3466. v !== null &&
  3467. (angular.isArray(v) ? v.length > 0 : true) &&
  3468. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3469. );
  3470. });
  3471. return _.cloneDeep(filtered, function (v) {
  3472. return v !== filtered && _.isPlainObject(v)
  3473. ? filter(v)
  3474. : undefined;
  3475. });
  3476. })(vm.models);
  3477. } else {
  3478. if (vm.form.$$parentForm.$error) {
  3479. SweetAlert.swal({
  3480. title: "校验错误",
  3481. text: "请填写必填项!",
  3482. type: "error",
  3483. confirmButtonColor: "#DD6B55",
  3484. });
  3485. angular.forEach(
  3486. vm.form.$$parentForm.$error.required,
  3487. function (item) {
  3488. angular.forEach(vm.tabs, function (tab) {
  3489. angular.forEach(tab.form.fields, function (f) {
  3490. if (f.name == item.$name) {
  3491. f.validation.show = true;
  3492. tab.active = true;
  3493. }
  3494. });
  3495. });
  3496. }
  3497. );
  3498. $scope.ldloading[style.replace("-", "_")] = false;
  3499. }
  3500. }
  3501. };
  3502. $scope.vm = vm;
  3503. $scope.refreshcmdbform = function (item) {
  3504. // if ($stateParams.model) {
  3505. // var modeldata = JSON.parse($stateParams.model)
  3506. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3507. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3508. var myData = Restangular.stripRestangular(data);
  3509. $scope.propTypeOptions = myData;
  3510. $scope.templateProps = myData;
  3511. $scope.vm.tabs = myData;
  3512. if ($scope.model.asset && $scope.model.asset.length != "") {
  3513. vm.models = JSON.parse($scope.model.asset);
  3514. }
  3515. decodeVMTabForm(vm.models, vm.tabs);
  3516. });
  3517. // }
  3518. };
  3519. var cifilterClassic = {};
  3520. setInterval(function () {
  3521. if (
  3522. $scope.$parent.$parent &&
  3523. $scope.$parent.$parent.$parent &&
  3524. $scope.$parent.$parent.$parent.model &&
  3525. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3526. cifilterClassic.id !=
  3527. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3528. ) {
  3529. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3530. cifilterClassic =
  3531. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3532. $scope.refreshcmdbform(cifilterClassic);
  3533. } else {
  3534. }
  3535. }, 100);
  3536. },
  3537. ],
  3538. });
  3539. //请求人信息
  3540. formlyConfigProvider.setType({
  3541. name: "ui-cmdbinformation",
  3542. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3543. wrapper: ["bootstrapHasError"],
  3544. defaultOptions: function (options, $scope) {
  3545. return {
  3546. templateOptions: {
  3547. // checkform: function(options) {
  3548. // if (options.model.requester) {
  3549. // options.value(options.model.requester);
  3550. // }
  3551. // },
  3552. },
  3553. };
  3554. },
  3555. controller: [
  3556. "$scope",
  3557. "api_user_data",
  3558. function ($scope, api_user_data) {
  3559. if ($scope.options.templateOptions.loginUser) {
  3560. if (
  3561. $scope.model[$scope.options.key] &&
  3562. $scope.model[$scope.options.key].id
  3563. ) {
  3564. } else {
  3565. $scope.model[$scope.options.key] =
  3566. $scope.options.templateOptions.loginUser;
  3567. }
  3568. $scope.options.initialValue = $scope.model[$scope.options.key];
  3569. }
  3570. },
  3571. ],
  3572. });
  3573. //资产属性
  3574. formlyConfigProvider.setType({
  3575. name: "ui-cmdbtype",
  3576. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3577. wrapper: ["bootstrapHasError"],
  3578. defaultOptions: function (options, $scope) {
  3579. return {
  3580. templateOptions: {
  3581. // checkform: function(options) {
  3582. // if (options.model.requester) {
  3583. // options.value(options.model.requester);
  3584. // }
  3585. // },
  3586. },
  3587. };
  3588. },
  3589. controller: [
  3590. "$scope",
  3591. "api_user_data",
  3592. function ($scope, api_user_data) {
  3593. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3594. $scope.property = {
  3595. hw_change: $scope.to.loginUser,
  3596. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3597. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3598. };
  3599. if ($scope.$parent.$parent.$parent.model.assets) {
  3600. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3601. }
  3602. },
  3603. ],
  3604. });
  3605. //申请单信息
  3606. formlyConfigProvider.setType({
  3607. name: "ui-cmdbformimform",
  3608. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3609. wrapper: ["bootstrapHasError"],
  3610. defaultOptions: function (options, $scope) {
  3611. return {
  3612. templateOptions: {
  3613. // checkform: function(options) {
  3614. // if (options.model.requester) {
  3615. // options.value(options.model.requester);
  3616. // }
  3617. // },
  3618. },
  3619. };
  3620. },
  3621. controller: [
  3622. "$scope",
  3623. "api_user_data",
  3624. function ($scope, api_user_data) {
  3625. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3626. $scope.getininform = {
  3627. serialNumbe:
  3628. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3629. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3630. };
  3631. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3632. $scope.getininform.types = "新资产入库";
  3633. } else if (
  3634. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3635. ) {
  3636. $scope.getininform.types = "资产归还";
  3637. }
  3638. },
  3639. ],
  3640. });
  3641. //出库单信息
  3642. formlyConfigProvider.setType({
  3643. name: "ui-outinformation",
  3644. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3645. wrapper: ["bootstrapHasError"],
  3646. defaultOptions: function (options, $scope) {
  3647. return {
  3648. templateOptions: {
  3649. // checkform: function(options) {
  3650. // if (options.model.requester) {
  3651. // options.value(options.model.requester);
  3652. // }
  3653. // },
  3654. },
  3655. };
  3656. },
  3657. controller: [
  3658. "$scope",
  3659. "api_user_data",
  3660. function ($scope, api_user_data) {
  3661. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3662. $scope.getininform = {
  3663. serialNumbe:
  3664. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3665. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3666. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3667. sourceId:
  3668. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3669. describe:
  3670. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3671. };
  3672. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3673. $scope.getininform.types = "新设备领用出库";
  3674. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3675. $scope.getininform.types = "设备更换";
  3676. }
  3677. $scope.getininform.source_id =
  3678. $scope.$parent.$parent.$parent.model.source.value;
  3679. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3680. $scope.getininform.source = "事件";
  3681. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3682. $scope.getininform.source = "变更";
  3683. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3684. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3685. $scope.getininform.source = "其它";
  3686. }
  3687. },
  3688. ],
  3689. });
  3690. //资产附件上传
  3691. formlyConfigProvider.setType({
  3692. name: "ui-cmdbuplode",
  3693. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3694. wrapper: ["bootstrapHasError"],
  3695. defaultOptions: function (options, $scope) {
  3696. return {
  3697. templateOptions: {
  3698. // checkform: function(options) {
  3699. // if (options.model.requester) {
  3700. // options.value(options.model.requester);
  3701. // }
  3702. // },
  3703. },
  3704. };
  3705. },
  3706. controller: [
  3707. "$scope",
  3708. "$rootScope",
  3709. "$http",
  3710. "SweetAlert",
  3711. "FileUploader",
  3712. "api_user_data",
  3713. "i18nService",
  3714. "$modal",
  3715. "Restangular",
  3716. "api_configure_data",
  3717. "api_cmdb",
  3718. "api_cmdb_new",
  3719. "api_wechatfile",
  3720. "api_sysinfo",
  3721. function (
  3722. $scope,
  3723. $rootScope,
  3724. $http,
  3725. SweetAlert,
  3726. FileUploader,
  3727. api_user_data,
  3728. i18nService,
  3729. $modal,
  3730. Restangular,
  3731. api_configure_data,
  3732. api_cmdb,
  3733. api_cmdb_new,
  3734. api_wechatfile,
  3735. api_sysinfo
  3736. ) {
  3737. $scope.state = 1;
  3738. $scope.myData3all = [];
  3739. $scope.myData3 = [];
  3740. $scope.memoryfilterDatahao = {
  3741. idx: 0,
  3742. sum: 10,
  3743. };
  3744. $scope.selected = {
  3745. items: [],
  3746. };
  3747. $scope.interceptMydata = function (mydate, idx, sum) {
  3748. return mydate.slice(idx * sum, (idx + 1) * sum);
  3749. };
  3750. // $scope.importnext = function() {
  3751. // $scope.state = 2;
  3752. // event.preventDefault();
  3753. // }
  3754. $scope.workspaces = [];
  3755. $scope.options.templateOptions.getpush = function (item) {
  3756. $scope.workspaces = [];
  3757. if (item.gu) {
  3758. $scope.workspaces.push({
  3759. id: 1,
  3760. name: "固定资产",
  3761. active: true,
  3762. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3763. });
  3764. }
  3765. if (item.hao) {
  3766. $scope.workspaces.push({
  3767. id: 2,
  3768. name: "耗材资产",
  3769. active: true,
  3770. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3771. });
  3772. }
  3773. };
  3774. //获取附件列表
  3775. $scope.listAttachmen = function () {
  3776. to.ApiService.listAttachment(
  3777. to.listAttachmentUrl,
  3778. to.bindType,
  3779. bindId
  3780. ).then(function (result) {
  3781. var myData = Restangular.stripRestangular(result);
  3782. // $scope.listAttachmens = myData;
  3783. $scope.attachments = myData.data;
  3784. });
  3785. };
  3786. //附件列表
  3787. if ($scope.options.templateOptions.bindType) {
  3788. if (angular.isUndefined($scope.form.dropState)) {
  3789. $scope.form.dropState = false;
  3790. }
  3791. var to = $scope.options.templateOptions;
  3792. var bindId = $scope.model[to.bindType].processInstanceId;
  3793. $scope.listAttachmen();
  3794. }
  3795. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3796. // $scope.listAttachmen();
  3797. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3798. // $scope.listAttachmen();
  3799. // }
  3800. //附件下载
  3801. $scope.download = function (token, filename) {
  3802. var downUrl = to.ApiService.downloadAttachment(
  3803. to.downUrl,
  3804. token
  3805. ).getRequestedUrl();
  3806. // window.open(downUrl);
  3807. var a = document.createElement("a");
  3808. a.href = downUrl;
  3809. a.target = "_blank";
  3810. a.download = filename;
  3811. document.body.appendChild(a);
  3812. a.click();
  3813. };
  3814. //附件预览
  3815. $scope.view = function (id, previewUrl) {
  3816. if (previewUrl) {
  3817. window.open(previewUrl);
  3818. }
  3819. };
  3820. //下载资产模版
  3821. $scope.filenum = 0;
  3822. $scope.openmeans = function () {
  3823. var modalInstance = $modal.open({
  3824. templateUrl: "assets/views/means/tpl/meansdown.html",
  3825. controller: function ($scope, scope, $modalInstance) {
  3826. $scope.item = {};
  3827. $scope.title = "选择下载模版";
  3828. $scope.lable = "资产模版下载";
  3829. function foreachdata(my_datas) {
  3830. // angular.forEach(my_datas, function(item, index) {
  3831. // if (item.children && item.children.length > 0) {
  3832. // foreachdata(item.children);
  3833. // } else {
  3834. // my_datas[index].checks = true;
  3835. // }
  3836. // })
  3837. for (var i = 0; i < my_datas.length; i++) {
  3838. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3839. foreachdata(my_datas[i].children);
  3840. console.log($scope);
  3841. } else {
  3842. my_datas[i].checks = true;
  3843. }
  3844. }
  3845. }
  3846. function foreachtree(data) {
  3847. angular.forEach(data, function (item) {
  3848. // if (item.checks != true) {
  3849. item.checks = true;
  3850. item.expanded = true;
  3851. if (item.children && item.children.length > 0) {
  3852. foreachtree(item.children);
  3853. } else {
  3854. $scope.getslowtree.push(item);
  3855. }
  3856. // }
  3857. });
  3858. }
  3859. $scope.getslowtree = [];
  3860. $scope.slowtree = function (tree) {
  3861. foreachtree(tree);
  3862. return $scope.getslowtree;
  3863. };
  3864. $scope.all = function (c, v) {
  3865. //全选
  3866. if (c == true) {
  3867. $scope.formdashboard($scope.slowtree(v));
  3868. } else {
  3869. $scope.my_data_after = [];
  3870. angular.forEach($scope.my_data, function (item, index) {
  3871. $scope.my_data[index].checks = false;
  3872. $scope.my_data[index].expanded = false;
  3873. if (item.children && item.children.length > 0) {
  3874. angular.forEach(
  3875. item.children,
  3876. function (itemone, indexone) {
  3877. $scope.my_data[index].children[
  3878. indexone
  3879. ].checks = false;
  3880. $scope.my_data[index].children[
  3881. indexone
  3882. ].expanded = false;
  3883. if (itemone.children && itemone.children.length > 0) {
  3884. angular.forEach(
  3885. itemone.children,
  3886. function (itemtwo, indextwo) {
  3887. $scope.my_data[index].children[
  3888. indexone
  3889. ].children[indextwo].checks = false;
  3890. }
  3891. );
  3892. } else {
  3893. }
  3894. }
  3895. );
  3896. } else {
  3897. }
  3898. });
  3899. $scope.mydatacate = [];
  3900. $scope.getslowtree = [];
  3901. // }
  3902. }
  3903. };
  3904. // $scope.searchone = function(search) {
  3905. // angular.forEach($scope.my_data, function(item) {
  3906. // if (item.indexOf(search) > 0) {
  3907. // }
  3908. // })
  3909. // }
  3910. $scope.checkall = function () {
  3911. angular.forEach($scope.my_data, function (item, index) {
  3912. scope.my_data[index].checks = true;
  3913. });
  3914. };
  3915. $scope.selectitem = [];
  3916. $scope.choiceitem = function (item) {
  3917. // if (item.checkeds) {
  3918. // item.checkeds = false;
  3919. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3920. // // if ($scope.selectitem[i].id == item.id) {
  3921. // // $scope.selectitem.splice(i, 1)
  3922. // // }
  3923. // // }
  3924. // for (var i = 0; i < $scope.my_data_after; i++) {
  3925. // if ($scope.my_data_after[i].id == item.id) {
  3926. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3927. // // $scope.selectitem.splice(i, 1)
  3928. // }
  3929. // }
  3930. // } else {
  3931. // item.checkeds = true;
  3932. // $scope.selectitem.push(item)
  3933. // }
  3934. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3935. if ($scope.my_data_after[i].id == item.id) {
  3936. $scope.my_data_after[i].checkeds
  3937. ? ($scope.my_data_after[i].checkeds = false)
  3938. : ($scope.my_data_after[i].checkeds = true);
  3939. }
  3940. }
  3941. };
  3942. $scope.remove = function (removeitem) {
  3943. var realdat = angular.copy($scope.my_data_after);
  3944. // angular.extend(realdat, $scope.selectitem);
  3945. $scope.my_data_after = [];
  3946. angular.forEach(realdat, function (item) {
  3947. if (!item.checkeds) {
  3948. $scope.my_data_after.push(item);
  3949. }
  3950. });
  3951. $scope.mydatacate = angular.copy($scope.my_data_after);
  3952. };
  3953. $scope.try_async_loads = function (item, search) {
  3954. var fildatas = {
  3955. idx: 0,
  3956. sum: 1000,
  3957. };
  3958. $scope.my_data = [];
  3959. // $scope.try_async_load = true;
  3960. if (item) {
  3961. angular.extend(fildatas, item);
  3962. }
  3963. api_configure_data
  3964. .fetchDataList("ciclassify", fildatas)
  3965. .then(function (response) {
  3966. if (response.status == 200) {
  3967. var data = response.list;
  3968. var objects = [];
  3969. for (var i = 0; i < data.length; i++) {
  3970. var object = {};
  3971. object.id = data[i].id;
  3972. if (search) {
  3973. delete data[i].parent;
  3974. } else {
  3975. if (data[i].parent && data[i].parent.id != 0) {
  3976. object.parent = data[i].parent.id;
  3977. }
  3978. }
  3979. angular.extend(object, data[i]);
  3980. objects.push(object);
  3981. }
  3982. $scope.my_data = convertParentToChildList(objects);
  3983. $scope.tree_data = angular.copy($scope.my_data);
  3984. if ($scope.my_data.length > 0) {
  3985. $scope.try_async_load = false;
  3986. }
  3987. } else {
  3988. SweetAlert.swal({
  3989. title: "系统错误!",
  3990. text: "请刷新重试!",
  3991. type: "error",
  3992. });
  3993. }
  3994. });
  3995. };
  3996. function convertListToTree(data, treeMap) {
  3997. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3998. var root = null; //Initially set our loop to null
  3999. //loop over data
  4000. for (var i = 0; i < data.length; i++) {
  4001. var datum = data[i];
  4002. //each node will have children, so let's give it a "children" poperty
  4003. datum.children = [];
  4004. //add an entry for this node to the map so that any future children can
  4005. //lookup the parent
  4006. idToNodeMap[datum.id] = datum;
  4007. //Does this node have a parent?
  4008. // console.log("datum="+JSON.stringify(datum))
  4009. if (
  4010. typeof datum.parent === "undefined" ||
  4011. datum.parent === null
  4012. ) {
  4013. //Doesn't look like it, so this node is the root of the tree
  4014. root = datum;
  4015. treeMap[datum.id] = root;
  4016. } else {
  4017. //This node has a parent, so let's look it up using the id
  4018. parentNode = idToNodeMap[datum.parent.id];
  4019. //We don't need this property, so let's delete it.
  4020. // delete datum.parent;
  4021. //Let's add the current node as a child of the parent node.
  4022. parentNode.children.push(datum);
  4023. }
  4024. }
  4025. return root;
  4026. }
  4027. function convertParentToChildList(data) {
  4028. var treeMap = {};
  4029. var list = [];
  4030. convertListToTree(data, treeMap);
  4031. angular.forEach(treeMap, function (item) {
  4032. list.push(item);
  4033. });
  4034. return list;
  4035. }
  4036. function convertParentToChild(datato) {
  4037. var treeMapto = {};
  4038. var listto = [];
  4039. convertListToTree(datato, treeMapto);
  4040. angular.forEach(treeMapto, function (items) {
  4041. listto.push(items);
  4042. });
  4043. return listto;
  4044. }
  4045. $scope.try_async_loads();
  4046. $scope.searchdown = function (key) {
  4047. if (key && key != "") {
  4048. $scope.try_async_loads(
  4049. {
  4050. ciclassify: {
  4051. label: key,
  4052. },
  4053. },
  4054. "search"
  4055. );
  4056. } else {
  4057. $scope.try_async_loads();
  4058. }
  4059. // var mydatacatedown = angular.copy($scope.my_data);
  4060. // $scope.my_data = [];
  4061. // var objects = [];
  4062. // angular.forEach(mydatacatedown, function(item) {
  4063. // if (item.label.match(key)) {
  4064. // objects.push(item)
  4065. // } else {
  4066. // // $scope.my_data_after.push(item)
  4067. // }
  4068. // })
  4069. // $scope.my_data = convertParentToChildList(objects);
  4070. // $scope.tree_data = angular.copy($scope.my_data);
  4071. };
  4072. $scope.mydatacate = [];
  4073. $scope.searchup = function (key) {
  4074. // var mydatacate = angular.copy($scope.my_data_after);
  4075. $scope.my_data_after = [];
  4076. angular.forEach($scope.mydatacate, function (item) {
  4077. if (item.label.match(key)) {
  4078. $scope.my_data_after.push(item);
  4079. } else {
  4080. }
  4081. });
  4082. };
  4083. //角色树
  4084. $scope.my_tree = [];
  4085. $scope.tree_data_after = [];
  4086. $scope.my_data = [];
  4087. $scope.my_data_after = [];
  4088. $scope.formdashboard = function (item) {
  4089. $scope.my_data_after = [];
  4090. angular.forEach(item, function (infox) {
  4091. if (infox.children.length == 0) {
  4092. $scope.my_data_after.push(infox);
  4093. }
  4094. });
  4095. $scope.mydatacate = angular.copy($scope.my_data_after);
  4096. };
  4097. $scope.ok = function (item) {
  4098. $modalInstance.close(item);
  4099. };
  4100. $scope.cancel = function () {
  4101. $modalInstance.dismiss("cancel");
  4102. };
  4103. },
  4104. // size: 'sm',
  4105. resolve: {
  4106. scope: function () {
  4107. return $scope;
  4108. },
  4109. },
  4110. });
  4111. modalInstance.result.then(function (selectedItem) {
  4112. // $rootScope.isMask = true;
  4113. if (selectedItem) {
  4114. var type = 1;
  4115. var fildat = {
  4116. configure: selectedItem,
  4117. };
  4118. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4119. // // if (data.errno == 0) {
  4120. // var file = new Blob([data], {
  4121. // // 'Accept': '*/*'
  4122. // type: 'application/octet-stream'
  4123. // // type: 'application/vnd.ms-excel'
  4124. // });
  4125. // //trick to download store a file having its URL
  4126. // var fileURL = URL.createObjectURL(file);
  4127. // var a = document.createElement('a');
  4128. // a.href = fileURL;
  4129. // a.target = '_blank';
  4130. // a.download = "资产导入模版.xlsx";
  4131. // document.body.appendChild(a);
  4132. // a.click();
  4133. // // }
  4134. // })
  4135. $http({
  4136. url: api_configure_data
  4137. .downModels("export/cmdb", fildat)
  4138. .getRequestedUrl(),
  4139. method: "POST",
  4140. data: JSON.stringify(fildat),
  4141. headers: {
  4142. // 'Content-type': 'application/xls',
  4143. Accept: "*/*",
  4144. },
  4145. responseType: "arraybuffer",
  4146. })
  4147. .success(function (data, status, headers, config) {
  4148. $rootScope.isMask = false;
  4149. var file = new Blob([data], {
  4150. type: "application/octet-stream",
  4151. // type : 'application/vnd.ms-excel'
  4152. });
  4153. //trick to download store a file having its URL
  4154. var fileURL = URL.createObjectURL(file);
  4155. var a = document.createElement("a");
  4156. a.href = fileURL;
  4157. a.target = "_blank";
  4158. a.download = "资产导入模版.xlsx";
  4159. document.body.appendChild(a);
  4160. a.click();
  4161. })
  4162. .error(function (data, status, headers, config) {
  4163. // console.log(data);
  4164. $rootScope.isMask = false;
  4165. });
  4166. // break;
  4167. // }
  4168. // }
  4169. // }
  4170. // })
  4171. } else {
  4172. SweetAlert.swal(
  4173. {
  4174. title: "未选择资产分类!",
  4175. text: "请选择资产分类",
  4176. type: "error",
  4177. },
  4178. function () {
  4179. $rootScope.isMask = false;
  4180. }
  4181. );
  4182. }
  4183. // }
  4184. });
  4185. };
  4186. $scope.wrongdata = [];
  4187. var uploader = ($scope.uploader =
  4188. $scope.options.templateOptions.fileUploader);
  4189. var uploadermeans = ($scope.uploadermeans =
  4190. $scope.options.templateOptions.fileUploadermeans);
  4191. $scope.importopen = function () {
  4192. //导入触发事件
  4193. if (angular.isUndefined($scope.form.dropState)) {
  4194. $scope.form.dropState = false;
  4195. }
  4196. //附件上传数据
  4197. //$scope.options.templateOptions.uploader();
  4198. // FILTERS
  4199. uploader.filters.push({
  4200. name: "customFilter",
  4201. fn: function (item /*{File|FileLikeObject}*/, options) {
  4202. return this.queue.length < 2;
  4203. },
  4204. });
  4205. // CALLBACKS
  4206. uploader.onWhenAddingFileFailed = function (
  4207. item /*{File|FileLikeObject}*/,
  4208. filter,
  4209. options
  4210. ) {
  4211. console.info("onWhenAddingFileFailed", item, filter, options);
  4212. };
  4213. uploader.onAfterAddingFile = function (fileItem) {
  4214. console.info("onAfterAddingFile", fileItem);
  4215. };
  4216. uploader.onAfterAddingAll = function (addedFileItems) {
  4217. console.info("onAfterAddingAll", addedFileItems);
  4218. };
  4219. uploader.onBeforeUploadItem = function (item) {
  4220. console.info("onBeforeUploadItem", item);
  4221. };
  4222. uploader.onProgressItem = function (fileItem, progress) {
  4223. console.info("onProgressItem", fileItem, progress);
  4224. };
  4225. uploader.onProgressAll = function (progress) {
  4226. console.info("onProgressAll", progress);
  4227. };
  4228. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4229. // console.info('onSuccessItem', fileItem, response, status, headers);
  4230. // };
  4231. uploader.onErrorItem = function (
  4232. fileItem,
  4233. response,
  4234. status,
  4235. headers
  4236. ) {
  4237. console.info("onErrorItem", fileItem, response, status, headers);
  4238. };
  4239. uploader.onCancelItem = function (
  4240. fileItem,
  4241. response,
  4242. status,
  4243. headers
  4244. ) {
  4245. console.info("onCancelItem", fileItem, response, status, headers);
  4246. };
  4247. uploader.onCompleteItem = function (
  4248. fileItem,
  4249. response,
  4250. status,
  4251. headers
  4252. ) {
  4253. console.info("onCompleteItem", fileItem, response, status, headers);
  4254. };
  4255. uploader.onCompleteAll = function () {
  4256. console.info("onCompleteAll");
  4257. };
  4258. };
  4259. // $scope.importnext = function() {
  4260. // $scope.state = 2;
  4261. // event.preventDefault();
  4262. // }
  4263. $scope.importnext = function () {
  4264. event.preventDefault();
  4265. // $rootScope.isMask = true;
  4266. $rootScope.loading = true;
  4267. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4268. uploader.onBeforeUploadItem = function (item) {
  4269. angular.extend(item.headers, $rootScope.getSession());
  4270. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4271. // if (item.index > 1) {
  4272. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4273. // }
  4274. // item.index = 1;
  4275. item.formData = [
  4276. {
  4277. filename: item.file.name,
  4278. },
  4279. ];
  4280. console.info("onBeforeUploadItem", item);
  4281. };
  4282. uploader.uploadAll();
  4283. uploader.onSuccessItem = function (
  4284. fileItem,
  4285. response,
  4286. status,
  4287. headers
  4288. ) {
  4289. if (response.status == 200) {
  4290. $scope.wrongdata = [];
  4291. $rootScope.loading = false;
  4292. if (response.abnormal) {
  4293. $scope.state = 2;
  4294. angular.forEach(response.msg, function (item) {
  4295. $scope.wrongdata.push({
  4296. name: item.assetName,
  4297. line: item.row,
  4298. cmdbname: item.name,
  4299. errotip: [
  4300. {
  4301. label: item.msg,
  4302. },
  4303. ],
  4304. });
  4305. });
  4306. } else {
  4307. $scope.state = 3;
  4308. }
  4309. } else {
  4310. $rootScope.loading = false;
  4311. $scope.state = 2;
  4312. }
  4313. };
  4314. };
  4315. $scope.clearItems = function () {
  4316. //重新选择文件时,清空队列,达到覆盖文件的效果
  4317. uploader.clearQueue();
  4318. // uploader.remove();
  4319. // uploader.cancel();
  4320. // uploader.onChange();
  4321. };
  4322. uploader.onAfterAddingFile = function (fileItem) {
  4323. $scope.fileItem = fileItem._file;
  4324. // $scope.$apply();
  4325. // $scope.fileItem = filenum;
  4326. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4327. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4328. $scope.filenum++;
  4329. };
  4330. uploader.onSuccessItem = function (
  4331. fileItem,
  4332. response,
  4333. status,
  4334. headers
  4335. ) {
  4336. $scope.uploadStatus = true; //上传成功则把状态改为true
  4337. // alert(response.path);
  4338. };
  4339. $scope.importnext = function () {
  4340. event.preventDefault();
  4341. // uploader.onChange();
  4342. $rootScope.loading = true;
  4343. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4344. uploader.onBeforeUploadItem = function (item) {
  4345. angular.extend(item.headers, $rootScope.getSession());
  4346. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4347. // if (item.index > 1) {
  4348. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4349. // }
  4350. // item.index = 1;
  4351. item.formData = [
  4352. {
  4353. filename: item.file.name,
  4354. },
  4355. ];
  4356. console.info("onBeforeUploadItem", item);
  4357. };
  4358. uploader.uploadAll();
  4359. uploader.onSuccessItem = function (
  4360. fileItem,
  4361. response,
  4362. status,
  4363. headers
  4364. ) {
  4365. if (response.status == 200) {
  4366. $scope.wrongdata = [];
  4367. // uploader.queue = [];
  4368. $rootScope.loading = false;
  4369. if (response.abnormal) {
  4370. $scope.state = 2;
  4371. uploader.clearQueue();
  4372. angular.forEach(response.msg, function (item) {
  4373. $scope.wrongdata.push({
  4374. name: item.assetName,
  4375. line: item.row,
  4376. cmdbname: item.name,
  4377. errotip: [
  4378. {
  4379. label: item.msg,
  4380. },
  4381. ],
  4382. });
  4383. });
  4384. } else {
  4385. $scope.state = 3;
  4386. }
  4387. } else {
  4388. uploader.clearQueue();
  4389. $rootScope.loading = false;
  4390. $scope.state = 2;
  4391. }
  4392. };
  4393. };
  4394. var setAllInactive = function () {
  4395. angular.forEach($scope.workspaces, function (workspace) {
  4396. workspace.active = false;
  4397. });
  4398. };
  4399. //添加
  4400. var addNewWorkspace = function (name, contentUrl) {
  4401. var id = $scope.workspaces.length + 1;
  4402. $scope.workspaces.push({
  4403. id: id,
  4404. name: name,
  4405. active: true,
  4406. contentUrl: "main/html/content.html",
  4407. });
  4408. };
  4409. //关闭
  4410. $scope.closeopen = function (closedata) {
  4411. event.preventDefault();
  4412. angular.forEach($scope.workspaces, function (item, index) {
  4413. if (closedata.id == item.id) {
  4414. if (closedata.id == 1) {
  4415. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4416. } else {
  4417. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4418. }
  4419. $scope.workspaces.splice(index, 1);
  4420. }
  4421. });
  4422. };
  4423. // $scope.workspaces = [
  4424. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4425. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4426. // ];
  4427. $scope.addWorkspace = function (contentUrl, name) {
  4428. setAllInactive();
  4429. addNewWorkspace(name, contentUrl);
  4430. };
  4431. // $rootScope.addWorkspace = $scope.addWorkspace;
  4432. $scope.close = function (idNumber) {
  4433. var index = 0; //记录当前元素下标
  4434. angular.forEach($scope.workspaces, function (workspace) {
  4435. if (workspace.id === idNumber) {
  4436. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4437. }
  4438. index++;
  4439. });
  4440. };
  4441. //grid2
  4442. $scope.langs = i18nService.getAllLangs();
  4443. $scope.lang = "zh-cn";
  4444. i18nService.setCurrentLang($scope.lang);
  4445. $scope.gridOptions2 = {};
  4446. $scope.gridOptions2.data = "myData3";
  4447. $scope.gridOptions2.enableColumnResizing = true;
  4448. $scope.gridOptions2.enableFiltering = false;
  4449. $scope.gridOptions2.enableGridMenu = false;
  4450. $scope.gridOptions2.showGridFooter = true;
  4451. $scope.gridOptions2.showColumnFooter = false;
  4452. $scope.gridOptions2.fastWatch = true;
  4453. $scope.gridOptions2.useExternalFiltering = true;
  4454. $scope.gridOptions2.useExternalPagination = true;
  4455. $scope.gridOptions2.paginationPageSizes = [10];
  4456. $scope.gridOptions2.paginationPageSize = 10;
  4457. $scope.gridOptions2.multiSelect = false;
  4458. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4459. $scope.gridOptions2.columnDefs = [
  4460. {
  4461. name: "item",
  4462. displayName: "序号",
  4463. width: 120,
  4464. },
  4465. {
  4466. name: "name",
  4467. displayName: "耗材名称",
  4468. width: 80,
  4469. enableFiltering: false,
  4470. },
  4471. {
  4472. name: "model",
  4473. displayName: "品牌/型号",
  4474. width: 100,
  4475. enableFiltering: false,
  4476. },
  4477. {
  4478. name: "Specifications",
  4479. displayName: "规格",
  4480. width: 150,
  4481. enableFiltering: false,
  4482. },
  4483. {
  4484. name: "sum",
  4485. displayName: "数量",
  4486. enableFiltering: false,
  4487. },
  4488. {
  4489. name: "操作",
  4490. cellTemplate:
  4491. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4492. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4493. "</div></div>",
  4494. enableFiltering: false,
  4495. },
  4496. ];
  4497. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4498. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4499. $scope.myData3all = JSON.parse(
  4500. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4501. );
  4502. for (var i = 0; i < $scope.myData3all.length; i++) {
  4503. $scope.myData3all[i]["item"] =
  4504. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4505. }
  4506. // $scope.model.consumables = $scope.myDataone;
  4507. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4508. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4509. $scope.model.applicationForm.consumables = $scope.myData3all;
  4510. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4511. $scope.options.templateOptions.getpush({
  4512. hao: true,
  4513. gu: true,
  4514. });
  4515. } else {
  4516. $scope.options.templateOptions.getpush({
  4517. hao: true,
  4518. });
  4519. }
  4520. } else {
  4521. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4522. $scope.options.templateOptions.getpush({
  4523. gu: true,
  4524. });
  4525. }
  4526. }
  4527. }
  4528. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4529. $scope.changecai = function (item) {
  4530. event.preventDefault();
  4531. var modalInstance = $modal.open({
  4532. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4533. controller: function ($scope, $modalInstance) {
  4534. $scope.title = "修改耗材数量";
  4535. $scope.consumptive = angular.copy(item);
  4536. $scope.ok = function () {
  4537. $modalInstance.close($scope.consumptive);
  4538. };
  4539. $scope.cancel = function () {
  4540. $modalInstance.dismiss("cancel");
  4541. };
  4542. },
  4543. size: "sm",
  4544. });
  4545. modalInstance.result.then(function (selectedItem) {
  4546. // angular.forEach($scope.myData3, function(items, index) {
  4547. // if (items.id == selectedItem.id) {
  4548. // $scope.myData3[index] = selectedItem;
  4549. // }
  4550. // })
  4551. // // $scope.myData3.push(selectedItem);
  4552. // $scope.model.applicationForm.consumables = $scope.myData3;
  4553. angular.forEach($scope.myData3all, function (items, index) {
  4554. if (
  4555. items.modelid == selectedItem.modelid &&
  4556. items.nameid == selectedItem.nameid &&
  4557. items.Specificationsid == selectedItem.Specificationsid
  4558. ) {
  4559. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4560. angular.extend($scope.myData3all[index], selectedItem);
  4561. }
  4562. });
  4563. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4564. $scope.myData3 = $scope.interceptMydata(
  4565. $scope.myData3all,
  4566. $scope.memoryfilterDatahao.idx,
  4567. 10
  4568. );
  4569. $scope.model.applicationForm.consumables = $scope.myData3all;
  4570. });
  4571. };
  4572. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4573. $scope.gridApi = gridApi;
  4574. gridApi.pagination.on.paginationChanged(
  4575. $scope,
  4576. function (newPage, pageSize) {
  4577. // var filtersData = $scope.memoryfilterDatahao;
  4578. // filtersData.idx = newPage - 1;
  4579. // filtersData.sum = pageSize;
  4580. // $scope.loadData(filtersData);
  4581. $scope.memoryfilterDatahao.idx = newPage - 1;
  4582. $scope.memoryfilterDatahao.sum = pageSize;
  4583. $scope.myData3 = $scope.interceptMydata(
  4584. $scope.myData3all,
  4585. $scope.memoryfilterDatahao.idx,
  4586. 10
  4587. );
  4588. }
  4589. );
  4590. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4591. $scope.selected.items = data.entity;
  4592. //console.log(data);
  4593. });
  4594. gridApi.selection.on.rowSelectionChangedBatch(
  4595. $scope,
  4596. function (data) {
  4597. $scope.selected.items = data.entity;
  4598. //console.log(data);
  4599. }
  4600. );
  4601. gridApi.core.on.filterChanged($scope, function () {
  4602. var grid = this.grid;
  4603. var filtersData = {
  4604. idx: 0,
  4605. sum: 10,
  4606. };
  4607. $scope.memoryfilterDatahao = filtersData;
  4608. // $scope.loadData(filtersData);
  4609. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4610. // $scope.memoryfilterDatahao.sum = pageSize;
  4611. $scope.myData3 = $scope.interceptMydata(
  4612. $scope.myData3all,
  4613. $scope.memoryfilterDatahao.idx,
  4614. 10
  4615. );
  4616. });
  4617. };
  4618. $scope.haocaiopen = function (items) {
  4619. event.preventDefault();
  4620. var modalInstance = $modal.open({
  4621. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4622. controller: function ($scope, $modalInstance, SweetAlert) {
  4623. $scope.consumptive = {};
  4624. $scope.title = "新增耗材";
  4625. if (items.name) {
  4626. $scope.consumptive.name = items.name.name;
  4627. }
  4628. $scope.clearNoNum = function (obj, attr) {
  4629. //先把非数字的都替换掉,除了数字和.
  4630. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4631. //必须保证第一个为数字而不是.
  4632. obj[attr] = obj[attr].replace(/^\./g, "");
  4633. //保证只有出现一个.而没有多个.
  4634. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4635. //保证.只出现一次,而不能出现两次以上
  4636. obj[attr] = obj[attr]
  4637. .replace(".", "$#$")
  4638. .replace(/\./g, "")
  4639. .replace("$#$", ".");
  4640. //小于最大值
  4641. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4642. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4643. // obj[attr] = '';
  4644. // }
  4645. };
  4646. $scope.ok = function (item) {
  4647. // if (item.name && item.model && item.Specifications && item.sum) {
  4648. if (
  4649. item.name &&
  4650. item.model &&
  4651. JSON.stringify(item.model) != "{}" &&
  4652. item.Specifications &&
  4653. JSON.stringify(item.Specifications) != "{}" &&
  4654. item.sum
  4655. ) {
  4656. $modalInstance.close(item);
  4657. } else {
  4658. SweetAlert.swal({
  4659. title: "数据填写不完整!",
  4660. text: "请检查数据然后提交!",
  4661. type: "error",
  4662. });
  4663. }
  4664. };
  4665. $scope.cancel = function () {
  4666. $modalInstance.dismiss("cancel");
  4667. };
  4668. },
  4669. size: "sm",
  4670. resolve: {
  4671. SweetAlert: function () {
  4672. return SweetAlert;
  4673. },
  4674. },
  4675. });
  4676. modalInstance.result.then(function (selectedItem) {
  4677. api_sysinfo
  4678. .addData("dictionaryTree", {
  4679. // "type": "list",
  4680. key: "haocaifenlei",
  4681. name: selectedItem.name,
  4682. parent: selectedItem.id,
  4683. value: selectedItem.name,
  4684. deleted: false,
  4685. level: 1,
  4686. })
  4687. .then(function (data) {
  4688. // $scope.haocainame.name = data.list;
  4689. api_sysinfo
  4690. .addData("dictionaryTree", {
  4691. // "type": "list",
  4692. key: "pinpai",
  4693. name: selectedItem.model,
  4694. parent: data.id,
  4695. value: selectedItem.model,
  4696. deleted: false,
  4697. level: 2,
  4698. })
  4699. .then(function (data) {
  4700. // $scope.haocainame = data.list;
  4701. });
  4702. api_sysinfo
  4703. .addData({
  4704. // "type": "list",
  4705. key: "guige",
  4706. name: selectedItem.Specifications,
  4707. parent: data.id,
  4708. value: selectedItem.Specifications,
  4709. deleted: false,
  4710. level: 2,
  4711. })
  4712. .then(function (data) {
  4713. // $scope.haocainame = data.list;
  4714. });
  4715. });
  4716. // $scope.myData3.push(selectedItem);
  4717. // for (var i = 0; i < $scope.myData3.length; i++) {
  4718. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4719. // }
  4720. // $scope.model.applicationForm.consumables = $scope.myData3;
  4721. $scope.myData3all.push(selectedItem);
  4722. for (var i = 0; i < $scope.myData3all.length; i++) {
  4723. $scope.myData3all[i]["item"] = i + 1;
  4724. }
  4725. // $scope.model.consumables = $scope.myDataone;
  4726. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4727. $scope.myData3 = $scope.interceptMydata(
  4728. $scope.myData3all,
  4729. $scope.memoryfilterDatahao.idx,
  4730. 10
  4731. );
  4732. $scope.model.applicationForm.consumables = $scope.myData3all;
  4733. });
  4734. };
  4735. $scope.haocaiadd = function () {
  4736. event.preventDefault();
  4737. var modalInstance = $modal.open({
  4738. templateUrl:
  4739. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4740. controller: function (
  4741. $scope,
  4742. scope,
  4743. $modalInstance,
  4744. api_wechatfile,
  4745. SweetAlert,
  4746. api_cmdb3
  4747. ) {
  4748. $scope.haocainame = [];
  4749. $scope.pinpai = [];
  4750. $scope.guige = [];
  4751. $scope.consumptive = {};
  4752. $scope.consumpall = {};
  4753. $scope.title = "添加耗材";
  4754. api_wechatfile
  4755. .getDictionary({
  4756. key: "haocaifenlei",
  4757. type: "tree",
  4758. })
  4759. .then(function (data) {
  4760. $scope.haocainame = data;
  4761. });
  4762. $scope.clearNoNum = function (obj, attr) {
  4763. //先把非数字的都替换掉,除了数字和.
  4764. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4765. //必须保证第一个为数字而不是.
  4766. obj[attr] = obj[attr].replace(/^\./g, "");
  4767. //保证只有出现一个.而没有多个.
  4768. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4769. //保证.只出现一次,而不能出现两次以上
  4770. obj[attr] = obj[attr]
  4771. .replace(".", "$#$")
  4772. .replace(/\./g, "")
  4773. .replace("$#$", ".");
  4774. //小于最大值
  4775. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4776. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4777. // obj[attr] = '';
  4778. // }
  4779. };
  4780. $scope.onChange = function (parent) {
  4781. $scope.consumptive.model = {};
  4782. $scope.consumptive.Specifications = {};
  4783. api_wechatfile
  4784. .getDictionaryForList({
  4785. key: "pinpai",
  4786. parent: parent.id,
  4787. })
  4788. .then(function (data) {
  4789. $scope.pinpai = data;
  4790. });
  4791. api_wechatfile
  4792. .getDictionaryForList({
  4793. key: "guige",
  4794. parent: parent.id,
  4795. })
  4796. .then(function (data) {
  4797. $scope.guige = data;
  4798. });
  4799. };
  4800. $scope.addhaocai = function () {
  4801. $modalInstance.dismiss("cancel");
  4802. scope.haocaiopen($scope.consumptive);
  4803. };
  4804. $scope.ok = function (item) {
  4805. var items = {};
  4806. var submittrue = true;
  4807. if (
  4808. item.name &&
  4809. item.model &&
  4810. JSON.stringify(item.model) != "{}" &&
  4811. item.Specifications &&
  4812. JSON.stringify(item.Specifications) != "{}" &&
  4813. item.sum
  4814. ) {
  4815. items = {
  4816. modelid: item.model.id,
  4817. nameid: item.name.id,
  4818. Specificationsid: item.Specifications.id,
  4819. name: item.name.name,
  4820. model: item.model.name,
  4821. Specifications: item.Specifications.name,
  4822. sum: item.sum,
  4823. };
  4824. angular.forEach(scope.myData3all, function (itemsdata) {
  4825. if (
  4826. item.model.id == itemsdata.modelid &&
  4827. item.name.id == itemsdata.nameid &&
  4828. item.Specifications.id == itemsdata.Specificationsid
  4829. ) {
  4830. submittrue = false;
  4831. }
  4832. });
  4833. if (submittrue) {
  4834. $modalInstance.close(items);
  4835. } else {
  4836. SweetAlert.swal({
  4837. title: "该耗材已有添加",
  4838. text: "请检查数据然后提交!",
  4839. type: "error",
  4840. });
  4841. }
  4842. } else {
  4843. SweetAlert.swal({
  4844. title: "数据填写不完整!",
  4845. text: "请检查数据然后提交!",
  4846. type: "error",
  4847. });
  4848. }
  4849. // var isold = false;
  4850. // if (item.name && item.model && item.Specifications && item.sum) {
  4851. // for (var i = 0; i < scope.myData3all.length; i++) {
  4852. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4853. // isold = true;
  4854. // }
  4855. // }
  4856. // if (isold) {
  4857. // SweetAlert.swal({
  4858. // title: "该耗材已添加!",
  4859. // text: "请不要重复添加耗材!",
  4860. // type: "error"
  4861. // });
  4862. // } else {
  4863. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4864. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4865. // $scope.consumpall.sum = item.sum;
  4866. // delete $scope.consumpall.brandModel;
  4867. // delete $scope.consumpall.specification;
  4868. // $modalInstance.close($scope.consumpall);
  4869. // }
  4870. // } else {
  4871. // SweetAlert.swal({
  4872. // title: "数据填写不完整!",
  4873. // text: "请检查数据然后提交!",
  4874. // type: "error"
  4875. // });
  4876. // }
  4877. };
  4878. $scope.cancel = function () {
  4879. $modalInstance.dismiss("cancel");
  4880. };
  4881. },
  4882. size: "sm",
  4883. resolve: {
  4884. scope: function () {
  4885. return $scope;
  4886. },
  4887. },
  4888. });
  4889. modalInstance.result.then(function (selectedItem) {
  4890. $scope.myData3all.push(selectedItem);
  4891. for (var i = 0; i < $scope.myData3all.length; i++) {
  4892. $scope.myData3all[i]["item"] = i + 1;
  4893. }
  4894. // $scope.model.consumables = $scope.myDataone;
  4895. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4896. $scope.myData3 = $scope.interceptMydata(
  4897. $scope.myData3all,
  4898. $scope.memoryfilterDatahao.idx,
  4899. 10
  4900. );
  4901. $scope.model.applicationForm.consumables = $scope.myData3all;
  4902. });
  4903. };
  4904. $scope.onDblClick = function (data, event) {
  4905. $scope.selectButtonClick(data, event);
  4906. };
  4907. // $scope.memoryfilterDatahao = {
  4908. // "idx": 0,
  4909. // "sum": 10,
  4910. // }
  4911. // $scope.loadData = function(filterData) {};
  4912. // $scope.title = title;
  4913. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4914. $scope.options.templateOptions.transform(
  4915. $scope.options,
  4916. $rootScope,
  4917. $scope
  4918. );
  4919. }
  4920. },
  4921. ],
  4922. });
  4923. //归还设备耗材tab
  4924. formlyConfigProvider.setType({
  4925. name: "ui-cmdbreturntab",
  4926. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4927. wrapper: ["bootstrapHasError"],
  4928. defaultOptions: function (options, $scope) {
  4929. return {
  4930. templateOptions: {
  4931. // checkform: function(options) {
  4932. // if (options.model.requester) {
  4933. // options.value(options.model.requester);
  4934. // }
  4935. // },
  4936. },
  4937. };
  4938. },
  4939. controller: [
  4940. "$scope",
  4941. "$modal",
  4942. "api_user_data",
  4943. "i18nService",
  4944. "api_wechatfile",
  4945. "api_cmdb3",
  4946. function (
  4947. $scope,
  4948. $modal,
  4949. api_user_data,
  4950. i18nService,
  4951. api_wechatfile,
  4952. api_cmdb3
  4953. ) {
  4954. var setAllInactive = function () {
  4955. angular.forEach($scope.workspaces, function (workspace) {
  4956. workspace.active = false;
  4957. });
  4958. };
  4959. $scope.memoryfilterData = {
  4960. idx: 0,
  4961. sum: 10,
  4962. };
  4963. //添加
  4964. var addNewWorkspace = function (name, contentUrl) {
  4965. var id = $scope.workspaces.length + 1;
  4966. $scope.workspaces.push({
  4967. id: id,
  4968. name: name,
  4969. active: true,
  4970. contentUrl: "main/html/content.html",
  4971. });
  4972. };
  4973. $scope.workspaces = [
  4974. {
  4975. id: 1,
  4976. name: "归还设备",
  4977. active: true,
  4978. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4979. },
  4980. {
  4981. id: 2,
  4982. name: "归还耗材",
  4983. active: true,
  4984. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4985. },
  4986. ];
  4987. $scope.addWorkspace = function (contentUrl, name) {
  4988. setAllInactive();
  4989. addNewWorkspace(name, contentUrl);
  4990. };
  4991. // $rootScope.addWorkspace = $scope.addWorkspace;
  4992. $scope.close = function (idNumber) {
  4993. var index = 0; //记录当前元素下标
  4994. angular.forEach($scope.workspaces, function (workspace) {
  4995. if (workspace.id === idNumber) {
  4996. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4997. }
  4998. index++;
  4999. });
  5000. };
  5001. $scope.memoryfilterDataguishe = {
  5002. idx: 0,
  5003. sum: 10,
  5004. };
  5005. //grid1
  5006. $scope.langs = i18nService.getAllLangs();
  5007. $scope.lang = "zh-cn";
  5008. i18nService.setCurrentLang($scope.lang);
  5009. $scope.gridOptions1 = {};
  5010. $scope.gridOptions1.data = "myData1";
  5011. $scope.gridOptions1.enableColumnResizing = true;
  5012. $scope.gridOptions1.enableFiltering = false;
  5013. $scope.gridOptions1.enableGridMenu = false;
  5014. $scope.gridOptions1.showGridFooter = true;
  5015. $scope.gridOptions1.showColumnFooter = false;
  5016. $scope.gridOptions1.fastWatch = true;
  5017. $scope.gridOptions1.useExternalFiltering = true;
  5018. $scope.gridOptions1.useExternalPagination = true;
  5019. $scope.gridOptions1.paginationPageSizes = [10];
  5020. $scope.gridOptions1.paginationPageSize = 10;
  5021. $scope.gridOptions1.multiSelect = false;
  5022. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5023. $scope.gridOptions1.columnDefs = [
  5024. {
  5025. name: "item",
  5026. displayName: "序号",
  5027. width: 120,
  5028. },
  5029. {
  5030. name: "props.hw_cifilterClassic",
  5031. displayName: "设备类型",
  5032. width: 150,
  5033. enableFiltering: false,
  5034. },
  5035. {
  5036. name: "props.hw_mingcheng",
  5037. displayName: "设备名称",
  5038. width: 180,
  5039. enableFiltering: false,
  5040. },
  5041. {
  5042. name: "uuid",
  5043. displayName: "设备编号",
  5044. width: 180,
  5045. enableFiltering: false,
  5046. },
  5047. {
  5048. name: "props.hw_state",
  5049. width: 150,
  5050. displayName: "状态",
  5051. enableFiltering: false,
  5052. },
  5053. {
  5054. name: "操作",
  5055. cellTemplate:
  5056. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5057. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5058. "</div></div>",
  5059. enableFiltering: false,
  5060. },
  5061. ];
  5062. // $scope.selectButtonClick
  5063. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5064. $scope.gridApi = gridApi;
  5065. gridApi.pagination.on.paginationChanged(
  5066. $scope,
  5067. function (newPage, pageSize) {
  5068. // var filtersData = $scope.memoryfilterData;
  5069. // filtersData.idx = newPage - 1;
  5070. // filtersData.sum = pageSize;
  5071. // $scope.loadData(filtersData);
  5072. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5073. $scope.memoryfilterDataguishe.sum = pageSize;
  5074. $scope.myData1 = $scope.interceptMydata(
  5075. $scope.myData2all,
  5076. $scope.memoryfilterDataguishe.idx,
  5077. 10
  5078. );
  5079. }
  5080. );
  5081. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5082. $scope.selected.items = data.entity;
  5083. //console.log(data);
  5084. });
  5085. gridApi.selection.on.rowSelectionChangedBatch(
  5086. $scope,
  5087. function (data) {
  5088. $scope.selected.items = data.entity;
  5089. //console.log(data);
  5090. }
  5091. );
  5092. gridApi.core.on.filterChanged($scope, function () {
  5093. // var grid = this.grid;
  5094. // var filtersData = {
  5095. // idx: 0,
  5096. // sum: 20,
  5097. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5098. // };
  5099. // angular.forEach(grid.columns, function(item) {
  5100. // if (item.enableFiltering) {
  5101. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5102. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5103. // if (angular.isUndefined(filtersData['user'])) {
  5104. // filtersData['user'] = {};
  5105. // }
  5106. // filtersData['user'][item.field] = item.filters[0].term;
  5107. // }
  5108. // }
  5109. // });
  5110. // $scope.memoryfilterData = filtersData;
  5111. // $scope.loadData(filtersData);
  5112. });
  5113. };
  5114. $scope.changegu = function (item) {
  5115. event.preventDefault();
  5116. var modalInstance = $modal.open({
  5117. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5118. controller: function ($scope, $modalInstance) {
  5119. $scope.title = "修改设备状态";
  5120. $scope.hw_state = {};
  5121. if (item.status) {
  5122. $scope.hw_state.name = item.hw_state;
  5123. }
  5124. // $scope.consumptive = item;
  5125. $scope.stateshe = [
  5126. {
  5127. id: 2,
  5128. name: "在库",
  5129. },
  5130. {
  5131. id: 4,
  5132. name: "报修",
  5133. },
  5134. {
  5135. id: 3,
  5136. name: "报废",
  5137. },
  5138. ];
  5139. $scope.ok = function (item) {
  5140. $modalInstance.close($scope.hw_state);
  5141. };
  5142. $scope.cancel = function () {
  5143. $modalInstance.dismiss("cancel");
  5144. };
  5145. },
  5146. size: "sm",
  5147. });
  5148. modalInstance.result.then(function (selectedItem) {
  5149. angular.forEach($scope.myData1, function (items, index) {
  5150. if (items.id == item.id) {
  5151. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5152. }
  5153. });
  5154. $scope.model.assets = $scope.myData1;
  5155. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5156. $scope.model.assets;
  5157. });
  5158. };
  5159. $scope.onDblClick = function (data, event) {
  5160. $scope.selectButtonClick(data, event);
  5161. };
  5162. $scope.memoryfilterData = {
  5163. idx: 0,
  5164. sum: 10,
  5165. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5166. };
  5167. // $scope.myData = {};
  5168. $scope.loadData = function (filterData) {};
  5169. // $scope.title = title;
  5170. $scope.loadData({
  5171. idx: 0,
  5172. sum: 10,
  5173. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5174. });
  5175. $scope.selected = {
  5176. items: [],
  5177. };
  5178. $scope.myData2 = [];
  5179. $scope.consumptive = {};
  5180. $scope.myDataguibeiall = [];
  5181. $scope.haocaiopen = function (items) {
  5182. event.preventDefault();
  5183. var modalInstance = $modal.open({
  5184. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5185. controller: function (
  5186. $scope,
  5187. $modalInstance,
  5188. SweetAlert,
  5189. api_wechatfile,
  5190. api_sysinfo
  5191. ) {
  5192. $scope.consumptive = {};
  5193. $scope.title = "新增耗材";
  5194. if (items.name) {
  5195. $scope.consumptive.name = items.name.name;
  5196. }
  5197. $scope.ok = function (item) {
  5198. if (
  5199. item.name &&
  5200. item.model &&
  5201. JSON.stringify(item.model) != "{}" &&
  5202. item.Specifications &&
  5203. JSON.stringify(item.Specifications) != "{}" &&
  5204. item.sum
  5205. ) {
  5206. $modalInstance.close(item);
  5207. } else {
  5208. SweetAlert.swal({
  5209. title: "数据填写不完整!",
  5210. text: "请检查数据然后提交!",
  5211. type: "error",
  5212. });
  5213. }
  5214. };
  5215. $scope.cancel = function () {
  5216. $modalInstance.dismiss("cancel");
  5217. };
  5218. },
  5219. size: "sm",
  5220. });
  5221. modalInstance.result.then(function (selectedItem) {
  5222. api_sysinfo
  5223. .addData({
  5224. type: "list",
  5225. key: "haocaifenlei",
  5226. name: selectedItem.name,
  5227. parent: selectedItem.id,
  5228. value: "1",
  5229. })
  5230. .then(function (data) {
  5231. // $scope.haocainame.name = data.list;
  5232. api_wechatfile
  5233. .addDictionary({
  5234. type: "list",
  5235. key: "pinpai",
  5236. name: selectedItem.model,
  5237. parent: data.id,
  5238. value: "1",
  5239. })
  5240. .then(function (data) {
  5241. // $scope.haocainame = data.list;
  5242. });
  5243. api_wechatfile
  5244. .addDictionary({
  5245. type: "list",
  5246. key: "guige",
  5247. name: selectedItem.Specifications,
  5248. parent: data.id,
  5249. value: "1",
  5250. })
  5251. .then(function (data) {
  5252. // $scope.haocainame = data.list;
  5253. });
  5254. });
  5255. $scope.myData2.push(selectedItem);
  5256. for (var i = 0; i < $scope.myData2.length; i++) {
  5257. $scope.myData2[i]["item"] =
  5258. i + 1 + $scope.memoryfilterData.idx * 10;
  5259. }
  5260. // $scope.model.applicationForm.consumables = $scope.myData2;
  5261. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5262. if (items.id == selectedItem.id) {
  5263. $scope.myDataguibeiall.splice(index, 1);
  5264. }
  5265. });
  5266. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5267. $scope.model.consumables = $scope.myDataguibeiall;
  5268. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5269. $scope.model.consumables;
  5270. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5271. });
  5272. };
  5273. //grid2
  5274. $scope.langs = i18nService.getAllLangs();
  5275. $scope.lang = "zh-cn";
  5276. i18nService.setCurrentLang($scope.lang);
  5277. $scope.gridOptions2 = {};
  5278. $scope.gridOptions2.data = "myData2";
  5279. $scope.gridOptions2.enableColumnResizing = true;
  5280. $scope.gridOptions2.enableFiltering = false;
  5281. $scope.gridOptions2.enableGridMenu = false;
  5282. $scope.gridOptions2.showGridFooter = true;
  5283. $scope.gridOptions2.showColumnFooter = false;
  5284. $scope.gridOptions2.fastWatch = true;
  5285. $scope.gridOptions2.useExternalFiltering = true;
  5286. $scope.gridOptions2.useExternalPagination = true;
  5287. $scope.gridOptions2.paginationPageSizes = [10];
  5288. $scope.gridOptions2.paginationPageSize = 10;
  5289. $scope.gridOptions2.multiSelect = false;
  5290. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5291. $scope.modelcons = {};
  5292. $scope.modelass = {};
  5293. $scope.myData2all = [];
  5294. $scope.myData1all = [];
  5295. $scope.memoryfilterDatagui = {
  5296. idx: 0,
  5297. sum: 10,
  5298. };
  5299. setInterval(function () {
  5300. if ($scope.model.assets) {
  5301. if (
  5302. $scope.model.assets != $scope.modelass &&
  5303. typeof $scope.model.assets == "string"
  5304. ) {
  5305. $scope.modelass = $scope.model.assets;
  5306. if (JSON.stringify($scope.model.assets) == "{}") {
  5307. $scope.model.assets = [];
  5308. } else {
  5309. $scope.model.assets = JSON.parse($scope.model.assets);
  5310. }
  5311. // $scope.myData1 = $scope.model.assets;
  5312. // for (var i = 0; i < $scope.myData1.length; i++) {
  5313. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5314. // }
  5315. $scope.myData1all = $scope.model.assets;
  5316. for (var i = 0; i < $scope.myData1all.length; i++) {
  5317. $scope.myData1all[i]["item"] =
  5318. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5319. }
  5320. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5321. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5322. }
  5323. }
  5324. if ($scope.model.consumables) {
  5325. if (
  5326. $scope.model.consumables != $scope.modelcons &&
  5327. typeof $scope.model.consumables == "string"
  5328. ) {
  5329. $scope.modelass = $scope.model.consumables;
  5330. if (JSON.stringify($scope.model.consumables) == "{}") {
  5331. $scope.model.consumables = [];
  5332. } else {
  5333. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5334. }
  5335. // $scope.myData2 = $scope.model.consumables;
  5336. // for (var i = 0; i < $scope.myData2.length; i++) {
  5337. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5338. // }
  5339. $scope.myData2all = $scope.model.consumables;
  5340. for (var i = 0; i < $scope.myData2all.length; i++) {
  5341. $scope.myData2all[i]["item"] =
  5342. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5343. }
  5344. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5345. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5346. // $scope.model.consumables = $scope.myData2all;
  5347. }
  5348. }
  5349. }, 100);
  5350. $scope.gridOptions2.columnDefs = [
  5351. {
  5352. name: "item",
  5353. displayName: "序号",
  5354. width: 120,
  5355. },
  5356. {
  5357. name: "name",
  5358. displayName: "耗材名称",
  5359. width: 180,
  5360. enableFiltering: false,
  5361. },
  5362. {
  5363. name: "model",
  5364. displayName: "品牌/型号",
  5365. width: 180,
  5366. enableFiltering: false,
  5367. },
  5368. {
  5369. name: "Specifications",
  5370. displayName: "规格",
  5371. width: 150,
  5372. enableFiltering: false,
  5373. },
  5374. {
  5375. name: "sum",
  5376. width: 150,
  5377. displayName: "数量",
  5378. enableFiltering: false,
  5379. },
  5380. {
  5381. name: "操作",
  5382. cellTemplate:
  5383. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5384. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5385. "</div></div>",
  5386. enableFiltering: false,
  5387. },
  5388. ];
  5389. // $scope.selectButtonClick
  5390. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5391. $scope.gridApi = gridApi;
  5392. gridApi.pagination.on.paginationChanged(
  5393. $scope,
  5394. function (newPage, pageSize) {
  5395. // var filtersData = $scope.memoryfilterDatagui;
  5396. // filtersData.idx = newPage - 1;
  5397. // filtersData.sum = pageSize;
  5398. $scope.memoryfilterDatagui.idx = newPage - 1;
  5399. $scope.memoryfilterDatagui.sum = pageSize;
  5400. $scope.myData2 = $scope.interceptMydata(
  5401. $scope.myData2all,
  5402. $scope.memoryfilterDatagui.idx,
  5403. 10
  5404. );
  5405. }
  5406. );
  5407. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5408. $scope.selected.items = data.entity;
  5409. //console.log(data);
  5410. });
  5411. gridApi.selection.on.rowSelectionChangedBatch(
  5412. $scope,
  5413. function (data) {
  5414. $scope.selected.items = data.entity;
  5415. //console.log(data);
  5416. }
  5417. );
  5418. gridApi.core.on.filterChanged($scope, function () {
  5419. var grid = this.grid;
  5420. var filtersData = {
  5421. idx: 0,
  5422. sum: 10,
  5423. };
  5424. angular.forEach(grid.columns, function (item) {
  5425. if (item.enableFiltering) {
  5426. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5427. if (
  5428. angular.isDefined(item.filters[0].term) &&
  5429. item.filters[0].term != ""
  5430. ) {
  5431. if (angular.isUndefined(filtersData["user"])) {
  5432. filtersData["user"] = {};
  5433. }
  5434. filtersData["user"][item.field] = item.filters[0].term;
  5435. }
  5436. }
  5437. });
  5438. $scope.memoryfilterData = filtersData;
  5439. $scope.loadData(filtersData);
  5440. });
  5441. };
  5442. $scope.changecai = function (item) {
  5443. event.preventDefault();
  5444. var modalInstance = $modal.open({
  5445. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5446. controller: function ($scope, $modalInstance) {
  5447. $scope.title = "修改耗材数量";
  5448. $scope.consumptive = angular.copy(item);
  5449. // $scope.consumptive = item;
  5450. $scope.maxsum = item.inventoryNum;
  5451. $scope.clearNoNum = function (obj, attr) {
  5452. //先把非数字的都替换掉,除了数字和.
  5453. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5454. //必须保证第一个为数字而不是.
  5455. obj[attr] = obj[attr].replace(/^\./g, "");
  5456. //保证只有出现一个.而没有多个.
  5457. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5458. //保证.只出现一次,而不能出现两次以上
  5459. obj[attr] = obj[attr]
  5460. .replace(".", "$#$")
  5461. .replace(/\./g, "")
  5462. .replace("$#$", ".");
  5463. //小于最大值
  5464. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5465. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5466. // obj[attr] = '';
  5467. // }
  5468. };
  5469. $scope.ok = function () {
  5470. $modalInstance.close($scope.consumptive);
  5471. };
  5472. $scope.cancel = function () {
  5473. $modalInstance.dismiss("cancel");
  5474. };
  5475. },
  5476. size: "sm",
  5477. });
  5478. modalInstance.result.then(function (selectedItem) {
  5479. angular.forEach($scope.myData2all, function (items, index) {
  5480. // if (items.id == selectedItem.id) {
  5481. if (
  5482. items.modelid == selectedItem.modelid &&
  5483. items.nameid == selectedItem.nameid &&
  5484. items.Specificationsid == selectedItem.Specificationsid
  5485. ) {
  5486. angular.extend($scope.myData2all[index], selectedItem);
  5487. }
  5488. });
  5489. // $scope.model.consumables = $scope.myData2;
  5490. // $scope.myData2 = $scope.model.consumables;
  5491. // $scope.myData2all.push(selectedItem);
  5492. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5493. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5494. // }
  5495. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5496. $scope.myData2 = $scope.interceptMydata(
  5497. $scope.myData2all,
  5498. $scope.memoryfilterDatagui.idx,
  5499. 10
  5500. );
  5501. $scope.model.consumables = $scope.myData2all;
  5502. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5503. $scope.model.consumables;
  5504. });
  5505. };
  5506. $scope.interceptMydata = function (mydate, idx, sum) {
  5507. return mydate.slice(idx * sum, (idx + 1) * sum);
  5508. };
  5509. $scope.haocaiadd = function () {
  5510. event.preventDefault();
  5511. var modalInstance = $modal.open({
  5512. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5513. controller: function (
  5514. $scope,
  5515. scope,
  5516. $modalInstance,
  5517. api_wechatfile,
  5518. SweetAlert
  5519. ) {
  5520. $scope.haocainame = [];
  5521. $scope.pinpai = [];
  5522. $scope.guige = [];
  5523. $scope.consumptive = {};
  5524. $scope.consumptiveall = {};
  5525. $scope.title = "添加耗材";
  5526. api_wechatfile
  5527. .getDictionaryForList({
  5528. key: "haocaifenlei",
  5529. })
  5530. .then(function (data) {
  5531. $scope.haocainame = data;
  5532. });
  5533. $scope.clearNoNum = function (obj, attr) {
  5534. //先把非数字的都替换掉,除了数字和.
  5535. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5536. //必须保证第一个为数字而不是.
  5537. obj[attr] = obj[attr].replace(/^\./g, "");
  5538. //保证只有出现一个.而没有多个.
  5539. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5540. //保证.只出现一次,而不能出现两次以上
  5541. obj[attr] = obj[attr]
  5542. .replace(".", "$#$")
  5543. .replace(/\./g, "")
  5544. .replace("$#$", ".");
  5545. //小于最大值
  5546. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5547. alert(
  5548. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5549. );
  5550. obj[attr] = "";
  5551. }
  5552. };
  5553. $scope.onChange = function (parent) {
  5554. $scope.consumptive.model = {};
  5555. $scope.consumptive.Specifications = {};
  5556. api_wechatfile
  5557. .getDictionaryForList({
  5558. key: "pinpai",
  5559. parent: parent.id,
  5560. })
  5561. .then(function (data) {
  5562. $scope.pinpai = data;
  5563. });
  5564. api_wechatfile
  5565. .getDictionaryForList({
  5566. key: "guige",
  5567. parent: parent.id,
  5568. })
  5569. .then(function (data) {
  5570. $scope.guige = data;
  5571. });
  5572. };
  5573. // $scope.onChangesum = function(item) {
  5574. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5575. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5576. // $scope.consumptiveall = data1;
  5577. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5578. // // if (data.list && data.list.length != 0) {
  5579. // // var myData = data.list;
  5580. // // $scope.consumptiveall = myData[0];
  5581. // // $scope.maxsum = myData[0].inventoryNum;
  5582. // // } else if (data.list && data.list.length == 0) {
  5583. // // SweetAlert.swal({
  5584. // // title: "库存数据存在问题!",
  5585. // // text: "请检查库存数据!",
  5586. // // type: "error"
  5587. // // });
  5588. // // }
  5589. // // });
  5590. // }
  5591. // }
  5592. $scope.addhaocai = function () {
  5593. $modalInstance.dismiss("cancel");
  5594. scope.haocaiopen($scope.consumptive);
  5595. };
  5596. $scope.ok = function (item) {
  5597. var submittrue = true;
  5598. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5599. var data = {
  5600. modelid: item.model.id,
  5601. nameid: item.name.id,
  5602. Specificationsid: item.Specifications.id,
  5603. name: item.name.name,
  5604. model: item.model.name,
  5605. Specifications: item.Specifications.name,
  5606. sum: item.sum,
  5607. };
  5608. if (
  5609. item.name &&
  5610. item.model &&
  5611. JSON.stringify(item.model) != "{}" &&
  5612. item.Specifications &&
  5613. JSON.stringify(item.Specifications) != "{}" &&
  5614. item.sum
  5615. ) {
  5616. // $modalInstance.close(data);
  5617. angular.forEach(scope.myData2all, function (itemsdata) {
  5618. // if (item.model.id == itemsdata.id) {
  5619. if (
  5620. item.model.id == itemsdata.modelid &&
  5621. item.name.id == itemsdata.nameid &&
  5622. item.Specifications.id == itemsdata.Specificationsid
  5623. ) {
  5624. submittrue = false;
  5625. }
  5626. });
  5627. if (submittrue) {
  5628. $modalInstance.close(data);
  5629. } else {
  5630. SweetAlert.swal({
  5631. title: "该耗材已有添加",
  5632. text: "请检查数据然后提交!",
  5633. type: "error",
  5634. });
  5635. }
  5636. } else {
  5637. SweetAlert.swal({
  5638. title: "数据填写不完整!",
  5639. text: "请检查数据然后提交!",
  5640. type: "error",
  5641. });
  5642. }
  5643. };
  5644. $scope.cancel = function () {
  5645. $modalInstance.dismiss("cancel");
  5646. };
  5647. },
  5648. size: "sm",
  5649. resolve: {
  5650. scope: function () {
  5651. return $scope;
  5652. },
  5653. },
  5654. });
  5655. modalInstance.result.then(function (selectedItem) {
  5656. // $scope.myData2.push(selectedItem);
  5657. // for (var i = 0; i < $scope.myData2.length; i++) {
  5658. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5659. // }
  5660. // $scope.model.consumables = $scope.myData2;
  5661. $scope.myData2all.push(selectedItem);
  5662. for (var i = 0; i < $scope.myData2all.length; i++) {
  5663. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5664. $scope.myData2all[i]["item"] = i + 1;
  5665. }
  5666. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5667. $scope.myData2 = $scope.interceptMydata(
  5668. $scope.myData2all,
  5669. $scope.memoryfilterDatagui.idx,
  5670. 10
  5671. );
  5672. $scope.model.consumables = $scope.myData2all;
  5673. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5674. $scope.model.consumables;
  5675. });
  5676. };
  5677. $scope.onDblClick = function (data, event) {
  5678. $scope.selectButtonClick(data, event);
  5679. };
  5680. $scope.memoryfilterData = {
  5681. idx: 0,
  5682. sum: 20,
  5683. user: {
  5684. roledata: {
  5685. rolecode: "roleset",
  5686. },
  5687. selectType: "1",
  5688. },
  5689. };
  5690. $scope.myData = {};
  5691. $scope.loadData = function (filterData) {};
  5692. // $scope.title = title;
  5693. $scope.loadData({
  5694. idx: 0,
  5695. sum: 20,
  5696. user: {
  5697. roledata: {
  5698. rolecode: "roleset",
  5699. },
  5700. selectType: "1",
  5701. },
  5702. });
  5703. $scope.selected = {
  5704. items: {},
  5705. };
  5706. },
  5707. ],
  5708. });
  5709. //tab 列表
  5710. formlyConfigProvider.setType({
  5711. name: "ui-cmdbtab",
  5712. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5713. wrapper: ["bootstrapHasError"],
  5714. defaultOptions: function (options, $scope) {
  5715. return {
  5716. templateOptions: {},
  5717. };
  5718. },
  5719. controller: [
  5720. "$scope",
  5721. "api_user_data",
  5722. "i18nService",
  5723. "$modal",
  5724. "api_cmdb",
  5725. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5726. $scope.memoryfilterDatashe = {
  5727. idx: 0,
  5728. sum: 10,
  5729. };
  5730. $scope.myDataoneall = [];
  5731. var setAllInactive = function () {
  5732. angular.forEach($scope.workspaces, function (workspace) {
  5733. workspace.active = false;
  5734. });
  5735. };
  5736. //添加
  5737. var addNewWorkspace = function (name, contentUrl) {
  5738. var id = $scope.workspaces.length + 1;
  5739. $scope.workspaces.push({
  5740. id: id,
  5741. name: name,
  5742. active: true,
  5743. contentUrl: "main/html/content.html",
  5744. });
  5745. };
  5746. //关闭
  5747. $scope.remove = function (closedata) {
  5748. event.preventDefault();
  5749. angular.forEach($scope.workspaces, function (item, index) {
  5750. if (closedata.id == item.id) {
  5751. if (closedata.id == 1) {
  5752. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5753. } else {
  5754. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5755. }
  5756. $scope.workspaces.splice(index, 1);
  5757. }
  5758. });
  5759. };
  5760. $scope.workspaces = [];
  5761. $scope.options.templateOptions.getpush = function (item) {
  5762. $scope.workspaces = [];
  5763. if (item.gu) {
  5764. $scope.workspaces.push({
  5765. id: 1,
  5766. name: "领用设备",
  5767. active: true,
  5768. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5769. });
  5770. }
  5771. if (item.hao) {
  5772. $scope.workspaces.push({
  5773. id: 2,
  5774. name: "领用耗材",
  5775. active: true,
  5776. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5777. });
  5778. }
  5779. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5780. };
  5781. $scope.addWorkspace = function (contentUrl, name) {
  5782. setAllInactive();
  5783. addNewWorkspace(name, contentUrl);
  5784. };
  5785. // $rootScope.addWorkspace = $scope.addWorkspace;
  5786. // $scope.remove = function(idNumber) {
  5787. // var index = 0; //记录当前元素下标
  5788. // angular.forEach($scope.workspaces, function(workspace) {
  5789. // if (workspace.id === idNumber.id) {
  5790. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5791. // }
  5792. // index++;
  5793. // });
  5794. // };
  5795. // setInterval(function() {
  5796. // if ($scope.model.assets) {
  5797. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5798. // $scope.modelass = $scope.model.assets;
  5799. // if (JSON.stringify($scope.model.assets) == "{}") {
  5800. // $scope.model.assets = []
  5801. // } else {
  5802. // $scope.model.assets = JSON.parse($scope.model.assets);
  5803. // }
  5804. // $scope.myDatalingbeiall = $scope.model.assets;
  5805. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5806. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5807. // }
  5808. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5809. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5810. // }
  5811. // }
  5812. // if ($scope.model.consumables) {
  5813. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5814. // $scope.modelass = $scope.model.consumables;
  5815. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5816. // $scope.model.consumables = [];
  5817. // } else {
  5818. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5819. // }
  5820. // $scope.myDatalingbeiall = $scope.model.consumables;
  5821. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5822. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5823. // }
  5824. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5825. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5826. // // $scope.model.consumables = $scope.myData2all;
  5827. // }
  5828. // }
  5829. // }, 100);
  5830. //grid1
  5831. $scope.langs = i18nService.getAllLangs();
  5832. $scope.lang = "zh-cn";
  5833. i18nService.setCurrentLang($scope.lang);
  5834. $scope.gridOptions1 = {};
  5835. $scope.gridOptions1.data = "myDatalingbei";
  5836. $scope.gridOptions1.enableColumnResizing = true;
  5837. $scope.gridOptions1.enableFiltering = false;
  5838. $scope.gridOptions1.enableGridMenu = false;
  5839. $scope.gridOptions1.showGridFooter = true;
  5840. $scope.gridOptions1.showColumnFooter = false;
  5841. $scope.gridOptions1.fastWatch = true;
  5842. $scope.gridOptions1.useExternalFiltering = true;
  5843. $scope.gridOptions1.useExternalPagination = true;
  5844. $scope.gridOptions1.paginationPageSizes = [10];
  5845. $scope.gridOptions1.paginationPageSize = 10;
  5846. $scope.gridOptions1.multiSelect = false;
  5847. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5848. $scope.gridOptions1.columnDefs = [
  5849. {
  5850. name: "item",
  5851. displayName: "序号",
  5852. width: 120,
  5853. },
  5854. {
  5855. name: "props.hw_cifilterClassic",
  5856. displayName: "设备类型",
  5857. width: 150,
  5858. enableFiltering: false,
  5859. },
  5860. {
  5861. name: "props.hw_mingcheng",
  5862. displayName: "设备名称",
  5863. width: 100,
  5864. enableFiltering: false,
  5865. },
  5866. {
  5867. name: "uuid",
  5868. displayName: "设备编号",
  5869. enableFiltering: false,
  5870. },
  5871. ];
  5872. $scope.myDatalingbeiall = [];
  5873. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5874. $scope.gridApi = gridApi;
  5875. gridApi.pagination.on.paginationChanged(
  5876. $scope,
  5877. function (newPage, pageSize) {
  5878. // var filtersData = $scope.memoryfilterData;
  5879. // filtersData.idx = newPage - 1;
  5880. // filtersData.sum = pageSize;
  5881. // $scope.loadData(filtersData);
  5882. $scope.memoryfilterDatashe.idx = newPage - 1;
  5883. $scope.memoryfilterDatashe.sum = pageSize;
  5884. $scope.myDatalingbei = $scope.interceptMydata(
  5885. $scope.myDatalingbeiall,
  5886. $scope.memoryfilterDatashe.idx,
  5887. 10
  5888. );
  5889. }
  5890. );
  5891. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5892. $scope.selected.items = data.entity;
  5893. //console.log(data);
  5894. });
  5895. gridApi.selection.on.rowSelectionChangedBatch(
  5896. $scope,
  5897. function (data) {
  5898. $scope.selected.items = data.entity;
  5899. //console.log(data);
  5900. }
  5901. );
  5902. gridApi.core.on.filterChanged($scope, function () {
  5903. var grid = this.grid;
  5904. var filtersData = {
  5905. idx: 0,
  5906. sum: 20,
  5907. user: {
  5908. roledata: {
  5909. rolecode: "roleset",
  5910. },
  5911. selectType: "1",
  5912. },
  5913. };
  5914. angular.forEach(grid.columns, function (item) {
  5915. if (item.enableFiltering) {
  5916. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5917. if (
  5918. angular.isDefined(item.filters[0].term) &&
  5919. item.filters[0].term != ""
  5920. ) {
  5921. if (angular.isUndefined(filtersData["user"])) {
  5922. filtersData["user"] = {};
  5923. }
  5924. filtersData["user"][item.field] = item.filters[0].term;
  5925. }
  5926. }
  5927. });
  5928. $scope.memoryfilterDatashe = filtersData;
  5929. // $scope.loadData(filtersData);
  5930. });
  5931. };
  5932. $scope.interceptMydata = function (mydate, idx, sum) {
  5933. return mydate.slice(idx * sum, (idx + 1) * sum);
  5934. };
  5935. $scope.removeshebei = function (item) {
  5936. event.preventDefault();
  5937. var modalInstance = $modal.open({
  5938. templateUrl: "assets/views/delete.html",
  5939. controller: function ($scope, $modalInstance, scope) {
  5940. $scope.title = "设备移除";
  5941. $scope.connect = "确定要移除此设备?";
  5942. $scope.consumptive = scope.selected.items;
  5943. $scope.ok = function () {
  5944. $modalInstance.close($scope.consumptive);
  5945. };
  5946. $scope.cancel = function () {
  5947. $modalInstance.dismiss("cancel");
  5948. };
  5949. },
  5950. size: "sm",
  5951. resolve: {
  5952. scope: function () {
  5953. return $scope;
  5954. },
  5955. },
  5956. });
  5957. modalInstance.result.then(function (selectedItem) {
  5958. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5959. if (items.id == selectedItem.id) {
  5960. $scope.myDatalingbeiall.splice(index, 1);
  5961. }
  5962. });
  5963. // $scope.myData3.push(selectedItem);
  5964. $scope.model.consumables = $scope.myDatalingbeiall;
  5965. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5966. $scope.myDatalingbeiall;
  5967. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5968. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5969. $scope.myDatalingbeiall[i]["item"] =
  5970. i +
  5971. 1 +
  5972. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5973. }
  5974. $scope.myDatalingbei = $scope.interceptMydata(
  5975. $scope.myDatalingbeiall,
  5976. 0,
  5977. 10
  5978. );
  5979. });
  5980. };
  5981. $scope.addshebei = function () {
  5982. event.preventDefault();
  5983. var modalInstance = $modal.open({
  5984. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5985. controller: function (
  5986. $scope,
  5987. i18nService,
  5988. $modalInstance,
  5989. items,
  5990. title,
  5991. Restangular,
  5992. APIService,
  5993. onDataCallback,
  5994. parentScope,
  5995. api_configure_data,
  5996. api_configure_form
  5997. ) {
  5998. $scope.langs = i18nService.getAllLangs();
  5999. $scope.lang = "zh-cn";
  6000. i18nService.setCurrentLang($scope.lang);
  6001. $scope.gridOptions = {};
  6002. $scope.gridOptions.data = "myDatatwo";
  6003. $scope.gridOptions.enableColumnResizing = true;
  6004. $scope.gridOptions.enableFiltering = false;
  6005. $scope.gridOptions.enableGridMenu = false;
  6006. $scope.gridOptions.showGridFooter = true;
  6007. $scope.gridOptions.showColumnFooter = false;
  6008. $scope.gridOptions.fastWatch = true;
  6009. $scope.gridOptions.useExternalFiltering = true;
  6010. $scope.gridOptions.useExternalPagination = true;
  6011. $scope.gridOptions.paginationPageSizes = [10];
  6012. $scope.gridOptions.paginationPageSize = 10;
  6013. $scope.gridOptions.multiSelect = true;
  6014. $scope.gridOptions.rowIdentity = function (row) {
  6015. return row.id;
  6016. };
  6017. $scope.gridOptions.getRowIdentity = function (row) {
  6018. return row.id;
  6019. };
  6020. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6021. $scope.gridOptions.columnDefs = [
  6022. {
  6023. name: "item",
  6024. displayName: "序号",
  6025. width: 80,
  6026. enableFiltering: false,
  6027. },
  6028. {
  6029. name: "uuid",
  6030. displayName: "内部编号",
  6031. width: 175,
  6032. },
  6033. {
  6034. name: "props.hw_mingcheng",
  6035. displayName: "资产名称",
  6036. width: 120,
  6037. },
  6038. {
  6039. name: "props.hw_cifilterClassic",
  6040. displayName: "资产类型",
  6041. width: 80,
  6042. enableFiltering: false,
  6043. },
  6044. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6045. {
  6046. name: "props.hw_state",
  6047. displayName: "资产状态",
  6048. width: 150,
  6049. enableFiltering: false,
  6050. },
  6051. {
  6052. name: "props.hwnw_area",
  6053. displayName: "资产地点",
  6054. width: 130,
  6055. enableFiltering: false,
  6056. },
  6057. {
  6058. name: "createtime",
  6059. displayName: "申请时间",
  6060. enableFiltering: false,
  6061. },
  6062. ];
  6063. // $scope.selectButtonClick
  6064. var defaultFilterData = {
  6065. // "assignee":2,
  6066. // "sign":"basehwitndl",
  6067. // "applicationForm": { "hw_state": "在线" },
  6068. hw_state: "在库",
  6069. idx: 0,
  6070. sum: 10,
  6071. };
  6072. $scope.memoryfilterData = {
  6073. // "assignee":2,
  6074. // "sign":"basehwitndl",
  6075. // "applicationForm": { "hw_state": "在线" },
  6076. hw_state: "在库",
  6077. idx: 0,
  6078. sum: 10,
  6079. };
  6080. $scope.refreshData = function (style, filterData) {
  6081. if (angular.isUndefined(filterData)) {
  6082. filterData = defaultFilterData;
  6083. }
  6084. $scope.myDatatwo = [];
  6085. // $scope.gridOptions['sum']=filterData.sum;
  6086. api_cmdb.query(filterData).then(
  6087. function (data) {
  6088. // $scope.callsPending--;
  6089. var filterData = $scope.memoryfilterData;
  6090. var myDatatwo = Restangular.stripRestangular(data);
  6091. $scope.gridOptions["totalItems"] = data.total;
  6092. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6093. myDatatwo.data.node[i].createtime = moment(
  6094. myDatatwo.data.node[i].createtime
  6095. ).format("YYYY-MM-DD");
  6096. }
  6097. $scope.myDatatwo = myDatatwo.data.node;
  6098. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6099. $scope.myDatatwo[i]["item"] =
  6100. i + 1 + filterData.idx * filterData.sum;
  6101. }
  6102. },
  6103. function () {}
  6104. );
  6105. };
  6106. $scope.refreshData("expand-right", defaultFilterData);
  6107. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6108. $scope.gridApi = gridApi;
  6109. gridApi.pagination.on.paginationChanged(
  6110. $scope,
  6111. function (newPage, pageSize) {
  6112. var filtersData = $scope.memoryfilterData;
  6113. filtersData.idx = newPage - 1;
  6114. filtersData.sum = pageSize;
  6115. // $scope.loadData(filtersData);
  6116. $scope.refreshData("expand-right", filtersData);
  6117. //console.log(pageSize);
  6118. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6119. }
  6120. );
  6121. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6122. // $scope.selected.items.push(data.entity);
  6123. //console.log(data);
  6124. gridApi.selection.on.rowSelectionChanged(
  6125. $scope,
  6126. function (scope, ect) {
  6127. if (scope.isSelected) {
  6128. scope.grid.appScope.selected.items.push(scope.entity);
  6129. } else {
  6130. for (
  6131. var i = 0;
  6132. i <= scope.grid.appScope.selected.items.length;
  6133. i++
  6134. ) {
  6135. if (
  6136. scope.grid.appScope.selected.items[i].id ==
  6137. scope.entity.id
  6138. ) {
  6139. scope.grid.appScope.selected.items.splice(i, 1);
  6140. break;
  6141. }
  6142. }
  6143. }
  6144. $scope.mySelectedRows =
  6145. $scope.gridApi.selection.getSelectedRows();
  6146. }
  6147. );
  6148. // });
  6149. gridApi.selection.on.rowSelectionChangedBatch(
  6150. $scope,
  6151. function (rows) {
  6152. // $scope.selected.items = data.entity;
  6153. //console.log(data);
  6154. var selectitem = [];
  6155. selectitem = angular.copy($scope.selected.items);
  6156. for (var j = 0; j < rows.length; j++) {
  6157. if (rows[j].isSelected == true) {
  6158. selectitem.push(rows[j].entity);
  6159. } else {
  6160. delete selectitem[j];
  6161. // rows.splice(j, 1);
  6162. }
  6163. }
  6164. $scope.selected.items = [];
  6165. for (var i = 0; i < selectitem.length; i++) {
  6166. if (selectitem[i]) {
  6167. $scope.selected.items.push(selectitem[i]);
  6168. }
  6169. }
  6170. }
  6171. );
  6172. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6173. // // if (row.entity.age > 45) {
  6174. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6175. // // }
  6176. // };
  6177. gridApi.core.on.filterChanged($scope, function () {
  6178. var grid = this.grid;
  6179. var filtersData = {
  6180. idx: 0,
  6181. sum: 10,
  6182. user: {
  6183. roledata: {
  6184. rolecode: "roleset",
  6185. },
  6186. selectType: "1",
  6187. },
  6188. };
  6189. angular.forEach(grid.columns, function (item) {
  6190. if (item.enableFiltering) {
  6191. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6192. if (
  6193. angular.isDefined(item.filters[0].term) &&
  6194. item.filters[0].term != ""
  6195. ) {
  6196. if (angular.isUndefined(filtersData["user"])) {
  6197. filtersData["user"] = {};
  6198. }
  6199. filtersData["user"][item.field] = item.filters[0].term;
  6200. }
  6201. }
  6202. });
  6203. $scope.memoryfilterData = filtersData;
  6204. // $scope.loadData(filtersData);
  6205. });
  6206. };
  6207. $scope.onDblClick = function (data, event) {
  6208. // $scope.selected.items = data.entity;
  6209. $scope.selectButtonClick(data, event);
  6210. };
  6211. // $scope.loadData = function(filterData) {
  6212. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6213. // items.fetchItems(filterData, APIService).then(function(data) {
  6214. // var myDatatwo = Restangular.stripRestangular(data);
  6215. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6216. // $scope.myDatatwo = myDatatwo.list;
  6217. // });
  6218. // };
  6219. $scope.title = title;
  6220. //树形图
  6221. var apple_selected, tree, treedata_avm, treedata_geography;
  6222. $scope.my_tree_handler = function (branch) {
  6223. //var _ref;
  6224. var classify = ($scope.classify =
  6225. branch.prefix.toLowerCase() + branch.sign);
  6226. api_cmdb
  6227. .query({
  6228. sign: classify,
  6229. })
  6230. .then(function (data) {
  6231. var myDatalingbei = Restangular.stripRestangular(data);
  6232. // console.log(myData.data.node);
  6233. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6234. var ret = myDatalingbei.data;
  6235. redrawSvg(myDatalingbei);
  6236. }
  6237. });
  6238. };
  6239. $scope.my_data = [];
  6240. function convertListToTree(data, treeMap) {
  6241. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6242. var root = null; //Initially set our loop to null
  6243. var parentNode = null;
  6244. //loop over data
  6245. for (var i = 0; i < data.length; i++) {
  6246. var datum = data[i];
  6247. //each node will have children, so let's give it a "children" poperty
  6248. datum.children = [];
  6249. //add an entry for this node to the map so that any future children can
  6250. //lookup the parent
  6251. idToNodeMap[datum.id] = datum;
  6252. //Does this node have a parent?
  6253. if (
  6254. typeof datum.parent === "undefined" ||
  6255. datum.parent == null
  6256. ) {
  6257. //Doesn't look like it, so this node is the root of the tree
  6258. root = datum;
  6259. treeMap[datum.id] = root;
  6260. } else {
  6261. //This node has a parent, so let's look it up using the id
  6262. parentNode = idToNodeMap[datum.parent.id];
  6263. //We don't need this property, so let's delete it.
  6264. delete datum.parent;
  6265. //Let's add the current node as a child of the parent node.
  6266. parentNode.children.push(datum);
  6267. }
  6268. }
  6269. return root;
  6270. }
  6271. function convertParentToChildList(data) {
  6272. var treeMap = {};
  6273. var list = [];
  6274. convertListToTree(data, treeMap);
  6275. angular.forEach(treeMap, function (item) {
  6276. list.push(item);
  6277. });
  6278. return list;
  6279. }
  6280. $scope.my_tree = tree = {};
  6281. $scope.try_async_load = function () {
  6282. $scope.my_data = [];
  6283. $scope.select_treedata = [];
  6284. $scope.doing_async = true;
  6285. api_configure_data
  6286. .fetchDataList("ciclassify", {
  6287. idx: 0,
  6288. sum: 100,
  6289. })
  6290. .then(function (result) {
  6291. //console.log(result['list']);
  6292. $scope.select_treedata = $scope.my_data =
  6293. convertParentToChildList(result["list"]);
  6294. $scope.doing_async = false;
  6295. // tree.expand_all();
  6296. //console.log(treelist);
  6297. });
  6298. };
  6299. $scope.select_treedata = [];
  6300. $scope.propTypeOptions = [];
  6301. $scope.try_async_load();
  6302. $scope.onFilterremove = function (item) {
  6303. console.log(item);
  6304. };
  6305. $scope.searchdata = {};
  6306. $scope.clear = function () {
  6307. $scope.searchdata = {};
  6308. $scope.cifilter_classic = {};
  6309. $scope.try_async_load();
  6310. var fildata = {
  6311. idx: 0,
  6312. sum: 10,
  6313. hw_state: "在库",
  6314. };
  6315. $scope.memoryfilterData = fildata;
  6316. $scope.refreshData("expand-right", fildata);
  6317. };
  6318. $scope.cifilter_classic = {};
  6319. $scope.chiceIncident = function (item) {
  6320. var fildata = defaultFilterData;
  6321. // fildata.applicationForm = {};
  6322. // sign: basehwnwswt
  6323. if (item && item.id) {
  6324. var classify = item.prefix.toLowerCase() + item.sign;
  6325. fildata.sign = classify;
  6326. } else {
  6327. delete fildata.sign;
  6328. }
  6329. $scope.gridOptions.paginationCurrentPage = 1;
  6330. var transitiondata = angular.copy(item);
  6331. $scope.refreshData("expand-right", fildata);
  6332. };
  6333. $scope.applicadata = [];
  6334. $scope.onFilterCallback = function (item) {
  6335. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6336. api_configure_form
  6337. .renderTabForm(tempclassify)
  6338. .then(function (data) {
  6339. var myData = Restangular.stripRestangular(data);
  6340. $scope.applicadata = myData[0].form.fields;
  6341. });
  6342. // }
  6343. };
  6344. // $scope.loadData({
  6345. // idx: 0,
  6346. // sum: 10,
  6347. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6348. // });
  6349. $scope.selected = {
  6350. items: [],
  6351. };
  6352. $scope.ok = function () {
  6353. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6354. // onDataCallback($scope.selected.item, parentScope);
  6355. // }
  6356. $modalInstance.close($scope.selected.items);
  6357. };
  6358. $scope.cancel = function () {
  6359. $modalInstance.dismiss("cancel");
  6360. };
  6361. },
  6362. size: "lg",
  6363. resolve: {
  6364. items: function () {
  6365. return {
  6366. fetchItems: function (filterData, APIService) {
  6367. filterData = filterData || {};
  6368. if (
  6369. angular.isDefined(filterData.idx) &&
  6370. filterData.idx == null
  6371. ) {
  6372. filterData = {
  6373. idx: 0,
  6374. sum: 10,
  6375. user: {
  6376. roledata: {
  6377. rolecode: "roleset",
  6378. },
  6379. selectType: "1",
  6380. },
  6381. };
  6382. }
  6383. return $scope.options.templateOptions.fetchItems(
  6384. filterData,
  6385. APIService
  6386. );
  6387. },
  6388. };
  6389. },
  6390. title: function () {
  6391. return $scope.options.templateOptions.label;
  6392. },
  6393. Restangular: function () {
  6394. return $scope.options.templateOptions.Restangular;
  6395. },
  6396. APIService: function () {
  6397. return $scope.options.templateOptions.ApiService;
  6398. },
  6399. onDataCallback: function () {
  6400. return $scope.options.templateOptions.callback;
  6401. },
  6402. parentScope: function () {
  6403. return $scope.options.templateOptions.that;
  6404. },
  6405. },
  6406. });
  6407. modalInstance.result.then(
  6408. function (selectedItem) {
  6409. // console.log(selectedItem);
  6410. // options.value(selectedItem);
  6411. var filterData = $scope.memoryfilterDatashe;
  6412. $scope.myDatalingbeiall = selectedItem;
  6413. $scope.gridOptions1["totalItems"] =
  6414. $scope.myDatalingbeiall.length;
  6415. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6416. $scope.myDatalingbeiall[i]["item"] =
  6417. i + 1 + filterData.idx * filterData.sum;
  6418. }
  6419. $scope.myDatalingbei = $scope.interceptMydata(
  6420. $scope.myDatalingbeiall,
  6421. 0,
  6422. 10
  6423. );
  6424. $scope.model.assets = $scope.myDatalingbeiall;
  6425. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6426. $scope.myDatalingbeiall;
  6427. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6428. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6429. // }
  6430. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6431. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6432. // }
  6433. },
  6434. function () {
  6435. //console.log('Modal dismissed at: ' + new Date());
  6436. }
  6437. );
  6438. };
  6439. $scope.onDblClick = function (data, event) {
  6440. $scope.selectButtonClick(data, event);
  6441. };
  6442. // $scope.loadData = function(filterData) {};
  6443. // $scope.title = title;
  6444. // $scope.loadData({
  6445. // idx: 0,
  6446. // sum: 20,
  6447. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6448. // });
  6449. $scope.selected = {
  6450. items: [],
  6451. };
  6452. //grid2
  6453. $scope.langs = i18nService.getAllLangs();
  6454. $scope.lang = "zh-cn";
  6455. i18nService.setCurrentLang($scope.lang);
  6456. $scope.gridOptions2 = {};
  6457. $scope.gridOptions2.data = "myDataone";
  6458. $scope.gridOptions2.enableColumnResizing = true;
  6459. $scope.gridOptions2.enableFiltering = false;
  6460. $scope.gridOptions2.enableGridMenu = false;
  6461. $scope.gridOptions2.showGridFooter = true;
  6462. $scope.gridOptions2.showColumnFooter = false;
  6463. $scope.gridOptions2.fastWatch = true;
  6464. $scope.gridOptions2.useExternalFiltering = true;
  6465. $scope.gridOptions2.useExternalPagination = true;
  6466. $scope.gridOptions2.paginationPageSizes = [10];
  6467. $scope.gridOptions2.paginationPageSize = 10;
  6468. $scope.gridOptions2.multiSelect = false;
  6469. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6470. $scope.gridOptions2.columnDefs = [
  6471. {
  6472. name: "item",
  6473. displayName: "序号",
  6474. width: 120,
  6475. },
  6476. {
  6477. name: "name",
  6478. displayName: "耗材名称",
  6479. width: 150,
  6480. enableFiltering: false,
  6481. },
  6482. {
  6483. name: "model",
  6484. displayName: "品牌/型号",
  6485. width: 100,
  6486. enableFiltering: false,
  6487. },
  6488. {
  6489. name: "Specifications",
  6490. displayName: "规格",
  6491. width: 150,
  6492. enableFiltering: false,
  6493. },
  6494. {
  6495. name: "sum",
  6496. displayName: "领用数量",
  6497. enableFiltering: false,
  6498. },
  6499. ];
  6500. // $scope.selectButtonClick
  6501. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6502. $scope.gridApi = gridApi;
  6503. gridApi.pagination.on.paginationChanged(
  6504. $scope,
  6505. function (newPage, pageSize) {
  6506. // var filtersData = $scope.memoryfilterData;
  6507. // filtersData.idx = newPage - 1;
  6508. // filtersData.sum = pageSize;
  6509. // $scope.loadData(filtersData);
  6510. $scope.memoryfilterDatahao.idx = newPage - 1;
  6511. $scope.memoryfilterDatahao.sum = pageSize;
  6512. $scope.myDataone = $scope.interceptMydata(
  6513. $scope.myDataoneall,
  6514. $scope.memoryfilterDatahao.idx,
  6515. 10
  6516. );
  6517. }
  6518. );
  6519. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6520. $scope.selected.items.push(data.entity);
  6521. //console.log(data);
  6522. });
  6523. gridApi.selection.on.rowSelectionChangedBatch(
  6524. $scope,
  6525. function (data) {
  6526. $scope.selected.items.push(data.entity);
  6527. //console.log(data);
  6528. }
  6529. );
  6530. gridApi.core.on.filterChanged($scope, function () {
  6531. var grid = this.grid;
  6532. var filtersData = {
  6533. idx: 0,
  6534. sum: 10,
  6535. user: {
  6536. roledata: {
  6537. rolecode: "roleset",
  6538. },
  6539. selectType: "1",
  6540. },
  6541. };
  6542. angular.forEach(grid.columns, function (item) {
  6543. if (item.enableFiltering) {
  6544. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6545. if (
  6546. angular.isDefined(item.filters[0].term) &&
  6547. item.filters[0].term != ""
  6548. ) {
  6549. if (angular.isUndefined(filtersData["user"])) {
  6550. filtersData["user"] = {};
  6551. }
  6552. filtersData["user"][item.field] = item.filters[0].term;
  6553. }
  6554. }
  6555. });
  6556. $scope.memoryfilterDatahao = filtersData;
  6557. $scope.loadData(filtersData);
  6558. });
  6559. };
  6560. $scope.removehaocai = function (item) {
  6561. event.preventDefault();
  6562. // var modalInstance = $modal.open({
  6563. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6564. // controller: function($scope, $modalInstance) {
  6565. // $scope.title = "修改耗材数量";
  6566. // $scope.consumptive = item;
  6567. // $scope.ok = function() {
  6568. // $modalInstance.close($scope.consumptive);
  6569. // };
  6570. // $scope.cancel = function() {
  6571. // $modalInstance.dismiss('cancel');
  6572. // };
  6573. // },
  6574. // size: 'sm'
  6575. // });
  6576. var modalInstance = $modal.open({
  6577. templateUrl: "assets/views/delete.html",
  6578. controller: function ($scope, $modalInstance, scope) {
  6579. $scope.title = "耗材移除";
  6580. $scope.connect = "确定要移除此设备?";
  6581. $scope.consumptive = scope.selected.items[0];
  6582. $scope.ok = function () {
  6583. $modalInstance.close($scope.consumptive);
  6584. };
  6585. $scope.cancel = function () {
  6586. $modalInstance.dismiss("cancel");
  6587. };
  6588. },
  6589. size: "sm",
  6590. resolve: {
  6591. scope: function () {
  6592. return $scope;
  6593. },
  6594. },
  6595. });
  6596. modalInstance.result.then(function (selectedItem) {
  6597. // angular.forEach($scope.myData3, function(items, index) {
  6598. // if (items.id == selectedItem.id) {
  6599. // $scope.myData3[index] = selectedItem;
  6600. // }
  6601. // })
  6602. // $scope.model.applicationForm.consumables = $scope.myData3;
  6603. angular.forEach($scope.myDataoneall, function (items, index) {
  6604. if (items.id == selectedItem.id) {
  6605. $scope.myDataoneall.splice(index, 1);
  6606. }
  6607. });
  6608. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6609. $scope.myDataoneall[i]["item"] =
  6610. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6611. }
  6612. $scope.myDataone = $scope.interceptMydata(
  6613. $scope.myDataoneall,
  6614. 0,
  6615. 10
  6616. );
  6617. $scope.model.consumables = $scope.myDataoneall;
  6618. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6619. $scope.myDataoneall;
  6620. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6621. $scope.selected = {
  6622. items: [],
  6623. };
  6624. });
  6625. };
  6626. $scope.haocaiadd = function () {
  6627. event.preventDefault();
  6628. var modalInstance = $modal.open({
  6629. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6630. controller: function (
  6631. $scope,
  6632. scope,
  6633. $modalInstance,
  6634. api_wechatfile,
  6635. SweetAlert,
  6636. api_cmdb3
  6637. ) {
  6638. $scope.haocainame = [];
  6639. $scope.pinpai = [];
  6640. $scope.guige = [];
  6641. $scope.consumptive = {};
  6642. $scope.consumpall = {};
  6643. $scope.title = "添加耗材";
  6644. api_wechatfile
  6645. .getDictionaryForList({
  6646. key: "haocaifenlei",
  6647. })
  6648. .then(function (data) {
  6649. $scope.haocainame = data;
  6650. });
  6651. $scope.clearNoNum = function (obj, attr) {
  6652. //先把非数字的都替换掉,除了数字和.
  6653. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6654. //必须保证第一个为数字而不是.
  6655. obj[attr] = obj[attr].replace(/^\./g, "");
  6656. //保证只有出现一个.而没有多个.
  6657. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6658. //保证.只出现一次,而不能出现两次以上
  6659. obj[attr] = obj[attr]
  6660. .replace(".", "$#$")
  6661. .replace(/\./g, "")
  6662. .replace("$#$", ".");
  6663. //小于最大值
  6664. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6665. alert(
  6666. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6667. );
  6668. obj[attr] = "";
  6669. }
  6670. };
  6671. $scope.onChange = function (parent) {
  6672. $scope.consumptive.model = {};
  6673. $scope.consumptive.Specifications = {};
  6674. api_wechatfile
  6675. .getDictionaryForList({
  6676. key: "pinpai",
  6677. parent: parent.id,
  6678. })
  6679. .then(function (data) {
  6680. $scope.pinpai = data;
  6681. });
  6682. api_wechatfile
  6683. .getDictionaryForList({
  6684. key: "guige",
  6685. parent: parent.id,
  6686. })
  6687. .then(function (data) {
  6688. $scope.guige = data;
  6689. });
  6690. };
  6691. $scope.onChangesum = function (item) {
  6692. if (item.name && item.model.id && item.Specifications.id) {
  6693. $scope.consumptive.sum = "";
  6694. var data1 = {
  6695. idx: 0,
  6696. sum: 10,
  6697. consumable: {
  6698. name: item.name.name,
  6699. brandModel: item.model.name,
  6700. specification: item.Specifications.name,
  6701. },
  6702. };
  6703. api_cmdb3
  6704. .fetchDataList("consumable", data1)
  6705. .then(function (data) {
  6706. if (data.status == 200 && data.list.length > 0) {
  6707. var myData = data.list;
  6708. $scope.consumpall = myData[0];
  6709. $scope.maxsum = myData[0].inventoryNum;
  6710. } else {
  6711. SweetAlert.swal({
  6712. title: "不存在该耗材",
  6713. text: "请检查库存后重新填写!",
  6714. type: "error",
  6715. });
  6716. }
  6717. });
  6718. }
  6719. };
  6720. $scope.addhaocai = function () {
  6721. $modalInstance.dismiss("cancel");
  6722. scope.haocaiopen($scope.consumptive);
  6723. };
  6724. $scope.ok = function (item) {
  6725. var items = {};
  6726. // if (item.name && item.model && item.Specifications && item.sum) {
  6727. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6728. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6729. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6730. // $scope.consumpall.sum = item.sum;
  6731. // delete $scope.consumpall.brandModel;
  6732. // delete $scope.consumpall.specification;
  6733. // $modalInstance.close($scope.consumpall);
  6734. // } else {
  6735. // SweetAlert.swal({
  6736. // title: "数据填写不完整!",
  6737. // text: "请检查数据然后提交!",
  6738. // type: "error"
  6739. // });
  6740. // }
  6741. var isold = false;
  6742. if (
  6743. item.name &&
  6744. item.model &&
  6745. JSON.stringify(item.model) != "{}" &&
  6746. item.Specifications &&
  6747. JSON.stringify(item.Specifications) != "{}" &&
  6748. item.sum
  6749. ) {
  6750. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6751. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6752. isold = true;
  6753. }
  6754. }
  6755. if (isold) {
  6756. SweetAlert.swal({
  6757. title: "该耗材已添加!",
  6758. text: "请不要重复添加耗材!",
  6759. type: "error",
  6760. });
  6761. } else {
  6762. $scope.consumpall.model = $scope.consumpall.brandModel;
  6763. $scope.consumpall.Specifications =
  6764. $scope.consumpall.specification;
  6765. $scope.consumpall.sum = item.sum;
  6766. delete $scope.consumpall.brandModel;
  6767. delete $scope.consumpall.specification;
  6768. $modalInstance.close($scope.consumpall);
  6769. }
  6770. } else {
  6771. SweetAlert.swal({
  6772. title: "数据填写不完整!",
  6773. text: "请检查数据然后提交!",
  6774. type: "error",
  6775. });
  6776. }
  6777. // $modalInstance.close(item);
  6778. };
  6779. $scope.cancel = function () {
  6780. $modalInstance.dismiss("cancel");
  6781. };
  6782. },
  6783. size: "sm",
  6784. resolve: {
  6785. scope: function () {
  6786. return $scope;
  6787. },
  6788. },
  6789. });
  6790. modalInstance.result.then(function (selectedItem) {
  6791. $scope.myDataoneall.push(selectedItem);
  6792. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6793. $scope.myDataoneall[i]["item"] =
  6794. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6795. }
  6796. // $scope.model.consumables = $scope.myDataone;
  6797. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6798. $scope.myDataone = $scope.interceptMydata(
  6799. $scope.myDataoneall,
  6800. 0,
  6801. 10
  6802. );
  6803. $scope.model.consumables = $scope.myDataoneall;
  6804. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6805. $scope.myDataoneall;
  6806. });
  6807. };
  6808. $scope.onDblClick = function (data, event) {
  6809. $scope.selectButtonClick(data, event);
  6810. };
  6811. $scope.memoryfilterDatahao = {
  6812. idx: 0,
  6813. sum: 10,
  6814. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6815. };
  6816. $scope.myDataone = [];
  6817. $scope.loadData = function (filterData) {};
  6818. // $scope.title = title;
  6819. $scope.ldloading = {};
  6820. $scope.selected = {
  6821. items: [],
  6822. };
  6823. if ($scope.$parent.$parent.$parent.model.gettype) {
  6824. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6825. if ($scope.model.assets) {
  6826. if (JSON.stringify($scope.model.assets) == "{}") {
  6827. $scope.model.assets = [];
  6828. } else {
  6829. $scope.model.assets = JSON.parse($scope.model.assets);
  6830. }
  6831. $scope.myDatalingbeiall = $scope.model.assets;
  6832. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6833. $scope.myDatalingbeiall[i]["item"] =
  6834. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6835. }
  6836. $scope.gridOptions1["totalItems"] =
  6837. $scope.myDatalingbeiall.length;
  6838. $scope.myDatalingbei = $scope.interceptMydata(
  6839. $scope.myDatalingbeiall,
  6840. 0,
  6841. 10
  6842. );
  6843. }
  6844. if ($scope.model.consumables) {
  6845. if (JSON.stringify($scope.model.consumables) == "{}") {
  6846. $scope.model.consumables = [];
  6847. } else {
  6848. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6849. }
  6850. $scope.myDataoneall = $scope.model.consumables;
  6851. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6852. $scope.myDataoneall[i]["item"] =
  6853. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6854. }
  6855. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6856. $scope.myDataone = $scope.interceptMydata(
  6857. $scope.myDataoneall,
  6858. 0,
  6859. 10
  6860. );
  6861. }
  6862. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6863. $scope.options.templateOptions.getpush({
  6864. hao: true,
  6865. gu: true,
  6866. });
  6867. } else {
  6868. $scope.options.templateOptions.getpush({
  6869. hao: true,
  6870. });
  6871. }
  6872. } else {
  6873. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6874. $scope.options.templateOptions.getpush({
  6875. gu: true,
  6876. });
  6877. }
  6878. }
  6879. }
  6880. },
  6881. ],
  6882. });
  6883. formlyConfigProvider.setType({
  6884. name: "ui-panel",
  6885. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6886. });
  6887. formlyConfigProvider.setType({
  6888. name: "ui-currentuser",
  6889. extends: "input",
  6890. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6891. defaultOptions: function (options) {
  6892. return {
  6893. templateOptions: {
  6894. // link: function() {}
  6895. },
  6896. };
  6897. },
  6898. controller: [
  6899. "$scope",
  6900. function ($scope) {
  6901. if ($scope.options.templateOptions.user) {
  6902. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6903. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6904. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6905. // }
  6906. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6907. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6908. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6909. }
  6910. $scope.model[$scope.options.key] =
  6911. $scope.options.templateOptions.user;
  6912. $scope.options.initialValue = $scope.model[$scope.options.key];
  6913. }
  6914. },
  6915. ],
  6916. });
  6917. //仪表盘
  6918. //待处理变更列表
  6919. formlyConfigProvider.setType({
  6920. name: "ui-ngpchangetable",
  6921. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6922. defaultOptions: function (options) {
  6923. return {
  6924. templateOptions: {
  6925. // relationAction: function() {
  6926. // options.hideExpression = true
  6927. // }
  6928. },
  6929. };
  6930. },
  6931. controller: [
  6932. "$scope",
  6933. "$modal",
  6934. "$timeout",
  6935. "SweetAlert",
  6936. "api_bpm_domain",
  6937. "$rootScope",
  6938. "ngTableParams",
  6939. "$filter",
  6940. "$state",
  6941. function (
  6942. $scope,
  6943. $modal,
  6944. $timeout,
  6945. SweetAlert,
  6946. api_bpm_domain,
  6947. $rootScope,
  6948. ngTableParams,
  6949. $filter,
  6950. $state
  6951. ) {
  6952. // var filterData = {
  6953. // "assignee": $rootScope.user.id,
  6954. // "searchtype": "all",
  6955. // "idx": "0",
  6956. // "sum": "10"
  6957. // };
  6958. var filterData = {
  6959. idx: "0",
  6960. sum: "10",
  6961. assignee: 2,
  6962. searchType: "todo",
  6963. };
  6964. $scope.incidentprocess = function (item) {
  6965. $state.go("app.wt_change.add", {
  6966. taskId: item.taskId,
  6967. processInstanceId: item.processInstanceId,
  6968. });
  6969. };
  6970. $scope.more = function () {
  6971. $state.go("app.wt_change.list", {});
  6972. };
  6973. api_bpm_domain
  6974. .fetchtask("bpm_change", filterData)
  6975. .then(function (data) {
  6976. if (data.data) {
  6977. $scope.myData = data.data;
  6978. } else {
  6979. SweetAlert.swal({
  6980. title: "操作异常!",
  6981. text: "系统异常,请稍后重试,或者联系管理员!",
  6982. type: "error",
  6983. });
  6984. }
  6985. });
  6986. $scope.removes = function () {
  6987. var modalInstance = $modal.open({
  6988. templateUrl: "assets/views/delete.html",
  6989. controller: function ($scope, $modalInstance) {
  6990. $scope.ok = function () {
  6991. $modalInstance.close();
  6992. };
  6993. $scope.cancel = function () {
  6994. $modalInstance.dismiss("cancel");
  6995. };
  6996. },
  6997. size: "sm",
  6998. });
  6999. modalInstance.result.then(function () {
  7000. console.log($scope.$parent.$parent.$parent.$parent);
  7001. for (
  7002. var i = 0;
  7003. i <
  7004. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7005. i++
  7006. ) {
  7007. if (
  7008. $scope.fields.type ==
  7009. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7010. .type
  7011. ) {
  7012. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7013. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7014. i,
  7015. 1
  7016. );
  7017. break;
  7018. }
  7019. }
  7020. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7021. if (vmForm) {
  7022. //console.log("vmForm>>>");//console.log(vmForm);
  7023. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7024. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7025. }
  7026. });
  7027. };
  7028. },
  7029. ],
  7030. });
  7031. //待处理问题列表
  7032. formlyConfigProvider.setType({
  7033. name: "ui-ngproblemtable",
  7034. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7035. defaultOptions: function (options) {
  7036. return {
  7037. templateOptions: {
  7038. // relationAction: function() {
  7039. // options.hideExpression = true
  7040. // }
  7041. },
  7042. };
  7043. },
  7044. controller: [
  7045. "$scope",
  7046. "$modal",
  7047. "$timeout",
  7048. "SweetAlert",
  7049. "api_bpm_data",
  7050. "$rootScope",
  7051. "ngTableParams",
  7052. "$filter",
  7053. "$state",
  7054. function (
  7055. $scope,
  7056. $modal,
  7057. $timeout,
  7058. SweetAlert,
  7059. api_bpm_data,
  7060. $rootScope,
  7061. ngTableParams,
  7062. $filter,
  7063. $state
  7064. ) {
  7065. var filterData = {
  7066. assignee: $rootScope.user.id,
  7067. candidateGroups: $rootScope.user.group[0].id,
  7068. searchtype: "todo",
  7069. idx: 0,
  7070. sum: 10,
  7071. };
  7072. $scope.incidentprocess = function (item) {
  7073. $state.go("app.wt_change.add", {
  7074. taskId: item.taskId,
  7075. processInstanceId: item.processInstanceId,
  7076. });
  7077. };
  7078. $scope.more = function () {
  7079. $state.go("app.wt_change.list", {});
  7080. };
  7081. api_bpm_data
  7082. .fetchDataList("changeclassify", filterData)
  7083. .then(function (data) {
  7084. if (data.data) {
  7085. $scope.myData = data.data;
  7086. } else {
  7087. SweetAlert.swal({
  7088. title: "操作异常!",
  7089. text: "系统异常,请稍后重试,或者联系管理员!",
  7090. type: "error",
  7091. });
  7092. }
  7093. });
  7094. $scope.removes = function () {
  7095. var modalInstance = $modal.open({
  7096. templateUrl: "assets/views/delete.html",
  7097. controller: function ($scope, $modalInstance) {
  7098. $scope.ok = function () {
  7099. $modalInstance.close();
  7100. };
  7101. $scope.cancel = function () {
  7102. $modalInstance.dismiss("cancel");
  7103. };
  7104. },
  7105. size: "sm",
  7106. });
  7107. modalInstance.result.then(function () {
  7108. console.log($scope.$parent.$parent.$parent.$parent);
  7109. for (
  7110. var i = 0;
  7111. i <
  7112. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7113. i++
  7114. ) {
  7115. if (
  7116. $scope.fields.type ==
  7117. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7118. .type
  7119. ) {
  7120. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7121. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7122. i,
  7123. 1
  7124. );
  7125. break;
  7126. }
  7127. }
  7128. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7129. if (vmForm) {
  7130. //console.log("vmForm>>>");//console.log(vmForm);
  7131. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7132. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7133. }
  7134. });
  7135. };
  7136. },
  7137. ],
  7138. });
  7139. //待处理事件列表
  7140. formlyConfigProvider.setType({
  7141. name: "ui-ngtable",
  7142. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7143. defaultOptions: function (options) {
  7144. return {
  7145. templateOptions: {
  7146. // relationAction: function() {
  7147. // options.hideExpression = true
  7148. // }
  7149. },
  7150. };
  7151. },
  7152. controller: [
  7153. "$scope",
  7154. "$modal",
  7155. "$timeout",
  7156. "SweetAlert",
  7157. "api_bpm_domain",
  7158. "$rootScope",
  7159. "ngTableParams",
  7160. "$filter",
  7161. "$state",
  7162. function (
  7163. $scope,
  7164. $modal,
  7165. $timeout,
  7166. SweetAlert,
  7167. api_bpm_domain,
  7168. $rootScope,
  7169. ngTableParams,
  7170. $filter,
  7171. $state
  7172. ) {
  7173. var filterData = {
  7174. assignee: $rootScope.user.id,
  7175. candidateGroups: $rootScope.user.group[0].id,
  7176. searchtype: "done",
  7177. idx: 0,
  7178. sum: 10,
  7179. };
  7180. $scope.incidentprocess = function (item) {
  7181. $state.go("app.incident.editor", {
  7182. taskId: item.taskId,
  7183. processInstanceId: item.processInstanceId,
  7184. });
  7185. };
  7186. $scope.more = function () {
  7187. $state.go("app.incident.list", {});
  7188. };
  7189. api_bpm_domain
  7190. .fetchtask("bpm_incident", filterData)
  7191. .then(function (data) {
  7192. if (data.data) {
  7193. $scope.myData = data.data;
  7194. } else {
  7195. SweetAlert.swal({
  7196. title: "操作异常!",
  7197. text: "系统异常,请稍后重试,或者联系管理员!",
  7198. type: "error",
  7199. });
  7200. }
  7201. });
  7202. $scope.removes = function () {
  7203. var modalInstance = $modal.open({
  7204. templateUrl: "assets/views/delete.html",
  7205. controller: function ($scope, $modalInstance) {
  7206. $scope.ok = function () {
  7207. $modalInstance.close();
  7208. };
  7209. $scope.cancel = function () {
  7210. $modalInstance.dismiss("cancel");
  7211. };
  7212. },
  7213. size: "sm",
  7214. });
  7215. modalInstance.result.then(function () {
  7216. console.log($scope.$parent.$parent.$parent.$parent);
  7217. for (
  7218. var i = 0;
  7219. i <
  7220. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7221. i++
  7222. ) {
  7223. if (
  7224. $scope.fields.type ==
  7225. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7226. .type
  7227. ) {
  7228. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7229. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7230. i,
  7231. 1
  7232. );
  7233. break;
  7234. }
  7235. }
  7236. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7237. if (vmForm) {
  7238. //console.log("vmForm>>>");//console.log(vmForm);
  7239. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7240. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7241. }
  7242. });
  7243. };
  7244. },
  7245. ],
  7246. });
  7247. //知识库列表
  7248. formlyConfigProvider.setType({
  7249. name: "ui-knowledge",
  7250. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7251. defaultOptions: function (options) {
  7252. return {
  7253. templateOptions: {
  7254. // relationAction: function() {
  7255. // options.hideExpression = true
  7256. // }
  7257. },
  7258. };
  7259. },
  7260. controller: [
  7261. "$scope",
  7262. "$modal",
  7263. "$timeout",
  7264. "api_solution",
  7265. "$rootScope",
  7266. "ngTableParams",
  7267. "$filter",
  7268. "$state",
  7269. function (
  7270. $scope,
  7271. $modal,
  7272. $timeout,
  7273. api_solution,
  7274. $rootScope,
  7275. ngTableParams,
  7276. $filter,
  7277. $state
  7278. ) {
  7279. var filterData = {
  7280. key: "null",
  7281. pageIndex: 0,
  7282. pageSum: 6,
  7283. status: 0,
  7284. userId: $rootScope.user.id,
  7285. };
  7286. $scope.model.removereport = false;
  7287. $scope.removes = function () {
  7288. $scope.model.removereport = true;
  7289. };
  7290. $scope.more = function () {
  7291. $state.go("app.knowledge.manager", {});
  7292. };
  7293. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7294. if (data.status == 200) {
  7295. $scope.myData = data.list;
  7296. }
  7297. });
  7298. $scope.removes = function () {
  7299. var modalInstance = $modal.open({
  7300. templateUrl: "assets/views/delete.html",
  7301. controller: function ($scope, $modalInstance) {
  7302. $scope.ok = function () {
  7303. $modalInstance.close();
  7304. };
  7305. $scope.cancel = function () {
  7306. $modalInstance.dismiss("cancel");
  7307. };
  7308. },
  7309. size: "sm",
  7310. });
  7311. modalInstance.result.then(function () {
  7312. for (
  7313. var i = 0;
  7314. i <
  7315. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7316. i++
  7317. ) {
  7318. if (
  7319. $scope.fields.type ==
  7320. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7321. .type
  7322. ) {
  7323. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7324. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7325. i,
  7326. 1
  7327. );
  7328. break;
  7329. }
  7330. }
  7331. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7332. if (vmForm) {
  7333. //console.log("vmForm>>>");//console.log(vmForm);
  7334. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7335. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7336. }
  7337. });
  7338. };
  7339. },
  7340. ],
  7341. });
  7342. //公告列表
  7343. formlyConfigProvider.setType({
  7344. name: "ui-ngnotice",
  7345. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7346. defaultOptions: function (options) {
  7347. return {
  7348. templateOptions: {
  7349. // relationAction: function() {
  7350. // options.hideExpression = true
  7351. // }
  7352. },
  7353. };
  7354. },
  7355. controller: [
  7356. "$scope",
  7357. "$modal",
  7358. "$timeout",
  7359. "SweetAlert",
  7360. "api_user_data",
  7361. "$rootScope",
  7362. "ngTableParams",
  7363. "$filter",
  7364. "$state",
  7365. function (
  7366. $scope,
  7367. $modal,
  7368. $timeout,
  7369. SweetAlert,
  7370. api_user_data,
  7371. $rootScope,
  7372. ngTableParams,
  7373. $filter,
  7374. $state
  7375. ) {
  7376. var filterData = {
  7377. idx: 0,
  7378. sum: 10,
  7379. };
  7380. // $scope.$scope.model.className = "col-xs-12";
  7381. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7382. if (data) {
  7383. $scope.myData = data.data;
  7384. } else {
  7385. SweetAlert.swal({
  7386. title: "操作异常!",
  7387. text: "系统异常,请稍后重试,或者联系管理员!",
  7388. type: "error",
  7389. });
  7390. }
  7391. });
  7392. $scope.more = function () {
  7393. $state.go("app.system.notice.list", {});
  7394. };
  7395. $scope.removes = function () {
  7396. var modalInstance = $modal.open({
  7397. templateUrl: "assets/views/delete.html",
  7398. controller: function ($scope, $modalInstance) {
  7399. $scope.ok = function () {
  7400. $modalInstance.close();
  7401. };
  7402. $scope.cancel = function () {
  7403. $modalInstance.dismiss("cancel");
  7404. };
  7405. },
  7406. size: "sm",
  7407. });
  7408. modalInstance.result.then(function () {
  7409. for (
  7410. var i = 0;
  7411. i <
  7412. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7413. i++
  7414. ) {
  7415. if (
  7416. $scope.fields.type ==
  7417. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7418. .type
  7419. ) {
  7420. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7421. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7422. i,
  7423. 1
  7424. );
  7425. break;
  7426. }
  7427. }
  7428. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7429. if (vmForm) {
  7430. //console.log("vmForm>>>");//console.log(vmForm);
  7431. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7432. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7433. }
  7434. });
  7435. };
  7436. },
  7437. ],
  7438. });
  7439. //事件统计图
  7440. formlyConfigProvider.setType({
  7441. name: "ui-incidentreport",
  7442. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7443. defaultOptions: function (options) {
  7444. return {
  7445. templateOptions: {
  7446. // relationAction: function() {
  7447. // options.hideExpression = true
  7448. // }
  7449. },
  7450. };
  7451. },
  7452. controller: [
  7453. "$scope",
  7454. "$modal",
  7455. "moment",
  7456. "api_report",
  7457. "$cookieStore",
  7458. function ($scope, $modal, moment, api_report, $cookieStore) {
  7459. api_report.getLicenseKey().then(function (response) {
  7460. $cookieStore.put("Auth-Token", response.token);
  7461. $scope.try_async_load();
  7462. });
  7463. $scope.try_async_load = function () {
  7464. $scope.my_data = [];
  7465. api_report.list().then(function (response) {
  7466. var dataList = response;
  7467. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7468. $scope.repoRoot.name = "事件报表";
  7469. convertRepoObject($scope.repoRoot);
  7470. $scope.my_data.push($scope.repoRoot);
  7471. });
  7472. };
  7473. var workspace = {};
  7474. $scope.repoRoot = null;
  7475. function getRepoRoot(repo, path) {
  7476. angular.forEach(repo, function (value, key) {
  7477. if (value.path == path) {
  7478. $scope.repoRoot = value;
  7479. } else {
  7480. if (
  7481. $scope.repoRoot == null &&
  7482. angular.isDefined(value.repoObjects)
  7483. ) {
  7484. getRepoRoot(value.repoObjects, path);
  7485. } else {
  7486. }
  7487. }
  7488. });
  7489. }
  7490. function convertRepoObject(repo) {
  7491. if (angular.isArray(repo)) {
  7492. angular.forEach(repo, function (value, key) {
  7493. convertRepoObject(value);
  7494. });
  7495. } else {
  7496. if (angular.isDefined(repo.name)) {
  7497. if (repo.name.indexOf(".") >= 0) {
  7498. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7499. } else {
  7500. repo.label = repo.name;
  7501. }
  7502. //delete repo.name;
  7503. }
  7504. if (angular.isDefined(repo.repoObjects)) {
  7505. repo.children = [];
  7506. repo.children = repo.repoObjects;
  7507. delete repo.repoObjects;
  7508. convertRepoObject(repo.children);
  7509. }
  7510. }
  7511. }
  7512. function parseDateParameter(parameters) {
  7513. var result = undefined;
  7514. if (angular.isArray(parameters)) {
  7515. // angular.forEach(parmeters,function(param){
  7516. // param.
  7517. // })
  7518. } else {
  7519. result = {};
  7520. for (var k in parameters) {
  7521. if (k.indexOf("Date") > 0) {
  7522. if (angular.isString(parameters[k])) {
  7523. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7524. "YYYY-MM-DD"
  7525. );
  7526. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7527. }
  7528. }
  7529. }
  7530. }
  7531. return result;
  7532. }
  7533. function ConvertDateParameter(parameters) {
  7534. var result = undefined;
  7535. if (angular.isArray(parameters)) {
  7536. //
  7537. } else {
  7538. result = {};
  7539. for (var k in parameters) {
  7540. if (k.indexOf("Date") > 0) {
  7541. if (angular.isDate(parameters[k])) {
  7542. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7543. } else if (angular.isString(parameters[k])) {
  7544. result[k] = parameters[k];
  7545. }
  7546. }
  7547. }
  7548. }
  7549. return result;
  7550. }
  7551. var incidentchart =
  7552. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7553. var queryUUID;
  7554. function genUUID() {
  7555. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7556. .replace(/[xy]/g, function (c) {
  7557. var r = (Math.random() * 16) | 0,
  7558. v = c == "x" ? r : (r & 0x3) | 0x8;
  7559. return v.toString(16);
  7560. })
  7561. .toUpperCase();
  7562. return uuid;
  7563. }
  7564. queryUUID = genUUID();
  7565. var pathincidenttimekey = [];
  7566. var incidenttime = {
  7567. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7568. "YYYYMMDD"
  7569. ),
  7570. endtimes: moment(new Date()).format("YYYYMMDD"),
  7571. };
  7572. var thisday = moment(new Date().getTime() + 86400000).format(
  7573. "YYYYMMDD"
  7574. );
  7575. var thisdaymine = Date.parse(
  7576. thisday.substr(4, 2) +
  7577. "/" +
  7578. thisday.substr(6, 2) +
  7579. "/" +
  7580. thisday.substr(0, 4)
  7581. );
  7582. var averages = [
  7583. [thisdaymine - 86400000 * 14, 0],
  7584. [thisdaymine - 86400000 * 13, 0],
  7585. [thisdaymine - 86400000 * 12, 0],
  7586. [thisdaymine - 86400000 * 11, 0],
  7587. [thisdaymine - 86400000 * 10, 0],
  7588. [thisdaymine - 86400000 * 9, 0],
  7589. [thisdaymine - 86400000 * 8, 0],
  7590. [thisdaymine - 86400000 * 7, 0],
  7591. [thisdaymine - 86400000 * 6, 0],
  7592. [thisdaymine - 86400000 * 5, 0],
  7593. [thisdaymine - 86400000 * 4, 0],
  7594. [thisdaymine - 86400000 * 3, 0],
  7595. [thisdaymine - 86400000 * 2, 0],
  7596. [thisdaymine - 86400000 * 1, 0],
  7597. [thisdaymine, 0],
  7598. ];
  7599. var getreportdata = function (incidenttime, path) {
  7600. api_report.getMdx(path, queryUUID).then(function (response) {
  7601. var mdxquery = response;
  7602. workspace.query = mdxquery;
  7603. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7604. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7605. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7606. weekuser(mdxquery);
  7607. });
  7608. };
  7609. getreportdata(incidenttime, incidentchart);
  7610. var weekuser = function (mdxquery) {
  7611. var key = [];
  7612. api_report.execute(mdxquery).then(function (data) {
  7613. $scope.rheaders = [];
  7614. $scope.rRows = [];
  7615. var reportData = data;
  7616. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7617. $scope.shows = true;
  7618. $scope.empty = "数据为空!";
  7619. } else {
  7620. angular.forEach(reportData.cellset, function (item, i) {
  7621. angular.forEach(averages, function (index, j) {
  7622. // angular.forEach(averages, function(item, index) {
  7623. if (item.length > 1 && i > 0 && item[1].value != "") {
  7624. if (
  7625. index[0] ==
  7626. Date.parse(
  7627. item[0].value.substr(4, 2) +
  7628. "/" +
  7629. item[0].value.substr(6, 2) +
  7630. "/" +
  7631. item[0].value.substr(0, 4)
  7632. ) +
  7633. 86400000
  7634. ) {
  7635. index[1] = Number(item[1].value);
  7636. }
  7637. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  7638. }
  7639. // })
  7640. });
  7641. });
  7642. incidentchartfun(averages);
  7643. }
  7644. });
  7645. };
  7646. var incidentchartfun = function (incidentchartkey) {
  7647. // $scope.isMaskincident = false;
  7648. Highcharts.chart("incidentchart", {
  7649. title: {
  7650. text: "事件近15天趋势图",
  7651. },
  7652. xAxis: {
  7653. type: "datetime",
  7654. labels: {
  7655. align: "left",
  7656. step: 1,
  7657. },
  7658. },
  7659. yAxis: {
  7660. title: {
  7661. text: null,
  7662. },
  7663. },
  7664. tooltip: {
  7665. crosshairs: true,
  7666. shared: true,
  7667. valueSuffix: "条",
  7668. },
  7669. legend: {},
  7670. series: [
  7671. {
  7672. name: "生成事件",
  7673. data: incidentchartkey,
  7674. zIndex: 1,
  7675. marker: {
  7676. fillColor: "white",
  7677. lineWidth: 2,
  7678. lineColor: Highcharts.getOptions().colors[0],
  7679. },
  7680. },
  7681. ],
  7682. });
  7683. };
  7684. $scope.data = {
  7685. labels: [
  7686. "1号",
  7687. "2号",
  7688. "3号",
  7689. "4号",
  7690. "5号",
  7691. "6号",
  7692. "7号",
  7693. "8号",
  7694. "9号",
  7695. "10号",
  7696. "11号",
  7697. "12号",
  7698. "13号",
  7699. "14号",
  7700. "15号",
  7701. ],
  7702. datasets: [
  7703. {
  7704. label: "新增事件数量",
  7705. fillColor: "rgba(220,220,220,0.2)",
  7706. strokeColor: "rgba(220,220,220,1)",
  7707. pointColor: "rgba(220,220,220,1)",
  7708. pointStrokeColor: "#fff",
  7709. pointHighlightFill: "#fff",
  7710. pointHighlightStroke: "rgba(220,220,220,1)",
  7711. data: [
  7712. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7713. ],
  7714. },
  7715. {
  7716. label: "已解决事件数量",
  7717. fillColor: "rgba(151,187,205,0.2)",
  7718. strokeColor: "rgba(151,187,205,1)",
  7719. pointColor: "rgba(151,187,205,1)",
  7720. pointStrokeColor: "#fff",
  7721. pointHighlightFill: "#fff",
  7722. pointHighlightStroke: "rgba(151,187,205,1)",
  7723. data: [
  7724. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7725. ],
  7726. },
  7727. ],
  7728. };
  7729. $scope.removes = function () {
  7730. var modalInstance = $modal.open({
  7731. templateUrl: "assets/views/delete.html",
  7732. controller: function ($scope, $modalInstance) {
  7733. $scope.ok = function () {
  7734. $modalInstance.close();
  7735. };
  7736. $scope.cancel = function () {
  7737. $modalInstance.dismiss("cancel");
  7738. };
  7739. },
  7740. size: "sm",
  7741. });
  7742. modalInstance.result.then(function () {
  7743. for (
  7744. var i = 0;
  7745. i <
  7746. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7747. i++
  7748. ) {
  7749. if (
  7750. $scope.fields.type ==
  7751. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7752. .type
  7753. ) {
  7754. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7755. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7756. i,
  7757. 1
  7758. );
  7759. break;
  7760. }
  7761. }
  7762. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7763. if (vmForm) {
  7764. //console.log("vmForm>>>");//console.log(vmForm);
  7765. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7766. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7767. }
  7768. });
  7769. };
  7770. var addDatas = 0;
  7771. var resolve = 0;
  7772. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7773. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7774. }
  7775. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7776. resolve = resolve + $scope.data.datasets[1].data[i];
  7777. }
  7778. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7779. $scope.opt = {
  7780. maintainAspectRatio: false,
  7781. // Sets the chart to be responsive
  7782. responsive: true,
  7783. ///Boolean - Whether grid lines are shown across the chart
  7784. scaleShowGridLines: true,
  7785. //String - Colour of the grid lines
  7786. scaleGridLineColor: "rgba(0,0,0,.05)",
  7787. //Number - Width of the grid lines
  7788. scaleGridLineWidth: 1,
  7789. //Boolean - Whether the line is curved between points
  7790. bezierCurve: false,
  7791. //Number - Tension of the bezier curve between points
  7792. bezierCurveTension: 0.4,
  7793. //Boolean - Whether to show a dot for each point
  7794. pointDot: true,
  7795. //Number - Radius of each point dot in pixels
  7796. pointDotRadius: 4,
  7797. //Number - Pixel width of point dot stroke
  7798. pointDotStrokeWidth: 1,
  7799. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7800. pointHitDetectionRadius: 20,
  7801. //Boolean - Whether to show a stroke for datasets
  7802. datasetStroke: true,
  7803. //Number - Pixel width of dataset stroke
  7804. datasetStrokeWidth: 2,
  7805. //Boolean - Whether to fill the dataset with a colour
  7806. datasetFill: true,
  7807. // Function - on animation progress
  7808. onAnimationProgress: function () {},
  7809. // Function - on animation complete
  7810. onAnimationComplete: function () {},
  7811. //String - A legend template
  7812. legendTemplate:
  7813. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7814. };
  7815. angular.extend($scope.options, $scope.opt);
  7816. $scope.datamonth = {
  7817. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7818. datasets: [
  7819. {
  7820. label: "新增事件数量",
  7821. fillColor: "rgba(220,220,220,0.5)",
  7822. strokeColor: "rgba(220,220,220,0.8)",
  7823. highlightFill: "rgba(220,220,220,0.75)",
  7824. highlightStroke: "rgba(220,220,220,1)",
  7825. data: [65, 59, 80, 81, 56, 55],
  7826. },
  7827. {
  7828. label: "已解决事件数量",
  7829. fillColor: "rgba(151,187,205,0.5)",
  7830. strokeColor: "rgba(151,187,205,0.8)",
  7831. highlightFill: "rgba(151,187,205,0.75)",
  7832. highlightStroke: "rgba(151,187,205,1)",
  7833. data: [28, 48, 40, 19, 86, 27],
  7834. },
  7835. ],
  7836. };
  7837. // Chart.js Options
  7838. $scope.taption = {
  7839. maintainAspectRatio: false,
  7840. // Sets the chart to be responsive
  7841. responsive: true,
  7842. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7843. scaleBeginAtZero: true,
  7844. //Boolean - Whether grid lines are shown across the chart
  7845. scaleShowGridLines: true,
  7846. //String - Colour of the grid lines
  7847. scaleGridLineColor: "rgba(0,0,0,.05)",
  7848. //Number - Width of the grid lines
  7849. scaleGridLineWidth: 1,
  7850. //Boolean - If there is a stroke on each bar
  7851. barShowStroke: true,
  7852. //Number - Pixel width of the bar stroke
  7853. barStrokeWidth: 2,
  7854. //Number - Spacing between each of the X value sets
  7855. barValueSpacing: 5,
  7856. //Number - Spacing between data sets within X values
  7857. barDatasetSpacing: 1,
  7858. //String - A legend template
  7859. legendTemplate:
  7860. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7861. };
  7862. },
  7863. ],
  7864. });
  7865. //排版日历
  7866. formlyConfigProvider.setType({
  7867. name: "ui-dashcalendar",
  7868. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7869. defaultOptions: function (options) {
  7870. return {
  7871. templateOptions: {
  7872. // relationAction: function() {
  7873. // options.hideExpression = true
  7874. // }
  7875. },
  7876. };
  7877. },
  7878. controller: [
  7879. "$rootScope",
  7880. "$scope",
  7881. "$modal",
  7882. "$aside",
  7883. "calendarConfig",
  7884. "moment",
  7885. "SweetAlert",
  7886. "Restangular",
  7887. "api_bpm_schedule",
  7888. "api_user_data",
  7889. "$state",
  7890. function (
  7891. $rootScope,
  7892. $scope,
  7893. $modal,
  7894. $aside,
  7895. calendarConfig,
  7896. moment,
  7897. SweetAlert,
  7898. Restangular,
  7899. api_bpm_schedule,
  7900. api_user_data,
  7901. $state
  7902. ) {
  7903. var loginUser = $rootScope.user;
  7904. calendarConfig.dateFormatter = "moment";
  7905. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7906. calendarConfig.i18nStrings.timeLabel = "时间";
  7907. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7908. calendarConfig.allDateFormats = {
  7909. angular: {
  7910. date: {
  7911. hour: "ha",
  7912. day: "d MMM",
  7913. month: "MMMM",
  7914. weekDay: "EEEE",
  7915. time: "HH:mm",
  7916. datetime: "MMM d, h:mm a",
  7917. },
  7918. title: {
  7919. day: "yyyy MMMM EEEE d",
  7920. week: "{year}年第{week}周",
  7921. month: "yyyy MMMM",
  7922. year: "yyyy",
  7923. },
  7924. },
  7925. moment: {
  7926. date: {
  7927. hour: "ha",
  7928. day: "MMMDD日",
  7929. month: "MMMM",
  7930. weekDay: "dddd",
  7931. time: "HH:mm",
  7932. datetime: "MMM D, h:mm a",
  7933. },
  7934. title: {
  7935. day: "YYYY年MMMMDD日, dddd ",
  7936. week: "{year}年第{week}周",
  7937. month: "YYYY年MMMM",
  7938. year: "YYYY",
  7939. },
  7940. },
  7941. };
  7942. moment.locale("zh_cn", {
  7943. months:
  7944. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7945. "_"
  7946. ),
  7947. monthsShort:
  7948. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7949. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7950. "_"
  7951. ),
  7952. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7953. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7954. longDateFormat: {
  7955. LT: "Ah点mm分",
  7956. LTS: "Ah点m分s秒",
  7957. L: "YYYY-MM-DD",
  7958. LL: "YYYY年MMMD日",
  7959. LLL: "YYYY年MMMD日Ah点mm分",
  7960. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7961. l: "YYYY-MM-DD",
  7962. ll: "YYYY年MMMD日",
  7963. lll: "YYYY年MMMD日Ah点mm分",
  7964. llll: "YYYY年MMMD日ddddAh点mm分",
  7965. },
  7966. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7967. meridiemHour: function (hour, meridiem) {
  7968. if (hour === 12) {
  7969. hour = 0;
  7970. }
  7971. if (
  7972. meridiem === "凌晨" ||
  7973. meridiem === "早上" ||
  7974. meridiem === "上午"
  7975. ) {
  7976. return hour;
  7977. } else if (meridiem === "下午" || meridiem === "晚上") {
  7978. return hour + 12;
  7979. } else {
  7980. // '中午'
  7981. return hour >= 11 ? hour : hour + 12;
  7982. }
  7983. },
  7984. meridiem: function (hour, minute, isLower) {
  7985. var hm = hour * 100 + minute;
  7986. if (hm < 600) {
  7987. return "凌晨";
  7988. } else if (hm < 900) {
  7989. return "早上";
  7990. } else if (hm < 1130) {
  7991. return "上午";
  7992. } else if (hm < 1230) {
  7993. return "中午";
  7994. } else if (hm < 1800) {
  7995. return "下午";
  7996. } else {
  7997. return "晚上";
  7998. }
  7999. },
  8000. calendar: {
  8001. sameDay: function () {
  8002. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8003. },
  8004. nextDay: function () {
  8005. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8006. },
  8007. lastDay: function () {
  8008. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8009. },
  8010. nextWeek: function () {
  8011. var startOfWeek, prefix;
  8012. startOfWeek = moment().startOf("week");
  8013. prefix =
  8014. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8015. ? "[下]"
  8016. : "[本]";
  8017. return this.minutes() === 0
  8018. ? prefix + "dddAh点整"
  8019. : prefix + "dddAh点mm";
  8020. },
  8021. lastWeek: function () {
  8022. var startOfWeek, prefix;
  8023. startOfWeek = moment().startOf("week");
  8024. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8025. return this.minutes() === 0
  8026. ? prefix + "dddAh点整"
  8027. : prefix + "dddAh点mm";
  8028. },
  8029. sameElse: "LL",
  8030. },
  8031. ordinalParse: /\d{1,2}(日|月|周)/,
  8032. ordinal: function (number, period) {
  8033. switch (period) {
  8034. case "d":
  8035. case "D":
  8036. case "DDD":
  8037. return number + "日";
  8038. case "M":
  8039. return number + "月";
  8040. case "w":
  8041. case "W":
  8042. return number + "周";
  8043. default:
  8044. return number;
  8045. }
  8046. },
  8047. relativeTime: {
  8048. future: "%s内",
  8049. past: "%s前",
  8050. s: "几秒",
  8051. m: "1 分钟",
  8052. mm: "%d 分钟",
  8053. h: "1 小时",
  8054. hh: "%d 小时",
  8055. d: "1 天",
  8056. dd: "%d 天",
  8057. M: "1 个月",
  8058. MM: "%d 个月",
  8059. y: "1 年",
  8060. yy: "%d 年",
  8061. },
  8062. week: {
  8063. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8064. dow: 1, // Monday is the first day of the week.
  8065. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8066. },
  8067. });
  8068. var date = new Date();
  8069. var d = date.getDate();
  8070. var m = date.getMonth();
  8071. var y = date.getFullYear();
  8072. var filterData = {
  8073. userId: loginUser.id,
  8074. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8075. "YYYY-MM-DD HH:mm:ss"
  8076. ),
  8077. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8078. "YYYY-MM-DD HH:mm:ss"
  8079. ),
  8080. };
  8081. var load = ($scope.load = function (filterData) {
  8082. api_bpm_schedule
  8083. .fetchSchedule(
  8084. filterData.userId,
  8085. filterData.startTime,
  8086. filterData.endTime
  8087. )
  8088. .then(function (response) {
  8089. if (response.status == 200) {
  8090. $scope.events = [];
  8091. var myData = response.list;
  8092. angular.forEach(myData, function (item) {
  8093. var eventTemp = {};
  8094. eventTemp.title = item.description;
  8095. eventTemp.type = item.scheduleClass.code;
  8096. eventTemp.startsAt = moment(
  8097. item["scheduleOrderDTO"].startTime
  8098. ).toDate();
  8099. eventTemp.endsAtTime = moment(
  8100. item["scheduleOrderDTO"].endTime
  8101. ).toDate();
  8102. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8103. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8104. //eventTemp.ends_at = moment(item.endTime).toDate();
  8105. eventTemp.id = item.id;
  8106. eventTemp.deletable = false;
  8107. eventTemp.user = item.user;
  8108. $scope.events.push(eventTemp);
  8109. });
  8110. }
  8111. });
  8112. });
  8113. // var load = $scope.load = function(filterData){
  8114. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8115. // console.log("response="+JSON.stringify(response));
  8116. // if(response.status==200){
  8117. // $scope.events = [];
  8118. // console.log(response.list);
  8119. // var myData = response.list;
  8120. // angular.forEach(myData,function(item){
  8121. // var eventTemp = {};
  8122. // eventTemp.title = item.description;
  8123. // eventTemp.type = item.scheduleClass.code;
  8124. // eventTemp.startsAt = moment(item.startTime).toDate();
  8125. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8126. // eventTemp.startTime = item.startTime;
  8127. // eventTemp.endTime = item.endTime;
  8128. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8129. // eventTemp.id = item.id;
  8130. // eventTemp.deletable = false;
  8131. // eventTemp.users = item.users;
  8132. // $scope.events.push(eventTemp);
  8133. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8134. // })
  8135. // }
  8136. // });
  8137. // }
  8138. $scope.scheduleClass = {};
  8139. var convertEvent = function (scheduleorder) {
  8140. var eventTemp = {};
  8141. eventTemp.title = scheduleorder.description;
  8142. eventTemp.type = scheduleorder.scheduleClass.code;
  8143. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8144. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8145. eventTemp.id = scheduleorder.id;
  8146. eventTemp.user = scheduleorder.user;
  8147. eventTemp.deletable = false;
  8148. return eventTemp;
  8149. };
  8150. // var convertEvent = function(scheduleorder){
  8151. // var eventTemp = {};
  8152. // eventTemp.title = scheduleorder.description;
  8153. // eventTemp.type = scheduleorder.scheduleClass.code;
  8154. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8155. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8156. // eventTemp.id = scheduleorder.id;
  8157. // eventTemp.users = scheduleorder.users;
  8158. // eventTemp.deletable = false;
  8159. // return eventTemp;
  8160. // }
  8161. api_bpm_schedule.getScheduleClass().then(function (response) {
  8162. if (response.status == 200) {
  8163. var scheduleClassList = response.list;
  8164. angular.forEach(scheduleClassList, function (item) {
  8165. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8166. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8167. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8168. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8169. $scope.scheduleClass[item["code"]] = item;
  8170. });
  8171. }
  8172. });
  8173. $scope.events = [];
  8174. $scope.calendarView = "month";
  8175. //$scope.calendarDay = new Date();
  8176. $scope.calendarDate = moment().startOf("month").toDate();
  8177. $scope.timeLabel = "时间";
  8178. $scope.eventLabel = "描述";
  8179. function showModal(action, event) {
  8180. // console.log("action="+JSON.stringify(action))
  8181. var modalInstance = $aside.open({
  8182. templateUrl: "scheduleEvent.html",
  8183. placement: "right",
  8184. size: "sm",
  8185. backdrop: true,
  8186. controller: function (
  8187. $scope,
  8188. $modalInstance,
  8189. scheduleClass,
  8190. APIService,
  8191. MementFormat
  8192. ) {
  8193. $scope.$modalInstance = $modalInstance;
  8194. $scope.action = action;
  8195. $scope.event = event;
  8196. $scope.scheduleClassic = scheduleClass;
  8197. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8198. // if(oldvalue == newvalue) return;
  8199. // if(scheduleClass[newvalue]){
  8200. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8201. var em = MementFormat(scheduleClass[newvalue].endTime);
  8202. console.log("sm=" + JSON.stringify(sm));
  8203. event.starts_at = MementFormat(event.startTime)
  8204. .startOf("day")
  8205. .add(sm.hour(), "hour")
  8206. .add(sm.minute(), "minute")
  8207. .add(sm.second(), "second")
  8208. .toDate();
  8209. console.log(
  8210. "event.starts_at=" + JSON.stringify(event.starts_at)
  8211. );
  8212. if (sm.hour() > em.hour()) {
  8213. event.ends_at = MementFormat(event.startTime)
  8214. .startOf("day")
  8215. .add(1, "day")
  8216. .add(em.hour(), "hour")
  8217. .add(em.minute(), "minute")
  8218. .add(em.second(), "second")
  8219. .toDate();
  8220. console.log(
  8221. "event.ends_at=" + JSON.stringify(event.starts_at)
  8222. );
  8223. } else {
  8224. event.ends_at = MementFormat(event.startTime)
  8225. .startOf("day")
  8226. .add(em.hour(), "hour")
  8227. .add(em.minute(), "minute")
  8228. .add(em.second(), "second")
  8229. .toDate();
  8230. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8231. }
  8232. // }
  8233. });
  8234. // $scope.ok = function (event) {
  8235. // console.log("event="+JSON.stringify(event))
  8236. // event.action = action;
  8237. // $modalInstance.close(event);
  8238. // };
  8239. $scope.cancel = function (event) {
  8240. $modalInstance.dismiss();
  8241. };
  8242. var acUserSelect = ($scope.refreshUser = function (key) {
  8243. //for test
  8244. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  8245. // return;
  8246. var data = {
  8247. idx: "0",
  8248. sum: "5",
  8249. };
  8250. if (key) {
  8251. data["user"] = {
  8252. name: key,
  8253. };
  8254. }
  8255. APIService.fetchDataList("user", data).then(function (
  8256. response
  8257. ) {
  8258. if (response) {
  8259. if ((response.status = 200)) {
  8260. $scope.users = response.list;
  8261. console.log($scope.users);
  8262. }
  8263. }
  8264. });
  8265. });
  8266. if (angular.isDefined(event.users) && event.users.length > 0) {
  8267. }
  8268. $scope.users = [event.user];
  8269. acUserSelect();
  8270. },
  8271. resolve: {
  8272. scheduleClass: function () {
  8273. return $scope.scheduleClass;
  8274. },
  8275. APIService: function () {
  8276. return api_user_data;
  8277. },
  8278. MementFormat: function () {
  8279. return moment;
  8280. },
  8281. },
  8282. });
  8283. modalInstance.result.then(function (selectedEvent) {
  8284. if (selectedEvent.action == "Clicked") {
  8285. // var data = {
  8286. // "scheduleorder":{
  8287. // "id":selectedEvent.id,
  8288. // "description":selectedEvent.title,
  8289. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8290. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8291. // "users":selectedEvent.users,
  8292. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8293. // }
  8294. // };
  8295. // api_bpm_schedule.update(data).then(function(response){
  8296. // if(response.status==200){
  8297. // SweetAlert.swal({
  8298. // title: "操作成功!",
  8299. // text: "排班更新成功!",
  8300. // type: "succes"
  8301. // });
  8302. // angular.forEach($scope.events,function(item){
  8303. // if(item.id==selectedEvent.id){
  8304. // item = selectedEvent;
  8305. // }
  8306. // })
  8307. // }else{
  8308. // SweetAlert.swal({
  8309. // title: "操作失败",
  8310. // text: "排班更新失败,请稍后重试!",
  8311. // type: "error"
  8312. // })
  8313. // }
  8314. // })
  8315. } else {
  8316. //
  8317. }
  8318. });
  8319. }
  8320. $scope.moment = function (string) {
  8321. return moment(string);
  8322. };
  8323. $scope.eventClicked = function (event) {
  8324. // console.log("event="+JSON.stringify(event))
  8325. showModal("Clicked", event);
  8326. };
  8327. $scope.eventEdited = function (event) {
  8328. showModal("Edited", event);
  8329. };
  8330. var updateView = function (newvalue, oldvalue) {
  8331. if (oldvalue == newvalue) return;
  8332. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8333. if ($scope.calendarView == "year") {
  8334. } else if ($scope.calendarView == "month") {
  8335. timeStart = moment(newvalue).startOf("month");
  8336. timeEnd = moment(newvalue).endOf("month");
  8337. } else if ($scope.calendarView == "week") {
  8338. timeStart = moment(newvalue).startOf("week");
  8339. timeEnd = moment(newvalue).endOf("week");
  8340. } else if ($scope.calendarView == "Day") {
  8341. timeStart = moment(newvalue).startOf("day");
  8342. timeEnd = moment(newvalue).endOf("day");
  8343. }
  8344. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8345. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8346. filterData["startTime"] = timeStartSpan;
  8347. filterData["endTime"] = timeEndSpan;
  8348. load(filterData);
  8349. };
  8350. $scope.$watch("calendarDate", updateView);
  8351. $scope.next = function () {
  8352. $scope.calendarControl.next();
  8353. };
  8354. $scope.prev = function () {
  8355. $scope.calendarControl.prev();
  8356. };
  8357. $scope.setCalendarToToday = function () {
  8358. $scope.calendarDay = new Date();
  8359. };
  8360. $scope.toggle = function ($event, field, event) {
  8361. $event.preventDefault();
  8362. $event.stopPropagation();
  8363. event[field] = !event[field];
  8364. };
  8365. $scope.load(filterData);
  8366. $scope.more = function () {
  8367. $state.go("app.scheduling.myscheduling", {});
  8368. };
  8369. $scope.removes = function () {
  8370. var modalInstance = $modal.open({
  8371. templateUrl: "assets/views/delete.html",
  8372. controller: function ($scope, $modalInstance) {
  8373. $scope.ok = function () {
  8374. $modalInstance.close();
  8375. };
  8376. $scope.cancel = function () {
  8377. $modalInstance.dismiss("cancel");
  8378. };
  8379. },
  8380. size: "sm",
  8381. });
  8382. modalInstance.result.then(function () {
  8383. for (
  8384. var i = 0;
  8385. i <
  8386. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8387. i++
  8388. ) {
  8389. if (
  8390. $scope.fields.type ==
  8391. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8392. .type
  8393. ) {
  8394. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8395. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8396. i,
  8397. 1
  8398. );
  8399. break;
  8400. }
  8401. }
  8402. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8403. if (vmForm) {
  8404. //console.log("vmForm>>>");//console.log(vmForm);
  8405. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8406. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8407. }
  8408. });
  8409. };
  8410. },
  8411. ],
  8412. });
  8413. //空格组件
  8414. formlyConfigProvider.setType({
  8415. name: "ui-black",
  8416. /*extends: 'input',*/
  8417. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8418. });
  8419. //请求人最近事件
  8420. formlyConfigProvider.setType({
  8421. name: "ui-recentIncident",
  8422. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8423. controller: [
  8424. "$scope",
  8425. "$modal",
  8426. "api_solution",
  8427. function ($scope, $modal, api_solution) {
  8428. var filterData = {
  8429. incident: {
  8430. requester: {
  8431. id: "",
  8432. },
  8433. },
  8434. idx: 0,
  8435. sum: 3,
  8436. };
  8437. setInterval(function () {
  8438. if (
  8439. filterData.incident.requester.id == "" ||
  8440. filterData.incident.requester.id != $scope.model.requester.id
  8441. ) {
  8442. var requester = $scope.model.requester;
  8443. if (requester != null && angular.isDefined(requester.id)) {
  8444. filterData.incident.requester.id = $scope.model.requester.id;
  8445. $scope.options.templateOptions
  8446. .getWorkernumber(
  8447. $scope.options.templateOptions.ApiService,
  8448. filterData
  8449. )
  8450. .then(function (result) {
  8451. var modelData =
  8452. $scope.options.templateOptions.Restangular.stripRestangular(
  8453. result
  8454. );
  8455. if (modelData.status == 200) {
  8456. $scope.lastrequst = modelData.list;
  8457. }
  8458. });
  8459. requester = null;
  8460. } else {
  8461. }
  8462. } else {
  8463. }
  8464. }, 1000);
  8465. $scope.detail = function (data) {
  8466. var modalInstance = $modal.open({
  8467. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8468. controller: function ($scope, $modalInstance) {
  8469. $scope.entity = {};
  8470. $scope.entity = data;
  8471. $scope.cancel = function () {
  8472. $modalInstance.dismiss("cancel");
  8473. };
  8474. },
  8475. size: "lg",
  8476. });
  8477. };
  8478. },
  8479. ],
  8480. });
  8481. //参数列表
  8482. formlyConfigProvider.setType({
  8483. name: "ui-listinput",
  8484. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8485. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8486. defaultOptions: function (options) {
  8487. return {
  8488. templateOptions: {},
  8489. };
  8490. },
  8491. controller: ["$scope", function ($scope) {}],
  8492. });
  8493. //时间段控件(分)
  8494. formlyConfigProvider.setType({
  8495. name: "ui-timeslot",
  8496. extends: "input",
  8497. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8498. controller: ["$scope", function ($scope) {}],
  8499. });
  8500. //优先级级联-逾期时间
  8501. formlyConfigProvider.setType({
  8502. name: "ui-overtime",
  8503. extends: "input",
  8504. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8505. controller: [
  8506. "$scope",
  8507. "api_bpm_domain",
  8508. function ($scope, api_bpm_domain) {
  8509. var filteData = {};
  8510. var datas = {};
  8511. setInterval(function () {
  8512. if (
  8513. $scope.model.priority &&
  8514. $scope.model.priority.id != null &&
  8515. filteData &&
  8516. datas != $scope.model.priority.id
  8517. ) {
  8518. filteData = "L" + $scope.model.priority.id;
  8519. datas = $scope.model.priority.id;
  8520. // console.log($scope.options.templateOptions)
  8521. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8522. // var overtime=requester.date;
  8523. if (requester.state == 200) {
  8524. // if($scope.options.key=="date"){
  8525. $scope.model[$scope.options.key] = requester.date;
  8526. // }
  8527. }
  8528. });
  8529. }
  8530. }, 1000);
  8531. },
  8532. ],
  8533. });
  8534. formlyConfigProvider.setType({
  8535. name: "ui-responsetime",
  8536. extends: "input",
  8537. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8538. controller: [
  8539. "$scope",
  8540. "api_bpm_domain",
  8541. function ($scope, api_bpm_domain) {
  8542. var filteData = {};
  8543. var datas = {};
  8544. setInterval(function () {
  8545. if (
  8546. $scope.model.priority &&
  8547. $scope.model.priority.id != null &&
  8548. filteData &&
  8549. datas != $scope.model.priority.id
  8550. ) {
  8551. filteData = "L" + $scope.model.priority.id;
  8552. datas = $scope.model.priority.id;
  8553. // console.log($scope.options.templateOptions)
  8554. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8555. // var overtime=requester.date;
  8556. if (requester.state == 200) {
  8557. var keyName = {};
  8558. // $scope.model.overdueTime = requester.date;
  8559. if ($scope.options.key == "expectIntroTime") {
  8560. keyName = "resolveTime";
  8561. } else if ($scope.options.key == "expectResponseTime") {
  8562. keyName = "responseTime";
  8563. }
  8564. $scope.model[$scope.options.key] =
  8565. requester.serviceLevelAgreement[keyName];
  8566. // }
  8567. console.log($scope.$parent.$parent.$parent.model);
  8568. }
  8569. if (requester.date1) {
  8570. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8571. requester.date;
  8572. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8573. requester.date1;
  8574. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8575. requester.serviceLevelAgreement.resolveTime;
  8576. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8577. requester.serviceLevelAgreement.responseTime;
  8578. }
  8579. });
  8580. }
  8581. }, 1000);
  8582. },
  8583. ],
  8584. });
  8585. //知识库按钮组件
  8586. formlyConfigProvider.setType({
  8587. name: "ui-discasecade",
  8588. extends: "input",
  8589. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8590. defaultOptions: function (options) {
  8591. return {
  8592. templateOptions: {
  8593. relationAction: function (fields, modelscope, item) {},
  8594. },
  8595. validators: {
  8596. required: {
  8597. expression: function (viewValue, modelValue) {
  8598. var value = modelValue || viewValue;
  8599. // return value = "true";
  8600. },
  8601. },
  8602. },
  8603. };
  8604. },
  8605. controller: [
  8606. "$scope",
  8607. "$rootScope",
  8608. "$modal",
  8609. "SweetAlert",
  8610. "api_bpm_data",
  8611. "api_solution",
  8612. "$aside",
  8613. "api_zsk",
  8614. "api_bpm_domain",
  8615. function (
  8616. $scope,
  8617. $rootScope,
  8618. $modal,
  8619. SweetAlert,
  8620. api_bpm_data,
  8621. api_solution,
  8622. $aside,
  8623. api_zsk,
  8624. api_bpm_domain
  8625. ) {
  8626. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8627. $scope.searchField = $scope.options.model[$scope.options.key];
  8628. $scope.searchData = "";
  8629. $scope.onChangeadd = function (searchData) {
  8630. $scope.searchKey = searchData.account;
  8631. // $scope.searchDataadd = searchData;
  8632. var requesdata = angular.copy(searchData);
  8633. $scope.requester = requesdata;
  8634. };
  8635. $scope.refreshUseradd = function (searchKey) {
  8636. //主题搜索
  8637. $scope.searchData = searchKey;
  8638. reashdata($scope.searchData);
  8639. };
  8640. $scope.getMydata = function (x) {
  8641. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8642. $scope.searchField = $scope.model[$scope.options.key];
  8643. };
  8644. $scope.getMydataone = function (x) {
  8645. $scope.model[$scope.options.key] = x;
  8646. $scope.searchField = $scope.model[$scope.options.key];
  8647. };
  8648. $scope.fildata = {
  8649. idx: 0,
  8650. sum: 10,
  8651. // 'incident': { 'tilte': item }
  8652. };
  8653. function reashdata(item) {
  8654. if (item && item != "") {
  8655. angular.extend($scope.fildata, {
  8656. incident: {
  8657. title: item,
  8658. },
  8659. });
  8660. } else {
  8661. delete $scope.fildata.incident;
  8662. }
  8663. api_bpm_data
  8664. .fetchDataList("incident", $scope.fildata)
  8665. .then(function (response) {
  8666. if (response) {
  8667. if ((response.status = 200)) {
  8668. var myData = response;
  8669. $scope.myData = myData.list;
  8670. }
  8671. }
  8672. });
  8673. }
  8674. function delHtmlTag(str) {
  8675. return str.replace(/<[^>]+>/g, "");
  8676. }
  8677. // reashdata();
  8678. var changedata = {};
  8679. setInterval(function () {
  8680. if (
  8681. $scope.model.category != null &&
  8682. $scope.model.category.id != changedata.id &&
  8683. $scope.model.titles != $scope.model.category
  8684. ) {
  8685. $scope.searchData = {};
  8686. changedata = angular.copy($scope.model.category);
  8687. if ($scope.options.key == "title") {
  8688. var filterData = {
  8689. idx: 0,
  8690. sum: 1000,
  8691. };
  8692. api_bpm_data
  8693. .fetchDataList("incidentcategory", filterData)
  8694. .then(function (data) {
  8695. var datalist = data.list;
  8696. angular.forEach(datalist, function (item) {
  8697. if (item.id == $scope.model.category.id) {
  8698. $scope.model[$scope.options.key] = item.category;
  8699. $scope.searchField =
  8700. $scope.options.model[$scope.options.key];
  8701. $scope.titles = item.category;
  8702. titles = $scope.model.category;
  8703. }
  8704. });
  8705. });
  8706. }
  8707. }
  8708. }, 1000);
  8709. $scope.open = function (key, options, fildata, $event, model) {
  8710. if (key && key.length > 1) {
  8711. api_zsk
  8712. .solutionData(
  8713. {
  8714. solution: {
  8715. searchWord: key,
  8716. },
  8717. idx: "0",
  8718. sum: "1000",
  8719. },
  8720. "solution"
  8721. )
  8722. .then(function (response) {
  8723. if (response && response.list.length > 0) {
  8724. $scope.dlideboxslide = true;
  8725. angular.forEach(response, function (item) {
  8726. console.log(response);
  8727. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8728. // if (response.status == 200) {
  8729. // var quote = { 'totalNum': response.totalNum }
  8730. // item = angular.extend(item, quote)
  8731. // }
  8732. // })
  8733. $scope.searchData = response.list;
  8734. console.log($scope.searchData);
  8735. });
  8736. $scope.changes = false;
  8737. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8738. // $scope.closepages = function(e) {
  8739. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8740. // event.preventDefault();
  8741. // };
  8742. $scope.shows = false;
  8743. $scope.tempData = {};
  8744. $scope.showpage = function (item) {
  8745. item.content = delHtmlTag(item.content);
  8746. $scope.shows = true;
  8747. $scope.tempData = item;
  8748. if (item.content != null) {
  8749. $scope.tempData.content = $scope.tempData.content
  8750. .replace("<p>", "")
  8751. .replace("</p>", "");
  8752. }
  8753. $scope.knowledgedata = item;
  8754. $scope.pageid = item.id;
  8755. $scope.changes = !$scope.changes;
  8756. api_bpm_domain
  8757. .listAttachments(item.id)
  8758. // api_solution.fetchDataList('file', {
  8759. // "file": {
  8760. // "solutionId": item.id
  8761. // },
  8762. // "idx": "0",
  8763. // "sum": "1000"
  8764. // })
  8765. .then(function (data) {
  8766. if (data) {
  8767. $scope.attachments = data.list;
  8768. $scope.view = function (attachmentId) {
  8769. for (
  8770. var i = 0;
  8771. i < $scope.attachments.length;
  8772. i++
  8773. ) {
  8774. if ($scope.attachments[i].id == attachmentId) {
  8775. window.open($scope.attachments[i].previewUrl);
  8776. }
  8777. }
  8778. };
  8779. $scope.download = function (contentId, filename) {
  8780. api_solution
  8781. .getSolutionDowpath(contentId)
  8782. .then(function (response) {
  8783. var file = new Blob([response], {
  8784. type: "application/octet-stream",
  8785. });
  8786. // var filename = filename;
  8787. var fileURL = URL.createObjectURL(file);
  8788. var a = document.createElement("a");
  8789. a.href = fileURL;
  8790. a.target = "_blank";
  8791. a.download = filename;
  8792. document.body.appendChild(a);
  8793. a.click();
  8794. });
  8795. };
  8796. }
  8797. });
  8798. };
  8799. $scope.related = function (item) {
  8800. if (item.content != null) {
  8801. item.content = item.content
  8802. .replace("<p>", "")
  8803. .replace("</p>", "");
  8804. }
  8805. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8806. options.model.handleDescription = item.content;
  8807. var data = {
  8808. solutionQuote: {
  8809. solutionId: item.id,
  8810. incidentsign: options.model.incidentsign,
  8811. },
  8812. };
  8813. api_zsk.solutionQuote(item.id).then(function (response) {
  8814. if (response.status == 200) {
  8815. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8816. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8817. "close";
  8818. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8819. } else {
  8820. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8821. }
  8822. });
  8823. };
  8824. $scope.close = function () {
  8825. $scope.changes = !$scope.changes;
  8826. event.preventDefault();
  8827. };
  8828. }
  8829. });
  8830. }
  8831. };
  8832. },
  8833. ],
  8834. });
  8835. //侧滑选择重复事件
  8836. formlyConfigProvider.setType({
  8837. name: "ui-repeatIncidentbtn",
  8838. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8839. defaultOptions: function (options) {
  8840. return {
  8841. templateOptions: {
  8842. relationAction: function (fields, modelscope, item) {},
  8843. },
  8844. validators: {
  8845. required: {
  8846. expression: function (viewValue, modelValue) {
  8847. // var value = modelValue || viewValue;
  8848. },
  8849. },
  8850. },
  8851. };
  8852. },
  8853. controller: [
  8854. "$scope",
  8855. "$rootScope",
  8856. "$modal",
  8857. "SweetAlert",
  8858. "api_bpm_data",
  8859. "api_solution",
  8860. "$aside",
  8861. "api_zsk",
  8862. "api_bpm_domain",
  8863. function (
  8864. $scope,
  8865. $rootScope,
  8866. $modal,
  8867. SweetAlert,
  8868. api_bpm_data,
  8869. api_solution,
  8870. $aside,
  8871. api_zsk,
  8872. api_bpm_domain
  8873. ) {
  8874. console.log($scope);
  8875. $scope.selection = {
  8876. id: "",
  8877. };
  8878. //认证计费数据获取
  8879. $scope.sumInfo = {};
  8880. function getSumInfo() {
  8881. api_bpm_data
  8882. .sumInfo($scope.model.incident.account)
  8883. .then(function (data) {
  8884. console.log(data);
  8885. if (data) {
  8886. $scope.sumInfo = data.data || {};
  8887. }
  8888. });
  8889. }
  8890. getSumInfo();
  8891. // 收起重复事件侧滑框
  8892. function reashdata(item) {
  8893. var fildata = {
  8894. idx: 0,
  8895. incident: {
  8896. department: {
  8897. id: $scope.model.incident.department.id,
  8898. },
  8899. },
  8900. sum: 3,
  8901. };
  8902. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8903. console.log(data);
  8904. if (data) {
  8905. $scope.repeatData = data.list;
  8906. }
  8907. });
  8908. }
  8909. reashdata();
  8910. // 确认选中的重复事件
  8911. $scope.repeatIncidentOk = function () {
  8912. if ($scope.selection.id) {
  8913. $scope.model.incident.repeat = $scope.selection;
  8914. $scope.model.isRepeat = true; //隐藏处理信息
  8915. console.log($scope.model);
  8916. }
  8917. angular.element("#repeatIncident").removeClass("active");
  8918. };
  8919. // 取消选中的重复事件
  8920. $scope.repeatIncidentCancle = function () {
  8921. angular.element("#repeatIncident").removeClass("active");
  8922. return;
  8923. };
  8924. },
  8925. ],
  8926. });
  8927. //侧滑选择知识库查询
  8928. formlyConfigProvider.setType({
  8929. name: "ui-knowledgebtn",
  8930. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8931. defaultOptions: function (options) {
  8932. return {
  8933. templateOptions: {
  8934. relationAction: function (fields, modelscope, item) {},
  8935. },
  8936. validators: {
  8937. required: {
  8938. expression: function (viewValue, modelValue) {
  8939. // var value = modelValue || viewValue;
  8940. },
  8941. },
  8942. },
  8943. };
  8944. },
  8945. controller: [
  8946. "$scope",
  8947. "$rootScope",
  8948. "$modal",
  8949. "SweetAlert",
  8950. "api_bpm_data",
  8951. "api_solution",
  8952. "$aside",
  8953. "api_zsk",
  8954. "api_bpm_domain",
  8955. "api_wechatfile",
  8956. "up_down_file",
  8957. function (
  8958. $scope,
  8959. $rootScope,
  8960. $modal,
  8961. SweetAlert,
  8962. api_bpm_data,
  8963. api_solution,
  8964. $aside,
  8965. api_zsk,
  8966. api_bpm_domain,
  8967. api_wechatfile,
  8968. up_down_file
  8969. ) {
  8970. $scope.keypressModel = function (e, key) {
  8971. if (e.keyCode === 13) {
  8972. $scope.openModel(key);
  8973. }
  8974. };
  8975. // 引用知识库点击
  8976. $scope.searchKeyWord = "";
  8977. $scope.openModel = function (key) {
  8978. // alert(1)//重点
  8979. $scope.searchKeyWord = key;
  8980. if (key) {
  8981. api_zsk
  8982. .solutionData(
  8983. {
  8984. solution: {
  8985. threeSearch: key,
  8986. status: { id: 72 }, //已发布
  8987. selectType: "keySearch",
  8988. },
  8989. idx: "0",
  8990. sum: "1000",
  8991. },
  8992. "solution"
  8993. )
  8994. .then(function (response) {
  8995. $scope.searchData = response.list;
  8996. });
  8997. }
  8998. };
  8999. $scope.openModel($scope.model.incident.description);
  9000. // 展开/收起
  9001. $scope.showId = "";
  9002. $scope.ifshow = false;
  9003. $scope.showAll = function (id) {
  9004. $scope.attachments = [];
  9005. if ($scope.showId == id) {
  9006. $scope.ifshow = !$scope.ifshow;
  9007. } else {
  9008. $scope.ifshow = true;
  9009. }
  9010. $scope.showId = id;
  9011. // 获取附件
  9012. api_wechatfile
  9013. .listAttachments("knowledge", $scope.showId)
  9014. .then(function (data) {
  9015. $scope.attachments = data.data;
  9016. $scope.download = function (token, filename) {
  9017. var downUrl = up_down_file
  9018. .downloadAttachment("common/common/downloadAttachment", token)
  9019. .getRequestedUrl();
  9020. // window.open(downUrl);
  9021. var a = document.createElement("a");
  9022. a.href = downUrl;
  9023. a.target = "_blank";
  9024. a.download = filename;
  9025. document.body.appendChild(a);
  9026. a.click();
  9027. };
  9028. });
  9029. };
  9030. // 引用
  9031. $scope.related = function (item) {
  9032. console.log(item, "引用名");
  9033. if (item.content) {
  9034. item.content = item.content
  9035. .replace(/<p>/g, "")
  9036. .replace(/<\/p>/g, "")
  9037. .replace(/&nbsp;/g, "");
  9038. }
  9039. $scope.model.incident.handleDescription = item.content;
  9040. $scope.model.incident.title = $scope.model.incident.description =
  9041. item.title;
  9042. $scope.model.incident.category = item.category;
  9043. if (item.category) {
  9044. $scope.model.incident.priority.id = item.category.priority.id;
  9045. item.category.label = item.category.category;
  9046. }
  9047. var categoryId = item.category ? item.category.id : "";
  9048. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  9049. function getres(nodes) {
  9050. if (!nodes || nodes.length == 0) {
  9051. return;
  9052. }
  9053. nodes.forEach((e) => {
  9054. e.selected = false;
  9055. if (e.id == categoryId) {
  9056. e.selected = true;
  9057. return false;
  9058. }
  9059. getres(e.children);
  9060. });
  9061. }
  9062. var categorys = [];
  9063. $scope.fields.forEach((e, i) => {
  9064. if (e.key == "category") {
  9065. categorys = e.templateOptions.options;
  9066. if (categorys.length) {
  9067. getres(categorys);
  9068. $scope.fields[i].templateOptions.options = categorys;
  9069. $scope.$root.refreshSelectedItems();
  9070. }
  9071. return false;
  9072. }
  9073. });
  9074. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9075. $scope.model.candidateGroups = item.category
  9076. ? item.category.group
  9077. : {};
  9078. // 携带关联优先级,事件工单信息的时间
  9079. if (
  9080. $scope.model &&
  9081. $scope.model.incident &&
  9082. item.category &&
  9083. item.category.priority &&
  9084. item.category.priority.id
  9085. ) {
  9086. api_bpm_domain
  9087. .expectedTime("L" + (item.category.priority.id - 1559))
  9088. .then(function (res) {
  9089. $scope.model.incident.expectResponseTime =
  9090. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9091. res.serviceLevelAgreement.responseTime;
  9092. $scope.model.incident.expectIntroTime =
  9093. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9094. res.serviceLevelAgreement.resolveTime;
  9095. $scope.model.incident.overdueTime =
  9096. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9097. res.date;
  9098. });
  9099. }
  9100. api_zsk.solutionQuote(item.id).then(function (response) {
  9101. if (response.status == 200) {
  9102. $("#seachknowledge").removeClass("active");
  9103. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9104. $scope.$parent.$parent.$parent.model.start_code = "close";
  9105. $scope.$parent.$parent.$parent.model.directClose = 0;
  9106. console.log($scope.model);
  9107. } else {
  9108. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9109. }
  9110. });
  9111. };
  9112. },
  9113. ],
  9114. });
  9115. //下拉输入组件
  9116. formlyConfigProvider.setType({
  9117. name: "ui-selectinput",
  9118. extends: "input",
  9119. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9120. defaultOptions: function (options) {
  9121. return {
  9122. templateOptions: {
  9123. refresh: function () {},
  9124. refreshDelay: 0,
  9125. linkage: function (modelName, data) {},
  9126. },
  9127. };
  9128. },
  9129. controller: [
  9130. "$scope",
  9131. "$rootScope",
  9132. "$modal",
  9133. "SweetAlert",
  9134. "api_bpm_data",
  9135. "api_solution",
  9136. "$aside",
  9137. function (
  9138. $scope,
  9139. $rootScope,
  9140. $modal,
  9141. SweetAlert,
  9142. api_bpm_data,
  9143. api_solution,
  9144. $aside
  9145. ) {
  9146. $scope.searchData = "";
  9147. $scope.onChangeadd = function (searchData) {
  9148. // $scope.searchKey = searchData.account;
  9149. // var requesdata = angular.copy(searchData)
  9150. // $scope.requester = requesdata;
  9151. };
  9152. $scope.refreshUseradd = function (searchKey) {
  9153. //主题搜索
  9154. // $scope.searchData = searchKey;
  9155. // reashdata($scope.searchData);
  9156. };
  9157. $scope.getMydata = function (x) {
  9158. $scope.model[$scope.options.key] =
  9159. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9160. $scope.searchField = $scope.model[$scope.options.key];
  9161. };
  9162. $scope.getMydataone = function (x) {
  9163. $scope.model[$scope.options.key] = x;
  9164. $scope.searchField = $scope.model[$scope.options.key];
  9165. if (
  9166. $scope.model[$scope.options.key] &&
  9167. $scope.model[$scope.options.key] != ""
  9168. ) {
  9169. $scope.hidden = false;
  9170. } else {
  9171. $scope.hidden = true;
  9172. }
  9173. };
  9174. function reashdata(item) {
  9175. $scope.myData = $scope.options.templateOptions.mydata;
  9176. }
  9177. reashdata();
  9178. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9179. $scope.options.templateOptions.fetchItems($scope);
  9180. }
  9181. },
  9182. ],
  9183. });
  9184. //重构组件模板
  9185. //获取当前人
  9186. formlyConfigProvider.setType({
  9187. name: "ui-users",
  9188. extends: "input",
  9189. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9190. defaultOptions: function (options) {
  9191. return {
  9192. templateOptions: {
  9193. translate: "",
  9194. refreshDelay: 0,
  9195. },
  9196. };
  9197. },
  9198. controller: [
  9199. "$scope",
  9200. function ($scope) {
  9201. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9202. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9203. },
  9204. ],
  9205. });
  9206. //只读控件
  9207. formlyConfigProvider.setType({
  9208. name: "ui-label",
  9209. extends: "input",
  9210. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9211. defaultOptions: function (options) {
  9212. return {
  9213. templateOptions: {
  9214. translate: "",
  9215. refreshDelay: 0,
  9216. },
  9217. };
  9218. },
  9219. controller: [
  9220. "$scope",
  9221. "$rootScope",
  9222. function ($scope, $rootScope) {
  9223. // console.log($scope.options.templateOptions)
  9224. // console.log($scope.options,'options1122');
  9225. $scope.isSolutionLabel = false;
  9226. $scope.solutionLabelStr = "";
  9227. // console.log($scope.options.templateOptions.solotinLabel);
  9228. if ($scope.options.templateOptions.solotinLabel) {
  9229. $scope.isSolutionLabel = true;
  9230. if ($scope.model[$scope.options.key]) {
  9231. var solutionArr = $scope.model[$scope.options.key].split("/");
  9232. $scope.solutionLabelStr = solutionArr.join(" ");
  9233. }
  9234. }
  9235. var value = $scope.model[$scope.options.key];
  9236. // ----------------
  9237. // ----------------
  9238. // console.log(value, 'pppp')
  9239. function treeDesc(children, key, label) {
  9240. if (label == "") {
  9241. label = children[key];
  9242. } else {
  9243. label = children[key] + "-" + label;
  9244. }
  9245. if (angular.isDefined(children.parent)) {
  9246. treeDesc(children.parent, key, label);
  9247. } else {
  9248. return label;
  9249. }
  9250. }
  9251. if (angular.isArray(value)) {
  9252. var tempValue = "";
  9253. angular.forEach(value, function (item) {
  9254. if (tempValue != "") {
  9255. tempValue = tempValue + ",";
  9256. }
  9257. tempValue =
  9258. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9259. item;
  9260. });
  9261. $scope.options.templateOptions.translate = tempValue;
  9262. } else if (angular.isObject(value)) {
  9263. if (
  9264. angular.isDefined(value.children) ||
  9265. angular.isDefined(value.parent)
  9266. ) {
  9267. //tree
  9268. // console.log("value.parent="+JSON.stringify(value.parent))
  9269. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9270. nameLabel = treeDesc(
  9271. value.parent,
  9272. $scope.options.templateOptions.labelProp,
  9273. nameLabel
  9274. );
  9275. $scope.options.templateOptions.translate = nameLabel;
  9276. } else {
  9277. $scope.options.templateOptions.translate = value;
  9278. }
  9279. } else if (
  9280. angular.isString(value) &&
  9281. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9282. ) {
  9283. // console.log("value=" + value);
  9284. $scope.options.templateOptions.translate = value;
  9285. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9286. // console.log("value="+value);
  9287. // $scope.options.templateOptions.translate = value;
  9288. } else {
  9289. // var datasdf = JSON.parse(value);
  9290. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9291. $scope.options.templateOptions.translate = value;
  9292. }
  9293. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9294. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9295. $scope.options.templateOptions.translate =
  9296. $scope.options.templateOptions.transform(
  9297. $scope.originalModel,
  9298. value,
  9299. $rootScope,
  9300. $scope
  9301. );
  9302. }
  9303. // console.log($scope.options.templateOptions.translate,99999);
  9304. },
  9305. ],
  9306. });
  9307. //小标题组件
  9308. formlyConfigProvider.setType({
  9309. name: "ui-header",
  9310. template:
  9311. '<div class="row"><div class="col-xs-12 col-15 form_heard border-top-left-2 border-top-right-2"> <div class = "pull-left fontcolor-two fontsizes-16 font-weight-500" > {{ options.templateOptions.label }} </div> </div></div>',
  9312. });
  9313. //标题组件
  9314. formlyConfigProvider.setType({
  9315. name: "ui-title",
  9316. template:
  9317. '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle">{{options.templateOptions.label}}<i tooltip={{options.templateOptions.placeholder}} tooltip-placement="right" class="fa ti-help-alt margin-left-10 fontcolor-five pointfont"></i></h1></div></div></section>',
  9318. });
  9319. //标栏是否展示
  9320. formlyConfigProvider.setType({
  9321. name: "ui-orshow",
  9322. template:
  9323. '<div class="panel"><div class="panel-heading px-nested-panel-heading {{options.templateOptions.heard}} clearfix"><h3 class="pull-left panel-title text-head margin-left-10" ng-if="options.templateOptions.label">{{options.templateOptions.label}} </h3><a ng-click="clickshow(model[options.key])" class="pull-right"><i class=" ti-angle-double-up" ng-if="model[options.key]">隐藏</i><i class="ti-angle-double-down" ng-if="!model[options.key]">展示</i></a></div></div>',
  9324. controller: [
  9325. "$scope",
  9326. function ($scope) {
  9327. $scope.clickshow = function (key) {
  9328. // $scope.model[$scope.options.key] != key;
  9329. if (key == false) {
  9330. $scope.model[$scope.options.key] = true;
  9331. } else {
  9332. $scope.model[$scope.options.key] = false;
  9333. }
  9334. };
  9335. },
  9336. ],
  9337. });
  9338. //按钮组
  9339. formlyConfigProvider.setType({
  9340. name: "ui-button",
  9341. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9342. defaultOptions: function (options) {
  9343. return {
  9344. noFormControl: true,
  9345. };
  9346. },
  9347. });
  9348. //3d组link
  9349. formlyConfigProvider.setType({
  9350. name: "ui-link",
  9351. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9352. defaultOptions: function (options) {
  9353. return {
  9354. noFormControl: true,
  9355. };
  9356. },
  9357. });
  9358. //隐藏域组件
  9359. formlyConfigProvider.setType({
  9360. name: "ui-hidden",
  9361. extends: "input",
  9362. template:
  9363. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9364. defaultOptions: function (options) {
  9365. return {
  9366. // noFormControl: true
  9367. };
  9368. },
  9369. });
  9370. //文本框组件
  9371. formlyConfigProvider.setType({
  9372. name: "ui-input",
  9373. extends: "input",
  9374. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9375. defaultOptions: function (options) {
  9376. return {
  9377. templateOptions: {
  9378. transform: function (value) {},
  9379. },
  9380. };
  9381. },
  9382. controller: [
  9383. "$scope",
  9384. "$timeout",
  9385. function ($scope, $timeout) {
  9386. // console.log($scope.model[$scope.options.key]);
  9387. // console.log($scope.options)
  9388. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9389. $scope.model[$scope.options.key] =
  9390. $scope.options.templateOptions.linkData($scope.model);
  9391. }
  9392. },
  9393. ],
  9394. });
  9395. //搜索下拉框-故障地点seimin
  9396. formlyConfigProvider.setType({
  9397. name: "ui-select-search",
  9398. extends: "input",
  9399. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9400. defaultOptions: function (options) {
  9401. return {
  9402. templateOptions: {
  9403. transform: function (value) {},
  9404. },
  9405. };
  9406. },
  9407. controller: [
  9408. "$scope",
  9409. "$rootScope",
  9410. "api_search_area",
  9411. function ($scope, $rootScope, api_search_area) {
  9412. // console.log($scope.options, $scope.model)
  9413. // ----------------分割线 start-----------------
  9414. // 故障地点下拉
  9415. $scope.address_arr = []; //故障地点所有数据
  9416. $scope.addressFlag = false; //默认下拉框列表隐藏
  9417. //点击文本框
  9418. $scope.AddressClickHandle = function () {
  9419. $scope.getDepartmentList();
  9420. angular.element("#bx_address_ul").scrollTop(0);
  9421. };
  9422. //修改文字,实时监听
  9423. $scope.ksChangeHandle = _.debounce(function () {
  9424. $scope.model[$scope.options.key] =
  9425. $scope.model[$scope.options.key] === undefined
  9426. ? ""
  9427. : $scope.model[$scope.options.key];
  9428. $scope.getDepartmentList();
  9429. angular.element("#bx_address_ul").scrollTop(0);
  9430. }, 500);
  9431. //获取故障地点seimin
  9432. $scope.getDepartmentList = function () {
  9433. $scope.model[$scope.options.key] =
  9434. $scope.model[$scope.options.key] === null
  9435. ? ""
  9436. : $scope.model[$scope.options.key];
  9437. api_search_area
  9438. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9439. .then((res) => {
  9440. if (res.state == 200) {
  9441. $scope.address_arr = res.result;
  9442. $scope.addressFlag = true; //显示
  9443. }
  9444. })
  9445. .catch((err) => {
  9446. console.log(err);
  9447. });
  9448. };
  9449. // $scope.getDepartmentList();
  9450. // console.log($scope.model[$scope.options.key])
  9451. //下拉框列表选中
  9452. $scope.addressItemClick = function (obj) {
  9453. $scope.addressFlag = false; //隐藏
  9454. $scope.model[$scope.options.key] = obj.place
  9455. ? obj.area.area + obj.place
  9456. : obj.area;
  9457. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9458. $scope.model.selecthouseNumber = obj;
  9459. console.log($scope, 77777);
  9460. $scope.$root.selecthouseNumber = obj;
  9461. };
  9462. //点击空白处隐藏
  9463. angular.element(document).on("click", function (e) {
  9464. if (e.target !== angular.element("#bx_address").get(0)) {
  9465. $scope.addressFlag = false; //隐藏
  9466. //模拟placeholder
  9467. // if ($('#bx_address').val() == '') {
  9468. // $('#bx_address').val('请选择报修科室');
  9469. // }
  9470. }
  9471. });
  9472. // -----------------分割线 end----------------
  9473. },
  9474. ],
  9475. });
  9476. //知识库关键字组件
  9477. formlyConfigProvider.setType({
  9478. name: "ui-knowledgeKeywords",
  9479. extends: "input",
  9480. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9481. defaultOptions: function (options) {
  9482. return {
  9483. templateOptions: {
  9484. transform: function (value) {},
  9485. },
  9486. };
  9487. },
  9488. controller: [
  9489. "$scope",
  9490. "$timeout",
  9491. "SweetAlert",
  9492. function ($scope, $timeout, SweetAlert) {
  9493. $scope.valueLength = [
  9494. {
  9495. value: "",
  9496. },
  9497. ];
  9498. $scope.valueAll = [];
  9499. if ($scope.model[$scope.options.key]) {
  9500. var valueArr = $scope.model[$scope.options.key].split("/");
  9501. $scope.valueLength = [];
  9502. for (var i = 0; i < valueArr.length; i++) {
  9503. $scope.valueLength.push({
  9504. value: valueArr[i],
  9505. });
  9506. }
  9507. }
  9508. $scope.addIpt = function () {
  9509. if ($scope.valueLength.length < 5) {
  9510. $scope.valueLength.push({
  9511. value: "",
  9512. });
  9513. } else {
  9514. SweetAlert.swal({
  9515. title: "添加失败",
  9516. text: "关键字不能超过5个!",
  9517. type: "error",
  9518. confirmButtonColor: "#DD6B55",
  9519. });
  9520. }
  9521. };
  9522. $scope.closeIpt = function (data) {
  9523. $scope.valueLength.splice(data, 1);
  9524. };
  9525. $scope.toOption = function () {
  9526. $scope.valueAll = [];
  9527. for (var i = 0; i < $scope.valueLength.length; i++) {
  9528. if ($scope.valueLength[i].value != "") {
  9529. $scope.valueAll.push($scope.valueLength[i].value);
  9530. }
  9531. }
  9532. $scope.model.label = $scope.valueAll.join("/");
  9533. };
  9534. },
  9535. ],
  9536. });
  9537. //文本框组件
  9538. formlyConfigProvider.setType({
  9539. name: "ui-num",
  9540. extends: "input",
  9541. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9542. defaultOptions: function (options) {
  9543. return {
  9544. templateOptions: {
  9545. transform: function (value) {},
  9546. },
  9547. };
  9548. },
  9549. controller: [
  9550. "$scope",
  9551. "$timeout",
  9552. function ($scope, $timeout) {
  9553. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9554. $scope.model[$scope.options.key] =
  9555. $scope.options.templateOptions.linkData($scope.model);
  9556. }
  9557. $scope.clearNoNum = function (obj, attr) {
  9558. //先把非数字的都替换掉,除了数字和.
  9559. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9560. //必须保证第一个为数字而不是.
  9561. obj[attr] = obj[attr].replace(/^\./g, "");
  9562. //保证只有出现一个.而没有多个.
  9563. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9564. //保证.只出现一次,而不能出现两次以上
  9565. obj[attr] = obj[attr]
  9566. .replace(".", "$#$")
  9567. .replace(/\./g, "")
  9568. .replace("$#$", ".");
  9569. //小于最大值
  9570. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9571. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9572. // obj[attr] = '';
  9573. // }
  9574. };
  9575. },
  9576. ],
  9577. });
  9578. // //关联请求人文本框组件
  9579. // formlyConfigProvider.setType({
  9580. // name: 'ui-requestinput',
  9581. // extends: 'input',
  9582. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9583. // defaultOptions: function(options) {
  9584. // return {
  9585. // templateOptions: {
  9586. // transform: function(value) {},
  9587. // linkData: function(options) {}
  9588. // }
  9589. // };
  9590. // }
  9591. // });
  9592. //只读文本
  9593. formlyConfigProvider.setType({
  9594. name: "ui-disableinput",
  9595. extends: "input",
  9596. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9597. defaultOptions: function (options) {
  9598. return {
  9599. templateOptions: {
  9600. transform: function (value) {
  9601. var ret = "";
  9602. if (value) {
  9603. ret = "已删除";
  9604. } else {
  9605. ret = "正常";
  9606. }
  9607. return ret;
  9608. },
  9609. },
  9610. };
  9611. },
  9612. });
  9613. formlyConfigProvider.setType({
  9614. name: "ui-disinput",
  9615. extends: "input",
  9616. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9617. defaultOptions: function (options) {
  9618. return {
  9619. templateOptions: {},
  9620. };
  9621. },
  9622. });
  9623. //数字组件
  9624. formlyConfigProvider.setType({
  9625. name: "ui-number",
  9626. extends: "input",
  9627. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9628. defaultOptions: function (options) {
  9629. return {
  9630. templateOptions: {},
  9631. };
  9632. },
  9633. controller: ["$scope", function ($scope) {}],
  9634. });
  9635. //含有周的日期
  9636. formlyConfigProvider.setType({
  9637. name: "ui-datepickerweek",
  9638. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9639. extends: "input",
  9640. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9641. defaultOptions: {
  9642. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9643. templateOptions: {
  9644. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9645. },
  9646. },
  9647. controller: [
  9648. "$scope",
  9649. "$filter",
  9650. function ($scope, $filter) {
  9651. $scope.mindata = new Date(
  9652. $scope.options.templateOptions.transform($scope.model).getTime() +
  9653. 5 * 60 * 1000
  9654. );
  9655. if ($scope.model[$scope.options.key]) {
  9656. } else {
  9657. $scope.model[$scope.options.key] = $filter("date")(
  9658. new Date(new Date().getTime()),
  9659. $scope.options.templateOptions.datepickerPopup
  9660. );
  9661. }
  9662. $scope.options.initialValue = $scope.model[$scope.options.key];
  9663. $scope.endOpen = true;
  9664. $scope.datepicker = {};
  9665. $scope.datepicker.opened = false;
  9666. $scope.datepicker.open = function ($event) {
  9667. $scope.datepicker.opened = true;
  9668. };
  9669. },
  9670. ],
  9671. });
  9672. //lmm
  9673. //分配任务列表
  9674. formlyConfigProvider.setType({
  9675. name: "jry_taskDistributionList",
  9676. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9677. wrapper: ["bootstrapHasError"],
  9678. defaultOptions: function (options, $scope) {
  9679. return {
  9680. templateOptions: {},
  9681. };
  9682. },
  9683. controller: function (
  9684. $rootScope,
  9685. $scope,
  9686. api_user_data,
  9687. $modal,
  9688. api_doc_data,
  9689. i18nService,
  9690. SweetAlert,
  9691. api_wechatfile
  9692. ) {
  9693. // 获取状态
  9694. $scope.stateListData = {};
  9695. $scope.getStateData = function () {
  9696. //lyl
  9697. var data = {
  9698. key: "task_sub_state",
  9699. type: "list",
  9700. };
  9701. api_wechatfile.getDictionary(data).then(function (res) {
  9702. angular.forEach(res, function (v, i) {
  9703. $scope.stateListData[v.value] = v.id;
  9704. });
  9705. });
  9706. };
  9707. $scope.getStateData();
  9708. var loginUser = $rootScope.user;
  9709. $scope.langs = i18nService.getAllLangs();
  9710. $scope.lang = "zh-cn";
  9711. i18nService.setCurrentLang($scope.lang);
  9712. $scope.gridOptions = {};
  9713. $scope.gridOptions.data = "myData";
  9714. $scope.gridOptions.enableColumnResizing = true;
  9715. $scope.gridOptions.enableGridMenu = false;
  9716. $scope.gridOptions.enableRowSelection = true;
  9717. $scope.gridOptions.showGridFooter = true;
  9718. $scope.gridOptions.showColumnFooter = false;
  9719. $scope.gridOptions.fastWatch = true;
  9720. $scope.gridOptions.useExternalFiltering = true;
  9721. $scope.gridOptions.useExternalPagination = true;
  9722. $scope.gridOptions.paginationPageSizes = [10];
  9723. $scope.gridOptions.paginationPageSize = 10;
  9724. $scope.gridOptions.multiSelect = true;
  9725. $scope.gridOptions.rowIdentity = function (row) {
  9726. return row.id;
  9727. };
  9728. $scope.gridOptions.getRowIdentity = function (row) {
  9729. return row.id;
  9730. };
  9731. // console.log($scope.model);//lmmmm
  9732. $scope.gridOptions.columnDefs = [
  9733. {
  9734. name: "item",
  9735. displayName: "序号",
  9736. width: "10%",
  9737. cellTemplate:
  9738. "<div>" +
  9739. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9740. "</div>",
  9741. },
  9742. {
  9743. name: "taskDescribe",
  9744. displayName: "任务说明",
  9745. width: "25%",
  9746. enableFiltering: false,
  9747. cellTemplate:
  9748. "<div>" +
  9749. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9750. "</div>",
  9751. },
  9752. {
  9753. name: "assign.name",
  9754. displayName: "指派人",
  9755. width: "5%",
  9756. enableFiltering: false,
  9757. cellTemplate:
  9758. "<div>" +
  9759. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9760. "</div>",
  9761. },
  9762. {
  9763. name: "startTime",
  9764. displayName: "开始时间",
  9765. width: "13%",
  9766. enableFiltering: false,
  9767. cellTemplate:
  9768. "<div>" +
  9769. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9770. "</div>",
  9771. },
  9772. {
  9773. name: "endTime",
  9774. displayName: "结束时间",
  9775. width: "13%",
  9776. enableFiltering: false,
  9777. cellTemplate:
  9778. "<div>" +
  9779. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9780. "</div>",
  9781. },
  9782. {
  9783. name: "priority.name",
  9784. displayName: "优先级",
  9785. width: "5%",
  9786. enableFiltering: false,
  9787. cellTemplate:
  9788. "<div>" +
  9789. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9790. "</div>",
  9791. },
  9792. {
  9793. name: "state.name",
  9794. displayName: "状态",
  9795. width: "5%",
  9796. enableFiltering: false,
  9797. cellTemplate:
  9798. "<div>" +
  9799. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9800. "</div>",
  9801. },
  9802. {
  9803. name: "操作", //lmmm
  9804. cellTemplate:
  9805. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9806. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9807. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9808. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9809. '<a ng-click="grid.appScope.see(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[2]||row.entity.state.id==grid.appScope.stateListData[3]||grid.appScope.model.showSee">查看</a>' +
  9810. "</div></div>",
  9811. enableFiltering: false,
  9812. },
  9813. ];
  9814. // 查看
  9815. $scope.see = function (data) {
  9816. $scope.seeData = data;
  9817. var modalInstance = $modal.open({
  9818. backdrop: false,
  9819. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9820. controller: function (
  9821. $scope,
  9822. scope,
  9823. $modalInstance,
  9824. api_doc_data,
  9825. SweetAlert,
  9826. api_user_data,
  9827. api_wechatfile
  9828. ) {
  9829. $scope.personData = {}; //指派人
  9830. $scope.priorityData = {}; //优先级
  9831. $scope.personListData = {}; //指派人下拉数据
  9832. $scope.priorityListData = {}; //优先级下拉数据
  9833. $scope.startTime = ""; //开始时间
  9834. $scope.releaseShow = "no";
  9835. $scope.subShow = "no";
  9836. $scope.onlySee = "ok";
  9837. $scope.endTime = ""; //结束时间
  9838. $scope.taskDescribe = ""; //任务描述
  9839. $scope.taskDescribe = scope.seeData.taskDescribe;
  9840. $scope.personData.data = scope.seeData.assign;
  9841. $scope.priorityData.data = scope.seeData.priority;
  9842. $scope.startTime = scope.seeData.startTime;
  9843. $scope.endTime = scope.seeData.endTime;
  9844. $scope.done = scope.seeData.done;
  9845. $scope.feedback = scope.seeData.feedback;
  9846. $scope.cancel = function () {
  9847. $modalInstance.dismiss("cancel");
  9848. };
  9849. },
  9850. size: "sm",
  9851. resolve: {
  9852. scope: function () {
  9853. return $scope;
  9854. },
  9855. },
  9856. backdrop: true,
  9857. });
  9858. };
  9859. // 编辑
  9860. $scope.edit = function (data) {
  9861. $scope.editData = data;
  9862. var modalInstance = $modal.open({
  9863. backdrop: false,
  9864. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9865. controller: function (
  9866. $scope,
  9867. scope,
  9868. $modalInstance,
  9869. api_doc_data,
  9870. SweetAlert,
  9871. api_user_data,
  9872. api_wechatfile
  9873. ) {
  9874. console.log(scope.editData);
  9875. $scope.personData = {}; //指派人
  9876. $scope.priorityData = {}; //优先级
  9877. $scope.personListData = {}; //指派人下拉数据
  9878. $scope.priorityListData = {}; //优先级下拉数据
  9879. $scope.startTime = ""; //开始时间
  9880. $scope.releaseShow = "no";
  9881. $scope.endTime = ""; //结束时间
  9882. $scope.taskDescribe = ""; //任务描述
  9883. $scope.taskDescribe = scope.editData.taskDescribe;
  9884. $scope.personData.data = scope.editData.assign;
  9885. $scope.priorityData.data = scope.editData.priority;
  9886. $scope.startTime = scope.editData.startTime;
  9887. $scope.endTime = scope.editData.endTime;
  9888. // 指派人下拉框数据
  9889. $scope.getPersonData = function () {
  9890. var data = {
  9891. idx: 0,
  9892. sum: 1000,
  9893. };
  9894. api_user_data.fetchDataList("user", data).then(function (res) {
  9895. $scope.personListData = res.list;
  9896. });
  9897. };
  9898. $scope.getPersonData();
  9899. //优先级下拉数据
  9900. $scope.getPriorityData = function () {
  9901. var data = {
  9902. key: "change_rick_level",
  9903. type: "list",
  9904. };
  9905. api_wechatfile.getDictionary(data).then(function (res) {
  9906. $scope.priorityListData = res;
  9907. });
  9908. };
  9909. $scope.getPriorityData();
  9910. // 获取状态-lmm
  9911. $scope.stateListData = {};
  9912. $scope.getStateData = function () {
  9913. //lyl
  9914. var data = {
  9915. key: "task_sub_state",
  9916. type: "list",
  9917. };
  9918. api_wechatfile.getDictionary(data).then(function (res) {
  9919. angular.forEach(res, function (v, i) {
  9920. $scope.stateListData[v.value] = v.id;
  9921. });
  9922. });
  9923. };
  9924. $scope.getStateData();
  9925. //时间控件
  9926. $scope.open = function ($event) {
  9927. $event.preventDefault();
  9928. $event.stopPropagation();
  9929. $scope.opened = !$scope.opened;
  9930. };
  9931. $scope.endOpen = function ($event) {
  9932. $event.preventDefault();
  9933. $event.stopPropagation();
  9934. $scope.startOpened = false;
  9935. $scope.endOpened = !$scope.endOpened;
  9936. };
  9937. $scope.startOpen = function ($event) {
  9938. $event.preventDefault();
  9939. $event.stopPropagation();
  9940. $scope.endOpened = false;
  9941. $scope.startOpened = !$scope.startOpened;
  9942. };
  9943. // 确定
  9944. $scope.ok = function (item) {
  9945. if (
  9946. $scope.taskDescribe &&
  9947. $scope.personData.data &&
  9948. $scope.priorityData.data &&
  9949. $scope.startTime &&
  9950. $scope.endTime
  9951. ) {
  9952. $scope.startTime = moment(
  9953. new Date($scope.startTime).getTime()
  9954. ).format("YYYY-MM-DD HH:mm:ss");
  9955. $scope.endTime = moment(
  9956. new Date($scope.endTime).getTime()
  9957. ).format("YYYY-MM-DD HH:mm:ss");
  9958. $scope.addData = {
  9959. taskSub: {
  9960. taskDescribe: $scope.taskDescribe,
  9961. assign: $scope.personData.data,
  9962. priority: $scope.priorityData.data,
  9963. startTime: $scope.startTime,
  9964. endTime: $scope.endTime,
  9965. taskMonth: {
  9966. id: scope.model.taskMonth.id,
  9967. },
  9968. id: scope.editData.id,
  9969. },
  9970. };
  9971. $scope.addData.taskSub["state"] = {
  9972. id: $scope.stateListData[1],
  9973. };
  9974. api_user_data
  9975. .updData("taskSub", $scope.addData)
  9976. .then(function (res) {
  9977. if (res.status == 200) {
  9978. SweetAlert.swal({
  9979. title: "修改成功!",
  9980. type: "success",
  9981. confirmButtonColor: "#007AFF",
  9982. });
  9983. scope.refreshData(scope.jry_filterdata);
  9984. $modalInstance.dismiss("cancel");
  9985. } else {
  9986. SweetAlert.swal({
  9987. title: "修改失败",
  9988. text: "系统错误,请重试!",
  9989. type: "error",
  9990. });
  9991. $modalInstance.dismiss("cancel");
  9992. }
  9993. });
  9994. } else {
  9995. SweetAlert.swal({
  9996. title: "修改失败",
  9997. text: "必填项不能为空!",
  9998. type: "error",
  9999. });
  10000. }
  10001. };
  10002. $scope.cancel = function () {
  10003. $modalInstance.dismiss("cancel");
  10004. };
  10005. },
  10006. size: "sm",
  10007. resolve: {
  10008. scope: function () {
  10009. return $scope;
  10010. },
  10011. },
  10012. backdrop: true,
  10013. });
  10014. };
  10015. // 发布
  10016. $scope.release = function (data) {
  10017. SweetAlert.swal(
  10018. {
  10019. title: "确认发布?",
  10020. text: "请确定发布操作!",
  10021. type: "warning",
  10022. showCancelButton: true,
  10023. confirmButtonColor: "#DD6B55",
  10024. confirmButtonText: "确定",
  10025. cancelButtonText: "取消",
  10026. closeOnConfirm: false,
  10027. closeOnCancel: false,
  10028. },
  10029. function (isConfirm) {
  10030. if (isConfirm) {
  10031. data.state.id = $scope.stateListData[2];
  10032. delete data.item;
  10033. api_user_data
  10034. .updData("taskSub", {
  10035. taskSub: data,
  10036. })
  10037. .then(function (res) {
  10038. if (res.status == 200) {
  10039. SweetAlert.swal({
  10040. title: "发布成功!",
  10041. type: "success",
  10042. confirmButtonColor: "#007AFF",
  10043. });
  10044. $scope.refreshData($scope.jry_filterdata);
  10045. } else {
  10046. SweetAlert.swal({
  10047. title: "删除失败",
  10048. text: "系统错误,请重试!",
  10049. type: "error",
  10050. });
  10051. }
  10052. });
  10053. } else {
  10054. SweetAlert.swal("操作取消", "发布取消", "error");
  10055. }
  10056. }
  10057. );
  10058. };
  10059. // 删除
  10060. $scope.remove = function (data) {
  10061. SweetAlert.swal(
  10062. {
  10063. title: "确认删除?",
  10064. text: "删除的数据不可恢复,请确认继续操作!",
  10065. type: "warning",
  10066. showCancelButton: true,
  10067. confirmButtonColor: "#DD6B55",
  10068. confirmButtonText: "继续删除",
  10069. cancelButtonText: "取消操作",
  10070. closeOnConfirm: false,
  10071. closeOnCancel: false,
  10072. },
  10073. function (isConfirm) {
  10074. if (isConfirm) {
  10075. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10076. if (res.status == 200) {
  10077. SweetAlert.swal({
  10078. title: "删除成功!",
  10079. type: "success",
  10080. confirmButtonColor: "#007AFF",
  10081. });
  10082. $scope.refreshData($scope.jry_filterdata);
  10083. } else {
  10084. SweetAlert.swal({
  10085. title: "删除失败",
  10086. text: "系统错误,请重试!",
  10087. type: "error",
  10088. });
  10089. }
  10090. });
  10091. } else {
  10092. SweetAlert.swal("操作取消", "数据安全", "error");
  10093. }
  10094. }
  10095. );
  10096. };
  10097. $scope.refreshData = function (filterData) {
  10098. // $scope.ldloading[style.replace('-', '_')] = true;
  10099. if (angular.isUndefined(filterData)) {
  10100. filterData = defaultFilterData;
  10101. }
  10102. $scope.myData = [];
  10103. $scope.memoryfilterData = filterData;
  10104. api_doc_data.fetchDataList("taskSub", filterData).then(
  10105. function (data) {
  10106. var myData = data;
  10107. $scope.gridOptions.totalItems = myData.totalNum;
  10108. $scope.removeFileNum = myData.totalNum;
  10109. if (angular.isArray(myData.list)) {
  10110. $scope.myData = myData.list;
  10111. for (var i = 0; i < $scope.myData.length; i++) {
  10112. //添加序号
  10113. $scope.myData[i]["item"] =
  10114. i + 1 + filterData.idx * filterData.sum;
  10115. $scope.myData[i].startTime = moment(
  10116. $scope.myData[i].startTime
  10117. ).format("YYYY-MM-DD HH:mm:ss");
  10118. $scope.myData[i].endTime = moment(
  10119. $scope.myData[i].endTime
  10120. ).format("YYYY-MM-DD HH:mm:ss");
  10121. }
  10122. }
  10123. },
  10124. function () {
  10125. // $scope.ldloading[style.replace('-', '_')] = false;
  10126. }
  10127. );
  10128. };
  10129. //分页控制
  10130. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10131. gridApi.pagination.on.paginationChanged(
  10132. $scope,
  10133. function (newPage, pageSize) {
  10134. $scope.jry_filterdata.idx = newPage - 1;
  10135. $scope.fenye = newPage - 1;
  10136. $scope.jry_filterdata.sum = pageSize;
  10137. $scope.refreshData($scope.jry_filterdata);
  10138. }
  10139. );
  10140. };
  10141. $scope.fenye = 0;
  10142. if ($scope.model.label == "分配任务") {
  10143. $scope.jry_filterdata = {
  10144. idx: $scope.fenye,
  10145. sum: 10,
  10146. taskSub: {
  10147. taskMonth: {
  10148. id: $scope.model.taskMonth.id,
  10149. },
  10150. userid: loginUser.id,
  10151. role: loginUser.role,
  10152. },
  10153. };
  10154. } else {
  10155. $scope.jry_filterdata = {
  10156. idx: $scope.fenye,
  10157. sum: 10,
  10158. taskSub: {
  10159. taskMonth: {
  10160. id: $scope.model.taskMonth.id,
  10161. },
  10162. userid: loginUser.id,
  10163. role: loginUser.role,
  10164. type: 1,
  10165. },
  10166. };
  10167. }
  10168. $scope.refreshData($scope.jry_filterdata);
  10169. //新增模态框
  10170. $scope.newDistribution = function () {
  10171. var modalInstance = $modal.open({
  10172. backdrop: false,
  10173. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10174. controller: function (
  10175. $scope,
  10176. scope,
  10177. $modalInstance,
  10178. api_doc_data,
  10179. SweetAlert,
  10180. api_user_data,
  10181. api_wechatfile
  10182. ) {
  10183. $scope.personData = {}; //指派人
  10184. $scope.priorityData = {}; //优先级
  10185. $scope.personListData = {}; //指派人下拉数据
  10186. $scope.priorityListData = {}; //优先级下拉数据
  10187. $scope.startTime = ""; //开始时间
  10188. $scope.endTime = ""; //结束时间
  10189. $scope.taskDescribe = ""; //任务描述
  10190. $scope.motaikuang = "";
  10191. $scope.shijian = "哈哈";
  10192. // 指派人下拉框数据
  10193. $scope.getPersonData = function () {
  10194. var data = {
  10195. idx: 0,
  10196. sum: 1000,
  10197. };
  10198. api_user_data.fetchDataList("user", data).then(function (res) {
  10199. $scope.personListData = res.list;
  10200. });
  10201. };
  10202. $scope.getPersonData();
  10203. //优先级下拉数据
  10204. $scope.getPriorityData = function () {
  10205. var data = {
  10206. key: "change_rick_level",
  10207. type: "list",
  10208. };
  10209. api_wechatfile.getDictionary(data).then(function (res) {
  10210. $scope.priorityListData = res;
  10211. });
  10212. };
  10213. // 控制结束时间的最大时间
  10214. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10215. // 控制结束时间的最小时间
  10216. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10217. $scope.$watch("startTime", function (n, o) {
  10218. if (n) {
  10219. if (n > scope.model.taskMonth.startTime) {
  10220. $scope.jryEndMinTime = n;
  10221. }
  10222. }
  10223. });
  10224. // 控制开始时间的最小时间
  10225. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10226. // 控制开始时间的最大时间
  10227. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10228. $scope.$watch("endTime", function (n, o) {
  10229. if (n) {
  10230. if (n < scope.model.taskMonth.endTime) {
  10231. $scope.jryStartMaxTime = n;
  10232. }
  10233. }
  10234. });
  10235. $scope.getPriorityData();
  10236. //时间控件
  10237. $scope.open = function ($event) {
  10238. $event.preventDefault();
  10239. $event.stopPropagation();
  10240. $scope.opened = !$scope.opened;
  10241. };
  10242. $scope.endOpen = function ($event) {
  10243. $event.preventDefault();
  10244. $event.stopPropagation();
  10245. $scope.startOpened = false;
  10246. $scope.endOpened = !$scope.endOpened;
  10247. };
  10248. $scope.startOpen = function ($event) {
  10249. $event.preventDefault();
  10250. $event.stopPropagation();
  10251. $scope.endOpened = false;
  10252. $scope.startOpened = !$scope.startOpened;
  10253. };
  10254. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10255. // 获取状态-lmm
  10256. $scope.stateListData = {};
  10257. $scope.getStateData = function () {
  10258. //lyl
  10259. var data = {
  10260. key: "task_sub_state",
  10261. type: "list",
  10262. };
  10263. api_wechatfile.getDictionary(data).then(function (res) {
  10264. angular.forEach(res, function (v, i) {
  10265. $scope.stateListData[v.value] = v.id;
  10266. });
  10267. });
  10268. };
  10269. $scope.getStateData();
  10270. // 草稿保存
  10271. $scope.ok = function (item) {
  10272. if (
  10273. $scope.taskDescribe &&
  10274. $scope.personData.data &&
  10275. $scope.priorityData.data &&
  10276. $scope.startTime &&
  10277. $scope.endTime
  10278. ) {
  10279. $scope.startTime = moment(
  10280. new Date($scope.startTime).getTime()
  10281. ).format("YYYY-MM-DD HH:mm:ss");
  10282. $scope.endTime = moment(
  10283. new Date($scope.endTime).getTime()
  10284. ).format("YYYY-MM-DD HH:mm:ss");
  10285. $scope.addData = {
  10286. taskSub: {
  10287. taskDescribe: $scope.taskDescribe,
  10288. assign: $scope.personData.data,
  10289. priority: $scope.priorityData.data,
  10290. startTime: $scope.startTime,
  10291. endTime: $scope.endTime,
  10292. taskMonth: {
  10293. id: scope.model.taskMonth.id,
  10294. },
  10295. },
  10296. };
  10297. $scope.addData.taskSub["state"] = {
  10298. id: $scope.stateListData[1],
  10299. };
  10300. api_user_data
  10301. .addData("taskSub", $scope.addData)
  10302. .then(function (res) {
  10303. if (res.status == 200) {
  10304. SweetAlert.swal({
  10305. title: "保存成功!",
  10306. type: "success",
  10307. confirmButtonColor: "#007AFF",
  10308. });
  10309. scope.refreshData(scope.jry_filterdata);
  10310. $modalInstance.dismiss("cancel");
  10311. } else {
  10312. SweetAlert.swal({
  10313. title: "保存失败",
  10314. text: "系统错误,请重试!",
  10315. type: "error",
  10316. });
  10317. $modalInstance.dismiss("cancel");
  10318. }
  10319. });
  10320. } else {
  10321. SweetAlert.swal({
  10322. title: "保存失败",
  10323. text: "必填项不能为空!",
  10324. type: "error",
  10325. });
  10326. }
  10327. };
  10328. // 发布
  10329. $scope.release = function () {
  10330. if (
  10331. $scope.taskDescribe &&
  10332. $scope.personData.data &&
  10333. $scope.priorityData.data &&
  10334. $scope.startTime &&
  10335. $scope.endTime
  10336. ) {
  10337. $scope.startTime = moment(
  10338. new Date($scope.startTime).getTime()
  10339. ).format("YYYY-MM-DD HH:mm:ss");
  10340. $scope.endTime = moment(
  10341. new Date($scope.endTime).getTime()
  10342. ).format("YYYY-MM-DD HH:mm:ss");
  10343. $scope.addData = {
  10344. taskSub: {
  10345. taskDescribe: $scope.taskDescribe,
  10346. assign: $scope.personData.data,
  10347. priority: $scope.priorityData.data,
  10348. startTime: $scope.startTime,
  10349. endTime: $scope.endTime,
  10350. taskMonth: {
  10351. id: scope.model.taskMonth.id,
  10352. },
  10353. },
  10354. };
  10355. $scope.addData.taskSub["state"] = {
  10356. id: $scope.stateListData[1],
  10357. };
  10358. api_user_data
  10359. .addData("taskSub", $scope.addData)
  10360. .then(function (res) {
  10361. if (res.status == 200) {
  10362. SweetAlert.swal({
  10363. title: "保存成功!",
  10364. type: "success",
  10365. confirmButtonColor: "#007AFF",
  10366. });
  10367. scope.refreshData(scope.jry_filterdata);
  10368. $modalInstance.dismiss("cancel");
  10369. } else {
  10370. SweetAlert.swal({
  10371. title: "保存失败",
  10372. text: "系统错误,请重试!",
  10373. type: "error",
  10374. });
  10375. $modalInstance.dismiss("cancel");
  10376. }
  10377. });
  10378. } else {
  10379. SweetAlert.swal({
  10380. title: "保存失败",
  10381. text: "必填项不能为空!",
  10382. type: "error",
  10383. });
  10384. }
  10385. };
  10386. $scope.cancel = function () {
  10387. $modalInstance.dismiss("cancel");
  10388. };
  10389. },
  10390. size: "sm",
  10391. resolve: {
  10392. scope: function () {
  10393. return $scope;
  10394. },
  10395. },
  10396. backdrop: true,
  10397. });
  10398. };
  10399. },
  10400. });
  10401. // 多次反馈文本域组件--jry
  10402. formlyConfigProvider.setType({
  10403. name: "ui-feedbacktTextarea",
  10404. extends: "textarea",
  10405. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10406. defaultOptions: function (options) {
  10407. return {
  10408. templateOptions: {
  10409. transform: function (model, value) {
  10410. return value;
  10411. },
  10412. },
  10413. validation: {
  10414. messages: {
  10415. maxlength: function (viewValue, modelValue, scope) {
  10416. if (viewValue != null) {
  10417. if (viewValue.length > scope.to.maxlength) {
  10418. return (
  10419. scope.to.label +
  10420. " 字数(" +
  10421. viewValue.length +
  10422. ")超限(" +
  10423. scope.to.maxlength +
  10424. ")"
  10425. );
  10426. } else {
  10427. return "";
  10428. }
  10429. }
  10430. },
  10431. },
  10432. },
  10433. };
  10434. },
  10435. controller: [
  10436. "$scope",
  10437. "moment",
  10438. function ($scope, moment) {
  10439. // console.log($scope);
  10440. var timeKey = $scope.options.templateOptions.time;
  10441. $scope.time = moment($scope.model[timeKey]).format(
  10442. "YYYY-MM-DD HH:mm:ss"
  10443. );
  10444. var value = $scope.model[$scope.options.key];
  10445. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10446. $scope.model[$scope.options.key] =
  10447. $scope.options.templateOptions.transform(
  10448. $scope.originalModel,
  10449. value
  10450. );
  10451. }
  10452. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10453. $scope.options.templateOptions.felditem($scope);
  10454. }
  10455. },
  10456. ],
  10457. });
  10458. //任务管理开始时间--jry
  10459. formlyConfigProvider.setType({
  10460. name: "ui-jryStartdatepicker",
  10461. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10462. extends: "input",
  10463. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10464. defaultOptions: {
  10465. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10466. templateOptions: {
  10467. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10468. },
  10469. },
  10470. controller: [
  10471. "$scope",
  10472. "$filter",
  10473. function ($scope, $filter) {
  10474. // console.log($scope.model[$scope.options.key],'lmm');
  10475. $scope.mindata = new Date(
  10476. $scope.options.templateOptions.transform($scope.model).getTime() +
  10477. 5 * 60 * 1000
  10478. );
  10479. if ($scope.model[$scope.options.key]) {
  10480. $scope.model[$scope.options.key] = $filter("date")(
  10481. $scope.model[$scope.options.key],
  10482. $scope.options.templateOptions.datepickerPopup
  10483. );
  10484. }
  10485. // console.log($scope.model[$scope.options.key],'lmm');
  10486. // console.log($scope.model,'lmm',$scope.options.key);
  10487. $scope.options.initialValue = $scope.model[$scope.options.key];
  10488. $scope.endOpen = true;
  10489. $scope.datepicker = {};
  10490. $scope.datepicker.opened = false;
  10491. $scope.datepicker.open = function ($event) {
  10492. $scope.datepicker.opened = true;
  10493. };
  10494. },
  10495. ],
  10496. });
  10497. //任务管理结束时间--jry
  10498. formlyConfigProvider.setType({
  10499. name: "ui-jryEnddatepicker",
  10500. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10501. extends: "input",
  10502. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10503. defaultOptions: {
  10504. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10505. templateOptions: {
  10506. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10507. },
  10508. },
  10509. controller: [
  10510. "$scope",
  10511. "$filter",
  10512. function ($scope, $filter) {
  10513. $scope.mindata = new Date(
  10514. $scope.options.templateOptions.transform($scope.model).getTime() +
  10515. 5 * 60 * 1000
  10516. );
  10517. if ($scope.model[$scope.options.key]) {
  10518. $scope.model[$scope.options.key] = $filter("date")(
  10519. $scope.model[$scope.options.key],
  10520. $scope.options.templateOptions.datepickerPopup
  10521. );
  10522. }
  10523. $scope.options.initialValue = $scope.model[$scope.options.key];
  10524. $scope.endOpen = true;
  10525. $scope.datepicker = {};
  10526. $scope.datepicker.opened = false;
  10527. $scope.datepicker.open = function ($event) {
  10528. $scope.datepicker.opened = true;
  10529. };
  10530. },
  10531. ],
  10532. });
  10533. //下拉多选框灵活组件--jry
  10534. formlyConfigProvider.setType({
  10535. name: "ui-jry_multiselectplus",
  10536. extends: "multiCheckbox",
  10537. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10538. defaultOptions: function (options) {
  10539. return {
  10540. templateOptions: {
  10541. refreshData: function (search, options, model, that) {
  10542. // var process = options.templateOptions.ApiService.all("");
  10543. if (search) {
  10544. } else {
  10545. }
  10546. var postData = options.templateOptions.optionsPostData;
  10547. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10548. postData = options.templateOptions.optionsPostData(
  10549. options,
  10550. model,
  10551. that
  10552. );
  10553. }
  10554. options.templateOptions.ApiService.fetchDataList(
  10555. options.templateOptions.optionsUrl,
  10556. options.templateOptions.optionsPostData
  10557. ).then(function (result) {
  10558. // if (!options.templateOptions.options) {
  10559. // options.templateOptions.options = [];
  10560. // }
  10561. if (options.templateOptions.optionsDataKey) {
  10562. options.templateOptions.options =
  10563. result[options.templateOptions.optionsDataKey];
  10564. } else {
  10565. options.templateOptions.options = result;
  10566. }
  10567. if (options.templateOptions.optionsChecked) {
  10568. // return options.value = null;
  10569. options.value(options.model[options.key]);
  10570. }
  10571. });
  10572. },
  10573. refreshDelay: 0,
  10574. // },
  10575. validators: {
  10576. required: {
  10577. expression: function (viewValue, modelValue) {
  10578. var value = modelValue || viewValue;
  10579. return value != null;
  10580. // return value.length>=1;
  10581. // if (modelValue && viewValue) {
  10582. // return value != null;
  10583. // } else {
  10584. // var value = modelValue || viewValue;
  10585. // return value.length > 0;
  10586. // }
  10587. },
  10588. },
  10589. },
  10590. },
  10591. };
  10592. },
  10593. controller: [
  10594. "$scope",
  10595. function ($scope) {
  10596. console.log($scope.to);
  10597. if (angular.isArray($scope.model[$scope.options.key])) {
  10598. } else {
  10599. $scope.model[$scope.options.key] = [];
  10600. }
  10601. },
  10602. ],
  10603. });
  10604. //下拉框组件
  10605. formlyConfigProvider.setType({
  10606. name: "ui-select",
  10607. extends: "select",
  10608. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10609. defaultOptions: function (options, scope) {
  10610. return {
  10611. templateOptions: {
  10612. // refresh: function() {},
  10613. getScope: function () {
  10614. return scope;
  10615. },
  10616. refreshDelay: 0,
  10617. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10618. //POST
  10619. console.log(model, "model");
  10620. angular.extend(data, {
  10621. idx: 0,
  10622. sum: 1000,
  10623. });
  10624. options.templateOptions.APIService.fetchDataList(
  10625. modelName,
  10626. data
  10627. ).then(function (response) {
  10628. var myData =
  10629. options.templateOptions.Restangular.stripRestangular(response);
  10630. var list = myData.list;
  10631. console.log(myData);
  10632. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10633. // console.log('balabalabala');
  10634. // console.log(res);
  10635. // })
  10636. if (list.length == 1) {
  10637. if (options.templateOptions.APIport) {
  10638. options.templateOptions.APIport.expectedTime(
  10639. "L" + list[0][key].id
  10640. ).then(function (response) {
  10641. if (response.state == "200") {
  10642. // if (model.$parent.model && model.$parent.model.incident) {
  10643. // } else {
  10644. // model.$parent.model = { 'incident': {} };
  10645. // }
  10646. var myDatas = response.serviceLevelAgreement;
  10647. //逾期
  10648. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10649. response.date;
  10650. //解决
  10651. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10652. myDatas.resolveTime;
  10653. //响应
  10654. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10655. myDatas.responseTime;
  10656. } else {
  10657. }
  10658. });
  10659. }
  10660. angular.forEach(model.fields, function (item) {
  10661. angular.forEach(model.fields, function (item) {
  10662. if (item.templateOptions.pkey == modelKey + "." + key) {
  10663. item.model.id = "";
  10664. if (key == "place") {
  10665. item.templateOptions.options = list;
  10666. } else if (key == "placeDTO") {
  10667. item.templateOptions.options = list;
  10668. } else if (key == "requester") {
  10669. } else {
  10670. item.value(list[0][key][item.key]);
  10671. }
  10672. }
  10673. });
  10674. });
  10675. } else {
  10676. if (model.fields) {
  10677. angular.forEach(model.fields, function (item) {
  10678. angular.forEach(model.fields, function (item) {
  10679. if (item.templateOptions.pkey == modelKey + "." + key) {
  10680. item.model.id = "";
  10681. if (key == "place") {
  10682. item.templateOptions.isnosearch = true;
  10683. item.templateOptions.options = list;
  10684. }
  10685. if (key == "placeDTO") {
  10686. item.templateOptions.options = list;
  10687. }
  10688. if (key == "requester") {
  10689. }
  10690. }
  10691. });
  10692. });
  10693. } else {
  10694. angular.forEach(
  10695. scope.$parent.$parent.$parent.fields,
  10696. function (item) {
  10697. angular.forEach(
  10698. scope.$parent.$parent.$parent.fields,
  10699. function (item) {
  10700. if (
  10701. item.templateOptions.pkey ==
  10702. modelKey + "." + key
  10703. ) {
  10704. if (key == "place") {
  10705. item.templateOptions.isnosearch = true;
  10706. item.templateOptions.options = list;
  10707. scope.$parent.$parent.$parent.model.incident.place =
  10708. model.incident.place;
  10709. }
  10710. if (key == "placeDTO") {
  10711. item.templateOptions.options = list;
  10712. }
  10713. if (key == "requester") {
  10714. }
  10715. }
  10716. }
  10717. );
  10718. }
  10719. );
  10720. }
  10721. }
  10722. console.log(key);
  10723. //报修科室
  10724. if (key == "dept") {
  10725. // 报修科室单选
  10726. scope.$parent.$parent.$parent.model.incident.department =
  10727. response.list[0];
  10728. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10729. response.list[0].phone;
  10730. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10731. // 选择重复事件侧滑框
  10732. scope.$parent.$parent.$parent.model[
  10733. "repeatIncidentShow"
  10734. ] = false;
  10735. setTimeout(() => {
  10736. scope.$parent.$parent.$parent.model[
  10737. "repeatIncidentShow"
  10738. ] = true;
  10739. }, 500);
  10740. }
  10741. // 报修人
  10742. if (key == "requester") {
  10743. // 报修人单选
  10744. scope.$parent.$parent.$parent.model.incident.requester =
  10745. response.list[0];
  10746. console.log(scope.$parent.$parent.$parent.model);
  10747. scope.$parent.$parent.$parent.model.incident.account =
  10748. response.list[0].account;
  10749. var selectedItem = response.list[0];
  10750. var data = {
  10751. requester: selectedItem,
  10752. };
  10753. scope.$parent.$parent.$parent.model["requestershow"] =
  10754. selectedItem;
  10755. console.log(selectedItem, "----------------------");
  10756. // if (selectedItem.dept.place.place) {
  10757. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10758. // }
  10759. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10760. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10761. scope.$parent.$parent.$parent.model.incident.area.id =
  10762. selectedItem.place ? selectedItem.place.area.id : null;
  10763. scope.$parent.$parent.$parent.model.incident.place.id =
  10764. selectedItem.place ? selectedItem.place.id : null;
  10765. console.log(scope, 89898998);
  10766. // console.log(scope.formData,'接单页面');
  10767. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10768. scope.model.selecthouseNumber = selectedItem.place
  10769. ? selectedItem.place
  10770. : {};
  10771. scope.$root.selecthouseNumber = selectedItem.place
  10772. ? selectedItem.place
  10773. : {};
  10774. options.templateOptions.ApiService.addData(
  10775. "requester",
  10776. data
  10777. ).then(function (response) {
  10778. if (response.status == 200) {
  10779. if (scope.$parent.$parent.$parent) {
  10780. if (scope.$parent.$parent.$parent.place) {
  10781. scope.$parent.$parent.$parent.place.id = "";
  10782. }
  10783. if (scope.$parent.$parent.$parent.area) {
  10784. scope.$parent.$parent.$parent.area.id = "";
  10785. }
  10786. scope.$parent.$parent.$parent.model.incident.contacts =
  10787. selectedItem.name;
  10788. if (
  10789. selectedItem.mphone &&
  10790. selectedItem.mphone != null &&
  10791. selectedItem.mphone != ""
  10792. ) {
  10793. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10794. selectedItem.mphone;
  10795. } else {
  10796. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10797. selectedItem.telephone;
  10798. }
  10799. if (
  10800. selectedItem.requesterTypeDTO &&
  10801. selectedItem.requesterTypeDTO.id == 2
  10802. ) {
  10803. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10804. }
  10805. }
  10806. if (!response.data.id) {
  10807. response.data.id = selectedItem.id;
  10808. }
  10809. console.log(scope);
  10810. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10811. // if (selectedItem.place && selectedItem.place.id) {
  10812. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10813. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10814. // };
  10815. // } else {
  10816. // if (selectedItem.place && selectedItem.place.id) {
  10817. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10818. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10819. // };
  10820. // }
  10821. // if(scope.$parent.$parent.$parent.model.incident.area){
  10822. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10823. // }
  10824. if (selectedItem.id) {
  10825. scope.$parent.$parent.$parent.model.incident.account =
  10826. selectedItem.account;
  10827. }
  10828. // 选择重复事件侧滑框
  10829. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10830. scope.$parent.$parent.$parent.model[
  10831. "repeatIncidentShow"
  10832. ] = false;
  10833. setTimeout(() => {
  10834. scope.$parent.$parent.$parent.model[
  10835. "repeatIncidentShow"
  10836. ] = true;
  10837. }, 500);
  10838. // }
  10839. }
  10840. });
  10841. }
  10842. //新建事件,选择派单,选择工作组查找处理人baba
  10843. if (key == "handlerUser") {
  10844. model.fields.forEach(function (v) {
  10845. if (v.templateOptions.pkey == "incident.handlerUser") {
  10846. v.templateOptions.options = list;
  10847. if (model.model.incident.handlerUser) {
  10848. if (model.model.incident.handlerUser.id) {
  10849. var flag = list.some(function (v) {
  10850. return v.id == model.model.incident.handlerUser.id;
  10851. });
  10852. if (flag) {
  10853. v.model.id = model.model.incident.handlerUser.id;
  10854. }
  10855. }
  10856. }
  10857. }
  10858. });
  10859. }
  10860. });
  10861. },
  10862. validators: {
  10863. required: {
  10864. expression: function (viewValue, modelValue) {
  10865. var value = modelValue || viewValue;
  10866. return value != null;
  10867. // return value.length>=1;
  10868. // if (modelValue && viewValue) {
  10869. // return value != null;
  10870. // } else {
  10871. // var value = modelValue || viewValue;
  10872. // return value.length > 0;
  10873. // }
  10874. },
  10875. },
  10876. },
  10877. },
  10878. controller: [
  10879. "$scope",
  10880. "$rootScope",
  10881. "api_bpm_domain",
  10882. function ($scope, $rootScope, api_bpm_domain) {
  10883. // $scope.myFilter = function(item) {
  10884. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10885. // }
  10886. console.log($scope, "风浪");
  10887. //工作组添加全部选项
  10888. // if($scope.options.templateOptions.label == '工作组'){
  10889. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10890. // $scope.model._group = 0;
  10891. // }
  10892. if (
  10893. $scope.options.templateOptions.pkey &&
  10894. $scope.options.templateOptions.pkey == "incident.place"
  10895. ) {
  10896. if (
  10897. $scope.$parent &&
  10898. $scope.$parent.$parent.$parent.model &&
  10899. $scope.$parent.$parent.$parent.model.incident.area &&
  10900. $scope.$parent.$parent.$parent.model.incident.area.id
  10901. ) {
  10902. $scope.options.templateOptions.linkage(
  10903. "place",
  10904. {
  10905. place: {
  10906. areaId:
  10907. $scope.$parent.$parent.$parent.model.incident.area.id,
  10908. // area:{
  10909. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  10910. // }
  10911. },
  10912. },
  10913. $scope.$parent.$parent.$parent.model,
  10914. "incident",
  10915. "place"
  10916. );
  10917. }
  10918. }
  10919. $scope.myFilter = $scope;
  10920. // console.log($scope.options.templateOptions)
  10921. console.log($scope, 77777);
  10922. //处理人根据事件分类自动带入baba
  10923. if ($scope.options.templateOptions.pkey == "incident.handlerUser") {
  10924. console.log($scope.options.templateOptions.pkey);
  10925. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  10926. if (
  10927. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  10928. ) {
  10929. $scope.$parent.$parent.$parent.model.assignee =
  10930. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  10931. $scope.options.model.id =
  10932. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  10933. }
  10934. }
  10935. }
  10936. // 关闭事件页面满意度评价下拉框处理
  10937. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  10938. $scope.model.id =
  10939. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  10940. }
  10941. if ($scope.options.templateOptions.initData == 1) {
  10942. $scope.options.templateOptions.onChange(
  10943. $scope.model.id,
  10944. $scope.options,
  10945. $scope
  10946. );
  10947. }
  10948. if ($scope.options.templateOptions.transform) {
  10949. $scope.options.templateOptions.onChange(
  10950. $scope.model.id,
  10951. $scope.options,
  10952. $scope
  10953. );
  10954. }
  10955. if (angular.isFunction($scope.options.templateOptions.translate)) {
  10956. $scope.model[$scope.options.key] =
  10957. $scope.options.templateOptions.translate(
  10958. $scope.options,
  10959. $rootScope,
  10960. $scope
  10961. );
  10962. }
  10963. if (
  10964. angular.isFunction($scope.options.templateOptions.translatefunc)
  10965. ) {
  10966. $scope.model[$scope.options.key] =
  10967. $scope.options.templateOptions.translatefunc(
  10968. $scope.options,
  10969. $rootScope,
  10970. $scope
  10971. );
  10972. }
  10973. if (
  10974. angular.isFunction($scope.options.templateOptions.onlyfunction)
  10975. ) {
  10976. $scope.options.templateOptions.onlyfunction(
  10977. $scope.options,
  10978. $rootScope,
  10979. $scope
  10980. );
  10981. }
  10982. },
  10983. ],
  10984. };
  10985. },
  10986. });
  10987. //下拉多选框组件
  10988. formlyConfigProvider.setType({
  10989. name: "ui-multiselect",
  10990. extends: "select",
  10991. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  10992. defaultOptions: function (options) {
  10993. return {
  10994. templateOptions: {
  10995. refresh: function () {},
  10996. refreshDelay: 1000,
  10997. },
  10998. };
  10999. },
  11000. controller: [
  11001. "$scope",
  11002. function ($scope) {
  11003. $scope.model[$scope.options.key] = [];
  11004. },
  11005. ],
  11006. });
  11007. //下拉多选框灵活组件
  11008. formlyConfigProvider.setType({
  11009. name: "ui-multiselectplus",
  11010. extends: "multiCheckbox",
  11011. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11012. defaultOptions: function (options, $scope) {
  11013. return {
  11014. templateOptions: {
  11015. refreshData: function (search, options, model, that) {
  11016. var process = options.templateOptions.ApiService.all("");
  11017. if (search) {
  11018. } else {
  11019. }
  11020. var postData = options.templateOptions.optionsPostData;
  11021. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11022. postData = options.templateOptions.optionsPostData(
  11023. options,
  11024. model,
  11025. that
  11026. );
  11027. }
  11028. if (options.templateOptions.modelreasondata) {
  11029. postData = options.templateOptions.modelreasondata;
  11030. }
  11031. process
  11032. .customPOST(postData, options.templateOptions.optionsUrl)
  11033. .then(function (result) {
  11034. // if (!options.templateOptions.options) {
  11035. // options.templateOptions.options = [];
  11036. // }
  11037. // 过滤下拉列表已选择的值
  11038. var modelVal = $scope.model[$scope.options.key];
  11039. for (var i = 0; i < modelVal.length; i++) {
  11040. for (var j = 0; j < result.list.length; j++) {
  11041. if (result.list[j].id == modelVal[i].id) {
  11042. result.list.splice(j, 1);
  11043. }
  11044. }
  11045. }
  11046. if (options.templateOptions.optionsDataKey) {
  11047. options.templateOptions.options =
  11048. result[options.templateOptions.optionsDataKey];
  11049. } else {
  11050. options.templateOptions.options = result;
  11051. }
  11052. if (options.templateOptions.optionsChecked) {
  11053. // return options.value = null;
  11054. options.value(options.model[options.key]);
  11055. }
  11056. });
  11057. },
  11058. refreshDelay: 0,
  11059. // },
  11060. // validators: {
  11061. // required: {
  11062. // expression: function(viewValue, modelValue) {
  11063. // var value = modelValue || viewValue;
  11064. // // return value.length>=1;
  11065. // // if (modelValue && viewValue) {
  11066. // // return value != null;
  11067. // // } else {
  11068. // // var value = modelValue || viewValue;
  11069. // // return value.length > 0;
  11070. // // }
  11071. // }
  11072. // }
  11073. },
  11074. };
  11075. },
  11076. controller: [
  11077. "$scope",
  11078. function ($scope) {
  11079. if (angular.isArray($scope.model[$scope.options.key])) {
  11080. } else {
  11081. $scope.model[$scope.options.key] = [];
  11082. }
  11083. },
  11084. ],
  11085. });
  11086. //下拉树形多选组件
  11087. formlyConfigProvider.setType({
  11088. name: "ui-multiselect-tree",
  11089. extends: "multiCheckbox",
  11090. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11091. defaultOptions: function (options) {
  11092. return {
  11093. templateOptions: {
  11094. linkage: function (modelName, data, model, modelKey, key) {
  11095. angular.extend(data, {
  11096. idx: 0,
  11097. sum: 10,
  11098. });
  11099. options.templateOptions.APIService.fetchDataList(
  11100. modelName,
  11101. data
  11102. ).then(function (response) {
  11103. var myData =
  11104. options.templateOptions.Restangular.stripRestangular(response);
  11105. var list = myData.list;
  11106. if (list.length == 1) {
  11107. angular.forEach(model.fields, function (item) {
  11108. angular.forEach(model.fields, function (item) {
  11109. if (item.templateOptions.pkey == modelKey + "." + key) {
  11110. item.model.id = "";
  11111. if (key == "place") {
  11112. item.templateOptions.options = list;
  11113. } else {
  11114. item.value(list[0][key][item.key]);
  11115. }
  11116. }
  11117. });
  11118. });
  11119. }
  11120. });
  11121. },
  11122. // my_tree_handler : function(items) {
  11123. // },
  11124. // onFilterCallback : function(items) {
  11125. // },
  11126. // onFilterCallback : function(items) {
  11127. // },
  11128. refresh: function (items) {
  11129. var treedata = [];
  11130. function convertListToTree(data, treeMap) {
  11131. treedata = data;
  11132. for (var i = 0; i < data.length; i++) {
  11133. for (var j = 0; j < data.length; j++) {
  11134. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11135. if (data[i].pid == data[j].id) {
  11136. data[i].parent = data[j];
  11137. }
  11138. }
  11139. }
  11140. }
  11141. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11142. var root = null; //Initially set our loop to null
  11143. //loop over data
  11144. for (var i = 0; i < data.length; i++) {
  11145. var datum = data[i];
  11146. //each node will have children, so let's give it a "children" poperty
  11147. datum.children = [];
  11148. //add an entry for this node to the map so that any future children can
  11149. //lookup the parent
  11150. idToNodeMap[datum.id] = datum;
  11151. //Does this node have a parent?
  11152. if (
  11153. typeof datum.parent === "undefined" ||
  11154. datum.parent === null
  11155. ) {
  11156. //Doesn't look like it, so this node is the root of the tree
  11157. root = datum;
  11158. treeMap[datum.id] = root;
  11159. } else {
  11160. //This node has a parent, so let's look it up using the id
  11161. parentNode = idToNodeMap[datum.parent.id];
  11162. //We don't need this property, so let's delete it.
  11163. delete datum.parent;
  11164. //Let's add the current node as a child of the parent node.
  11165. parentNode.children.push(datum);
  11166. }
  11167. }
  11168. return root;
  11169. }
  11170. function convertParentToChildList(data) {
  11171. // console.log("data="+JSON.stringify(data))
  11172. var treeMap = {};
  11173. var list = [];
  11174. convertListToTree(data, treeMap);
  11175. angular.forEach(treeMap, function (item) {
  11176. list.push(item);
  11177. });
  11178. return list;
  11179. }
  11180. function selectItem(pmodel, childrens) {
  11181. if (angular.isArray(pmodel)) {
  11182. angular.forEach(pmodel, function (index) {
  11183. if (index && index.id) {
  11184. angular.forEach(childrens, function (item) {
  11185. if (item.id == index.id) {
  11186. item.selected = true;
  11187. }
  11188. if (item && item.children) {
  11189. selectItem(pmodel, item.children);
  11190. }
  11191. });
  11192. }
  11193. });
  11194. } else {
  11195. if (pmodel && pmodel.id) {
  11196. angular.forEach(childrens, function (item) {
  11197. if (item.id == pmodel.id) {
  11198. item.selected = true;
  11199. }
  11200. if (item && item.children) {
  11201. selectItem(pmodel, item.children);
  11202. }
  11203. });
  11204. }
  11205. }
  11206. }
  11207. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11208. options.templateOptions
  11209. .refreshData(options.templateOptions.APIService)
  11210. .then(function (result) {
  11211. if (result.status == 200) {
  11212. if (!options.templateOptions.options) {
  11213. options.templateOptions.options = [];
  11214. }
  11215. if (options.templateOptions.optionsDataKey) {
  11216. options.templateOptions.options = convertParentToChildList(
  11217. result[options.templateOptions.optionsDataKey]
  11218. );
  11219. } else {
  11220. options.templateOptions.options =
  11221. convertParentToChildList(result);
  11222. }
  11223. //set default value
  11224. var pmodel,
  11225. i = 0;
  11226. if (options.templateOptions.pkey) {
  11227. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11228. angular.forEach(
  11229. options.templateOptions.pkey.split("."),
  11230. function (p) {
  11231. if (i == 0) {
  11232. if (options.model[p] == null) {
  11233. options.model[p] = {};
  11234. }
  11235. pmodel = options.model[p];
  11236. i++;
  11237. } else {
  11238. if (pmodel[p] == null) {
  11239. pmodel[p] = {};
  11240. }
  11241. pmodel = pmodel[p];
  11242. }
  11243. }
  11244. );
  11245. } else {
  11246. pmodel = options.model;
  11247. }
  11248. }
  11249. if (pmodel) {
  11250. pmodel = pmodel[options.key];
  11251. } else if (options.model) {
  11252. pmodel = options.model[options.key];
  11253. } else {
  11254. pmodel = options.templateOptions.options;
  11255. }
  11256. if (angular.isArray(pmodel)) {
  11257. if (pmodel) {
  11258. // if(options.templateOptions.isMultiSelect==true){
  11259. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11260. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11261. // })
  11262. // }else{
  11263. selectItem(pmodel, options.templateOptions.options);
  11264. // }
  11265. }
  11266. } else {
  11267. if (pmodel && pmodel.id) {
  11268. selectItem(pmodel, options.templateOptions.options);
  11269. }
  11270. }
  11271. items.inputModel = options.templateOptions.options;
  11272. }
  11273. });
  11274. },
  11275. },
  11276. validators: {
  11277. required: {
  11278. expression: function (viewValue, modelValue) {
  11279. var value = modelValue || viewValue;
  11280. if (angular.isArray(value)) {
  11281. for (var i = 0; i < value.length; i++) {
  11282. value[i] = {
  11283. id: value[i].id,
  11284. };
  11285. }
  11286. return value.length > 0;
  11287. } else {
  11288. // console.log(options)
  11289. // return value = "true";
  11290. return value != null;
  11291. }
  11292. },
  11293. },
  11294. },
  11295. };
  11296. },
  11297. controller: [
  11298. "$scope",
  11299. "api_configure_form",
  11300. function ($scope, api_configure_form) {
  11301. if ($scope.options.templateOptions.isMultiSelect) {
  11302. // console.log($scope);
  11303. } else {
  11304. if ($scope.model[$scope.options.key]) {
  11305. }
  11306. }
  11307. },
  11308. ],
  11309. });
  11310. //多选下拉框组件
  11311. formlyConfigProvider.setType({
  11312. name: "ui-multi-select-tree",
  11313. extends: "input",
  11314. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11315. defaultOptions: function (options) {
  11316. return {
  11317. templateOptions: {
  11318. linkage: function (modelName, data, model, modelKey, key) {
  11319. angular.extend(data, {
  11320. idx: 0,
  11321. sum: 10,
  11322. });
  11323. options.templateOptions.APIService.fetchDataList(
  11324. modelName,
  11325. data
  11326. ).then(function (response) {
  11327. var myData =
  11328. options.templateOptions.Restangular.stripRestangular(response);
  11329. var list = myData.list;
  11330. if (list.length == 1) {
  11331. angular.forEach(model.fields, function (item) {
  11332. angular.forEach(model.fields, function (item) {
  11333. if (item.templateOptions.pkey == modelKey + "." + key) {
  11334. item.model.id = "";
  11335. if (key == "place") {
  11336. item.templateOptions.options = list;
  11337. } else {
  11338. item.value(list[0][key][item.key]);
  11339. }
  11340. }
  11341. });
  11342. });
  11343. }
  11344. });
  11345. },
  11346. getparentdata: function (items) {
  11347. // console.log(items)
  11348. },
  11349. refresh: function (items, search, fn) {
  11350. console.log(items);
  11351. var treedata = [];
  11352. function convertListToTree(data, treeMap) {
  11353. // console.log(data)
  11354. treedata = data;
  11355. for (var i = 0; i < data.length; i++) {
  11356. for (var j = 0; j < data.length; j++) {
  11357. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11358. if (data[i].pid == data[j].id) {
  11359. data[i].parent = data[j];
  11360. }
  11361. }
  11362. // if (data[i].id) {
  11363. // if (data[i].id== data[j].id) {
  11364. // data[i].parent = data[j];
  11365. // }
  11366. // }
  11367. }
  11368. }
  11369. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11370. var root = []; //Initially set our loop to null
  11371. if (search == "search" && items.filterKeyword) {
  11372. function transform(nodes) {
  11373. var treeConverter = {
  11374. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11375. attributeName: "id", //节点唯一标识符
  11376. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11377. transform: function (node) {
  11378. //转化递归函数,参数:一个待插入节点
  11379. if (node.parent != null) {
  11380. //该节点有父节点
  11381. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11382. if (this.needFind) {
  11383. for (var i = 0; i < newNode.children.length; i++) {
  11384. //查找要插入的node子节点是否在newNode这个父节点中存在
  11385. if (
  11386. newNode.children[i][this.attributeName] ===
  11387. node[this.attributeName]
  11388. ) {
  11389. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11390. }
  11391. }
  11392. }
  11393. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11394. // delete node.parent; //删除该节点的parent属性,如果有的话
  11395. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11396. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11397. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11398. } else if (node.parent == null) {
  11399. //该叶节点没有父节点,即为根节点
  11400. // delete node.parent; //删除该节点的parent属性,如果有的话
  11401. if (this.result == null) {
  11402. //根节点不存在
  11403. node.children = []; //给该节点增加children:[]属性
  11404. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11405. } else {
  11406. node.children = [];
  11407. // 顶级去重
  11408. for (
  11409. var i = 0;
  11410. i < this.result.children.length;
  11411. i++
  11412. ) {
  11413. if (
  11414. this.result.children[i][this.attributeName] ===
  11415. node[this.attributeName]
  11416. ) {
  11417. return this.result.children[i];
  11418. }
  11419. }
  11420. this.result.children.push(node);
  11421. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11422. }
  11423. }
  11424. },
  11425. getWhole: function (nodes, attributeName) {
  11426. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11427. var _node = {};
  11428. _node.children = [];
  11429. this.result = _node; //重置根节点
  11430. this.attributeName =
  11431. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11432. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11433. nodes.forEach((item) => {
  11434. //循环调用转化方法
  11435. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11436. this.transform(item);
  11437. });
  11438. return this.result; //返回根节点
  11439. },
  11440. };
  11441. var result = treeConverter.getWhole(nodes); //调用
  11442. return result;
  11443. }
  11444. var li = transform(data).children;
  11445. // li=[...new Set(li)]
  11446. console.log(li);
  11447. treeMap = li;
  11448. fn(li);
  11449. return li;
  11450. } else {
  11451. //loop over data
  11452. for (var i = 0; i < data.length; i++) {
  11453. var datum = data[i];
  11454. //each node will have children, so let's give it a "children" poperty
  11455. datum.children = [];
  11456. //add an entry for this node to the map so that any future children can
  11457. //lookup the parent
  11458. idToNodeMap[datum.id] = datum;
  11459. //Does this node have a parent?
  11460. if (
  11461. typeof datum.parent === "undefined" ||
  11462. datum.parent === null
  11463. ) {
  11464. //Doesn't look like it, so this node is the root of the tree
  11465. root = datum;
  11466. treeMap[datum.id] = root;
  11467. } else {
  11468. //This node has a parent, so let's look it up using the id
  11469. parentNode = idToNodeMap[datum.parent.id];
  11470. //We don't need this property, so let's delete it.
  11471. // delete datum.parent;
  11472. //Let's add the current node as a child of the parent node.
  11473. parentNode.children.push(datum);
  11474. }
  11475. }
  11476. }
  11477. return root;
  11478. }
  11479. function convertParentToChildList(data) {
  11480. var treeMap = {};
  11481. var list = [];
  11482. if (search == "search" && items.filterKeyword) {
  11483. var lis = convertListToTree(data, treeMap);
  11484. return lis;
  11485. } else {
  11486. if (data[0] && data[0].orders) {
  11487. list = data;
  11488. } else {
  11489. convertListToTree(data, treeMap);
  11490. angular.forEach(treeMap, function (item) {
  11491. // console.log("item="+JSON.stringify(item))
  11492. list.push(item);
  11493. });
  11494. }
  11495. return list;
  11496. }
  11497. }
  11498. function selectItem(pmodel, childrens) {
  11499. if (angular.isArray(pmodel)) {
  11500. angular.forEach(pmodel, function (index) {
  11501. if (index && index.id) {
  11502. angular.forEach(childrens, function (item) {
  11503. if (item.id == index.id) {
  11504. item.selected = true;
  11505. }
  11506. if (item && item.children) {
  11507. selectItem(pmodel, item.children);
  11508. }
  11509. });
  11510. // angular.forEach(treedata,function(parentdata){
  11511. // if(parentdata.id == index.id){
  11512. // if(parentdata.parent&&parentdata.parent.id){
  11513. // parentdata.parent.$
  11514. // }
  11515. // item.selected = true;
  11516. // }
  11517. // if (item && item.children) {
  11518. // selectItem(pmodel ,item.children);
  11519. // }
  11520. // });
  11521. }
  11522. });
  11523. } else {
  11524. if (pmodel && pmodel.id) {
  11525. angular.forEach(childrens, function (item, index) {
  11526. if (item.id == pmodel.id) {
  11527. item.selected = true;
  11528. delete item.children;
  11529. }
  11530. if (item && item.children) {
  11531. selectItem(pmodel, item.children);
  11532. }
  11533. });
  11534. }
  11535. }
  11536. }
  11537. function selectItemchild(pmodel, childrens) {
  11538. if (angular.isArray(pmodel)) {
  11539. angular.forEach(pmodel, function (index) {
  11540. if (index && index.id) {
  11541. angular.forEach(childrens, function (item) {
  11542. if (item.id == index.id) {
  11543. item.selected = true;
  11544. }
  11545. if (item && item.children) {
  11546. selectItem(pmodel, item.children);
  11547. }
  11548. });
  11549. }
  11550. });
  11551. } else {
  11552. if (pmodel && pmodel.id) {
  11553. angular.forEach(childrens, function (item, index) {
  11554. if (item.id == pmodel.id) {
  11555. item.selected = true;
  11556. childrens[index].selected = true;
  11557. }
  11558. if (item && item.children) {
  11559. selectItem(pmodel, item.children);
  11560. }
  11561. });
  11562. }
  11563. }
  11564. }
  11565. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11566. if (search === "search" && items.filterKeyword) {
  11567. // bala:树形模糊搜索
  11568. options.templateOptions
  11569. .bala(options.templateOptions.APIService, items.filterKeyword)
  11570. .then(function (result) {
  11571. result.list = [...new Set(result.list)]; //去重
  11572. if (!options.templateOptions.options) {
  11573. options.templateOptions.options = [];
  11574. }
  11575. if (options.templateOptions.optionsDataKey) {
  11576. options.templateOptions.options = convertParentToChildList(
  11577. result[options.templateOptions.optionsDataKey]
  11578. );
  11579. } else {
  11580. options.templateOptions.options =
  11581. convertParentToChildList(result);
  11582. }
  11583. //set default value
  11584. var pmodel,
  11585. i = 0;
  11586. if (
  11587. options.templateOptions.pkey ||
  11588. options.templateOptions.pkey != ""
  11589. ) {
  11590. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11591. angular.forEach(
  11592. options.templateOptions.pkey.split("."),
  11593. function (p) {
  11594. if (i == 0) {
  11595. if (options.model[p] == null) {
  11596. options.model[p] = {};
  11597. }
  11598. pmodel = options.model[p];
  11599. i++;
  11600. } else {
  11601. if (pmodel[p] == null) {
  11602. pmodel[p] = {};
  11603. }
  11604. pmodel = pmodel[p];
  11605. }
  11606. }
  11607. );
  11608. } else {
  11609. pmodel = options.model;
  11610. }
  11611. }
  11612. var topdata = angular.copy(options.templateOptions.options);
  11613. if (pmodel) {
  11614. pmodel = pmodel[options.key];
  11615. } else if (options.model) {
  11616. pmodel = options.model[options.key];
  11617. }
  11618. if (angular.isArray(pmodel)) {
  11619. if (pmodel) {
  11620. items.inputModel = angular.copy(
  11621. options.templateOptions.options
  11622. );
  11623. selectItem(pmodel, options.templateOptions.options);
  11624. }
  11625. } else {
  11626. if (pmodel && pmodel.id) {
  11627. items.inputModel = angular.copy(
  11628. options.templateOptions.options
  11629. );
  11630. selectItem(pmodel, options.templateOptions.options);
  11631. } else {
  11632. // items.inputModel = options.templateOptions.options;
  11633. }
  11634. }
  11635. // items.inputModel = options.templateOptions.options;
  11636. items.selectModel = options.templateOptions.options;
  11637. // 可在此展开
  11638. if (!items.inputModel) {
  11639. items.inputModel = items.selectModel;
  11640. } else {
  11641. selectItemchild(pmodel, items.inputModel);
  11642. // for (var i = 0; i < items.inputModel.length; i++) {
  11643. // items.inputModel[i].
  11644. // for (var j = 0; j < items.selectModel.length; j++) {
  11645. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11646. // items.inputModel[i].selected = true;
  11647. // }
  11648. // }
  11649. // }
  11650. }
  11651. return items.inputModel;
  11652. // options.templateOptions.options = angular.copy(topdata);
  11653. // console.log(model);
  11654. // console.log(options);
  11655. });
  11656. } else {
  11657. options.templateOptions
  11658. .refreshData(options.templateOptions.APIService)
  11659. .then(function (result) {
  11660. if (!options.templateOptions.options) {
  11661. options.templateOptions.options = [];
  11662. }
  11663. if (options.templateOptions.optionsDataKey) {
  11664. options.templateOptions.options = convertParentToChildList(
  11665. result[options.templateOptions.optionsDataKey]
  11666. );
  11667. } else {
  11668. options.templateOptions.options =
  11669. convertParentToChildList(result);
  11670. }
  11671. //set default value
  11672. var pmodel,
  11673. i = 0;
  11674. if (
  11675. options.templateOptions.pkey ||
  11676. options.templateOptions.pkey != ""
  11677. ) {
  11678. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11679. angular.forEach(
  11680. options.templateOptions.pkey.split("."),
  11681. function (p) {
  11682. if (i == 0) {
  11683. if (options.model[p] == null) {
  11684. options.model[p] = {};
  11685. }
  11686. pmodel = options.model[p];
  11687. i++;
  11688. } else {
  11689. if (pmodel[p] == null) {
  11690. pmodel[p] = {};
  11691. }
  11692. pmodel = pmodel[p];
  11693. }
  11694. }
  11695. );
  11696. } else {
  11697. pmodel = options.model;
  11698. }
  11699. }
  11700. var topdata = angular.copy(options.templateOptions.options);
  11701. if (pmodel) {
  11702. pmodel = pmodel[options.key];
  11703. } else if (options.model) {
  11704. pmodel = options.model[options.key];
  11705. }
  11706. if (angular.isArray(pmodel)) {
  11707. if (pmodel) {
  11708. items.inputModel = angular.copy(
  11709. options.templateOptions.options
  11710. );
  11711. selectItem(pmodel, options.templateOptions.options);
  11712. }
  11713. } else {
  11714. if (pmodel && pmodel.id) {
  11715. items.inputModel = angular.copy(
  11716. options.templateOptions.options
  11717. );
  11718. selectItem(pmodel, options.templateOptions.options);
  11719. } else {
  11720. // items.inputModel = options.templateOptions.options;
  11721. }
  11722. }
  11723. // items.inputModel = options.templateOptions.options;
  11724. items.selectModel = options.templateOptions.options;
  11725. if (!items.inputModel) {
  11726. items.inputModel = items.selectModel;
  11727. } else {
  11728. selectItemchild(pmodel, items.inputModel);
  11729. // for (var i = 0; i < items.inputModel.length; i++) {
  11730. // for (var j = 0; j < items.selectModel.length; j++) {
  11731. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11732. // items.inputModel[i].selected = true;
  11733. // }
  11734. // }
  11735. // }
  11736. }
  11737. // options.templateOptions.options = angular.copy(topdata);
  11738. // console.log(model);
  11739. // console.log(options);
  11740. });
  11741. }
  11742. },
  11743. },
  11744. validators: {
  11745. required: {
  11746. expression: function (viewValue, modelValue) {
  11747. var value = modelValue || viewValue;
  11748. if (angular.isArray(value)) {
  11749. return value.length > 0;
  11750. } else {
  11751. // console.log(options)
  11752. if (options.templateOptions.required && !value) {
  11753. // return value != null;
  11754. } else {
  11755. return value;
  11756. }
  11757. // return value = "true";
  11758. }
  11759. },
  11760. },
  11761. },
  11762. };
  11763. },
  11764. controller: [
  11765. "$scope",
  11766. "$rootScope",
  11767. "api_configure_form",
  11768. "api_bpm_domain",
  11769. function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  11770. $rootScope.checkClicked = function (item) {
  11771. angular.forEach($scope.to.options, function (itemone) {
  11772. if (!item.parent) {
  11773. if (item.id == itemone.id) {
  11774. // itemone.isExpanded = true;
  11775. } else {
  11776. itemone.isExpanded = false;
  11777. }
  11778. } else {
  11779. if (item.parent.id == itemone.id) {
  11780. angular.forEach(itemone.children, function (itemtwo) {
  11781. if (item.id == itemtwo.id) {
  11782. } else {
  11783. itemtwo.isExpanded = false;
  11784. }
  11785. });
  11786. }
  11787. }
  11788. });
  11789. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  11790. console.log($scope, "gsm");
  11791. if (
  11792. $scope.originalModel &&
  11793. $scope.originalModel.incident &&
  11794. item.category &&
  11795. (!item.children || !item.children.length) &&
  11796. item.priority &&
  11797. item.priority.id
  11798. ) {
  11799. api_bpm_domain
  11800. .expectedTime("L" + (item.priority.id - 1559))
  11801. .then(function (res) {
  11802. $scope.originalModel.incident.expectResponseTime =
  11803. res.serviceLevelAgreement.responseTime;
  11804. $scope.originalModel.incident.expectIntroTime =
  11805. res.serviceLevelAgreement.resolveTime;
  11806. $scope.originalModel.incident.overdueTime = res.date;
  11807. });
  11808. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  11809. // setTimeout(() => {
  11810. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  11811. // }, 500);
  11812. // console.log($scope.$parent.$parent.$parent)
  11813. }
  11814. };
  11815. if ($scope.options.templateOptions.isMultiSelect) {
  11816. // console.log($scope);
  11817. } else {
  11818. if ($scope.model[$scope.options.key]) {
  11819. }
  11820. }
  11821. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  11822. // console.log(item)
  11823. // // if(){
  11824. // // }
  11825. // // $scope.model[$scope.options.key]=item.id;
  11826. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  11827. // $scope.propTypeOptions = data;
  11828. // });
  11829. // }
  11830. // $scope.model[$scope.options.key]=[];
  11831. // $scope.fn
  11832. $rootScope.bala1 = function (items, fn) {
  11833. // $scope.fn = fn;
  11834. console.log(items);
  11835. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  11836. $scope.options.templateOptions.refresh(items, "search", fn);
  11837. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  11838. // // return res.list;
  11839. // console.log(666)
  11840. // fn(res.list)
  11841. // })
  11842. };
  11843. },
  11844. ],
  11845. });
  11846. //勾选组件
  11847. formlyConfigProvider.setType({
  11848. name: "ui-checkbox",
  11849. extends: "checkbox",
  11850. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  11851. controller: [
  11852. "$scope",
  11853. function ($scope) {
  11854. // 巡检生成事件,默认派单
  11855. if ($scope.model.isInspection) {
  11856. $scope.model[$scope.options.key] = true;
  11857. }
  11858. if ($scope.model[$scope.options.key] == "true") {
  11859. $scope.model[$scope.options.key] = true;
  11860. }
  11861. if ($scope.model[$scope.options.key] == "false") {
  11862. $scope.model[$scope.options.key] = false;
  11863. }
  11864. },
  11865. ],
  11866. });
  11867. //换行组件
  11868. formlyConfigProvider.setType({
  11869. name: "ui-nextLine",
  11870. /*extends: 'input',*/
  11871. template: "<div></div>",
  11872. });
  11873. //多选框组件
  11874. formlyConfigProvider.setType({
  11875. name: "ui-checklist",
  11876. extends: "multiCheckbox",
  11877. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  11878. defaultOptions: function (options) {
  11879. return {
  11880. templateOptions: {
  11881. refresh: function () {},
  11882. refreshDelay: 0,
  11883. },
  11884. };
  11885. },
  11886. });
  11887. //单选框组件
  11888. formlyConfigProvider.setType({
  11889. name: "ui-radio",
  11890. extends: "radio",
  11891. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  11892. defaultOptions: function (options) {
  11893. return {
  11894. templateOptions: {
  11895. refresh: function () {},
  11896. refreshDelay: 0,
  11897. },
  11898. };
  11899. },
  11900. controller: [
  11901. "$scope",
  11902. function ($scope) {
  11903. // 巡检生成事件,默认派单
  11904. if ($scope.model.isInspection) {
  11905. $scope.model[$scope.options.key] = true;
  11906. // $scope.model.isHandlerUser=true;
  11907. $scope.model.start_code = "assignment";
  11908. console.log($scope.model);
  11909. }
  11910. //多次暂存配置
  11911. // console.log($scope);
  11912. if ($scope.model.saveAgain) {
  11913. if (
  11914. $scope.model.directClose == "1" ||
  11915. $scope.model.directClose == true
  11916. ) {
  11917. $scope.model[$scope.options.key] = true;
  11918. // if($scope.model.incident.handlingPersonnelUser){
  11919. // delete $scope.model.incident.handlingPersonnelUser;
  11920. // };
  11921. if ($scope.model.incident.handleDescription) {
  11922. delete $scope.model.incident.handleDescription;
  11923. }
  11924. if ($scope.model.incident.closecode) {
  11925. delete $scope.model.incident.closecode;
  11926. }
  11927. if ($scope.model.incident.degree) {
  11928. delete $scope.model.incident.degree;
  11929. }
  11930. } else {
  11931. $scope.model.incident.handlingPersonnelUser =
  11932. $scope.model.incident.acceptUser;
  11933. $scope.model[$scope.options.key] = false;
  11934. }
  11935. }
  11936. },
  11937. ],
  11938. });
  11939. //文本域组件
  11940. formlyConfigProvider.setWrapper({
  11941. name: "validation",
  11942. types: ["ui-textarea"],
  11943. template:
  11944. '<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>',
  11945. });
  11946. formlyConfigProvider.setType({
  11947. name: "ui-textarea",
  11948. extends: "textarea",
  11949. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  11950. defaultOptions: function (options) {
  11951. return {
  11952. templateOptions: {
  11953. transform: function (model, value) {
  11954. return value;
  11955. },
  11956. },
  11957. validation: {
  11958. messages: {
  11959. maxlength: function (viewValue, modelValue, scope) {
  11960. if (viewValue != null) {
  11961. if (viewValue.length > scope.to.maxlength) {
  11962. return (
  11963. scope.to.label +
  11964. " 字数(" +
  11965. viewValue.length +
  11966. ")超限(" +
  11967. scope.to.maxlength +
  11968. ")"
  11969. );
  11970. } else {
  11971. return "";
  11972. }
  11973. }
  11974. },
  11975. },
  11976. },
  11977. };
  11978. },
  11979. controller: [
  11980. "$scope",
  11981. function ($scope) {
  11982. var value = $scope.model[$scope.options.key];
  11983. if (angular.isFunction($scope.options.templateOptions.transform)) {
  11984. $scope.model[$scope.options.key] =
  11985. $scope.options.templateOptions.transform(
  11986. $scope.originalModel,
  11987. value
  11988. );
  11989. }
  11990. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  11991. $scope.options.templateOptions.felditem($scope);
  11992. }
  11993. },
  11994. ],
  11995. });
  11996. // div版的textarea(展示富文本框内容用)
  11997. formlyConfigProvider.setType({
  11998. name: "ui-divTextarea",
  11999. extends: "textarea",
  12000. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12001. defaultOptions: function (options) {
  12002. return {
  12003. templateOptions: {
  12004. transform: function (model, value) {
  12005. return value;
  12006. },
  12007. },
  12008. validation: {
  12009. messages: {
  12010. // maxlength: function (viewValue, modelValue, scope) {
  12011. // if (viewValue != null) {
  12012. // if (viewValue.length > scope.to.maxlength) {
  12013. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12014. // } else {
  12015. // return "";
  12016. // }
  12017. // }
  12018. // },
  12019. },
  12020. },
  12021. };
  12022. },
  12023. controller: [
  12024. "$scope",
  12025. function ($scope) {
  12026. var value = $scope.model[$scope.options.key];
  12027. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12028. $scope.model[$scope.options.key] =
  12029. $scope.options.templateOptions.transform(
  12030. $scope.originalModel,
  12031. value
  12032. );
  12033. }
  12034. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12035. $scope.options.templateOptions.felditem($scope);
  12036. }
  12037. },
  12038. ],
  12039. });
  12040. // 带有知识库引用的textarea
  12041. formlyConfigProvider.setType({
  12042. name: "ui-textAreaKnowledge",
  12043. // extends: 'textarea',
  12044. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12045. defaultOptions: function (options) {
  12046. return {
  12047. templateOptions: {
  12048. transform: function (model, value) {
  12049. return value;
  12050. },
  12051. },
  12052. validation: {
  12053. messages: {
  12054. maxlength: function (viewValue, modelValue, scope) {
  12055. if (viewValue != null) {
  12056. if (viewValue.length > scope.to.maxlength) {
  12057. return (
  12058. scope.to.label +
  12059. " 字数(" +
  12060. viewValue.length +
  12061. ")超限(" +
  12062. scope.to.maxlength +
  12063. ")"
  12064. );
  12065. } else {
  12066. return "";
  12067. }
  12068. }
  12069. },
  12070. },
  12071. },
  12072. };
  12073. },
  12074. controller: [
  12075. "$scope",
  12076. "$rootScope",
  12077. "$modal",
  12078. "SweetAlert",
  12079. "api_bpm_data",
  12080. "api_bpm_domain",
  12081. "api_solution",
  12082. "$aside",
  12083. "api_zsk",
  12084. "up_down_file",
  12085. "api_wechatfile",
  12086. function (
  12087. $scope,
  12088. $rootScope,
  12089. $modal,
  12090. SweetAlert,
  12091. api_bpm_data,
  12092. api_bpm_domain,
  12093. api_solution,
  12094. $aside,
  12095. api_zsk,
  12096. up_down_file,
  12097. api_wechatfile
  12098. ) {
  12099. // console.log($scope);
  12100. var value = $scope.model[$scope.options.key];
  12101. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12102. $scope.model[$scope.options.key] =
  12103. $scope.options.templateOptions.transform(
  12104. $scope.originalModel,
  12105. value
  12106. );
  12107. }
  12108. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12109. $scope.options.templateOptions.felditem($scope);
  12110. }
  12111. // 引用知识库点击
  12112. $scope.openSolution = function () {
  12113. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12114. setTimeout(() => {
  12115. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12116. }, 100);
  12117. };
  12118. },
  12119. ],
  12120. });
  12121. //常用语句选择textarea
  12122. formlyConfigProvider.setType({
  12123. name: "ui-textselect",
  12124. extends: "textarea",
  12125. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12126. defaultOptions: function (options) {
  12127. return {
  12128. templateOptions: {
  12129. transform: function (model, value) {
  12130. return value;
  12131. },
  12132. },
  12133. validation: {
  12134. messages: {
  12135. maxlength: function (viewValue, modelValue, scope) {
  12136. if (viewValue != null) {
  12137. if (viewValue.length > scope.to.maxlength) {
  12138. return (
  12139. scope.to.label +
  12140. " 字数(" +
  12141. viewValue.length +
  12142. ")超限(" +
  12143. scope.to.maxlength +
  12144. ")"
  12145. );
  12146. } else {
  12147. return "";
  12148. }
  12149. }
  12150. },
  12151. },
  12152. },
  12153. };
  12154. },
  12155. controller: [
  12156. "$scope",
  12157. function ($scope) {
  12158. var value = $scope.model[$scope.options.key];
  12159. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12160. $scope.model[$scope.options.key] =
  12161. $scope.options.templateOptions.transform(
  12162. $scope.originalModel,
  12163. value
  12164. );
  12165. }
  12166. },
  12167. ],
  12168. });
  12169. //改动的组件 ckeditor封装后的组件
  12170. formlyConfigProvider.setType({
  12171. name: "ui-text-check",
  12172. extends: "textarea",
  12173. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12174. defaultOptions: function (options) {
  12175. return {
  12176. templateOptions: {
  12177. extraPlugins: "uploadimage",
  12178. uploadimageConfig: {
  12179. backend: "basic",
  12180. settings: {
  12181. uploadUrl:
  12182. options.templateOptions.APIService.upload().getRequestedUrl(),
  12183. headers: "",
  12184. downloadUrl:
  12185. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12186. },
  12187. },
  12188. refresh: function (APIService, contentId, data) {
  12189. return APIService.fetchDataList(contentId, data);
  12190. },
  12191. downloadUri: function (APIService, contentId) {
  12192. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12193. },
  12194. upload: function (APIService, contentId) {
  12195. return APIService.getSolutionDowpath(contentId);
  12196. },
  12197. view: function (attachmentId) {
  12198. // return APIService.attachmentsPreviewUrl(contentId);
  12199. },
  12200. refreshDelay: 0,
  12201. transform: function (model, value) {
  12202. return value;
  12203. },
  12204. },
  12205. validation: {
  12206. messages: {
  12207. maxlength: function (viewValue, modelValue, scope) {
  12208. if (viewValue != null) {
  12209. if (viewValue.length > scope.to.maxlength) {
  12210. return (
  12211. scope.to.label +
  12212. " 字数(" +
  12213. viewValue.length +
  12214. ")超限(" +
  12215. scope.to.maxlength +
  12216. ")"
  12217. );
  12218. } else {
  12219. return "";
  12220. }
  12221. }
  12222. },
  12223. },
  12224. },
  12225. };
  12226. },
  12227. controller: [
  12228. "$scope",
  12229. "$rootScope",
  12230. function ($scope, $rootScope) {
  12231. var value = $scope.model[$scope.options.key];
  12232. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12233. $scope.model[$scope.options.key] =
  12234. $scope.options.templateOptions.transform(
  12235. $scope.originalModel,
  12236. value
  12237. );
  12238. }
  12239. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12240. $rootScope.getSession();
  12241. //var expiry={'expiry':14804244006};
  12242. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12243. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12244. $scope.upload = function (contentId, filename) {
  12245. var filename = filename;
  12246. $scope.options.templateOptions
  12247. .upload($scope.options.templateOptions.ApiService, contentId)
  12248. .then(function (response) {
  12249. var file = new Blob([response], {
  12250. type: "application/octet-stream",
  12251. });
  12252. // var filename = filename;
  12253. var fileURL = URL.createObjectURL(file);
  12254. var a = document.createElement("a");
  12255. a.href = fileURL;
  12256. a.target = "_blank";
  12257. a.download = filename;
  12258. document.body.appendChild(a);
  12259. a.click();
  12260. });
  12261. };
  12262. },
  12263. ],
  12264. });
  12265. //改动的组件 ckeditor封装后的附文本组件
  12266. formlyConfigProvider.setType({
  12267. name: "ui-fuwenben",
  12268. extends: "textarea",
  12269. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12270. defaultOptions: function (options) {
  12271. return {
  12272. templateOptions: {
  12273. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12274. extraPlugins: "uploadimage",
  12275. uploadimageConfig: {
  12276. backend: "basic",
  12277. settings: {
  12278. uploadUrl:
  12279. options.templateOptions.APIService.upload(
  12280. -110
  12281. ).getRequestedUrl(),
  12282. headers: "",
  12283. downloadUrl:
  12284. options.templateOptions.APIService.uploadResponseUri(),
  12285. },
  12286. },
  12287. refresh: function (APIService, contentId, data) {
  12288. return APIService.fetchDataList(-110, data);
  12289. },
  12290. downloadUri: function (APIService, contentId) {
  12291. return APIService.downloadAttachment(-110).getRequestedUrl();
  12292. },
  12293. upload: function (APIService, contentId) {
  12294. return APIService.getSolutionDowpath(-110);
  12295. },
  12296. view: function (attachmentId) {
  12297. // return APIService.attachmentsPreviewUrl(contentId);
  12298. },
  12299. refreshDelay: 0,
  12300. transform: function (model, value) {
  12301. return value;
  12302. },
  12303. },
  12304. validation: {
  12305. messages: {
  12306. maxlength: function (viewValue, modelValue, scope) {
  12307. if (viewValue != null) {
  12308. if (viewValue.length > scope.to.maxlength) {
  12309. return (
  12310. scope.to.label +
  12311. " 字数(" +
  12312. viewValue.length +
  12313. ")超限(" +
  12314. scope.to.maxlength +
  12315. ")"
  12316. );
  12317. } else {
  12318. return "";
  12319. }
  12320. }
  12321. },
  12322. },
  12323. },
  12324. };
  12325. },
  12326. controller: [
  12327. "$scope",
  12328. "$rootScope",
  12329. function ($scope, $rootScope) {
  12330. var value = $scope.model[$scope.options.key];
  12331. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12332. $scope.model[$scope.options.key] =
  12333. $scope.options.templateOptions.transform(
  12334. $scope.originalModel,
  12335. value
  12336. );
  12337. }
  12338. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12339. $rootScope.getSession();
  12340. //var expiry={'expiry':14804244006};
  12341. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12342. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12343. $scope.upload = function (contentId, filename) {
  12344. var filename = filename;
  12345. $scope.options.templateOptions
  12346. .upload($scope.options.templateOptions.ApiService, -110)
  12347. .then(function (response) {
  12348. var file = new Blob([response], {
  12349. type: "application/octet-stream",
  12350. });
  12351. // var filename = filename;
  12352. var fileURL = URL.createObjectURL(file);
  12353. var a = document.createElement("a");
  12354. a.href = fileURL;
  12355. a.target = "_blank";
  12356. a.download = filename;
  12357. document.body.appendChild(a);
  12358. a.click();
  12359. });
  12360. };
  12361. },
  12362. ],
  12363. });
  12364. //ui-grid展示控件
  12365. formlyConfigProvider.setType({
  12366. name: "ui-grid-show",
  12367. extends: "multiCheckbox",
  12368. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12369. defaultOptions: function (options) {
  12370. return {
  12371. templateOptions: {
  12372. linkage: function () {},
  12373. },
  12374. };
  12375. },
  12376. controller: function (
  12377. $scope,
  12378. $rootScope,
  12379. i18nService,
  12380. Restangular,
  12381. api_bpm_data
  12382. ) {
  12383. var loginUser = $rootScope.user;
  12384. $scope.langs = i18nService.getAllLangs();
  12385. $scope.lang = "zh-cn";
  12386. i18nService.setCurrentLang($scope.lang);
  12387. $scope.gridOptions = {};
  12388. $scope.gridOptions.data = "myData";
  12389. $scope.gridOptions.enableColumnResizing = true;
  12390. // $scope.gridOptions.enableFiltering = true;
  12391. $scope.gridOptions.enableGridMenu = false;
  12392. $scope.gridOptions.enableRowSelection = true;
  12393. $scope.gridOptions.showGridFooter = true;
  12394. $scope.gridOptions.showColumnFooter = false;
  12395. $scope.gridOptions.fastWatch = true;
  12396. $scope.gridOptions.useExternalFiltering = true;
  12397. $scope.gridOptions.useExternalPagination = true;
  12398. $scope.gridOptions.paginationPageSizes = [10];
  12399. $scope.gridOptions.paginationPageSize = 10;
  12400. $scope.gridOptions.multiSelect = true;
  12401. $scope.gridOptions.rowIdentity = function (row) {
  12402. return row.id;
  12403. };
  12404. $scope.gridOptions.getRowIdentity = function (row) {
  12405. return row.id;
  12406. };
  12407. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12408. $scope.gridOptions.columnDefs = [
  12409. // { name:'id', width:80, enableFiltering:false},
  12410. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12411. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12412. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12413. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12414. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12415. {
  12416. name: "inspection.title",
  12417. displayName: "计划主题",
  12418. width: 120,
  12419. enableFiltering: false,
  12420. },
  12421. {
  12422. name: "stateName",
  12423. displayName: "状态",
  12424. width: 80,
  12425. enableFiltering: false,
  12426. },
  12427. {
  12428. name: "processUser.name",
  12429. displayName: "处理人",
  12430. width: 80,
  12431. enableFiltering: false,
  12432. },
  12433. {
  12434. name: "startDate",
  12435. displayName: "开始时间",
  12436. width: 160,
  12437. enableFiltering: false,
  12438. },
  12439. {
  12440. name: "overdueTime",
  12441. displayName: "逾期时间",
  12442. width: 160,
  12443. enableFiltering: false,
  12444. },
  12445. ];
  12446. var defaultFilterData = {
  12447. idx: 0,
  12448. sum: 10,
  12449. };
  12450. //分页控制
  12451. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12452. gridApi.pagination.on.paginationChanged(
  12453. $scope,
  12454. function (newPage, pageSize) {
  12455. var filtersData = $scope.memoryfilterData;
  12456. filtersData.idx = newPage - 1;
  12457. filtersData.sum = pageSize;
  12458. $scope.refreshData("expand-right", filtersData);
  12459. }
  12460. );
  12461. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12462. data.grid.appScope.selected.items = data.entity;
  12463. });
  12464. };
  12465. //页面获取数据
  12466. $scope.refreshData = function (style, filterData) {
  12467. // $scope.ldloading[style.replace('-', '_')] = true;
  12468. if (angular.isUndefined(filterData)) {
  12469. filterData = defaultFilterData;
  12470. }
  12471. $scope.myData = [];
  12472. angular.extend(filterData, {
  12473. inspectionProcessActual: {
  12474. inspectionid: $scope.model.id,
  12475. },
  12476. });
  12477. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  12478. function (data) {
  12479. var myData = Restangular.stripRestangular(data);
  12480. $scope.gridOptions.totalItems = myData.totalNum;
  12481. $scope.myData = myData.list;
  12482. for (var i = 0; i < $scope.myData.length; i++) {
  12483. //添加序号
  12484. $scope.myData[i]["item"] =
  12485. i + 1 + filterData.idx * filterData.sum;
  12486. }
  12487. // $scope.ldloading[style.replace('-', '_')] = false;
  12488. },
  12489. function () {
  12490. // $scope.ldloading[style.replace('-', '_')] = false;
  12491. }
  12492. );
  12493. };
  12494. $scope.refreshData("expand-right", defaultFilterData);
  12495. },
  12496. });
  12497. //文本框自定义选择面板组件
  12498. formlyConfigProvider.setType({
  12499. name: "ui-input-selectmodal",
  12500. extends: "input",
  12501. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  12502. defaultOptions: function (options) {
  12503. return {
  12504. templateOptions: {
  12505. openModal: function (size, options, modal) {
  12506. var modalInstance = modal.open({
  12507. templateUrl: "assets/views/customform/tpl/modal-content.html",
  12508. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  12509. size: size,
  12510. resolve: options.templateOptions.modalParam,
  12511. });
  12512. modalInstance.result.then(
  12513. function (selectedItem) {
  12514. options.value(selectedItem);
  12515. },
  12516. function () {
  12517. //console.log('Modal dismissed at: ' + new Date());
  12518. }
  12519. );
  12520. },
  12521. },
  12522. };
  12523. },
  12524. });
  12525. //日期控件
  12526. var datepicker_attr = [
  12527. "date-disabled",
  12528. "custom-class",
  12529. "show-weeks",
  12530. "starting-day",
  12531. "init-date",
  12532. "min-mode",
  12533. "max-mode",
  12534. "format-day",
  12535. "format-month",
  12536. "format-year",
  12537. "format-day-header",
  12538. "format-day-title",
  12539. "format-month-title",
  12540. "year-range",
  12541. "shortcut-propagation",
  12542. "datepicker-popup",
  12543. "show-button-bar",
  12544. "current-text",
  12545. "clear-text",
  12546. "close-text",
  12547. "close-on-date-selection",
  12548. "datepicker-append-to-body",
  12549. ];
  12550. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  12551. formlyConfigProvider.setType({
  12552. name: "ui-datetime",
  12553. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  12554. extends: "input",
  12555. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12556. defaultOptions: {
  12557. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12558. templateOptions: {
  12559. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12560. },
  12561. },
  12562. controller: [
  12563. "$scope",
  12564. "$filter",
  12565. function ($scope, $filter) {
  12566. $scope.model[$scope.options.key] = $filter("date")(
  12567. new Date(),
  12568. $scope.options.templateOptions.datepickerPopup
  12569. );
  12570. $scope.options.initialValue = $scope.model[$scope.options.key];
  12571. },
  12572. ],
  12573. });
  12574. //日期控件
  12575. formlyConfigProvider.setType({
  12576. name: "ui-datepicker",
  12577. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  12578. extends: "input",
  12579. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12580. defaultOptions: {
  12581. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  12582. templateOptions: {
  12583. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  12584. },
  12585. },
  12586. controller: [
  12587. "$scope",
  12588. "$filter",
  12589. function ($scope, $filter) {
  12590. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  12591. if ($scope.model[$scope.options.key]) {
  12592. } else {
  12593. $scope.model[$scope.options.key] = $filter("date")(
  12594. new Date(),
  12595. $scope.options.templateOptions.datepickerPopup
  12596. );
  12597. }
  12598. $scope.options.initialValue = $scope.model[$scope.options.key];
  12599. $scope.endOpen = true;
  12600. $scope.datepicker = {};
  12601. $scope.datepicker.opened = false;
  12602. $scope.datepicker.open = function ($event) {
  12603. $scope.datepicker.opened = true;
  12604. };
  12605. },
  12606. ],
  12607. });
  12608. //时分控件
  12609. formlyConfigProvider.setType({
  12610. name: "ui-datehourtime",
  12611. extends: "input",
  12612. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  12613. defaultOptions: function (options) {
  12614. return {
  12615. noFormControl: true,
  12616. // validators:{
  12617. // required:{
  12618. // expression:function(viewValue, modelValue){
  12619. // console.log(options)
  12620. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  12621. // // var value = modelValue.getHours() || viewValue.getHours();
  12622. // return value.length>=1;
  12623. // }
  12624. // }
  12625. // }
  12626. };
  12627. },
  12628. controller: [
  12629. "$scope",
  12630. "$log",
  12631. function ($scope, $log) {
  12632. $scope.hstep = new Date(
  12633. Date.parse($scope.model[$scope.options.key])
  12634. ).getHours();
  12635. $scope.minutes = new Date(
  12636. Date.parse($scope.model[$scope.options.key])
  12637. ).getMinutes();
  12638. $scope.model[$scope.options.key] = new Date(
  12639. Date.parse($scope.model[$scope.options.key])
  12640. );
  12641. },
  12642. ],
  12643. });
  12644. //状态追踪
  12645. formlyConfigProvider.setType({
  12646. name: "ui-followStatus",
  12647. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  12648. controller: [
  12649. "$scope",
  12650. "api_bpm_data",
  12651. "Restangular",
  12652. function ($scope, api_bpm_data, Restangular) {
  12653. setTimeout(function () {
  12654. var pkey = $scope.options.templateOptions.pkey;
  12655. var dataId = $scope.model.id;
  12656. if (dataId) {
  12657. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  12658. if (response) {
  12659. var myData = Restangular.stripRestangular(response);
  12660. var processInstanceId = myData.data.processInstanceId;
  12661. $scope.options.templateOptions
  12662. .getData(
  12663. $scope.model,
  12664. $scope.options.templateOptions.ApiService,
  12665. processInstanceId
  12666. )
  12667. .then(function (result) {
  12668. if (result.status == 200) {
  12669. var newData = Restangular.stripRestangular(result);
  12670. $scope.followData = newData.data;
  12671. }
  12672. });
  12673. }
  12674. });
  12675. }
  12676. }, 10);
  12677. },
  12678. ],
  12679. });
  12680. //历史记录
  12681. formlyConfigProvider.setType({
  12682. name: "ui-history",
  12683. templateUrl: "assets/views/customform/tpl/ui-history.html",
  12684. controller: [
  12685. "$scope",
  12686. "api_bpm_data",
  12687. "Restangular",
  12688. function ($scope, api_bpm_data, Restangular) {
  12689. setTimeout(function () {
  12690. var pkey = $scope.options.templateOptions.pkey;
  12691. var dataId = $scope.model.id;
  12692. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  12693. if (response) {
  12694. var myData = Restangular.stripRestangular(response);
  12695. var processInstanceId = myData.data.processInstanceId;
  12696. $scope.options.templateOptions
  12697. .getData(
  12698. $scope.model,
  12699. $scope.options.templateOptions.ApiService,
  12700. processInstanceId
  12701. )
  12702. .then(function (result) {
  12703. if (result.status == 200) {
  12704. var newData = Restangular.stripRestangular(result);
  12705. var long = newData.data.length - 1;
  12706. $scope.followData = newData.data[long];
  12707. }
  12708. });
  12709. }
  12710. });
  12711. }, 10);
  12712. },
  12713. ],
  12714. });
  12715. // //请求人信息显示
  12716. // formlyConfigProvider.setType({
  12717. // name: "ui-disrequester",
  12718. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  12719. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  12720. // defaultOptions: function(options) {
  12721. // return {
  12722. // templateOptions: {}
  12723. // };
  12724. // },
  12725. // controller: ['$scope', function($scope) {
  12726. // $scope.options.templateOptions.that = $scope;
  12727. // }]
  12728. // });
  12729. //退回人信息显示
  12730. formlyConfigProvider.setType({
  12731. name: "ui-returnperson",
  12732. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  12733. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12734. defaultOptions: function (options) {
  12735. return {
  12736. templateOptions: {},
  12737. };
  12738. },
  12739. controller: [
  12740. "$scope",
  12741. function ($scope) {
  12742. $scope.group = "";
  12743. $scope.role = "";
  12744. if (
  12745. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  12746. $scope.model.handlingPersonnelUser.group.length == 1
  12747. ) {
  12748. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  12749. } else {
  12750. for (
  12751. var i = 0;
  12752. i < $scope.model.handlingPersonnelUser.group.length;
  12753. i++
  12754. ) {
  12755. $scope.group +=
  12756. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  12757. }
  12758. }
  12759. if (
  12760. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  12761. $scope.model.handlingPersonnelUser.role.length == 1
  12762. ) {
  12763. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  12764. } else {
  12765. for (
  12766. var i = 0;
  12767. i < $scope.model.handlingPersonnelUser.role.length;
  12768. i++
  12769. ) {
  12770. $scope.role +=
  12771. $scope.model.handlingPersonnelUser.role[i].role + ",";
  12772. }
  12773. }
  12774. $scope.options.templateOptions.that = $scope;
  12775. $scope.options.templateOptions.that = $scope;
  12776. },
  12777. ],
  12778. });
  12779. //退回人信息显示(去掉工作组&角色)
  12780. formlyConfigProvider.setType({
  12781. name: "ui-returnpersonNoGroup",
  12782. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  12783. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12784. defaultOptions: function (options) {
  12785. return {
  12786. templateOptions: {},
  12787. };
  12788. },
  12789. controller: [
  12790. "$scope",
  12791. function ($scope) {
  12792. $scope.group = "";
  12793. $scope.role = "";
  12794. if (
  12795. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  12796. $scope.model.handlingPersonnelUser.group.length == 1
  12797. ) {
  12798. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  12799. } else {
  12800. for (
  12801. var i = 0;
  12802. i < $scope.model.handlingPersonnelUser.group.length;
  12803. i++
  12804. ) {
  12805. $scope.group +=
  12806. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  12807. }
  12808. }
  12809. if (
  12810. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  12811. $scope.model.handlingPersonnelUser.role.length == 1
  12812. ) {
  12813. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  12814. } else {
  12815. for (
  12816. var i = 0;
  12817. i < $scope.model.handlingPersonnelUser.role.length;
  12818. i++
  12819. ) {
  12820. $scope.role +=
  12821. $scope.model.handlingPersonnelUser.role[i].role + ",";
  12822. }
  12823. }
  12824. $scope.options.templateOptions.that = $scope;
  12825. $scope.options.templateOptions.that = $scope;
  12826. },
  12827. ],
  12828. });
  12829. //指派技术人员
  12830. formlyConfigProvider.setType({
  12831. name: "ui-apiontperson",
  12832. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  12833. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  12834. defaultOptions: function (options) {
  12835. return {
  12836. templateOptions: {
  12837. transtlara: function (value, $scope) {},
  12838. },
  12839. };
  12840. },
  12841. controller: [
  12842. "$scope",
  12843. "api_user_data",
  12844. "Restangular",
  12845. function ($scope, api_user_data, Restangular) {
  12846. var filterData = {
  12847. idx: 0,
  12848. sum: 1000,
  12849. };
  12850. api_user_data
  12851. .fetchDataList("group", filterData)
  12852. .then(function (response) {
  12853. if (response.status == 200) {
  12854. $scope.select = {};
  12855. $scope.multipleDemo = {};
  12856. $scope.userdata = {};
  12857. var data = response.list;
  12858. var item = [];
  12859. $scope.multipleDemo = data;
  12860. $scope.multipleDemo;
  12861. }
  12862. });
  12863. $scope.options.templateOptions.onChange = function (
  12864. id,
  12865. options,
  12866. groupdata,
  12867. $event,
  12868. model
  12869. ) {
  12870. if (groupdata.option) {
  12871. $scope.model[$scope.options.key] = {};
  12872. var fildate = {
  12873. idx: 0,
  12874. sum: 1000,
  12875. user: {
  12876. roledata: {
  12877. rolecode: model.currentRole,
  12878. },
  12879. selectType: "1",
  12880. groupdata: {
  12881. id: groupdata.option.id,
  12882. },
  12883. },
  12884. };
  12885. api_user_data
  12886. .fetchDataList("user", fildate)
  12887. .then(function (response) {
  12888. if (response.status == 200) {
  12889. $scope.userdata = {};
  12890. $scope.userdata = response.list;
  12891. }
  12892. });
  12893. } else {
  12894. $scope.model[$scope.options.key] = {
  12895. id: groupdata.id.id,
  12896. };
  12897. $scope.options.templateOptions.transtlara(
  12898. $scope.model[$scope.options.key],
  12899. $scope
  12900. );
  12901. }
  12902. };
  12903. // }
  12904. },
  12905. ],
  12906. });
  12907. //请求科室信息(小蓝框) lmm
  12908. formlyConfigProvider.setType({
  12909. name: "ui-deptinformation",
  12910. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  12911. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  12912. return {
  12913. templateOptions: {
  12914. checkform: function (options) {},
  12915. },
  12916. };
  12917. },
  12918. controller: [
  12919. "$scope",
  12920. "api_statistic",
  12921. function ($scope, api_statistic) {
  12922. // console.log($scope)
  12923. },
  12924. ],
  12925. });
  12926. //请求人信息
  12927. formlyConfigProvider.setType({
  12928. name: "ui-requesterinformation",
  12929. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  12930. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  12931. return {
  12932. templateOptions: {
  12933. checkform: function (options) {
  12934. if (options.model.requester) {
  12935. options.value(options.model.requester);
  12936. }
  12937. },
  12938. addRequeter: function (size, options, modal, e) {
  12939. if (e.clientX === 0) {
  12940. return;
  12941. }
  12942. e.preventDefault();
  12943. var modalInstance = modal.open({
  12944. templateUrl:
  12945. "assets/views/customform/tpl/modal-add-callrequester.html",
  12946. controller: function (
  12947. $scope,
  12948. sco,
  12949. $rootScope,
  12950. $modalInstance,
  12951. items,
  12952. SweetAlert,
  12953. title,
  12954. Restangular,
  12955. APIService,
  12956. UserService,
  12957. api_user_data,
  12958. api_statistic,
  12959. api_wechatfile
  12960. ) {
  12961. $modalInstance.SweetAlert = SweetAlert;
  12962. $scope.title = "新增报修人";
  12963. $scope.requester = {};
  12964. $scope.searchData = {};
  12965. $scope.onChangeadd = function (searchData) {
  12966. $scope.searchKey = searchData.account;
  12967. // $scope.searchDataadd = searchData;
  12968. var requesdata = angular.copy(searchData);
  12969. if (requesdata.mphone) {
  12970. delete requesdata.mphone;
  12971. }
  12972. $scope.requester = requesdata;
  12973. console.log($scope.requester);
  12974. };
  12975. $scope.refreshUseradd = function (searchKey) {
  12976. //请求人搜索
  12977. $scope.requester.account = searchKey;
  12978. $scope.searchData = searchKey;
  12979. serchdataadd(searchKey);
  12980. };
  12981. $scope.getMydata = function (x) {
  12982. $scope.searchField = JSON.parse(x[0]).account;
  12983. $scope.requester = JSON.parse(x[0]);
  12984. console.log($scope.requester);
  12985. };
  12986. $scope.getMydataone = function (x) {
  12987. $scope.searchField = x;
  12988. $scope.requester.account = x;
  12989. };
  12990. serchdataadd();
  12991. api_wechatfile
  12992. .getDictionary({
  12993. type: "list",
  12994. key: "male",
  12995. })
  12996. .then(function (data) {
  12997. if (data.status == 200) {
  12998. requester.gender = data.list;
  12999. }
  13000. });
  13001. function serchdataadd(searchKey) {
  13002. if (searchKey) {
  13003. var filterData = {
  13004. requester: {
  13005. searchKey: searchKey,
  13006. },
  13007. idx: 0,
  13008. sum: 10,
  13009. };
  13010. } else {
  13011. var filterData = {
  13012. idx: 0,
  13013. sum: 10,
  13014. };
  13015. }
  13016. api_user_data
  13017. .fetchDataList("requester", filterData)
  13018. .then(function (response) {
  13019. var myData = response;
  13020. $scope.myData = myData.list;
  13021. });
  13022. }
  13023. api_user_data
  13024. .fetchDataList("area", {
  13025. idx: 0,
  13026. sum: 1000,
  13027. })
  13028. .then(function (response) {
  13029. if (response.status == 200) {
  13030. $scope.areas = response.list;
  13031. }
  13032. });
  13033. api_wechatfile
  13034. .getDictionary(
  13035. {
  13036. key: "requester_type",
  13037. type: "list",
  13038. },
  13039. {
  13040. idx: 0,
  13041. sum: 100,
  13042. }
  13043. )
  13044. .then(function (response) {
  13045. if (response) {
  13046. $scope.networktypes = response;
  13047. }
  13048. });
  13049. $scope.requesterAreaid = "";
  13050. $scope.onChange = function (item) {
  13051. $scope.requesterAreaid = item.id;
  13052. api_user_data
  13053. .fetchDataList("place", {
  13054. place: {
  13055. area: {
  13056. id: item.id,
  13057. },
  13058. },
  13059. idx: 0,
  13060. sum: 1000,
  13061. })
  13062. .then(function (response) {
  13063. if (response.status == 200) {
  13064. $scope.places = response.list;
  13065. delete $scope.requester.placeDTO;
  13066. }
  13067. });
  13068. };
  13069. $scope.refresh = function (searchVal) {
  13070. var faildata = {};
  13071. if ($scope.requesterAreaid) {
  13072. faildata = {
  13073. idx: 0,
  13074. sum: 1000,
  13075. place: {
  13076. areaId: $scope.requesterAreaid,
  13077. place: searchVal,
  13078. selectType: "pinyin_qs",
  13079. },
  13080. };
  13081. } else {
  13082. faildata = {
  13083. idx: 0,
  13084. sum: 1000,
  13085. place: {
  13086. place: searchVal,
  13087. selectType: "pinyin_qs",
  13088. },
  13089. };
  13090. }
  13091. api_user_data
  13092. .fetchDataList("place", faildata)
  13093. .then(function (response) {
  13094. $scope.places = response.list;
  13095. delete $scope.requester.placeDTO;
  13096. });
  13097. };
  13098. $scope.refreshDepts = function (key) {
  13099. var filterData = {
  13100. idx: 0,
  13101. sum: 5,
  13102. dept: {
  13103. name: key,
  13104. },
  13105. };
  13106. UserService.fetchDataList("department", filterData).then(
  13107. function (response) {
  13108. if (response.status == 200) {
  13109. $scope.depts = response.list;
  13110. }
  13111. }
  13112. );
  13113. };
  13114. $scope.ok = function () {
  13115. if (
  13116. angular.isUndefined($scope.requester.account) ||
  13117. $scope.requester.account == null ||
  13118. $scope.requester.account == ""
  13119. ) {
  13120. SweetAlert.swal(
  13121. "报修人员编号未填!",
  13122. "请填写报修人员编号",
  13123. "error"
  13124. );
  13125. } else if (
  13126. angular.isUndefined($scope.requester.name) ||
  13127. $scope.requester.name == null ||
  13128. $scope.requester.name == ""
  13129. ) {
  13130. SweetAlert.swal(
  13131. "报修人姓名未填!",
  13132. "请填写报修人姓名",
  13133. "error"
  13134. );
  13135. } else if (
  13136. angular.isUndefined($scope.requester.requesterType) ||
  13137. $scope.requester.requesterType == null ||
  13138. $scope.requester.requesterTypeDTO == ""
  13139. ) {
  13140. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13141. } else if (
  13142. angular.isUndefined($scope.requester.mphone) ||
  13143. $scope.requester.mphone == null ||
  13144. $scope.requester.mphone == ""
  13145. ) {
  13146. SweetAlert.swal(
  13147. "报修人联系电话未填!",
  13148. "请填写报修人联系电话",
  13149. "error"
  13150. );
  13151. } else {
  13152. $scope.requesterId = $scope.requester.id;
  13153. var data = {
  13154. incident: {
  13155. requester: {
  13156. id: $scope.requesterId,
  13157. },
  13158. },
  13159. idx: 0,
  13160. sum: 3,
  13161. };
  13162. api_statistic
  13163. .tableData(data, "incident")
  13164. .then(function (data) {
  13165. sco.$parent.$parent.$parent.model.incident.tableList =
  13166. data.list;
  13167. });
  13168. $scope.$watch(
  13169. sco.$parent.$parent.$parent.model.incident.tableList,
  13170. function (oldObj, newObj) {
  13171. if (newObj != oldObj) {
  13172. sco.$parent.$parent.$parent.model.incident.tableList =
  13173. newObj;
  13174. }
  13175. }
  13176. ); //lmm
  13177. console.log($scope.requester);
  13178. $modalInstance.close($scope.requester);
  13179. }
  13180. };
  13181. $scope.cancel = function () {
  13182. $modalInstance.dismiss("cancel");
  13183. };
  13184. },
  13185. resolve: {
  13186. items: function () {
  13187. return {
  13188. fetchItems: function (filterData, APIService) {
  13189. filterData = filterData || {};
  13190. if (!filterData.idx) {
  13191. filterData = {
  13192. idx: 0,
  13193. sum: 10,
  13194. };
  13195. }
  13196. return options.templateOptions.fetchItems(
  13197. filterData,
  13198. APIService
  13199. );
  13200. },
  13201. };
  13202. },
  13203. title: function () {
  13204. return options.templateOptions.modalTitle;
  13205. },
  13206. Restangular: function () {
  13207. return options.templateOptions.Restangular;
  13208. },
  13209. APIService: function () {
  13210. return options.templateOptions.ApiService;
  13211. },
  13212. UserService: function () {
  13213. return options.templateOptions.UserService;
  13214. },
  13215. sco: function () {
  13216. return $scope;
  13217. },
  13218. },
  13219. });
  13220. modalInstance.result.then(
  13221. function (selectedItem) {
  13222. console.log(selectedItem);
  13223. if (selectedItem) {
  13224. var data = {
  13225. requester: selectedItem,
  13226. };
  13227. $scope.searchKey = selectedItem.account;
  13228. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13229. // if (selectedItem.place && selectedItem.place.place) {
  13230. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13231. // }
  13232. options.templateOptions.UserService.addData(
  13233. "requester",
  13234. data
  13235. ).then(function (response) {
  13236. if (response.status == 200) {
  13237. if (options.model) {
  13238. options.model.requester = response.data;
  13239. $scope.$parent.$parent.$parent.model.incident.requester =
  13240. response.data;
  13241. $scope.$parent.$parent.$parent.model.requestershow =
  13242. response.data;
  13243. if (options.model.place) {
  13244. options.model.place.id = "";
  13245. }
  13246. if (options.model.area) {
  13247. options.model.area.id = "";
  13248. }
  13249. options.model.contacts = selectedItem.name;
  13250. if (
  13251. selectedItem.mphone &&
  13252. selectedItem.mphone != null &&
  13253. selectedItem.mphone != ""
  13254. ) {
  13255. options.model.contactsInformation =
  13256. selectedItem.mphone;
  13257. } else {
  13258. options.model.contactsInformation =
  13259. selectedItem.telephone;
  13260. }
  13261. if (
  13262. selectedItem.requesterTypeDTO &&
  13263. selectedItem.requesterTypeDTO.id == 2
  13264. ) {
  13265. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13266. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13267. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13268. }
  13269. }
  13270. if (!response.data.id) {
  13271. response.data.id = selectedItem.id;
  13272. }
  13273. options.value(response.data);
  13274. options.value(response.data);
  13275. console.log($scope, "0000000");
  13276. //新增报修人带入区域地点2020年4月23日19:48:15
  13277. $scope.model.selecthouseNumber = selectedItem.place
  13278. ? selectedItem.place
  13279. : {};
  13280. $scope.$root.selecthouseNumber = selectedItem.place
  13281. ? selectedItem.place
  13282. : {};
  13283. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13284. if (selectedItem.place && selectedItem.place.id) {
  13285. options.model.place.id = selectedItem.place.id;
  13286. options.model.place.area.id =
  13287. selectedItem.place.area.id;
  13288. }
  13289. } else {
  13290. if (selectedItem.place && selectedItem.place.id) {
  13291. options.model.place.id = selectedItem.place.id;
  13292. options.model.area.id = selectedItem.place.area.id;
  13293. }
  13294. }
  13295. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13296. // options.model.area.id = selectedItem.place.area.id
  13297. // }
  13298. if (selectedItem.houseNumber) {
  13299. options.model.houseNumber = selectedItem.houseNumber;
  13300. }
  13301. // if (selectedItem.id) {
  13302. options.model.account = selectedItem.account;
  13303. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  13304. var baoxiuFields =
  13305. $scope.$parent.$parent.$parent.$parent.$parent.vm
  13306. .fields[1].fields;
  13307. var baoxiurenTo;
  13308. baoxiuFields.forEach((e, i) => {
  13309. if (e.key == "account") {
  13310. baoxiurenTo = e.templateOptions;
  13311. baoxiurenTo.APIService.fetchDataList("requester", {
  13312. idx: 0,
  13313. sum: 20,
  13314. requester: {
  13315. searchKey: selectedItem.account,
  13316. },
  13317. }).then((res) => {
  13318. baoxiurenTo.options = res.list;
  13319. options.model.account = selectedItem.account;
  13320. });
  13321. }
  13322. });
  13323. // }
  13324. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  13325. // 选择重复事件侧滑框
  13326. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  13327. $scope.$parent.$parent.$parent.model[
  13328. "repeatIncidentShow"
  13329. ] = false;
  13330. setTimeout(() => {
  13331. $scope.$parent.$parent.$parent.model[
  13332. "repeatIncidentShow"
  13333. ] = true;
  13334. }, 500);
  13335. // }
  13336. } else {
  13337. modalInstance.SweetAlert.swal({
  13338. title: "系统错误",
  13339. text: "账号重复!",
  13340. type: "error",
  13341. });
  13342. }
  13343. });
  13344. }
  13345. },
  13346. function () {}
  13347. );
  13348. },
  13349. changeRequeter: function (
  13350. size,
  13351. options,
  13352. modal,
  13353. modeldata,
  13354. $rootScope
  13355. ) {
  13356. var modalInstance = modal.open({
  13357. templateUrl:
  13358. "assets/views/customform/tpl/modal-change-requester.html",
  13359. controller: function (
  13360. $scope,
  13361. $modalInstance,
  13362. items,
  13363. SweetAlert,
  13364. title,
  13365. Restangular,
  13366. APIService,
  13367. UserService,
  13368. api_user_data,
  13369. $rootScope
  13370. ) {
  13371. $scope.title = "修改报修人";
  13372. $scope.requester = {
  13373. id: modeldata.requester.id,
  13374. account: modeldata.requester.account,
  13375. name: modeldata.requester.name,
  13376. gender: modeldata.requester.gender,
  13377. email: modeldata.requester.email,
  13378. deptName: modeldata.requester.deptName,
  13379. mphone: modeldata.requester.mphone,
  13380. telephone: modeldata.requester.telephone,
  13381. studentNo: modeldata.requester.studentNo,
  13382. areaDTO: modeldata.requester.areaDTO,
  13383. placeDTO: modeldata.requester.placeDTO,
  13384. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  13385. };
  13386. $scope.onChangeadd = function (searchData) {
  13387. console.log(searchData);
  13388. $scope.searchKey = searchData.account;
  13389. var requesdata = angular.copy(searchData);
  13390. if (requesdata.mphone) {
  13391. delete requesdata.mphone;
  13392. }
  13393. $scope.requester = requesdata;
  13394. };
  13395. $scope.refreshUseradd = function (searchKey) {
  13396. //请求人搜索
  13397. $scope.requester.account = searchKey;
  13398. $scope.searchData = searchKey;
  13399. serchdataadd(searchKey);
  13400. };
  13401. $scope.getMydata = function (x) {
  13402. $scope.searchField = JSON.parse(x[0]).account;
  13403. $scope.requester = JSON.parse(x[0]);
  13404. };
  13405. $scope.getMydataone = function (x) {
  13406. $scope.searchField = x;
  13407. $scope.requester.account = x;
  13408. };
  13409. serchdataadd();
  13410. function serchdataadd(searchKey) {
  13411. if (searchKey) {
  13412. var filterData = {
  13413. requester: {
  13414. searchKey: searchKey,
  13415. },
  13416. idx: 0,
  13417. sum: 10,
  13418. };
  13419. } else {
  13420. var filterData = {
  13421. idx: 0,
  13422. sum: 10,
  13423. };
  13424. }
  13425. api_user_data
  13426. .fetchDataList("requester", filterData)
  13427. .then(function (response) {
  13428. var myData = response;
  13429. $scope.myData = myData.list;
  13430. });
  13431. }
  13432. api_user_data
  13433. .fetchDataList("area", {
  13434. idx: 0,
  13435. sum: 1000,
  13436. })
  13437. .then(function (response) {
  13438. if (response.status == 200) {
  13439. $scope.areas = response.list;
  13440. }
  13441. });
  13442. api_user_data
  13443. .fetchDataList("requesterType", {
  13444. idx: 0,
  13445. sum: 100,
  13446. })
  13447. .then(function (response) {
  13448. if (response.status == 200) {
  13449. $scope.networktypes = response.list;
  13450. }
  13451. });
  13452. if (
  13453. $scope.requester.areaDTO &&
  13454. $scope.requester.areaDTO.id &&
  13455. $scope.requester.areaDTO.id != ""
  13456. ) {
  13457. api_user_data
  13458. .fetchDataList("place", {
  13459. place: {
  13460. areaId: $scope.requester.areaDTO.id,
  13461. },
  13462. idx: 0,
  13463. sum: 1000,
  13464. })
  13465. .then(function (response) {
  13466. if (response.status == 200) {
  13467. $scope.places = response.list;
  13468. }
  13469. });
  13470. }
  13471. $scope.onChange = function (item) {
  13472. $scope.requester.placeDTO = {};
  13473. api_user_data
  13474. .fetchDataList("place", {
  13475. place: {
  13476. areaId: item.id,
  13477. },
  13478. idx: 0,
  13479. sum: 1000,
  13480. })
  13481. .then(function (response) {
  13482. if (response.status == 200) {
  13483. $scope.places = response.list;
  13484. }
  13485. });
  13486. };
  13487. $scope.refreshDepts = function (key) {
  13488. var filterData = {
  13489. idx: 0,
  13490. sum: 5,
  13491. dept: {
  13492. name: key,
  13493. },
  13494. };
  13495. UserService.fetchDataList("department", filterData).then(
  13496. function (response) {
  13497. if (response.status == 200) {
  13498. $scope.depts = response.list;
  13499. }
  13500. }
  13501. );
  13502. };
  13503. $scope.ok = function () {
  13504. if (
  13505. $scope.requester.account == "" ||
  13506. $scope.requester.name == ""
  13507. ) {
  13508. SweetAlert.swal(
  13509. "报修人姓名或人员编号号未填!",
  13510. "请补全报修人信息",
  13511. "error"
  13512. );
  13513. } else {
  13514. $modalInstance.close($scope.requester);
  13515. }
  13516. };
  13517. $scope.cancel = function () {
  13518. $modalInstance.dismiss("cancel");
  13519. };
  13520. },
  13521. resolve: {
  13522. items: function () {
  13523. return {
  13524. fetchItems: function (filterData, APIService) {
  13525. filterData = filterData || {};
  13526. if (!filterData.idx) {
  13527. filterData = {
  13528. idx: 0,
  13529. sum: 10,
  13530. };
  13531. }
  13532. return options.templateOptions.fetchItems(
  13533. filterData,
  13534. APIService
  13535. );
  13536. },
  13537. };
  13538. },
  13539. title: function () {
  13540. return options.templateOptions.modalTitle;
  13541. },
  13542. Restangular: function () {
  13543. return options.templateOptions.Restangular;
  13544. },
  13545. APIService: function () {
  13546. return options.templateOptions.ApiService;
  13547. },
  13548. UserService: function () {
  13549. return options.templateOptions.UserService;
  13550. },
  13551. },
  13552. });
  13553. modalInstance.result.then(
  13554. function (selectedItem) {
  13555. console.log(selectedItem);
  13556. if (selectedItem) {
  13557. if (options.model) {
  13558. if (options.model.place) {
  13559. options.model.place.id = "";
  13560. }
  13561. if (options.model.area) {
  13562. options.model.area.id = "";
  13563. }
  13564. options.model.contacts = selectedItem.name;
  13565. if (
  13566. selectedItem.mphone &&
  13567. selectedItem.mphone != null &&
  13568. selectedItem.mphone != ""
  13569. ) {
  13570. options.model.contactsInformation = selectedItem.mphone;
  13571. } else {
  13572. options.model.contactsInformation =
  13573. selectedItem.telephone;
  13574. }
  13575. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  13576. options.model.place.id = selectedItem.placeDTO.id;
  13577. }
  13578. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  13579. options.model.area.id = selectedItem.areaDTO.id;
  13580. }
  13581. if (
  13582. selectedItem.requesterTypeDTO &&
  13583. selectedItem.requesterTypeDTO.id == 2
  13584. ) {
  13585. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13586. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13587. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13588. }
  13589. }
  13590. var data = {
  13591. requester: selectedItem,
  13592. };
  13593. options.templateOptions.UserService.addData(
  13594. "requester",
  13595. data
  13596. ).then(function (response) {
  13597. if (response.status == 200) {
  13598. $scope.$parent.$parent.$parent.model["requestershow"] =
  13599. selectedItem;
  13600. options.value(response.data);
  13601. } else {
  13602. }
  13603. });
  13604. }
  13605. },
  13606. function () {}
  13607. );
  13608. event.preventDefault();
  13609. },
  13610. },
  13611. };
  13612. },
  13613. controller: [
  13614. "$scope",
  13615. "api_user_data",
  13616. "api_statistic",
  13617. function ($scope, api_user_data, api_statistic) {
  13618. $scope.options.initialValue = $scope.model[$scope.options.key];
  13619. $scope.saveReqPlace = false;
  13620. $scope.model.saveReqPlace = false;
  13621. $scope.selectGradeBox = function () {
  13622. $scope.saveReqPlace = !$scope.saveReqPlace;
  13623. console.log($scope);
  13624. $scope.model.saveReqPlace = $scope.saveReqPlace;
  13625. };
  13626. if (
  13627. $scope.model.requester &&
  13628. $scope.model.requester.requesterTypeDTO &&
  13629. $scope.model.requester.requesterTypeDTO.id == 2
  13630. ) {
  13631. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13632. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13633. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13634. }
  13635. },
  13636. ],
  13637. });
  13638. // 请求人选控件
  13639. formlyConfigProvider.setType({
  13640. name: "ui-requesterselect",
  13641. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  13642. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13643. defaultOptions: function (options, $scope) {
  13644. return {
  13645. templateOptions: {
  13646. // checkform: function(options) {
  13647. // if (options.model.requestershow) {
  13648. // options.value(options.model.requestershow);
  13649. // }
  13650. // },
  13651. validators: {
  13652. required: {
  13653. expression: function (viewValue, modelValue) {
  13654. var value = modelValue || viewValue;
  13655. return value.length >= 1;
  13656. },
  13657. },
  13658. },
  13659. openModal: function (size, options, modal) {
  13660. //查找弹出框
  13661. var modelObject = options.value();
  13662. var searchModal = function (filterSearchData) {
  13663. var modalInstance = modal.open({
  13664. templateUrl:
  13665. "assets/views/customform/tpl/checktable-modal-content.html",
  13666. controller: function (
  13667. $scope,
  13668. scope,
  13669. i18nService,
  13670. $modalInstance,
  13671. items,
  13672. title,
  13673. Restangular,
  13674. APIService,
  13675. language,
  13676. searchDatas,
  13677. api_bpm_data
  13678. ) {
  13679. $scope.langs = i18nService.getAllLangs();
  13680. $scope.lang = "zh-cn";
  13681. i18nService.setCurrentLang($scope.lang);
  13682. $scope.gridOptions = {};
  13683. $scope.gridOptions.data = "myData";
  13684. $scope.gridOptions.enableColumnResizing = true;
  13685. $scope.gridOptions.enableFiltering = true;
  13686. $scope.gridOptions.enableGridMenu = false;
  13687. $scope.gridOptions.enableRowSelection = true;
  13688. $scope.gridOptions.showGridFooter = true;
  13689. $scope.gridOptions.showColumnFooter = false;
  13690. $scope.gridOptions.fastWatch = true;
  13691. $scope.gridOptions.useExternalFiltering = true;
  13692. $scope.gridOptions.useExternalPagination = true;
  13693. $scope.gridOptions.paginationPageSizes = [10];
  13694. $scope.gridOptions.paginationPageSize = 10;
  13695. $scope.gridOptions.multiSelect = false;
  13696. $scope.gridOptions.rowIdentity = function (row) {
  13697. return row.id;
  13698. };
  13699. $scope.gridOptions.getRowIdentity = function (row) {
  13700. return row.id;
  13701. };
  13702. $scope.gridOptions.columnDefs = [
  13703. {
  13704. name: "account",
  13705. displayName: "人员编号",
  13706. width: 140,
  13707. },
  13708. {
  13709. name: "name",
  13710. displayName: "姓名",
  13711. width: 100,
  13712. },
  13713. {
  13714. name: "gender.name",
  13715. displayName: "性别",
  13716. width: 80,
  13717. enableFiltering: false,
  13718. },
  13719. {
  13720. name: "mphone",
  13721. displayName: "电话",
  13722. width: 100,
  13723. enableFiltering: false,
  13724. },
  13725. {
  13726. name: "email",
  13727. displayName: "邮件",
  13728. width: 100,
  13729. },
  13730. {
  13731. name: "areaDTO.area",
  13732. displayName: "区域",
  13733. width: 100,
  13734. enableFiltering: false,
  13735. },
  13736. {
  13737. name: "placeDTO.place",
  13738. displayName: "地点",
  13739. enableFiltering: false,
  13740. },
  13741. ];
  13742. $scope.gridOptions.onRegisterApi = function (gridApi) {
  13743. $scope.gridApi = gridApi;
  13744. // var filtersData = $scope.memoryfilterData;
  13745. // filtersData.idx = newPage - 1;
  13746. // filtersData.sum = pageSize;
  13747. gridApi.pagination.on.paginationChanged(
  13748. $scope,
  13749. function (newPage, pageSize) {
  13750. var filtersData = $scope.memoryfilterData;
  13751. filtersData.idx = newPage - 1;
  13752. filtersData.sum = pageSize;
  13753. $scope.loadData(filtersData);
  13754. }
  13755. );
  13756. gridApi.selection.on.rowSelectionChanged(
  13757. $scope,
  13758. function (data) {
  13759. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  13760. $scope.selected.item = data.entity;
  13761. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  13762. }
  13763. );
  13764. gridApi.core.on.filterChanged($scope, function () {
  13765. var grid = this.grid;
  13766. var filtersData = {
  13767. idx: 0,
  13768. sum: 10,
  13769. // 'requester': { 'userType': 1 }
  13770. };
  13771. angular.forEach(grid.columns, function (item) {
  13772. if (item.enableFiltering) {
  13773. if (
  13774. angular.isDefined(item.filters[0].term) &&
  13775. item.filters[0].term != ""
  13776. ) {
  13777. if (angular.isUndefined(filtersData["requester"])) {
  13778. filtersData["requester"] = {};
  13779. }
  13780. filtersData["requester"][item.field] =
  13781. item.filters[0].term;
  13782. }
  13783. }
  13784. });
  13785. $scope.memoryfilterData = filtersData;
  13786. $scope.loadData(filtersData);
  13787. });
  13788. };
  13789. $scope.memoryfilterData = defaultFilterData = {
  13790. idx: 0,
  13791. sum: 10,
  13792. };
  13793. $scope.loadData = function (filterData) {
  13794. if (!filterData.requester) {
  13795. filterData.requester = {};
  13796. }
  13797. if (scope.roleidcode) {
  13798. angular.extend(filterData["requester"], {
  13799. userType: 1,
  13800. });
  13801. }
  13802. items
  13803. .fetchItems(filterData, APIService)
  13804. .then(function (data) {
  13805. var myData = Restangular.stripRestangular(data);
  13806. $scope.gridOptions.totalItems = myData.totalNum;
  13807. $scope.myData = myData.list;
  13808. });
  13809. };
  13810. // $scope.title = title;
  13811. if (searchDatas) {
  13812. $scope.loadData(searchDatas);
  13813. } else {
  13814. $scope.loadData({
  13815. idx: 0,
  13816. sum: 10,
  13817. });
  13818. }
  13819. $scope.selected = {
  13820. item: {},
  13821. };
  13822. $scope.ok = function () {
  13823. $modalInstance.close($scope.selected.item);
  13824. };
  13825. $scope.cancel = function () {
  13826. $modalInstance.dismiss("cancel");
  13827. };
  13828. },
  13829. size: size,
  13830. resolve: {
  13831. items: function () {
  13832. return {
  13833. fetchItems: function (filterData, APIService) {
  13834. filterData = filterData || {};
  13835. if (
  13836. angular.isUndefined(filterData.idx) ||
  13837. filterData.idx == null
  13838. ) {
  13839. filterData = {
  13840. idx: 0,
  13841. sum: 10,
  13842. };
  13843. }
  13844. return options.templateOptions.fetchItems(
  13845. filterData,
  13846. APIService
  13847. );
  13848. },
  13849. };
  13850. },
  13851. title: function () {
  13852. return options.templateOptions.modalTitle;
  13853. },
  13854. Restangular: function () {
  13855. return options.templateOptions.Restangular;
  13856. },
  13857. APIService: function () {
  13858. return options.templateOptions.ApiService;
  13859. },
  13860. language: function () {
  13861. return options.templateOptions.language;
  13862. },
  13863. searchDatas: function () {
  13864. return filterSearchData;
  13865. },
  13866. scope: function () {
  13867. return $scope;
  13868. },
  13869. },
  13870. });
  13871. modalInstance.result.then(
  13872. function (selectedItem) {
  13873. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  13874. selectedItem.telephone =
  13875. $scope.model.incident.contactsInformation;
  13876. }
  13877. $scope.$parent.$parent.$parent.model.incident["requester"] =
  13878. selectedItem;
  13879. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  13880. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  13881. if ($scope.model) {
  13882. if ($scope.model.incident.place) {
  13883. $scope.model.incident.place.id = "";
  13884. }
  13885. if ($scope.model.area) {
  13886. $scope.model.incident.area.id = "";
  13887. }
  13888. $scope.model.incident.contacts = selectedItem.name;
  13889. if (
  13890. selectedItem.mphone &&
  13891. selectedItem.mphone != null &&
  13892. selectedItem.mphone != ""
  13893. ) {
  13894. $scope.model.incident.contactsInformation =
  13895. selectedItem.mphone;
  13896. } else {
  13897. $scope.model.incident.contactsInformation =
  13898. selectedItem.telephone;
  13899. }
  13900. $scope.model.incident.houseNumber = "";
  13901. if (
  13902. selectedItem.requesterTypeDTO &&
  13903. selectedItem.requesterTypeDTO.id == 2
  13904. ) {
  13905. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13906. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13907. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13908. }
  13909. }
  13910. $scope.options.value(selectedItem);
  13911. $scope.searchData = selectedItem.account;
  13912. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  13913. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  13914. }
  13915. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  13916. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  13917. }
  13918. if (selectedItem.houseNumber) {
  13919. $scope.model.incident.houseNumber =
  13920. selectedItem.houseNumber;
  13921. }
  13922. if (
  13923. selectedItem.requesterTypeDTO &&
  13924. selectedItem.requesterTypeDTO.id == 2
  13925. ) {
  13926. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13927. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13928. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  13929. }
  13930. if (
  13931. options.templateOptions.callback &&
  13932. angular.isFunction(options.templateOptions.callback)
  13933. ) {
  13934. options.templateOptions.callback(selectedItem, options);
  13935. }
  13936. if (!$scope.roleidcode) {
  13937. $scope.charging(selectedItem, modal);
  13938. }
  13939. $scope.recentlyincident(selectedItem);
  13940. },
  13941. function () {
  13942. //console.log('Modal dismissed at: ' + new Date());
  13943. }
  13944. );
  13945. };
  13946. searchModal();
  13947. // }
  13948. },
  13949. },
  13950. };
  13951. },
  13952. controller: [
  13953. "$rootScope",
  13954. "$scope",
  13955. "ngTableParams",
  13956. "$filter",
  13957. "SweetAlert",
  13958. "moment",
  13959. function (
  13960. $rootScope,
  13961. $scope,
  13962. ngTableParams,
  13963. $filter,
  13964. SweetAlert,
  13965. moment
  13966. ) {
  13967. $scope.roleidcode = true;
  13968. // $scope.options.initialValue = undefined;
  13969. if ($rootScope.user && $rootScope.user.role) {
  13970. angular.forEach($rootScope.user.role, function (item) {
  13971. if (item.rolecode == "call center") {
  13972. $scope.roleidcode = false;
  13973. }
  13974. });
  13975. }
  13976. $scope.recently = false;
  13977. $scope.recentlyincident = function (key, model) {
  13978. //关联事件
  13979. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  13980. idx: 0,
  13981. sum: 4,
  13982. incident: {
  13983. requester: {
  13984. id: key.id,
  13985. },
  13986. },
  13987. }).then(function (response) {
  13988. if (response.status == 200) {
  13989. $scope.recently = true;
  13990. $scope.recentincident = response.list;
  13991. } else {
  13992. $scope.recently = false;
  13993. }
  13994. });
  13995. $scope.bodyHeight = window.innerHeight - 100;
  13996. $(window).resize(function () {
  13997. $scope.bodyHeight = window.innerHeight - 100;
  13998. });
  13999. // $scope.shows = false;
  14000. $scope.tempData = {};
  14001. $scope.close = function () {
  14002. $scope.changes = !$scope.changes;
  14003. event.preventDefault();
  14004. };
  14005. };
  14006. $scope.charging = function (key, model) {
  14007. //计费弹出框
  14008. //用户信息
  14009. $scope.information = {};
  14010. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14011. userId: key.account,
  14012. }).then(function (response) {
  14013. // if (response.status == 200) {
  14014. if (response && response.data) {
  14015. angular.extend($scope.information, response.data[0]);
  14016. // $scope.information = response.data[0];
  14017. $scope.information.autologicDestroyTime = moment(
  14018. response.data[0].autologicDestroyTime
  14019. ).format("YYYY-MM-DD");
  14020. $scope.information.periodStartTime = moment(
  14021. response.data[0].periodStartTime
  14022. ).format("YYYY-MM-DD");
  14023. $scope.information.nextBillingTime = moment(
  14024. response.data[0].nextBillingTime
  14025. ).format("YYYY-MM-DD");
  14026. } else if (response.err) {
  14027. SweetAlert.swal(
  14028. "系统错误!",
  14029. "用户信息未取到,请刷新重试",
  14030. "error"
  14031. );
  14032. }
  14033. // }
  14034. });
  14035. //上网明细
  14036. $scope.options.templateOptions.ApiSer.fetchDataList(
  14037. "queryOnlineDetail",
  14038. {
  14039. userId: key.account,
  14040. limit: "10",
  14041. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14042. "YYYY-MM-DD HH:mm:ss"
  14043. ),
  14044. toLogoutTime: moment(new Date().getTime()).format(
  14045. "YYYY-MM-DD HH:mm:ss"
  14046. ),
  14047. }
  14048. ).then(function (response) {
  14049. // if (response.status == 200) {
  14050. if (response && response.data) {
  14051. angular.forEach(response.data, function (item, index) {
  14052. if (item.logoutTime) {
  14053. response.data[index].logoutTime = moment(
  14054. item.logoutTime
  14055. ).format("YYYY-MM-DD HH:mm:ss");
  14056. }
  14057. if (item.loginTime) {
  14058. response.data[index].loginTime = moment(
  14059. item.loginTime
  14060. ).format("YYYY-MM-DD HH:mm:ss");
  14061. }
  14062. });
  14063. $scope.logininform = response.data;
  14064. } else if (response.err) {
  14065. SweetAlert.swal(
  14066. "系统错误!",
  14067. "上网明细未取到,请刷新重试",
  14068. "error"
  14069. );
  14070. }
  14071. });
  14072. //黑名单
  14073. // $scope.information.blacklist = "否"
  14074. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14075. userId: key.account,
  14076. }).then(function (response) {
  14077. // if (response.status == 200) {
  14078. // $scope.logininformation = response.data;
  14079. if (response) {
  14080. if (response.data || response.data != null) {
  14081. $scope.information.blacklist = "是";
  14082. } else {
  14083. if (response.err) {
  14084. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14085. } else {
  14086. $scope.information.blacklist = "否";
  14087. }
  14088. }
  14089. }
  14090. // }
  14091. });
  14092. $scope.bodyHeight = window.innerHeight - 100;
  14093. $(window).resize(function () {
  14094. $scope.bodyHeight = window.innerHeight - 100;
  14095. });
  14096. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14097. // $scope.closepages = function(e) {
  14098. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14099. // event.preventDefault();
  14100. // };
  14101. // $scope.shows = false;
  14102. $scope.tempData = {};
  14103. $scope.close = function () {
  14104. $scope.changes = !$scope.changes;
  14105. event.preventDefault();
  14106. };
  14107. };
  14108. $scope.options.templateOptions.ApiService.fetchDataList(
  14109. "requesterType",
  14110. {
  14111. idx: 0,
  14112. sum: 100,
  14113. }
  14114. ).then(function (response) {
  14115. if (response.status == 200) {
  14116. $scope.networktypes = response.list;
  14117. } else {
  14118. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14119. }
  14120. });
  14121. function serchdata(searchKey) {
  14122. if (searchKey) {
  14123. var filterData = {
  14124. requester: {
  14125. searchKey: searchKey,
  14126. // 'userType': 1
  14127. },
  14128. idx: 0,
  14129. sum: 10,
  14130. };
  14131. } else {
  14132. var filterData = {
  14133. idx: 0,
  14134. requester: {},
  14135. sum: 10,
  14136. };
  14137. }
  14138. if (
  14139. $scope.model.requester &&
  14140. $scope.model.requester.requesterTypeDTO
  14141. ) {
  14142. angular.extend(filterData.requester, {
  14143. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14144. });
  14145. if (!$scope.options.model.contactsInformation) {
  14146. $scope.options.model.contactsInformation =
  14147. $scope.model.requester.mphone;
  14148. }
  14149. }
  14150. if ($scope.roleidcode) {
  14151. angular.extend(filterData["requester"], {
  14152. userType: 1,
  14153. });
  14154. }
  14155. $scope.options.templateOptions.ApiService.fetchDataList(
  14156. "requester",
  14157. filterData
  14158. ).then(function (response) {
  14159. var myData = response;
  14160. $scope.myData = myData.list;
  14161. });
  14162. }
  14163. $scope.searchData = {};
  14164. $scope.refreshUser = function (searchKey) {
  14165. //请求人搜索
  14166. if (searchKey && searchKey != "") {
  14167. serchdata(searchKey);
  14168. }
  14169. };
  14170. if (
  14171. $scope.$parent.$parent.$parent.model.incident.callID ||
  14172. $scope.$parent.$parent.$parent.model.requestershow
  14173. ) {
  14174. if (!$scope.roleidcode) {
  14175. $scope.charging(
  14176. $scope.$parent.$parent.$parent.model.incident.requester
  14177. );
  14178. }
  14179. $scope.recentlyincident(
  14180. $scope.$parent.$parent.$parent.model.incident.requester
  14181. );
  14182. }
  14183. $scope.onChange = function (searchData) {
  14184. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14185. searchData.telephone = $scope.model.incident.contactsInformation;
  14186. }
  14187. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14188. searchData;
  14189. if (!$scope.roleidcode) {
  14190. $scope.charging(searchData);
  14191. }
  14192. $scope.recentlyincident(searchData);
  14193. $scope.accountshow = false;
  14194. if ($scope.model.incident) {
  14195. if ($scope.model.incident.place) {
  14196. $scope.model.incident.place.id = "";
  14197. }
  14198. if ($scope.model.incident.area) {
  14199. $scope.model.incident.area.id = "";
  14200. }
  14201. $scope.model.incident.contacts = searchData.name;
  14202. if (
  14203. searchData.mphone &&
  14204. searchData.mphone != null &&
  14205. searchData.mphone != ""
  14206. ) {
  14207. $scope.model.incident.contactsInformation = searchData.mphone;
  14208. } else {
  14209. $scope.model.incident.contactsInformation = searchData.telephone;
  14210. }
  14211. $scope.model.incident.houseNumber = "";
  14212. if (
  14213. searchData.requesterTypeDTO &&
  14214. searchData.requesterTypeDTO.id == 2
  14215. ) {
  14216. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14217. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14218. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14219. }
  14220. }
  14221. $scope.options.value(searchData);
  14222. $scope.searchKey = searchData.account;
  14223. if (searchData.placeDTO && searchData.placeDTO.id) {
  14224. $scope.model.incident.place.id = searchData.placeDTO.id;
  14225. }
  14226. if (searchData.areaDTO && searchData.areaDTO.id) {
  14227. $scope.model.incident.area.id = searchData.areaDTO.id;
  14228. }
  14229. if (searchData.houseNumber) {
  14230. $scope.model.incident.houseNumber = searchData.houseNumber;
  14231. }
  14232. if (
  14233. searchData.requesterTypeDTO &&
  14234. searchData.requesterTypeDTO.id == 2
  14235. ) {
  14236. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14237. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14238. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14239. }
  14240. };
  14241. },
  14242. ],
  14243. });
  14244. //ui-grid-table展示控件
  14245. formlyConfigProvider.setType({
  14246. name: "ui-grid-table",
  14247. // extends: 'multiCheckbox',//去掉冒号
  14248. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  14249. defaultOptions: function (options) {
  14250. return {
  14251. templateOptions: {
  14252. linkage: function () {},
  14253. },
  14254. };
  14255. },
  14256. controller: function (
  14257. $scope,
  14258. $rootScope,
  14259. i18nService,
  14260. Restangular,
  14261. api_bpm_data,
  14262. api_statistic,
  14263. $rootScope
  14264. ) {
  14265. var loginUser = $rootScope.user;
  14266. $scope.langs = i18nService.getAllLangs();
  14267. $scope.lang = "zh-cn";
  14268. i18nService.setCurrentLang($scope.lang);
  14269. $scope.gridOptions = {};
  14270. $scope.gridOptions.data = "myData";
  14271. $scope.gridOptions.enableColumnResizing = true;
  14272. $scope.gridOptions.enableGridMenu = false;
  14273. $scope.gridOptions.enableRowSelection = true;
  14274. $scope.gridOptions.showGridFooter = false;
  14275. $scope.gridOptions.showColumnFooter = false;
  14276. $scope.gridOptions.fastWatch = true;
  14277. $scope.gridOptions.useExternalFiltering = true;
  14278. $scope.gridOptions.useExternalPagination = false;
  14279. $scope.gridOptions.paginationPageSizes = [10];
  14280. $scope.gridOptions.paginationPageSize = 3;
  14281. $scope.gridOptions.multiSelect = false;
  14282. $scope.gridOptions.rowIdentity = function (row) {
  14283. return row.id;
  14284. };
  14285. $scope.gridOptions.getRowIdentity = function (row) {
  14286. return row.id;
  14287. };
  14288. $scope.gridOptions.columnDefs = [
  14289. {
  14290. name: "item",
  14291. displayName: "序号",
  14292. width: 80,
  14293. enableFiltering: false,
  14294. },
  14295. {
  14296. name: "incidentsign",
  14297. displayName: "单号",
  14298. width: 80,
  14299. enableFiltering: false,
  14300. },
  14301. {
  14302. name: "description",
  14303. displayName: "主题",
  14304. width: 80,
  14305. enableFiltering: false,
  14306. },
  14307. {
  14308. name: "state.name",
  14309. displayName: "状态",
  14310. width: 110,
  14311. enableFiltering: false,
  14312. },
  14313. {
  14314. name: "acceptDate",
  14315. displayName: "创建时间",
  14316. width: 160,
  14317. enableFiltering: false,
  14318. },
  14319. {
  14320. name: "requester.name",
  14321. displayName: "请求人",
  14322. width: 80,
  14323. enableFiltering: false,
  14324. },
  14325. {
  14326. name: "handlingPersonnelUser.name",
  14327. displayName: "处理人",
  14328. width: 160,
  14329. enableFiltering: false,
  14330. },
  14331. {
  14332. name: "place.place",
  14333. displayName: "区域地点",
  14334. width: 160,
  14335. enableFiltering: false,
  14336. },
  14337. ];
  14338. // var defaultFilterData = {
  14339. // "idx": 0,
  14340. // "sum": 3
  14341. // };
  14342. // // //分页控制
  14343. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14344. gridApi.pagination.on.paginationChanged(
  14345. $scope,
  14346. function (newPage, pageSize) {
  14347. var filtersData = $scope.memoryfilterData;
  14348. filtersData.idx = newPage - 1;
  14349. filtersData.sum = pageSize;
  14350. $scope.refreshData("expand-right", filtersData);
  14351. }
  14352. );
  14353. // 表格单选事件
  14354. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  14355. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  14356. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  14357. data.entity;
  14358. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  14359. data.entity.id;
  14360. var str =
  14361. data.grid.appScope.$parent.$parent.$parent.model.incident
  14362. .description || "";
  14363. str = str.split("").reverse().join("");
  14364. var del = addstr.split("").reverse().join("");
  14365. // console.log(del);
  14366. var reg = new RegExp(del);
  14367. str = str.replace(reg, "");
  14368. str = str.split("").reverse().join("");
  14369. if (
  14370. data.grid.appScope.$parent.$parent.$parent.model.incident
  14371. .associationType == "事件补充"
  14372. ) {
  14373. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  14374. null;
  14375. str += data.entity.description;
  14376. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14377. data.entity.description;
  14378. } else if (
  14379. data.grid.appScope.$parent.$parent.$parent.model.incident
  14380. .associationType == "事件已解决"
  14381. ) {
  14382. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  14383. "close";
  14384. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  14385. "";
  14386. }
  14387. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  14388. str;
  14389. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  14390. data.entity.id;
  14391. });
  14392. };
  14393. // 刷新表格
  14394. setInterval(function () {
  14395. // console.log($scope.myData);
  14396. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  14397. // console.log($scope.myData);
  14398. if ($scope.myData != null) {
  14399. for (var i = 0; i < $scope.myData.length; i++) {
  14400. //添加序号
  14401. $scope.myData[i]["item"] = i + 1;
  14402. }
  14403. }
  14404. }, 1000);
  14405. },
  14406. });
  14407. //处理人信息
  14408. formlyConfigProvider.setType({
  14409. name: "ui-userinformation",
  14410. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  14411. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14412. defaultOptions: function (options) {
  14413. return {
  14414. templateOptions: {},
  14415. };
  14416. },
  14417. controller: [
  14418. "$scope",
  14419. function ($scope) {
  14420. $scope.group = "";
  14421. $scope.role = "";
  14422. if (
  14423. angular.isDefined($scope.model.handlingPersonnelUser) &&
  14424. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14425. $scope.model.handlingPersonnelUser.group.length == 1
  14426. ) {
  14427. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14428. } else {
  14429. for (
  14430. var i = 0;
  14431. i < $scope.model.handlingPersonnelUser.group.length;
  14432. i++
  14433. ) {
  14434. $scope.group +=
  14435. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14436. }
  14437. }
  14438. if (
  14439. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  14440. $scope.model.handlingPersonnelUser.role.length == 1
  14441. ) {
  14442. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  14443. } else {
  14444. for (
  14445. var i = 0;
  14446. i < $scope.model.handlingPersonnelUser.role.length;
  14447. i++
  14448. ) {
  14449. $scope.role +=
  14450. $scope.model.handlingPersonnelUser.role[i].role + ",";
  14451. }
  14452. }
  14453. $scope.options.templateOptions.that = $scope;
  14454. },
  14455. ],
  14456. });
  14457. //处理界面处理人信息
  14458. formlyConfigProvider.setType({
  14459. name: "ui-handler",
  14460. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  14461. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14462. defaultOptions: function (options) {
  14463. return {
  14464. templateOptions: {},
  14465. };
  14466. },
  14467. controller: [
  14468. "$scope",
  14469. function ($scope) {
  14470. $scope.group = "";
  14471. // $scope.role="";
  14472. if (
  14473. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  14474. $scope.model.handlingPersonnelUser.group.length == 1
  14475. ) {
  14476. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  14477. } else {
  14478. for (
  14479. var i = 0;
  14480. i < $scope.model.handlingPersonnelUser.group.length;
  14481. i++
  14482. ) {
  14483. $scope.group +=
  14484. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  14485. }
  14486. }
  14487. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  14488. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  14489. // }else{
  14490. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  14491. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  14492. // }
  14493. // }
  14494. $scope.options.templateOptions.that = $scope;
  14495. },
  14496. ],
  14497. });
  14498. //微信事件流程
  14499. formlyConfigProvider.setType({
  14500. name: "ui-wxIncidentProcess",
  14501. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  14502. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14503. defaultOptions: function (options) {
  14504. return {
  14505. templateOptions: {},
  14506. };
  14507. },
  14508. controller: [
  14509. "$scope",
  14510. function ($scope) {
  14511. console.log($scope.model);
  14512. $scope.pingjia = false;
  14513. $scope.jiejue = false;
  14514. if ($scope.model.incidentState.value == "3") {
  14515. $scope.pingjia = true;
  14516. } else if ($scope.model.incidentState.value == "4") {
  14517. $scope.jiejue = true;
  14518. }
  14519. },
  14520. ],
  14521. });
  14522. //打电话
  14523. formlyConfigProvider.setType({
  14524. name: "ui-inputcall",
  14525. extends: "input",
  14526. templateUrl: "assets/views/customform/tpl/inputcall.html",
  14527. defaultOptions: function (options) {
  14528. return {
  14529. templateOptions: {
  14530. transform: function (value) {},
  14531. },
  14532. };
  14533. },
  14534. controller: [
  14535. "$scope",
  14536. "$rootScope",
  14537. "api_text",
  14538. "SweetAlert",
  14539. function ($scope, $rootScope, api_text, SweetAlert) {
  14540. $scope.dialout = function (teleno) {
  14541. var gid = "@0";
  14542. var telephone = "9" + teleno;
  14543. $rootScope.callout = 2;
  14544. if ($rootScope.takes) {
  14545. api_text
  14546. .dialout($rootScope.takes, gid, telephone)
  14547. .then(function (data) {
  14548. if (data.errno == 0) {
  14549. $rootScope.status = 6;
  14550. }
  14551. });
  14552. } else {
  14553. SweetAlert.swal({
  14554. title: "呼叫失败",
  14555. text: "请先签入呼叫中心!",
  14556. type: "error",
  14557. confirmButtonColor: "#DD6B55",
  14558. });
  14559. }
  14560. };
  14561. $scope.options.templateOptions.that = $scope;
  14562. },
  14563. ],
  14564. });
  14565. //关闭界面处理人信息
  14566. formlyConfigProvider.setType({
  14567. name: "ui-closehandler",
  14568. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  14569. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14570. defaultOptions: function (options) {
  14571. return {
  14572. templateOptions: {},
  14573. };
  14574. },
  14575. controller: [
  14576. "$scope",
  14577. "$rootScope",
  14578. "api_text",
  14579. function ($scope, $rootScope, api_text) {
  14580. $scope.dialout = function (teleno) {
  14581. var gid = "@0";
  14582. var telephone = "9" + teleno;
  14583. api_text
  14584. .dialout($rootScope.takes, gid, telephone)
  14585. .then(function (data) {
  14586. if (data.errno == 0) {
  14587. $rootScope.status = 6;
  14588. }
  14589. });
  14590. };
  14591. $scope.options.templateOptions.that = $scope;
  14592. },
  14593. ],
  14594. });
  14595. //用户单选控件
  14596. formlyConfigProvider.setType({
  14597. name: "ui-userselect",
  14598. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  14599. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14600. defaultOptions: function (options) {
  14601. return {
  14602. templateOptions: {
  14603. openModal: function (size, options, modal) {
  14604. var modalInstance = modal.open({
  14605. templateUrl:
  14606. "assets/views/customform/tpl/checktable-modal-content.html",
  14607. controller: function (
  14608. $scope,
  14609. i18nService,
  14610. $modalInstance,
  14611. items,
  14612. title,
  14613. Restangular,
  14614. APIService,
  14615. onDataCallback,
  14616. parentScope
  14617. ) {
  14618. $scope.langs = i18nService.getAllLangs();
  14619. $scope.lang = "zh-cn";
  14620. i18nService.setCurrentLang($scope.lang);
  14621. $scope.gridOptions = {};
  14622. $scope.gridOptions.data = "myData";
  14623. $scope.gridOptions.enableColumnResizing = true;
  14624. $scope.gridOptions.enableFiltering = true;
  14625. $scope.gridOptions.enableGridMenu = false;
  14626. $scope.gridOptions.showGridFooter = true;
  14627. $scope.gridOptions.showColumnFooter = false;
  14628. $scope.gridOptions.fastWatch = true;
  14629. $scope.gridOptions.useExternalFiltering = true;
  14630. $scope.gridOptions.useExternalPagination = true;
  14631. $scope.gridOptions.paginationPageSizes = [10];
  14632. $scope.gridOptions.paginationPageSize = 10;
  14633. $scope.gridOptions.multiSelect = false;
  14634. $scope.gridOptions.rowIdentity = function (row) {
  14635. return row.id;
  14636. };
  14637. $scope.gridOptions.getRowIdentity = function (row) {
  14638. return row.id;
  14639. };
  14640. $scope.gridOptions.rowTemplate =
  14641. '<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>';
  14642. $scope.gridOptions.columnDefs = [
  14643. {
  14644. name: "account",
  14645. displayName: "人员编号",
  14646. width: 120,
  14647. },
  14648. {
  14649. name: "name",
  14650. displayName: "姓名",
  14651. width: 100,
  14652. cellTemplate:
  14653. "<div>" +
  14654. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  14655. "</div>",
  14656. },
  14657. // {
  14658. // name: 'gender.name',
  14659. // displayName: '性别',
  14660. // width: 80,
  14661. // enableFiltering: false
  14662. // },
  14663. {
  14664. name: "phone",
  14665. displayName: "电话",
  14666. width: 230,
  14667. enableFiltering: false,
  14668. },
  14669. {
  14670. name: "email",
  14671. displayName: "邮箱",
  14672. width: 180,
  14673. enableFiltering: false,
  14674. },
  14675. {
  14676. name: "dept.dept",
  14677. displayName: "科室",
  14678. width: 130,
  14679. enableFiltering: false,
  14680. },
  14681. {
  14682. name: "taskCount",
  14683. displayName: "处理中事件数",
  14684. enableFiltering: false,
  14685. },
  14686. ];
  14687. // $scope.selectButtonClick
  14688. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14689. $scope.gridApi = gridApi;
  14690. gridApi.pagination.on.paginationChanged(
  14691. $scope,
  14692. function (newPage, pageSize) {
  14693. var filtersData = $scope.memoryfilterData;
  14694. filtersData.idx = newPage - 1;
  14695. filtersData.sum = pageSize;
  14696. $scope.loadData(filtersData);
  14697. //console.log(pageSize);
  14698. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  14699. }
  14700. );
  14701. gridApi.selection.on.rowSelectionChanged(
  14702. $scope,
  14703. function (data) {
  14704. $scope.selected.items = data.entity;
  14705. //console.log(data);
  14706. }
  14707. );
  14708. gridApi.selection.on.rowSelectionChangedBatch(
  14709. $scope,
  14710. function (data) {
  14711. $scope.selected.items = data.entity;
  14712. //console.log(data);
  14713. }
  14714. );
  14715. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  14716. // // if (row.entity.age > 45) {
  14717. // row.grid.api.selection.selectRow(row.entity); // 选中行
  14718. // // }
  14719. // };
  14720. gridApi.core.on.filterChanged($scope, function () {
  14721. var grid = this.grid;
  14722. var filtersData = {
  14723. idx: 0,
  14724. sum: 10,
  14725. user: {
  14726. roledata: {
  14727. rolecode: "roleset",
  14728. },
  14729. selectType: "1",
  14730. },
  14731. };
  14732. angular.forEach(grid.columns, function (item) {
  14733. if (item.enableFiltering) {
  14734. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  14735. if (
  14736. angular.isDefined(item.filters[0].term) &&
  14737. item.filters[0].term != ""
  14738. ) {
  14739. if (angular.isUndefined(filtersData["user"])) {
  14740. filtersData["user"] = {};
  14741. }
  14742. filtersData["user"][item.field] =
  14743. item.filters[0].term;
  14744. }
  14745. }
  14746. });
  14747. $scope.memoryfilterData = filtersData;
  14748. $scope.loadData(filtersData);
  14749. });
  14750. };
  14751. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  14752. // if (row.entity.age > 45) {
  14753. // row.grid.api.selection.selectRow(row.entity); // 选中行
  14754. // }
  14755. // },
  14756. $scope.onDblClick = function (data, event) {
  14757. // $scope.selected.items = data.entity;
  14758. $scope.selectButtonClick(data, event);
  14759. };
  14760. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  14761. // $scope.selected.items = data.entity;
  14762. // })
  14763. // };
  14764. $scope.memoryfilterData = {
  14765. idx: 0,
  14766. sum: 10,
  14767. user: {
  14768. roledata: {
  14769. rolecode: "roleset",
  14770. },
  14771. selectType: "1",
  14772. },
  14773. };
  14774. $scope.loadData = function (filterData) {
  14775. // console.log("filtersData=111" + JSON.stringify(filterData))
  14776. items
  14777. .fetchItems(filterData, APIService)
  14778. .then(function (data) {
  14779. var myData = Restangular.stripRestangular(data);
  14780. $scope.gridOptions.totalItems = myData.totalNum;
  14781. $scope.myData = myData.list;
  14782. });
  14783. };
  14784. // $scope.title = title;
  14785. $scope.loadData({
  14786. idx: 0,
  14787. sum: 10,
  14788. user: {
  14789. roledata: {
  14790. rolecode: "roleset",
  14791. },
  14792. selectType: "1",
  14793. },
  14794. });
  14795. $scope.selected = {
  14796. items: {},
  14797. };
  14798. $scope.ok = function () {
  14799. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  14800. // onDataCallback($scope.selected.item, parentScope);
  14801. // }
  14802. $modalInstance.close($scope.selected.items);
  14803. };
  14804. $scope.cancel = function () {
  14805. $modalInstance.dismiss("cancel");
  14806. };
  14807. },
  14808. size: size,
  14809. resolve: {
  14810. items: function () {
  14811. return {
  14812. fetchItems: function (filterData, APIService) {
  14813. filterData = filterData || {};
  14814. if (
  14815. angular.isDefined(filterData.idx) &&
  14816. filterData.idx == null
  14817. ) {
  14818. filterData = {
  14819. idx: 0,
  14820. sum: 10,
  14821. user: {
  14822. roledata: {
  14823. rolecode: "roleset",
  14824. },
  14825. selectType: "1",
  14826. },
  14827. };
  14828. }
  14829. return options.templateOptions.fetchItems(
  14830. filterData,
  14831. APIService
  14832. );
  14833. },
  14834. };
  14835. },
  14836. title: function () {
  14837. return options.templateOptions.label;
  14838. },
  14839. Restangular: function () {
  14840. return options.templateOptions.Restangular;
  14841. },
  14842. APIService: function () {
  14843. return options.templateOptions.ApiService;
  14844. },
  14845. onDataCallback: function () {
  14846. return options.templateOptions.callback;
  14847. },
  14848. parentScope: function () {
  14849. return options.templateOptions.that;
  14850. },
  14851. },
  14852. });
  14853. modalInstance.result.then(
  14854. function (selectedItem) {
  14855. // console.log(selectedItem);
  14856. options.value(selectedItem);
  14857. if (
  14858. options.templateOptions.callback &&
  14859. angular.isFunction(options.templateOptions.callback)
  14860. ) {
  14861. options.templateOptions.callback(
  14862. selectedItem,
  14863. options.templateOptions.that
  14864. );
  14865. }
  14866. if (
  14867. options.templateOptions.linkData &&
  14868. angular.isFunction(options.templateOptions.linkData)
  14869. ) {
  14870. options.templateOptions.linkData(
  14871. selectedItem,
  14872. options.templateOptions.that
  14873. );
  14874. }
  14875. },
  14876. function () {
  14877. //console.log('Modal dismissed at: ' + new Date());
  14878. }
  14879. );
  14880. },
  14881. },
  14882. };
  14883. },
  14884. controller: [
  14885. "$scope",
  14886. function ($scope) {
  14887. $scope.options.templateOptions.that = $scope;
  14888. // $scope.options.model[$scope.options.key] = {}
  14889. },
  14890. ],
  14891. });
  14892. //用户单选控件(dd 单选input带搜索)
  14893. formlyConfigProvider.setType({
  14894. name: "ui-userselectSearch",
  14895. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  14896. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14897. defaultOptions: function (options) {
  14898. return {
  14899. templateOptions: {
  14900. openModal: function (size, options, modal) {
  14901. var modalInstance = modal.open({
  14902. templateUrl:
  14903. "assets/views/customform/tpl/checktable-modal-content.html",
  14904. controller: function (
  14905. $scope,
  14906. i18nService,
  14907. $modalInstance,
  14908. items,
  14909. title,
  14910. Restangular,
  14911. APIService,
  14912. onDataCallback,
  14913. parentScope
  14914. ) {
  14915. $scope.langs = i18nService.getAllLangs();
  14916. $scope.lang = "zh-cn";
  14917. i18nService.setCurrentLang($scope.lang);
  14918. $scope.gridOptions = {};
  14919. $scope.gridOptions.data = "myData";
  14920. $scope.gridOptions.enableColumnResizing = true;
  14921. $scope.gridOptions.enableFiltering = true;
  14922. $scope.gridOptions.enableGridMenu = false;
  14923. $scope.gridOptions.showGridFooter = true;
  14924. $scope.gridOptions.showColumnFooter = false;
  14925. $scope.gridOptions.fastWatch = true;
  14926. $scope.gridOptions.useExternalFiltering = true;
  14927. $scope.gridOptions.useExternalPagination = true;
  14928. $scope.gridOptions.paginationPageSizes = [10];
  14929. $scope.gridOptions.paginationPageSize = 10;
  14930. $scope.gridOptions.multiSelect = false;
  14931. $scope.gridOptions.rowIdentity = function (row) {
  14932. return row.id;
  14933. };
  14934. $scope.gridOptions.getRowIdentity = function (row) {
  14935. return row.id;
  14936. };
  14937. $scope.gridOptions.rowTemplate =
  14938. '<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>';
  14939. $scope.gridOptions.columnDefs = [
  14940. {
  14941. name: "account",
  14942. displayName: "人员编号",
  14943. width: 120,
  14944. },
  14945. {
  14946. name: "name",
  14947. displayName: "姓名",
  14948. width: 100,
  14949. cellTemplate:
  14950. "<div>" +
  14951. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  14952. "</div>",
  14953. },
  14954. // {
  14955. // name: 'gender.name',
  14956. // displayName: '性别',
  14957. // width: 80,
  14958. // enableFiltering: false
  14959. // },
  14960. {
  14961. name: "phone",
  14962. displayName: "电话",
  14963. width: 230,
  14964. enableFiltering: false,
  14965. },
  14966. {
  14967. name: "email",
  14968. displayName: "邮箱",
  14969. width: 180,
  14970. enableFiltering: false,
  14971. },
  14972. {
  14973. name: "dept.dept",
  14974. displayName: "科室",
  14975. width: 130,
  14976. enableFiltering: false,
  14977. },
  14978. {
  14979. name: "taskCount",
  14980. displayName: "处理中事件数",
  14981. enableFiltering: false,
  14982. },
  14983. ];
  14984. // $scope.selectButtonClick
  14985. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14986. $scope.gridApi = gridApi;
  14987. gridApi.pagination.on.paginationChanged(
  14988. $scope,
  14989. function (newPage, pageSize) {
  14990. var filtersData = $scope.memoryfilterData;
  14991. filtersData.idx = newPage - 1;
  14992. filtersData.sum = pageSize;
  14993. $scope.loadData(filtersData);
  14994. //console.log(pageSize);
  14995. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  14996. }
  14997. );
  14998. gridApi.selection.on.rowSelectionChanged(
  14999. $scope,
  15000. function (data) {
  15001. $scope.selected.items = data.entity;
  15002. //console.log(data);
  15003. }
  15004. );
  15005. gridApi.selection.on.rowSelectionChangedBatch(
  15006. $scope,
  15007. function (data) {
  15008. $scope.selected.items = data.entity;
  15009. //console.log(data);
  15010. }
  15011. );
  15012. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15013. // // if (row.entity.age > 45) {
  15014. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15015. // // }
  15016. // };
  15017. gridApi.core.on.filterChanged($scope, function () {
  15018. var grid = this.grid;
  15019. var filtersData = {
  15020. idx: 0,
  15021. sum: 10,
  15022. user: {
  15023. roledata: {
  15024. rolecode: "first-line support",
  15025. },
  15026. selectType: "1",
  15027. },
  15028. };
  15029. angular.forEach(grid.columns, function (item) {
  15030. if (item.enableFiltering) {
  15031. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15032. if (
  15033. angular.isDefined(item.filters[0].term) &&
  15034. item.filters[0].term != ""
  15035. ) {
  15036. if (angular.isUndefined(filtersData["user"])) {
  15037. filtersData["user"] = {};
  15038. }
  15039. filtersData["user"][item.field] =
  15040. item.filters[0].term;
  15041. }
  15042. }
  15043. });
  15044. $scope.memoryfilterData = filtersData;
  15045. $scope.loadData(filtersData);
  15046. });
  15047. };
  15048. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15049. // if (row.entity.age > 45) {
  15050. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15051. // }
  15052. // },
  15053. $scope.onDblClick = function (data, event) {
  15054. // $scope.selected.items = data.entity;
  15055. $scope.selectButtonClick(data, event);
  15056. };
  15057. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15058. // $scope.selected.items = data.entity;
  15059. // })
  15060. // };
  15061. $scope.memoryfilterData = {
  15062. idx: 0,
  15063. sum: 10,
  15064. user: {
  15065. roledata: {
  15066. rolecode: "first-line support",
  15067. },
  15068. selectType: "1",
  15069. },
  15070. };
  15071. $scope.loadData = function (filterData) {
  15072. // console.log("filtersData=111" + JSON.stringify(filterData))
  15073. items
  15074. .fetchItems(filterData, APIService)
  15075. .then(function (data) {
  15076. var myData = Restangular.stripRestangular(data);
  15077. $scope.gridOptions.totalItems = myData.totalNum;
  15078. $scope.myData = myData.list;
  15079. });
  15080. };
  15081. $scope.title = title;
  15082. $scope.loadData({
  15083. idx: 0,
  15084. sum: 10,
  15085. user: {
  15086. roledata: {
  15087. rolecode: "first-line support",
  15088. },
  15089. selectType: "1",
  15090. },
  15091. });
  15092. $scope.selected = {
  15093. items: {},
  15094. };
  15095. $scope.ok = function () {
  15096. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15097. // onDataCallback($scope.selected.item, parentScope);
  15098. // }
  15099. $modalInstance.close($scope.selected.items);
  15100. };
  15101. $scope.cancel = function () {
  15102. $modalInstance.dismiss("cancel");
  15103. };
  15104. },
  15105. size: size,
  15106. resolve: {
  15107. items: function () {
  15108. return {
  15109. fetchItems: function (filterData, APIService) {
  15110. filterData = filterData || {};
  15111. if (
  15112. angular.isDefined(filterData.idx) &&
  15113. filterData.idx == null
  15114. ) {
  15115. filterData = {
  15116. idx: 0,
  15117. sum: 10,
  15118. user: {
  15119. roledata: {
  15120. rolecode: "first-line support",
  15121. },
  15122. selectType: "1",
  15123. },
  15124. };
  15125. }
  15126. return options.templateOptions.fetchItems(
  15127. filterData,
  15128. APIService
  15129. );
  15130. },
  15131. };
  15132. },
  15133. title: function () {
  15134. return options.templateOptions.label;
  15135. },
  15136. Restangular: function () {
  15137. return options.templateOptions.Restangular;
  15138. },
  15139. APIService: function () {
  15140. return options.templateOptions.ApiService;
  15141. },
  15142. onDataCallback: function () {
  15143. return options.templateOptions.callback;
  15144. },
  15145. parentScope: function () {
  15146. return options.templateOptions.that;
  15147. },
  15148. },
  15149. });
  15150. modalInstance.result.then(
  15151. function (selectedItem) {
  15152. // console.log(selectedItem);
  15153. options.value(selectedItem);
  15154. if (
  15155. options.templateOptions.callback &&
  15156. angular.isFunction(options.templateOptions.callback)
  15157. ) {
  15158. options.templateOptions.callback(
  15159. selectedItem,
  15160. options.templateOptions.that
  15161. );
  15162. }
  15163. if (
  15164. options.templateOptions.linkData &&
  15165. angular.isFunction(options.templateOptions.linkData)
  15166. ) {
  15167. options.templateOptions.linkData(
  15168. selectedItem,
  15169. options.templateOptions.that
  15170. );
  15171. }
  15172. },
  15173. function () {
  15174. //console.log('Modal dismissed at: ' + new Date());
  15175. }
  15176. );
  15177. },
  15178. },
  15179. };
  15180. },
  15181. controller: [
  15182. "$scope",
  15183. function ($scope) {
  15184. $scope.options.templateOptions.that = $scope;
  15185. },
  15186. ],
  15187. });
  15188. //用户多选控件
  15189. formlyConfigProvider.setType({
  15190. name: "ui-multiuserselect",
  15191. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  15192. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15193. defaultOptions: function (options) {
  15194. return {
  15195. templateOptions: {
  15196. openModal: function (size, options, modal, model) {
  15197. var modalInstance = modal.open({
  15198. templateUrl:
  15199. "assets/views/customform/tpl/checktable-modal-content.html",
  15200. controller: function (
  15201. $scope,
  15202. $modalInstance,
  15203. i18nService,
  15204. $timeout,
  15205. items,
  15206. title,
  15207. Restangular,
  15208. APIService,
  15209. selectItems
  15210. ) {
  15211. $scope.langs = i18nService.getAllLangs();
  15212. $scope.lang = "zh-cn";
  15213. i18nService.setCurrentLang($scope.lang);
  15214. $scope.gridOptions = {};
  15215. $scope.gridOptions.data = "myData";
  15216. $scope.gridOptions.enableColumnResizing = true;
  15217. $scope.gridOptions.enableFiltering = true;
  15218. $scope.gridOptions.enableGridMenu = true;
  15219. $scope.gridOptions.showGridFooter = true;
  15220. $scope.gridOptions.showColumnFooter = true;
  15221. $scope.gridOptions.fastWatch = true;
  15222. $scope.gridOptions.useExternalFiltering = true;
  15223. $scope.gridOptions.useExternalPagination = true;
  15224. $scope.gridOptions.paginationPageSizes = [10];
  15225. $scope.gridOptions.paginationPageSize = 10;
  15226. $scope.gridOptions.multiSelect = true;
  15227. $scope.gridOptions.rowIdentity = function (row) {
  15228. return row.id;
  15229. };
  15230. $scope.gridOptions.getRowIdentity = function (row) {
  15231. return row.id;
  15232. };
  15233. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  15234. $scope.gridOptions.columnDefs = [
  15235. // { name:'id', width:80, enableFiltering:false},
  15236. {
  15237. name: "account",
  15238. displayName: "账号",
  15239. width: 140,
  15240. },
  15241. {
  15242. name: "name",
  15243. displayName: "名称",
  15244. width: 100,
  15245. },
  15246. {
  15247. name: "gender.name",
  15248. displayName: "性别",
  15249. width: 140,
  15250. enableFiltering: false,
  15251. },
  15252. {
  15253. name: "phone",
  15254. displayName: "电话",
  15255. width: 100,
  15256. enableFiltering: false,
  15257. },
  15258. {
  15259. name: "email",
  15260. displayName: "邮件",
  15261. width: 100,
  15262. enableFiltering: false,
  15263. },
  15264. {
  15265. name: "dept.dept",
  15266. displayName: "科室",
  15267. width: 100,
  15268. enableFiltering: false,
  15269. },
  15270. {
  15271. name: "group[0].groupName",
  15272. displayName: "职位",
  15273. width: 100,
  15274. enableFiltering: false,
  15275. },
  15276. ];
  15277. $scope.selected = {
  15278. items: selectItems,
  15279. };
  15280. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15281. $scope.gridApi = gridApi;
  15282. gridApi.pagination.on.paginationChanged(
  15283. $scope,
  15284. function (newPage, pageSize) {
  15285. var filtersData = $scope.memoryfilterData;
  15286. filtersData.idx = newPage - 1;
  15287. filtersData.sum = pageSize;
  15288. $scope.loadData(filtersData);
  15289. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15290. }
  15291. );
  15292. gridApi.selection.on.rowSelectionChanged(
  15293. $scope,
  15294. function (scope) {
  15295. var j = 0;
  15296. for (
  15297. var i = 0;
  15298. i <= scope.grid.appScope.selected.items.length;
  15299. i++
  15300. ) {
  15301. if (
  15302. scope.grid.appScope.selected.items[i] == scope.entity
  15303. ) {
  15304. j++;
  15305. break;
  15306. }
  15307. }
  15308. if (j == 1) {
  15309. scope.grid.appScope.selected.items.splice(i, 1);
  15310. } else {
  15311. scope.grid.appScope.selected.items.push(scope.entity);
  15312. for (
  15313. var i = 0;
  15314. i < scope.grid.appScope.selected.items.length;
  15315. i++
  15316. ) {
  15317. for (
  15318. var z = 0;
  15319. z < scope.grid.appScope.selected.items.length;
  15320. z++
  15321. ) {
  15322. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  15323. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  15324. if (
  15325. angular.isDefined(
  15326. scope.grid.appScope.selected.items
  15327. ) &&
  15328. scope.grid.appScope.selected.items[i].id ==
  15329. scope.grid.appScope.selected.items[z].id &&
  15330. i != z
  15331. ) {
  15332. scope.grid.appScope.selected.items.splice(i, 1);
  15333. }
  15334. }
  15335. }
  15336. }
  15337. }
  15338. );
  15339. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  15340. // $scope.grid.appScope.selected.items.push($scope.entity);
  15341. // });
  15342. gridApi.core.on.filterChanged($scope, function () {
  15343. var grid = this.grid;
  15344. var filtersData = {
  15345. idx: 0,
  15346. sum: 10,
  15347. user: {
  15348. roledata: {
  15349. rolecode: options.model.currentRole,
  15350. },
  15351. selectType: "1",
  15352. },
  15353. };
  15354. angular.forEach(grid.columns, function (item) {
  15355. if (item.enableFiltering) {
  15356. //console.log("filtersData="+JSON.stringify(filtersData))
  15357. if (
  15358. angular.isDefined(item.filters[0].term) &&
  15359. item.filters[0].term != ""
  15360. ) {
  15361. if (angular.isUndefined(filtersData["user"])) {
  15362. filtersData["user"] = {};
  15363. }
  15364. filtersData["user"][item.field] =
  15365. item.filters[0].term;
  15366. }
  15367. }
  15368. });
  15369. $scope.memoryfilterData = filtersData;
  15370. $scope.loadData(filtersData);
  15371. });
  15372. };
  15373. if (!options.model) {
  15374. var mouse = {
  15375. model: {
  15376. currentRole: "",
  15377. },
  15378. };
  15379. angular.extend(options, mouse);
  15380. }
  15381. $scope.memoryfilterData = {
  15382. idx: 0,
  15383. sum: 10,
  15384. user: {
  15385. roledata: {
  15386. rolecode: options.model.currentRole,
  15387. },
  15388. selectType: "1",
  15389. },
  15390. };
  15391. $scope.loadData = function (filterData) {
  15392. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  15393. items
  15394. .fetchItems(filterData, APIService)
  15395. .then(function (data) {
  15396. var myData = Restangular.stripRestangular(data);
  15397. $scope.gridOptions.totalItems = myData.totalNum;
  15398. $scope.myData = myData.list;
  15399. //console.log($scope.gridOptions.pagination.getTotalPages());
  15400. // if($scope.selected.items){
  15401. // angular.forEach($scope.selected.items,function(selectItem){
  15402. // $scope.gridApi.selection.selectRow(selectItem);
  15403. // });
  15404. // }
  15405. });
  15406. };
  15407. // $scope.title = title;
  15408. $scope.loadData({
  15409. idx: 0,
  15410. sum: 10,
  15411. user: {
  15412. roledata: {
  15413. rolecode: options.model.currentRole,
  15414. },
  15415. selectType: "1",
  15416. },
  15417. });
  15418. // $timeout(function(){
  15419. // if($scope.selected.items){
  15420. // angular.forEach($scope.selected.items,function(selectItem){
  15421. // $scope.gridApi.selection.selectRow(selectItem);
  15422. // });
  15423. // }
  15424. // },2000)
  15425. $scope.ok = function () {
  15426. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  15427. $modalInstance.close($scope.selected.items);
  15428. };
  15429. $scope.cancel = function () {
  15430. $modalInstance.dismiss("cancel");
  15431. };
  15432. },
  15433. size: size,
  15434. resolve: {
  15435. items: function () {
  15436. return {
  15437. fetchItems: function (filterData, APIService) {
  15438. filterData = filterData || {};
  15439. if (
  15440. angular.isDefined(filterData.idx) &&
  15441. filterData.idx == null
  15442. ) {
  15443. filterData = {
  15444. idx: 0,
  15445. sum: 10,
  15446. user: {
  15447. roledata: {
  15448. rolecode: options.model.incident.currentRole,
  15449. },
  15450. selectType: "1",
  15451. },
  15452. };
  15453. }
  15454. return options.templateOptions.fetchItems(
  15455. filterData,
  15456. APIService
  15457. );
  15458. },
  15459. };
  15460. },
  15461. title: function () {
  15462. return options.templateOptions.modalTitle;
  15463. },
  15464. Restangular: function () {
  15465. return options.templateOptions.Restangular;
  15466. },
  15467. APIService: function () {
  15468. return options.templateOptions.ApiService;
  15469. },
  15470. selectItems: function () {
  15471. return model || [];
  15472. },
  15473. },
  15474. });
  15475. modalInstance.result.then(
  15476. function (selectedItem) {
  15477. options.value(selectedItem);
  15478. options.formControl.$validate();
  15479. },
  15480. function () {
  15481. //console.log('Modal dismissed at: ' + new Date());
  15482. }
  15483. );
  15484. },
  15485. },
  15486. validators: {
  15487. required: {
  15488. expression: function (viewValue, modelValue) {
  15489. var value = modelValue || viewValue;
  15490. return value.length >= 1;
  15491. },
  15492. },
  15493. },
  15494. };
  15495. },
  15496. controller: [
  15497. "$scope",
  15498. function ($scope) {
  15499. $scope.model[$scope.options.key] = [];
  15500. $scope.remove = function (itemId) {
  15501. angular.forEach(
  15502. $scope.model[$scope.options.key],
  15503. function (entry, index) {
  15504. if (entry.id == itemId) {
  15505. $scope.model[$scope.options.key].splice(index, 1);
  15506. // console.log($scope.options.formControl)
  15507. $scope.options.formControl.$validate();
  15508. } else {
  15509. }
  15510. }
  15511. );
  15512. };
  15513. },
  15514. ],
  15515. });
  15516. //用户多选控件-字符串展示
  15517. formlyConfigProvider.setType({
  15518. name: "ui-stringuserselect",
  15519. extends: "input",
  15520. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  15521. defaultOptions: function (options) {
  15522. return {
  15523. templateOptions: {
  15524. translate: "",
  15525. refreshDelay: 0,
  15526. },
  15527. };
  15528. },
  15529. controller: [
  15530. "$scope",
  15531. function ($scope) {
  15532. var keydata = "";
  15533. if (angular.isArray($scope.model)) {
  15534. angular.forEach($scope.model, function (item) {
  15535. keydata = keydata + "," + item.name;
  15536. });
  15537. }
  15538. // $scope.model[$scope.options.key] = [];
  15539. },
  15540. ],
  15541. });
  15542. //重复事件
  15543. formlyConfigProvider.setType({
  15544. name: "ui-incidentmodelselect",
  15545. extends: "input",
  15546. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  15547. defaultOptions: function (options) {
  15548. return {
  15549. templateOptions: {
  15550. openModal: function (size, options, modal) {
  15551. var modalInstance = modal.open({
  15552. templateUrl:
  15553. "assets/views/customform/tpl/checktable-modal-content.html",
  15554. controller: function (
  15555. $scope,
  15556. $rootScope,
  15557. $modalInstance,
  15558. items,
  15559. title,
  15560. Restangular,
  15561. APIService,
  15562. i18nService,
  15563. api_configure_data,
  15564. api_user_data,
  15565. api_bpm_data
  15566. ) {
  15567. $scope.langs = i18nService.getAllLangs();
  15568. $scope.lang = "zh-cn";
  15569. i18nService.setCurrentLang($scope.lang);
  15570. $scope.gridOptions = {};
  15571. $scope.gridOptions.data = "myData";
  15572. $scope.gridOptions.enableColumnResizing = true;
  15573. $scope.gridOptions.enableFiltering = true;
  15574. $scope.gridOptions.enableGridMenu = false;
  15575. $scope.gridOptions.enableRowSelection = true;
  15576. $scope.gridOptions.showGridFooter = true;
  15577. $scope.gridOptions.showColumnFooter = false;
  15578. $scope.gridOptions.fastWatch = true;
  15579. $scope.gridOptions.useExternalFiltering = true;
  15580. $scope.gridOptions.useExternalPagination = true;
  15581. $scope.gridOptions.paginationPageSizes = [10];
  15582. $scope.gridOptions.paginationPageSize = 10;
  15583. $scope.gridOptions.multiSelect = false;
  15584. var mun = $scope.gridOptions.paginationPageSize;
  15585. $scope.gridOptions.rowIdentity = function (row) {
  15586. return row.id;
  15587. };
  15588. $scope.gridOptions.getRowIdentity = function (row) {
  15589. return row.id;
  15590. };
  15591. $scope.gridOptions.columnDefs = items.columnDefs();
  15592. $scope.transferTime = function (time) {
  15593. return moment(time).format("YYYY-MM-DD HH:mm");
  15594. };
  15595. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15596. $scope.gridApi = gridApi;
  15597. gridApi.pagination.on.paginationChanged(
  15598. $scope,
  15599. function (newPage, pageSize) {
  15600. // console.log(newPage);
  15601. // console.log(pageSize);
  15602. $scope.loadData({
  15603. idx: newPage - 1,
  15604. sum: pageSize,
  15605. });
  15606. }
  15607. );
  15608. gridApi.core.on.filterChanged($scope, function () {
  15609. var grid = this.grid;
  15610. var filtersData = {
  15611. idx: 0,
  15612. sum: 100,
  15613. };
  15614. angular.forEach(grid.columns, function (item) {
  15615. if (item.enableFiltering) {
  15616. if (
  15617. angular.isDefined(item.filters[0].term) &&
  15618. item.filters[0].term != ""
  15619. ) {
  15620. // console.log("filtersData="+JSON.stringify(filtersData))
  15621. if (angular.isUndefined(filtersData["incident"])) {
  15622. filtersData["incident"] = {};
  15623. }
  15624. filtersData["incident"][item.field] =
  15625. item.filters[0].term;
  15626. if (angular.isUndefined(filtersData["problem"])) {
  15627. filtersData["problem"] = {};
  15628. }
  15629. filtersData["problem"][item.field] =
  15630. item.filters[0].term;
  15631. if (angular.isUndefined(filtersData["change"])) {
  15632. filtersData["change"] = {};
  15633. }
  15634. filtersData["change"][item.field] =
  15635. item.filters[0].term;
  15636. if (angular.isUndefined(filtersData["release"])) {
  15637. filtersData["release"] = {};
  15638. }
  15639. filtersData["release"][item.field] =
  15640. item.filters[0].term;
  15641. }
  15642. }
  15643. });
  15644. $scope.loadData(filtersData);
  15645. });
  15646. gridApi.selection.on.rowSelectionChanged(
  15647. $scope,
  15648. function (data) {
  15649. $scope.selected.item = data.entity;
  15650. //console.log(data);
  15651. }
  15652. );
  15653. };
  15654. //资产
  15655. $scope.cmdb = {};
  15656. //资产状态
  15657. $scope.state_data = [
  15658. {
  15659. name: "全部状态",
  15660. value: "",
  15661. },
  15662. {
  15663. name: "在库",
  15664. value: "1",
  15665. },
  15666. {
  15667. name: "在线",
  15668. value: "2",
  15669. },
  15670. {
  15671. name: "借出",
  15672. value: "3",
  15673. },
  15674. {
  15675. name: "报修",
  15676. value: "4",
  15677. },
  15678. {
  15679. name: "报废",
  15680. value: "5",
  15681. },
  15682. {
  15683. name: "备用",
  15684. value: "6",
  15685. },
  15686. ];
  15687. //资产类型
  15688. $scope.wt_zcfl = function () {
  15689. api_configure_data
  15690. .fetchDataList("ciclassify", {
  15691. idx: 0,
  15692. sum: 100,
  15693. })
  15694. .then(function (data) {
  15695. console.log(data);
  15696. // $scope.wt_zclx = data.list;
  15697. console.log(data);
  15698. $scope.wtData = [];
  15699. if (data.status == 200) {
  15700. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  15701. var root = null; //Initially set our loop to null
  15702. var parentNode = null;
  15703. //loop over data
  15704. // $scope.wtData=data.list;
  15705. data = data.list;
  15706. //知识库分类数据三级处理
  15707. for (var i = 0; i < data.length; i++) {
  15708. // console.log(data[i])
  15709. var datum = data[i];
  15710. //each node will have children, so let's give it a "children" poperty
  15711. // console.log(datum);
  15712. datum.children = [];
  15713. if (!datum.parent) {
  15714. $scope.wtData.push(datum);
  15715. // console.log($scope.wtData)
  15716. } else {
  15717. if ($scope.wtData[0]) {
  15718. if ($scope.wtData[0].id == datum.parent.id) {
  15719. $scope.wtData[0].children.push(datum);
  15720. }
  15721. for (
  15722. var j = 0;
  15723. j < $scope.wtData[0].children.length;
  15724. j++
  15725. ) {
  15726. if (
  15727. $scope.wtData[0].children[j].id ==
  15728. datum.parent.id
  15729. ) {
  15730. $scope.wtData[0].children[j].children.push(
  15731. datum
  15732. );
  15733. }
  15734. }
  15735. }
  15736. if ($scope.wtData[1]) {
  15737. if ($scope.wtData[1].id == datum.parent.id) {
  15738. $scope.wtData[1].children.push(datum);
  15739. }
  15740. for (
  15741. var j = 0;
  15742. j < $scope.wtData[1].children.length;
  15743. j++
  15744. ) {
  15745. if (
  15746. $scope.wtData[1].children[j].id ==
  15747. datum.parent.id
  15748. ) {
  15749. $scope.wtData[1].children[j].children.push(
  15750. datum
  15751. );
  15752. }
  15753. }
  15754. }
  15755. if ($scope.wtData[2]) {
  15756. if ($scope.wtData[2].id == datum.parent.id) {
  15757. $scope.wtData[2].children.push(datum);
  15758. }
  15759. for (
  15760. var j = 0;
  15761. j < $scope.wtData[2].children.length;
  15762. j++
  15763. ) {
  15764. if (
  15765. $scope.wtData[2].children[j].id ==
  15766. datum.parent.id
  15767. ) {
  15768. $scope.wtData[2].children[j].children.push(
  15769. datum
  15770. );
  15771. }
  15772. }
  15773. }
  15774. }
  15775. // console.log($scope.wtData)
  15776. idToNodeMap[datum.id] = datum;
  15777. root = datum;
  15778. // treeMap[datum.id] = root;
  15779. }
  15780. }
  15781. });
  15782. };
  15783. $scope.wt_zcfl();
  15784. //事件
  15785. //受理人,处理人
  15786. $scope.searchkeys = {};
  15787. var fieldata = {
  15788. idx: 0,
  15789. sum: 100,
  15790. flag: -1,
  15791. };
  15792. getUser(fieldata, 3);
  15793. function getUser(fieldatas, it) {
  15794. api_user_data
  15795. .fetchDataList("user", fieldatas)
  15796. .then(function (data) {
  15797. if (it == 1) {
  15798. $scope.acceptUser = data.list;
  15799. } else if (it == 2) {
  15800. $scope.handlingPersonnelUser = data.list;
  15801. } else if (it == 3) {
  15802. $scope.acceptUser = data.list;
  15803. $scope.handlingPersonnelUser = data.list;
  15804. }
  15805. });
  15806. }
  15807. //状态
  15808. $scope.othcode = {};
  15809. api_bpm_data
  15810. .fetchDataList("incidentstatus", {
  15811. idx: 0,
  15812. sum: 100,
  15813. })
  15814. .then(function (response) {
  15815. if (response) {
  15816. if ((response.status = 200)) {
  15817. $scope.state = response.list;
  15818. }
  15819. }
  15820. });
  15821. var defaultFilterData = {
  15822. assignee: $rootScope.user.id,
  15823. searchType: "todo",
  15824. idx: 0,
  15825. sum: mun,
  15826. };
  15827. var defaultFilterData1 = {
  15828. // "searchType": "todo",
  15829. idx: 0,
  15830. sum: mun,
  15831. };
  15832. //搜索
  15833. $scope.chiceIncident = function (parameters, item, stateid) {
  15834. console.log(item, stateid);
  15835. console.log($scope);
  15836. if ($scope.title == "关联资产编号") {
  15837. // alert('222222222222');
  15838. var fildata = defaultFilterData1;
  15839. $scope.gridOptions.paginationCurrentPage = 1;
  15840. var transitiondata = angular.copy(item);
  15841. angular.extend(fildata, transitiondata);
  15842. if (fildata.hw_state) {
  15843. fildata.hw_state = fildata.hw_state.name;
  15844. }
  15845. if (fildata.sign) {
  15846. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  15847. fildata.sign = fildata.sign.split(";");
  15848. fildata.sign = fildata.sign.join("");
  15849. fildata.sign = fildata.sign.toLowerCase();
  15850. }
  15851. if (fildata.keys) {
  15852. fildata["searchCriteria"] = "uuid";
  15853. }
  15854. console.log(fildata);
  15855. $scope.loadData(fildata);
  15856. }
  15857. if ($scope.title == "关联事件工单") {
  15858. // alert('3333333333333333')
  15859. if (stateid && stateid.code) {
  15860. item.statusId = stateid.code;
  15861. }
  15862. var fildata = defaultFilterData;
  15863. // $scope.memoryfilterData = fildata;
  15864. if (!fildata.incident) {
  15865. fildata["incident"] = {};
  15866. }
  15867. $scope.gridOptions.paginationCurrentPage = 1;
  15868. var transitiondata = angular.copy(item);
  15869. angular.extend(fildata.incident, transitiondata);
  15870. console.log(fildata);
  15871. // $scope.loadData(fildata);
  15872. api_bpm_data
  15873. .fetchDataList("incident", fildata)
  15874. .then(function (data) {
  15875. console.log(data);
  15876. if (data) {
  15877. $scope.myData = data.list;
  15878. $scope.gridOptions.totalItems = data.totalNum;
  15879. }
  15880. });
  15881. }
  15882. };
  15883. //重置
  15884. $scope.replacement = function (
  15885. parameters,
  15886. searchkeys,
  15887. othcode
  15888. ) {
  15889. // console.log(parameters, searchkeys, othcode);
  15890. delete defaultFilterData.incident;
  15891. console.log(defaultFilterData);
  15892. $scope.parameters = null;
  15893. $scope.searchkeys = {};
  15894. $scope.othcode = {};
  15895. $scope.wt_zcfl();
  15896. };
  15897. $scope.loadData = function (filterData) {
  15898. items
  15899. .fetchItems(filterData, APIService, $rootScope)
  15900. .then(function (data) {
  15901. var myData = Restangular.stripRestangular(data);
  15902. if (myData.data && myData.data.node) {
  15903. $scope.gridOptions.totalItems = myData.total;
  15904. $scope.myData = myData.data.node;
  15905. } else {
  15906. if (myData.resultCount) {
  15907. $scope.gridOptions["totalItems"] = myData.resultCount;
  15908. } else {
  15909. $scope.gridOptions.totalItems = myData.totalNum;
  15910. }
  15911. if (myData.list) {
  15912. $scope.myData = myData.list;
  15913. } else {
  15914. $scope.myData = myData.data;
  15915. }
  15916. }
  15917. });
  15918. };
  15919. $scope.title = title;
  15920. $scope.loadData({
  15921. idx: 0,
  15922. sum: 10,
  15923. });
  15924. $scope.selected = {
  15925. item: {},
  15926. };
  15927. $scope.ok = function () {
  15928. //console.log($scope.selected.item);
  15929. $modalInstance.close($scope.selected.item);
  15930. };
  15931. $scope.cancel = function () {
  15932. $modalInstance.dismiss("cancel");
  15933. };
  15934. },
  15935. size: size,
  15936. resolve: {
  15937. items: function () {
  15938. return {
  15939. fetchItems: function (filterData, APIService, $rootScope) {
  15940. filterData = filterData || {};
  15941. // if(!filterData.idx){
  15942. if (
  15943. angular.isDefined(filterData.idx) &&
  15944. filterData.idx == null
  15945. ) {
  15946. filterData = {
  15947. idx: 0,
  15948. sum: 10,
  15949. };
  15950. }
  15951. return options.templateOptions.fetchItems(
  15952. filterData,
  15953. APIService,
  15954. $rootScope
  15955. );
  15956. },
  15957. columnDefs: function () {
  15958. return options.templateOptions.columnDefs;
  15959. },
  15960. };
  15961. },
  15962. title: function () {
  15963. return options.templateOptions.modalTitle;
  15964. },
  15965. Restangular: function () {
  15966. return options.templateOptions.Restangular;
  15967. },
  15968. APIService: function () {
  15969. return options.templateOptions.ApiService;
  15970. },
  15971. },
  15972. });
  15973. modalInstance.result.then(
  15974. function (selectedItem) {
  15975. var selectitem = {
  15976. title: selectedItem.title,
  15977. description: selectedItem.description,
  15978. };
  15979. if (options.key == "chuku") {
  15980. if (selectedItem.assets) {
  15981. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  15982. selectedItem.assets;
  15983. }
  15984. if (selectedItem.consumables) {
  15985. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  15986. selectedItem.consumables;
  15987. }
  15988. angular.extend(
  15989. $scope.$parent.$parent.$parent.model,
  15990. selectitem
  15991. );
  15992. options.value(selectedItem);
  15993. // options.model.consumables = JSON.parse(consumables);
  15994. } else if (options.templateOptions.pkey == "change") {
  15995. console.log(options);
  15996. angular.extend(options.model);
  15997. options.value(selectedItem);
  15998. } else if (options.key == "cmdbCode") {
  15999. var zc_selectitem = selectedItem.uuid;
  16000. // angular.extend(options.model,zc_selectitem);
  16001. options.model.cmdbCode = zc_selectitem;
  16002. // angular.extend(options.model,zc_selectitem);
  16003. // options.templateOptions.displayName=zc_selectitem;
  16004. options.value(selectedItem);
  16005. console.log(options.model);
  16006. } else {
  16007. angular.extend(options.model, selectitem);
  16008. options.value(selectedItem);
  16009. }
  16010. },
  16011. function () {
  16012. //console.log('Modal dismissed at: ' + new Date());
  16013. }
  16014. );
  16015. },
  16016. },
  16017. };
  16018. },
  16019. });
  16020. //选项选择控件
  16021. formlyConfigProvider.setType({
  16022. name: "ui-modelselect",
  16023. extends: "input",
  16024. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16025. defaultOptions: function (options) {
  16026. return {
  16027. templateOptions: {
  16028. openModal: function (size, options, modal) {
  16029. var modalInstance = modal.open({
  16030. templateUrl:
  16031. "assets/views/customform/tpl/checktable-modal-content.html",
  16032. controller: function (
  16033. $scope,
  16034. $modalInstance,
  16035. items,
  16036. title,
  16037. Restangular,
  16038. APIService,
  16039. i18nService
  16040. ) {
  16041. $scope.langs = i18nService.getAllLangs();
  16042. $scope.lang = "zh-cn";
  16043. i18nService.setCurrentLang($scope.lang);
  16044. $scope.gridOptions = {};
  16045. $scope.gridOptions.data = "myData";
  16046. $scope.gridOptions.enableColumnResizing = true;
  16047. $scope.gridOptions.enableFiltering = true;
  16048. $scope.gridOptions.enableGridMenu = false;
  16049. $scope.gridOptions.enableRowSelection = true;
  16050. $scope.gridOptions.showGridFooter = true;
  16051. $scope.gridOptions.showColumnFooter = true;
  16052. $scope.gridOptions.fastWatch = true;
  16053. $scope.gridOptions.useExternalFiltering = true;
  16054. $scope.gridOptions.useExternalPagination = true;
  16055. $scope.gridOptions.paginationPageSizes = [10];
  16056. $scope.gridOptions.paginationPageSize = 10;
  16057. $scope.gridOptions.multiSelect = false;
  16058. $scope.gridOptions.rowIdentity = function (row) {
  16059. return row.id;
  16060. };
  16061. $scope.gridOptions.getRowIdentity = function (row) {
  16062. return row.id;
  16063. };
  16064. $scope.gridOptions.columnDefs = items.columnDefs();
  16065. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16066. $scope.gridApi = gridApi;
  16067. gridApi.pagination.on.paginationChanged(
  16068. $scope,
  16069. function (newPage, pageSize) {
  16070. // console.log(newPage);
  16071. // console.log(pageSize);
  16072. $scope.loadData({
  16073. idx: newPage - 1,
  16074. sum: pageSize,
  16075. });
  16076. }
  16077. );
  16078. gridApi.core.on.filterChanged($scope, function () {
  16079. var grid = this.grid;
  16080. var filtersData = {
  16081. idx: 0,
  16082. sum: 10,
  16083. };
  16084. angular.forEach(grid.columns, function (item) {
  16085. if (item.enableFiltering) {
  16086. if (
  16087. angular.isDefined(item.filters[0].term) &&
  16088. item.filters[0].term != ""
  16089. ) {
  16090. // console.log("filtersData="+JSON.stringify(filtersData))
  16091. if (angular.isUndefined(filtersData["incident"])) {
  16092. filtersData["incident"] = {};
  16093. }
  16094. filtersData["incident"][item.field] =
  16095. item.filters[0].term;
  16096. if (angular.isUndefined(filtersData["problem"])) {
  16097. filtersData["problem"] = {};
  16098. }
  16099. filtersData["problem"][item.field] =
  16100. item.filters[0].term;
  16101. if (angular.isUndefined(filtersData["change"])) {
  16102. filtersData["change"] = {};
  16103. }
  16104. filtersData["change"][item.field] =
  16105. item.filters[0].term;
  16106. if (angular.isUndefined(filtersData["release"])) {
  16107. filtersData["release"] = {};
  16108. }
  16109. filtersData["release"][item.field] =
  16110. item.filters[0].term;
  16111. }
  16112. }
  16113. });
  16114. $scope.loadData(filtersData);
  16115. });
  16116. gridApi.selection.on.rowSelectionChanged(
  16117. $scope,
  16118. function (data) {
  16119. $scope.selected.item = data.entity;
  16120. //console.log(data);
  16121. }
  16122. );
  16123. };
  16124. $scope.loadData = function (filterData) {
  16125. items
  16126. .fetchItems(filterData, APIService)
  16127. .then(function (data) {
  16128. var myData = Restangular.stripRestangular(data);
  16129. $scope.gridOptions.totalItems = myData.totalNum;
  16130. $scope.myData = myData.list;
  16131. });
  16132. };
  16133. $scope.title = title;
  16134. $scope.loadData({
  16135. idx: 0,
  16136. sum: 10,
  16137. });
  16138. $scope.selected = {
  16139. item: {},
  16140. };
  16141. $scope.ok = function () {
  16142. if ($scope.selected.item.scheduleOrder) {
  16143. $scope.selected.item.descriptionData =
  16144. "日期:" +
  16145. $scope.selected.item.watchTime +
  16146. ";" +
  16147. "班次:" +
  16148. $scope.selected.item.scheduleOrder.description +
  16149. ";" +
  16150. "值班人:" +
  16151. $scope.selected.item.scheduleOrder.users[0].name;
  16152. }
  16153. //console.log($scope.selected.item);
  16154. $modalInstance.close($scope.selected.item);
  16155. };
  16156. $scope.cancel = function () {
  16157. $modalInstance.dismiss("cancel");
  16158. };
  16159. },
  16160. size: size,
  16161. resolve: {
  16162. items: function () {
  16163. return {
  16164. fetchItems: function (filterData, APIService) {
  16165. filterData = filterData || {};
  16166. // if(!filterData.idx){
  16167. if (
  16168. angular.isDefined(filterData.idx) &&
  16169. filterData.idx == null
  16170. ) {
  16171. filterData = {
  16172. idx: 0,
  16173. sum: 10,
  16174. };
  16175. }
  16176. return options.templateOptions.fetchItems(
  16177. filterData,
  16178. APIService,
  16179. options
  16180. );
  16181. },
  16182. columnDefs: function () {
  16183. return options.templateOptions.columnDefs;
  16184. },
  16185. };
  16186. },
  16187. title: function () {
  16188. return options.templateOptions.modalTitle;
  16189. },
  16190. Restangular: function () {
  16191. return options.templateOptions.Restangular;
  16192. },
  16193. APIService: function () {
  16194. return options.templateOptions.ApiService;
  16195. },
  16196. },
  16197. });
  16198. modalInstance.result.then(
  16199. function (selectedItem) {
  16200. options.value(selectedItem);
  16201. },
  16202. function () {
  16203. //console.log('Modal dismissed at: ' + new Date());
  16204. }
  16205. );
  16206. },
  16207. },
  16208. };
  16209. },
  16210. });
  16211. formlyConfigProvider.setType({
  16212. name: "ui-requestform",
  16213. extends: "input",
  16214. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  16215. controller: [
  16216. "$scope",
  16217. function ($scope) {
  16218. setTimeout(function () {
  16219. var filterData = {
  16220. idx: 0,
  16221. sum: 5,
  16222. incident: {
  16223. requester: {
  16224. id: "",
  16225. },
  16226. },
  16227. };
  16228. $scope.options.templateOptions
  16229. .getWorkernumber(
  16230. $scope.options.templateOptions.ApiService,
  16231. filterData
  16232. )
  16233. .then(function (result) {
  16234. var modelData =
  16235. $scope.options.templateOptions.Restangular.stripRestangular(
  16236. result
  16237. );
  16238. });
  16239. }, 1000);
  16240. },
  16241. ],
  16242. });
  16243. //报修图片展示
  16244. formlyConfigProvider.setType({
  16245. name: "ui-repair-photos",
  16246. // extends: 'label',
  16247. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  16248. controller: [
  16249. "$scope",
  16250. "api_wechatfile",
  16251. "$stateParams",
  16252. function ($scope, api_wechatfile, $stateParams) {
  16253. console.log($scope);
  16254. $scope.fileUrls = [];
  16255. if ($scope.model.wxFile) {
  16256. api_wechatfile
  16257. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  16258. .then(function (res) {
  16259. $scope.fileUrls = res.data;
  16260. });
  16261. }
  16262. console.log($stateParams);
  16263. if (
  16264. $stateParams &&
  16265. $stateParams.model &&
  16266. JSON.parse($stateParams.model) &&
  16267. JSON.parse($stateParams.model).model &&
  16268. JSON.parse($stateParams.model).model.flow
  16269. ) {
  16270. api_wechatfile
  16271. .listAttachment(
  16272. "wechatRequesterIncident",
  16273. JSON.parse($stateParams.model).model.flow
  16274. )
  16275. .then(function (res) {
  16276. $scope.fileUrls = res.data;
  16277. });
  16278. }
  16279. if ($scope.model.flow) {
  16280. api_wechatfile
  16281. .listAttachment("wechatRequesterIncident", $scope.model.flow)
  16282. .then(function (res) {
  16283. $scope.fileUrls = res.data;
  16284. });
  16285. }
  16286. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  16287. // // setTimeout(function () {
  16288. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  16289. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  16290. // // if (modelData.status == 200) {
  16291. // // $scope.model[$scope.options.key] = modelData.data;
  16292. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  16293. // // }
  16294. // // });
  16295. // // }, 1000);
  16296. // }
  16297. $scope.showBigImg = false;
  16298. $scope.showBigImgCli = function (data) {
  16299. $scope.showBigImg = true;
  16300. $scope.bigImgUrl = data;
  16301. };
  16302. $scope.closeBigImg = function () {
  16303. $scope.showBigImg = false;
  16304. };
  16305. },
  16306. ],
  16307. });
  16308. //图片展示
  16309. formlyConfigProvider.setType({
  16310. name: "ui-showImgs",
  16311. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  16312. defaultOptions: function (options) {
  16313. return {
  16314. templateOptions: {
  16315. refresh: function (APIService, processInstanceId, data) {
  16316. return APIService.listAttachments(processInstanceId);
  16317. },
  16318. downloadUri: function (APIService, contentId) {
  16319. return APIService.downloadAttachment(contentId).getRequestedUrl();
  16320. },
  16321. view: function (APIService, contentId) {
  16322. return APIService.attachmentsPreviewUrl(contentId);
  16323. },
  16324. download: function (APIService, contentId, item) {
  16325. var item = {
  16326. url: APIService.download(contentId),
  16327. headers: headers,
  16328. };
  16329. return item;
  16330. },
  16331. refreshDelay: 0,
  16332. },
  16333. };
  16334. },
  16335. controller: [
  16336. "$scope",
  16337. "$timeout",
  16338. "$modal",
  16339. "$rootScope",
  16340. "$http",
  16341. "up_down_file",
  16342. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  16343. var _refreshDelayPromise;
  16344. /**
  16345. * refresh
  16346. */
  16347. $scope._refresh = function (refreshAttr) {
  16348. $scope.attachments = [];
  16349. if (refreshAttr !== undefined) {
  16350. if (_refreshDelayPromise) {
  16351. $timeout.cancel(_refreshDelayPromise);
  16352. }
  16353. _refreshDelayPromise = $timeout(function () {
  16354. // 暂存附件
  16355. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  16356. $scope.options.templateOptions
  16357. .refresh(
  16358. $scope.options.templateOptions.ApiService,
  16359. $scope.options.templateOptions.processInstanceId,
  16360. {
  16361. idx: 0,
  16362. sum: 1000,
  16363. }
  16364. )
  16365. .then(function (response) {
  16366. var myData =
  16367. $scope.options.templateOptions.Restangular.stripRestangular(
  16368. response
  16369. );
  16370. if (myData) {
  16371. for (var i = 0; i < myData.data.length; i++) {
  16372. $scope.attachments.push(myData.data[i]);
  16373. }
  16374. }
  16375. $scope.options.templateOptions
  16376. .refresh(
  16377. $scope.options.templateOptions.ApiService,
  16378. $scope.$parent.$parent.$parent.model.save_fileId,
  16379. {
  16380. idx: 0,
  16381. sum: 1000,
  16382. }
  16383. )
  16384. .then(function (response2) {
  16385. var myData2 =
  16386. $scope.options.templateOptions.Restangular.stripRestangular(
  16387. response2
  16388. );
  16389. if (myData2) {
  16390. for (var i = 0; i < myData2.data.length; i++) {
  16391. $scope.attachments.push(myData2.data[i]);
  16392. }
  16393. }
  16394. console.log($scope.attachments);
  16395. });
  16396. });
  16397. // 正常附件
  16398. } else {
  16399. $scope.options.templateOptions
  16400. .refresh(
  16401. $scope.options.templateOptions.ApiService,
  16402. $scope.options.templateOptions.processInstanceId,
  16403. {
  16404. idx: 0,
  16405. sum: 1000,
  16406. }
  16407. )
  16408. .then(function (response) {
  16409. var myData =
  16410. $scope.options.templateOptions.Restangular.stripRestangular(
  16411. response
  16412. );
  16413. if (myData) {
  16414. $scope.attachments = [];
  16415. $scope.imgs = [];
  16416. myData.data.forEach((e) => {
  16417. if (
  16418. e.suffix == "jpeg" ||
  16419. e.suffix == "jpg" ||
  16420. e.suffix == "svg" ||
  16421. e.suffix == "png" ||
  16422. e.suffix == "bmp" ||
  16423. e.suffix == "gif" ||
  16424. e.suffix == "tif"
  16425. ) {
  16426. $scope.imgs.push(e);
  16427. }
  16428. });
  16429. $scope.imgs = $scope.imgs.splice(0, 3);
  16430. console.log($scope.imgs);
  16431. }
  16432. });
  16433. }
  16434. }, $scope.options.templateOptions.refreshDelay);
  16435. }
  16436. };
  16437. $scope._refresh({});
  16438. // $scope.attachments = $scope.model[$scope.options.key]
  16439. // 预览
  16440. $scope.preview = function (url, idx) {
  16441. var title = $scope.imgs[idx].title;
  16442. $modal.open({
  16443. backdrop: false,
  16444. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  16445. controller: function ($scope, scope, $modalInstance) {
  16446. $scope.title = title;
  16447. $scope.imageurl = url;
  16448. $scope.cancel = function () {
  16449. $modalInstance.dismiss("cancel");
  16450. };
  16451. },
  16452. resolve: {
  16453. scope: function () {
  16454. return $scope;
  16455. },
  16456. },
  16457. });
  16458. };
  16459. },
  16460. ],
  16461. });
  16462. //工单/受理人控件
  16463. formlyConfigProvider.setType({
  16464. name: "ui-workernumbersign",
  16465. // extends: 'label',
  16466. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  16467. controller: [
  16468. "$scope",
  16469. function ($scope) {
  16470. // 2020年4月24日13:20:40
  16471. console.log($scope, "docu");
  16472. // 左侧事件工单区域地点填充
  16473. $scope.model.selecthouseNumber = $scope.model.place;
  16474. if (
  16475. angular.isUndefined($scope.model[$scope.options.key]) ||
  16476. $scope.model[$scope.options.key] == null
  16477. ) {
  16478. setTimeout(function () {
  16479. $scope.options.templateOptions
  16480. .getWorkernumber($scope.options.templateOptions.ApiService)
  16481. .then(function (result) {
  16482. var modelData =
  16483. $scope.options.templateOptions.Restangular.stripRestangular(
  16484. result
  16485. );
  16486. if (modelData.status == 200) {
  16487. $scope.model[$scope.options.key] = modelData.data;
  16488. $scope.options.initialValue =
  16489. $scope.model[$scope.options.key];
  16490. }
  16491. });
  16492. }, 1000);
  16493. }
  16494. if (
  16495. $scope.options.templateOptions.user &&
  16496. (angular.isUndefined($scope.model.acceptUser) ||
  16497. $scope.model.acceptUser == null)
  16498. ) {
  16499. if (angular.isFunction($scope.options.templateOptions.transform)) {
  16500. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  16501. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  16502. // }
  16503. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16504. $scope.$parent.$parent.$parent.model["directClose"] = false;
  16505. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  16506. }
  16507. $scope.model.acceptUser = $scope.options.templateOptions.user;
  16508. // $scope.options.initialValue = $scope.model.acceptUser;
  16509. }
  16510. },
  16511. ],
  16512. });
  16513. //工单控件-only number
  16514. formlyConfigProvider.setType({
  16515. name: "ui-workernumber",
  16516. extends: "input",
  16517. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  16518. controller: [
  16519. "$scope",
  16520. function ($scope) {
  16521. if (
  16522. angular.isUndefined($scope.model[$scope.options.key]) ||
  16523. $scope.model[$scope.options.key] == null
  16524. ) {
  16525. setTimeout(function () {
  16526. $scope.options.templateOptions
  16527. .getWorkernumber($scope.options.templateOptions.ApiService)
  16528. .then(function (result) {
  16529. var modelData =
  16530. $scope.options.templateOptions.Restangular.stripRestangular(
  16531. result
  16532. );
  16533. if (modelData.status == 200) {
  16534. $scope.model[$scope.options.key] = modelData.data;
  16535. $scope.options.initialValue =
  16536. $scope.model[$scope.options.key];
  16537. }
  16538. });
  16539. }, 1000);
  16540. }
  16541. },
  16542. ],
  16543. });
  16544. //cmdb工单
  16545. formlyConfigProvider.setType({
  16546. name: "ui-cmdbworkernumber",
  16547. extends: "input",
  16548. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  16549. controller: [
  16550. "$scope",
  16551. function ($scope) {
  16552. if (
  16553. angular.isUndefined($scope.model[$scope.options.key]) ||
  16554. $scope.model[$scope.options.key] == null
  16555. ) {
  16556. setTimeout(function () {
  16557. $scope.options.templateOptions
  16558. .getWorkernumber(
  16559. $scope.options.templateOptions.ApiService,
  16560. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  16561. .cifilter_classics.id
  16562. )
  16563. .then(function (result) {
  16564. var modelData =
  16565. $scope.options.templateOptions.Restangular.stripRestangular(
  16566. result
  16567. );
  16568. // if(modelData.status==200){
  16569. $scope.model[$scope.options.key] =
  16570. modelData[$scope.options.key];
  16571. $scope.options.initialValue = $scope.model[$scope.options.key];
  16572. // }
  16573. });
  16574. }, 1000);
  16575. }
  16576. },
  16577. ],
  16578. });
  16579. //简易上传图片组件
  16580. formlyConfigProvider.setType({
  16581. name: "ui-uploadImgs",
  16582. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  16583. wrapper: ["bootstrapHasError"],
  16584. controller: [
  16585. "$scope",
  16586. "fileReader",
  16587. "$parse",
  16588. "$modal",
  16589. function ($scope, fileReader, $parse, $modal) {
  16590. $scope.imgshows = [];
  16591. $scope.uploadimgs = [];
  16592. var model = $parse("upload_img");
  16593. var modelSetter = model.assign;
  16594. var uploader = ($scope.uploader =
  16595. $scope.options.templateOptions.fileUploader);
  16596. uploader.filters.push({
  16597. name: "customFilter",
  16598. fn: function (item /*{File|FileLikeObject}*/, options) {
  16599. return this.queue.length < 10;
  16600. },
  16601. });
  16602. // 添加
  16603. $scope.change = function (event) {
  16604. var element = $(".upinp");
  16605. modelSetter($scope, element[0].files[0]);
  16606. //附件预览
  16607. $scope.imgupload = event.files[0];
  16608. getFile($scope.imgupload, $scope);
  16609. //获得预览图地址并且把file对象放入上传合集内
  16610. function getFile(imgupload, $scope) {
  16611. if (!imgupload) {
  16612. return;
  16613. }
  16614. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  16615. $scope.imgshows.push(result);
  16616. var file = document.querySelector("input[type=file]").files[0];
  16617. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  16618. console.log($scope.imgshows, $scope.uploadimgs);
  16619. if ($scope.imgshows.length < 3) {
  16620. $("#upup").show();
  16621. } else {
  16622. $("#upup").hide();
  16623. }
  16624. });
  16625. }
  16626. };
  16627. // 删除
  16628. $scope.uploadimg_del = function (index, imgs) {
  16629. console.log(index, imgs);
  16630. $scope.imgshows.splice(index, 1);
  16631. $scope.uploadimgs.splice(index, 1);
  16632. if ($scope.imgshows.length < 3) {
  16633. $("#upup").show();
  16634. } else {
  16635. $("#upup").hide();
  16636. }
  16637. };
  16638. // 预览
  16639. $scope.preview = function (url, idx) {
  16640. var name = $scope.uploadimgs[idx].name;
  16641. $modal.open({
  16642. backdrop: false,
  16643. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  16644. controller: function ($scope, scope, $modalInstance) {
  16645. $scope.title = name;
  16646. $scope.imageurl = url;
  16647. $scope.cancel = function () {
  16648. $modalInstance.dismiss("cancel");
  16649. };
  16650. },
  16651. resolve: {
  16652. scope: function () {
  16653. return $scope;
  16654. },
  16655. },
  16656. });
  16657. };
  16658. if (uploader) {
  16659. uploader.onWhenAddingFileFailed = function (
  16660. item /*{File|FileLikeObject}*/,
  16661. filter,
  16662. options
  16663. ) {
  16664. console.info("onWhenAddingFileFailed", item, filter, options);
  16665. };
  16666. uploader.onAfterAddingFile = function (fileItem) {
  16667. console.info("onAfterAddingFile", fileItem);
  16668. };
  16669. uploader.onAfterAddingAll = function (addedFileItems) {
  16670. console.info("onAfterAddingAll", addedFileItems);
  16671. };
  16672. uploader.onBeforeUploadItem = function (item) {
  16673. console.info("onBeforeUploadItem", item);
  16674. };
  16675. uploader.onProgressItem = function (fileItem, progress) {
  16676. console.info("onProgressItem", fileItem, progress);
  16677. };
  16678. uploader.onProgressAll = function (progress) {
  16679. console.info("onProgressAll", progress);
  16680. };
  16681. uploader.onSuccessItem = function (
  16682. fileItem,
  16683. response,
  16684. status,
  16685. headers
  16686. ) {
  16687. console.info("onSuccessItem", fileItem, response, status, headers);
  16688. };
  16689. uploader.onErrorItem = function (
  16690. fileItem,
  16691. response,
  16692. status,
  16693. headers
  16694. ) {
  16695. console.info("onErrorItem", fileItem, response, status, headers);
  16696. };
  16697. uploader.onCancelItem = function (
  16698. fileItem,
  16699. response,
  16700. status,
  16701. headers
  16702. ) {
  16703. console.info("onCancelItem", fileItem, response, status, headers);
  16704. };
  16705. uploader.onCompleteItem = function (
  16706. fileItem,
  16707. response,
  16708. status,
  16709. headers
  16710. ) {
  16711. console.info("onCompleteItem", fileItem, response, status, headers);
  16712. };
  16713. uploader.onCompleteAll = function () {
  16714. console.info("onCompleteAll");
  16715. };
  16716. }
  16717. // console.log(modelSetter)
  16718. },
  16719. ],
  16720. });
  16721. //jry-上传下载一体
  16722. formlyConfigProvider.setType({
  16723. name: "ui-upDropFile",
  16724. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  16725. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16726. defaultOptions: function (options) {
  16727. return {
  16728. templateOptions: {
  16729. view: function (APIService, contentId) {
  16730. return APIService.downloadAttachment(contentId);
  16731. },
  16732. // ApiService: 'api_wechatfile',
  16733. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  16734. // upUrl: 'common/common/uploadAttachment',
  16735. // listAttachmentUrl: 'common/common/listAttachment',
  16736. // downUrl: 'common/common/downloadAttachment',
  16737. // bindType: 'incident',
  16738. // bindId: 2323
  16739. },
  16740. // validators: {
  16741. // required: {
  16742. // expression: function(viewValue, modelValue) {
  16743. // var value = modelValue || viewValue;
  16744. // return value.length >= 1;
  16745. // }
  16746. // }
  16747. // }
  16748. };
  16749. },
  16750. controller: [
  16751. "$scope",
  16752. "$rootScope",
  16753. "Restangular",
  16754. "up_down_file",
  16755. "$http",
  16756. "api_bpm",
  16757. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  16758. console.log($scope);
  16759. $scope.showFileUp = true;
  16760. if ($scope.model.isKnowledge_detail) {
  16761. $scope.showFileUp = false;
  16762. }
  16763. if (angular.isUndefined($scope.form.dropState)) {
  16764. $scope.form.dropState = false;
  16765. }
  16766. if ($scope.model.incident) {
  16767. if ($scope.model.incident.alarm) {
  16768. console.log($scope);
  16769. if ($scope.model.incident.alarm) {
  16770. if ($scope.model.incident.alarm.alarmExtension) {
  16771. $scope.model.incident.alarm.alarmExtension =
  16772. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  16773. $scope.model.incident.alarm.alarmExtension =
  16774. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  16775. $scope.model.incident.description =
  16776. $scope.model.incident.alarm.alarmExtension;
  16777. console.log($scope.model.incident.description);
  16778. $scope.model.incident.description =
  16779. '"' +
  16780. "告警名称" +
  16781. '":' +
  16782. '"' +
  16783. $scope.model.incident.alarm.alarmSystem +
  16784. '",' +
  16785. '"' +
  16786. "告警状态" +
  16787. '":' +
  16788. '"' +
  16789. $scope.model.incident.alarm.alarmStatus +
  16790. '",' +
  16791. '"' +
  16792. "告警内容" +
  16793. '":' +
  16794. '"' +
  16795. $scope.model.incident.alarm.alarmContent +
  16796. '",' +
  16797. $scope.model.incident.description;
  16798. } else {
  16799. $scope.model.incident.description =
  16800. '"' +
  16801. "告警名称" +
  16802. '":' +
  16803. '"' +
  16804. $scope.model.incident.alarm.alarmSystem +
  16805. '",' +
  16806. '"' +
  16807. "告警状态" +
  16808. '":' +
  16809. '"' +
  16810. $scope.model.incident.alarm.alarmStatus +
  16811. '",' +
  16812. '"' +
  16813. "告警内容" +
  16814. '":' +
  16815. '"' +
  16816. $scope.model.incident.alarm.alarmContent +
  16817. '",';
  16818. }
  16819. $scope.model.incident.description =
  16820. $scope.model.incident.description.replace(/,/g, "\n");
  16821. console.log($scope.model.incident.description);
  16822. }
  16823. }
  16824. api_bpm
  16825. .tellCategory($scope.model.incident.category.id)
  16826. .then(function (wt_data) {
  16827. console.log(wt_data);
  16828. if (wt_data) {
  16829. $rootScope.wt_category = wt_data.data;
  16830. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  16831. $rootScope.wt_child = wt_data.child;
  16832. }
  16833. });
  16834. if ($scope.model.titleName == "接单") {
  16835. $scope.model.receive_code = "handler";
  16836. if (
  16837. $scope.model.incident.groupLeader &&
  16838. !$scope.model.incident.repeat
  16839. ) {
  16840. $scope.model.isHandlerUser = true;
  16841. }
  16842. }
  16843. if ($scope.model.titleName == "事件处理") {
  16844. console.log($scope.model.cmdbCode);
  16845. if ($scope.model.cmdbCode) {
  16846. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  16847. }
  16848. }
  16849. } else {
  16850. $rootScope.wt_category = "";
  16851. }
  16852. //附件上传数据
  16853. if ($scope.options.templateOptions.fileUploader) {
  16854. var uploader = ($scope.uploader =
  16855. $scope.options.templateOptions.fileUploader);
  16856. //$scope.options.templateOptions.uploader();
  16857. console.log(uploader);
  16858. // FILTERS
  16859. uploader.filters.push({
  16860. name: "customFilter",
  16861. fn: function (item /*{File|FileLikeObject}*/, options) {
  16862. return this.queue.length < 10;
  16863. },
  16864. });
  16865. }
  16866. var to = $scope.options.templateOptions;
  16867. // var bindType = $scope.model.bindType;
  16868. if (to.bindType == "incident") {
  16869. var bindId = $scope.model[to.bindType].processInstanceId;
  16870. } else if (to.bindType == "change") {
  16871. var bindId = $scope.model[to.bindType].processInstanceId;
  16872. } else {
  16873. var bindId = $scope.model[to.bindType].id;
  16874. }
  16875. //获取附件列表
  16876. $scope.listAttachmen = function () {
  16877. to.ApiService.listAttachment(
  16878. to.listAttachmentUrl,
  16879. to.bindType,
  16880. bindId
  16881. ).then(function (result) {
  16882. var myData = Restangular.stripRestangular(result);
  16883. // $scope.listAttachmens = myData;
  16884. $scope.attachments = myData.data;
  16885. });
  16886. };
  16887. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  16888. $scope.listAttachmen();
  16889. } else if (to.bindType && $scope.model[to.bindType].id) {
  16890. $scope.listAttachmen();
  16891. }
  16892. //附件上传
  16893. $scope.isUpfload = to.isUpfload;
  16894. $scope.dropfile = function (
  16895. APIService,
  16896. processInstanceId,
  16897. taskId,
  16898. userId
  16899. ) {
  16900. uploader.onBeforeUploadItem = function (item) {
  16901. angular.extend(item.headers, $rootScope.getSession());
  16902. item.url = to.ApiService.saveAttachments(
  16903. to.uploadUrl,
  16904. to.bindType,
  16905. bindId
  16906. ).getRequestedUrl();
  16907. item.formData.push({
  16908. filename: item.file.name,
  16909. });
  16910. };
  16911. uploader.uploadAll();
  16912. };
  16913. //附件下载
  16914. $scope.download = function (token, filename) {
  16915. var downUrl = to.ApiService.downloadAttachment(
  16916. to.downUrl,
  16917. token
  16918. ).getRequestedUrl();
  16919. // window.open(downUrl);
  16920. var a = document.createElement("a");
  16921. a.href = downUrl;
  16922. a.target = "_blank";
  16923. a.download = filename;
  16924. document.body.appendChild(a);
  16925. a.click();
  16926. };
  16927. //附件预览
  16928. $scope.view = function (id, previewUrl) {
  16929. if (previewUrl) {
  16930. window.open(previewUrl);
  16931. }
  16932. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  16933. // if (response.state == 200) {
  16934. // window.open(response.previewUrl);
  16935. // }
  16936. // })
  16937. };
  16938. // CALLBACKS
  16939. if (uploader) {
  16940. uploader.onWhenAddingFileFailed = function (
  16941. item /*{File|FileLikeObject}*/,
  16942. filter,
  16943. options
  16944. ) {
  16945. console.info("onWhenAddingFileFailed", item, filter, options);
  16946. };
  16947. uploader.onAfterAddingFile = function (fileItem) {
  16948. console.info("onAfterAddingFile", fileItem);
  16949. };
  16950. uploader.onAfterAddingAll = function (addedFileItems) {
  16951. console.info("onAfterAddingAll", addedFileItems);
  16952. };
  16953. uploader.onBeforeUploadItem = function (item) {
  16954. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  16955. // // $scope.uploader.options.url();
  16956. // $scope.uploader.onBeforeUploadItem = function(item) {
  16957. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  16958. // console.info('onBeforeUploadItem', item);
  16959. // };
  16960. // $scope.uploader.uploadAll();
  16961. // }
  16962. console.info("onBeforeUploadItem", item);
  16963. };
  16964. uploader.onProgressItem = function (fileItem, progress) {
  16965. console.info("onProgressItem", fileItem, progress);
  16966. };
  16967. uploader.onProgressAll = function (progress) {
  16968. console.info("onProgressAll", progress);
  16969. };
  16970. uploader.onSuccessItem = function (
  16971. fileItem,
  16972. response,
  16973. status,
  16974. headers
  16975. ) {
  16976. console.info("onSuccessItem", fileItem, response, status, headers);
  16977. if (response.status == 200) {
  16978. $scope.listAttachmen();
  16979. }
  16980. };
  16981. uploader.onErrorItem = function (
  16982. fileItem,
  16983. response,
  16984. status,
  16985. headers
  16986. ) {
  16987. console.info("onErrorItem", fileItem, response, status, headers);
  16988. };
  16989. uploader.onCancelItem = function (
  16990. fileItem,
  16991. response,
  16992. status,
  16993. headers
  16994. ) {
  16995. console.info("onCancelItem", fileItem, response, status, headers);
  16996. };
  16997. uploader.onCompleteItem = function (
  16998. fileItem,
  16999. response,
  17000. status,
  17001. headers
  17002. ) {
  17003. console.info("onCompleteItem", fileItem, response, status, headers);
  17004. };
  17005. uploader.onCompleteAll = function () {
  17006. console.info("onCompleteAll");
  17007. };
  17008. }
  17009. },
  17010. ],
  17011. });
  17012. //简易上传下载附件组件
  17013. formlyConfigProvider.setType({
  17014. name: "ui-upDownFiles",
  17015. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  17016. wrapper: ["bootstrapHasError"],
  17017. defaultOptions: function (options) {
  17018. return {
  17019. templateOptions: {
  17020. refresh: function (APIService, processInstanceId, data) {
  17021. return APIService.listAttachments(processInstanceId);
  17022. },
  17023. downloadUri: function (APIService, contentId) {
  17024. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17025. },
  17026. view: function (APIService, contentId) {
  17027. return APIService.attachmentsPreviewUrl(contentId);
  17028. },
  17029. download: function (APIService, contentId, item) {
  17030. var item = {
  17031. url: APIService.download(contentId),
  17032. headers: headers,
  17033. };
  17034. return item;
  17035. },
  17036. refreshDelay: 0,
  17037. },
  17038. };
  17039. },
  17040. controller: [
  17041. "$scope",
  17042. "$timeout",
  17043. "$modal",
  17044. "$rootScope",
  17045. "$http",
  17046. "up_down_file",
  17047. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17048. if (angular.isUndefined($scope.form.dropState)) {
  17049. $scope.form.dropState = false;
  17050. }
  17051. //附件上传数据
  17052. var uploader = ($scope.uploader =
  17053. $scope.options.templateOptions.fileUploader);
  17054. //$scope.options.templateOptions.uploader();
  17055. // FILTERS
  17056. uploader.filters.push({
  17057. name: "customFilter",
  17058. fn: function (item /*{File|FileLikeObject}*/, options) {
  17059. return this.queue.length < 10;
  17060. },
  17061. });
  17062. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  17063. // uploader.onBeforeUploadItem = function (item) {
  17064. // angular.extend(item.headers, $rootScope.getSession());
  17065. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  17066. // item.formData.push({
  17067. // 'fileName': item.file.name
  17068. // });
  17069. // console.info('onBeforeUploadItem', item);
  17070. // };
  17071. // }
  17072. // CALLBACKS
  17073. uploader.onWhenAddingFileFailed = function (
  17074. item /*{File|FileLikeObject}*/,
  17075. filter,
  17076. options
  17077. ) {
  17078. console.info("onWhenAddingFileFailed", item, filter, options);
  17079. };
  17080. uploader.onAfterAddingFile = function (fileItem) {
  17081. console.info("onAfterAddingFile", fileItem);
  17082. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17083. alert("文件过大");
  17084. fileItem.uploader.queue.pop();
  17085. console.log($scope);
  17086. }
  17087. };
  17088. uploader.onAfterAddingAll = function (addedFileItems) {
  17089. // console.info('onAfterAddingAll', addedFileItems);
  17090. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17091. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17092. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17093. // console.log(123)
  17094. };
  17095. uploader.onBeforeUploadItem = function (item) {
  17096. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17097. // // $scope.uploader.options.url();
  17098. // $scope.uploader.onBeforeUploadItem = function(item) {
  17099. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17100. // console.info('onBeforeUploadItem', item);
  17101. // };
  17102. // $scope.uploader.uploadAll();
  17103. // }
  17104. console.info("onBeforeUploadItem", item);
  17105. };
  17106. uploader.onProgressItem = function (fileItem, progress) {
  17107. console.info("onProgressItem", fileItem, progress);
  17108. };
  17109. uploader.onProgressAll = function (progress) {
  17110. console.info("onProgressAll", progress);
  17111. };
  17112. uploader.onSuccessItem = function (
  17113. fileItem,
  17114. response,
  17115. status,
  17116. headers
  17117. ) {
  17118. console.info("onSuccessItem", fileItem, response, status, headers);
  17119. };
  17120. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17121. console.info("onErrorItem", fileItem, response, status, headers);
  17122. };
  17123. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17124. console.info("onCancelItem", fileItem, response, status, headers);
  17125. };
  17126. uploader.onCompleteItem = function (
  17127. fileItem,
  17128. response,
  17129. status,
  17130. headers
  17131. ) {
  17132. console.info("onCompleteItem", fileItem, response, status, headers);
  17133. };
  17134. uploader.onCompleteAll = function () {
  17135. console.info("onCompleteAll");
  17136. };
  17137. var _refreshDelayPromise;
  17138. // 下载
  17139. $scope.download = function (contentId, filename, token) {
  17140. // console.log(contentId, filename, token)
  17141. //附件下载
  17142. var downUrl = up_down_file
  17143. .downloadAttachment("common/common/downloadAttachment", token)
  17144. .getRequestedUrl();
  17145. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17146. // console.log(downUrl)
  17147. var a = document.createElement("a");
  17148. a.href = downUrl;
  17149. a.target = "_blank";
  17150. a.download = filename;
  17151. document.body.appendChild(a);
  17152. a.click();
  17153. };
  17154. $scope._refresh = function (refreshAttr) {
  17155. $scope.attachments = [];
  17156. if (refreshAttr !== undefined) {
  17157. if (_refreshDelayPromise) {
  17158. $timeout.cancel(_refreshDelayPromise);
  17159. }
  17160. _refreshDelayPromise = $timeout(function () {
  17161. // 暂存附件
  17162. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17163. $scope.options.templateOptions
  17164. .refresh(
  17165. $scope.options.templateOptions.ApiService,
  17166. $scope.options.templateOptions.processInstanceId,
  17167. {
  17168. idx: 0,
  17169. sum: 1000,
  17170. }
  17171. )
  17172. .then(function (response) {
  17173. var myData =
  17174. $scope.options.templateOptions.Restangular.stripRestangular(
  17175. response
  17176. );
  17177. if (myData) {
  17178. for (var i = 0; i < myData.data.length; i++) {
  17179. $scope.attachments.push(myData.data[i]);
  17180. }
  17181. }
  17182. $scope.options.templateOptions
  17183. .refresh(
  17184. $scope.options.templateOptions.ApiService,
  17185. $scope.$parent.$parent.$parent.model.save_fileId,
  17186. {
  17187. idx: 0,
  17188. sum: 1000,
  17189. }
  17190. )
  17191. .then(function (response2) {
  17192. var myData2 =
  17193. $scope.options.templateOptions.Restangular.stripRestangular(
  17194. response2
  17195. );
  17196. if (myData2) {
  17197. for (var i = 0; i < myData2.data.length; i++) {
  17198. $scope.attachments.push(myData2.data[i]);
  17199. }
  17200. // 只展示除图片以外的附件
  17201. var a = [];
  17202. $scope.attachments.forEach((e) => {
  17203. if (
  17204. e.suffix == "jpeg" ||
  17205. e.suffix == "jpg" ||
  17206. e.suffix == "svg" ||
  17207. e.suffix == "png" ||
  17208. e.suffix == "bmp" ||
  17209. e.suffix == "gif" ||
  17210. e.suffix == "tif"
  17211. ) {
  17212. // $scope.imgs.push(e)
  17213. } else {
  17214. a.push(e);
  17215. }
  17216. });
  17217. $scope.attachments = a;
  17218. }
  17219. console.log($scope.attachments);
  17220. });
  17221. });
  17222. // 正常附件
  17223. } else {
  17224. $scope.options.templateOptions
  17225. .refresh(
  17226. $scope.options.templateOptions.ApiService,
  17227. $scope.options.templateOptions.processInstanceId,
  17228. {
  17229. idx: 0,
  17230. sum: 1000,
  17231. }
  17232. )
  17233. .then(function (response) {
  17234. var myData =
  17235. $scope.options.templateOptions.Restangular.stripRestangular(
  17236. response
  17237. );
  17238. if (myData) {
  17239. $scope.attachments = myData.data;
  17240. // 只展示除图片以外的附件
  17241. var a = [];
  17242. $scope.attachments.forEach((e) => {
  17243. if (
  17244. e.suffix == "jpeg" ||
  17245. e.suffix == "jpg" ||
  17246. e.suffix == "svg" ||
  17247. e.suffix == "png" ||
  17248. e.suffix == "bmp" ||
  17249. e.suffix == "gif" ||
  17250. e.suffix == "tif"
  17251. ) {
  17252. // $scope.imgs.push(e)
  17253. } else {
  17254. a.push(e);
  17255. }
  17256. });
  17257. $scope.attachments = a;
  17258. }
  17259. });
  17260. }
  17261. }, $scope.options.templateOptions.refreshDelay);
  17262. }
  17263. };
  17264. $scope._refresh({});
  17265. },
  17266. ],
  17267. });
  17268. //简易上传附件组件
  17269. formlyConfigProvider.setType({
  17270. name: "ui-uploadFiles",
  17271. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  17272. wrapper: ["bootstrapHasError"],
  17273. controller: [
  17274. "$scope",
  17275. function ($scope) {
  17276. if (angular.isUndefined($scope.form.dropState)) {
  17277. $scope.form.dropState = false;
  17278. }
  17279. //附件上传数据
  17280. var uploader = ($scope.uploader =
  17281. $scope.options.templateOptions.fileUploader);
  17282. //$scope.options.templateOptions.uploader();
  17283. // FILTERS
  17284. uploader.filters.push({
  17285. name: "customFilter",
  17286. fn: function (item /*{File|FileLikeObject}*/, options) {
  17287. return this.queue.length < 10;
  17288. },
  17289. });
  17290. $scope.dropfile = function (
  17291. APIService,
  17292. processInstanceId,
  17293. taskId,
  17294. userId
  17295. ) {
  17296. uploader.onBeforeUploadItem = function (item) {
  17297. angular.extend(item.headers, $rootScope.getSession());
  17298. item.url = APIService.saveAttachments(
  17299. processInstanceId,
  17300. taskId,
  17301. userId
  17302. ).getRequestedUrl();
  17303. item.formData.push({
  17304. fileName: item.file.name,
  17305. });
  17306. console.info("onBeforeUploadItem", item);
  17307. };
  17308. };
  17309. // CALLBACKS
  17310. uploader.onWhenAddingFileFailed = function (
  17311. item /*{File|FileLikeObject}*/,
  17312. filter,
  17313. options
  17314. ) {
  17315. console.info("onWhenAddingFileFailed", item, filter, options);
  17316. };
  17317. uploader.onAfterAddingFile = function (fileItem) {
  17318. console.info("onAfterAddingFile", fileItem);
  17319. if (fileItem.file.size >= 1024 * 1024 * 10) {
  17320. alert("文件过大");
  17321. fileItem.uploader.queue.pop();
  17322. console.log($scope);
  17323. }
  17324. };
  17325. uploader.onAfterAddingAll = function (addedFileItems) {
  17326. // console.info('onAfterAddingAll', addedFileItems);
  17327. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17328. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  17329. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  17330. // console.log(123)
  17331. };
  17332. uploader.onBeforeUploadItem = function (item) {
  17333. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17334. // // $scope.uploader.options.url();
  17335. // $scope.uploader.onBeforeUploadItem = function(item) {
  17336. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17337. // console.info('onBeforeUploadItem', item);
  17338. // };
  17339. // $scope.uploader.uploadAll();
  17340. // }
  17341. console.info("onBeforeUploadItem", item);
  17342. };
  17343. uploader.onProgressItem = function (fileItem, progress) {
  17344. console.info("onProgressItem", fileItem, progress);
  17345. };
  17346. uploader.onProgressAll = function (progress) {
  17347. console.info("onProgressAll", progress);
  17348. };
  17349. uploader.onSuccessItem = function (
  17350. fileItem,
  17351. response,
  17352. status,
  17353. headers
  17354. ) {
  17355. console.info("onSuccessItem", fileItem, response, status, headers);
  17356. };
  17357. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17358. console.info("onErrorItem", fileItem, response, status, headers);
  17359. };
  17360. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17361. console.info("onCancelItem", fileItem, response, status, headers);
  17362. };
  17363. uploader.onCompleteItem = function (
  17364. fileItem,
  17365. response,
  17366. status,
  17367. headers
  17368. ) {
  17369. console.info("onCompleteItem", fileItem, response, status, headers);
  17370. };
  17371. uploader.onCompleteAll = function () {
  17372. console.info("onCompleteAll");
  17373. };
  17374. },
  17375. ],
  17376. });
  17377. //无上传按钮附件上传组件
  17378. formlyConfigProvider.setType({
  17379. name: "ui-dropfilenotup",
  17380. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17381. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17382. controller: [
  17383. "$scope",
  17384. function ($scope) {
  17385. if (angular.isUndefined($scope.form.dropState)) {
  17386. $scope.form.dropState = false;
  17387. }
  17388. //附件上传数据
  17389. var uploader = ($scope.uploader =
  17390. $scope.options.templateOptions.fileUploader);
  17391. //$scope.options.templateOptions.uploader();
  17392. // FILTERS
  17393. uploader.filters.push({
  17394. name: "customFilter",
  17395. fn: function (item /*{File|FileLikeObject}*/, options) {
  17396. return this.queue.length < 10;
  17397. },
  17398. });
  17399. $scope.dropfile = function (
  17400. APIService,
  17401. processInstanceId,
  17402. taskId,
  17403. userId
  17404. ) {
  17405. uploader.onBeforeUploadItem = function (item) {
  17406. angular.extend(item.headers, $rootScope.getSession());
  17407. item.url = APIService.saveAttachments(
  17408. processInstanceId,
  17409. taskId,
  17410. userId
  17411. ).getRequestedUrl();
  17412. item.formData.push({
  17413. fileName: item.file.name,
  17414. });
  17415. console.info("onBeforeUploadItem", item);
  17416. };
  17417. uploader.uploadAll();
  17418. };
  17419. // CALLBACKS
  17420. uploader.onWhenAddingFileFailed = function (
  17421. item /*{File|FileLikeObject}*/,
  17422. filter,
  17423. options
  17424. ) {
  17425. console.info("onWhenAddingFileFailed", item, filter, options);
  17426. };
  17427. uploader.onAfterAddingFile = function (fileItem) {
  17428. console.info("onAfterAddingFile", fileItem);
  17429. };
  17430. uploader.onAfterAddingAll = function (addedFileItems) {
  17431. console.info("onAfterAddingAll", addedFileItems);
  17432. };
  17433. uploader.onBeforeUploadItem = function (item) {
  17434. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17435. // // $scope.uploader.options.url();
  17436. // $scope.uploader.onBeforeUploadItem = function(item) {
  17437. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17438. // console.info('onBeforeUploadItem', item);
  17439. // };
  17440. // $scope.uploader.uploadAll();
  17441. // }
  17442. console.info("onBeforeUploadItem", item);
  17443. };
  17444. uploader.onProgressItem = function (fileItem, progress) {
  17445. console.info("onProgressItem", fileItem, progress);
  17446. };
  17447. uploader.onProgressAll = function (progress) {
  17448. console.info("onProgressAll", progress);
  17449. };
  17450. uploader.onSuccessItem = function (
  17451. fileItem,
  17452. response,
  17453. status,
  17454. headers
  17455. ) {
  17456. console.info("onSuccessItem", fileItem, response, status, headers);
  17457. };
  17458. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17459. console.info("onErrorItem", fileItem, response, status, headers);
  17460. };
  17461. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17462. console.info("onCancelItem", fileItem, response, status, headers);
  17463. };
  17464. uploader.onCompleteItem = function (
  17465. fileItem,
  17466. response,
  17467. status,
  17468. headers
  17469. ) {
  17470. console.info("onCompleteItem", fileItem, response, status, headers);
  17471. };
  17472. uploader.onCompleteAll = function () {
  17473. console.info("onCompleteAll");
  17474. };
  17475. },
  17476. ],
  17477. });
  17478. //无按钮知识库上传
  17479. formlyConfigProvider.setType({
  17480. name: "ui-dropfielkn",
  17481. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  17482. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17483. controller: [
  17484. "$scope",
  17485. function ($scope) {
  17486. if (angular.isUndefined($scope.form.dropState)) {
  17487. $scope.form.dropState = false;
  17488. }
  17489. //附件上传数据
  17490. var uploader = ($scope.uploader =
  17491. $scope.options.templateOptions.fileUploader);
  17492. //$scope.options.templateOptions.uploader();
  17493. // FILTERS
  17494. uploader.filters.push({
  17495. name: "customFilter",
  17496. fn: function (item /*{File|FileLikeObject}*/, options) {
  17497. return this.queue.length < 10;
  17498. },
  17499. });
  17500. $scope.dropfile = function (
  17501. APIService,
  17502. processInstanceId,
  17503. taskId,
  17504. userId
  17505. ) {
  17506. uploader.onBeforeUploadItem = function (item) {
  17507. angular.extend(item.headers, $rootScope.getSession());
  17508. item.url = APIService.addFile(
  17509. processInstanceId,
  17510. taskId,
  17511. userId
  17512. ).getRequestedUrl();
  17513. item.formData.push({
  17514. fileName: item.file.name,
  17515. });
  17516. console.info("onBeforeUploadItem", item);
  17517. };
  17518. uploader.uploadAll();
  17519. };
  17520. // CALLBACKS
  17521. uploader.onWhenAddingFileFailed = function (
  17522. item /*{File|FileLikeObject}*/,
  17523. filter,
  17524. options
  17525. ) {
  17526. console.info("onWhenAddingFileFailed", item, filter, options);
  17527. };
  17528. uploader.onAfterAddingFile = function (fileItem) {
  17529. console.info("onAfterAddingFile", fileItem);
  17530. };
  17531. uploader.onAfterAddingAll = function (addedFileItems) {
  17532. console.info("onAfterAddingAll", addedFileItems);
  17533. };
  17534. uploader.onBeforeUploadItem = function (item) {
  17535. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17536. // // $scope.uploader.options.url();
  17537. // $scope.uploader.onBeforeUploadItem = function(item) {
  17538. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17539. // console.info('onBeforeUploadItem', item);
  17540. // };
  17541. // $scope.uploader.uploadAll();
  17542. // }
  17543. console.info("onBeforeUploadItem", item);
  17544. };
  17545. uploader.onProgressItem = function (fileItem, progress) {
  17546. console.info("onProgressItem", fileItem, progress);
  17547. };
  17548. uploader.onProgressAll = function (progress) {
  17549. console.info("onProgressAll", progress);
  17550. };
  17551. uploader.onSuccessItem = function (
  17552. fileItem,
  17553. response,
  17554. status,
  17555. headers
  17556. ) {
  17557. console.info("onSuccessItem", fileItem, response, status, headers);
  17558. };
  17559. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17560. console.info("onErrorItem", fileItem, response, status, headers);
  17561. };
  17562. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17563. console.info("onCancelItem", fileItem, response, status, headers);
  17564. };
  17565. uploader.onCompleteItem = function (
  17566. fileItem,
  17567. response,
  17568. status,
  17569. headers
  17570. ) {
  17571. console.info("onCompleteItem", fileItem, response, status, headers);
  17572. };
  17573. uploader.onCompleteAll = function () {
  17574. console.info("onCompleteAll");
  17575. };
  17576. },
  17577. ],
  17578. });
  17579. //附件上传列表组件
  17580. formlyConfigProvider.setType({
  17581. name: "ui-dropfile",
  17582. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  17583. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17584. controller: [
  17585. "$scope",
  17586. "$rootScope",
  17587. function ($scope, $rootScope) {
  17588. if (angular.isUndefined($scope.form.dropState)) {
  17589. $scope.form.dropState = false;
  17590. }
  17591. //附件上传数据
  17592. var uploader = ($scope.uploader =
  17593. $scope.options.templateOptions.fileUploader);
  17594. //$scope.options.templateOptions.uploader();
  17595. // FILTERS
  17596. uploader.filters.push({
  17597. name: "customFilter",
  17598. fn: function (item /*{File|FileLikeObject}*/, options) {
  17599. return this.queue.length < 10;
  17600. },
  17601. });
  17602. $scope.dropfile = function (
  17603. APIService,
  17604. processInstanceId,
  17605. taskId,
  17606. userId
  17607. ) {
  17608. uploader.onBeforeUploadItem = function (item) {
  17609. angular.extend(item.headers, $rootScope.getSession());
  17610. if (
  17611. $scope.options.templateOptions.upservice &&
  17612. $scope.options.templateOptions.formname
  17613. ) {
  17614. // if ($scope.options.templateOptions.formket) {
  17615. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  17616. // } else {
  17617. item.url = APIService[$scope.options.templateOptions.upservice](
  17618. $scope.model[$scope.options.templateOptions.formname].id,
  17619. taskId,
  17620. userId
  17621. ).getRequestedUrl();
  17622. // }
  17623. } else {
  17624. item.url = APIService.saveAttachments(
  17625. processInstanceId,
  17626. taskId,
  17627. userId
  17628. ).getRequestedUrl();
  17629. }
  17630. item.formData.push({
  17631. filename: item.file.name,
  17632. });
  17633. console.info("onBeforeUploadItem", item);
  17634. };
  17635. uploader.uploadAll();
  17636. };
  17637. // CALLBACKS
  17638. uploader.onWhenAddingFileFailed = function (
  17639. item /*{File|FileLikeObject}*/,
  17640. filter,
  17641. options
  17642. ) {
  17643. console.info("onWhenAddingFileFailed", item, filter, options);
  17644. };
  17645. uploader.onAfterAddingFile = function (fileItem) {
  17646. console.info("onAfterAddingFile", fileItem);
  17647. };
  17648. uploader.onAfterAddingAll = function (addedFileItems) {
  17649. console.info("onAfterAddingAll", addedFileItems);
  17650. };
  17651. uploader.onBeforeUploadItem = function (item) {
  17652. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17653. // // $scope.uploader.options.url();
  17654. // $scope.uploader.onBeforeUploadItem = function(item) {
  17655. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17656. // console.info('onBeforeUploadItem', item);
  17657. // };
  17658. // $scope.uploader.uploadAll();
  17659. // }
  17660. console.info("onBeforeUploadItem", item);
  17661. };
  17662. uploader.onProgressItem = function (fileItem, progress) {
  17663. console.info("onProgressItem", fileItem, progress);
  17664. };
  17665. uploader.onProgressAll = function (progress) {
  17666. console.info("onProgressAll", progress);
  17667. };
  17668. uploader.onSuccessItem = function (
  17669. fileItem,
  17670. response,
  17671. status,
  17672. headers
  17673. ) {
  17674. console.info("onSuccessItem", fileItem, response, status, headers);
  17675. };
  17676. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17677. console.info("onErrorItem", fileItem, response, status, headers);
  17678. };
  17679. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17680. console.info("onCancelItem", fileItem, response, status, headers);
  17681. };
  17682. uploader.onCompleteItem = function (
  17683. fileItem,
  17684. response,
  17685. status,
  17686. headers
  17687. ) {
  17688. console.info("onCompleteItem", fileItem, response, status, headers);
  17689. };
  17690. uploader.onCompleteAll = function () {
  17691. console.info("onCompleteAll");
  17692. };
  17693. },
  17694. ],
  17695. });
  17696. //简易附件展示下载列表组件
  17697. formlyConfigProvider.setType({
  17698. name: "ui-dropFiles",
  17699. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  17700. defaultOptions: function (options) {
  17701. return {
  17702. templateOptions: {
  17703. refresh: function (APIService, processInstanceId, data) {
  17704. return APIService.listAttachments(processInstanceId);
  17705. },
  17706. downloadUri: function (APIService, contentId) {
  17707. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17708. },
  17709. view: function (APIService, contentId) {
  17710. return APIService.attachmentsPreviewUrl(contentId);
  17711. },
  17712. download: function (APIService, contentId, item) {
  17713. var item = {
  17714. url: APIService.download(contentId),
  17715. headers: headers,
  17716. };
  17717. return item;
  17718. },
  17719. refreshDelay: 0,
  17720. },
  17721. };
  17722. },
  17723. controller: [
  17724. "$scope",
  17725. "$timeout",
  17726. "$modal",
  17727. "$rootScope",
  17728. "$http",
  17729. "up_down_file",
  17730. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17731. var _refreshDelayPromise;
  17732. // $scope.downloadUrl = function(contentId){
  17733. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  17734. // };
  17735. $scope.download = function (contentId, filename, token) {
  17736. // console.log(contentId, filename, token)
  17737. //附件下载
  17738. var downUrl = up_down_file
  17739. .downloadAttachment("common/common/downloadAttachment", token)
  17740. .getRequestedUrl();
  17741. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  17742. // console.log(downUrl)
  17743. var a = document.createElement("a");
  17744. a.href = downUrl;
  17745. a.target = "_blank";
  17746. a.download = filename;
  17747. document.body.appendChild(a);
  17748. a.click();
  17749. };
  17750. $scope.view = function (contentId, token, filename, type) {
  17751. $scope.options.templateOptions
  17752. .view($scope.options.templateOptions.ApiService, contentId)
  17753. .then(function (response) {
  17754. if (response.state == 200) {
  17755. window.open(response.previewUrl);
  17756. }
  17757. });
  17758. };
  17759. /**
  17760. * refresh
  17761. */
  17762. $scope._refresh = function (refreshAttr) {
  17763. $scope.attachments = [];
  17764. if (refreshAttr !== undefined) {
  17765. if (_refreshDelayPromise) {
  17766. $timeout.cancel(_refreshDelayPromise);
  17767. }
  17768. _refreshDelayPromise = $timeout(function () {
  17769. // 暂存附件
  17770. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17771. $scope.options.templateOptions
  17772. .refresh(
  17773. $scope.options.templateOptions.ApiService,
  17774. $scope.options.templateOptions.processInstanceId,
  17775. {
  17776. idx: 0,
  17777. sum: 1000,
  17778. }
  17779. )
  17780. .then(function (response) {
  17781. var myData =
  17782. $scope.options.templateOptions.Restangular.stripRestangular(
  17783. response
  17784. );
  17785. if (myData) {
  17786. for (var i = 0; i < myData.data.length; i++) {
  17787. $scope.attachments.push(myData.data[i]);
  17788. }
  17789. }
  17790. $scope.options.templateOptions
  17791. .refresh(
  17792. $scope.options.templateOptions.ApiService,
  17793. $scope.$parent.$parent.$parent.model.save_fileId,
  17794. {
  17795. idx: 0,
  17796. sum: 1000,
  17797. }
  17798. )
  17799. .then(function (response2) {
  17800. var myData2 =
  17801. $scope.options.templateOptions.Restangular.stripRestangular(
  17802. response2
  17803. );
  17804. if (myData2) {
  17805. for (var i = 0; i < myData2.data.length; i++) {
  17806. $scope.attachments.push(myData2.data[i]);
  17807. }
  17808. // 只展示除图片以外的附件
  17809. var a = [];
  17810. $scope.attachments.forEach((e) => {
  17811. if (
  17812. e.suffix == "jpeg" ||
  17813. e.suffix == "jpg" ||
  17814. e.suffix == "svg" ||
  17815. e.suffix == "png" ||
  17816. e.suffix == "bmp" ||
  17817. e.suffix == "gif" ||
  17818. e.suffix == "tif"
  17819. ) {
  17820. // $scope.imgs.push(e)
  17821. } else {
  17822. a.push(e);
  17823. }
  17824. });
  17825. $scope.attachments = a;
  17826. }
  17827. console.log($scope.attachments);
  17828. });
  17829. });
  17830. // 正常附件
  17831. } else {
  17832. $scope.options.templateOptions
  17833. .refresh(
  17834. $scope.options.templateOptions.ApiService,
  17835. $scope.options.templateOptions.processInstanceId,
  17836. {
  17837. idx: 0,
  17838. sum: 1000,
  17839. }
  17840. )
  17841. .then(function (response) {
  17842. var myData =
  17843. $scope.options.templateOptions.Restangular.stripRestangular(
  17844. response
  17845. );
  17846. if (myData) {
  17847. $scope.attachments = myData.data;
  17848. // 只展示除图片以外的附件
  17849. var a = [];
  17850. $scope.attachments.forEach((e) => {
  17851. if (
  17852. e.suffix == "jpeg" ||
  17853. e.suffix == "jpg" ||
  17854. e.suffix == "svg" ||
  17855. e.suffix == "png" ||
  17856. e.suffix == "bmp" ||
  17857. e.suffix == "gif" ||
  17858. e.suffix == "tif"
  17859. ) {
  17860. // $scope.imgs.push(e)
  17861. } else {
  17862. a.push(e);
  17863. }
  17864. });
  17865. $scope.attachments = a;
  17866. console.log($scope.attachments);
  17867. }
  17868. });
  17869. }
  17870. }, $scope.options.templateOptions.refreshDelay);
  17871. }
  17872. };
  17873. $scope._refresh({});
  17874. // $scope.attachments = $scope.model[$scope.options.key]
  17875. },
  17876. ],
  17877. });
  17878. //知识库附件上传
  17879. formlyConfigProvider.setType({
  17880. name: "ui-dropfielknow",
  17881. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  17882. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17883. controller: [
  17884. "$scope",
  17885. "$rootScope",
  17886. function ($scope, $rootScope) {
  17887. if (angular.isUndefined($scope.form.dropState)) {
  17888. $scope.form.dropState = false;
  17889. }
  17890. //附件上传数据
  17891. var uploader = ($scope.uploader =
  17892. $scope.options.templateOptions.fileUploader);
  17893. //$scope.options.templateOptions.uploader();
  17894. // FILTERS
  17895. uploader.filters.push({
  17896. name: "customFilter",
  17897. fn: function (item /*{File|FileLikeObject}*/, options) {
  17898. return this.queue.length < 10;
  17899. },
  17900. });
  17901. $scope.dropfile = function (
  17902. APIService,
  17903. processInstanceId,
  17904. taskId,
  17905. userId
  17906. ) {
  17907. uploader.onBeforeUploadItem = function (item) {
  17908. angular.extend(item.headers, $rootScope.getSession());
  17909. item.url = APIService.upload(
  17910. processInstanceId,
  17911. taskId,
  17912. userId
  17913. ).getRequestedUrl();
  17914. item.formData.push({
  17915. fileName: item.file.name,
  17916. type: "solution",
  17917. solutionId: $scope.model.knowledge.id,
  17918. });
  17919. console.info("onBeforeUploadItem", item);
  17920. };
  17921. uploader.uploadAll();
  17922. };
  17923. // CALLBACKS
  17924. uploader.onWhenAddingFileFailed = function (
  17925. item /*{File|FileLikeObject}*/,
  17926. filter,
  17927. options
  17928. ) {
  17929. console.info("onWhenAddingFileFailed", item, filter, options);
  17930. };
  17931. uploader.onAfterAddingFile = function (fileItem) {
  17932. console.info("onAfterAddingFile", fileItem);
  17933. };
  17934. uploader.onAfterAddingAll = function (addedFileItems) {
  17935. console.info("onAfterAddingAll", addedFileItems);
  17936. };
  17937. uploader.onBeforeUploadItem = function (item) {
  17938. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17939. // // $scope.uploader.options.url();
  17940. // $scope.uploader.onBeforeUploadItem = function(item) {
  17941. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17942. // console.info('onBeforeUploadItem', item);
  17943. // };
  17944. // $scope.uploader.uploadAll();
  17945. // }
  17946. console.info("onBeforeUploadItem", item);
  17947. };
  17948. uploader.onProgressItem = function (fileItem, progress) {
  17949. console.info("onProgressItem", fileItem, progress);
  17950. };
  17951. uploader.onProgressAll = function (progress) {
  17952. console.info("onProgressAll", progress);
  17953. };
  17954. uploader.onSuccessItem = function (
  17955. fileItem,
  17956. response,
  17957. status,
  17958. headers
  17959. ) {
  17960. console.info("onSuccessItem", fileItem, response, status, headers);
  17961. };
  17962. uploader.onErrorItem = function (fileItem, response, status, headers) {
  17963. console.info("onErrorItem", fileItem, response, status, headers);
  17964. };
  17965. uploader.onCancelItem = function (fileItem, response, status, headers) {
  17966. console.info("onCancelItem", fileItem, response, status, headers);
  17967. };
  17968. uploader.onCompleteItem = function (
  17969. fileItem,
  17970. response,
  17971. status,
  17972. headers
  17973. ) {
  17974. console.info("onCompleteItem", fileItem, response, status, headers);
  17975. };
  17976. uploader.onCompleteAll = function () {
  17977. console.info("onCompleteAll");
  17978. };
  17979. },
  17980. ],
  17981. });
  17982. //知识库附件下载列表
  17983. formlyConfigProvider.setType({
  17984. name: "ui-dropfileknowledge",
  17985. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  17986. defaultOptions: function (options) {
  17987. return {
  17988. templateOptions: {
  17989. refresh: function (APIService, contentId, data) {
  17990. return APIService.fetchDataList(contentId, data);
  17991. },
  17992. downloadUri: function (APIService, contentId) {
  17993. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17994. },
  17995. download: function (APIService, contentId) {
  17996. return APIService.getSolutionDowpath(contentId);
  17997. },
  17998. view: function (attachmentId) {
  17999. // return APIService.attachmentsPreviewUrl(contentId);
  18000. },
  18001. refreshDelay: 0,
  18002. },
  18003. };
  18004. },
  18005. controller: [
  18006. "$scope",
  18007. "$timeout",
  18008. "$modal",
  18009. "$rootScope",
  18010. "api_solution",
  18011. "$http",
  18012. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  18013. var _refreshDelayPromise;
  18014. $scope.attachments = [];
  18015. $scope.downloadUrl = function (contentId) {
  18016. return (
  18017. $scope.options.templateOptions.downloadUri(
  18018. $scope.options.templateOptions.ApiService,
  18019. contentId
  18020. ) || "#"
  18021. );
  18022. };
  18023. $scope.download = function (contentId, filename) {
  18024. $http({
  18025. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  18026. contentId
  18027. ).getRequestedUrl(),
  18028. method: "GET",
  18029. headers: {
  18030. //'Content-type' : 'application/xls',
  18031. Accept: "*/*",
  18032. },
  18033. responseType: "arraybuffer",
  18034. })
  18035. .success(function (data, status, headers, config) {
  18036. var file = new Blob([data], {
  18037. type: "application/octet-stream",
  18038. });
  18039. //trick to download store a file having its URL
  18040. var fileURL = URL.createObjectURL(file);
  18041. var a = document.createElement("a");
  18042. a.href = fileURL;
  18043. a.target = "_blank";
  18044. a.download = filename;
  18045. document.body.appendChild(a);
  18046. a.click();
  18047. })
  18048. .error(function (data, status, headers, config) {
  18049. // console.log(data);
  18050. });
  18051. };
  18052. $scope.view = function (contentId, filename, attachment) {
  18053. var index = filename.indexOf(".");
  18054. var type = filename.substring(index + 1);
  18055. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18056. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  18057. // var modalInstance = $modal.open({
  18058. // backdrop: false,
  18059. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18060. // controller: function($scope, scope, $modalInstance, filename) {
  18061. // $scope.title = filename;
  18062. // $scope.imageurl = scope.imageurl;
  18063. // $scope.cancel = function() {
  18064. // $modalInstance.dismiss('cancel');
  18065. // }
  18066. // },
  18067. // resolve: {
  18068. // scope: function() {
  18069. // return $scope;
  18070. // },
  18071. // filename: function() {
  18072. // return filename;
  18073. // }
  18074. // }
  18075. // });
  18076. // event.preventDefault();
  18077. // } else {
  18078. // for (var i = 0; i < $scope.attachments.length; i++) {
  18079. // if ($scope.attachments[i].id == attachmentId) {
  18080. window.open(attachment.previewUrl);
  18081. // }
  18082. // }
  18083. // }
  18084. };
  18085. $scope._refresh = function (refreshAttr) {
  18086. if (refreshAttr !== undefined) {
  18087. if (_refreshDelayPromise) {
  18088. $timeout.cancel(_refreshDelayPromise);
  18089. }
  18090. _refreshDelayPromise = $timeout(function () {
  18091. $scope.options.templateOptions
  18092. .refresh($scope.options.templateOptions.ApiService, "file", {
  18093. file: {
  18094. solutionId: $scope.model.knowledge.id,
  18095. },
  18096. idx: "0",
  18097. sum: "1000",
  18098. })
  18099. .then(function (response) {
  18100. var myData =
  18101. $scope.options.templateOptions.Restangular.stripRestangular(
  18102. response
  18103. );
  18104. if (myData) {
  18105. $scope.attachments = myData.list;
  18106. // $scope.view = function(attachmentId) {
  18107. // for (var i = 0; i < $scope.attachments.length; i++) {
  18108. // if ($scope.attachments[i].id == attachmentId) {
  18109. // window.open($scope.attachments[i].previewUrl);
  18110. // // var modalInstance = $modal.open({
  18111. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  18112. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  18113. // // }
  18114. // // });
  18115. // }
  18116. // }
  18117. // };
  18118. }
  18119. });
  18120. }, $scope.options.templateOptions.refreshDelay);
  18121. }
  18122. };
  18123. $scope._refresh({});
  18124. // $scope.attachments = $scope.model[$scope.options.key]
  18125. },
  18126. ],
  18127. });
  18128. //附件图片下载
  18129. formlyConfigProvider.setType({
  18130. name: "ui-downimage",
  18131. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  18132. defaultOptions: function (options) {
  18133. return {
  18134. templateOptions: {
  18135. refresh: function (APIService, processInstanceId, data) {
  18136. return APIService.listAttachments(processInstanceId, data);
  18137. },
  18138. downloadUri: function (APIService, contentId) {
  18139. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18140. },
  18141. view: function (APIService, contentId) {
  18142. return APIService.attachmentsPreviewUrl(contentId);
  18143. },
  18144. download: function (APIService, contentId, item) {
  18145. var item = {
  18146. url: APIService.download(contentId),
  18147. headers: headers,
  18148. };
  18149. return item;
  18150. },
  18151. refreshDelay: 0,
  18152. },
  18153. };
  18154. },
  18155. controller: [
  18156. "$scope",
  18157. "$timeout",
  18158. "$rootScope",
  18159. "$http",
  18160. function ($scope, $timeout, $rootScope, $http) {
  18161. var _refreshDelayPromise;
  18162. // $scope.downloadUrl = function(contentId){
  18163. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18164. // };
  18165. $scope.download = function (contentId, filename) {
  18166. // var headers=
  18167. $http({
  18168. url: $scope.options.templateOptions.ApiService.download(
  18169. contentId
  18170. ).getRequestedUrl(),
  18171. method: "GET",
  18172. headers: {
  18173. //'Content-type' : 'application/xls',
  18174. Accept: "*/*",
  18175. },
  18176. responseType: "arraybuffer",
  18177. })
  18178. .success(function (data, status, headers, config) {
  18179. var file = new Blob([data], {
  18180. type: "application/octet-stream",
  18181. });
  18182. //trick to download store a file having its URL
  18183. var fileURL = URL.createObjectURL(file);
  18184. var a = document.createElement("a");
  18185. a.href = fileURL;
  18186. a.target = "_blank";
  18187. a.download = filename;
  18188. document.body.appendChild(a);
  18189. a.click();
  18190. })
  18191. .error(function (data, status, headers, config) {
  18192. // console.log(data);
  18193. });
  18194. };
  18195. $scope.view = function (contentId) {
  18196. $scope.imageurl =
  18197. $scope.options.templateOptions.ApiService.download(
  18198. contentId
  18199. ).getRequestedUrl();
  18200. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  18201. // if (response.state == 200) {
  18202. // window.open(response.previewUrl);
  18203. // }
  18204. // })
  18205. };
  18206. /**
  18207. * refresh
  18208. */
  18209. $scope._refresh = function (refreshAttr) {
  18210. if (refreshAttr !== undefined) {
  18211. if (_refreshDelayPromise) {
  18212. $timeout.cancel(_refreshDelayPromise);
  18213. }
  18214. _refreshDelayPromise = $timeout(function () {
  18215. $scope.options.templateOptions
  18216. .refresh(
  18217. $scope.options.templateOptions.ApiService,
  18218. $scope.options.templateOptions.processInstanceId,
  18219. {
  18220. idx: 0,
  18221. sum: 1000,
  18222. }
  18223. )
  18224. .then(function (response) {
  18225. var myData =
  18226. $scope.options.templateOptions.Restangular.stripRestangular(
  18227. response
  18228. );
  18229. if (myData) {
  18230. $scope.attachments = myData.data;
  18231. }
  18232. });
  18233. }, $scope.options.templateOptions.refreshDelay);
  18234. }
  18235. };
  18236. $scope._refresh({});
  18237. // $scope.attachments = $scope.model[$scope.options.key]
  18238. },
  18239. ],
  18240. });
  18241. //附件下载列表组件
  18242. formlyConfigProvider.setType({
  18243. name: "ui-dropfiletable",
  18244. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  18245. defaultOptions: function (options) {
  18246. return {
  18247. templateOptions: {
  18248. refresh: function (APIService, processInstanceId, data) {
  18249. return APIService.listAttachments(processInstanceId, data);
  18250. },
  18251. downloadUri: function (APIService, contentId) {
  18252. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18253. },
  18254. view: function (APIService, contentId) {
  18255. return APIService.attachmentsPreviewUrl(contentId);
  18256. },
  18257. download: function (APIService, contentId, item) {
  18258. var item = {
  18259. url: APIService.download(contentId),
  18260. headers: headers,
  18261. };
  18262. return item;
  18263. },
  18264. refreshDelay: 0,
  18265. },
  18266. };
  18267. },
  18268. controller: [
  18269. "$scope",
  18270. "$timeout",
  18271. "$modal",
  18272. "$rootScope",
  18273. "$http",
  18274. function ($scope, $timeout, $modal, $rootScope, $http) {
  18275. var _refreshDelayPromise;
  18276. // $scope.downloadUrl = function(contentId){
  18277. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18278. // };
  18279. $scope.download = function (contentId, filename) {
  18280. // var headers=
  18281. $http({
  18282. url: $scope.options.templateOptions.ApiService.download(
  18283. contentId
  18284. ).getRequestedUrl(),
  18285. method: "GET",
  18286. headers: {
  18287. //'Content-type' : 'application/xls',
  18288. Accept: "*/*",
  18289. },
  18290. responseType: "arraybuffer",
  18291. })
  18292. .success(function (data, status, headers, config) {
  18293. var file = new Blob([data], {
  18294. type: "application/octet-stream",
  18295. });
  18296. //trick to download store a file having its URL
  18297. var fileURL = URL.createObjectURL(file);
  18298. var a = document.createElement("a");
  18299. a.href = fileURL;
  18300. a.target = "_blank";
  18301. a.download = filename;
  18302. document.body.appendChild(a);
  18303. a.click();
  18304. })
  18305. .error(function (data, status, headers, config) {
  18306. // console.log(data);
  18307. });
  18308. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  18309. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  18310. // var file = new Blob([response], {
  18311. // type : 'application/octet-stream'
  18312. // });
  18313. // // var filename = filename;
  18314. // //var file = new Blob([response], {type: 'application/pdf'});
  18315. // var fileURL = URL.createObjectURL(file);
  18316. // var a = document.createElement('a');
  18317. // a.href = fileURL;
  18318. // a.target = '_blank';
  18319. // a.download = filename ;
  18320. // document.body.appendChild(a);
  18321. // a.click();
  18322. // })
  18323. };
  18324. $scope.view = function (contentId, token, filename, type) {
  18325. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  18326. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  18327. // var modalInstance = $modal.open({
  18328. // backdrop: false,
  18329. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18330. // controller: function($scope, scope, $modalInstance, filename) {
  18331. // $scope.title = filename;
  18332. // $scope.imageurl = scope.imageurl;
  18333. // $scope.cancel = function() {
  18334. // $modalInstance.dismiss('cancel');
  18335. // }
  18336. // },
  18337. // resolve: {
  18338. // scope: function() {
  18339. // return $scope;
  18340. // },
  18341. // filename: function() {
  18342. // return filename;
  18343. // }
  18344. // }
  18345. // });
  18346. // event.preventDefault();
  18347. // } else {
  18348. $scope.options.templateOptions
  18349. .view($scope.options.templateOptions.ApiService, contentId)
  18350. .then(function (response) {
  18351. if (response.state == 200) {
  18352. window.open(response.previewUrl);
  18353. }
  18354. });
  18355. // }
  18356. };
  18357. /**
  18358. * refresh
  18359. */
  18360. $scope._refresh = function (refreshAttr) {
  18361. if (refreshAttr !== undefined) {
  18362. if (_refreshDelayPromise) {
  18363. $timeout.cancel(_refreshDelayPromise);
  18364. }
  18365. _refreshDelayPromise = $timeout(function () {
  18366. $scope.options.templateOptions
  18367. .refresh(
  18368. $scope.options.templateOptions.ApiService,
  18369. $scope.options.templateOptions.processInstanceId,
  18370. {
  18371. idx: 0,
  18372. sum: 1000,
  18373. }
  18374. )
  18375. .then(function (response) {
  18376. var myData =
  18377. $scope.options.templateOptions.Restangular.stripRestangular(
  18378. response
  18379. );
  18380. if (myData) {
  18381. $scope.attachments = myData.data;
  18382. }
  18383. });
  18384. }, $scope.options.templateOptions.refreshDelay);
  18385. }
  18386. };
  18387. $scope._refresh({});
  18388. // $scope.attachments = $scope.model[$scope.options.key]
  18389. },
  18390. ],
  18391. });
  18392. //微信附件下载列表组件
  18393. formlyConfigProvider.setType({
  18394. name: "ui-dropfilewechat",
  18395. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  18396. defaultOptions: function (options) {
  18397. return {
  18398. templateOptions: {
  18399. // refresh: function(APIService, processInstanceId, data) {
  18400. // return APIService.listAttachments(processInstanceId, data);
  18401. // },
  18402. // downloadUri: function(APIService, contentId) {
  18403. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  18404. // },
  18405. view: function (APIService, contentId) {
  18406. // return APIService.attachmentsPreviewUrl(contentId);
  18407. return APIService.attachmentsPreviewUrl(contentId);
  18408. },
  18409. download: function (APIService, contentId, item) {
  18410. var item = {
  18411. url: APIService.download(contentId),
  18412. headers: headers,
  18413. };
  18414. return item;
  18415. },
  18416. // download: function(APIService, contentId, item) {
  18417. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  18418. // return item;
  18419. // },
  18420. refreshDelay: 0,
  18421. },
  18422. };
  18423. },
  18424. controller: [
  18425. "$scope",
  18426. "$timeout",
  18427. "$modal",
  18428. "$stateParams",
  18429. "$rootScope",
  18430. "$http",
  18431. "api_wechatfile",
  18432. function (
  18433. $scope,
  18434. $timeout,
  18435. $modal,
  18436. $stateParams,
  18437. $rootScope,
  18438. $http,
  18439. api_wechatfile
  18440. ) {
  18441. var _refreshDelayPromise;
  18442. // $scope.downloadUrl = function(contentId){
  18443. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18444. // };
  18445. $scope.attachments = {};
  18446. $scope.previewUrl = "";
  18447. $scope.download = function (token, filename) {
  18448. // var headers=
  18449. console.log($scope);
  18450. $http({
  18451. url: $scope.options.templateOptions.ApiService.jry_download(
  18452. token
  18453. ).getRequestedUrl(),
  18454. method: "GET",
  18455. headers: {
  18456. //'Content-type' : 'application/xls',
  18457. Accept: "*/*",
  18458. },
  18459. responseType: "arraybuffer",
  18460. })
  18461. .success(function (data, status, headers, config) {
  18462. var file = new Blob([data], {
  18463. type: "application/octet-stream",
  18464. });
  18465. //trick to download store a file having its URL
  18466. var fileURL = URL.createObjectURL(file);
  18467. var a = document.createElement("a");
  18468. a.href = fileURL;
  18469. a.target = "_blank";
  18470. a.download = filename;
  18471. document.body.appendChild(a);
  18472. a.click();
  18473. })
  18474. .error(function (data, status, headers, config) {
  18475. // console.log(data);
  18476. });
  18477. };
  18478. $scope.view = function (contentId, token, filename, type, previewUrl) {
  18479. // if (type) {
  18480. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  18481. // var modalInstance = $modal.open({
  18482. // backdrop: false,
  18483. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  18484. // controller: function($scope, scope, $modalInstance, filename) {
  18485. // $scope.title = filename;
  18486. // $scope.imageurl = scope.imageurl;
  18487. // $scope.cancel = function() {
  18488. // $modalInstance.dismiss('cancel');
  18489. // }
  18490. // },
  18491. // resolve: {
  18492. // scope: function() {
  18493. // return $scope;
  18494. // },
  18495. // filename: function() {
  18496. // return filename;
  18497. // }
  18498. // }
  18499. // });
  18500. // event.preventDefault();
  18501. // } else {
  18502. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  18503. // if (response.state == 200) {
  18504. // window.open(response.previewUrl);
  18505. // }
  18506. // })
  18507. window.open(previewUrl);
  18508. // }
  18509. };
  18510. /**
  18511. * refresh
  18512. */
  18513. $scope._refresh = function (refreshAttr) {
  18514. if (refreshAttr !== undefined) {
  18515. if (_refreshDelayPromise) {
  18516. $timeout.cancel(_refreshDelayPromise);
  18517. }
  18518. _refreshDelayPromise = $timeout(function () {
  18519. // console.log(JSON.parse($stateParams.model))
  18520. var incidentChart = {};
  18521. if ($stateParams.model) {
  18522. incidentChart = JSON.parse($stateParams.model).model;
  18523. }
  18524. $scope.options.templateOptions
  18525. .refresh(
  18526. $scope.options.templateOptions.ApiService,
  18527. $scope.model
  18528. )
  18529. .then(function (response) {
  18530. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  18531. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  18532. var myData =
  18533. $scope.options.templateOptions.Restangular.stripRestangular(
  18534. response
  18535. );
  18536. if (myData) {
  18537. $scope.attachments = myData.data;
  18538. }
  18539. });
  18540. }, $scope.options.templateOptions.refreshDelay);
  18541. }
  18542. };
  18543. $scope._refresh({});
  18544. // $scope.attachments = $scope.model[$scope.options.key]
  18545. },
  18546. ],
  18547. });
  18548. formlyConfigProvider.setType({
  18549. name: "ui-paralleltask",
  18550. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  18551. defaultOptions: function (options) {
  18552. return {
  18553. templateOptions: {
  18554. refresh: function (APIService, processInstanceId, data) {
  18555. //return APIService.listAttachments(processInstanceId, data);
  18556. },
  18557. refreshDelay: 0,
  18558. },
  18559. };
  18560. },
  18561. controller: ["$scope", "$timeout", function ($scope, $timeout) {}],
  18562. });
  18563. //repeatSection
  18564. //
  18565. formlyConfigProvider.setType({
  18566. name: "ui-repeatSection",
  18567. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  18568. defaultOptions: function (options) {
  18569. return {
  18570. templateOptions: {
  18571. unique: 1,
  18572. initDisplay: false,
  18573. },
  18574. };
  18575. },
  18576. controller: function ($scope) {
  18577. //$scope.options.templateOptions.unique;
  18578. $scope.formOptions = {
  18579. formState: $scope.formState,
  18580. };
  18581. $scope.addNew = addNew;
  18582. $scope.copyFields = copyFields;
  18583. function copyFields(fields) {
  18584. fields = angular.copy(fields);
  18585. addRandomIds(fields);
  18586. return fields;
  18587. }
  18588. function addNew() {
  18589. $scope.model[$scope.options.key] =
  18590. $scope.model[$scope.options.key] || [];
  18591. var repeatsection = $scope.model[$scope.options.key];
  18592. var lastSection = repeatsection[repeatsection.length - 1];
  18593. var newsection = {};
  18594. repeatsection.push(newsection);
  18595. }
  18596. function addRandomIds(fields) {
  18597. $scope.options.templateOptions.unique++;
  18598. angular.forEach(fields, function (field, index) {
  18599. if (field.fieldGroup) {
  18600. addRandomIds(field.fieldGroup);
  18601. return; // fieldGroups don't need an ID
  18602. }
  18603. if (field.templateOptions && field.templateOptions.fields) {
  18604. addRandomIds(field.templateOptions.fields);
  18605. }
  18606. field.id =
  18607. field.id ||
  18608. field.key +
  18609. "_" +
  18610. index +
  18611. "_" +
  18612. $scope.options.templateOptions.unique +
  18613. getRandomInt(0, 9999);
  18614. });
  18615. }
  18616. function getRandomInt(min, max) {
  18617. return Math.floor(Math.random() * (max - min)) + min;
  18618. }
  18619. if ($scope.options.templateOptions.initDisplay) {
  18620. addNew();
  18621. }
  18622. },
  18623. });
  18624. //时间轴任务列表组件
  18625. //cmdb控件
  18626. formlyConfigProvider.setType({
  18627. name: "ui-cmdb",
  18628. extends: "input",
  18629. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  18630. defaultOptions: function (options) {
  18631. return {
  18632. templateOptions: {
  18633. onClick: function (size, options, modal, event, model) {
  18634. var modalInstance = modal.open({
  18635. templateUrl:
  18636. "assets/views/customform/tpl/cmdb-modal-content.html",
  18637. controller: function (
  18638. $scope,
  18639. $modalInstance,
  18640. title,
  18641. Restangular,
  18642. APIService,
  18643. ConfigDataService,
  18644. ConfigFormService,
  18645. SweetAlert,
  18646. Toaster,
  18647. api_wechatfile
  18648. ) {
  18649. var width = ($scope.width = 600);
  18650. var height = ($scope.height = 400);
  18651. var tree;
  18652. var d3 = window.d3;
  18653. $scope.my_tree_handler = function (branch) {
  18654. //var _ref;
  18655. var classify = ($scope.classify =
  18656. branch.prefix.toLowerCase() + branch.sign);
  18657. APIService.query({
  18658. sign: classify,
  18659. }).then(function (data) {
  18660. var myData = Restangular.stripRestangular(data);
  18661. // console.log(myData.data.node);
  18662. if (myData.data && myData.status == 200) {
  18663. var ret = myData.data;
  18664. redrawSvg(myData);
  18665. }
  18666. });
  18667. };
  18668. $scope.my_data = [];
  18669. function convertListToTree(data, treeMap) {
  18670. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  18671. var root = null; //Initially set our loop to null
  18672. var parentNode = null;
  18673. //loop over data
  18674. for (var i = 0; i < data.length; i++) {
  18675. var datum = data[i];
  18676. //each node will have children, so let's give it a "children" poperty
  18677. datum.children = [];
  18678. //add an entry for this node to the map so that any future children can
  18679. //lookup the parent
  18680. idToNodeMap[datum.id] = datum;
  18681. //Does this node have a parent?
  18682. if (
  18683. typeof datum.parent === "undefined" ||
  18684. datum.parent == null
  18685. ) {
  18686. //Doesn't look like it, so this node is the root of the tree
  18687. root = datum;
  18688. treeMap[datum.id] = root;
  18689. } else {
  18690. //This node has a parent, so let's look it up using the id
  18691. parentNode = idToNodeMap[datum.parent.id];
  18692. //We don't need this property, so let's delete it.
  18693. delete datum.parent;
  18694. //Let's add the current node as a child of the parent node.
  18695. parentNode.children.push(datum);
  18696. }
  18697. }
  18698. return root;
  18699. }
  18700. function convertParentToChildList(data) {
  18701. var treeMap = {};
  18702. var list = [];
  18703. convertListToTree(data, treeMap);
  18704. angular.forEach(treeMap, function (item) {
  18705. list.push(item);
  18706. });
  18707. return list;
  18708. }
  18709. $scope.my_tree = tree = {};
  18710. $scope.try_async_load = function () {
  18711. $scope.my_data = [];
  18712. $scope.select_treedata = [];
  18713. $scope.doing_async = true;
  18714. ConfigDataService.fetchDataList("ciclassify", {
  18715. idx: 0,
  18716. sum: 100,
  18717. }).then(function (result) {
  18718. $scope.select_treedata = $scope.my_data =
  18719. convertParentToChildList(result["list"]);
  18720. $scope.doing_async = false;
  18721. });
  18722. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  18723. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  18724. // $scope.doing_async = false;
  18725. // });
  18726. };
  18727. $scope.select_treedata = [];
  18728. $scope.propTypeOptions = [];
  18729. $scope.try_async_load();
  18730. $scope.onFilterCallback = function (item) {
  18731. //console.log(item);
  18732. if (
  18733. angular.isDefined(item.children) &&
  18734. item.children.length >= 1
  18735. ) {
  18736. //not valid
  18737. } else {
  18738. var tempclassify = item.prefix.toLowerCase() + item.sign;
  18739. $scope.cifilter_classic = tempclassify;
  18740. ConfigFormService.renderTabForm(tempclassify).then(
  18741. function (data) {
  18742. var myData = Restangular.stripRestangular(data);
  18743. $scope.propTypeOptions = myData;
  18744. }
  18745. );
  18746. }
  18747. };
  18748. $scope.onPropTypeChange = function (form) {
  18749. $scope.propOptions = form.fields;
  18750. };
  18751. $scope.onPropChange = function (prop) {
  18752. $scope.cifilter_prop = prop;
  18753. };
  18754. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  18755. //if(searchKey!=null&&searchKey.length>1){
  18756. var searchData = {};
  18757. if (angular.isUndefined(propObj)) {
  18758. propObj = $scope.cifilter_prop;
  18759. }
  18760. if (angular.isUndefined(ciclassify)) {
  18761. ciclassify = $scope.cifilter_classic;
  18762. }
  18763. searchData["sign"] = ciclassify;
  18764. if (angular.isDefined(propObj)) {
  18765. searchData[propObj.key] = searchKey;
  18766. }
  18767. APIService.query(searchData).then(function (response) {
  18768. var data = Restangular.stripRestangular(response);
  18769. //此处不清空nodes
  18770. var node = data.data.node;
  18771. var tempNode = [];
  18772. //nodes 或者links 要去重
  18773. for (var i = 0; i < node.length; i++) {
  18774. var tmp = 0;
  18775. for (var j = 0; j < nodes.length; j++) {
  18776. if (node[i].uuid == nodes[j].uuid) {
  18777. tmp++;
  18778. break;
  18779. }
  18780. }
  18781. if (tmp == 0) {
  18782. tempNode.push(node[i]);
  18783. }
  18784. }
  18785. for (var i = 0; i < tempNode.length; i++) {
  18786. //nodes 不清空
  18787. nodes.push(tempNode[i]);
  18788. }
  18789. restart();
  18790. });
  18791. };
  18792. $scope.refresh = function () {
  18793. nodes.length = 0;
  18794. links.length = 0;
  18795. restart();
  18796. };
  18797. $scope.traversal = function () {
  18798. if ($scope.selected_node == null) {
  18799. SweetAlert.swal({
  18800. title: "错误的操作!",
  18801. text: "没有配置项被选中!",
  18802. type: "error",
  18803. });
  18804. } else {
  18805. var uuid = $scope.selected_node.uuid;
  18806. APIService.traversal(uuid).then(function (response) {
  18807. var d = response.data;
  18808. var node = d.node;
  18809. var link = d.edge;
  18810. var tempNode = [];
  18811. var tempLink = [];
  18812. //nodes 或者links 要去重
  18813. for (var i = 0; i < node.length; i++) {
  18814. var tmp = 0;
  18815. for (var j = 0; j < nodes.length; j++) {
  18816. if (node[i].id == nodes[j].id) {
  18817. tmp++;
  18818. break;
  18819. }
  18820. }
  18821. if (tmp == 0) {
  18822. tempNode.push(node[i]);
  18823. }
  18824. }
  18825. for (var i = 0; i < link.length; i++) {
  18826. var tmp = 0;
  18827. for (var j = 0; j < links.length; j++) {
  18828. if (link[i].id == links[j].id) {
  18829. tmp++;
  18830. break;
  18831. }
  18832. }
  18833. if (tmp == 0) {
  18834. tempLink.push(link[i]);
  18835. }
  18836. }
  18837. //数据写入页面
  18838. for (var i = 0; i < tempNode.length; i++) {
  18839. //nodes 不清空
  18840. nodes.push(tempNode[i]);
  18841. }
  18842. for (var i = 0; i < tempLink.length; i++) {
  18843. //link 不清空
  18844. links.push(tempLink[i]);
  18845. }
  18846. //links转换
  18847. for (var i = 0; i < links.length; i++) {
  18848. for (var j = 0; j < nodes.length; j++) {
  18849. if (links[i].source == nodes[j].id) {
  18850. links[i].source = nodes[j];
  18851. }
  18852. if (links[i].target == nodes[j].id) {
  18853. links[i].target = nodes[j];
  18854. }
  18855. }
  18856. }
  18857. restart();
  18858. });
  18859. }
  18860. };
  18861. var svg;
  18862. var force;
  18863. var drag_line, path, circle;
  18864. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  18865. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  18866. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  18867. var nodes = [],
  18868. links = [];
  18869. var treeNodes = [];
  18870. //读取labels (node)
  18871. var labels = [];
  18872. function redrawSvg(json) {
  18873. nodes.length = 0; //先清空
  18874. links.length = 0;
  18875. var data = json.data;
  18876. for (var i = 0; i < data.node.length; i++) {
  18877. nodes.push(data.node[i]);
  18878. }
  18879. restart();
  18880. }
  18881. //读取status (节点 连线)
  18882. var statuses = [];
  18883. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  18884. // if (result && result.status == 200) {
  18885. // d3.select('#nodeStatus').selectAll('option')
  18886. // .data(statuses).enter()
  18887. // .append('option')
  18888. // .attr('value', function(d) { return d.code; })
  18889. // .html(function(d) { return d.desc; });
  18890. // } else {
  18891. // SweetAlert.swal({
  18892. // title: "提示!",
  18893. // text: "服务器请求异常!",
  18894. // type: "error"
  18895. // });
  18896. // }
  18897. // });
  18898. api_wechatfile
  18899. .getDictionary({
  18900. key: "cmdb_status",
  18901. type: "list",
  18902. })
  18903. .then(function (result) {
  18904. if (result) {
  18905. d3.select("#nodeStatus")
  18906. .selectAll("option")
  18907. .data(statuses)
  18908. .enter()
  18909. .append("option")
  18910. .attr("value", function (d) {
  18911. return d.code;
  18912. })
  18913. .html(function (d) {
  18914. return d.desc;
  18915. });
  18916. } else {
  18917. SweetAlert.swal({
  18918. title: "提示!",
  18919. text: "服务器请求异常!",
  18920. type: "error",
  18921. });
  18922. }
  18923. });
  18924. //查询relationship_type表 name 为表里的type,label为显示值
  18925. var linkType = [];
  18926. function fetchEdgeTypes() {
  18927. ConfigDataService.fetchDataList("ciedgetype", {
  18928. idx: 0,
  18929. sum: 100,
  18930. }).then(function (response) {
  18931. if (response) {
  18932. if (response["list"]) {
  18933. linkType = response["list"];
  18934. // d3.select('#linkName').selectAll('option')
  18935. // .data(linkType).enter()
  18936. // .append('option')
  18937. // .attr('value',function(d){return d.type;})
  18938. // .html(function(d){ return d.label;});
  18939. } else {
  18940. SweetAlert.swal({
  18941. title: "提示!",
  18942. text: "服务器请求异常!",
  18943. type: "error",
  18944. });
  18945. }
  18946. } else {
  18947. SweetAlert.swal({
  18948. title: "提示!",
  18949. text: "服务器请求异常!",
  18950. type: "error",
  18951. });
  18952. }
  18953. });
  18954. }
  18955. // fetchEdgeTypes();
  18956. /*
  18957. // init D3 force layout
  18958. var force = d3.layout.force()
  18959. .nodes(nodes)
  18960. .links(links)
  18961. .size([width, height])
  18962. .gravity(.05)
  18963. .linkDistance(150)
  18964. .linkStrength(2)
  18965. .charge(-500)
  18966. .on('tick', tick);
  18967. // define arrow markers for graph links
  18968. svg.append('svg:defs').append('svg:marker')
  18969. .attr('id', 'end-arrow')
  18970. .attr('viewBox', '0 -5 10 10')
  18971. .attr('refX', 6)
  18972. .attr('markerWidth', 3)
  18973. .attr('markerHeight', 3)
  18974. .attr('orient', 'auto')
  18975. .append('svg:path')
  18976. .attr('d', 'M0,-5L10,0L0,5')
  18977. .attr('fill', '#000');
  18978. svg.append('svg:defs').append('svg:marker')
  18979. .attr('id', 'start-arrow')
  18980. .attr('viewBox', '0 -5 10 10')
  18981. .attr('refX', 4)
  18982. .attr('markerWidth', 3)
  18983. .attr('markerHeight', 3)
  18984. .attr('orient', 'auto')
  18985. .append('svg:path')
  18986. .attr('d', 'M10,-5L0,0L10,5')
  18987. .attr('fill', '#000');
  18988. // line displayed when dragging new nodes
  18989. var drag_line = svg.append('svg:path')
  18990. .attr('class', 'link dragline hidden')
  18991. .attr('d', 'M0,0L0,0');
  18992. // handles to link and node element groups
  18993. //(1)var path = svg.append('svg:g').selectAll('g')
  18994. var path = svg.append('svg:g').selectAll('g'),
  18995. circle = svg.append('svg:g').selectAll('g');
  18996. */
  18997. // mouse event vars
  18998. var selected_node = null,
  18999. selected_link = null,
  19000. mousedown_link = null,
  19001. mousedown_node = null,
  19002. mouseup_node = null;
  19003. function resetMouseVars() {
  19004. mousedown_node = null;
  19005. mouseup_node = null;
  19006. mousedown_link = null;
  19007. }
  19008. // update force layout (called automatically each iteration)
  19009. function tick() {
  19010. // draw directed edges with proper padding from node centers
  19011. path.selectAll("path").attr("d", function (d) {
  19012. var deltaX = d.target.x - d.source.x,
  19013. deltaY = d.target.y - d.source.y,
  19014. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  19015. normX = deltaX / dist,
  19016. normY = deltaY / dist,
  19017. sourcePadding = d.left ? 27 : 22,
  19018. targetPadding = d.right ? 27 : 22,
  19019. sourceX = d.source.x + sourcePadding * normX,
  19020. sourceY = d.source.y + sourcePadding * normY,
  19021. targetX = d.target.x - targetPadding * normX,
  19022. targetY = d.target.y - targetPadding * normY;
  19023. return (
  19024. "M" +
  19025. sourceX +
  19026. "," +
  19027. sourceY +
  19028. "L" +
  19029. targetX +
  19030. "," +
  19031. targetY
  19032. );
  19033. });
  19034. circle.attr("transform", function (d) {
  19035. return "translate(" + d.x + "," + d.y + ")";
  19036. });
  19037. }
  19038. // update graph (called when needed)
  19039. function restart() {
  19040. //绑定link 数据
  19041. path.datum(links);
  19042. // path (link) group
  19043. path = path.data(links, function (d) {
  19044. return d.id;
  19045. });
  19046. var p = path.enter().append("svg:g");
  19047. //update existing links
  19048. path
  19049. .selectAll("path")
  19050. .classed("selected", function (d) {
  19051. return d === selected_link;
  19052. })
  19053. .style("marker-start", function (d) {
  19054. return d.left ? "url(#start-arrow)" : "";
  19055. })
  19056. .style("marker-end", function (d) {
  19057. return d.right ? "url(#end-arrow)" : "";
  19058. });
  19059. // add new links
  19060. p.append("svg:path")
  19061. .attr("class", "link")
  19062. .attr("id", function (d) {
  19063. return "path_" + d.id;
  19064. })
  19065. // .attr('startOffset', '0%')
  19066. .classed("selected", function (d) {
  19067. return d === selected_link;
  19068. })
  19069. .style("marker-start", function (d) {
  19070. return d.left ? "url(#start-arrow)" : "";
  19071. })
  19072. .style("marker-end", function (d) {
  19073. return d.right ? "url(#end-arrow)" : "";
  19074. })
  19075. .on("mousedown", function (d) {
  19076. if (d3.event.ctrlKey) return;
  19077. //去除没有提交的连线
  19078. for (var i = 0; i < links.length; i++) {
  19079. if (links[i].id == -1 && d.id != -1) {
  19080. links.splice(i, 1);
  19081. }
  19082. }
  19083. // select link
  19084. mousedown_link = d;
  19085. if (mousedown_link === selected_link) {
  19086. selected_link = $scope.selected_link = null;
  19087. selected_node = $scope.selected_node = null;
  19088. // d3.select("#linkDetail").attr('style','display:none');
  19089. //hideLinkForm(true);//return ;
  19090. } else {
  19091. selected_link = $scope.selected_link = mousedown_link;
  19092. selected_node = $scope.selected_node = null;
  19093. }
  19094. selected_node = $scope.selected_node = null;
  19095. restart();
  19096. });
  19097. p.append("svg:text")
  19098. .attr("x", 30)
  19099. .attr("y", 20)
  19100. .attr("class", "fontM")
  19101. .append("textPath")
  19102. .attr("xlink:xlink:href", function (d, i) {
  19103. return "#path_" + d.id;
  19104. })
  19105. .html(function (d) {
  19106. for (var i = 0; i < linkType.length; i++) {
  19107. if (linkType[i].type == d.name) {
  19108. return linkType[i].label;
  19109. }
  19110. }
  19111. });
  19112. // remove old links
  19113. path.exit().remove();
  19114. // circle (node) group
  19115. // NB: the function arg is crucial here! nodes are known by id, not by index!
  19116. circle.datum(nodes);
  19117. circle = circle.data(nodes, function (d) {
  19118. return d.id;
  19119. });
  19120. // update existing nodes (reflexive & selected visual states)
  19121. circle
  19122. .selectAll("circle")
  19123. .style("fill", function (d) {
  19124. return d === selected_node
  19125. ? d3.rgb(colors(d.label)).brighter().toString()
  19126. : colors(d.label);
  19127. })
  19128. .style("fill-opacity", 0.75) // add by xi
  19129. .classed("reflexive", function (d) {
  19130. return d.reflexive;
  19131. });
  19132. // add new nodes
  19133. var g = circle.enter().append("svg:g");
  19134. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  19135. //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');
  19136. g.append("svg:circle")
  19137. .attr("r", 24)
  19138. .style("fill", function (d) {
  19139. return d === selected_node
  19140. ? "rgb(153,153,153)"
  19141. : "rgb(255,255,255)";
  19142. })
  19143. .style("stroke", function (d) {
  19144. return d3.rgb(colors(d.label)).darker().toString();
  19145. })
  19146. .style("stroke-width", "2");
  19147. g.append("svg:circle")
  19148. .attr("class", "node")
  19149. .attr("r", 18)
  19150. .style("fill", function (d) {
  19151. return d === selected_node
  19152. ? d3.rgb(colors(d.label)).brighter().toString()
  19153. : colors(d.label);
  19154. })
  19155. .style("stroke", function (d) {
  19156. return d3.rgb(colors(d.label)).darker().toString();
  19157. })
  19158. .style("fill-opacity", 0.25) //add by xj
  19159. .style("stroke-opacity", 0.5) //add by xj
  19160. .classed("reflexive", function (d) {
  19161. return d.reflexive;
  19162. });
  19163. g.on("mouseover", function (d) {
  19164. //if(!mousedown_node || d === mousedown_node) return;
  19165. // enlarge target node
  19166. //d3.select(this).attr('transform', 'scale(1.1)');
  19167. })
  19168. .on("mouseout", function (d) {
  19169. //if(!mousedown_node || d === mousedown_node) return;
  19170. // unenlarge target node
  19171. //d3.select(this).attr('transform', '');
  19172. })
  19173. .on("mousedown", function (d) {
  19174. if (d3.event.ctrlKey) return;
  19175. //hideLinkForm(true);
  19176. //去除没有提交的连线
  19177. for (var i = 0; i < links.length; i++) {
  19178. if (links[i].id == -1) {
  19179. links.splice(i, 1);
  19180. }
  19181. }
  19182. // select node
  19183. mousedown_node = d;
  19184. if (mousedown_node === selected_node) {
  19185. selected_node = $scope.selected_node = null;
  19186. } else {
  19187. selected_node = $scope.selected_node = mousedown_node;
  19188. selected_link = $scope.selected_link = null;
  19189. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  19190. APIService.findRefById(selected_node.id).then(function (
  19191. result
  19192. ) {
  19193. var d = result.data;
  19194. var node = d.node;
  19195. var link = d.edge;
  19196. var tempNode = [];
  19197. var tempLink = [];
  19198. //nodes 或者links 要去重
  19199. for (var i = 0; i < node.length; i++) {
  19200. var tmp = 0;
  19201. for (var j = 0; j < nodes.length; j++) {
  19202. if (node[i].id == nodes[j].id) {
  19203. tmp++;
  19204. break;
  19205. }
  19206. }
  19207. if (tmp == 0) {
  19208. tempNode.push(node[i]);
  19209. }
  19210. }
  19211. for (var i = 0; i < link.length; i++) {
  19212. var tmp = 0;
  19213. for (var j = 0; j < links.length; j++) {
  19214. if (link[i].id == links[j].id) {
  19215. tmp++;
  19216. break;
  19217. }
  19218. }
  19219. if (tmp == 0) {
  19220. tempLink.push(link[i]);
  19221. }
  19222. }
  19223. //数据写入页面
  19224. for (var i = 0; i < tempNode.length; i++) {
  19225. //nodes 不清空
  19226. nodes.push(tempNode[i]);
  19227. }
  19228. for (var i = 0; i < tempLink.length; i++) {
  19229. //link 不清空
  19230. links.push(tempLink[i]);
  19231. }
  19232. //links转换
  19233. for (var i = 0; i < links.length; i++) {
  19234. for (var j = 0; j < nodes.length; j++) {
  19235. if (links[i].source == nodes[j].id) {
  19236. links[i].source = nodes[j];
  19237. }
  19238. if (links[i].target == nodes[j].id) {
  19239. links[i].target = nodes[j];
  19240. }
  19241. }
  19242. }
  19243. restart();
  19244. });
  19245. }
  19246. // reposition drag line
  19247. drag_line
  19248. .style("marker-end", "url(#end-arrow)")
  19249. .classed("hidden", false)
  19250. .attr(
  19251. "d",
  19252. "M" +
  19253. mousedown_node.x +
  19254. "," +
  19255. mousedown_node.y +
  19256. "L" +
  19257. mousedown_node.x +
  19258. "," +
  19259. mousedown_node.y
  19260. );
  19261. restart();
  19262. })
  19263. .on("mouseup", function (d) {
  19264. if (!mousedown_node) return;
  19265. });
  19266. // show node name
  19267. g.append("svg:text")
  19268. .attr("x", 0)
  19269. .attr("y", 34)
  19270. .attr("class", "id")
  19271. .text(function (d) {
  19272. return d.name;
  19273. }); //TODO 改为 d.name
  19274. //设置图片
  19275. g.append("svg:foreignObject")
  19276. .attr("width", 32)
  19277. .attr("height", 32)
  19278. .attr("x", "-16px")
  19279. .attr("y", "-11px")
  19280. .html(function (d) {
  19281. for (var i = 0; i < labels.length; i++) {
  19282. if (d.label == labels[i].sign) {
  19283. return (
  19284. '<i class="icon iconfont">' +
  19285. labels[i].iconname +
  19286. "</i>"
  19287. );
  19288. }
  19289. }
  19290. });
  19291. // remove old nodes
  19292. circle.exit().remove();
  19293. // set the graph in motion
  19294. force.start();
  19295. }
  19296. function mousedown() {
  19297. // prevent I-bar on drag
  19298. //d3.event.preventDefault();
  19299. // because :active only works in WebKit?
  19300. svg.classed("active", true);
  19301. if (mousedown_node) {
  19302. viewNode(mousedown_node);
  19303. }
  19304. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  19305. return;
  19306. restart();
  19307. }
  19308. function mousemove() {
  19309. if (!mousedown_node) return;
  19310. // update drag line
  19311. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  19312. //restart();
  19313. }
  19314. function mouseup() {
  19315. if (mousedown_node) {
  19316. // hide drag line
  19317. drag_line.classed("hidden", true).style("marker-end", "");
  19318. }
  19319. // because :active only works in WebKit?
  19320. svg.classed("active", false);
  19321. // clear mouse event vars
  19322. resetMouseVars();
  19323. }
  19324. function spliceLinksForNode(node) {
  19325. var toSplice = links.filter(function (l) {
  19326. return l.source === node || l.target === node;
  19327. });
  19328. toSplice.map(function (l) {
  19329. links.splice(links.indexOf(l), 1);
  19330. });
  19331. }
  19332. // only respond once per keydown
  19333. var lastKeyDown = -1;
  19334. function keydown() {
  19335. //d3.event.preventDefault();
  19336. if (lastKeyDown !== -1) return;
  19337. lastKeyDown = d3.event.keyCode;
  19338. // ctrl
  19339. if (d3.event.keyCode === 17) {
  19340. circle.call(force.drag);
  19341. svg.classed("ctrl", true);
  19342. }
  19343. if (!selected_node && !selected_link) return;
  19344. switch (d3.event.keyCode) {
  19345. case 8: // backspace
  19346. case 66: // B
  19347. if (selected_link) {
  19348. // set link direction to both left and right
  19349. selected_link.left = true;
  19350. selected_link.right = true;
  19351. }
  19352. restart();
  19353. break;
  19354. case 76: // L
  19355. if (selected_link) {
  19356. // set link direction to left only
  19357. selected_link.left = true;
  19358. selected_link.right = false;
  19359. }
  19360. restart();
  19361. break;
  19362. case 82: // R
  19363. if (selected_node) {
  19364. // toggle node reflexivity
  19365. selected_node.reflexive = !selected_node.reflexive;
  19366. } else if (selected_link) {
  19367. // set link direction to right only
  19368. selected_link.left = false;
  19369. selected_link.right = true;
  19370. }
  19371. restart();
  19372. break;
  19373. }
  19374. }
  19375. function keyup() {
  19376. lastKeyDown = -1;
  19377. // ctrl
  19378. if (d3.event.keyCode === 17) {
  19379. circle
  19380. .on("mousedown.drag", null)
  19381. .on("touchstart.drag", null);
  19382. svg.classed("ctrl", false);
  19383. }
  19384. }
  19385. function viewNode(node) {
  19386. // console.log(svg.attr('left'));
  19387. //var el = angular.element('div.modal-dialog')[0];
  19388. var title =
  19389. $scope.selected_node.name +
  19390. "-[" +
  19391. $scope.selected_node.uuid +
  19392. "]";
  19393. if (!$scope.selected_node.props.state) {
  19394. $scope.selected_node.props.state = "空";
  19395. } else if ($scope.selected_node.props.state) {
  19396. if ($scope.selected_node.props.state == "1") {
  19397. $scope.selected_node.props.state = "未审核";
  19398. } else if ($scope.selected_node.props.state == "2") {
  19399. $scope.selected_node.props.state = "已审核";
  19400. } else if ($scope.selected_node.props.state == "3") {
  19401. $scope.selected_node.props.state = "不匹配";
  19402. } else if ($scope.selected_node.props.state == "4") {
  19403. $scope.selected_node.props.state = "丢失";
  19404. }
  19405. }
  19406. if (!$scope.selected_node.name) {
  19407. $scope.selected_node.name = "空";
  19408. }
  19409. if (!$scope.selected_node.status) {
  19410. $scope.selected_node.statu = "空";
  19411. }
  19412. if (!$scope.selected_node.props.useradmin) {
  19413. $scope.selected_node.props.useradmin = "空";
  19414. }
  19415. Toaster.pop({
  19416. // type: 'info',
  19417. // title: title,
  19418. body:
  19419. "<br/><p>搜索代码:" +
  19420. $scope.selected_node.uuid +
  19421. "</p>" +
  19422. "<p>配置标题:" +
  19423. $scope.selected_node.name +
  19424. "</p>" +
  19425. "<p>状态:" +
  19426. $scope.selected_node.status +
  19427. "</p>" +
  19428. "<p>审核状态:" +
  19429. $scope.selected_node.props.state +
  19430. "</p>" +
  19431. "<p>维护人员:" +
  19432. $scope.selected_node.props.useradmin +
  19433. "</p>",
  19434. bodyOutputType: "trustedHtml",
  19435. timeout: 3000,
  19436. });
  19437. }
  19438. //GT 颜色与数值对照表
  19439. function colors(sign) {
  19440. //num=num>20?num%20:parseInt(num);
  19441. for (var i = 0; i < labels.length; i++) {
  19442. var entity = labels[i];
  19443. if (sign == entity.sign) {
  19444. return entity.color;
  19445. }
  19446. if (i == labels.length - 1 && sign != entity.sign) {
  19447. return "#ffeeee";
  19448. }
  19449. }
  19450. }
  19451. $scope.init = function () {
  19452. svg = d3
  19453. .select("#cmdbSVG")
  19454. .append("svg")
  19455. .attr("width", width)
  19456. .attr("height", height);
  19457. // init D3 force layout
  19458. force = d3.layout
  19459. .force()
  19460. .nodes(nodes)
  19461. .links(links)
  19462. .size([width, height])
  19463. .gravity(0.05)
  19464. .linkDistance(150)
  19465. .linkStrength(2)
  19466. .charge(-500)
  19467. .on("tick", tick);
  19468. // define arrow markers for graph links
  19469. svg
  19470. .append("svg:defs")
  19471. .append("svg:marker")
  19472. .attr("id", "end-arrow")
  19473. .attr("viewBox", "0 -5 10 10")
  19474. .attr("refX", 6)
  19475. .attr("markerWidth", 3)
  19476. .attr("markerHeight", 3)
  19477. .attr("orient", "auto")
  19478. .append("svg:path")
  19479. .attr("d", "M0,-5L10,0L0,5")
  19480. .attr("fill", "#000");
  19481. svg
  19482. .append("svg:defs")
  19483. .append("svg:marker")
  19484. .attr("id", "start-arrow")
  19485. .attr("viewBox", "0 -5 10 10")
  19486. .attr("refX", 4)
  19487. .attr("markerWidth", 3)
  19488. .attr("markerHeight", 3)
  19489. .attr("orient", "auto")
  19490. .append("svg:path")
  19491. .attr("d", "M10,-5L0,0L10,5")
  19492. .attr("fill", "#000");
  19493. // line displayed when dragging new nodes
  19494. drag_line = svg
  19495. .append("svg:path")
  19496. .attr("class", "link dragline hidden")
  19497. .attr("d", "M0,0L0,0");
  19498. // handles to link and node element groups
  19499. //(1)var path = svg.append('svg:g').selectAll('g')
  19500. path = svg.append("svg:g").selectAll("g");
  19501. circle = svg.append("svg:g").selectAll("g");
  19502. svg
  19503. .on("mousedown", mousedown)
  19504. .on("mousemove", mousemove)
  19505. .on("mouseup", mouseup);
  19506. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  19507. };
  19508. var CI = {};
  19509. window.CI = CI;
  19510. $scope.ok = function () {
  19511. $modalInstance.close($scope.selected_node);
  19512. };
  19513. $scope.cancel = function () {
  19514. $modalInstance.dismiss("cancel");
  19515. };
  19516. },
  19517. size: size,
  19518. resolve: {
  19519. title: function () {
  19520. return options.templateOptions.title;
  19521. },
  19522. Restangular: function () {
  19523. return options.templateOptions.Restangular;
  19524. },
  19525. APIService: function () {
  19526. return options.templateOptions.ApiService;
  19527. },
  19528. ConfigDataService: function () {
  19529. return options.templateOptions.ConfigDataService;
  19530. },
  19531. ConfigFormService: function () {
  19532. return options.templateOptions.ConfigFormService;
  19533. },
  19534. SweetAlert: function () {
  19535. return options.templateOptions.Alert;
  19536. },
  19537. Toaster: function () {
  19538. return options.templateOptions.toaster;
  19539. },
  19540. },
  19541. });
  19542. modalInstance.result.then(
  19543. function (selectedItem) {
  19544. options.value(selectedItem.name + "-" + selectedItem.uuid);
  19545. },
  19546. function () {
  19547. //console.log('Modal dismissed at: ' + new Date());
  19548. }
  19549. );
  19550. },
  19551. },
  19552. };
  19553. },
  19554. controller: [
  19555. "$scope",
  19556. function ($scope) {
  19557. // setTimeout(function(){
  19558. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  19559. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  19560. // if(modelData.status==200){
  19561. // $scope.model[$scope.options.key] = modelData.data;
  19562. // $scope.options.initialValue = $scope.model[$scope.options.key];
  19563. // }
  19564. // });
  19565. // },1000);
  19566. },
  19567. ],
  19568. });
  19569. });
  19570. appFormly.run(function (formlyConfig, $parse) {
  19571. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  19572. var removeOnHideTransformer = function (fields, model) {
  19573. return fields.map(function (field) {
  19574. if (
  19575. field.hideExpression &&
  19576. (!field.data || !field.data.dontRemoveOnHidden)
  19577. ) {
  19578. addFieldRemoveOnHideWatcher(field);
  19579. }
  19580. if (field.type == "ui-title") {
  19581. addFieldRemoveOnHideWatcher(field);
  19582. }
  19583. return field;
  19584. });
  19585. };
  19586. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  19587. function addFieldRemoveOnHideWatcher(field) {
  19588. var watcher = getWatcher();
  19589. if (field.watcher) {
  19590. if (!angular.isArray(field.watcher)) {
  19591. field.watcher = [field.watcher];
  19592. }
  19593. field.watcher.push(watcher);
  19594. } else {
  19595. field.watcher = watcher;
  19596. }
  19597. }
  19598. function getWatcher() {
  19599. return {
  19600. expression: function (field) {
  19601. return field.hide;
  19602. },
  19603. listener: function (field, newHide, oldHide, scope) {
  19604. if (field.hide) {
  19605. if (field.templateOptions.pkey) {
  19606. if (field.key == "transferuser") {
  19607. $parse(field.templateOptions.pkey + "." + field.key).assign(
  19608. scope.model,
  19609. undefined
  19610. );
  19611. }
  19612. } else {
  19613. $parse(field.key).assign(scope.model, undefined);
  19614. }
  19615. }
  19616. if (field.type == "ui-title") {
  19617. $parse(field.key).assign(scope.model, undefined);
  19618. }
  19619. },
  19620. };
  19621. }
  19622. });
  19623. appFormly.controller("CustomformCtrl", [
  19624. "$rootScope",
  19625. "$scope",
  19626. "$parse",
  19627. "$injector",
  19628. "$http",
  19629. "$q",
  19630. "$state",
  19631. "$stateParams",
  19632. "$modal",
  19633. "$timeout",
  19634. "$interval",
  19635. "SweetAlert",
  19636. "FileUploader",
  19637. "i18nService",
  19638. "Restangular",
  19639. "UserRestangular",
  19640. "BpmRestangular",
  19641. "WechatRestangular",
  19642. "api_configure_form",
  19643. "api_bpm_domain",
  19644. "api_bpm_data",
  19645. "api_user_data",
  19646. "api_statistic",
  19647. "up_down_file",
  19648. "fileReader",
  19649. function (
  19650. $rootScope,
  19651. $scope,
  19652. $parse,
  19653. $injector,
  19654. $http,
  19655. $q,
  19656. $state,
  19657. $stateParams,
  19658. $modal,
  19659. $timeout,
  19660. $interval,
  19661. SweetAlert,
  19662. FileUploader,
  19663. i18nService,
  19664. Restangular,
  19665. UserRestangular,
  19666. BpmRestangular,
  19667. WechatRestangular,
  19668. api_configure_form,
  19669. api_bpm_domain,
  19670. api_bpm_data,
  19671. api_user_data,
  19672. api_statistic,
  19673. up_down_file,
  19674. fileReader
  19675. ) {
  19676. //console.log($parse('Restangular')($scope));
  19677. //console.log($injector.get('Restangular'));
  19678. //console.log($stateParams);
  19679. //保存报修主体
  19680. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  19681. $scope.imgUrlList = [];
  19682. $scope.uploadimg_del = function () {
  19683. console.log(123);
  19684. };
  19685. var vm = this;
  19686. vm.options = {};
  19687. vm.exampleTitle = ["expressionProperties", "model property"];
  19688. vm.fields = [];
  19689. vm.model = {};
  19690. $scope.langs = i18nService.getAllLangs();
  19691. $scope.lang = "zh-cn";
  19692. i18nService.setCurrentLang($scope.lang);
  19693. //alert($rootScope.user.id,null,2);
  19694. vm.model["loginUser"] = $rootScope.user;
  19695. var loginUser = $rootScope.user;
  19696. // console.log(vm);
  19697. var that = $injector;
  19698. var parse = $parse;
  19699. var formKey = "";
  19700. var pdKey = "";
  19701. var modelWatch = "";
  19702. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  19703. modelWatch = JSON.parse($stateParams.model);
  19704. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  19705. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  19706. console.log(modelWatch, $rootScope);
  19707. // if(modelWatch.model.incident){
  19708. // if(modelWatch.model.incident.place){
  19709. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  19710. // }else{
  19711. // $rootScope.selecthouseNumber = undefined;
  19712. // }
  19713. // }
  19714. }
  19715. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  19716. pdKey = $state.current.pdKey;
  19717. } else if ($stateParams.pdKey) {
  19718. pdKey = $stateParams.pdKey;
  19719. }
  19720. // console.log("pdKey::" + JSON.stringify($state.current.title));
  19721. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  19722. formKey = $stateParams.formKey;
  19723. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  19724. }
  19725. if (angular.isDefined($stateParams.model)) {
  19726. var formModel = $stateParams.model;
  19727. }
  19728. //用户测试数据,后续从header的auth中获取
  19729. var userId = 2;
  19730. userId = $rootScope.user.id;
  19731. //==============处理表单设计数据 开始====================
  19732. //处理组件加载后台数据选项的方法
  19733. function refreshSelectOptions(searchVal, field) {
  19734. if (
  19735. field.templateOptions.optionsUrl &&
  19736. !field.templateOptions.isnosearch
  19737. ) {
  19738. var process = BpmRestangular.all("");
  19739. if (field.templateOptions.ApiService) {
  19740. process = UserRestangular.all("");
  19741. }
  19742. if (field.templateOptions.Apicommon) {
  19743. process = WechatRestangular.all("");
  19744. }
  19745. var datakey = {
  19746. idx: 0,
  19747. sum: 1000,
  19748. };
  19749. if (field.templateOptions.modelreasondata) {
  19750. datakey = field.templateOptions.modelreasondata;
  19751. }
  19752. process
  19753. .customPOST(datakey, field.templateOptions.optionsUrl)
  19754. .then(function (result) {
  19755. if (!field.templateOptions.options) {
  19756. field.templateOptions.options = [];
  19757. }
  19758. if (field.templateOptions.optionsDataKey) {
  19759. field.templateOptions.options =
  19760. result[field.templateOptions.optionsDataKey];
  19761. } else {
  19762. field.templateOptions.options = result;
  19763. }
  19764. });
  19765. }
  19766. }
  19767. //获取表单后数据处理
  19768. function formfield(field, result) {
  19769. // angular.forEach(fields.fields, function(field) {
  19770. if (field.key == "") {
  19771. delete field.key;
  19772. }
  19773. if (angular.isDefined(field.extjson)) {
  19774. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  19775. angular.extend(field.templateOptions, extObj.templateOptions);
  19776. delete extObj.templateOptions;
  19777. for (var prop in extObj) {
  19778. if (new RegExp("Expression").test(prop)) {
  19779. //var obj = $scope.$eval(extObj[prop]);
  19780. //extObj[prop] = $scope.$eval(extObj[prop]);
  19781. if (extObj[prop] != null) {
  19782. if (new RegExp("function").test(extObj[prop])) {
  19783. var propValue = eval(extObj[prop]);
  19784. extObj[prop] = propValue;
  19785. } else {
  19786. //console.log(extObj[prop]);
  19787. var obj = $scope.$eval(extObj[prop]);
  19788. extObj[prop] = obj;
  19789. //console.log(obj);
  19790. }
  19791. }
  19792. } else if (new RegExp("expressionProperties").test(prop)) {
  19793. for (var p in extObj[prop]) {
  19794. if (new RegExp("function").test(extObj[prop][p])) {
  19795. var propValue = eval(extObj[prop][p]);
  19796. extObj[prop][p] = propValue;
  19797. } else {
  19798. //if(p.indexOf("'")>=0){
  19799. // var obj = $scope.$eval(extObj[prop][p]);
  19800. // extObj[prop][$scope.$eval(p)]=obj;
  19801. //}
  19802. }
  19803. }
  19804. } else if ("watcher" == prop) {
  19805. if (angular.isArray(extObj[prop])) {
  19806. angular.forEach(extObj[prop], function (item, index) {
  19807. for (var p in item) {
  19808. if (new RegExp("function").test(item[p])) {
  19809. var propValue = eval(item[p]);
  19810. extObj[prop][index][p] = propValue;
  19811. }
  19812. }
  19813. });
  19814. } else if (angular.isObject(extObj[prop])) {
  19815. for (var p in extObj[prop]) {
  19816. if (new RegExp("function").test(extObj[prop][p])) {
  19817. var propValue = eval(extObj[prop][p]);
  19818. extObj[prop][p] = propValue;
  19819. }
  19820. }
  19821. }
  19822. }
  19823. }
  19824. angular.extend(field, extObj);
  19825. delete field.extjson;
  19826. }
  19827. if (angular.isDefined(field.templateOptions)) {
  19828. var templateOs = field.templateOptions;
  19829. // console.log(templateOs,'come')
  19830. for (var property in templateOs) {
  19831. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  19832. if (angular.isString(templateOs[property])) {
  19833. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  19834. if (new RegExp("function").test(templateOs[property])) {
  19835. var propValue = eval(templateOs[property]);
  19836. field.templateOptions[property] = propValue;
  19837. } else {
  19838. if (that.has(templateOs[property])) {
  19839. field.templateOptions[property] = that.get(
  19840. templateOs[property]
  19841. );
  19842. } else {
  19843. field.templateOptions[property] = templateOs[property];
  19844. }
  19845. }
  19846. } else if (templateOs[property] == null) {
  19847. //delete field.templateOptions[property];
  19848. } else {
  19849. }
  19850. }
  19851. }
  19852. if (
  19853. angular.isDefined(field.templateOptions) &&
  19854. angular.isDefined(field.templateOptions.extjson)
  19855. ) {
  19856. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  19857. angular.extend(field.templateOptions, extObj);
  19858. delete field.templateOptions.extjson;
  19859. }
  19860. // ...
  19861. if (field.templateOptions) {
  19862. //处理远程获取数据控件方法调用
  19863. if (
  19864. field.templateOptions.optionsUrl &&
  19865. !field.templateOptions.refresh
  19866. ) {
  19867. // if (!field.templateOptions.isnoreash) {
  19868. field.templateOptions.refresh = refreshSelectOptions;
  19869. // }
  19870. }
  19871. //处理嵌套属性数据绑定/
  19872. if (field.templateOptions.pkey) {
  19873. var pmodel,
  19874. i = 0;
  19875. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  19876. if (i == 0) {
  19877. if (result.model[p] == null) {
  19878. result.model[p] = {};
  19879. }
  19880. pmodel = result.model[p];
  19881. i++;
  19882. } else {
  19883. if (pmodel[p] == null) {
  19884. pmodel[p] = {};
  19885. }
  19886. pmodel = pmodel[p];
  19887. }
  19888. });
  19889. if (pmodel != null) {
  19890. field.model = pmodel;
  19891. if (pmodel[field.key] == null) {
  19892. pmodel[field.key] = null;
  19893. }
  19894. }
  19895. } else {
  19896. if (result.model[field.key] == null) {
  19897. result.model[field.key] = null;
  19898. }
  19899. }
  19900. //处理弹出框组件初始化
  19901. if (field.type == "ui-input-selectmodal") {
  19902. field.templateOptions.modal = $modal;
  19903. //field.templateOptions.Restangular = Restangular;
  19904. } else if (field.type == "ui-requesterselect") {
  19905. //field.templateOptions.language = $scope.lang;
  19906. field.templateOptions.modal = $modal;
  19907. field.templateOptions.UserService = api_user_data;
  19908. } else if (field.type == "ui-deptinformation") {
  19909. field.templateOptions.modal = $modal;
  19910. field.templateOptions.UserService = api_user_data;
  19911. } else if (field.type == "ui-requesterinformation") {
  19912. field.templateOptions.modal = $modal;
  19913. field.templateOptions.UserService = api_user_data;
  19914. } else if (field.type == "ui-userselect") {
  19915. field.templateOptions.modal = $modal;
  19916. //field.templateOptions.Restangular = Restangular;
  19917. } else if (field.type == "ui-userselectSearch") {
  19918. field.templateOptions.modal = $modal;
  19919. //field.templateOptions.Restangular = Restangular;
  19920. } else if (field.type == "ui-multiuserselect") {
  19921. field.templateOptions.modal = $modal;
  19922. } else if (field.type == "ui-stringuserselect") {
  19923. field.templateOptions.modal = $modal;
  19924. } else if (field.type == "ui-search") {
  19925. field.templateOptions.modal = $modal;
  19926. } else if (field.type == "ui-modelselect") {
  19927. field.templateOptions.modal = $modal;
  19928. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  19929. field.templateOptions.loginUser = $rootScope.user;
  19930. //field.templateOptions.Restangular = Restangular;
  19931. } else if (field.type == "ui-incidentmodelselect") {
  19932. field.templateOptions.modal = $modal;
  19933. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  19934. field.templateOptions.loginUser = $rootScope.user;
  19935. //field.templateOptions.Restangular = Restangular;
  19936. } else if (field.type == "ui-dropfile") {
  19937. $scope.fileUploader = field.templateOptions.fileUploader =
  19938. new FileUploader({
  19939. url: "/uploader",
  19940. });
  19941. field.templateOptions.taskId = $stateParams.taskId;
  19942. field.templateOptions.processInstanceId =
  19943. $stateParams.processInstanceId;
  19944. field.templateOptions.userId = $rootScope.user.id;
  19945. } else if (field.type == "ui-dropfielknow") {
  19946. $scope.fileUploader = field.templateOptions.fileUploader =
  19947. new FileUploader({
  19948. url: "/uploader",
  19949. });
  19950. field.templateOptions.taskId = $stateParams.taskId;
  19951. field.templateOptions.processInstanceId =
  19952. $stateParams.processInstanceId;
  19953. field.templateOptions.userId = $rootScope.user.id;
  19954. } else if (field.type == "ui-upDropFile") {
  19955. $scope.fileUploader = field.templateOptions.fileUploader =
  19956. new FileUploader({
  19957. url: "/uploader",
  19958. });
  19959. field.templateOptions.taskId = $stateParams.taskId;
  19960. field.templateOptions.processInstanceId =
  19961. $stateParams.processInstanceId;
  19962. field.templateOptions.userId = $rootScope.user.id;
  19963. } else if (field.type == "ui-dropfilenotup") {
  19964. $scope.fileUploader = field.templateOptions.fileUploader =
  19965. new FileUploader({
  19966. url: "/uploader",
  19967. });
  19968. field.templateOptions.taskId = $stateParams.taskId;
  19969. field.templateOptions.processInstanceId =
  19970. $stateParams.processInstanceId;
  19971. field.templateOptions.userId = $rootScope.user.id;
  19972. //field.ApiService=api_bpm_domain;
  19973. } else if (field.type == "ui-uploadFiles") {
  19974. $scope.fileUploader = field.templateOptions.fileUploader =
  19975. new FileUploader({
  19976. url: "/uploader",
  19977. });
  19978. field.templateOptions.taskId = $stateParams.taskId;
  19979. field.templateOptions.processInstanceId =
  19980. $stateParams.processInstanceId;
  19981. field.templateOptions.userId = $rootScope.user.id;
  19982. //field.ApiService=api_bpm_domain;
  19983. } else if (field.type == "ui-upDownFiles") {
  19984. $scope.fileUploader = field.templateOptions.fileUploader =
  19985. new FileUploader({
  19986. url: "/uploader",
  19987. });
  19988. field.templateOptions.taskId = $stateParams.taskId;
  19989. field.templateOptions.processInstanceId =
  19990. $stateParams.processInstanceId;
  19991. field.templateOptions.userId = $rootScope.user.id;
  19992. //field.ApiService=api_bpm_domain;
  19993. } else if (field.type == "ui-uploadImgs") {
  19994. $scope.fileUploader = field.templateOptions.fileUploader =
  19995. new FileUploader({
  19996. url: "/uploader",
  19997. });
  19998. field.templateOptions.taskId = $stateParams.taskId;
  19999. field.templateOptions.processInstanceId =
  20000. $stateParams.processInstanceId;
  20001. field.templateOptions.userId = $rootScope.user.id;
  20002. //field.ApiService=api_bpm_domain;
  20003. } else if (field.type == "ui-dropfiletable") {
  20004. if (field.templateOptions.processInstanceId) {
  20005. } else {
  20006. field.templateOptions.processInstanceId =
  20007. $stateParams.processInstanceId;
  20008. }
  20009. } else if (field.type == "ui-dropFiles") {
  20010. if (field.templateOptions.processInstanceId) {
  20011. } else {
  20012. field.templateOptions.processInstanceId =
  20013. $stateParams.processInstanceId;
  20014. }
  20015. } else if (field.type == "ui-showImgs") {
  20016. if (field.templateOptions.processInstanceId) {
  20017. } else {
  20018. field.templateOptions.processInstanceId =
  20019. $stateParams.processInstanceId;
  20020. }
  20021. } else if (field.type == "ui-repeatSection") {
  20022. var repeatForm = {
  20023. model: {},
  20024. fields: field.templateOptions.fields,
  20025. };
  20026. repeatForm.model[field.key] = [];
  20027. decodeVMForm(repeatForm);
  20028. } else if (field.type == "ui-currentuser") {
  20029. field.templateOptions.user = vm.model["loginUser"];
  20030. } else if (field.type == "ui-workernumbersign") {
  20031. field.templateOptions.user = vm.model["loginUser"];
  20032. } else if (field.type == "ui-repair-photos") {
  20033. field.templateOptions.user = vm.model["loginUser"];
  20034. }
  20035. }
  20036. }
  20037. //解析自定义表单设计数据
  20038. $scope.oldfromtype = true;
  20039. function decodeVMForm(vmForm) {
  20040. if (vmForm.formType == "1") {
  20041. $scope.oldfromtype = false;
  20042. } else {
  20043. $scope.oldfromtype = true;
  20044. }
  20045. var result = {
  20046. model: {},
  20047. fields: [],
  20048. };
  20049. //设置模型实体数据 begin
  20050. // var mdata = vmForm.model;
  20051. //解析数据实体
  20052. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  20053. angular.extend(result.model, mdata);
  20054. if (modelWatch != null && modelWatch != "") {
  20055. //angular.extend(result.model.incident,modelWatch.incident);
  20056. //result.model.alarmType = modelWatch.alarmType;
  20057. // vmForm.cancelUrl = modelWatch.cancelUrl;
  20058. // console.log(modelWatch.cancelUrl)
  20059. for (var index in modelWatch.model) {
  20060. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  20061. if (result.model[index] != null) {
  20062. angular.extend(result.model[index], modelWatch.model[index]);
  20063. } else {
  20064. result.model[index] = modelWatch.model[index];
  20065. }
  20066. }
  20067. }
  20068. //设置模型实体数据 end
  20069. //解析设计数据生成表单项 begin
  20070. var fields = [];
  20071. //处理修改设计数据中展示设置
  20072. angular.forEach(vmForm.fields, function (fields) {
  20073. if (vmForm.formType == "1") {
  20074. angular.forEach(fields.fields, function (field) {
  20075. formfield(field, result);
  20076. });
  20077. } else {
  20078. formfield(fields, result);
  20079. }
  20080. // console.log(field);
  20081. result.fields.push(fields);
  20082. });
  20083. angular.extend($scope.vm.fields, result.fields);
  20084. angular.extend($scope.vm.model, result.model);
  20085. vm.model["loginUser"] = $rootScope.user;
  20086. //增加识别报修主体seimin
  20087. vm.model.repairType = $scope.repairMain.valueconfig;
  20088. if (vm.model.incident) {
  20089. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  20090. }
  20091. console.log(vm, "repairType"); //lmm
  20092. if (
  20093. modelWatch != null &&
  20094. modelWatch != "" &&
  20095. modelWatch.cancelUrl != null &&
  20096. modelWatch.cancelUrl != ""
  20097. ) {
  20098. vmForm.cancelUrl = modelWatch.cancelUrl;
  20099. }
  20100. $scope.formData = vmForm;
  20101. console.log($scope.formData, 4444444);
  20102. // console.log($scope.formData.url);
  20103. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  20104. if ($scope.formData.url == "start") {
  20105. $scope.Reset = true;
  20106. $scope.close = true;
  20107. $rootScope.isMask = false;
  20108. } else if ($scope.formData.url == "complete") {
  20109. $scope.Reset = false;
  20110. $scope.close = true;
  20111. }
  20112. //解析设计数据生成表单项 end
  20113. return result;
  20114. }
  20115. //======================处理表单设计数据 结束========================
  20116. $scope.ldloading = {};
  20117. function filter(obj) {
  20118. angular.forEach(obj, function (key, value) {
  20119. if (value === "" || value === null) {
  20120. delete obj[key];
  20121. } else if (
  20122. Object.prototype.toString.call(value) === "[object Object]"
  20123. ) {
  20124. filter(value);
  20125. } else if (angular.isArray(value)) {
  20126. angular.forEach(value, function (item) {
  20127. filter(item);
  20128. });
  20129. }
  20130. });
  20131. }
  20132. $scope.closeModel = function () {
  20133. // console.log($stateParams);
  20134. $state.go($scope.formData.cancelUrl, {});
  20135. event.preventDefault();
  20136. };
  20137. // console.log(vm);
  20138. // 暂存
  20139. $scope.save = function (data) {
  20140. console.log(vm);
  20141. if (vm.model.startSave) {
  20142. vm.model["initUser"] = $rootScope.user.id;
  20143. vm.model.start_code = "temporary";
  20144. //处理请求数据0327
  20145. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20146. delete data0327.repairType;
  20147. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20148. if (
  20149. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20150. .selecthouseNumber
  20151. ) {
  20152. data0327.incident.place = {
  20153. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  20154. .selecthouseNumber.id,
  20155. };
  20156. }
  20157. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  20158. if (response) {
  20159. var resData = Restangular.stripRestangular(response);
  20160. if (resData) {
  20161. if (
  20162. $scope.fileUploader != null &&
  20163. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  20164. resData.id
  20165. ) {
  20166. $scope.fileUploader.onBeforeUploadItem = function (item) {
  20167. angular.extend(item.headers, $rootScope.getSession());
  20168. item.url = api_bpm_domain
  20169. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  20170. .getRequestedUrl();
  20171. item.formData.push({
  20172. fileName: item.file.name,
  20173. });
  20174. //console.log();
  20175. };
  20176. $scope.fileUploader.uploadAll();
  20177. }
  20178. }
  20179. SweetAlert.swal(
  20180. {
  20181. title: "提交成功!",
  20182. type: "success",
  20183. confirmButtonColor: "#007AFF",
  20184. },
  20185. function () {
  20186. $state.go($scope.formData.cancelUrl);
  20187. }
  20188. );
  20189. } else {
  20190. SweetAlert.swal({
  20191. title: "系统错误",
  20192. text: "系统错误,请稍后重试!",
  20193. type: "error",
  20194. confirmButtonColor: "#DD6B55",
  20195. });
  20196. }
  20197. $scope.ldloading[style.replace("-", "_")] = false;
  20198. });
  20199. event.preventDefault();
  20200. } else if (vm.model.saveAgain) {
  20201. var toData = {
  20202. incident: vm.model.incident,
  20203. };
  20204. api_user_data.updData("incident", toData).then(function (response) {
  20205. if (response) {
  20206. var resData = Restangular.stripRestangular(response);
  20207. SweetAlert.swal(
  20208. {
  20209. title: "提交成功!",
  20210. type: "success",
  20211. confirmButtonColor: "#007AFF",
  20212. },
  20213. function () {
  20214. $state.go($scope.formData.cancelUrl);
  20215. }
  20216. );
  20217. } else {
  20218. SweetAlert.swal({
  20219. title: "系统错误",
  20220. text: "系统错误,请稍后重试!",
  20221. type: "error",
  20222. confirmButtonColor: "#DD6B55",
  20223. });
  20224. }
  20225. $scope.ldloading[style.replace("-", "_")] = false;
  20226. });
  20227. event.preventDefault();
  20228. } else {
  20229. SweetAlert.swal({
  20230. title: "系统错误",
  20231. text: "系统错误,请稍后重试!",
  20232. type: "error",
  20233. confirmButtonColor: "#DD6B55",
  20234. });
  20235. }
  20236. };
  20237. // 巡检生成事件
  20238. $scope.inspectionToIncident = function () {
  20239. var userData = {
  20240. idx: 0,
  20241. sum: 10,
  20242. requester: {
  20243. name: loginUser.name,
  20244. },
  20245. };
  20246. api_user_data.fetchDataList("requester", userData).then(function (res) {
  20247. console.log(res);
  20248. var toUser = {};
  20249. if (res.list.length > 0) {
  20250. toUser = res.list[0];
  20251. } else {
  20252. toUser = loginUser;
  20253. }
  20254. console.log(vm);
  20255. var incidentDescription = "";
  20256. console.log($stateParams.formUiEdit);
  20257. if ($stateParams.formUiEdit == "inspection_confirm") {
  20258. if (vm.model.wnCheckEnable) {
  20259. incidentDescription =
  20260. incidentDescription.concat(" 机房温度检查异常");
  20261. }
  20262. if (vm.model.sdCheckEnable) {
  20263. incidentDescription =
  20264. incidentDescription.concat(" 机房湿度检查异常");
  20265. }
  20266. if (vm.model.xfjCheckEnable) {
  20267. incidentDescription = incidentDescription.concat(" 新风机检查异常");
  20268. }
  20269. if (vm.model.lsCheckEnable) {
  20270. incidentDescription = incidentDescription.concat(" 漏水检查异常");
  20271. }
  20272. if (vm.model.xfCheckEnable) {
  20273. incidentDescription = incidentDescription.concat(" 消防检查异常");
  20274. }
  20275. if (vm.model.upsCheckEnable) {
  20276. incidentDescription =
  20277. incidentDescription.concat(" UPS供电检查异常");
  20278. }
  20279. if (vm.model.dcCheckEnable) {
  20280. incidentDescription =
  20281. incidentDescription.concat(" 电池连接检查异常");
  20282. }
  20283. if (vm.model.plCheckEnable) {
  20284. incidentDescription =
  20285. incidentDescription.concat(" 旁路供电检查异常");
  20286. }
  20287. if (vm.model.wjtdCheckEnable) {
  20288. incidentDescription =
  20289. incidentDescription.concat(" 外机通道检查异常");
  20290. }
  20291. if (vm.model.descriptionTextarea) {
  20292. incidentDescription = incidentDescription.concat(
  20293. " " + "备注:" + vm.model.descriptionTextarea
  20294. );
  20295. }
  20296. }
  20297. // console.log(incidentDescription)
  20298. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  20299. var formdata = {
  20300. model: {
  20301. // 'isInspection': true,
  20302. // 'start_code':'assignment',
  20303. // 'isHandlerUser':false,
  20304. incident: {
  20305. requester: bxr,
  20306. area: bxr.place.area,
  20307. place: bxr.place,
  20308. houseNumber: bxr.houseNumber,
  20309. contacts: bxr.name,
  20310. contactsInformation: bxr.mphone,
  20311. // 'category': data.wxIncidentClassifyDTO.category,
  20312. description: incidentDescription,
  20313. source: {
  20314. id: 1552,
  20315. },
  20316. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  20317. // 'sourceType': data.incident.sourceType,
  20318. // 'fileUrl': data.incident.fileUrl
  20319. },
  20320. // 'requestershow': toUser,//2020年4月27日22:29:15
  20321. // 'flow': data.incident.id
  20322. // 'assignee': loginUser.id//2020年4月27日22:29:25
  20323. },
  20324. };
  20325. // console.log(formdata,toUser,'1111');
  20326. console.log(formdata, "1111");
  20327. // return;
  20328. $state.go("app.incident.chart", {
  20329. model: JSON.stringify(formdata),
  20330. });
  20331. });
  20332. // var formdata = {
  20333. // model:$rootScope.login_requester
  20334. // };
  20335. // console.log(formdata,'00000')
  20336. // return;
  20337. // $state.go("app.incident.chart", {
  20338. // 'model': JSON.stringify(formdata)
  20339. // });
  20340. event.preventDefault();
  20341. };
  20342. // console.log(vm);
  20343. // 创建事件seimin
  20344. vm.submit = function (data, style) {
  20345. console.log(vm, 22222);
  20346. // return;
  20347. if (vm.model.handler_code == undefined) {
  20348. vm.model.handler_code = "resolve";
  20349. }
  20350. if (
  20351. vm.model.change &&
  20352. vm.model.change.requestingPerson &&
  20353. vm.model.change.requestingPerson.menu
  20354. ) {
  20355. delete vm.model.change.requestingPerson.menu;
  20356. }
  20357. // var pdKey = $stateParams.pdKey;
  20358. if (vm.form.$valid) {
  20359. if (data.incident && data.incident.synergetic) {
  20360. console.log(data.incident.synergetic);
  20361. var synergetic = [];
  20362. for (var i = 0; i < data.incident.synergetic.length; i++) {
  20363. synergetic.push({
  20364. id: data.incident.synergetic[i],
  20365. });
  20366. }
  20367. data.incident.synergetic = synergetic;
  20368. vm.model.incident.synergetic = synergetic;
  20369. }
  20370. $scope.ldloading[style.replace("-", "_")] = true;
  20371. var startsub = true;
  20372. if (pdKey == "bpm_incident") {
  20373. angular.forEach(vm.fields, function (item) {
  20374. angular.forEach(item.fields, function (index) {
  20375. if (index.templateOptions.required && !index.hide) {
  20376. if (index.model) {
  20377. if (
  20378. angular.isDefined(index.model[index.key]) &&
  20379. index.model[index.key] != null
  20380. ) {
  20381. if (
  20382. index.model[index.key].id &&
  20383. index.model[index.key].id == ""
  20384. ) {
  20385. startsub = false;
  20386. $scope.ldloading.expand_right = false;
  20387. SweetAlert.swal({
  20388. title: index.templateOptions.label + "未填",
  20389. text: "请填写此项!",
  20390. type: "error",
  20391. confirmButtonColor: "#DD6B55",
  20392. });
  20393. } else {
  20394. }
  20395. } else {
  20396. startsub = false;
  20397. $scope.ldloading.expand_right = false;
  20398. console.log(vm);
  20399. SweetAlert.swal({
  20400. title: index.templateOptions.label + "未填",
  20401. text: "请填写此项!",
  20402. type: "error",
  20403. confirmButtonColor: "#DD6B55",
  20404. });
  20405. }
  20406. } else {
  20407. if (
  20408. data[index.key] &&
  20409. data[index.key] != "" &&
  20410. data[index.key] != null
  20411. ) {
  20412. } else {
  20413. startsub = false;
  20414. $scope.ldloading.expand_right = false;
  20415. SweetAlert.swal({
  20416. title: index.templateOptions.label + "未填",
  20417. text: "请填写此项!",
  20418. type: "error",
  20419. confirmButtonColor: "#DD6B55",
  20420. });
  20421. }
  20422. }
  20423. }
  20424. });
  20425. });
  20426. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  20427. // startsub = false;
  20428. // $scope.ldloading.expand_right = false;
  20429. // SweetAlert.swal({
  20430. // title: '保修人未填',
  20431. // text: "请填写此项!",
  20432. // type: "error",
  20433. // confirmButtonColor: "#DD6B55"
  20434. // });
  20435. // }
  20436. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  20437. // } else {
  20438. // startsub = false;
  20439. // $scope.ldloading.expand_right = false;
  20440. // SweetAlert.swal({
  20441. // title: '事件分类未填',
  20442. // text: "请填写此项!",
  20443. // type: "error",
  20444. // confirmButtonColor: "#DD6B55"
  20445. // });
  20446. // }
  20447. }
  20448. if (startsub) {
  20449. $scope.ldloading[style.replace("-", "_")] = true;
  20450. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  20451. // console.log("vm.options:"+ JSON.stringify(vm.options));
  20452. vm.options.updateInitialValue();
  20453. // console.log("dfjkasdhfkhskjf ")
  20454. var _ = window._;
  20455. vm.model = (function filter(obj) {
  20456. var dateTransKeys = [];
  20457. var filtered = _.pick(obj, function (v, k, obj) {
  20458. if (_.isDate(v)) {
  20459. dateTransKeys.push(k);
  20460. }
  20461. return (
  20462. angular.isDefined(v) &&
  20463. v !== null &&
  20464. (angular.isArray(v) ? v.length > 0 : true) &&
  20465. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  20466. );
  20467. });
  20468. return _.cloneDeep(filtered, function (v, index, object) {
  20469. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  20470. angular.forEach(dateTransKeys, function (item) {
  20471. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  20472. });
  20473. dateTransKey = [];
  20474. return v;
  20475. }
  20476. return !_.isEmpty(filtered) &&
  20477. v !== filtered &&
  20478. _.isPlainObject(v)
  20479. ? filter(v)
  20480. : undefined;
  20481. });
  20482. })(vm.model);
  20483. if (pdKey != "") {
  20484. if ($scope.oprcode == "save") {
  20485. //保存
  20486. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  20487. if (response) {
  20488. var resData = Restangular.stripRestangular(response);
  20489. SweetAlert.swal(
  20490. {
  20491. title: "保存成功!",
  20492. confirmButtonColor: "#007AFF",
  20493. },
  20494. function () {
  20495. $state.go($scope.formData.cancelUri);
  20496. }
  20497. );
  20498. // if(resData.status){
  20499. // resData
  20500. // }
  20501. } else {
  20502. SweetAlert.swal({
  20503. title: "系统错误",
  20504. text: "系统错误,请稍后重试!",
  20505. type: "error",
  20506. confirmButtonColor: "#DD6B55",
  20507. });
  20508. }
  20509. $scope.ldloading[style.replace("-", "_")] = false;
  20510. });
  20511. } else {
  20512. console.log($scope.formData.url, "zzzz");
  20513. switch ($scope.formData.url) {
  20514. case "start":
  20515. vm.model["initUser"] = $rootScope.user.id;
  20516. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  20517. } else {
  20518. vm.model["assignee"] = $rootScope.user.id;
  20519. }
  20520. if (
  20521. vm.model["candidateGroups"] &&
  20522. vm.model.candidateGroups.id
  20523. ) {
  20524. vm.model.candidateGroups = vm.model.candidateGroups.id;
  20525. }
  20526. if (pdKey == "bpm_service_request") {
  20527. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  20528. angular.extend(vm.model.serviceCatalogueProcessActual, {
  20529. category: {
  20530. id: $stateParams.userId,
  20531. },
  20532. });
  20533. }
  20534. if (vm.model.schedule && vm.model.schedule.initUser) {
  20535. delete vm.model.schedule.initUser.menu;
  20536. }
  20537. if (
  20538. vm.model.isHandlerUser == "true" ||
  20539. vm.model.isHandlerUser == true
  20540. ) {
  20541. delete vm.model.candidateGroups;
  20542. }
  20543. if (vm.model.start_code == "close") {
  20544. // 直接处理
  20545. vm.model.incident.handlingPersonnelUser =
  20546. vm.model.incident.acceptUser;
  20547. delete vm.model.incident.handlerUser;
  20548. delete vm.model.candidateGroups;
  20549. } else if (vm.model.start_code == "assignment") {
  20550. // 派单
  20551. delete vm.model.incident.handlingPersonnelUser;
  20552. }
  20553. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  20554. $scope.jry_processInstanceId =
  20555. $stateParams.processInstanceId;
  20556. }
  20557. if ($scope.jry_processInstanceId) {
  20558. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  20559. }
  20560. //事件暂存判断
  20561. if (vm.model.saveAgain) {
  20562. if (
  20563. vm.model.directClose == "1" ||
  20564. vm.model.directClose == true
  20565. ) {
  20566. vm.model.start_code = "assignment";
  20567. vm.model.temporary_code = "assignment";
  20568. } else {
  20569. vm.model.start_code = "close";
  20570. vm.model.temporary_code = "close";
  20571. }
  20572. if (
  20573. vm.model.isHandlerUser == "true" ||
  20574. vm.model.isHandlerUser == true
  20575. ) {
  20576. delete vm.model.candidateGroups;
  20577. }
  20578. }
  20579. //处理请求数据0327
  20580. var data0327 = JSON.parse(JSON.stringify(vm.model));
  20581. delete data0327.repairType;
  20582. // 增加地点的请求参数2020年4月24日10:44:36
  20583. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  20584. // if($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber){
  20585. // data0327.incident.place = {
  20586. // id:$scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber.id
  20587. // }
  20588. // }
  20589. if (data0327.start_code == "close") {
  20590. data0327.incident.directProcess = 1;
  20591. }
  20592. console.log(vm);
  20593. api_bpm_domain
  20594. .start(pdKey, data0327)
  20595. .then(function (response) {
  20596. // console.log("response="+JSON.stringify(response));
  20597. if (response) {
  20598. var resData = Restangular.stripRestangular(response);
  20599. if (resData) {
  20600. if (resData) {
  20601. if (
  20602. $scope.fileUploader != null &&
  20603. $scope.fileUploader.getNotUploadedItems().length >
  20604. 0 &&
  20605. resData.id
  20606. ) {
  20607. $scope.fileUploader.onBeforeUploadItem =
  20608. function (item) {
  20609. angular.extend(
  20610. item.headers,
  20611. $rootScope.getSession()
  20612. );
  20613. item.url = api_bpm_domain
  20614. .uploadAttachment(
  20615. resData.id,
  20616. "00000",
  20617. $rootScope.user.id
  20618. )
  20619. .getRequestedUrl();
  20620. item.formData.push({
  20621. fileName: item.file.name,
  20622. });
  20623. //console.log();
  20624. };
  20625. $scope.fileUploader.uploadAll();
  20626. }
  20627. }
  20628. }
  20629. SweetAlert.swal(
  20630. {
  20631. title: "提交成功!",
  20632. type: "success",
  20633. confirmButtonColor: "#007AFF",
  20634. },
  20635. function () {
  20636. if (
  20637. vm.model.incident &&
  20638. vm.model.incident.callID &&
  20639. vm.model.incident.callID != ""
  20640. ) {
  20641. $rootScope.app.layout.isSidebarClosed = false;
  20642. if ($scope.login && !$rootScope.busy) {
  20643. $rootScope.setidle();
  20644. }
  20645. }
  20646. $state.go($scope.formData.cancelUrl);
  20647. }
  20648. );
  20649. } else {
  20650. SweetAlert.swal({
  20651. title: "系统错误",
  20652. text: "系统错误,请稍后重试!",
  20653. type: "error",
  20654. confirmButtonColor: "#DD6B55",
  20655. });
  20656. }
  20657. $scope.ldloading[style.replace("-", "_")] = false;
  20658. });
  20659. break;
  20660. case "complete":
  20661. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  20662. //console.log("complete taskId::"+$stateParams.taskId);
  20663. if (
  20664. $scope.formData.name == "transferform" &&
  20665. vm.model.ishandlers &&
  20666. !vm.model.incident.handlerUser
  20667. ) {
  20668. SweetAlert.swal({
  20669. title: "处理人未填",
  20670. text: "请填写此项!",
  20671. type: "error",
  20672. confirmButtonColor: "#DD6B55",
  20673. });
  20674. return;
  20675. }
  20676. api_bpm_domain
  20677. .complete($stateParams.taskId, userId, vm.model)
  20678. .then(function (response) {
  20679. if (response) {
  20680. var resData = Restangular.stripRestangular(response);
  20681. SweetAlert.swal(
  20682. {
  20683. title: "提交成功!",
  20684. type: "success",
  20685. confirmButtonColor: "#007AFF",
  20686. },
  20687. function () {
  20688. if (
  20689. $scope.fileUploader != null &&
  20690. $scope.fileUploader.getNotUploadedItems().length >
  20691. 0
  20692. ) {
  20693. console.log(vm);
  20694. if (vm.model.incident) {
  20695. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  20696. // angular.extend(item.headers, $rootScope.getSession());
  20697. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  20698. // item.formData.push({
  20699. // 'fileName': item.file.name
  20700. // });
  20701. // };
  20702. // $scope.fileUploader.uploadAll();
  20703. $scope.fileUploader.onBeforeUploadItem =
  20704. function (item) {
  20705. angular.extend(
  20706. item.headers,
  20707. $rootScope.getSession()
  20708. );
  20709. item.url = api_bpm_domain
  20710. .uploadAttachment(
  20711. vm.model.incident.processInstanceId,
  20712. "00000",
  20713. $rootScope.user.id
  20714. )
  20715. .getRequestedUrl();
  20716. item.formData.push({
  20717. fileName: item.file.name,
  20718. });
  20719. //console.log();
  20720. };
  20721. $scope.fileUploader.uploadAll();
  20722. } else if (vm.model.problem) {
  20723. $scope.fileUploader.onBeforeUploadItem =
  20724. function (item) {
  20725. angular.extend(
  20726. item.headers,
  20727. $rootScope.getSession()
  20728. );
  20729. item.url = api_bpm_domain
  20730. .uploadAttachmentJryModel(
  20731. "problem",
  20732. vm.model.problem.id,
  20733. "00000",
  20734. $rootScope.user.id
  20735. )
  20736. .getRequestedUrl();
  20737. item.formData.push({
  20738. fileName: item.file.name,
  20739. });
  20740. };
  20741. $scope.fileUploader.uploadAll();
  20742. } else if (vm.model.change) {
  20743. }
  20744. }
  20745. $state.go($scope.formData.cancelUrl);
  20746. }
  20747. );
  20748. } else {
  20749. SweetAlert.swal({
  20750. title: "系统错误",
  20751. text: "系统错误,请稍后重试!",
  20752. type: "error",
  20753. confirmButtonColor: "#DD6B55",
  20754. });
  20755. }
  20756. $scope.ldloading[style.replace("-", "_")] = false;
  20757. });
  20758. break;
  20759. case "back":
  20760. $state.go($scope.formData.cancelUrl);
  20761. break;
  20762. default:
  20763. $scope.ldloading[style.replace("-", "_")] = false;
  20764. break;
  20765. }
  20766. }
  20767. // var submitFunc = api_bpm_domain[$scope.formData.url]
  20768. // if(anuglar.isFunction(submitFunc)){
  20769. // submitFunc.apply(null, pdKey)
  20770. // }
  20771. }
  20772. }
  20773. } else {
  20774. // console.log(data)
  20775. // angular.forEach(vm.form.$error.required, function(item){
  20776. // var i=(item.$name).substring(item.$name.length-2)
  20777. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  20778. // for(var i=0;i<vm.fields.length;i++){
  20779. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  20780. SweetAlert.swal({
  20781. title: vm.fields[i].templateOptions.label + "未填",
  20782. text: "请填写此项!",
  20783. type: "error",
  20784. confirmButtonColor: "#DD6B55",
  20785. });
  20786. }
  20787. // }
  20788. // angular.forEach(vm.fields,function(f){
  20789. // if(f.name == item.$name){
  20790. // f.validation.show = true;
  20791. // SweetAlert.swal({
  20792. // title: f.templateOptions.label+'未填',
  20793. // text: "请填写此项!",
  20794. // type: "error",
  20795. // confirmButtonColor: "#DD6B55"
  20796. // });
  20797. // }
  20798. // });
  20799. // })
  20800. }
  20801. };
  20802. $scope.vm = vm;
  20803. console.log($stateParams, pdKey, 88888);
  20804. console.log($scope.vm, "assdfsdf");
  20805. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  20806. var processInstanceId = $stateParams.processInstanceId;
  20807. var itemId = $stateParams.dataId;
  20808. console.log($stateParams);
  20809. if (
  20810. angular.isDefined($stateParams.pdKey) &&
  20811. $stateParams.pdKey == "bpm_inspection"
  20812. ) {
  20813. api_configure_form
  20814. .renderForm(
  20815. $stateParams.formUiEdit,
  20816. userId,
  20817. processInstanceId,
  20818. itemId
  20819. )
  20820. .then(function (responseData) {
  20821. if (responseData) {
  20822. //console.log("responseData>>>");//console.log(responseData);
  20823. var vmForm = Restangular.stripRestangular(responseData);
  20824. if (vmForm) {
  20825. //console.log("vmForm>>>");//console.log(vmForm);
  20826. decodeVMForm(vmForm);
  20827. }
  20828. }
  20829. });
  20830. } else if (
  20831. angular.isDefined($stateParams.pdKey) &&
  20832. $stateParams.pdKey == "bpm_service_request"
  20833. ) {
  20834. api_configure_form
  20835. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  20836. .then(function (responseData) {
  20837. if (responseData) {
  20838. //console.log("responseData>>>");//console.log(responseData);
  20839. var vmForm = Restangular.stripRestangular(responseData);
  20840. if (vmForm) {
  20841. //console.log("vmForm>>>");//console.log(vmForm);
  20842. decodeVMForm(vmForm);
  20843. }
  20844. }
  20845. });
  20846. } else {
  20847. api_bpm_domain
  20848. .taskformkey($stateParams.taskId)
  20849. .then(function (response) {
  20850. if (response) {
  20851. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  20852. api_configure_form
  20853. .renderForm(myData.data, userId, processInstanceId, itemId)
  20854. .then(function (responseData) {
  20855. if (responseData) {
  20856. //console.log("responseData>>>");//console.log(responseData);
  20857. var vmForm = Restangular.stripRestangular(responseData);
  20858. if (vmForm) {
  20859. //console.log("vmForm>>>");//console.log(vmForm);
  20860. decodeVMForm(vmForm);
  20861. console.log(vmForm, 111111);
  20862. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  20863. console.log($scope, "今天"); //2020年4月24日11:40:55
  20864. }
  20865. }
  20866. });
  20867. }
  20868. });
  20869. }
  20870. } else {
  20871. // create process instance
  20872. if (pdKey != "") {
  20873. //for process
  20874. if (pdKey == "bpm_service_request") {
  20875. api_configure_form
  20876. .renderForm($stateParams.formUiStart, userId)
  20877. .then(function (responseData) {
  20878. if (responseData) {
  20879. var vmForm = Restangular.stripRestangular(responseData);
  20880. if (vmForm) {
  20881. decodeVMForm(vmForm);
  20882. }
  20883. }
  20884. });
  20885. } else {
  20886. api_bpm_domain.startformkey(pdKey).then(function (response) {
  20887. if (response) {
  20888. var myData = Restangular.stripRestangular(response);
  20889. //myData.data = "arrangeform";
  20890. api_configure_form
  20891. .renderForm(myData.data, userId)
  20892. .then(function (responseData) {
  20893. if (responseData) {
  20894. var vmForm = Restangular.stripRestangular(responseData);
  20895. if (vmForm) {
  20896. decodeVMForm(vmForm);
  20897. }
  20898. }
  20899. });
  20900. }
  20901. });
  20902. }
  20903. } else {
  20904. //for form
  20905. //TODO
  20906. //测试数据 开始
  20907. var testJson = {
  20908. fields: [
  20909. {
  20910. fields: [
  20911. {
  20912. className: "col-xs-12",
  20913. noFormControl: true,
  20914. key: "formtitle",
  20915. templateOptions: {
  20916. readOnly: false,
  20917. placeholder: "新建事件单",
  20918. hidden: false,
  20919. label: "事件工单",
  20920. required: false,
  20921. },
  20922. type: "ui-title",
  20923. },
  20924. ],
  20925. },
  20926. {
  20927. fields: [
  20928. {
  20929. key: "selectUser",
  20930. type: "ui-deptinformation",
  20931. className: "col-xs-12",
  20932. templateOptions: {
  20933. label: "请求人信息",
  20934. modalTitle: "请求人列表",
  20935. fetchItems: function (filterData, APIService) {
  20936. return APIService.fetchDataList("requester", filterData);
  20937. },
  20938. Restangular: Restangular,
  20939. ApiService: api_user_data,
  20940. // onClick:function(val, options, field, event , model){
  20941. // console.log(options);
  20942. // }
  20943. },
  20944. },
  20945. ],
  20946. },
  20947. {
  20948. fields: [
  20949. {
  20950. key: "first",
  20951. type: "ui-workernumber",
  20952. className: "col-xs-12",
  20953. templateOptions: {
  20954. type: "input",
  20955. label: "事件单号",
  20956. pkey: "name",
  20957. },
  20958. },
  20959. ],
  20960. },
  20961. {
  20962. fields: [
  20963. {
  20964. type: "ui-header",
  20965. key: "title",
  20966. className: "col-xs-12",
  20967. templateOptions: {
  20968. label: "报修人",
  20969. pkey: "change",
  20970. },
  20971. },
  20972. {
  20973. type: "ui-input",
  20974. key: "title",
  20975. className: "col-xs-4",
  20976. templateOptions: {
  20977. label: "报修人",
  20978. pkey: "change",
  20979. },
  20980. },
  20981. {
  20982. type: "ui-input",
  20983. key: "title",
  20984. className: "col-xs-4",
  20985. templateOptions: {
  20986. label: "联系人",
  20987. pkey: "change",
  20988. },
  20989. },
  20990. {
  20991. type: "ui-input",
  20992. key: "title",
  20993. className: "col-xs-4",
  20994. templateOptions: {
  20995. label: "联系电话",
  20996. pkey: "change",
  20997. },
  20998. },
  20999. ],
  21000. },
  21001. {
  21002. fields: [
  21003. {
  21004. type: "ui-header",
  21005. key: "title1",
  21006. className: "col-xs-12",
  21007. templateOptions: {
  21008. label: "报修人",
  21009. pkey: "change",
  21010. },
  21011. },
  21012. {
  21013. type: "ui-input",
  21014. key: "title2",
  21015. className: "col-xs-4",
  21016. templateOptions: {
  21017. label: "报修人",
  21018. pkey: "change",
  21019. },
  21020. },
  21021. {
  21022. type: "ui-input",
  21023. key: "title3",
  21024. className: "col-xs-4",
  21025. templateOptions: {
  21026. label: "联系人",
  21027. pkey: "change",
  21028. },
  21029. },
  21030. {
  21031. type: "ui-input",
  21032. key: "title4",
  21033. className: "col-xs-4",
  21034. templateOptions: {
  21035. label: "联系电话",
  21036. pkey: "change",
  21037. },
  21038. },
  21039. ],
  21040. },
  21041. ],
  21042. model: [
  21043. {
  21044. username: "robin lau",
  21045. password: "123456",
  21046. chkme: false,
  21047. start_code: 0,
  21048. formtitle: "Hey!I am title value!",
  21049. name: {
  21050. first: "robin",
  21051. last: "lau",
  21052. },
  21053. multiselectItem: [],
  21054. //date:"2015-09-15 00:00:00"
  21055. },
  21056. ],
  21057. // }
  21058. };
  21059. setTimeout(function () {
  21060. decodeVMForm(testJson);
  21061. $scope.$apply();
  21062. }, 500);
  21063. //测试数据结束
  21064. }
  21065. }
  21066. //console.log("end decode");
  21067. },
  21068. ]);