customformCtrl.js 851 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095
  1. var appFormly = angular.module("formlyExample", [
  2. "formly",
  3. "formlyBootstrap",
  4. "ui.bootstrap",
  5. "ngSanitize",
  6. "ui.select",
  7. "ui.grid",
  8. ]);
  9. app.requires.push("formlyExample");
  10. // var appFormly = angular.module('formlyExample', [
  11. // 'formly', 'formlyBootstrap','ui.bootstrap',
  12. // 'ngSanitize','ui.select','ui.grid'],
  13. // 图片上传
  14. app.factory("fileReader", [
  15. "$q",
  16. "$log",
  17. function ($q, $log) {
  18. var onLoad = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.resolve(reader.result);
  22. });
  23. };
  24. };
  25. var onError = function (reader, deferred, scope) {
  26. return function () {
  27. scope.$apply(function () {
  28. deferred.reject(reader.result);
  29. });
  30. };
  31. };
  32. var getReader = function (deferred, scope) {
  33. var reader = new FileReader(); //fileReader
  34. reader.onload = onLoad(reader, deferred, scope);
  35. reader.onerror = onError(reader, deferred, scope);
  36. return reader;
  37. };
  38. var readAsDataURL = function (file, scope) {
  39. var deferred = $q.defer();
  40. var reader = getReader(deferred, scope);
  41. reader.readAsDataURL(file);
  42. return deferred.promise;
  43. };
  44. return {
  45. readAsDataUrl: readAsDataURL,
  46. };
  47. },
  48. ]);
  49. appFormly.filter("minutesToHours", function () {
  50. //分钟转小时
  51. return function (num) {
  52. var hour = parseInt(num / 60);
  53. var minute = num % 60;
  54. return hour + "小时" + minute + "分钟";
  55. };
  56. });
  57. appFormly.config(function config(formlyConfigProvider) {
  58. //格式转换方法 XXX-XXX转驼峰命名
  59. function camelize(string) {
  60. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  61. return chr ? chr.toUpperCase() : "";
  62. });
  63. // Ensure 1st char is always lowercase
  64. return string.replace(/^([A-Z])/, function (match, chr) {
  65. return chr ? chr.toLowerCase() : "";
  66. });
  67. }
  68. //获取ngModelAttr对象设置
  69. function getNgModelAttr(attrs, bindings) {
  70. var ngModelAttrs = {};
  71. angular.forEach(attrs, function (attr) {
  72. ngModelAttrs[camelize(attr)] = {
  73. attribute: attr,
  74. };
  75. });
  76. angular.forEach(bindings, function (binding) {
  77. ngModelAttrs[camelize(binding)] = {
  78. bound: binding,
  79. };
  80. });
  81. return ngModelAttrs;
  82. }
  83. formlyConfigProvider.setWrapper({
  84. overwriteOk: true,
  85. name: "bootstrapLabel",
  86. templateUrl: "assets/views/customform/tpl/normal-label.html",
  87. });
  88. //流程图
  89. formlyConfigProvider.setType({
  90. name: "ui-process",
  91. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  92. defaultOptions: function (options) {
  93. return {
  94. templateOptions: {
  95. refresh: function () { },
  96. refreshDelay: 0,
  97. },
  98. };
  99. },
  100. controller: [
  101. "$scope",
  102. "$modal",
  103. "SweetAlert",
  104. "api_bpm_domain",
  105. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  106. $scope.processdata = [];
  107. api_bpm_domain
  108. .flowTracing($scope.model.applicationForm.processInstanceId)
  109. .then(function (data) {
  110. console.log(data);
  111. $scope.processdata = data.data;
  112. });
  113. },
  114. ],
  115. });
  116. //出库单详情
  117. formlyConfigProvider.setType({
  118. name: "ui-getoutinform",
  119. extends: "radio",
  120. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  121. defaultOptions: function (options) {
  122. return {
  123. templateOptions: {
  124. refresh: function () { },
  125. refreshDelay: 0,
  126. },
  127. };
  128. },
  129. controller: [
  130. "$scope",
  131. "$modal",
  132. "SweetAlert",
  133. "api_bpm_domain",
  134. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  135. if (
  136. angular.isDefined($scope.model.type.id) &&
  137. !$scope.model.type.name
  138. ) {
  139. if (($scope.model.type.id = 0)) {
  140. $scope.model.type.name = "新资产入库";
  141. } else if (($scope.model.type.id = 1)) {
  142. $scope.model.type.name = "新设备领用出库";
  143. } else if (($scope.model.type.id = 2)) {
  144. $scope.model.type.name = "资产归还";
  145. } else if (($scope.model.type.id = 4)) {
  146. $scope.model.type.name = "设备更换";
  147. }
  148. }
  149. },
  150. ],
  151. });
  152. //多选框组件
  153. formlyConfigProvider.setType({
  154. name: "ui-checkboxmore",
  155. extends: "radio",
  156. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  157. defaultOptions: function (options) {
  158. return {
  159. templateOptions: {
  160. refresh: function () { },
  161. refreshDelay: 0,
  162. },
  163. };
  164. },
  165. controller: [
  166. "$scope",
  167. "$modal",
  168. "SweetAlert",
  169. "api_bpm_domain",
  170. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  171. $scope.options.initialValue = $scope.model[$scope.options.key];
  172. },
  173. ],
  174. });
  175. //入库单详情
  176. formlyConfigProvider.setType({
  177. name: "ui-getininform",
  178. extends: "radio",
  179. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  180. defaultOptions: function (options) {
  181. return {
  182. templateOptions: {
  183. refresh: function () { },
  184. refreshDelay: 0,
  185. },
  186. };
  187. },
  188. controller: [
  189. "$scope",
  190. "$modal",
  191. "SweetAlert",
  192. "api_bpm_domain",
  193. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  194. if (
  195. angular.isDefined($scope.model.type.id) &&
  196. !$scope.model.type.name
  197. ) {
  198. if (($scope.model.type.id = 0)) {
  199. $scope.model.type.name = "新资产入库";
  200. } else if (($scope.model.type.id = 1)) {
  201. $scope.model.type.name = "新设备领用出库";
  202. } else if (($scope.model.type.id = 2)) {
  203. $scope.model.type.name = "资产归还";
  204. } else if (($scope.model.type.id = 4)) {
  205. $scope.model.type.name = "设备更换";
  206. }
  207. }
  208. },
  209. ],
  210. });
  211. //申请人详情
  212. formlyConfigProvider.setType({
  213. name: "ui-requsterinfom",
  214. extends: "radio",
  215. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  216. defaultOptions: function (options) {
  217. return {
  218. templateOptions: {
  219. refresh: function () { },
  220. refreshDelay: 0,
  221. },
  222. };
  223. },
  224. });
  225. //设备耗材list组件
  226. formlyConfigProvider.setType({
  227. name: "ui-uplodchange",
  228. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  229. defaultOptions: function (options) {
  230. return {
  231. templateOptions: {
  232. refresh: function () { },
  233. refreshDelay: 0,
  234. view: function (APIService, contentId) {
  235. return APIService.downloadAttachment(contentId);
  236. },
  237. },
  238. };
  239. },
  240. controller: [
  241. "$scope",
  242. "$filter",
  243. "ngTableParams",
  244. "$rootScope",
  245. "Restangular",
  246. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  247. // var data = { "haodata": [], "shedata": [] };
  248. var haodata = [];
  249. var shedata = [];
  250. if ($scope.model.consumables) {
  251. if (angular.isArray($scope.model.consumables)) {
  252. haodata = $scope.model.consumables;
  253. } else {
  254. haodata = JSON.parse($scope.model.consumables);
  255. }
  256. $scope.model.consumables = haodata;
  257. angular.forEach(haodata, function (item, index) {
  258. haodata[index].item = index + 1;
  259. });
  260. }
  261. if ($scope.model.assets) {
  262. if (angular.isArray($scope.model.assets)) {
  263. shedata = $scope.model.assets;
  264. } else {
  265. shedata = JSON.parse($scope.model.assets);
  266. }
  267. $scope.model.assets = shedata;
  268. angular.forEach(shedata, function (item, index) {
  269. shedata[index].item = index + 1;
  270. });
  271. }
  272. $scope.tableParamshao = new ngTableParams(
  273. {
  274. page: 1,
  275. count: 5,
  276. },
  277. {
  278. total: haodata.length,
  279. getData: function ($defer, params) {
  280. var orderedData = params.sorting()
  281. ? $filter("orderBy")(haodata, params.orderBy())
  282. : haodata;
  283. $defer.resolve(
  284. orderedData.slice(
  285. (params.page() - 1) * params.count(),
  286. params.page() * params.count()
  287. )
  288. );
  289. },
  290. }
  291. );
  292. $scope.tableParamsshe = new ngTableParams(
  293. {
  294. page: 1,
  295. count: 5,
  296. },
  297. {
  298. total: shedata.length,
  299. getData: function ($defer, params) {
  300. var orderedData = params.sorting()
  301. ? $filter("orderBy")(shedata, params.orderBy())
  302. : shedata;
  303. $defer.resolve(
  304. orderedData.slice(
  305. (params.page() - 1) * params.count(),
  306. params.page() * params.count()
  307. )
  308. );
  309. },
  310. }
  311. );
  312. $scope.editId = -1;
  313. $scope.setEditId = function (pid) {
  314. $scope.editId = pid;
  315. };
  316. if (angular.isUndefined($scope.form.dropState)) {
  317. $scope.form.dropState = false;
  318. }
  319. var to = $scope.options.templateOptions;
  320. var bindId = $scope.model.processInstanceId;
  321. //获取附件列表
  322. $scope.listAttachmen = function () {
  323. to.ApiService.listAttachment(
  324. to.listAttachmentUrl,
  325. to.bindType,
  326. bindId
  327. ).then(function (result) {
  328. var myData = Restangular.stripRestangular(result);
  329. // $scope.listAttachmens = myData;
  330. $scope.attachments = myData.data;
  331. });
  332. };
  333. $scope.listAttachmen();
  334. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  335. // $scope.listAttachmen();
  336. // } else if (to.bindType && $scope.model[to.bindType].id) {
  337. // $scope.listAttachmen();
  338. // }
  339. //附件下载
  340. $scope.download = function (token, filename) {
  341. var downUrl = to.ApiService.downloadAttachment(
  342. to.downUrl,
  343. token
  344. ).getRequestedUrl();
  345. // window.open(downUrl);
  346. var a = document.createElement("a");
  347. a.href = downUrl;
  348. a.target = "_blank";
  349. a.download = filename;
  350. document.body.appendChild(a);
  351. a.click();
  352. };
  353. //附件预览
  354. $scope.view = function (id, previewUrl) {
  355. if (previewUrl) {
  356. window.open(previewUrl);
  357. }
  358. };
  359. },
  360. ],
  361. });
  362. //多选框组件
  363. formlyConfigProvider.setType({
  364. name: "ui-nodataimage",
  365. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  366. defaultOptions: function (options) {
  367. return {
  368. templateOptions: {
  369. refresh: function () { },
  370. refreshDelay: 0,
  371. },
  372. };
  373. },
  374. });
  375. //ui-grid list
  376. formlyConfigProvider.setType({
  377. name: "ui-gridtwolist",
  378. // extends: 'input',
  379. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  380. defaultOptions: function (options, $scope) {
  381. return {
  382. templateOptions: {},
  383. };
  384. },
  385. controller: [
  386. "$scope",
  387. "$modal",
  388. "i18nService",
  389. "SweetAlert",
  390. function ($scope, $modal, i18nService, SweetAlert) {
  391. //gridone
  392. $scope.langs = i18nService.getAllLangs();
  393. $scope.lang = "zh-cn";
  394. i18nService.setCurrentLang($scope.lang);
  395. $scope.gridOptions = {};
  396. $scope.gridOptions.data = "myDatagrid";
  397. $scope.gridOptions.enableColumnResizing = true;
  398. $scope.gridOptions.enableFiltering = true;
  399. $scope.gridOptions.enableGridMenu = false;
  400. $scope.gridOptions.enableRowSelection = true;
  401. $scope.gridOptions.showGridFooter = true;
  402. $scope.gridOptions.showColumnFooter = false;
  403. $scope.gridOptions.fastWatch = true;
  404. $scope.gridOptions.useExternalFiltering = false;
  405. $scope.gridOptions.useExternalPagination = true;
  406. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  407. $scope.gridOptions.paginationPageSize = 10;
  408. $scope.gridOptions.multiSelect = false;
  409. $scope.myDatagrid = [];
  410. $scope.myDatagridall = [];
  411. $scope.selected = {
  412. item: {},
  413. };
  414. $scope.memoryfilterDatagrid = {
  415. idx: 0,
  416. sum: 10,
  417. };
  418. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  419. filterData = {
  420. idx: 0,
  421. sum: 10,
  422. };
  423. $scope.gridOptions.columnDefs =
  424. $scope.options.templateOptions.columnDefs;
  425. }
  426. $scope.gridOptions.rowIdentity = function (row) {
  427. return row.id;
  428. };
  429. $scope.gridOptions.getRowIdentity = function (row) {
  430. return row.id;
  431. };
  432. // $scope.gridOptions.columnDefs = items.columnDefs();
  433. $scope.interceptMydata = function (mydate, idx, sum) {
  434. return mydate.slice(idx * sum, (idx + 1) * sum);
  435. };
  436. $scope.gridOptions.onRegisterApi = function (gridApi) {
  437. $scope.gridApi = gridApi;
  438. gridApi.pagination.on.paginationChanged(
  439. $scope,
  440. function (newPage, pageSize) {
  441. $scope.memoryfilterDatagrid.idx = newPage - 1;
  442. $scope.memoryfilterDatagrid.sum = pageSize;
  443. $scope.myDatagrid = $scope.interceptMydata(
  444. $scope.myDatagridall,
  445. $scope.memoryfilterDatagrid.idx,
  446. 10
  447. );
  448. $scope.loadData({
  449. idx: newPage - 1,
  450. sum: pageSize,
  451. });
  452. }
  453. );
  454. gridApi.core.on.filterChanged($scope, function () { });
  455. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  456. $scope.selected.item = data.entity;
  457. //console.log(data);
  458. });
  459. };
  460. $scope.loadData = function (mydate, idx, sum) {
  461. angular.forEach($scope.myDatagrid, function (item, index) {
  462. $scope.myDatagrid[index].item = index;
  463. });
  464. $scope.gridOptions.totalItems = mydate.length;
  465. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  466. };
  467. if ($scope.model.assets) {
  468. $scope.myDatagridall = $scope.model.assets;
  469. $scope.loadData($scope.model.assets, 0, 10);
  470. }
  471. $scope.saveData = function (itemin) {
  472. event.preventDefault();
  473. var modalInstance = $modal.open({
  474. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  475. controller: function ($scope, $modalInstance, SweetAlert) {
  476. // $scope.consumptive = {};
  477. $scope.title = "填写领用设备信息";
  478. // if (items.name) {
  479. // $scope.consumptive.name = items.name.name;
  480. // }
  481. $scope.placechange = angular.copy(itemin);
  482. $scope.ok = function (item) {
  483. if (
  484. item.props &&
  485. item.props.hwnw_area &&
  486. item.props.hwnw_place &&
  487. item.props.hwnw_room &&
  488. item.props.hwnwswt_jiguihao &&
  489. item.props.hwnwswt_Ushu &&
  490. item.props.snnum
  491. ) {
  492. $modalInstance.close(item);
  493. } else {
  494. SweetAlert.swal({
  495. title: "数据填写不完整!",
  496. text: "请检查数据然后提交!",
  497. type: "error",
  498. });
  499. }
  500. };
  501. $scope.cancel = function () {
  502. $modalInstance.dismiss("cancel");
  503. };
  504. },
  505. resolve: {
  506. SweetAlert: function () {
  507. return SweetAlert;
  508. },
  509. },
  510. });
  511. modalInstance.result.then(function (selectedItem) {
  512. angular.forEach($scope.myDatagrid, function (item, index) {
  513. // $scope.myDatagrid[index].props.hw_state = "在线";
  514. if (item.id == selectedItem.id) {
  515. // $scope.myDatagrid[index] = selectedItem;
  516. angular.extend($scope.myDatagrid[index], selectedItem);
  517. }
  518. });
  519. // $scope.myData3.push(selectedItem);
  520. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  521. $scope.myDatagrid[i]["item"] =
  522. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  523. }
  524. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  525. $scope.myDatagridall;
  526. });
  527. };
  528. //gridtwo
  529. $scope.langs = i18nService.getAllLangs();
  530. $scope.lang = "zh-cn";
  531. i18nService.setCurrentLang($scope.lang);
  532. $scope.gridOptions2 = {};
  533. $scope.gridOptions2.data = "myDatagridold";
  534. $scope.gridOptions2.enableColumnResizing = true;
  535. $scope.gridOptions2.enableFiltering = true;
  536. $scope.gridOptions2.enableGridMenu = false;
  537. $scope.gridOptions2.enableRowSelection = true;
  538. $scope.gridOptions2.showGridFooter = true;
  539. $scope.gridOptions2.showColumnFooter = false;
  540. $scope.gridOptions2.fastWatch = true;
  541. $scope.gridOptions2.useExternalFiltering = false;
  542. $scope.gridOptions.useExternalPagination = true;
  543. $scope.gridOptions2.paginationPageSizes = [10];
  544. $scope.gridOptions2.paginationPageSize = 10;
  545. $scope.gridOptions2.multiSelect = false;
  546. $scope.myDatagridold = [];
  547. $scope.myDatagridoldall = [];
  548. $scope.selected = {
  549. item: {},
  550. };
  551. $scope.memoryfilterDatagridold = {
  552. idx: 0,
  553. sum: 10,
  554. };
  555. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  556. filterData = {
  557. idx: 0,
  558. sum: 10,
  559. };
  560. $scope.gridOptions2.columnDefs =
  561. $scope.options.templateOptions.columnDefstwo;
  562. }
  563. $scope.gridOptions2.rowIdentity = function (row) {
  564. return row.id;
  565. };
  566. $scope.gridOptions2.getRowIdentity = function (row) {
  567. return row.id;
  568. };
  569. // $scope.gridOptions.columnDefs = items.columnDefs();
  570. $scope.interceptMydata = function (mydate, idx, sum) {
  571. return mydate.slice(idx * sum, (idx + 1) * sum);
  572. };
  573. if ($scope.model.oldAssets) {
  574. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  575. $scope.myDatagridold = $scope.interceptMydata(
  576. $scope.myDatagridallold,
  577. $scope.memoryfilterDatagridold.idx,
  578. 10
  579. );
  580. }
  581. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  582. $scope.gridApi = gridApi;
  583. gridApi.pagination.on.paginationChanged(
  584. $scope,
  585. function (newPage, pageSize) {
  586. $scope.memoryfilterDatagridold.idx = newPage - 1;
  587. $scope.memoryfilterDatagridold.sum = pageSize;
  588. $scope.myDatagridold = $scope.interceptMydata(
  589. $scope.myDatagridallold,
  590. $scope.memoryfilterDatagridold.idx,
  591. 10
  592. );
  593. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  594. }
  595. );
  596. gridApi.core.on.filterChanged($scope, function () { });
  597. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  598. $scope.selected.item = data.entity;
  599. //console.log(data);
  600. });
  601. };
  602. // $scope.loadData = function(mydate, idx, sum) {
  603. // angular.forEach($scope.myDatagridold, function(item, index) {
  604. // $scope.myDatagridold[index].item = index;
  605. // })
  606. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  607. // }
  608. // if ($scope.model.assets) {
  609. // $scope.myDatagridallold = $scope.model.assets;
  610. // $scope.loadData($scope.model.assets, 0, 10)
  611. // }
  612. // $scope.addoldassets = function(itemin) {
  613. // event.preventDefault();
  614. // var modalInstance = $modal.open({
  615. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  616. // controller: function($scope, $modalInstance, SweetAlert) {
  617. // // $scope.consumptive = {};
  618. // $scope.title = "填写领用设备信息";
  619. // // if (items.name) {
  620. // // $scope.consumptive.name = items.name.name;
  621. // // }
  622. // $scope.placechange = itemin;
  623. // $scope.ok = function(item) {
  624. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  625. // $modalInstance.close(item);
  626. // } else {
  627. // SweetAlert.swal({
  628. // title: "数据填写不完整!",
  629. // text: "请检查数据然后提交!",
  630. // type: "error"
  631. // });
  632. // }
  633. // };
  634. // $scope.cancel = function() {
  635. // $modalInstance.dismiss('cancel');
  636. // };
  637. // },
  638. // resolve: {
  639. // SweetAlert: function() {
  640. // return SweetAlert;
  641. // }
  642. // }
  643. // });
  644. $scope.interceptMydata = function (mydate, idx, sum) {
  645. return mydate.slice(idx * sum, (idx + 1) * sum);
  646. };
  647. $scope.addshebei = function () {
  648. event.preventDefault();
  649. var modalInstance = $modal.open({
  650. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  651. controller: function (
  652. $scope,
  653. i18nService,
  654. $modalInstance,
  655. items,
  656. title,
  657. Restangular,
  658. APIService,
  659. onDataCallback,
  660. parentScope,
  661. api_configure_data,
  662. api_configure_form,
  663. api_cmdb
  664. ) {
  665. $scope.langs = i18nService.getAllLangs();
  666. $scope.lang = "zh-cn";
  667. i18nService.setCurrentLang($scope.lang);
  668. $scope.gridOptions = {};
  669. $scope.gridOptions.data = "myDatatwo";
  670. $scope.gridOptions.enableColumnResizing = true;
  671. $scope.gridOptions.enableFiltering = false;
  672. $scope.gridOptions.enableGridMenu = false;
  673. $scope.gridOptions.showGridFooter = true;
  674. $scope.gridOptions.showColumnFooter = false;
  675. $scope.gridOptions.fastWatch = true;
  676. $scope.gridOptions.useExternalFiltering = true;
  677. $scope.gridOptions.useExternalPagination = true;
  678. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  679. $scope.gridOptions.paginationPageSize = 10;
  680. $scope.gridOptions.multiSelect = true;
  681. $scope.gridOptions.rowIdentity = function (row) {
  682. return row.id;
  683. };
  684. $scope.gridOptions.getRowIdentity = function (row) {
  685. return row.id;
  686. };
  687. $scope.gridOptions.columnDefs = [
  688. {
  689. name: "item",
  690. displayName: "序号",
  691. width: 80,
  692. enableFiltering: false,
  693. },
  694. {
  695. name: "uuid",
  696. displayName: "内部编号",
  697. width: 150,
  698. },
  699. {
  700. name: "props.hw_mingcheng",
  701. displayName: "资产名称",
  702. width: 100,
  703. },
  704. {
  705. name: "props.hw_cifilterClassic",
  706. displayName: "资产类型",
  707. width: 120,
  708. enableFiltering: false,
  709. },
  710. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  711. {
  712. name: "props.hw_state",
  713. displayName: "资产状态",
  714. width: 150,
  715. enableFiltering: false,
  716. },
  717. {
  718. name: "props.hwnw_area",
  719. displayName: "资产地点",
  720. width: 130,
  721. enableFiltering: false,
  722. },
  723. {
  724. name: "createtime",
  725. displayName: "申请时间",
  726. enableFiltering: false,
  727. },
  728. ];
  729. // $scope.selectButtonClick
  730. var defaultFilterData = {
  731. // "assignee":2,
  732. // "applicationForm": { "hw_state": "在线" },
  733. hw_state: "在线",
  734. idx: 0,
  735. sum: 10,
  736. };
  737. $scope.memoryfilterData = {
  738. // "assignee":2,
  739. // "applicationForm": { "hw_state": "在线" },
  740. hw_state: "在线",
  741. idx: 0,
  742. sum: 10,
  743. };
  744. $scope.refreshData = function (style, filterData) {
  745. if (angular.isUndefined(filterData)) {
  746. filterData = defaultFilterData;
  747. }
  748. $scope.myDatatwo = [];
  749. // $scope.gridOptions['sum']=filterData.sum;
  750. api_cmdb.query(filterData).then(
  751. function (data) {
  752. // $scope.callsPending--;
  753. var myDatatwo = Restangular.stripRestangular(data);
  754. $scope.gridOptions["totalItems"] = data.total;
  755. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  756. myDatatwo.data.node[i].createtime = moment(
  757. myDatatwo.data.node[i].createtime
  758. ).format("YYYY-MM-DD");
  759. }
  760. $scope.myDatatwo = myDatatwo.data.node;
  761. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  762. $scope.myDatatwo[i]["item"] =
  763. i + 1 + filterData.idx * filterData.sum;
  764. }
  765. },
  766. function () { }
  767. );
  768. };
  769. $scope.refreshData("expand-right", defaultFilterData);
  770. $scope.gridOptions.onRegisterApi = function (gridApi) {
  771. $scope.gridApi = gridApi;
  772. gridApi.pagination.on.paginationChanged(
  773. $scope,
  774. function (newPage, pageSize) {
  775. var filtersData = $scope.memoryfilterData;
  776. filtersData.idx = newPage - 1;
  777. filtersData.sum = pageSize;
  778. // $scope.loadData(filtersData);
  779. $scope.refreshData("expand-right", filtersData);
  780. //console.log(pageSize);
  781. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  782. }
  783. );
  784. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  785. // $scope.selected.items.push(data.entity);
  786. //console.log(data);
  787. gridApi.selection.on.rowSelectionChanged(
  788. $scope,
  789. function (scope, ect) {
  790. if (scope.isSelected) {
  791. scope.grid.appScope.selected.items.push(scope.entity);
  792. } else {
  793. for (
  794. var i = 0;
  795. i <= scope.grid.appScope.selected.items.length;
  796. i++
  797. ) {
  798. if (
  799. scope.grid.appScope.selected.items[i].id ==
  800. scope.entity.id
  801. ) {
  802. scope.grid.appScope.selected.items.splice(i, 1);
  803. break;
  804. }
  805. }
  806. }
  807. $scope.mySelectedRows =
  808. $scope.gridApi.selection.getSelectedRows();
  809. }
  810. );
  811. // });
  812. gridApi.selection.on.rowSelectionChangedBatch(
  813. $scope,
  814. function (rows) {
  815. // $scope.selected.items = data.entity;
  816. //console.log(data);
  817. var selectitem = [];
  818. selectitem = angular.copy($scope.selected.items);
  819. for (var j = 0; j < rows.length; j++) {
  820. if (rows[j].isSelected == true) {
  821. selectitem.push(rows[j].entity);
  822. } else {
  823. delete selectitem[j];
  824. // rows.splice(j, 1);
  825. }
  826. }
  827. $scope.selected.items = [];
  828. for (var i = 0; i < selectitem.length; i++) {
  829. if (selectitem[i]) {
  830. $scope.selected.items.push(selectitem[i]);
  831. }
  832. }
  833. }
  834. );
  835. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  836. // // if (row.entity.age > 45) {
  837. // row.grid.api.selection.selectRow(row.entity); // 选中行
  838. // // }
  839. // };
  840. gridApi.core.on.filterChanged($scope, function () {
  841. var grid = this.grid;
  842. var filtersData = {
  843. idx: 0,
  844. sum: 10,
  845. user: {
  846. roledata: {
  847. rolecode: "roleset",
  848. },
  849. selectType: "1",
  850. },
  851. };
  852. angular.forEach(grid.columns, function (item) {
  853. if (item.enableFiltering) {
  854. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  855. if (
  856. angular.isDefined(item.filters[0].term) &&
  857. item.filters[0].term != ""
  858. ) {
  859. if (angular.isUndefined(filtersData["user"])) {
  860. filtersData["user"] = {};
  861. }
  862. filtersData["user"][item.field] = item.filters[0].term;
  863. }
  864. }
  865. });
  866. $scope.memoryfilterData = filtersData;
  867. // $scope.loadData(filtersData);
  868. });
  869. };
  870. $scope.onDblClick = function (data, event) {
  871. // $scope.selected.items = data.entity;
  872. $scope.selectButtonClick(data, event);
  873. };
  874. $scope.title = title;
  875. //树形图
  876. var apple_selected, tree, treedata_avm, treedata_geography;
  877. $scope.my_tree_handler = function (branch) {
  878. //var _ref;
  879. var classify = ($scope.classify =
  880. branch.prefix.toLowerCase() + branch.sign);
  881. api_cmdb
  882. .query({
  883. sign: classify,
  884. })
  885. .then(function (data) {
  886. var myDatalingbei = Restangular.stripRestangular(data);
  887. // console.log(myData.data.node);
  888. if (myDatalingbei.data && myDatalingbei.status == 200) {
  889. var ret = myDatalingbei.data;
  890. redrawSvg(myDatalingbei);
  891. }
  892. });
  893. };
  894. $scope.my_data = [];
  895. function convertListToTree(data, treeMap) {
  896. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  897. var root = null; //Initially set our loop to null
  898. var parentNode = null;
  899. //loop over data
  900. for (var i = 0; i < data.length; i++) {
  901. var datum = data[i];
  902. //each node will have children, so let's give it a "children" poperty
  903. datum.children = [];
  904. //add an entry for this node to the map so that any future children can
  905. //lookup the parent
  906. idToNodeMap[datum.id] = datum;
  907. //Does this node have a parent?
  908. if (
  909. typeof datum.parent === "undefined" ||
  910. datum.parent == null
  911. ) {
  912. //Doesn't look like it, so this node is the root of the tree
  913. root = datum;
  914. treeMap[datum.id] = root;
  915. } else {
  916. //This node has a parent, so let's look it up using the id
  917. parentNode = idToNodeMap[datum.parent.id];
  918. //We don't need this property, so let's delete it.
  919. delete datum.parent;
  920. //Let's add the current node as a child of the parent node.
  921. parentNode.children.push(datum);
  922. }
  923. }
  924. return root;
  925. }
  926. function convertParentToChildList(data) {
  927. var treeMap = {};
  928. var list = [];
  929. convertListToTree(data, treeMap);
  930. angular.forEach(treeMap, function (item) {
  931. list.push(item);
  932. });
  933. return list;
  934. }
  935. $scope.my_tree = tree = {};
  936. $scope.try_async_load = function () {
  937. $scope.my_data = [];
  938. $scope.select_treedata = [];
  939. $scope.doing_async = true;
  940. api_configure_data
  941. .fetchDataList("ciclassify", {
  942. idx: 0,
  943. sum: 100,
  944. })
  945. .then(function (result) {
  946. //console.log(result['list']);
  947. $scope.select_treedata = $scope.my_data =
  948. convertParentToChildList(result["list"]);
  949. $scope.doing_async = false;
  950. // tree.expand_all();
  951. //console.log(treelist);
  952. });
  953. };
  954. $scope.select_treedata = [];
  955. $scope.propTypeOptions = [];
  956. $scope.try_async_load();
  957. $scope.onFilterremove = function (item) {
  958. console.log(item);
  959. };
  960. $scope.searchdata = {};
  961. $scope.clear = function () {
  962. $scope.searchdata = {};
  963. $scope.cifilter_classic = {};
  964. $scope.try_async_load();
  965. var fildata = {
  966. idx: 0,
  967. sum: 10,
  968. hw_state: "在线",
  969. };
  970. $scope.memoryfilterData = fildata;
  971. $scope.refreshData("expand-right", fildata);
  972. };
  973. $scope.chiceIncident = function (item) {
  974. var fildata = $scope.memoryfilterData;
  975. // fildata.applicationForm = {};
  976. // if (item.alltitle && item.alldata) {
  977. // fildata.applicationForm[item.alltitle.key] = item.alldata
  978. // }
  979. if (item && item.id) {
  980. var classify = item.prefix.toLowerCase() + item.sign;
  981. fildata.sign = classify;
  982. }
  983. $scope.gridOptions.paginationCurrentPage = 1;
  984. var transitiondata = angular.copy(item);
  985. $scope.refreshData("expand-right", fildata);
  986. };
  987. $scope.applicadata = [];
  988. $scope.onFilterCallback = function (item) {
  989. var tempclassify = item.prefix.toLowerCase() + item.sign;
  990. api_configure_form
  991. .renderTabForm(tempclassify)
  992. .then(function (data) {
  993. var myData = Restangular.stripRestangular(data);
  994. $scope.applicadata = myData[0].form.fields;
  995. });
  996. // }
  997. };
  998. // $scope.loadData({
  999. // idx: 0,
  1000. // sum: 10,
  1001. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1002. // });
  1003. $scope.selected = {
  1004. items: [],
  1005. };
  1006. $scope.ok = function () {
  1007. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1008. // onDataCallback($scope.selected.item, parentScope);
  1009. // }
  1010. $modalInstance.close($scope.selected.items);
  1011. };
  1012. $scope.cancel = function () {
  1013. $modalInstance.dismiss("cancel");
  1014. };
  1015. },
  1016. size: "lg",
  1017. resolve: {
  1018. items: function () {
  1019. return {
  1020. fetchItems: function (filterData, APIService) {
  1021. filterData = filterData || {};
  1022. if (
  1023. angular.isDefined(filterData.idx) &&
  1024. filterData.idx == null
  1025. ) {
  1026. filterData = {
  1027. idx: 0,
  1028. sum: 10,
  1029. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1030. };
  1031. }
  1032. return $scope.options.templateOptions.fetchItems(
  1033. filterData,
  1034. APIService
  1035. );
  1036. },
  1037. };
  1038. },
  1039. title: function () {
  1040. return $scope.options.templateOptions.label;
  1041. },
  1042. Restangular: function () {
  1043. return $scope.options.templateOptions.Restangular;
  1044. },
  1045. APIService: function () {
  1046. return $scope.options.templateOptions.ApiService;
  1047. },
  1048. onDataCallback: function () {
  1049. return $scope.options.templateOptions.callback;
  1050. },
  1051. parentScope: function () {
  1052. return $scope.options.templateOptions.that;
  1053. },
  1054. },
  1055. });
  1056. modalInstance.result.then(function (selectedItem) {
  1057. $scope.myDatagridoldall = selectedItem;
  1058. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1059. $scope.myDatagridoldall[i]["item"] =
  1060. i +
  1061. 1 +
  1062. $scope.memoryfilterDatagridold.idx *
  1063. $scope.memoryfilterDatagridold.sum;
  1064. }
  1065. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1066. $scope.myDatagridold = $scope.interceptMydata(
  1067. $scope.myDatagridoldall,
  1068. 0,
  1069. 10
  1070. );
  1071. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1072. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1073. $scope.myDatagridoldall;
  1074. $scope.options.initialValue = $scope.model.oldAssets;
  1075. });
  1076. // }
  1077. };
  1078. $scope.changestate = function (itemin) {
  1079. event.preventDefault();
  1080. var modalInstance = $modal.open({
  1081. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1082. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1083. $scope.title = "旧设备状态修改";
  1084. $scope.stateshe = [
  1085. {
  1086. id: 2,
  1087. name: "在库",
  1088. },
  1089. {
  1090. id: 4,
  1091. name: "报修",
  1092. },
  1093. {
  1094. id: 3,
  1095. name: "报废",
  1096. },
  1097. ];
  1098. $scope.hw_state = {};
  1099. $scope.ok = function (item) {
  1100. $modalInstance.close(item.id);
  1101. };
  1102. $scope.cancel = function () {
  1103. $modalInstance.dismiss("cancel");
  1104. };
  1105. },
  1106. size: "sm",
  1107. resolve: {
  1108. scope: function () {
  1109. return $scope;
  1110. },
  1111. },
  1112. });
  1113. modalInstance.result.then(function (selectedItem) {
  1114. if (selectedItem) {
  1115. angular.forEach($scope.myDatagridallold, function (item, index) {
  1116. if (item.id == itemin.id) {
  1117. $scope.myDatagridallold[index].props.hw_state =
  1118. selectedItem.name;
  1119. }
  1120. });
  1121. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1122. $scope.myDatagridallold[i]["item"] =
  1123. i +
  1124. 1 +
  1125. $scope.memoryfilterDatagridold.idx *
  1126. $scope.memoryfilterDatagridold.sum;
  1127. }
  1128. $scope.gridOptions2["totalItems"] =
  1129. $scope.myDatagridallold.length;
  1130. $scope.myDatagridold = $scope.interceptMydata(
  1131. $scope.myDatagridallold,
  1132. $scope.memoryfilterDatagridold.idx,
  1133. $scope.memoryfilterDatagridold.sum
  1134. );
  1135. // $scope.model.oldAssets = $scope.myDatagridallold;
  1136. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1137. $scope.myDatagridallold;
  1138. $scope.options.initialValue = $scope.model.oldAssets;
  1139. }
  1140. });
  1141. };
  1142. $scope.savedata = function (data) {
  1143. event.preventDefault();
  1144. var modalInstance = $modal.open({
  1145. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1146. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1147. $scope.title = "设备编辑";
  1148. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1149. $scope.ok = function (item) {
  1150. $modalInstance.close(item);
  1151. };
  1152. $scope.cancel = function () {
  1153. $modalInstance.dismiss("cancel");
  1154. };
  1155. },
  1156. size: "sm",
  1157. resolve: {
  1158. scope: function () {
  1159. return $scope;
  1160. },
  1161. },
  1162. });
  1163. modalInstance.result.then(function (selectedItem) {
  1164. if (selectedItem) {
  1165. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1166. if (item.id == data.id) {
  1167. $scope.myDatagridoldall[index].olddecription =
  1168. selectedItem.olddecription;
  1169. }
  1170. });
  1171. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1172. $scope.myDatagridoldall[i]["item"] =
  1173. i +
  1174. 1 +
  1175. $scope.memoryfilterDatagridold.idx *
  1176. $scope.memoryfilterDatagridold.sum;
  1177. }
  1178. $scope.gridOptions2["totalItems"] =
  1179. $scope.myDatagridoldall.length;
  1180. $scope.myDatagridold = $scope.interceptMydata(
  1181. $scope.myDatagridoldall,
  1182. 0,
  1183. 10
  1184. );
  1185. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1186. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1187. $scope.myDatagridoldall;
  1188. $scope.options.initialValue = $scope.model.oldAssets;
  1189. }
  1190. });
  1191. };
  1192. $scope.removeold = function (data) {
  1193. event.preventDefault();
  1194. var modalInstance = $modal.open({
  1195. templateUrl: "assets/views/delete.html",
  1196. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1197. $scope.title = "设备删除";
  1198. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1199. $scope.ok = function () {
  1200. $modalInstance.close(data);
  1201. };
  1202. $scope.cancel = function () {
  1203. $modalInstance.dismiss("cancel");
  1204. };
  1205. },
  1206. size: "sm",
  1207. resolve: {
  1208. scope: function () {
  1209. return $scope;
  1210. },
  1211. },
  1212. });
  1213. modalInstance.result.then(function (selectedItem) {
  1214. if (selectedItem) {
  1215. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1216. if (item.id == selectedItem.id) {
  1217. $scope.myDatagridoldall.splice(index, 1);
  1218. }
  1219. });
  1220. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1221. $scope.myDatagridoldall[i]["item"] =
  1222. i +
  1223. 1 +
  1224. $scope.memoryfilterDatagridold.idx *
  1225. $scope.memoryfilterDatagridold.sum;
  1226. }
  1227. $scope.gridOptions2["totalItems"] =
  1228. $scope.myDatagridoldall.length;
  1229. $scope.myDatagridold = $scope.interceptMydata(
  1230. $scope.myDatagridoldall,
  1231. 0,
  1232. 10
  1233. );
  1234. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1235. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1236. $scope.myDatagridoldall;
  1237. $scope.options.initialValue = $scope.model.oldAssets;
  1238. }
  1239. });
  1240. };
  1241. },
  1242. ],
  1243. });
  1244. //ui-grid list
  1245. formlyConfigProvider.setType({
  1246. name: "ui-gridlist",
  1247. extends: "input",
  1248. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1249. defaultOptions: function (options, $scope) {
  1250. return {
  1251. templateOptions: {},
  1252. };
  1253. },
  1254. controller: [
  1255. "$scope",
  1256. "$modal",
  1257. "i18nService",
  1258. "SweetAlert",
  1259. function ($scope, $modal, i18nService, SweetAlert) {
  1260. //gridone
  1261. $scope.langs = i18nService.getAllLangs();
  1262. $scope.lang = "zh-cn";
  1263. i18nService.setCurrentLang($scope.lang);
  1264. $scope.gridOptions = {};
  1265. $scope.gridOptions.data = "myDatagrid";
  1266. $scope.gridOptions.enableColumnResizing = true;
  1267. $scope.gridOptions.enableFiltering = true;
  1268. $scope.gridOptions.enableGridMenu = false;
  1269. $scope.gridOptions.enableRowSelection = true;
  1270. $scope.gridOptions.showGridFooter = true;
  1271. $scope.gridOptions.showColumnFooter = false;
  1272. $scope.gridOptions.fastWatch = true;
  1273. $scope.gridOptions.useExternalFiltering = false;
  1274. // $scope.gridOptions.useExternalPagination = true;
  1275. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1276. $scope.gridOptions.paginationPageSize = 10;
  1277. $scope.gridOptions.multiSelect = false;
  1278. $scope.myDatagrid = [];
  1279. $scope.myDatagridall = [];
  1280. $scope.selected = {
  1281. item: {},
  1282. };
  1283. $scope.memoryfilterDatagrid = {
  1284. idx: 0,
  1285. sum: 10,
  1286. };
  1287. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1288. filterData = {
  1289. idx: 0,
  1290. sum: 10,
  1291. };
  1292. $scope.gridOptions.columnDefs =
  1293. $scope.options.templateOptions.columnDefs;
  1294. }
  1295. $scope.gridOptions.rowIdentity = function (row) {
  1296. return row.id;
  1297. };
  1298. $scope.gridOptions.getRowIdentity = function (row) {
  1299. return row.id;
  1300. };
  1301. // $scope.gridOptions.columnDefs = items.columnDefs();
  1302. $scope.interceptMydata = function (mydate, idx, sum) {
  1303. return mydate.slice(idx * sum, (idx + 1) * sum);
  1304. };
  1305. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1306. $scope.gridApi = gridApi;
  1307. gridApi.pagination.on.paginationChanged(
  1308. $scope,
  1309. function (newPage, pageSize) {
  1310. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1311. $scope.memoryfilterDatagrid.sum = pageSize;
  1312. $scope.myDatagrid = $scope.interceptMydata(
  1313. $scope.myDatagridall,
  1314. $scope.memoryfilterDatagrid.idx,
  1315. 10
  1316. );
  1317. $scope.loadData({
  1318. idx: newPage - 1,
  1319. sum: pageSize,
  1320. });
  1321. }
  1322. );
  1323. gridApi.core.on.filterChanged($scope, function () { });
  1324. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1325. $scope.selected.item = data.entity;
  1326. //console.log(data);
  1327. });
  1328. };
  1329. $scope.loadData = function (mydate, idx, sum) {
  1330. angular.forEach($scope.myDatagrid, function (item, index) {
  1331. $scope.myDatagrid[index].item = index;
  1332. });
  1333. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1334. };
  1335. if ($scope.model.assets) {
  1336. $scope.myDatagridall = $scope.model.assets;
  1337. $scope.loadData($scope.model.assets, 0, 10);
  1338. }
  1339. $scope.saveData = function (itemin) {
  1340. event.preventDefault();
  1341. var modalInstance = $modal.open({
  1342. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1343. controller: function ($scope, $modalInstance, SweetAlert) {
  1344. // $scope.consumptive = {};
  1345. $scope.title = "填写领用设备信息";
  1346. // if (items.name) {
  1347. // $scope.consumptive.name = items.name.name;
  1348. // }
  1349. $scope.placechange = angular.copy(itemin);
  1350. $scope.ok = function (item) {
  1351. if (
  1352. item.props &&
  1353. item.props.hwnw_area &&
  1354. item.props.hwnw_place &&
  1355. item.props.hwnw_room &&
  1356. item.props.hwnwswt_jiguihao &&
  1357. item.props.hwnwswt_Ushu &&
  1358. item.props.snnum
  1359. ) {
  1360. $modalInstance.close(item);
  1361. } else {
  1362. SweetAlert.swal({
  1363. title: "数据填写不完整!",
  1364. text: "请检查数据然后提交!",
  1365. type: "error",
  1366. });
  1367. }
  1368. };
  1369. $scope.cancel = function () {
  1370. $modalInstance.dismiss("cancel");
  1371. };
  1372. },
  1373. resolve: {
  1374. SweetAlert: function () {
  1375. return SweetAlert;
  1376. },
  1377. },
  1378. });
  1379. modalInstance.result.then(function (selectedItem) {
  1380. angular.forEach($scope.myDatagrid, function (item, index) {
  1381. if (item.id == selectedItem.id) {
  1382. angular.extend($scope.myDatagrid[index], selectedItem);
  1383. }
  1384. });
  1385. // $scope.myData3.push(selectedItem);
  1386. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1387. $scope.myDatagrid[i]["item"] =
  1388. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1389. }
  1390. // $scope.model.assets = $scope.myDatagridall;
  1391. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1392. $scope.myDatagridall;
  1393. });
  1394. };
  1395. },
  1396. ],
  1397. });
  1398. //设备耗材list组件
  1399. formlyConfigProvider.setType({
  1400. name: "ui-shehaolist",
  1401. // extends: 'radio',
  1402. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1403. defaultOptions: function (options) {
  1404. return {
  1405. templateOptions: {
  1406. refresh: function () { },
  1407. refreshDelay: 0,
  1408. },
  1409. };
  1410. },
  1411. controller: [
  1412. "$scope",
  1413. "$filter",
  1414. "ngTableParams",
  1415. function ($scope, $filter, ngTableParams) {
  1416. // var data = { "haodata": [], "shedata": [] };
  1417. var haodata = [];
  1418. var shedata = [];
  1419. if ($scope.model.consumables) {
  1420. if (angular.isArray($scope.model.consumables)) {
  1421. haodata = $scope.model.consumables;
  1422. } else {
  1423. haodata = JSON.parse($scope.model.consumables);
  1424. }
  1425. $scope.model.consumables = haodata;
  1426. angular.forEach(haodata, function (item, index) {
  1427. haodata[index].item = index + 1;
  1428. });
  1429. }
  1430. if ($scope.model.assets) {
  1431. if (angular.isArray($scope.model.assets)) {
  1432. shedata = $scope.model.assets;
  1433. } else {
  1434. shedata = JSON.parse($scope.model.assets);
  1435. }
  1436. $scope.model.assets = shedata;
  1437. angular.forEach(shedata, function (item, index) {
  1438. shedata[index].item = index + 1;
  1439. });
  1440. }
  1441. $scope.tableParamshao = new ngTableParams(
  1442. {
  1443. page: 1,
  1444. count: 5,
  1445. },
  1446. {
  1447. total: haodata.length,
  1448. getData: function ($defer, params) {
  1449. var orderedData = params.sorting()
  1450. ? $filter("orderBy")(haodata, params.orderBy())
  1451. : haodata;
  1452. $defer.resolve(
  1453. orderedData.slice(
  1454. (params.page() - 1) * params.count(),
  1455. params.page() * params.count()
  1456. )
  1457. );
  1458. },
  1459. }
  1460. );
  1461. $scope.tableParamsshe = new ngTableParams(
  1462. {
  1463. page: 1,
  1464. count: 5,
  1465. },
  1466. {
  1467. total: shedata.length,
  1468. getData: function ($defer, params) {
  1469. var orderedData = params.sorting()
  1470. ? $filter("orderBy")(shedata, params.orderBy())
  1471. : shedata;
  1472. $defer.resolve(
  1473. orderedData.slice(
  1474. (params.page() - 1) * params.count(),
  1475. params.page() * params.count()
  1476. )
  1477. );
  1478. },
  1479. }
  1480. );
  1481. $scope.editId = -1;
  1482. $scope.setEditId = function (pid) {
  1483. $scope.editId = pid;
  1484. };
  1485. if (
  1486. $scope.$parent.$parent.$parent.model.isAgree &&
  1487. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1488. ) {
  1489. $scope.isAgree = "同意";
  1490. } else if (
  1491. $scope.$parent.$parent.$parent.model.isAgree &&
  1492. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1493. ) {
  1494. $scope.isAgree = "同意";
  1495. } else if (
  1496. $scope.$parent.$parent.$parent.model.isAgree &&
  1497. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1498. ) {
  1499. $scope.isAgree = "返回修改";
  1500. }
  1501. },
  1502. ],
  1503. });
  1504. //关联资产出库
  1505. formlyConfigProvider.setType({
  1506. name: "ui-meansmodelselect",
  1507. extends: "input",
  1508. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1509. defaultOptions: function (options) {
  1510. return {
  1511. templateOptions: {},
  1512. };
  1513. },
  1514. controller: [
  1515. "$scope",
  1516. "$modal",
  1517. function ($scope, $modal) {
  1518. $scope.openModal = function (size, options, modal) {
  1519. var modalInstance = $modal.open({
  1520. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1521. controller: function (
  1522. $scope,
  1523. $rootScope,
  1524. $modalInstance,
  1525. items,
  1526. title,
  1527. Restangular,
  1528. APIService,
  1529. api_user_data,
  1530. i18nService,
  1531. api_wechatfile
  1532. ) {
  1533. $scope.langs = i18nService.getAllLangs();
  1534. $scope.lang = "zh-cn";
  1535. i18nService.setCurrentLang($scope.lang);
  1536. $scope.gridOptions = {};
  1537. $scope.gridOptions.data = "myData";
  1538. $scope.gridOptions.enableColumnResizing = true;
  1539. $scope.gridOptions.enableFiltering = false;
  1540. $scope.gridOptions.enableGridMenu = false;
  1541. $scope.gridOptions.showGridFooter = true;
  1542. $scope.gridOptions.showColumnFooter = false;
  1543. $scope.gridOptions.fastWatch = true;
  1544. $scope.gridOptions.useExternalFiltering = true;
  1545. $scope.gridOptions.useExternalPagination = true;
  1546. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1547. $scope.gridOptions.paginationPageSize = 10;
  1548. $scope.gridOptions.multiSelect = false;
  1549. $scope.gridOptions.rowIdentity = function (row) {
  1550. return row.id;
  1551. };
  1552. $scope.gridOptions.getRowIdentity = function (row) {
  1553. return row.id;
  1554. };
  1555. // $scope.states = [{
  1556. // id: 0,
  1557. // name: '待批准'
  1558. // },
  1559. // {
  1560. // id: 1,
  1561. // name: '已驳回'
  1562. // },
  1563. // {
  1564. // id: 2,
  1565. // name: '待出库'
  1566. // },
  1567. // {
  1568. // id: 3,
  1569. // name: '信息更新'
  1570. // },
  1571. // {
  1572. // id: 4,
  1573. // name: '信息确认'
  1574. // },
  1575. // {
  1576. // id: 5,
  1577. // name: '已关闭'
  1578. // }
  1579. // ];
  1580. $scope.getStatesDictionary = function () {
  1581. var data = {
  1582. key: "applicationForm_status",
  1583. type: "list",
  1584. };
  1585. api_wechatfile.getDictionary(data).then(function (res) {
  1586. $scope.states = res;
  1587. });
  1588. };
  1589. $scope.getStatesDictionary();
  1590. $scope.type = [
  1591. {
  1592. id: 1,
  1593. name: "资产入库",
  1594. },
  1595. {
  1596. id: 2,
  1597. name: "资产归还",
  1598. },
  1599. {
  1600. id: 3,
  1601. name: "资产领用",
  1602. },
  1603. {
  1604. id: 4,
  1605. name: "资产更换",
  1606. },
  1607. ];
  1608. $scope.typedata = function (row) {
  1609. if (row.type == 0) {
  1610. return "资产入库";
  1611. } else if (row.type == 2) {
  1612. return "资产归还";
  1613. } else if (row.type == 1) {
  1614. return "资产领用";
  1615. } else if (row.type == 4) {
  1616. return "资产更换";
  1617. }
  1618. };
  1619. $scope.statedata = function (row) {
  1620. if (row.status == 0) {
  1621. return "待批准";
  1622. } else if (row.status == 1) {
  1623. return "已驳回";
  1624. } else if (row.status == 2) {
  1625. return "待出库";
  1626. } else if (row.status == 3) {
  1627. return "信息更新";
  1628. } else if (row.status == 4) {
  1629. return "信息确认";
  1630. } else if (row.status == 5) {
  1631. return "已关闭";
  1632. }
  1633. };
  1634. $scope.transferTime = function (time) {
  1635. return moment(time).format("YYYY-MM-DD HH:mm");
  1636. };
  1637. $scope.application = [
  1638. {
  1639. value: "serialNumbe",
  1640. name: "申请单编号",
  1641. },
  1642. // { value: "proposer", name: '申请人' },
  1643. {
  1644. value: "purpose",
  1645. name: "领用用途",
  1646. },
  1647. // { value: "cmdbsign", name: '设备编号' }
  1648. ];
  1649. $scope.parameters = null;
  1650. $scope.open = function ($event) {
  1651. $event.preventDefault();
  1652. $event.stopPropagation();
  1653. $scope.opened = !$scope.opened;
  1654. };
  1655. $scope.endOpen = function ($event) {
  1656. $event.preventDefault();
  1657. $event.stopPropagation();
  1658. $scope.startOpened = false;
  1659. $scope.endOpened = !$scope.endOpened;
  1660. };
  1661. $scope.startOpen = function ($event) {
  1662. $event.preventDefault();
  1663. $event.stopPropagation();
  1664. $scope.endOpened = false;
  1665. $scope.startOpened = !$scope.startOpened;
  1666. };
  1667. $scope.othcode = {};
  1668. $scope.searchkeys = {};
  1669. $scope.parameters = {};
  1670. $scope.memoryfilterData = {
  1671. assignee: $rootScope.user.id,
  1672. candidateGroups: $rootScope.user.group[0].id,
  1673. searchType: "todo",
  1674. idx: 0,
  1675. sum: 10,
  1676. };
  1677. $scope.clear = function () {
  1678. $scope.searchkeys = {};
  1679. // $scope.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. $scope.memoryfilterData = fildata;
  1689. $scope.loadData(fildata);
  1690. };
  1691. $scope.chiceIncident = function (parameters, item, stateid) {
  1692. var fildata = {
  1693. assignee: $rootScope.user.id,
  1694. candidateGroups: 1,
  1695. searchType: "todo",
  1696. idx: 0,
  1697. sum: 10,
  1698. };
  1699. if (item) {
  1700. fildata.applicationForm = {};
  1701. if (item.alltitle && item.alldata) {
  1702. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1703. }
  1704. if (item.linkProposer) {
  1705. fildata.applicationForm.linkProposer = item.linkProposer;
  1706. }
  1707. if (item.proposer) {
  1708. fildata.applicationForm.proposer = item.proposer;
  1709. }
  1710. if (item.status) {
  1711. fildata.applicationForm["status"] = {
  1712. id: item.status.id,
  1713. };
  1714. }
  1715. if (item.type) {
  1716. fildata.applicationForm["type"] = {
  1717. id: item.type.id,
  1718. };
  1719. }
  1720. }
  1721. $scope.gridOptions.paginationCurrentPage = 1;
  1722. if (
  1723. parameters &&
  1724. parameters.paramDateFrom &&
  1725. parameters.paramDateTo
  1726. ) {
  1727. angular.extend(fildata, {
  1728. idx: 0,
  1729. sum: $scope.gridOptions.paginationPageSize,
  1730. });
  1731. angular.extend(fildata.applicationForm, {
  1732. startDate: moment(parameters.paramDateFrom).format(
  1733. "YYYY-MM-DD HH:mm:ss"
  1734. ),
  1735. endDate: moment(parameters.paramDateTo).format(
  1736. "YYYY-MM-DD 23:59:59"
  1737. ),
  1738. });
  1739. }
  1740. var transitiondata = angular.copy(item);
  1741. // angular.extend(fildata.applicationForm, transitiondata)
  1742. $scope.loadData(fildata);
  1743. };
  1744. $scope.key = {};
  1745. api_user_data
  1746. .fetchDataList("user", {
  1747. idx: 0,
  1748. sum: 1000,
  1749. flag: -1,
  1750. })
  1751. .then(function (data) {
  1752. $scope.handlingPersonnelUser = data.list;
  1753. });
  1754. $scope.gridOptions.columnDefs = items.columnDefs();
  1755. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1756. $scope.gridApi = gridApi;
  1757. gridApi.pagination.on.paginationChanged(
  1758. $scope,
  1759. function (newPage, pageSize) {
  1760. // console.log(newPage);
  1761. // console.log(pageSize);
  1762. $scope.loadData({
  1763. idx: newPage - 1,
  1764. sum: pageSize,
  1765. });
  1766. }
  1767. );
  1768. gridApi.core.on.filterChanged($scope, function () { });
  1769. gridApi.selection.on.rowSelectionChanged(
  1770. $scope,
  1771. function (data) {
  1772. $scope.selected.item = data.entity;
  1773. //console.log(data);
  1774. }
  1775. );
  1776. };
  1777. $scope.loadData = function (filterData) {
  1778. items.fetchItems(filterData, APIService).then(function (data) {
  1779. var myData = Restangular.stripRestangular(data);
  1780. $scope.gridOptions.totalItems = myData.totalNum;
  1781. $scope.myData = myData.list;
  1782. for (var i = 0; i < $scope.myData.length; i++) {
  1783. $scope.myData[i]["item"] =
  1784. i + 1 + filterData.idx * filterData.sum;
  1785. }
  1786. });
  1787. };
  1788. $scope.title = title;
  1789. $scope.loadData({
  1790. idx: 0,
  1791. sum: 10,
  1792. assignee: $rootScope.user.id,
  1793. candidateGroups: $rootScope.user.group[0].id,
  1794. searchType: "todo",
  1795. });
  1796. $scope.selected = {
  1797. item: {},
  1798. };
  1799. $scope.ok = function () {
  1800. //console.log($scope.selected.item);
  1801. $modalInstance.close($scope.selected.item);
  1802. };
  1803. $scope.cancel = function () {
  1804. $modalInstance.dismiss("cancel");
  1805. };
  1806. },
  1807. size: "lg",
  1808. resolve: {
  1809. items: function () {
  1810. return {
  1811. fetchItems: function (filterData, APIService) {
  1812. filterData = filterData || {};
  1813. // if(!filterData.idx){
  1814. if (
  1815. angular.isDefined(filterData.idx) &&
  1816. filterData.idx == null
  1817. ) {
  1818. filterData = {
  1819. idx: 0,
  1820. sum: 10,
  1821. };
  1822. }
  1823. return options.templateOptions.fetchItems(
  1824. filterData,
  1825. APIService,
  1826. options
  1827. );
  1828. },
  1829. columnDefs: function () {
  1830. return options.templateOptions.columnDefs;
  1831. },
  1832. };
  1833. },
  1834. title: function () {
  1835. return options.templateOptions.modalTitle;
  1836. },
  1837. Restangular: function () {
  1838. return options.templateOptions.Restangular;
  1839. },
  1840. APIService: function () {
  1841. return options.templateOptions.ApiService;
  1842. },
  1843. },
  1844. });
  1845. modalInstance.result.then(
  1846. function (selectedItem) {
  1847. var selectitem = {
  1848. title: selectedItem.title,
  1849. description: selectedItem.description,
  1850. };
  1851. if (options.key == "chuku") {
  1852. if (selectedItem.assets) {
  1853. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1854. selectedItem.assets;
  1855. }
  1856. if (selectedItem.consumables) {
  1857. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1858. selectedItem.consumables;
  1859. }
  1860. angular.extend(
  1861. $scope.$parent.$parent.$parent.model,
  1862. selectitem
  1863. );
  1864. options.value(selectedItem);
  1865. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1866. } else {
  1867. angular.extend(options.model, selectitem);
  1868. options.value(selectedItem);
  1869. }
  1870. },
  1871. function () {
  1872. //console.log('Modal dismissed at: ' + new Date());
  1873. }
  1874. );
  1875. };
  1876. },
  1877. ],
  1878. });
  1879. //文本框
  1880. formlyConfigProvider.setType({
  1881. name: "ui-textcmdb",
  1882. extends: "",
  1883. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1884. defaultOptions: function (options) {
  1885. return {
  1886. templateOptions: {
  1887. transform: function (model, value) {
  1888. return value;
  1889. },
  1890. },
  1891. validation: {
  1892. messages: {
  1893. maxlength: function (viewValue, modelValue, scope) {
  1894. if (viewValue != null) {
  1895. if (viewValue.length > scope.to.maxlength) {
  1896. return (
  1897. scope.to.label +
  1898. " 字数(" +
  1899. viewValue.length +
  1900. ")超限(" +
  1901. scope.to.maxlength +
  1902. ")"
  1903. );
  1904. } else {
  1905. return "";
  1906. }
  1907. }
  1908. },
  1909. },
  1910. },
  1911. };
  1912. },
  1913. controller: [
  1914. "$scope",
  1915. function ($scope) {
  1916. var value = $scope.model[$scope.options.key];
  1917. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1918. $scope.model[$scope.options.key] =
  1919. $scope.options.templateOptions.transform(
  1920. $scope.originalModel,
  1921. value
  1922. );
  1923. }
  1924. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1925. $scope.options.templateOptions.felditem($scope);
  1926. }
  1927. },
  1928. ],
  1929. });
  1930. //设备组件
  1931. formlyConfigProvider.setType({
  1932. name: "ui-applist",
  1933. extends: "radio",
  1934. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1935. defaultOptions: function (options) {
  1936. return {
  1937. templateOptions: {
  1938. refresh: function () { },
  1939. refreshDelay: 0,
  1940. },
  1941. };
  1942. },
  1943. controller: [
  1944. "$scope",
  1945. "$filter",
  1946. "ngTableParams",
  1947. function ($scope, $filter, ngTableParams) {
  1948. var data = [];
  1949. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1950. // data = JSON.parse($scope.model.consumables);
  1951. if (angular.isArray($scope.model.consumables)) {
  1952. data = $scope.model.consumables;
  1953. } else {
  1954. data = JSON.parse($scope.model.consumables);
  1955. }
  1956. $scope.model.consumables = data;
  1957. angular.forEach(data, function (item, index) {
  1958. data[index].item = index + 1;
  1959. });
  1960. }
  1961. if ($scope.model.assets && $scope.options.key == "assets") {
  1962. if (angular.isArray($scope.model.assets)) {
  1963. data = $scope.model.assets;
  1964. } else {
  1965. data = JSON.parse($scope.model.assets);
  1966. }
  1967. // data = JSON.parse($scope.model.assets);
  1968. $scope.model.assets = data;
  1969. angular.forEach(data, function (item, index) {
  1970. data[index].item = index + 1;
  1971. });
  1972. }
  1973. $scope.tableParams = new ngTableParams(
  1974. {
  1975. page: 1,
  1976. count: 5,
  1977. },
  1978. {
  1979. total: data.length,
  1980. getData: function ($defer, params) {
  1981. var orderedData = params.sorting()
  1982. ? $filter("orderBy")(data, params.orderBy())
  1983. : data;
  1984. $defer.resolve(
  1985. orderedData.slice(
  1986. (params.page() - 1) * params.count(),
  1987. params.page() * params.count()
  1988. )
  1989. );
  1990. },
  1991. }
  1992. );
  1993. $scope.editId = -1;
  1994. $scope.setEditId = function (pid) {
  1995. $scope.editId = pid;
  1996. };
  1997. },
  1998. ],
  1999. });
  2000. //list组件
  2001. formlyConfigProvider.setType({
  2002. name: "ui-gudinglist",
  2003. extends: "radio",
  2004. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2005. defaultOptions: function (options) {
  2006. return {
  2007. templateOptions: {
  2008. refresh: function () { },
  2009. refreshDelay: 0,
  2010. },
  2011. };
  2012. },
  2013. controller: [
  2014. "$scope",
  2015. "$filter",
  2016. "ngTableParams",
  2017. function ($scope, $filter, ngTableParams) {
  2018. var data = [];
  2019. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2020. // data = JSON.parse($scope.model.consumables);
  2021. if (angular.isArray($scope.model.consumables)) {
  2022. data = $scope.model.consumables;
  2023. } else {
  2024. data = JSON.parse($scope.model.consumables);
  2025. }
  2026. $scope.model.consumables = data;
  2027. angular.forEach(data, function (item, index) {
  2028. data[index].item = index + 1;
  2029. });
  2030. }
  2031. if ($scope.model.assets && $scope.options.key == "assets") {
  2032. if (angular.isArray($scope.model.assets)) {
  2033. data = $scope.model.assets;
  2034. } else {
  2035. data = JSON.parse($scope.model.assets);
  2036. }
  2037. // data = JSON.parse($scope.model.assets);
  2038. $scope.model.assets = data;
  2039. angular.forEach(data, function (item, index) {
  2040. data[index].item = index + 1;
  2041. });
  2042. }
  2043. $scope.tableParams = new ngTableParams(
  2044. {
  2045. page: 1,
  2046. count: 5,
  2047. },
  2048. {
  2049. total: data.length,
  2050. getData: function ($defer, params) {
  2051. var orderedData = params.sorting()
  2052. ? $filter("orderBy")(data, params.orderBy())
  2053. : data;
  2054. $defer.resolve(
  2055. orderedData.slice(
  2056. (params.page() - 1) * params.count(),
  2057. params.page() * params.count()
  2058. )
  2059. );
  2060. },
  2061. }
  2062. );
  2063. $scope.editId = -1;
  2064. $scope.setEditId = function (pid) {
  2065. $scope.editId = pid;
  2066. };
  2067. },
  2068. ],
  2069. });
  2070. //other list tab组件
  2071. formlyConfigProvider.setType({
  2072. name: "ui-otherlisttab",
  2073. extends: "",
  2074. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2075. defaultOptions: function (options) {
  2076. return {
  2077. templateOptions: {
  2078. refresh: function () { },
  2079. refreshDelay: 0,
  2080. },
  2081. };
  2082. },
  2083. controller: [
  2084. "$scope",
  2085. "$filter",
  2086. "ngTableParams",
  2087. function ($scope, $filter, ngTableParams) { },
  2088. ],
  2089. });
  2090. //审核查看组件
  2091. formlyConfigProvider.setType({
  2092. name: "ui-aprovelist",
  2093. extends: "",
  2094. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2095. defaultOptions: function (options) {
  2096. return {
  2097. templateOptions: {
  2098. refresh: function () { },
  2099. refreshDelay: 0,
  2100. },
  2101. };
  2102. },
  2103. controller: [
  2104. "$scope",
  2105. "$filter",
  2106. "ngTableParams",
  2107. function ($scope, $filter, ngTableParams) {
  2108. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2109. $scope.isAgree = "同意";
  2110. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2111. $scope.isAgree = "同意";
  2112. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2113. $scope.isAgree = "返回修改";
  2114. }
  2115. },
  2116. ],
  2117. });
  2118. //other list组件
  2119. formlyConfigProvider.setType({
  2120. name: "ui-otherlist",
  2121. extends: "",
  2122. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2123. defaultOptions: function (options) {
  2124. return {
  2125. templateOptions: {
  2126. refresh: function () { },
  2127. refreshDelay: 0,
  2128. },
  2129. };
  2130. },
  2131. controller: [
  2132. "$rootScope",
  2133. "$scope",
  2134. "$parse",
  2135. "$injector",
  2136. "$http",
  2137. "$q",
  2138. "$state",
  2139. "$stateParams",
  2140. "$modal",
  2141. "$timeout",
  2142. "$interval",
  2143. "i18nService",
  2144. "SweetAlert",
  2145. "FileUploader",
  2146. "Restangular",
  2147. "UserRestangular",
  2148. "BpmRestangular",
  2149. "api_configure_form",
  2150. "api_configure_data",
  2151. "api_bpm_domain",
  2152. "api_bpm_data",
  2153. "api_user_data",
  2154. "api_cmdb",
  2155. "api_sysinfo",
  2156. function (
  2157. $rootScope,
  2158. $scope,
  2159. $parse,
  2160. $injector,
  2161. $http,
  2162. $q,
  2163. $state,
  2164. $stateParams,
  2165. $modal,
  2166. $timeout,
  2167. $interval,
  2168. i18nService,
  2169. SweetAlert,
  2170. FileUploader,
  2171. Restangular,
  2172. UserRestangular,
  2173. BpmRestangular,
  2174. api_configure_form,
  2175. api_configure_data,
  2176. api_bpm_domain,
  2177. api_bpm_data,
  2178. api_user_data,
  2179. api_cmdb,
  2180. api_sysinfo
  2181. ) {
  2182. console.log("哈哈");
  2183. console.log($scope);
  2184. $scope.langs = i18nService.getAllLangs();
  2185. $scope.lang = "zh-cn";
  2186. i18nService.setCurrentLang($scope.lang);
  2187. var vm = this;
  2188. vm.options = {};
  2189. vm.exampleTitle = ["expressionProperties", "model property"];
  2190. vm.fields = [];
  2191. vm.models = {};
  2192. // vm.models["loginUser"] = $rootScope.user;
  2193. var that = $injector;
  2194. var parse = $parse;
  2195. var formKey = "";
  2196. var pdKey = "";
  2197. if (
  2198. angular.isDefined($state.current.pdKey) &&
  2199. $state.current.pdKey != ""
  2200. ) {
  2201. pdKey = $state.current.pdKey;
  2202. //console.log("pdKey::"+$state.current.pdKey);
  2203. }
  2204. if (
  2205. angular.isDefined($stateParams.formKey) &&
  2206. $stateParams.formKey != ""
  2207. ) {
  2208. formKey = $stateParams.formKey;
  2209. //console.log("formKey::"+$stateParams.formKey);
  2210. }
  2211. //用户测试数据,后续从header的auth中获取
  2212. var userId = 2;
  2213. userId = $rootScope.user.id;
  2214. //==============处理表单设计数据 开始====================
  2215. //处理组件加载后台数据选项的方法
  2216. function refreshSelectOptions(searchVal, field) {
  2217. if (field.templateOptions.optionsUrl) {
  2218. var process = BpmRestangular.all("");
  2219. if (field.templateOptions.ApiService) {
  2220. process = UserRestangular.all("");
  2221. }
  2222. process
  2223. .customPOST(
  2224. {
  2225. idx: 0,
  2226. sum: 1000,
  2227. },
  2228. field.templateOptions.optionsUrl
  2229. )
  2230. .then(function (result) {
  2231. if (!field.templateOptions.options) {
  2232. field.templateOptions.options = [];
  2233. }
  2234. if (field.templateOptions.optionsDataKey) {
  2235. field.templateOptions.options =
  2236. result[field.templateOptions.optionsDataKey];
  2237. } else {
  2238. field.templateOptions.options = result;
  2239. }
  2240. });
  2241. }
  2242. }
  2243. function decodeVMTabForm(model, tabs) {
  2244. var result = {
  2245. model: {},
  2246. tabs: [],
  2247. };
  2248. var mdata = angular.fromJson(model);
  2249. angular.extend(result.model, mdata);
  2250. angular.forEach(tabs, function (tab) {
  2251. tab.form.model = vm.models;
  2252. angular.forEach(tab.form.fields, function (field) {
  2253. if (field.key == "") {
  2254. delete field.key;
  2255. }
  2256. field.type = "ui-otherlisttab";
  2257. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2258. var extObj = angular.fromJson(field.extjson);
  2259. angular.extend(field.templateOptions, extObj.templateOptions);
  2260. delete extObj.templateOptions;
  2261. for (var prop in extObj) {
  2262. if (new RegExp("Expression").test(prop)) {
  2263. //var obj = $scope.$eval(extObj[prop]);
  2264. //extObj[prop] = $scope.$eval(extObj[prop]);
  2265. if (extObj[prop] != null) {
  2266. if (new RegExp("function").test(extObj[prop])) {
  2267. var propValue = eval(extObj[prop]);
  2268. extObj[prop] = propValue;
  2269. } else {
  2270. //console.log(extObj[prop]);
  2271. var obj = $scope.$eval(extObj[prop]);
  2272. extObj[prop] = obj;
  2273. //console.log(obj);
  2274. }
  2275. }
  2276. } else if (new RegExp("expressionProperties").test(prop)) {
  2277. for (var p in extObj[prop]) {
  2278. if (new RegExp("function").test(extObj[prop][p])) {
  2279. var propValue = eval(extObj[prop][p]);
  2280. extObj[prop][p] = propValue;
  2281. } else {
  2282. //if(p.indexOf("'")>=0){
  2283. // var obj = $scope.$eval(extObj[prop][p]);
  2284. // extObj[prop][$scope.$eval(p)]=obj;
  2285. //}
  2286. }
  2287. }
  2288. } else if ("watcher" == prop) {
  2289. if (angular.isArray(extObj[prop])) {
  2290. angular.forEach(extObj[prop], function (item, index) {
  2291. for (var p in item) {
  2292. if (new RegExp("function").test(item[p])) {
  2293. var propValue = eval(item[p]);
  2294. extObj[prop][index][p] = propValue;
  2295. }
  2296. }
  2297. });
  2298. } else if (angular.isObject(extObj[prop])) {
  2299. for (var p in extObj[prop]) {
  2300. if (new RegExp("function").test(extObj[prop][p])) {
  2301. var propValue = eval(extObj[prop][p]);
  2302. extObj[prop][p] = propValue;
  2303. }
  2304. }
  2305. }
  2306. }
  2307. }
  2308. angular.extend(field, extObj);
  2309. delete field.extjson;
  2310. }
  2311. if (field.extjson == "") {
  2312. delete field.extjson;
  2313. }
  2314. if (angular.isDefined(field.templateOptions)) {
  2315. var templateOs = field.templateOptions;
  2316. for (var property in templateOs) {
  2317. //console.log(property);
  2318. if (
  2319. angular.isString(templateOs[property]) &&
  2320. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2321. ) {
  2322. if (new RegExp("function").test(templateOs[property])) {
  2323. var propValue = eval(templateOs[property]);
  2324. field.templateOptions[property] = propValue;
  2325. } else {
  2326. if (that.has(templateOs[property])) {
  2327. field.templateOptions[property] = that.get(
  2328. templateOs[property]
  2329. );
  2330. } else {
  2331. field.templateOptions[property] = templateOs[property];
  2332. }
  2333. }
  2334. } else if (templateOs[property] == null) {
  2335. //delete field.templateOptions[property];
  2336. } else {
  2337. }
  2338. }
  2339. }
  2340. if (
  2341. angular.isDefined(field.templateOptions) &&
  2342. angular.isDefined(field.templateOptions.extjson)
  2343. ) {
  2344. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2345. angular.extend(field.templateOptions, extObj);
  2346. delete field.templateOptions.extjson;
  2347. }
  2348. //...
  2349. if (field.templateOptions) {
  2350. //处理远程获取数据控件方法调用
  2351. if (field.templateOptions.optionsUrl) {
  2352. field.templateOptions.refresh = refreshSelectOptions;
  2353. }
  2354. //处理嵌套属性数据绑定/
  2355. if (field.templateOptions.pkey) {
  2356. var pmodel,
  2357. i = 0;
  2358. angular.forEach(
  2359. field.templateOptions.pkey.split("."),
  2360. function (p) {
  2361. if (i == 0) {
  2362. if (result.model[p] == null) {
  2363. result.model[p] = {};
  2364. }
  2365. pmodel = result.model[p];
  2366. i++;
  2367. } else {
  2368. if (pmodel[p] == null) {
  2369. pmodel[p] = {};
  2370. }
  2371. pmodel = pmodel[p];
  2372. }
  2373. }
  2374. );
  2375. if (pmodel != null) {
  2376. field.model = pmodel;
  2377. if (pmodel[field.key] == null) {
  2378. pmodel[field.key] = null;
  2379. }
  2380. }
  2381. } else {
  2382. if (result.model[field.key] == null) {
  2383. result.model[field.key] = null;
  2384. }
  2385. }
  2386. //处理弹出框组件初始化
  2387. if (field.type == "ui-input-selectmodal") {
  2388. field.templateOptions.modal = $modal;
  2389. //field.templateOptions.Restangular = Restangular;
  2390. } else if (field.type == "ui-userselect") {
  2391. field.templateOptions.modal = $modal;
  2392. //field.templateOptions.Restangular = Restangular;
  2393. } else if (field.type == "ui-multiuserselect") {
  2394. field.templateOptions.modal = $modal;
  2395. } else if (field.type == "ui-modelselect") {
  2396. field.templateOptions.modal = $modal;
  2397. //field.templateOptions.Restangular = Restangular;
  2398. } else if (field.type == "ui-cmdbuplode") {
  2399. $scope.fileUploader = field.templateOptions.fileUploader =
  2400. new FileUploader({
  2401. url: "/uploader",
  2402. queueLimit: 1, //文件个数
  2403. autoUpload: true,
  2404. });
  2405. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2406. } else if (field.type == "ui-dropfile") {
  2407. field.templateOptions.fileUploader = new FileUploader({
  2408. url: "/uploader",
  2409. });
  2410. field.templateOptions.taskId = $stateParams.taskId;
  2411. field.templateOptions.processInstanceId =
  2412. $stateParams.processInstanceId;
  2413. field.templateOptions.userId = $rootScope.user.id;
  2414. //field.ApiService=api_bpm_domain;
  2415. } else if (field.type == "ui-dropfiletable") {
  2416. if (field.templateOptions.processInstanceId) {
  2417. } else {
  2418. field.templateOptions.processInstanceId =
  2419. $stateParams.processInstanceId;
  2420. }
  2421. } else if (field.type == "ui-repeatSection") {
  2422. var repeatForm = {
  2423. model: {},
  2424. fields: field.templateOptions.fields,
  2425. };
  2426. repeatForm.model[field.key] = [];
  2427. decodeVMTabForm(repeatForm);
  2428. }
  2429. }
  2430. // console.log(field);
  2431. //field
  2432. //result.fields.push(field);
  2433. });
  2434. });
  2435. vm.originalTabs = angular.copy(vm.form);
  2436. }
  2437. //======================处理表单设计数据 结束========================
  2438. $scope.ldloading = {};
  2439. function filter(obj) {
  2440. angular.forEach(obj, function (key, value) {
  2441. if (value === "" || value === null) {
  2442. delete obj[key];
  2443. } else if (
  2444. Object.prototype.toString.call(value) === "[object Object]"
  2445. ) {
  2446. filter(value);
  2447. } else if (angular.isArray(value)) {
  2448. angular.forEach(value, function (item) {
  2449. filter(item);
  2450. });
  2451. }
  2452. });
  2453. }
  2454. function invokeOnAllFormOptions(fn) {
  2455. angular.forEach(vm.tabs, function (tab) {
  2456. if (tab.form.options && tab.form.options[fn]) {
  2457. tab.form.options[fn]();
  2458. }
  2459. });
  2460. }
  2461. function encodeCIData(data, ciId) {
  2462. /*
  2463. create/update state:未审核
  2464. create createtime:系统时间
  2465. create/update lastupdatetime : 系统时间
  2466. label:ci分类
  2467. */
  2468. if (ciId) {
  2469. var baseprop = [
  2470. "uuid",
  2471. "name",
  2472. "type",
  2473. "label",
  2474. "status",
  2475. "createtime",
  2476. "lastupdatetime",
  2477. "props",
  2478. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2479. var extraprop = "props";
  2480. data[extraprop] = {};
  2481. for (var key in data) {
  2482. console.log(data[key]);
  2483. if (_.indexOf(baseprop, key) >= 0) {
  2484. continue;
  2485. } else {
  2486. data[extraprop][key] = data[key];
  2487. delete data[key];
  2488. }
  2489. }
  2490. if ($rootScope.user) {
  2491. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2492. data[extraprop]["configperson"] = $rootScope.user.name;
  2493. var isCMAdminFlag = false;
  2494. angular.forEach($rootScope.user.role, function (roleItem) {
  2495. if (roleItem.rolecode == "cmdb charge") {
  2496. isCMAdminFlag = true;
  2497. }
  2498. });
  2499. if (!isCMAdminFlag) {
  2500. data[extraprop]["state"] = "1";
  2501. }
  2502. }
  2503. if (data.props.id) {
  2504. } else {
  2505. data.label = ciId;
  2506. }
  2507. return data;
  2508. }
  2509. return undefined;
  2510. }
  2511. function decodeCIModel(data) {
  2512. var extraprop = "props";
  2513. if (data[extraprop]) {
  2514. for (var key in data[extraprop]) {
  2515. data[key] = data[extraprop][key];
  2516. }
  2517. delete data[extraprop];
  2518. }
  2519. data["iscmadmin"] = false;
  2520. angular.forEach($rootScope.user.role, function (roleItem) {
  2521. if (roleItem.rolecode == "cmdb charge") {
  2522. data["iscmadmin"] = true;
  2523. }
  2524. });
  2525. return data;
  2526. }
  2527. function formValid() {
  2528. angular.forEach(vm.tabs, function (item) {
  2529. //item.
  2530. });
  2531. }
  2532. $scope.vm = vm;
  2533. $scope.refreshcmdbform = function (item) {
  2534. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2535. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2536. var myData = Restangular.stripRestangular(data);
  2537. $scope.propTypeOptions = myData;
  2538. $scope.templateProps = myData;
  2539. $scope.vm.tabs = myData;
  2540. if ($scope.model.assets) {
  2541. vm.models = JSON.parse($scope.model.assets);
  2542. }
  2543. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2544. if (vm.models.vtvmvtm_kaiji) {
  2545. vm.models.vtvmvtm_kaiji = "是";
  2546. } else {
  2547. vm.models.vtvmvtm_kaiji = "否";
  2548. }
  2549. }
  2550. decodeVMTabForm(vm.models, vm.tabs);
  2551. });
  2552. // }
  2553. };
  2554. var cifilterClassic = {};
  2555. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2556. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2557. $scope.refreshcmdbform(
  2558. $scope.$parent.$parent.$parent.model.cifilterClassic
  2559. );
  2560. // } else {}
  2561. },
  2562. ],
  2563. });
  2564. //固定资产下载
  2565. formlyConfigProvider.setType({
  2566. name: "ui-dropupload",
  2567. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2568. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2569. defaultOptions: function (options) {
  2570. return {
  2571. templateOptions: {
  2572. view: function (APIService, contentId) {
  2573. return APIService.downloadAttachment(contentId);
  2574. },
  2575. },
  2576. };
  2577. },
  2578. controller: [
  2579. "$scope",
  2580. "$rootScope",
  2581. "Restangular",
  2582. function ($scope, $rootScope, Restangular) {
  2583. if (angular.isUndefined($scope.form.dropState)) {
  2584. $scope.form.dropState = false;
  2585. }
  2586. var to = $scope.options.templateOptions;
  2587. var bindId = $scope.model[to.bindType].processInstanceId;
  2588. //获取附件列表
  2589. $scope.listAttachmen = function () {
  2590. to.ApiService.listAttachment(
  2591. to.listAttachmentUrl,
  2592. to.bindType,
  2593. bindId
  2594. ).then(function (result) {
  2595. var myData = Restangular.stripRestangular(result);
  2596. // $scope.listAttachmens = myData;
  2597. $scope.attachments = myData.data;
  2598. });
  2599. };
  2600. $scope.listAttachmen();
  2601. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2602. // $scope.listAttachmen();
  2603. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2604. // $scope.listAttachmen();
  2605. // }
  2606. //附件下载
  2607. $scope.download = function (token, filename) {
  2608. var downUrl = to.ApiService.downloadAttachment(
  2609. to.downUrl,
  2610. token
  2611. ).getRequestedUrl();
  2612. var a = document.createElement("a");
  2613. a.href = downUrl;
  2614. a.target = "_blank";
  2615. a.download = filename;
  2616. document.body.appendChild(a);
  2617. a.click();
  2618. };
  2619. //附件预览
  2620. $scope.view = function (id, previewUrl) {
  2621. if (previewUrl) {
  2622. window.open(previewUrl);
  2623. }
  2624. };
  2625. },
  2626. ],
  2627. });
  2628. formlyConfigProvider.setType({
  2629. name: "ui-form",
  2630. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2631. defaultOptions: function (options) {
  2632. return {
  2633. templateOptions: {
  2634. // link: function() {}
  2635. },
  2636. };
  2637. },
  2638. controller: [
  2639. "$rootScope",
  2640. "$scope",
  2641. "$parse",
  2642. "$injector",
  2643. "$http",
  2644. "$q",
  2645. "$state",
  2646. "$stateParams",
  2647. "$modal",
  2648. "$timeout",
  2649. "$interval",
  2650. "i18nService",
  2651. "SweetAlert",
  2652. "FileUploader",
  2653. "Restangular",
  2654. "UserRestangular",
  2655. "BpmRestangular",
  2656. "api_configure_form",
  2657. "api_configure_data",
  2658. "api_bpm_domain",
  2659. "api_bpm_data",
  2660. "api_user_data",
  2661. "api_cmdb",
  2662. "api_sysinfo",
  2663. function (
  2664. $rootScope,
  2665. $scope,
  2666. $parse,
  2667. $injector,
  2668. $http,
  2669. $q,
  2670. $state,
  2671. $stateParams,
  2672. $modal,
  2673. $timeout,
  2674. $interval,
  2675. i18nService,
  2676. SweetAlert,
  2677. FileUploader,
  2678. Restangular,
  2679. UserRestangular,
  2680. BpmRestangular,
  2681. api_configure_form,
  2682. api_configure_data,
  2683. api_bpm_domain,
  2684. api_bpm_data,
  2685. api_user_data,
  2686. api_cmdb,
  2687. api_sysinfo
  2688. ) {
  2689. $scope.langs = i18nService.getAllLangs();
  2690. $scope.lang = "zh-cn";
  2691. i18nService.setCurrentLang($scope.lang);
  2692. var vm = this;
  2693. vm.options = {};
  2694. vm.exampleTitle = ["expressionProperties", "model property"];
  2695. vm.fields = [];
  2696. vm.models = {};
  2697. // vm.models["loginUser"] = $rootScope.user;
  2698. var that = $injector;
  2699. var parse = $parse;
  2700. var formKey = "";
  2701. var pdKey = "";
  2702. if (
  2703. angular.isDefined($state.current.pdKey) &&
  2704. $state.current.pdKey != ""
  2705. ) {
  2706. pdKey = $state.current.pdKey;
  2707. //console.log("pdKey::"+$state.current.pdKey);
  2708. }
  2709. if (
  2710. angular.isDefined($stateParams.formKey) &&
  2711. $stateParams.formKey != ""
  2712. ) {
  2713. formKey = $stateParams.formKey;
  2714. //console.log("formKey::"+$stateParams.formKey);
  2715. }
  2716. //用户测试数据,后续从header的auth中获取
  2717. var userId = 2;
  2718. userId = $rootScope.user.id;
  2719. //==============处理表单设计数据 开始====================
  2720. //处理组件加载后台数据选项的方法
  2721. function refreshSelectOptions(searchVal, field) {
  2722. if (field.templateOptions.optionsUrl) {
  2723. var process = BpmRestangular.all("");
  2724. if (field.templateOptions.ApiService) {
  2725. process = UserRestangular.all("");
  2726. }
  2727. process
  2728. .customPOST(
  2729. {
  2730. idx: 0,
  2731. sum: 1000,
  2732. },
  2733. field.templateOptions.optionsUrl
  2734. )
  2735. .then(function (result) {
  2736. if (!field.templateOptions.options) {
  2737. field.templateOptions.options = [];
  2738. }
  2739. if (field.templateOptions.optionsDataKey) {
  2740. field.templateOptions.options =
  2741. result[field.templateOptions.optionsDataKey];
  2742. } else {
  2743. field.templateOptions.options = result;
  2744. }
  2745. });
  2746. }
  2747. }
  2748. function decodeVMTabForm(model, tabs) {
  2749. var result = {
  2750. model: {},
  2751. tabs: [],
  2752. };
  2753. var mdata = angular.fromJson(model);
  2754. angular.extend(result.model, mdata);
  2755. angular.forEach(tabs, function (tab) {
  2756. tab.form.model = vm.models;
  2757. angular.forEach(tab.form.fields, function (field) {
  2758. if (field.key == "") {
  2759. delete field.key;
  2760. }
  2761. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2762. var extObj = angular.fromJson(field.extjson);
  2763. angular.extend(field.templateOptions, extObj.templateOptions);
  2764. delete extObj.templateOptions;
  2765. for (var prop in extObj) {
  2766. if (new RegExp("Expression").test(prop)) {
  2767. //var obj = $scope.$eval(extObj[prop]);
  2768. //extObj[prop] = $scope.$eval(extObj[prop]);
  2769. if (extObj[prop] != null) {
  2770. if (new RegExp("function").test(extObj[prop])) {
  2771. var propValue = eval(extObj[prop]);
  2772. extObj[prop] = propValue;
  2773. } else {
  2774. //console.log(extObj[prop]);
  2775. var obj = $scope.$eval(extObj[prop]);
  2776. extObj[prop] = obj;
  2777. //console.log(obj);
  2778. }
  2779. }
  2780. } else if (new RegExp("expressionProperties").test(prop)) {
  2781. for (var p in extObj[prop]) {
  2782. if (new RegExp("function").test(extObj[prop][p])) {
  2783. var propValue = eval(extObj[prop][p]);
  2784. extObj[prop][p] = propValue;
  2785. } else {
  2786. //if(p.indexOf("'")>=0){
  2787. // var obj = $scope.$eval(extObj[prop][p]);
  2788. // extObj[prop][$scope.$eval(p)]=obj;
  2789. //}
  2790. }
  2791. }
  2792. } else if ("watcher" == prop) {
  2793. if (angular.isArray(extObj[prop])) {
  2794. angular.forEach(extObj[prop], function (item, index) {
  2795. for (var p in item) {
  2796. if (new RegExp("function").test(item[p])) {
  2797. var propValue = eval(item[p]);
  2798. extObj[prop][index][p] = propValue;
  2799. }
  2800. }
  2801. });
  2802. } else if (angular.isObject(extObj[prop])) {
  2803. for (var p in extObj[prop]) {
  2804. if (new RegExp("function").test(extObj[prop][p])) {
  2805. var propValue = eval(extObj[prop][p]);
  2806. extObj[prop][p] = propValue;
  2807. }
  2808. }
  2809. }
  2810. }
  2811. }
  2812. angular.extend(field, extObj);
  2813. delete field.extjson;
  2814. }
  2815. if (field.extjson == "") {
  2816. delete field.extjson;
  2817. }
  2818. if (angular.isDefined(field.templateOptions)) {
  2819. var templateOs = field.templateOptions;
  2820. for (var property in templateOs) {
  2821. //console.log(property);
  2822. if (
  2823. angular.isString(templateOs[property]) &&
  2824. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2825. ) {
  2826. if (new RegExp("function").test(templateOs[property])) {
  2827. var propValue = eval(templateOs[property]);
  2828. field.templateOptions[property] = propValue;
  2829. } else {
  2830. if (that.has(templateOs[property])) {
  2831. field.templateOptions[property] = that.get(
  2832. templateOs[property]
  2833. );
  2834. } else {
  2835. field.templateOptions[property] = templateOs[property];
  2836. }
  2837. }
  2838. } else if (templateOs[property] == null) {
  2839. //delete field.templateOptions[property];
  2840. } else {
  2841. }
  2842. }
  2843. }
  2844. if (
  2845. angular.isDefined(field.templateOptions) &&
  2846. angular.isDefined(field.templateOptions.extjson)
  2847. ) {
  2848. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2849. angular.extend(field.templateOptions, extObj);
  2850. delete field.templateOptions.extjson;
  2851. }
  2852. //...
  2853. if (field.templateOptions) {
  2854. //处理远程获取数据控件方法调用
  2855. if (field.templateOptions.optionsUrl) {
  2856. field.templateOptions.refresh = refreshSelectOptions;
  2857. }
  2858. //处理嵌套属性数据绑定/
  2859. if (field.templateOptions.pkey) {
  2860. var pmodel,
  2861. i = 0;
  2862. angular.forEach(
  2863. field.templateOptions.pkey.split("."),
  2864. function (p) {
  2865. if (i == 0) {
  2866. if (result.model[p] == null) {
  2867. result.model[p] = {};
  2868. }
  2869. pmodel = result.model[p];
  2870. i++;
  2871. } else {
  2872. if (pmodel[p] == null) {
  2873. pmodel[p] = {};
  2874. }
  2875. pmodel = pmodel[p];
  2876. }
  2877. }
  2878. );
  2879. if (pmodel != null) {
  2880. field.model = pmodel;
  2881. if (pmodel[field.key] == null) {
  2882. pmodel[field.key] = null;
  2883. }
  2884. }
  2885. } else {
  2886. if (result.model[field.key] == null) {
  2887. result.model[field.key] = null;
  2888. }
  2889. }
  2890. //处理弹出框组件初始化
  2891. if (field.type == "ui-input-selectmodal") {
  2892. field.templateOptions.modal = $modal;
  2893. //field.templateOptions.Restangular = Restangular;
  2894. } else if (field.type == "ui-userselect") {
  2895. field.templateOptions.modal = $modal;
  2896. //field.templateOptions.Restangular = Restangular;
  2897. } else if (field.type == "ui-multiuserselect") {
  2898. field.templateOptions.modal = $modal;
  2899. } else if (field.type == "ui-modelselect") {
  2900. field.templateOptions.modal = $modal;
  2901. //field.templateOptions.Restangular = Restangular;
  2902. } else if (field.type == "ui-dropfile") {
  2903. field.templateOptions.fileUploader = new FileUploader({
  2904. url: "/uploader",
  2905. });
  2906. field.templateOptions.taskId = $stateParams.taskId;
  2907. field.templateOptions.processInstanceId =
  2908. $stateParams.processInstanceId;
  2909. field.templateOptions.userId = $rootScope.user.id;
  2910. //field.ApiService=api_bpm_domain;
  2911. // }else if (field.type == "ui-uploadFile") {
  2912. // field.templateOptions.fileUploader = new FileUploader({
  2913. // url: '/uploader'
  2914. // });
  2915. // field.templateOptions.taskId = $stateParams.taskId;
  2916. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2917. // field.templateOptions.userId = $rootScope.user.id;
  2918. //field.ApiService=api_bpm_domain;
  2919. } else if (field.type == "ui-dropfiletable") {
  2920. if (field.templateOptions.processInstanceId) {
  2921. } else {
  2922. field.templateOptions.processInstanceId =
  2923. $stateParams.processInstanceId;
  2924. }
  2925. } else if (field.type == "ui-dropFiles") {
  2926. if (field.templateOptions.processInstanceId) {
  2927. } else {
  2928. field.templateOptions.processInstanceId =
  2929. $stateParams.processInstanceId;
  2930. }
  2931. } else if (field.type == "ui-showImgs") {
  2932. if (field.templateOptions.processInstanceId) {
  2933. } else {
  2934. field.templateOptions.processInstanceId =
  2935. $stateParams.processInstanceId;
  2936. }
  2937. } else if (field.type == "ui-repeatSection") {
  2938. var repeatForm = {
  2939. model: {},
  2940. fields: field.templateOptions.fields,
  2941. };
  2942. repeatForm.model[field.key] = [];
  2943. decodeVMTabForm(repeatForm);
  2944. }
  2945. }
  2946. // console.log(field);
  2947. //field
  2948. //result.fields.push(field);
  2949. });
  2950. });
  2951. vm.originalTabs = angular.copy(vm.form);
  2952. }
  2953. //解析自定义表单设计数据
  2954. function decodeVMForm(vmForm) {
  2955. var result = {
  2956. model: {},
  2957. tabs: [],
  2958. };
  2959. //设置模型实体数据 begin
  2960. // var mdata = vmForm.model;
  2961. //解析数据实体
  2962. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2963. angular.extend(result.model, mdata);
  2964. //设置模型实体数据 end
  2965. //解析设计数据生成表单项 begin
  2966. var fields = [];
  2967. //处理修改设计数据中展示设置
  2968. angular.forEach(vmForm.tabs, function (field) {
  2969. if (field.key == "") {
  2970. delete field.key;
  2971. }
  2972. if (angular.isDefined(field.extjson)) {
  2973. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2974. angular.extend(field.templateOptions, extObj.templateOptions);
  2975. delete extObj.templateOptions;
  2976. for (var prop in extObj) {
  2977. if (new RegExp("Expression").test(prop)) {
  2978. //var obj = $scope.$eval(extObj[prop]);
  2979. //extObj[prop] = $scope.$eval(extObj[prop]);
  2980. if (extObj[prop] != null) {
  2981. if (new RegExp("function").test(extObj[prop])) {
  2982. var propValue = eval(extObj[prop]);
  2983. extObj[prop] = propValue;
  2984. } else {
  2985. //console.log(extObj[prop]);
  2986. var obj = $scope.$eval(extObj[prop]);
  2987. extObj[prop] = obj;
  2988. //console.log(obj);
  2989. }
  2990. }
  2991. } else if (new RegExp("expressionProperties").test(prop)) {
  2992. for (var p in extObj[prop]) {
  2993. if (new RegExp("function").test(extObj[prop][p])) {
  2994. var propValue = eval(extObj[prop][p]);
  2995. extObj[prop][p] = propValue;
  2996. } else {
  2997. //if(p.indexOf("'")>=0){
  2998. // var obj = $scope.$eval(extObj[prop][p]);
  2999. // extObj[prop][$scope.$eval(p)]=obj;
  3000. //}
  3001. }
  3002. }
  3003. } else if ("watcher" == prop) {
  3004. if (angular.isArray(extObj[prop])) {
  3005. angular.forEach(extObj[prop], function (item, index) {
  3006. for (var p in item) {
  3007. if (new RegExp("function").test(item[p])) {
  3008. var propValue = eval(item[p]);
  3009. extObj[prop][index][p] = propValue;
  3010. }
  3011. }
  3012. });
  3013. } else if (angular.isObject(extObj[prop])) {
  3014. for (var p in extObj[prop]) {
  3015. if (new RegExp("function").test(extObj[prop][p])) {
  3016. var propValue = eval(extObj[prop][p]);
  3017. extObj[prop][p] = propValue;
  3018. }
  3019. }
  3020. }
  3021. }
  3022. }
  3023. angular.extend(field, extObj);
  3024. delete field.extjson;
  3025. }
  3026. if (angular.isDefined(field.templateOptions)) {
  3027. var templateOs = field.templateOptions;
  3028. for (var property in templateOs) {
  3029. //console.log(property);
  3030. if (
  3031. angular.isString(templateOs[property]) &&
  3032. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3033. ) {
  3034. if (new RegExp("function").test(templateOs[property])) {
  3035. var propValue = eval(templateOs[property]);
  3036. field.templateOptions[property] = propValue;
  3037. } else {
  3038. if (that.has(templateOs[property])) {
  3039. field.templateOptions[property] = that.get(
  3040. templateOs[property]
  3041. );
  3042. } else {
  3043. field.templateOptions[property] = templateOs[property];
  3044. }
  3045. }
  3046. } else if (templateOs[property] == null) {
  3047. //delete field.templateOptions[property];
  3048. } else {
  3049. }
  3050. }
  3051. }
  3052. if (
  3053. angular.isDefined(field.templateOptions) &&
  3054. angular.isDefined(field.templateOptions.extjson)
  3055. ) {
  3056. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3057. angular.extend(field.templateOptions, extObj);
  3058. delete field.templateOptions.extjson;
  3059. }
  3060. //...
  3061. if (field.templateOptions) {
  3062. //处理远程获取数据控件方法调用
  3063. if (field.templateOptions.optionsUrl) {
  3064. field.templateOptions.refresh = refreshSelectOptions;
  3065. }
  3066. //处理嵌套属性数据绑定/
  3067. if (field.templateOptions.pkey) {
  3068. var pmodel,
  3069. i = 0;
  3070. angular.forEach(
  3071. field.templateOptions.pkey.split("."),
  3072. function (p) {
  3073. if (i == 0) {
  3074. if (result.model[p] == null) {
  3075. result.model[p] = {};
  3076. }
  3077. pmodel = result.model[p];
  3078. i++;
  3079. } else {
  3080. if (pmodel[p] == null) {
  3081. pmodel[p] = {};
  3082. }
  3083. pmodel = pmodel[p];
  3084. }
  3085. }
  3086. );
  3087. if (pmodel != null) {
  3088. field.model = pmodel;
  3089. if (pmodel[field.key] == null) {
  3090. pmodel[field.key] = null;
  3091. }
  3092. }
  3093. } else {
  3094. if (result.model[field.key] == null) {
  3095. result.model[field.key] = null;
  3096. }
  3097. }
  3098. //处理弹出框组件初始化
  3099. if (field.type == "ui-input-selectmodal") {
  3100. field.templateOptions.modal = $modal;
  3101. //field.templateOptions.Restangular = Restangular;
  3102. } else if (field.type == "ui-userselect") {
  3103. field.templateOptions.modal = $modal;
  3104. //field.templateOptions.Restangular = Restangular;
  3105. } else if (field.type == "ui-multiuserselect") {
  3106. field.templateOptions.modal = $modal;
  3107. } else if (field.type == "ui-modelselect") {
  3108. field.templateOptions.modal = $modal;
  3109. //field.templateOptions.Restangular = Restangular;
  3110. } else if (field.type == "ui-dropfile") {
  3111. field.templateOptions.fileUploader = new FileUploader({
  3112. url: "/uploader",
  3113. });
  3114. field.templateOptions.taskId = $stateParams.taskId;
  3115. field.templateOptions.processInstanceId =
  3116. $stateParams.processInstanceId;
  3117. field.templateOptions.userId = $rootScope.user.id;
  3118. //field.ApiService=api_bpm_domain;
  3119. } else if (field.type == "ui-dropfiletable") {
  3120. if (field.templateOptions.processInstanceId) {
  3121. } else {
  3122. field.templateOptions.processInstanceId =
  3123. $stateParams.processInstanceId;
  3124. }
  3125. } else if (field.type == "ui-dropFiles") {
  3126. if (field.templateOptions.processInstanceId) {
  3127. } else {
  3128. field.templateOptions.processInstanceId =
  3129. $stateParams.processInstanceId;
  3130. }
  3131. } else if (field.type == "ui-showImgs") {
  3132. if (field.templateOptions.processInstanceId) {
  3133. } else {
  3134. field.templateOptions.processInstanceId =
  3135. $stateParams.processInstanceId;
  3136. }
  3137. } else if (field.type == "ui-repeatSection") {
  3138. var repeatForm = {
  3139. model: {},
  3140. fields: field.templateOptions.fields,
  3141. };
  3142. repeatForm.model[field.key] = [];
  3143. decodeVMForm(repeatForm);
  3144. }
  3145. }
  3146. // console.log(field);
  3147. result.fields.push(field);
  3148. });
  3149. angular.extend($scope.vm.fields, result.fields);
  3150. angular.extend($scope.vm.models, result.model);
  3151. $scope.formData = vmForm;
  3152. //console.log($scope.vm);
  3153. //解析设计数据生成表单项 end
  3154. return result;
  3155. }
  3156. //======================处理表单设计数据 结束========================
  3157. $scope.ldloading = {};
  3158. function filter(obj) {
  3159. angular.forEach(obj, function (key, value) {
  3160. if (value === "" || value === null) {
  3161. delete obj[key];
  3162. } else if (
  3163. Object.prototype.toString.call(value) === "[object Object]"
  3164. ) {
  3165. filter(value);
  3166. } else if (angular.isArray(value)) {
  3167. angular.forEach(value, function (item) {
  3168. filter(item);
  3169. });
  3170. }
  3171. });
  3172. }
  3173. function invokeOnAllFormOptions(fn) {
  3174. angular.forEach(vm.tabs, function (tab) {
  3175. if (tab.form.options && tab.form.options[fn]) {
  3176. tab.form.options[fn]();
  3177. }
  3178. });
  3179. }
  3180. function encodeCIData(data, ciId) {
  3181. /*
  3182. create/update state:未审核
  3183. create createtime:系统时间
  3184. create/update lastupdatetime : 系统时间
  3185. label:ci分类
  3186. */
  3187. if (ciId) {
  3188. var baseprop = [
  3189. "uuid",
  3190. "name",
  3191. "type",
  3192. "label",
  3193. "status",
  3194. "createtime",
  3195. "lastupdatetime",
  3196. "props",
  3197. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3198. var extraprop = "props";
  3199. data[extraprop] = {};
  3200. for (var key in data) {
  3201. console.log(data[key]);
  3202. if (_.indexOf(baseprop, key) >= 0) {
  3203. continue;
  3204. } else {
  3205. data[extraprop][key] = data[key];
  3206. delete data[key];
  3207. }
  3208. }
  3209. if ($rootScope.user) {
  3210. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3211. data[extraprop]["configperson"] = $rootScope.user.name;
  3212. var isCMAdminFlag = false;
  3213. angular.forEach($rootScope.user.role, function (roleItem) {
  3214. if (roleItem.rolecode == "cmdb charge") {
  3215. isCMAdminFlag = true;
  3216. }
  3217. });
  3218. if (!isCMAdminFlag) {
  3219. data[extraprop]["state"] = "1";
  3220. }
  3221. }
  3222. if (data.props.id) {
  3223. } else {
  3224. data.label = ciId;
  3225. }
  3226. return data;
  3227. }
  3228. return undefined;
  3229. }
  3230. function decodeCIModel(data) {
  3231. var extraprop = "props";
  3232. if (data[extraprop]) {
  3233. for (var key in data[extraprop]) {
  3234. data[key] = data[extraprop][key];
  3235. }
  3236. delete data[extraprop];
  3237. }
  3238. data["iscmadmin"] = false;
  3239. angular.forEach($rootScope.user.role, function (roleItem) {
  3240. if (roleItem.rolecode == "cmdb charge") {
  3241. data["iscmadmin"] = true;
  3242. }
  3243. });
  3244. return data;
  3245. }
  3246. vm.remove = function (data, style) {
  3247. $scope.ldloading[style.replace("-", "_")] = true;
  3248. var modalInstance = $modal.open({
  3249. templateUrl: "assets/views/delete.html",
  3250. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3251. var cidata = {
  3252. label: data.label,
  3253. id: data.id,
  3254. uuid: data.uuid,
  3255. name: data.name,
  3256. props: {},
  3257. };
  3258. if (cidata.id) {
  3259. cidata.props["removeflag"] = true;
  3260. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3261. $scope.ok = function () {
  3262. $modalInstance.close(cidata);
  3263. };
  3264. $scope.cancel = function () {
  3265. $modalInstance.dismiss("cancel");
  3266. };
  3267. }
  3268. },
  3269. size: "sm",
  3270. resolve: {
  3271. scope: function () {
  3272. return $scope;
  3273. },
  3274. },
  3275. });
  3276. modalInstance.result.then(function (selectedItem) {
  3277. if (selectedItem) {
  3278. // if (selectedItem.length > 0) {
  3279. api_cmdb
  3280. .put(selectedItem, selectedItem.id)
  3281. .then(function (response) {
  3282. if (response) {
  3283. var resData = Restangular.stripRestangular(response);
  3284. SweetAlert.swal(
  3285. {
  3286. title: "删除成功!",
  3287. confirmButtonColor: "#007AFF",
  3288. },
  3289. function () {
  3290. $state.go("app.means.list");
  3291. // $scope.refreshform();
  3292. // reinitTabForm($scope.classify);
  3293. }
  3294. );
  3295. } else {
  3296. SweetAlert.swal({
  3297. title: "系统错误",
  3298. text: "系统错误,请稍后重试!",
  3299. type: "error",
  3300. confirmButtonColor: "#DD6B55",
  3301. });
  3302. }
  3303. $scope.ldloading[style.replace("-", "_")] = false;
  3304. });
  3305. }
  3306. });
  3307. };
  3308. function formValid() {
  3309. angular.forEach(vm.tabs, function (item) {
  3310. //item.
  3311. });
  3312. }
  3313. $scope.closeModel = function () {
  3314. console.log($stateParams);
  3315. if (
  3316. angular.isDefined($stateParams.formKey) &&
  3317. $stateParams.formKey != ""
  3318. ) {
  3319. if (
  3320. $stateParams.formKey == "means_editor" ||
  3321. $stateParams.formKey == "means_edit"
  3322. ) {
  3323. $state.go("app.means.list", {});
  3324. }
  3325. event.preventDefault();
  3326. }
  3327. };
  3328. // setInterval(function() {
  3329. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3330. // cifilter_classic = $scope.model.cifilter_classic;
  3331. // $scope.refreshcmdbform(cifilter_classic);
  3332. // } else {}
  3333. // }, 100);
  3334. vm.models = (function filter(obj) {
  3335. var filtered = _.pick(obj, function (v) {
  3336. return (
  3337. angular.isDefined(v) &&
  3338. v !== null &&
  3339. (angular.isArray(v) ? v.length > 0 : true) &&
  3340. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3341. );
  3342. });
  3343. return _.cloneDeep(filtered, function (v) {
  3344. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3345. });
  3346. })(vm.models);
  3347. // setInterval(function() {
  3348. // if ($scope.model.type == 0) {
  3349. // $scope.model[$scope.options.key] = vm.models;
  3350. // }
  3351. // }, 100);
  3352. setInterval(function () {
  3353. if (vm.form && vm.form.$$parentForm.$valid) {
  3354. if (
  3355. $scope.$parent &&
  3356. $scope.$parent.$parent &&
  3357. $scope.$parent.$parent.$parent &&
  3358. $scope.$parent.$parent.$parent.model
  3359. ) {
  3360. vm.models.hw_cifilterClassic =
  3361. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3362. $scope.model[$scope.options.key] = vm.models;
  3363. }
  3364. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3365. // $scope.model[$scope.options.key] = vm.models;
  3366. }
  3367. }, 100);
  3368. vm.submit = function (data, ciId, templateitem, style) {
  3369. // $scope.ldloading[style.replace('-', '_')] = true;
  3370. console.log(vm.form.$$parentForm.$valid);
  3371. if (vm.form.$$parentForm.$valid) {
  3372. invokeOnAllFormOptions("updateInitialValue");
  3373. //alert(JSON.stringify(vm.model), null, 2);
  3374. //vm.options.updateInitialValue();
  3375. //console.log(vm.model);
  3376. var cidata = encodeCIData(vm.models, ciId);
  3377. if (cidata) {
  3378. //var cidata = ;
  3379. if (cidata.props.id) {
  3380. //修改
  3381. api_cmdb.put(cidata, ciId).then(function (response) {
  3382. if (response) {
  3383. var resData = Restangular.stripRestangular(response);
  3384. SweetAlert.swal(
  3385. {
  3386. title: "保存成功!",
  3387. confirmButtonColor: "#007AFF",
  3388. },
  3389. function () {
  3390. $scope.ldloading[style.replace("-", "_")] = false;
  3391. // $scope.refreshform();
  3392. $state.go("app.means.list");
  3393. }
  3394. );
  3395. } else {
  3396. SweetAlert.swal({
  3397. title: "系统错误",
  3398. text: "系统错误,请稍后重试!",
  3399. type: "error",
  3400. confirmButtonColor: "#DD6B55",
  3401. });
  3402. }
  3403. $scope.ldloading[style.replace("-", "_")] = false;
  3404. });
  3405. } else {
  3406. //新建
  3407. var type = 2;
  3408. api_sysinfo
  3409. .getSerialnumber(type, templateitem.id)
  3410. .then(function (data) {
  3411. if (data && data.status == 200) {
  3412. cidata.uuid = data.uuid;
  3413. api_cmdb.create(cidata).then(function (response) {
  3414. if (response) {
  3415. var resData = Restangular.stripRestangular(response);
  3416. SweetAlert.swal(
  3417. {
  3418. title: "保存成功!",
  3419. text: "内部编号:" + cidata.uuid,
  3420. confirmButtonColor: "#007AFF",
  3421. },
  3422. function () {
  3423. $state.go("app.means.list");
  3424. }
  3425. );
  3426. // if(resData.status){
  3427. // resData
  3428. // }
  3429. } else {
  3430. SweetAlert.swal({
  3431. title: "系统错误",
  3432. text: "系统错误,请稍后重试!",
  3433. type: "error",
  3434. confirmButtonColor: "#DD6B55",
  3435. });
  3436. }
  3437. $scope.ldloading[style.replace("-", "_")] = false;
  3438. });
  3439. } else {
  3440. SweetAlert.swal({
  3441. title: "系统错误",
  3442. text: "内部编号生成出错!",
  3443. type: "error",
  3444. confirmButtonColor: "#DD6B55",
  3445. });
  3446. }
  3447. });
  3448. }
  3449. } else {
  3450. SweetAlert.swal({
  3451. title: "错误",
  3452. text: "错误,请选择资产分类!",
  3453. type: "error",
  3454. confirmButtonColor: "#DD6B55",
  3455. });
  3456. }
  3457. //alert(JSON.stringify(cidata), null, 2);
  3458. $scope.ldloading[style.replace("-", "_")] = true;
  3459. return;
  3460. var _ = window._;
  3461. vm.models = (function filter(obj) {
  3462. var filtered = _.pick(obj, function (v) {
  3463. return (
  3464. angular.isDefined(v) &&
  3465. v !== null &&
  3466. (angular.isArray(v) ? v.length > 0 : true) &&
  3467. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3468. );
  3469. });
  3470. return _.cloneDeep(filtered, function (v) {
  3471. return v !== filtered && _.isPlainObject(v)
  3472. ? filter(v)
  3473. : undefined;
  3474. });
  3475. })(vm.models);
  3476. } else {
  3477. if (vm.form.$$parentForm.$error) {
  3478. SweetAlert.swal({
  3479. title: "校验错误",
  3480. text: "请填写必填项!",
  3481. type: "error",
  3482. confirmButtonColor: "#DD6B55",
  3483. });
  3484. angular.forEach(
  3485. vm.form.$$parentForm.$error.required,
  3486. function (item) {
  3487. angular.forEach(vm.tabs, function (tab) {
  3488. angular.forEach(tab.form.fields, function (f) {
  3489. if (f.name == item.$name) {
  3490. f.validation.show = true;
  3491. tab.active = true;
  3492. }
  3493. });
  3494. });
  3495. }
  3496. );
  3497. $scope.ldloading[style.replace("-", "_")] = false;
  3498. }
  3499. }
  3500. };
  3501. $scope.vm = vm;
  3502. $scope.refreshcmdbform = function (item) {
  3503. // if ($stateParams.model) {
  3504. // var modeldata = JSON.parse($stateParams.model)
  3505. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3506. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3507. var myData = Restangular.stripRestangular(data);
  3508. $scope.propTypeOptions = myData;
  3509. $scope.templateProps = myData;
  3510. $scope.vm.tabs = myData;
  3511. if ($scope.model.asset && $scope.model.asset.length != "") {
  3512. vm.models = JSON.parse($scope.model.asset);
  3513. }
  3514. decodeVMTabForm(vm.models, vm.tabs);
  3515. });
  3516. // }
  3517. };
  3518. var cifilterClassic = {};
  3519. setInterval(function () {
  3520. if (
  3521. $scope.$parent.$parent &&
  3522. $scope.$parent.$parent.$parent &&
  3523. $scope.$parent.$parent.$parent.model &&
  3524. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3525. cifilterClassic.id !=
  3526. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3527. ) {
  3528. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3529. cifilterClassic =
  3530. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3531. $scope.refreshcmdbform(cifilterClassic);
  3532. } else {
  3533. }
  3534. }, 100);
  3535. },
  3536. ],
  3537. });
  3538. //请求人信息
  3539. formlyConfigProvider.setType({
  3540. name: "ui-cmdbinformation",
  3541. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3542. wrapper: ["bootstrapHasError"],
  3543. defaultOptions: function (options, $scope) {
  3544. return {
  3545. templateOptions: {
  3546. // checkform: function(options) {
  3547. // if (options.model.requester) {
  3548. // options.value(options.model.requester);
  3549. // }
  3550. // },
  3551. },
  3552. };
  3553. },
  3554. controller: [
  3555. "$scope",
  3556. "api_user_data",
  3557. function ($scope, api_user_data) {
  3558. if ($scope.options.templateOptions.loginUser) {
  3559. if (
  3560. $scope.model[$scope.options.key] &&
  3561. $scope.model[$scope.options.key].id
  3562. ) {
  3563. } else {
  3564. $scope.model[$scope.options.key] =
  3565. $scope.options.templateOptions.loginUser;
  3566. }
  3567. $scope.options.initialValue = $scope.model[$scope.options.key];
  3568. }
  3569. },
  3570. ],
  3571. });
  3572. //资产属性
  3573. formlyConfigProvider.setType({
  3574. name: "ui-cmdbtype",
  3575. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3576. wrapper: ["bootstrapHasError"],
  3577. defaultOptions: function (options, $scope) {
  3578. return {
  3579. templateOptions: {
  3580. // checkform: function(options) {
  3581. // if (options.model.requester) {
  3582. // options.value(options.model.requester);
  3583. // }
  3584. // },
  3585. },
  3586. };
  3587. },
  3588. controller: [
  3589. "$scope",
  3590. "api_user_data",
  3591. function ($scope, api_user_data) {
  3592. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3593. $scope.property = {
  3594. hw_change: $scope.to.loginUser,
  3595. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3596. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3597. };
  3598. if ($scope.$parent.$parent.$parent.model.assets) {
  3599. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3600. }
  3601. },
  3602. ],
  3603. });
  3604. //申请单信息
  3605. formlyConfigProvider.setType({
  3606. name: "ui-cmdbformimform",
  3607. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3608. wrapper: ["bootstrapHasError"],
  3609. defaultOptions: function (options, $scope) {
  3610. return {
  3611. templateOptions: {
  3612. // checkform: function(options) {
  3613. // if (options.model.requester) {
  3614. // options.value(options.model.requester);
  3615. // }
  3616. // },
  3617. },
  3618. };
  3619. },
  3620. controller: [
  3621. "$scope",
  3622. "api_user_data",
  3623. function ($scope, api_user_data) {
  3624. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3625. $scope.getininform = {
  3626. serialNumbe:
  3627. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3628. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3629. };
  3630. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3631. $scope.getininform.types = "新资产入库";
  3632. } else if (
  3633. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3634. ) {
  3635. $scope.getininform.types = "资产归还";
  3636. }
  3637. },
  3638. ],
  3639. });
  3640. //出库单信息
  3641. formlyConfigProvider.setType({
  3642. name: "ui-outinformation",
  3643. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3644. wrapper: ["bootstrapHasError"],
  3645. defaultOptions: function (options, $scope) {
  3646. return {
  3647. templateOptions: {
  3648. // checkform: function(options) {
  3649. // if (options.model.requester) {
  3650. // options.value(options.model.requester);
  3651. // }
  3652. // },
  3653. },
  3654. };
  3655. },
  3656. controller: [
  3657. "$scope",
  3658. "api_user_data",
  3659. function ($scope, api_user_data) {
  3660. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3661. $scope.getininform = {
  3662. serialNumbe:
  3663. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3664. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3665. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3666. sourceId:
  3667. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3668. describe:
  3669. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3670. };
  3671. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3672. $scope.getininform.types = "新设备领用出库";
  3673. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3674. $scope.getininform.types = "设备更换";
  3675. }
  3676. $scope.getininform.source_id =
  3677. $scope.$parent.$parent.$parent.model.source.value;
  3678. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3679. $scope.getininform.source = "事件";
  3680. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3681. $scope.getininform.source = "变更";
  3682. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3683. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3684. $scope.getininform.source = "其它";
  3685. }
  3686. },
  3687. ],
  3688. });
  3689. //资产附件上传
  3690. formlyConfigProvider.setType({
  3691. name: "ui-cmdbuplode",
  3692. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3693. wrapper: ["bootstrapHasError"],
  3694. defaultOptions: function (options, $scope) {
  3695. return {
  3696. templateOptions: {
  3697. // checkform: function(options) {
  3698. // if (options.model.requester) {
  3699. // options.value(options.model.requester);
  3700. // }
  3701. // },
  3702. },
  3703. };
  3704. },
  3705. controller: [
  3706. "$scope",
  3707. "$rootScope",
  3708. "$http",
  3709. "SweetAlert",
  3710. "FileUploader",
  3711. "api_user_data",
  3712. "i18nService",
  3713. "$modal",
  3714. "Restangular",
  3715. "api_configure_data",
  3716. "api_cmdb",
  3717. "api_cmdb_new",
  3718. "api_wechatfile",
  3719. "api_sysinfo",
  3720. function (
  3721. $scope,
  3722. $rootScope,
  3723. $http,
  3724. SweetAlert,
  3725. FileUploader,
  3726. api_user_data,
  3727. i18nService,
  3728. $modal,
  3729. Restangular,
  3730. api_configure_data,
  3731. api_cmdb,
  3732. api_cmdb_new,
  3733. api_wechatfile,
  3734. api_sysinfo
  3735. ) {
  3736. $scope.state = 1;
  3737. $scope.myData3all = [];
  3738. $scope.myData3 = [];
  3739. $scope.memoryfilterDatahao = {
  3740. idx: 0,
  3741. sum: 10,
  3742. };
  3743. $scope.selected = {
  3744. items: [],
  3745. };
  3746. $scope.interceptMydata = function (mydate, idx, sum) {
  3747. return mydate.slice(idx * sum, (idx + 1) * sum);
  3748. };
  3749. // $scope.importnext = function() {
  3750. // $scope.state = 2;
  3751. // event.preventDefault();
  3752. // }
  3753. $scope.workspaces = [];
  3754. $scope.options.templateOptions.getpush = function (item) {
  3755. $scope.workspaces = [];
  3756. if (item.gu) {
  3757. $scope.workspaces.push({
  3758. id: 1,
  3759. name: "固定资产",
  3760. active: true,
  3761. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3762. });
  3763. }
  3764. if (item.hao) {
  3765. $scope.workspaces.push({
  3766. id: 2,
  3767. name: "耗材资产",
  3768. active: true,
  3769. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3770. });
  3771. }
  3772. };
  3773. //获取附件列表
  3774. $scope.listAttachmen = function () {
  3775. to.ApiService.listAttachment(
  3776. to.listAttachmentUrl,
  3777. to.bindType,
  3778. bindId
  3779. ).then(function (result) {
  3780. var myData = Restangular.stripRestangular(result);
  3781. // $scope.listAttachmens = myData;
  3782. $scope.attachments = myData.data;
  3783. });
  3784. };
  3785. //附件列表
  3786. if ($scope.options.templateOptions.bindType) {
  3787. if (angular.isUndefined($scope.form.dropState)) {
  3788. $scope.form.dropState = false;
  3789. }
  3790. var to = $scope.options.templateOptions;
  3791. var bindId = $scope.model[to.bindType].processInstanceId;
  3792. $scope.listAttachmen();
  3793. }
  3794. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3795. // $scope.listAttachmen();
  3796. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3797. // $scope.listAttachmen();
  3798. // }
  3799. //附件下载
  3800. $scope.download = function (token, filename) {
  3801. var downUrl = to.ApiService.downloadAttachment(
  3802. to.downUrl,
  3803. token
  3804. ).getRequestedUrl();
  3805. // window.open(downUrl);
  3806. var a = document.createElement("a");
  3807. a.href = downUrl;
  3808. a.target = "_blank";
  3809. a.download = filename;
  3810. document.body.appendChild(a);
  3811. a.click();
  3812. };
  3813. //附件预览
  3814. $scope.view = function (id, previewUrl) {
  3815. if (previewUrl) {
  3816. window.open(previewUrl);
  3817. }
  3818. };
  3819. //下载资产模版
  3820. $scope.filenum = 0;
  3821. $scope.openmeans = function () {
  3822. var modalInstance = $modal.open({
  3823. templateUrl: "assets/views/means/tpl/meansdown.html",
  3824. controller: function ($scope, scope, $modalInstance) {
  3825. $scope.item = {};
  3826. $scope.title = "选择下载模版";
  3827. $scope.lable = "资产模版下载";
  3828. function foreachdata(my_datas) {
  3829. // angular.forEach(my_datas, function(item, index) {
  3830. // if (item.children && item.children.length > 0) {
  3831. // foreachdata(item.children);
  3832. // } else {
  3833. // my_datas[index].checks = true;
  3834. // }
  3835. // })
  3836. for (var i = 0; i < my_datas.length; i++) {
  3837. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3838. foreachdata(my_datas[i].children);
  3839. console.log($scope);
  3840. } else {
  3841. my_datas[i].checks = true;
  3842. }
  3843. }
  3844. }
  3845. function foreachtree(data) {
  3846. angular.forEach(data, function (item) {
  3847. // if (item.checks != true) {
  3848. item.checks = true;
  3849. item.expanded = true;
  3850. if (item.children && item.children.length > 0) {
  3851. foreachtree(item.children);
  3852. } else {
  3853. $scope.getslowtree.push(item);
  3854. }
  3855. // }
  3856. });
  3857. }
  3858. $scope.getslowtree = [];
  3859. $scope.slowtree = function (tree) {
  3860. foreachtree(tree);
  3861. return $scope.getslowtree;
  3862. };
  3863. $scope.all = function (c, v) {
  3864. //全选
  3865. if (c == true) {
  3866. $scope.formdashboard($scope.slowtree(v));
  3867. } else {
  3868. $scope.my_data_after = [];
  3869. angular.forEach($scope.my_data, function (item, index) {
  3870. $scope.my_data[index].checks = false;
  3871. $scope.my_data[index].expanded = false;
  3872. if (item.children && item.children.length > 0) {
  3873. angular.forEach(
  3874. item.children,
  3875. function (itemone, indexone) {
  3876. $scope.my_data[index].children[
  3877. indexone
  3878. ].checks = false;
  3879. $scope.my_data[index].children[
  3880. indexone
  3881. ].expanded = false;
  3882. if (itemone.children && itemone.children.length > 0) {
  3883. angular.forEach(
  3884. itemone.children,
  3885. function (itemtwo, indextwo) {
  3886. $scope.my_data[index].children[
  3887. indexone
  3888. ].children[indextwo].checks = false;
  3889. }
  3890. );
  3891. } else {
  3892. }
  3893. }
  3894. );
  3895. } else {
  3896. }
  3897. });
  3898. $scope.mydatacate = [];
  3899. $scope.getslowtree = [];
  3900. // }
  3901. }
  3902. };
  3903. // $scope.searchone = function(search) {
  3904. // angular.forEach($scope.my_data, function(item) {
  3905. // if (item.indexOf(search) > 0) {
  3906. // }
  3907. // })
  3908. // }
  3909. $scope.checkall = function () {
  3910. angular.forEach($scope.my_data, function (item, index) {
  3911. scope.my_data[index].checks = true;
  3912. });
  3913. };
  3914. $scope.selectitem = [];
  3915. $scope.choiceitem = function (item) {
  3916. // if (item.checkeds) {
  3917. // item.checkeds = false;
  3918. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3919. // // if ($scope.selectitem[i].id == item.id) {
  3920. // // $scope.selectitem.splice(i, 1)
  3921. // // }
  3922. // // }
  3923. // for (var i = 0; i < $scope.my_data_after; i++) {
  3924. // if ($scope.my_data_after[i].id == item.id) {
  3925. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3926. // // $scope.selectitem.splice(i, 1)
  3927. // }
  3928. // }
  3929. // } else {
  3930. // item.checkeds = true;
  3931. // $scope.selectitem.push(item)
  3932. // }
  3933. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3934. if ($scope.my_data_after[i].id == item.id) {
  3935. $scope.my_data_after[i].checkeds
  3936. ? ($scope.my_data_after[i].checkeds = false)
  3937. : ($scope.my_data_after[i].checkeds = true);
  3938. }
  3939. }
  3940. };
  3941. $scope.remove = function (removeitem) {
  3942. var realdat = angular.copy($scope.my_data_after);
  3943. // angular.extend(realdat, $scope.selectitem);
  3944. $scope.my_data_after = [];
  3945. angular.forEach(realdat, function (item) {
  3946. if (!item.checkeds) {
  3947. $scope.my_data_after.push(item);
  3948. }
  3949. });
  3950. $scope.mydatacate = angular.copy($scope.my_data_after);
  3951. };
  3952. $scope.try_async_loads = function (item, search) {
  3953. var fildatas = {
  3954. idx: 0,
  3955. sum: 1000,
  3956. };
  3957. $scope.my_data = [];
  3958. // $scope.try_async_load = true;
  3959. if (item) {
  3960. angular.extend(fildatas, item);
  3961. }
  3962. api_configure_data
  3963. .fetchDataList("ciclassify", fildatas)
  3964. .then(function (response) {
  3965. if (response.status == 200) {
  3966. var data = response.list;
  3967. var objects = [];
  3968. for (var i = 0; i < data.length; i++) {
  3969. var object = {};
  3970. object.id = data[i].id;
  3971. if (search) {
  3972. delete data[i].parent;
  3973. } else {
  3974. if (data[i].parent && data[i].parent.id != 0) {
  3975. object.parent = data[i].parent.id;
  3976. }
  3977. }
  3978. angular.extend(object, data[i]);
  3979. objects.push(object);
  3980. }
  3981. $scope.my_data = convertParentToChildList(objects);
  3982. $scope.tree_data = angular.copy($scope.my_data);
  3983. if ($scope.my_data.length > 0) {
  3984. $scope.try_async_load = false;
  3985. }
  3986. } else {
  3987. SweetAlert.swal({
  3988. title: "系统错误!",
  3989. text: "请刷新重试!",
  3990. type: "error",
  3991. });
  3992. }
  3993. });
  3994. };
  3995. function convertListToTree(data, treeMap) {
  3996. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3997. var root = null; //Initially set our loop to null
  3998. //loop over data
  3999. for (var i = 0; i < data.length; i++) {
  4000. var datum = data[i];
  4001. //each node will have children, so let's give it a "children" poperty
  4002. datum.children = [];
  4003. //add an entry for this node to the map so that any future children can
  4004. //lookup the parent
  4005. idToNodeMap[datum.id] = datum;
  4006. //Does this node have a parent?
  4007. // console.log("datum="+JSON.stringify(datum))
  4008. if (
  4009. typeof datum.parent === "undefined" ||
  4010. datum.parent === null
  4011. ) {
  4012. //Doesn't look like it, so this node is the root of the tree
  4013. root = datum;
  4014. treeMap[datum.id] = root;
  4015. } else {
  4016. //This node has a parent, so let's look it up using the id
  4017. parentNode = idToNodeMap[datum.parent.id];
  4018. //We don't need this property, so let's delete it.
  4019. // delete datum.parent;
  4020. //Let's add the current node as a child of the parent node.
  4021. parentNode.children.push(datum);
  4022. }
  4023. }
  4024. return root;
  4025. }
  4026. function convertParentToChildList(data) {
  4027. var treeMap = {};
  4028. var list = [];
  4029. convertListToTree(data, treeMap);
  4030. angular.forEach(treeMap, function (item) {
  4031. list.push(item);
  4032. });
  4033. return list;
  4034. }
  4035. function convertParentToChild(datato) {
  4036. var treeMapto = {};
  4037. var listto = [];
  4038. convertListToTree(datato, treeMapto);
  4039. angular.forEach(treeMapto, function (items) {
  4040. listto.push(items);
  4041. });
  4042. return listto;
  4043. }
  4044. $scope.try_async_loads();
  4045. $scope.searchdown = function (key) {
  4046. if (key && key != "") {
  4047. $scope.try_async_loads(
  4048. {
  4049. ciclassify: {
  4050. label: key,
  4051. },
  4052. },
  4053. "search"
  4054. );
  4055. } else {
  4056. $scope.try_async_loads();
  4057. }
  4058. // var mydatacatedown = angular.copy($scope.my_data);
  4059. // $scope.my_data = [];
  4060. // var objects = [];
  4061. // angular.forEach(mydatacatedown, function(item) {
  4062. // if (item.label.match(key)) {
  4063. // objects.push(item)
  4064. // } else {
  4065. // // $scope.my_data_after.push(item)
  4066. // }
  4067. // })
  4068. // $scope.my_data = convertParentToChildList(objects);
  4069. // $scope.tree_data = angular.copy($scope.my_data);
  4070. };
  4071. $scope.mydatacate = [];
  4072. $scope.searchup = function (key) {
  4073. // var mydatacate = angular.copy($scope.my_data_after);
  4074. $scope.my_data_after = [];
  4075. angular.forEach($scope.mydatacate, function (item) {
  4076. if (item.label.match(key)) {
  4077. $scope.my_data_after.push(item);
  4078. } else {
  4079. }
  4080. });
  4081. };
  4082. //角色树
  4083. $scope.my_tree = [];
  4084. $scope.tree_data_after = [];
  4085. $scope.my_data = [];
  4086. $scope.my_data_after = [];
  4087. $scope.formdashboard = function (item) {
  4088. $scope.my_data_after = [];
  4089. angular.forEach(item, function (infox) {
  4090. if (infox.children.length == 0) {
  4091. $scope.my_data_after.push(infox);
  4092. }
  4093. });
  4094. $scope.mydatacate = angular.copy($scope.my_data_after);
  4095. };
  4096. $scope.ok = function (item) {
  4097. $modalInstance.close(item);
  4098. };
  4099. $scope.cancel = function () {
  4100. $modalInstance.dismiss("cancel");
  4101. };
  4102. },
  4103. // size: 'sm',
  4104. resolve: {
  4105. scope: function () {
  4106. return $scope;
  4107. },
  4108. },
  4109. });
  4110. modalInstance.result.then(function (selectedItem) {
  4111. // $rootScope.isMask = true;
  4112. if (selectedItem) {
  4113. var type = 1;
  4114. var fildat = {
  4115. configure: selectedItem,
  4116. };
  4117. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4118. // // if (data.errno == 0) {
  4119. // var file = new Blob([data], {
  4120. // // 'Accept': '*/*'
  4121. // type: 'application/octet-stream'
  4122. // // type: 'application/vnd.ms-excel'
  4123. // });
  4124. // //trick to download store a file having its URL
  4125. // var fileURL = URL.createObjectURL(file);
  4126. // var a = document.createElement('a');
  4127. // a.href = fileURL;
  4128. // a.target = '_blank';
  4129. // a.download = "资产导入模版.xlsx";
  4130. // document.body.appendChild(a);
  4131. // a.click();
  4132. // // }
  4133. // })
  4134. $http({
  4135. url: api_configure_data
  4136. .downModels("export/cmdb", fildat)
  4137. .getRequestedUrl(),
  4138. method: "POST",
  4139. data: JSON.stringify(fildat),
  4140. headers: {
  4141. // 'Content-type': 'application/xls',
  4142. Accept: "*/*",
  4143. },
  4144. responseType: "arraybuffer",
  4145. })
  4146. .success(function (data, status, headers, config) {
  4147. $rootScope.isMask = false;
  4148. var file = new Blob([data], {
  4149. type: "application/octet-stream",
  4150. // type : 'application/vnd.ms-excel'
  4151. });
  4152. //trick to download store a file having its URL
  4153. var fileURL = URL.createObjectURL(file);
  4154. var a = document.createElement("a");
  4155. a.href = fileURL;
  4156. a.target = "_blank";
  4157. a.download = "资产导入模版.xlsx";
  4158. document.body.appendChild(a);
  4159. a.click();
  4160. })
  4161. .error(function (data, status, headers, config) {
  4162. // console.log(data);
  4163. $rootScope.isMask = false;
  4164. });
  4165. // break;
  4166. // }
  4167. // }
  4168. // }
  4169. // })
  4170. } else {
  4171. SweetAlert.swal(
  4172. {
  4173. title: "未选择资产分类!",
  4174. text: "请选择资产分类",
  4175. type: "error",
  4176. },
  4177. function () {
  4178. $rootScope.isMask = false;
  4179. }
  4180. );
  4181. }
  4182. // }
  4183. });
  4184. };
  4185. $scope.wrongdata = [];
  4186. var uploader = ($scope.uploader =
  4187. $scope.options.templateOptions.fileUploader);
  4188. var uploadermeans = ($scope.uploadermeans =
  4189. $scope.options.templateOptions.fileUploadermeans);
  4190. $scope.importopen = function () {
  4191. //导入触发事件
  4192. if (angular.isUndefined($scope.form.dropState)) {
  4193. $scope.form.dropState = false;
  4194. }
  4195. //附件上传数据
  4196. //$scope.options.templateOptions.uploader();
  4197. // FILTERS
  4198. uploader.filters.push({
  4199. name: "customFilter",
  4200. fn: function (item /*{File|FileLikeObject}*/, options) {
  4201. return this.queue.length < 2;
  4202. },
  4203. });
  4204. // CALLBACKS
  4205. uploader.onWhenAddingFileFailed = function (
  4206. item /*{File|FileLikeObject}*/,
  4207. filter,
  4208. options
  4209. ) {
  4210. console.info("onWhenAddingFileFailed", item, filter, options);
  4211. };
  4212. uploader.onAfterAddingFile = function (fileItem) {
  4213. console.info("onAfterAddingFile", fileItem);
  4214. };
  4215. uploader.onAfterAddingAll = function (addedFileItems) {
  4216. console.info("onAfterAddingAll", addedFileItems);
  4217. };
  4218. uploader.onBeforeUploadItem = function (item) {
  4219. console.info("onBeforeUploadItem", item);
  4220. };
  4221. uploader.onProgressItem = function (fileItem, progress) {
  4222. console.info("onProgressItem", fileItem, progress);
  4223. };
  4224. uploader.onProgressAll = function (progress) {
  4225. console.info("onProgressAll", progress);
  4226. };
  4227. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4228. // console.info('onSuccessItem', fileItem, response, status, headers);
  4229. // };
  4230. uploader.onErrorItem = function (
  4231. fileItem,
  4232. response,
  4233. status,
  4234. headers
  4235. ) {
  4236. console.info("onErrorItem", fileItem, response, status, headers);
  4237. };
  4238. uploader.onCancelItem = function (
  4239. fileItem,
  4240. response,
  4241. status,
  4242. headers
  4243. ) {
  4244. console.info("onCancelItem", fileItem, response, status, headers);
  4245. };
  4246. uploader.onCompleteItem = function (
  4247. fileItem,
  4248. response,
  4249. status,
  4250. headers
  4251. ) {
  4252. console.info("onCompleteItem", fileItem, response, status, headers);
  4253. };
  4254. uploader.onCompleteAll = function () {
  4255. console.info("onCompleteAll");
  4256. };
  4257. };
  4258. // $scope.importnext = function() {
  4259. // $scope.state = 2;
  4260. // event.preventDefault();
  4261. // }
  4262. $scope.importnext = function () {
  4263. event.preventDefault();
  4264. // $rootScope.isMask = true;
  4265. $rootScope.loading = true;
  4266. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4267. uploader.onBeforeUploadItem = function (item) {
  4268. angular.extend(item.headers, $rootScope.getSession());
  4269. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4270. // if (item.index > 1) {
  4271. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4272. // }
  4273. // item.index = 1;
  4274. item.formData = [
  4275. {
  4276. filename: item.file.name,
  4277. },
  4278. ];
  4279. console.info("onBeforeUploadItem", item);
  4280. };
  4281. uploader.uploadAll();
  4282. uploader.onSuccessItem = function (
  4283. fileItem,
  4284. response,
  4285. status,
  4286. headers
  4287. ) {
  4288. if (response.status == 200) {
  4289. $scope.wrongdata = [];
  4290. $rootScope.loading = false;
  4291. if (response.abnormal) {
  4292. $scope.state = 2;
  4293. angular.forEach(response.msg, function (item) {
  4294. $scope.wrongdata.push({
  4295. name: item.assetName,
  4296. line: item.row,
  4297. cmdbname: item.name,
  4298. errotip: [
  4299. {
  4300. label: item.msg,
  4301. },
  4302. ],
  4303. });
  4304. });
  4305. } else {
  4306. $scope.state = 3;
  4307. }
  4308. } else {
  4309. $rootScope.loading = false;
  4310. $scope.state = 2;
  4311. }
  4312. };
  4313. };
  4314. $scope.clearItems = function () {
  4315. //重新选择文件时,清空队列,达到覆盖文件的效果
  4316. uploader.clearQueue();
  4317. // uploader.remove();
  4318. // uploader.cancel();
  4319. // uploader.onChange();
  4320. };
  4321. uploader.onAfterAddingFile = function (fileItem) {
  4322. $scope.fileItem = fileItem._file;
  4323. // $scope.$apply();
  4324. // $scope.fileItem = filenum;
  4325. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4326. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4327. $scope.filenum++;
  4328. };
  4329. uploader.onSuccessItem = function (
  4330. fileItem,
  4331. response,
  4332. status,
  4333. headers
  4334. ) {
  4335. $scope.uploadStatus = true; //上传成功则把状态改为true
  4336. // alert(response.path);
  4337. };
  4338. $scope.importnext = function () {
  4339. event.preventDefault();
  4340. // uploader.onChange();
  4341. $rootScope.loading = true;
  4342. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4343. uploader.onBeforeUploadItem = function (item) {
  4344. angular.extend(item.headers, $rootScope.getSession());
  4345. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4346. // if (item.index > 1) {
  4347. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4348. // }
  4349. // item.index = 1;
  4350. item.formData = [
  4351. {
  4352. filename: item.file.name,
  4353. },
  4354. ];
  4355. console.info("onBeforeUploadItem", item);
  4356. };
  4357. uploader.uploadAll();
  4358. uploader.onSuccessItem = function (
  4359. fileItem,
  4360. response,
  4361. status,
  4362. headers
  4363. ) {
  4364. if (response.status == 200) {
  4365. $scope.wrongdata = [];
  4366. // uploader.queue = [];
  4367. $rootScope.loading = false;
  4368. if (response.abnormal) {
  4369. $scope.state = 2;
  4370. uploader.clearQueue();
  4371. angular.forEach(response.msg, function (item) {
  4372. $scope.wrongdata.push({
  4373. name: item.assetName,
  4374. line: item.row,
  4375. cmdbname: item.name,
  4376. errotip: [
  4377. {
  4378. label: item.msg,
  4379. },
  4380. ],
  4381. });
  4382. });
  4383. } else {
  4384. $scope.state = 3;
  4385. }
  4386. } else {
  4387. uploader.clearQueue();
  4388. $rootScope.loading = false;
  4389. $scope.state = 2;
  4390. }
  4391. };
  4392. };
  4393. var setAllInactive = function () {
  4394. angular.forEach($scope.workspaces, function (workspace) {
  4395. workspace.active = false;
  4396. });
  4397. };
  4398. //添加
  4399. var addNewWorkspace = function (name, contentUrl) {
  4400. var id = $scope.workspaces.length + 1;
  4401. $scope.workspaces.push({
  4402. id: id,
  4403. name: name,
  4404. active: true,
  4405. contentUrl: "main/html/content.html",
  4406. });
  4407. };
  4408. //关闭
  4409. $scope.closeopen = function (closedata) {
  4410. event.preventDefault();
  4411. angular.forEach($scope.workspaces, function (item, index) {
  4412. if (closedata.id == item.id) {
  4413. if (closedata.id == 1) {
  4414. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4415. } else {
  4416. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4417. }
  4418. $scope.workspaces.splice(index, 1);
  4419. }
  4420. });
  4421. };
  4422. // $scope.workspaces = [
  4423. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4424. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4425. // ];
  4426. $scope.addWorkspace = function (contentUrl, name) {
  4427. setAllInactive();
  4428. addNewWorkspace(name, contentUrl);
  4429. };
  4430. // $rootScope.addWorkspace = $scope.addWorkspace;
  4431. $scope.close = function (idNumber) {
  4432. var index = 0; //记录当前元素下标
  4433. angular.forEach($scope.workspaces, function (workspace) {
  4434. if (workspace.id === idNumber) {
  4435. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4436. }
  4437. index++;
  4438. });
  4439. };
  4440. //grid2
  4441. $scope.langs = i18nService.getAllLangs();
  4442. $scope.lang = "zh-cn";
  4443. i18nService.setCurrentLang($scope.lang);
  4444. $scope.gridOptions2 = {};
  4445. $scope.gridOptions2.data = "myData3";
  4446. $scope.gridOptions2.enableColumnResizing = true;
  4447. $scope.gridOptions2.enableFiltering = false;
  4448. $scope.gridOptions2.enableGridMenu = false;
  4449. $scope.gridOptions2.showGridFooter = true;
  4450. $scope.gridOptions2.showColumnFooter = false;
  4451. $scope.gridOptions2.fastWatch = true;
  4452. $scope.gridOptions2.useExternalFiltering = true;
  4453. $scope.gridOptions2.useExternalPagination = true;
  4454. $scope.gridOptions2.paginationPageSizes = [10];
  4455. $scope.gridOptions2.paginationPageSize = 10;
  4456. $scope.gridOptions2.multiSelect = false;
  4457. // $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>";
  4458. $scope.gridOptions2.columnDefs = [
  4459. {
  4460. name: "item",
  4461. displayName: "序号",
  4462. width: 120,
  4463. },
  4464. {
  4465. name: "name",
  4466. displayName: "耗材名称",
  4467. width: 80,
  4468. enableFiltering: false,
  4469. },
  4470. {
  4471. name: "model",
  4472. displayName: "品牌/型号",
  4473. width: 100,
  4474. enableFiltering: false,
  4475. },
  4476. {
  4477. name: "Specifications",
  4478. displayName: "规格",
  4479. width: 150,
  4480. enableFiltering: false,
  4481. },
  4482. {
  4483. name: "sum",
  4484. displayName: "数量",
  4485. enableFiltering: false,
  4486. },
  4487. {
  4488. name: "操作",
  4489. cellTemplate:
  4490. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4491. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4492. "</div></div>",
  4493. enableFiltering: false,
  4494. },
  4495. ];
  4496. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4497. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4498. $scope.myData3all = JSON.parse(
  4499. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4500. );
  4501. for (var i = 0; i < $scope.myData3all.length; i++) {
  4502. $scope.myData3all[i]["item"] =
  4503. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4504. }
  4505. // $scope.model.consumables = $scope.myDataone;
  4506. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4507. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4508. $scope.model.applicationForm.consumables = $scope.myData3all;
  4509. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4510. $scope.options.templateOptions.getpush({
  4511. hao: true,
  4512. gu: true,
  4513. });
  4514. } else {
  4515. $scope.options.templateOptions.getpush({
  4516. hao: true,
  4517. });
  4518. }
  4519. } else {
  4520. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4521. $scope.options.templateOptions.getpush({
  4522. gu: true,
  4523. });
  4524. }
  4525. }
  4526. }
  4527. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4528. $scope.changecai = function (item) {
  4529. event.preventDefault();
  4530. var modalInstance = $modal.open({
  4531. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4532. controller: function ($scope, $modalInstance) {
  4533. $scope.title = "修改耗材数量";
  4534. $scope.consumptive = angular.copy(item);
  4535. $scope.ok = function () {
  4536. $modalInstance.close($scope.consumptive);
  4537. };
  4538. $scope.cancel = function () {
  4539. $modalInstance.dismiss("cancel");
  4540. };
  4541. },
  4542. size: "sm",
  4543. });
  4544. modalInstance.result.then(function (selectedItem) {
  4545. // angular.forEach($scope.myData3, function(items, index) {
  4546. // if (items.id == selectedItem.id) {
  4547. // $scope.myData3[index] = selectedItem;
  4548. // }
  4549. // })
  4550. // // $scope.myData3.push(selectedItem);
  4551. // $scope.model.applicationForm.consumables = $scope.myData3;
  4552. angular.forEach($scope.myData3all, function (items, index) {
  4553. if (
  4554. items.modelid == selectedItem.modelid &&
  4555. items.nameid == selectedItem.nameid &&
  4556. items.Specificationsid == selectedItem.Specificationsid
  4557. ) {
  4558. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4559. angular.extend($scope.myData3all[index], selectedItem);
  4560. }
  4561. });
  4562. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4563. $scope.myData3 = $scope.interceptMydata(
  4564. $scope.myData3all,
  4565. $scope.memoryfilterDatahao.idx,
  4566. 10
  4567. );
  4568. $scope.model.applicationForm.consumables = $scope.myData3all;
  4569. });
  4570. };
  4571. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4572. $scope.gridApi = gridApi;
  4573. gridApi.pagination.on.paginationChanged(
  4574. $scope,
  4575. function (newPage, pageSize) {
  4576. // var filtersData = $scope.memoryfilterDatahao;
  4577. // filtersData.idx = newPage - 1;
  4578. // filtersData.sum = pageSize;
  4579. // $scope.loadData(filtersData);
  4580. $scope.memoryfilterDatahao.idx = newPage - 1;
  4581. $scope.memoryfilterDatahao.sum = pageSize;
  4582. $scope.myData3 = $scope.interceptMydata(
  4583. $scope.myData3all,
  4584. $scope.memoryfilterDatahao.idx,
  4585. 10
  4586. );
  4587. }
  4588. );
  4589. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4590. $scope.selected.items = data.entity;
  4591. //console.log(data);
  4592. });
  4593. gridApi.selection.on.rowSelectionChangedBatch(
  4594. $scope,
  4595. function (data) {
  4596. $scope.selected.items = data.entity;
  4597. //console.log(data);
  4598. }
  4599. );
  4600. gridApi.core.on.filterChanged($scope, function () {
  4601. var grid = this.grid;
  4602. var filtersData = {
  4603. idx: 0,
  4604. sum: 10,
  4605. };
  4606. $scope.memoryfilterDatahao = filtersData;
  4607. // $scope.loadData(filtersData);
  4608. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4609. // $scope.memoryfilterDatahao.sum = pageSize;
  4610. $scope.myData3 = $scope.interceptMydata(
  4611. $scope.myData3all,
  4612. $scope.memoryfilterDatahao.idx,
  4613. 10
  4614. );
  4615. });
  4616. };
  4617. $scope.haocaiopen = function (items) {
  4618. event.preventDefault();
  4619. var modalInstance = $modal.open({
  4620. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4621. controller: function ($scope, $modalInstance, SweetAlert) {
  4622. $scope.consumptive = {};
  4623. $scope.title = "新增耗材";
  4624. if (items.name) {
  4625. $scope.consumptive.name = items.name.name;
  4626. }
  4627. $scope.clearNoNum = function (obj, attr) {
  4628. //先把非数字的都替换掉,除了数字和.
  4629. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4630. //必须保证第一个为数字而不是.
  4631. obj[attr] = obj[attr].replace(/^\./g, "");
  4632. //保证只有出现一个.而没有多个.
  4633. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4634. //保证.只出现一次,而不能出现两次以上
  4635. obj[attr] = obj[attr]
  4636. .replace(".", "$#$")
  4637. .replace(/\./g, "")
  4638. .replace("$#$", ".");
  4639. //小于最大值
  4640. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4641. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4642. // obj[attr] = '';
  4643. // }
  4644. };
  4645. $scope.ok = function (item) {
  4646. // if (item.name && item.model && item.Specifications && item.sum) {
  4647. if (
  4648. item.name &&
  4649. item.model &&
  4650. JSON.stringify(item.model) != "{}" &&
  4651. item.Specifications &&
  4652. JSON.stringify(item.Specifications) != "{}" &&
  4653. item.sum
  4654. ) {
  4655. $modalInstance.close(item);
  4656. } else {
  4657. SweetAlert.swal({
  4658. title: "数据填写不完整!",
  4659. text: "请检查数据然后提交!",
  4660. type: "error",
  4661. });
  4662. }
  4663. };
  4664. $scope.cancel = function () {
  4665. $modalInstance.dismiss("cancel");
  4666. };
  4667. },
  4668. size: "sm",
  4669. resolve: {
  4670. SweetAlert: function () {
  4671. return SweetAlert;
  4672. },
  4673. },
  4674. });
  4675. modalInstance.result.then(function (selectedItem) {
  4676. api_sysinfo
  4677. .addData("dictionaryTree", {
  4678. // "type": "list",
  4679. key: "haocaifenlei",
  4680. name: selectedItem.name,
  4681. parent: selectedItem.id,
  4682. value: selectedItem.name,
  4683. deleted: false,
  4684. level: 1,
  4685. })
  4686. .then(function (data) {
  4687. // $scope.haocainame.name = data.list;
  4688. api_sysinfo
  4689. .addData("dictionaryTree", {
  4690. // "type": "list",
  4691. key: "pinpai",
  4692. name: selectedItem.model,
  4693. parent: data.id,
  4694. value: selectedItem.model,
  4695. deleted: false,
  4696. level: 2,
  4697. })
  4698. .then(function (data) {
  4699. // $scope.haocainame = data.list;
  4700. });
  4701. api_sysinfo
  4702. .addData({
  4703. // "type": "list",
  4704. key: "guige",
  4705. name: selectedItem.Specifications,
  4706. parent: data.id,
  4707. value: selectedItem.Specifications,
  4708. deleted: false,
  4709. level: 2,
  4710. })
  4711. .then(function (data) {
  4712. // $scope.haocainame = data.list;
  4713. });
  4714. });
  4715. // $scope.myData3.push(selectedItem);
  4716. // for (var i = 0; i < $scope.myData3.length; i++) {
  4717. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4718. // }
  4719. // $scope.model.applicationForm.consumables = $scope.myData3;
  4720. $scope.myData3all.push(selectedItem);
  4721. for (var i = 0; i < $scope.myData3all.length; i++) {
  4722. $scope.myData3all[i]["item"] = i + 1;
  4723. }
  4724. // $scope.model.consumables = $scope.myDataone;
  4725. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4726. $scope.myData3 = $scope.interceptMydata(
  4727. $scope.myData3all,
  4728. $scope.memoryfilterDatahao.idx,
  4729. 10
  4730. );
  4731. $scope.model.applicationForm.consumables = $scope.myData3all;
  4732. });
  4733. };
  4734. $scope.haocaiadd = function () {
  4735. event.preventDefault();
  4736. var modalInstance = $modal.open({
  4737. templateUrl:
  4738. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4739. controller: function (
  4740. $scope,
  4741. scope,
  4742. $modalInstance,
  4743. api_wechatfile,
  4744. SweetAlert,
  4745. api_cmdb3
  4746. ) {
  4747. $scope.haocainame = [];
  4748. $scope.pinpai = [];
  4749. $scope.guige = [];
  4750. $scope.consumptive = {};
  4751. $scope.consumpall = {};
  4752. $scope.title = "添加耗材";
  4753. api_wechatfile
  4754. .getDictionary({
  4755. key: "haocaifenlei",
  4756. type: "tree",
  4757. })
  4758. .then(function (data) {
  4759. $scope.haocainame = data;
  4760. });
  4761. $scope.clearNoNum = function (obj, attr) {
  4762. //先把非数字的都替换掉,除了数字和.
  4763. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4764. //必须保证第一个为数字而不是.
  4765. obj[attr] = obj[attr].replace(/^\./g, "");
  4766. //保证只有出现一个.而没有多个.
  4767. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4768. //保证.只出现一次,而不能出现两次以上
  4769. obj[attr] = obj[attr]
  4770. .replace(".", "$#$")
  4771. .replace(/\./g, "")
  4772. .replace("$#$", ".");
  4773. //小于最大值
  4774. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4775. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4776. // obj[attr] = '';
  4777. // }
  4778. };
  4779. $scope.onChange = function (parent) {
  4780. $scope.consumptive.model = {};
  4781. $scope.consumptive.Specifications = {};
  4782. api_wechatfile
  4783. .getDictionaryForList({
  4784. key: "pinpai",
  4785. parent: parent.id,
  4786. })
  4787. .then(function (data) {
  4788. $scope.pinpai = data;
  4789. });
  4790. api_wechatfile
  4791. .getDictionaryForList({
  4792. key: "guige",
  4793. parent: parent.id,
  4794. })
  4795. .then(function (data) {
  4796. $scope.guige = data;
  4797. });
  4798. };
  4799. $scope.addhaocai = function () {
  4800. $modalInstance.dismiss("cancel");
  4801. scope.haocaiopen($scope.consumptive);
  4802. };
  4803. $scope.ok = function (item) {
  4804. var items = {};
  4805. var submittrue = true;
  4806. if (
  4807. item.name &&
  4808. item.model &&
  4809. JSON.stringify(item.model) != "{}" &&
  4810. item.Specifications &&
  4811. JSON.stringify(item.Specifications) != "{}" &&
  4812. item.sum
  4813. ) {
  4814. items = {
  4815. modelid: item.model.id,
  4816. nameid: item.name.id,
  4817. Specificationsid: item.Specifications.id,
  4818. name: item.name.name,
  4819. model: item.model.name,
  4820. Specifications: item.Specifications.name,
  4821. sum: item.sum,
  4822. };
  4823. angular.forEach(scope.myData3all, function (itemsdata) {
  4824. if (
  4825. item.model.id == itemsdata.modelid &&
  4826. item.name.id == itemsdata.nameid &&
  4827. item.Specifications.id == itemsdata.Specificationsid
  4828. ) {
  4829. submittrue = false;
  4830. }
  4831. });
  4832. if (submittrue) {
  4833. $modalInstance.close(items);
  4834. } else {
  4835. SweetAlert.swal({
  4836. title: "该耗材已有添加",
  4837. text: "请检查数据然后提交!",
  4838. type: "error",
  4839. });
  4840. }
  4841. } else {
  4842. SweetAlert.swal({
  4843. title: "数据填写不完整!",
  4844. text: "请检查数据然后提交!",
  4845. type: "error",
  4846. });
  4847. }
  4848. // var isold = false;
  4849. // if (item.name && item.model && item.Specifications && item.sum) {
  4850. // for (var i = 0; i < scope.myData3all.length; i++) {
  4851. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4852. // isold = true;
  4853. // }
  4854. // }
  4855. // if (isold) {
  4856. // SweetAlert.swal({
  4857. // title: "该耗材已添加!",
  4858. // text: "请不要重复添加耗材!",
  4859. // type: "error"
  4860. // });
  4861. // } else {
  4862. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4863. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4864. // $scope.consumpall.sum = item.sum;
  4865. // delete $scope.consumpall.brandModel;
  4866. // delete $scope.consumpall.specification;
  4867. // $modalInstance.close($scope.consumpall);
  4868. // }
  4869. // } else {
  4870. // SweetAlert.swal({
  4871. // title: "数据填写不完整!",
  4872. // text: "请检查数据然后提交!",
  4873. // type: "error"
  4874. // });
  4875. // }
  4876. };
  4877. $scope.cancel = function () {
  4878. $modalInstance.dismiss("cancel");
  4879. };
  4880. },
  4881. size: "sm",
  4882. resolve: {
  4883. scope: function () {
  4884. return $scope;
  4885. },
  4886. },
  4887. });
  4888. modalInstance.result.then(function (selectedItem) {
  4889. $scope.myData3all.push(selectedItem);
  4890. for (var i = 0; i < $scope.myData3all.length; i++) {
  4891. $scope.myData3all[i]["item"] = i + 1;
  4892. }
  4893. // $scope.model.consumables = $scope.myDataone;
  4894. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4895. $scope.myData3 = $scope.interceptMydata(
  4896. $scope.myData3all,
  4897. $scope.memoryfilterDatahao.idx,
  4898. 10
  4899. );
  4900. $scope.model.applicationForm.consumables = $scope.myData3all;
  4901. });
  4902. };
  4903. $scope.onDblClick = function (data, event) {
  4904. $scope.selectButtonClick(data, event);
  4905. };
  4906. // $scope.memoryfilterDatahao = {
  4907. // "idx": 0,
  4908. // "sum": 10,
  4909. // }
  4910. // $scope.loadData = function(filterData) {};
  4911. // $scope.title = title;
  4912. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4913. $scope.options.templateOptions.transform(
  4914. $scope.options,
  4915. $rootScope,
  4916. $scope
  4917. );
  4918. }
  4919. },
  4920. ],
  4921. });
  4922. //归还设备耗材tab
  4923. formlyConfigProvider.setType({
  4924. name: "ui-cmdbreturntab",
  4925. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4926. wrapper: ["bootstrapHasError"],
  4927. defaultOptions: function (options, $scope) {
  4928. return {
  4929. templateOptions: {
  4930. // checkform: function(options) {
  4931. // if (options.model.requester) {
  4932. // options.value(options.model.requester);
  4933. // }
  4934. // },
  4935. },
  4936. };
  4937. },
  4938. controller: [
  4939. "$scope",
  4940. "$modal",
  4941. "api_user_data",
  4942. "i18nService",
  4943. "api_wechatfile",
  4944. "api_cmdb3",
  4945. function (
  4946. $scope,
  4947. $modal,
  4948. api_user_data,
  4949. i18nService,
  4950. api_wechatfile,
  4951. api_cmdb3
  4952. ) {
  4953. var setAllInactive = function () {
  4954. angular.forEach($scope.workspaces, function (workspace) {
  4955. workspace.active = false;
  4956. });
  4957. };
  4958. $scope.memoryfilterData = {
  4959. idx: 0,
  4960. sum: 10,
  4961. };
  4962. //添加
  4963. var addNewWorkspace = function (name, contentUrl) {
  4964. var id = $scope.workspaces.length + 1;
  4965. $scope.workspaces.push({
  4966. id: id,
  4967. name: name,
  4968. active: true,
  4969. contentUrl: "main/html/content.html",
  4970. });
  4971. };
  4972. $scope.workspaces = [
  4973. {
  4974. id: 1,
  4975. name: "归还设备",
  4976. active: true,
  4977. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4978. },
  4979. {
  4980. id: 2,
  4981. name: "归还耗材",
  4982. active: true,
  4983. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4984. },
  4985. ];
  4986. $scope.addWorkspace = function (contentUrl, name) {
  4987. setAllInactive();
  4988. addNewWorkspace(name, contentUrl);
  4989. };
  4990. // $rootScope.addWorkspace = $scope.addWorkspace;
  4991. $scope.close = function (idNumber) {
  4992. var index = 0; //记录当前元素下标
  4993. angular.forEach($scope.workspaces, function (workspace) {
  4994. if (workspace.id === idNumber) {
  4995. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4996. }
  4997. index++;
  4998. });
  4999. };
  5000. $scope.memoryfilterDataguishe = {
  5001. idx: 0,
  5002. sum: 10,
  5003. };
  5004. //grid1
  5005. $scope.langs = i18nService.getAllLangs();
  5006. $scope.lang = "zh-cn";
  5007. i18nService.setCurrentLang($scope.lang);
  5008. $scope.gridOptions1 = {};
  5009. $scope.gridOptions1.data = "myData1";
  5010. $scope.gridOptions1.enableColumnResizing = true;
  5011. $scope.gridOptions1.enableFiltering = false;
  5012. $scope.gridOptions1.enableGridMenu = false;
  5013. $scope.gridOptions1.showGridFooter = true;
  5014. $scope.gridOptions1.showColumnFooter = false;
  5015. $scope.gridOptions1.fastWatch = true;
  5016. $scope.gridOptions1.useExternalFiltering = true;
  5017. $scope.gridOptions1.useExternalPagination = true;
  5018. $scope.gridOptions1.paginationPageSizes = [10];
  5019. $scope.gridOptions1.paginationPageSize = 10;
  5020. $scope.gridOptions1.multiSelect = false;
  5021. // $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>";
  5022. $scope.gridOptions1.columnDefs = [
  5023. {
  5024. name: "item",
  5025. displayName: "序号",
  5026. width: 120,
  5027. },
  5028. {
  5029. name: "props.hw_cifilterClassic",
  5030. displayName: "设备类型",
  5031. width: 150,
  5032. enableFiltering: false,
  5033. },
  5034. {
  5035. name: "props.hw_mingcheng",
  5036. displayName: "设备名称",
  5037. width: 180,
  5038. enableFiltering: false,
  5039. },
  5040. {
  5041. name: "uuid",
  5042. displayName: "设备编号",
  5043. width: 180,
  5044. enableFiltering: false,
  5045. },
  5046. {
  5047. name: "props.hw_state",
  5048. width: 150,
  5049. displayName: "状态",
  5050. enableFiltering: false,
  5051. },
  5052. {
  5053. name: "操作",
  5054. cellTemplate:
  5055. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5056. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5057. "</div></div>",
  5058. enableFiltering: false,
  5059. },
  5060. ];
  5061. // $scope.selectButtonClick
  5062. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5063. $scope.gridApi = gridApi;
  5064. gridApi.pagination.on.paginationChanged(
  5065. $scope,
  5066. function (newPage, pageSize) {
  5067. // var filtersData = $scope.memoryfilterData;
  5068. // filtersData.idx = newPage - 1;
  5069. // filtersData.sum = pageSize;
  5070. // $scope.loadData(filtersData);
  5071. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5072. $scope.memoryfilterDataguishe.sum = pageSize;
  5073. $scope.myData1 = $scope.interceptMydata(
  5074. $scope.myData2all,
  5075. $scope.memoryfilterDataguishe.idx,
  5076. 10
  5077. );
  5078. }
  5079. );
  5080. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5081. $scope.selected.items = data.entity;
  5082. //console.log(data);
  5083. });
  5084. gridApi.selection.on.rowSelectionChangedBatch(
  5085. $scope,
  5086. function (data) {
  5087. $scope.selected.items = data.entity;
  5088. //console.log(data);
  5089. }
  5090. );
  5091. gridApi.core.on.filterChanged($scope, function () {
  5092. // var grid = this.grid;
  5093. // var filtersData = {
  5094. // idx: 0,
  5095. // sum: 20,
  5096. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5097. // };
  5098. // angular.forEach(grid.columns, function(item) {
  5099. // if (item.enableFiltering) {
  5100. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5101. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5102. // if (angular.isUndefined(filtersData['user'])) {
  5103. // filtersData['user'] = {};
  5104. // }
  5105. // filtersData['user'][item.field] = item.filters[0].term;
  5106. // }
  5107. // }
  5108. // });
  5109. // $scope.memoryfilterData = filtersData;
  5110. // $scope.loadData(filtersData);
  5111. });
  5112. };
  5113. $scope.changegu = function (item) {
  5114. event.preventDefault();
  5115. var modalInstance = $modal.open({
  5116. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5117. controller: function ($scope, $modalInstance) {
  5118. $scope.title = "修改设备状态";
  5119. $scope.hw_state = {};
  5120. if (item.status) {
  5121. $scope.hw_state.name = item.hw_state;
  5122. }
  5123. // $scope.consumptive = item;
  5124. $scope.stateshe = [
  5125. {
  5126. id: 2,
  5127. name: "在库",
  5128. },
  5129. {
  5130. id: 4,
  5131. name: "报修",
  5132. },
  5133. {
  5134. id: 3,
  5135. name: "报废",
  5136. },
  5137. ];
  5138. $scope.ok = function (item) {
  5139. $modalInstance.close($scope.hw_state);
  5140. };
  5141. $scope.cancel = function () {
  5142. $modalInstance.dismiss("cancel");
  5143. };
  5144. },
  5145. size: "sm",
  5146. });
  5147. modalInstance.result.then(function (selectedItem) {
  5148. angular.forEach($scope.myData1, function (items, index) {
  5149. if (items.id == item.id) {
  5150. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5151. }
  5152. });
  5153. $scope.model.assets = $scope.myData1;
  5154. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5155. $scope.model.assets;
  5156. });
  5157. };
  5158. $scope.onDblClick = function (data, event) {
  5159. $scope.selectButtonClick(data, event);
  5160. };
  5161. $scope.memoryfilterData = {
  5162. idx: 0,
  5163. sum: 10,
  5164. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5165. };
  5166. // $scope.myData = {};
  5167. $scope.loadData = function (filterData) { };
  5168. // $scope.title = title;
  5169. $scope.loadData({
  5170. idx: 0,
  5171. sum: 10,
  5172. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5173. });
  5174. $scope.selected = {
  5175. items: [],
  5176. };
  5177. $scope.myData2 = [];
  5178. $scope.consumptive = {};
  5179. $scope.myDataguibeiall = [];
  5180. $scope.haocaiopen = function (items) {
  5181. event.preventDefault();
  5182. var modalInstance = $modal.open({
  5183. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5184. controller: function (
  5185. $scope,
  5186. $modalInstance,
  5187. SweetAlert,
  5188. api_wechatfile,
  5189. api_sysinfo
  5190. ) {
  5191. $scope.consumptive = {};
  5192. $scope.title = "新增耗材";
  5193. if (items.name) {
  5194. $scope.consumptive.name = items.name.name;
  5195. }
  5196. $scope.ok = function (item) {
  5197. if (
  5198. item.name &&
  5199. item.model &&
  5200. JSON.stringify(item.model) != "{}" &&
  5201. item.Specifications &&
  5202. JSON.stringify(item.Specifications) != "{}" &&
  5203. item.sum
  5204. ) {
  5205. $modalInstance.close(item);
  5206. } else {
  5207. SweetAlert.swal({
  5208. title: "数据填写不完整!",
  5209. text: "请检查数据然后提交!",
  5210. type: "error",
  5211. });
  5212. }
  5213. };
  5214. $scope.cancel = function () {
  5215. $modalInstance.dismiss("cancel");
  5216. };
  5217. },
  5218. size: "sm",
  5219. });
  5220. modalInstance.result.then(function (selectedItem) {
  5221. api_sysinfo
  5222. .addData({
  5223. type: "list",
  5224. key: "haocaifenlei",
  5225. name: selectedItem.name,
  5226. parent: selectedItem.id,
  5227. value: "1",
  5228. })
  5229. .then(function (data) {
  5230. // $scope.haocainame.name = data.list;
  5231. api_wechatfile
  5232. .addDictionary({
  5233. type: "list",
  5234. key: "pinpai",
  5235. name: selectedItem.model,
  5236. parent: data.id,
  5237. value: "1",
  5238. })
  5239. .then(function (data) {
  5240. // $scope.haocainame = data.list;
  5241. });
  5242. api_wechatfile
  5243. .addDictionary({
  5244. type: "list",
  5245. key: "guige",
  5246. name: selectedItem.Specifications,
  5247. parent: data.id,
  5248. value: "1",
  5249. })
  5250. .then(function (data) {
  5251. // $scope.haocainame = data.list;
  5252. });
  5253. });
  5254. $scope.myData2.push(selectedItem);
  5255. for (var i = 0; i < $scope.myData2.length; i++) {
  5256. $scope.myData2[i]["item"] =
  5257. i + 1 + $scope.memoryfilterData.idx * 10;
  5258. }
  5259. // $scope.model.applicationForm.consumables = $scope.myData2;
  5260. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5261. if (items.id == selectedItem.id) {
  5262. $scope.myDataguibeiall.splice(index, 1);
  5263. }
  5264. });
  5265. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5266. $scope.model.consumables = $scope.myDataguibeiall;
  5267. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5268. $scope.model.consumables;
  5269. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5270. });
  5271. };
  5272. //grid2
  5273. $scope.langs = i18nService.getAllLangs();
  5274. $scope.lang = "zh-cn";
  5275. i18nService.setCurrentLang($scope.lang);
  5276. $scope.gridOptions2 = {};
  5277. $scope.gridOptions2.data = "myData2";
  5278. $scope.gridOptions2.enableColumnResizing = true;
  5279. $scope.gridOptions2.enableFiltering = false;
  5280. $scope.gridOptions2.enableGridMenu = false;
  5281. $scope.gridOptions2.showGridFooter = true;
  5282. $scope.gridOptions2.showColumnFooter = false;
  5283. $scope.gridOptions2.fastWatch = true;
  5284. $scope.gridOptions2.useExternalFiltering = true;
  5285. $scope.gridOptions2.useExternalPagination = true;
  5286. $scope.gridOptions2.paginationPageSizes = [10];
  5287. $scope.gridOptions2.paginationPageSize = 10;
  5288. $scope.gridOptions2.multiSelect = false;
  5289. // $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>";
  5290. $scope.modelcons = {};
  5291. $scope.modelass = {};
  5292. $scope.myData2all = [];
  5293. $scope.myData1all = [];
  5294. $scope.memoryfilterDatagui = {
  5295. idx: 0,
  5296. sum: 10,
  5297. };
  5298. setInterval(function () {
  5299. if ($scope.model.assets) {
  5300. if (
  5301. $scope.model.assets != $scope.modelass &&
  5302. typeof $scope.model.assets == "string"
  5303. ) {
  5304. $scope.modelass = $scope.model.assets;
  5305. if (JSON.stringify($scope.model.assets) == "{}") {
  5306. $scope.model.assets = [];
  5307. } else {
  5308. $scope.model.assets = JSON.parse($scope.model.assets);
  5309. }
  5310. // $scope.myData1 = $scope.model.assets;
  5311. // for (var i = 0; i < $scope.myData1.length; i++) {
  5312. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5313. // }
  5314. $scope.myData1all = $scope.model.assets;
  5315. for (var i = 0; i < $scope.myData1all.length; i++) {
  5316. $scope.myData1all[i]["item"] =
  5317. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5318. }
  5319. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5320. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5321. }
  5322. }
  5323. if ($scope.model.consumables) {
  5324. if (
  5325. $scope.model.consumables != $scope.modelcons &&
  5326. typeof $scope.model.consumables == "string"
  5327. ) {
  5328. $scope.modelass = $scope.model.consumables;
  5329. if (JSON.stringify($scope.model.consumables) == "{}") {
  5330. $scope.model.consumables = [];
  5331. } else {
  5332. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5333. }
  5334. // $scope.myData2 = $scope.model.consumables;
  5335. // for (var i = 0; i < $scope.myData2.length; i++) {
  5336. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5337. // }
  5338. $scope.myData2all = $scope.model.consumables;
  5339. for (var i = 0; i < $scope.myData2all.length; i++) {
  5340. $scope.myData2all[i]["item"] =
  5341. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5342. }
  5343. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5344. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5345. // $scope.model.consumables = $scope.myData2all;
  5346. }
  5347. }
  5348. }, 100);
  5349. $scope.gridOptions2.columnDefs = [
  5350. {
  5351. name: "item",
  5352. displayName: "序号",
  5353. width: 120,
  5354. },
  5355. {
  5356. name: "name",
  5357. displayName: "耗材名称",
  5358. width: 180,
  5359. enableFiltering: false,
  5360. },
  5361. {
  5362. name: "model",
  5363. displayName: "品牌/型号",
  5364. width: 180,
  5365. enableFiltering: false,
  5366. },
  5367. {
  5368. name: "Specifications",
  5369. displayName: "规格",
  5370. width: 150,
  5371. enableFiltering: false,
  5372. },
  5373. {
  5374. name: "sum",
  5375. width: 150,
  5376. displayName: "数量",
  5377. enableFiltering: false,
  5378. },
  5379. {
  5380. name: "操作",
  5381. cellTemplate:
  5382. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5383. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5384. "</div></div>",
  5385. enableFiltering: false,
  5386. },
  5387. ];
  5388. // $scope.selectButtonClick
  5389. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5390. $scope.gridApi = gridApi;
  5391. gridApi.pagination.on.paginationChanged(
  5392. $scope,
  5393. function (newPage, pageSize) {
  5394. // var filtersData = $scope.memoryfilterDatagui;
  5395. // filtersData.idx = newPage - 1;
  5396. // filtersData.sum = pageSize;
  5397. $scope.memoryfilterDatagui.idx = newPage - 1;
  5398. $scope.memoryfilterDatagui.sum = pageSize;
  5399. $scope.myData2 = $scope.interceptMydata(
  5400. $scope.myData2all,
  5401. $scope.memoryfilterDatagui.idx,
  5402. 10
  5403. );
  5404. }
  5405. );
  5406. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5407. $scope.selected.items = data.entity;
  5408. //console.log(data);
  5409. });
  5410. gridApi.selection.on.rowSelectionChangedBatch(
  5411. $scope,
  5412. function (data) {
  5413. $scope.selected.items = data.entity;
  5414. //console.log(data);
  5415. }
  5416. );
  5417. gridApi.core.on.filterChanged($scope, function () {
  5418. var grid = this.grid;
  5419. var filtersData = {
  5420. idx: 0,
  5421. sum: 10,
  5422. };
  5423. angular.forEach(grid.columns, function (item) {
  5424. if (item.enableFiltering) {
  5425. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5426. if (
  5427. angular.isDefined(item.filters[0].term) &&
  5428. item.filters[0].term != ""
  5429. ) {
  5430. if (angular.isUndefined(filtersData["user"])) {
  5431. filtersData["user"] = {};
  5432. }
  5433. filtersData["user"][item.field] = item.filters[0].term;
  5434. }
  5435. }
  5436. });
  5437. $scope.memoryfilterData = filtersData;
  5438. $scope.loadData(filtersData);
  5439. });
  5440. };
  5441. $scope.changecai = function (item) {
  5442. event.preventDefault();
  5443. var modalInstance = $modal.open({
  5444. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5445. controller: function ($scope, $modalInstance) {
  5446. $scope.title = "修改耗材数量";
  5447. $scope.consumptive = angular.copy(item);
  5448. // $scope.consumptive = item;
  5449. $scope.maxsum = item.inventoryNum;
  5450. $scope.clearNoNum = function (obj, attr) {
  5451. //先把非数字的都替换掉,除了数字和.
  5452. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5453. //必须保证第一个为数字而不是.
  5454. obj[attr] = obj[attr].replace(/^\./g, "");
  5455. //保证只有出现一个.而没有多个.
  5456. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5457. //保证.只出现一次,而不能出现两次以上
  5458. obj[attr] = obj[attr]
  5459. .replace(".", "$#$")
  5460. .replace(/\./g, "")
  5461. .replace("$#$", ".");
  5462. //小于最大值
  5463. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5464. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5465. // obj[attr] = '';
  5466. // }
  5467. };
  5468. $scope.ok = function () {
  5469. $modalInstance.close($scope.consumptive);
  5470. };
  5471. $scope.cancel = function () {
  5472. $modalInstance.dismiss("cancel");
  5473. };
  5474. },
  5475. size: "sm",
  5476. });
  5477. modalInstance.result.then(function (selectedItem) {
  5478. angular.forEach($scope.myData2all, function (items, index) {
  5479. // if (items.id == selectedItem.id) {
  5480. if (
  5481. items.modelid == selectedItem.modelid &&
  5482. items.nameid == selectedItem.nameid &&
  5483. items.Specificationsid == selectedItem.Specificationsid
  5484. ) {
  5485. angular.extend($scope.myData2all[index], selectedItem);
  5486. }
  5487. });
  5488. // $scope.model.consumables = $scope.myData2;
  5489. // $scope.myData2 = $scope.model.consumables;
  5490. // $scope.myData2all.push(selectedItem);
  5491. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5492. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5493. // }
  5494. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5495. $scope.myData2 = $scope.interceptMydata(
  5496. $scope.myData2all,
  5497. $scope.memoryfilterDatagui.idx,
  5498. 10
  5499. );
  5500. $scope.model.consumables = $scope.myData2all;
  5501. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5502. $scope.model.consumables;
  5503. });
  5504. };
  5505. $scope.interceptMydata = function (mydate, idx, sum) {
  5506. return mydate.slice(idx * sum, (idx + 1) * sum);
  5507. };
  5508. $scope.haocaiadd = function () {
  5509. event.preventDefault();
  5510. var modalInstance = $modal.open({
  5511. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5512. controller: function (
  5513. $scope,
  5514. scope,
  5515. $modalInstance,
  5516. api_wechatfile,
  5517. SweetAlert
  5518. ) {
  5519. $scope.haocainame = [];
  5520. $scope.pinpai = [];
  5521. $scope.guige = [];
  5522. $scope.consumptive = {};
  5523. $scope.consumptiveall = {};
  5524. $scope.title = "添加耗材";
  5525. api_wechatfile
  5526. .getDictionaryForList({
  5527. key: "haocaifenlei",
  5528. })
  5529. .then(function (data) {
  5530. $scope.haocainame = data;
  5531. });
  5532. $scope.clearNoNum = function (obj, attr) {
  5533. //先把非数字的都替换掉,除了数字和.
  5534. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5535. //必须保证第一个为数字而不是.
  5536. obj[attr] = obj[attr].replace(/^\./g, "");
  5537. //保证只有出现一个.而没有多个.
  5538. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5539. //保证.只出现一次,而不能出现两次以上
  5540. obj[attr] = obj[attr]
  5541. .replace(".", "$#$")
  5542. .replace(/\./g, "")
  5543. .replace("$#$", ".");
  5544. //小于最大值
  5545. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5546. alert(
  5547. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5548. );
  5549. obj[attr] = "";
  5550. }
  5551. };
  5552. $scope.onChange = function (parent) {
  5553. $scope.consumptive.model = {};
  5554. $scope.consumptive.Specifications = {};
  5555. api_wechatfile
  5556. .getDictionaryForList({
  5557. key: "pinpai",
  5558. parent: parent.id,
  5559. })
  5560. .then(function (data) {
  5561. $scope.pinpai = data;
  5562. });
  5563. api_wechatfile
  5564. .getDictionaryForList({
  5565. key: "guige",
  5566. parent: parent.id,
  5567. })
  5568. .then(function (data) {
  5569. $scope.guige = data;
  5570. });
  5571. };
  5572. // $scope.onChangesum = function(item) {
  5573. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5574. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5575. // $scope.consumptiveall = data1;
  5576. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5577. // // if (data.list && data.list.length != 0) {
  5578. // // var myData = data.list;
  5579. // // $scope.consumptiveall = myData[0];
  5580. // // $scope.maxsum = myData[0].inventoryNum;
  5581. // // } else if (data.list && data.list.length == 0) {
  5582. // // SweetAlert.swal({
  5583. // // title: "库存数据存在问题!",
  5584. // // text: "请检查库存数据!",
  5585. // // type: "error"
  5586. // // });
  5587. // // }
  5588. // // });
  5589. // }
  5590. // }
  5591. $scope.addhaocai = function () {
  5592. $modalInstance.dismiss("cancel");
  5593. scope.haocaiopen($scope.consumptive);
  5594. };
  5595. $scope.ok = function (item) {
  5596. var submittrue = true;
  5597. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5598. var data = {
  5599. modelid: item.model.id,
  5600. nameid: item.name.id,
  5601. Specificationsid: item.Specifications.id,
  5602. name: item.name.name,
  5603. model: item.model.name,
  5604. Specifications: item.Specifications.name,
  5605. sum: item.sum,
  5606. };
  5607. if (
  5608. item.name &&
  5609. item.model &&
  5610. JSON.stringify(item.model) != "{}" &&
  5611. item.Specifications &&
  5612. JSON.stringify(item.Specifications) != "{}" &&
  5613. item.sum
  5614. ) {
  5615. // $modalInstance.close(data);
  5616. angular.forEach(scope.myData2all, function (itemsdata) {
  5617. // if (item.model.id == itemsdata.id) {
  5618. if (
  5619. item.model.id == itemsdata.modelid &&
  5620. item.name.id == itemsdata.nameid &&
  5621. item.Specifications.id == itemsdata.Specificationsid
  5622. ) {
  5623. submittrue = false;
  5624. }
  5625. });
  5626. if (submittrue) {
  5627. $modalInstance.close(data);
  5628. } else {
  5629. SweetAlert.swal({
  5630. title: "该耗材已有添加",
  5631. text: "请检查数据然后提交!",
  5632. type: "error",
  5633. });
  5634. }
  5635. } else {
  5636. SweetAlert.swal({
  5637. title: "数据填写不完整!",
  5638. text: "请检查数据然后提交!",
  5639. type: "error",
  5640. });
  5641. }
  5642. };
  5643. $scope.cancel = function () {
  5644. $modalInstance.dismiss("cancel");
  5645. };
  5646. },
  5647. size: "sm",
  5648. resolve: {
  5649. scope: function () {
  5650. return $scope;
  5651. },
  5652. },
  5653. });
  5654. modalInstance.result.then(function (selectedItem) {
  5655. // $scope.myData2.push(selectedItem);
  5656. // for (var i = 0; i < $scope.myData2.length; i++) {
  5657. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5658. // }
  5659. // $scope.model.consumables = $scope.myData2;
  5660. $scope.myData2all.push(selectedItem);
  5661. for (var i = 0; i < $scope.myData2all.length; i++) {
  5662. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5663. $scope.myData2all[i]["item"] = i + 1;
  5664. }
  5665. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5666. $scope.myData2 = $scope.interceptMydata(
  5667. $scope.myData2all,
  5668. $scope.memoryfilterDatagui.idx,
  5669. 10
  5670. );
  5671. $scope.model.consumables = $scope.myData2all;
  5672. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5673. $scope.model.consumables;
  5674. });
  5675. };
  5676. $scope.onDblClick = function (data, event) {
  5677. $scope.selectButtonClick(data, event);
  5678. };
  5679. $scope.memoryfilterData = {
  5680. idx: 0,
  5681. sum: 20,
  5682. user: {
  5683. roledata: {
  5684. rolecode: "roleset",
  5685. },
  5686. selectType: "1",
  5687. },
  5688. };
  5689. $scope.myData = {};
  5690. $scope.loadData = function (filterData) { };
  5691. // $scope.title = title;
  5692. $scope.loadData({
  5693. idx: 0,
  5694. sum: 20,
  5695. user: {
  5696. roledata: {
  5697. rolecode: "roleset",
  5698. },
  5699. selectType: "1",
  5700. },
  5701. });
  5702. $scope.selected = {
  5703. items: {},
  5704. };
  5705. },
  5706. ],
  5707. });
  5708. //tab 列表
  5709. formlyConfigProvider.setType({
  5710. name: "ui-cmdbtab",
  5711. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5712. wrapper: ["bootstrapHasError"],
  5713. defaultOptions: function (options, $scope) {
  5714. return {
  5715. templateOptions: {},
  5716. };
  5717. },
  5718. controller: [
  5719. "$scope",
  5720. "api_user_data",
  5721. "i18nService",
  5722. "$modal",
  5723. "api_cmdb",
  5724. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5725. $scope.memoryfilterDatashe = {
  5726. idx: 0,
  5727. sum: 10,
  5728. };
  5729. $scope.myDataoneall = [];
  5730. var setAllInactive = function () {
  5731. angular.forEach($scope.workspaces, function (workspace) {
  5732. workspace.active = false;
  5733. });
  5734. };
  5735. //添加
  5736. var addNewWorkspace = function (name, contentUrl) {
  5737. var id = $scope.workspaces.length + 1;
  5738. $scope.workspaces.push({
  5739. id: id,
  5740. name: name,
  5741. active: true,
  5742. contentUrl: "main/html/content.html",
  5743. });
  5744. };
  5745. //关闭
  5746. $scope.remove = function (closedata) {
  5747. event.preventDefault();
  5748. angular.forEach($scope.workspaces, function (item, index) {
  5749. if (closedata.id == item.id) {
  5750. if (closedata.id == 1) {
  5751. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5752. } else {
  5753. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5754. }
  5755. $scope.workspaces.splice(index, 1);
  5756. }
  5757. });
  5758. };
  5759. $scope.workspaces = [];
  5760. $scope.options.templateOptions.getpush = function (item) {
  5761. $scope.workspaces = [];
  5762. if (item.gu) {
  5763. $scope.workspaces.push({
  5764. id: 1,
  5765. name: "领用设备",
  5766. active: true,
  5767. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5768. });
  5769. }
  5770. if (item.hao) {
  5771. $scope.workspaces.push({
  5772. id: 2,
  5773. name: "领用耗材",
  5774. active: true,
  5775. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5776. });
  5777. }
  5778. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5779. };
  5780. $scope.addWorkspace = function (contentUrl, name) {
  5781. setAllInactive();
  5782. addNewWorkspace(name, contentUrl);
  5783. };
  5784. // $rootScope.addWorkspace = $scope.addWorkspace;
  5785. // $scope.remove = function(idNumber) {
  5786. // var index = 0; //记录当前元素下标
  5787. // angular.forEach($scope.workspaces, function(workspace) {
  5788. // if (workspace.id === idNumber.id) {
  5789. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5790. // }
  5791. // index++;
  5792. // });
  5793. // };
  5794. // setInterval(function() {
  5795. // if ($scope.model.assets) {
  5796. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5797. // $scope.modelass = $scope.model.assets;
  5798. // if (JSON.stringify($scope.model.assets) == "{}") {
  5799. // $scope.model.assets = []
  5800. // } else {
  5801. // $scope.model.assets = JSON.parse($scope.model.assets);
  5802. // }
  5803. // $scope.myDatalingbeiall = $scope.model.assets;
  5804. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5805. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5806. // }
  5807. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5808. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5809. // }
  5810. // }
  5811. // if ($scope.model.consumables) {
  5812. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5813. // $scope.modelass = $scope.model.consumables;
  5814. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5815. // $scope.model.consumables = [];
  5816. // } else {
  5817. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5818. // }
  5819. // $scope.myDatalingbeiall = $scope.model.consumables;
  5820. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5821. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5822. // }
  5823. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5824. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5825. // // $scope.model.consumables = $scope.myData2all;
  5826. // }
  5827. // }
  5828. // }, 100);
  5829. //grid1
  5830. $scope.langs = i18nService.getAllLangs();
  5831. $scope.lang = "zh-cn";
  5832. i18nService.setCurrentLang($scope.lang);
  5833. $scope.gridOptions1 = {};
  5834. $scope.gridOptions1.data = "myDatalingbei";
  5835. $scope.gridOptions1.enableColumnResizing = true;
  5836. $scope.gridOptions1.enableFiltering = false;
  5837. $scope.gridOptions1.enableGridMenu = false;
  5838. $scope.gridOptions1.showGridFooter = true;
  5839. $scope.gridOptions1.showColumnFooter = false;
  5840. $scope.gridOptions1.fastWatch = true;
  5841. $scope.gridOptions1.useExternalFiltering = true;
  5842. $scope.gridOptions1.useExternalPagination = true;
  5843. $scope.gridOptions1.paginationPageSizes = [10];
  5844. $scope.gridOptions1.paginationPageSize = 10;
  5845. $scope.gridOptions1.multiSelect = false;
  5846. // $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>";
  5847. $scope.gridOptions1.columnDefs = [
  5848. {
  5849. name: "item",
  5850. displayName: "序号",
  5851. width: 120,
  5852. },
  5853. {
  5854. name: "props.hw_cifilterClassic",
  5855. displayName: "设备类型",
  5856. width: 150,
  5857. enableFiltering: false,
  5858. },
  5859. {
  5860. name: "props.hw_mingcheng",
  5861. displayName: "设备名称",
  5862. width: 100,
  5863. enableFiltering: false,
  5864. },
  5865. {
  5866. name: "uuid",
  5867. displayName: "设备编号",
  5868. enableFiltering: false,
  5869. },
  5870. ];
  5871. $scope.myDatalingbeiall = [];
  5872. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5873. $scope.gridApi = gridApi;
  5874. gridApi.pagination.on.paginationChanged(
  5875. $scope,
  5876. function (newPage, pageSize) {
  5877. // var filtersData = $scope.memoryfilterData;
  5878. // filtersData.idx = newPage - 1;
  5879. // filtersData.sum = pageSize;
  5880. // $scope.loadData(filtersData);
  5881. $scope.memoryfilterDatashe.idx = newPage - 1;
  5882. $scope.memoryfilterDatashe.sum = pageSize;
  5883. $scope.myDatalingbei = $scope.interceptMydata(
  5884. $scope.myDatalingbeiall,
  5885. $scope.memoryfilterDatashe.idx,
  5886. 10
  5887. );
  5888. }
  5889. );
  5890. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5891. $scope.selected.items = data.entity;
  5892. //console.log(data);
  5893. });
  5894. gridApi.selection.on.rowSelectionChangedBatch(
  5895. $scope,
  5896. function (data) {
  5897. $scope.selected.items = data.entity;
  5898. //console.log(data);
  5899. }
  5900. );
  5901. gridApi.core.on.filterChanged($scope, function () {
  5902. var grid = this.grid;
  5903. var filtersData = {
  5904. idx: 0,
  5905. sum: 20,
  5906. user: {
  5907. roledata: {
  5908. rolecode: "roleset",
  5909. },
  5910. selectType: "1",
  5911. },
  5912. };
  5913. angular.forEach(grid.columns, function (item) {
  5914. if (item.enableFiltering) {
  5915. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5916. if (
  5917. angular.isDefined(item.filters[0].term) &&
  5918. item.filters[0].term != ""
  5919. ) {
  5920. if (angular.isUndefined(filtersData["user"])) {
  5921. filtersData["user"] = {};
  5922. }
  5923. filtersData["user"][item.field] = item.filters[0].term;
  5924. }
  5925. }
  5926. });
  5927. $scope.memoryfilterDatashe = filtersData;
  5928. // $scope.loadData(filtersData);
  5929. });
  5930. };
  5931. $scope.interceptMydata = function (mydate, idx, sum) {
  5932. return mydate.slice(idx * sum, (idx + 1) * sum);
  5933. };
  5934. $scope.removeshebei = function (item) {
  5935. event.preventDefault();
  5936. var modalInstance = $modal.open({
  5937. templateUrl: "assets/views/delete.html",
  5938. controller: function ($scope, $modalInstance, scope) {
  5939. $scope.title = "设备移除";
  5940. $scope.connect = "确定要移除此设备?";
  5941. $scope.consumptive = scope.selected.items;
  5942. $scope.ok = function () {
  5943. $modalInstance.close($scope.consumptive);
  5944. };
  5945. $scope.cancel = function () {
  5946. $modalInstance.dismiss("cancel");
  5947. };
  5948. },
  5949. size: "sm",
  5950. resolve: {
  5951. scope: function () {
  5952. return $scope;
  5953. },
  5954. },
  5955. });
  5956. modalInstance.result.then(function (selectedItem) {
  5957. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5958. if (items.id == selectedItem.id) {
  5959. $scope.myDatalingbeiall.splice(index, 1);
  5960. }
  5961. });
  5962. // $scope.myData3.push(selectedItem);
  5963. $scope.model.consumables = $scope.myDatalingbeiall;
  5964. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5965. $scope.myDatalingbeiall;
  5966. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5967. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5968. $scope.myDatalingbeiall[i]["item"] =
  5969. i +
  5970. 1 +
  5971. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5972. }
  5973. $scope.myDatalingbei = $scope.interceptMydata(
  5974. $scope.myDatalingbeiall,
  5975. 0,
  5976. 10
  5977. );
  5978. });
  5979. };
  5980. $scope.addshebei = function () {
  5981. event.preventDefault();
  5982. var modalInstance = $modal.open({
  5983. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5984. controller: function (
  5985. $scope,
  5986. i18nService,
  5987. $modalInstance,
  5988. items,
  5989. title,
  5990. Restangular,
  5991. APIService,
  5992. onDataCallback,
  5993. parentScope,
  5994. api_configure_data,
  5995. api_configure_form
  5996. ) {
  5997. $scope.langs = i18nService.getAllLangs();
  5998. $scope.lang = "zh-cn";
  5999. i18nService.setCurrentLang($scope.lang);
  6000. $scope.gridOptions = {};
  6001. $scope.gridOptions.data = "myDatatwo";
  6002. $scope.gridOptions.enableColumnResizing = true;
  6003. $scope.gridOptions.enableFiltering = false;
  6004. $scope.gridOptions.enableGridMenu = false;
  6005. $scope.gridOptions.showGridFooter = true;
  6006. $scope.gridOptions.showColumnFooter = false;
  6007. $scope.gridOptions.fastWatch = true;
  6008. $scope.gridOptions.useExternalFiltering = true;
  6009. $scope.gridOptions.useExternalPagination = true;
  6010. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  6011. $scope.gridOptions.paginationPageSize = 10;
  6012. $scope.gridOptions.multiSelect = true;
  6013. $scope.gridOptions.rowIdentity = function (row) {
  6014. return row.id;
  6015. };
  6016. $scope.gridOptions.getRowIdentity = function (row) {
  6017. return row.id;
  6018. };
  6019. // $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>";
  6020. $scope.gridOptions.columnDefs = [
  6021. {
  6022. name: "item",
  6023. displayName: "序号",
  6024. width: 80,
  6025. enableFiltering: false,
  6026. },
  6027. {
  6028. name: "uuid",
  6029. displayName: "内部编号",
  6030. width: 175,
  6031. },
  6032. {
  6033. name: "props.hw_mingcheng",
  6034. displayName: "资产名称",
  6035. width: 120,
  6036. },
  6037. {
  6038. name: "props.hw_cifilterClassic",
  6039. displayName: "资产类型",
  6040. width: 80,
  6041. enableFiltering: false,
  6042. },
  6043. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6044. {
  6045. name: "props.hw_state",
  6046. displayName: "资产状态",
  6047. width: 150,
  6048. enableFiltering: false,
  6049. },
  6050. {
  6051. name: "props.hwnw_area",
  6052. displayName: "资产地点",
  6053. width: 130,
  6054. enableFiltering: false,
  6055. },
  6056. {
  6057. name: "createtime",
  6058. displayName: "申请时间",
  6059. enableFiltering: false,
  6060. },
  6061. ];
  6062. // $scope.selectButtonClick
  6063. var defaultFilterData = {
  6064. // "assignee":2,
  6065. // "sign":"basehwitndl",
  6066. // "applicationForm": { "hw_state": "在线" },
  6067. hw_state: "在库",
  6068. idx: 0,
  6069. sum: 10,
  6070. };
  6071. $scope.memoryfilterData = {
  6072. // "assignee":2,
  6073. // "sign":"basehwitndl",
  6074. // "applicationForm": { "hw_state": "在线" },
  6075. hw_state: "在库",
  6076. idx: 0,
  6077. sum: 10,
  6078. };
  6079. $scope.refreshData = function (style, filterData) {
  6080. if (angular.isUndefined(filterData)) {
  6081. filterData = defaultFilterData;
  6082. }
  6083. $scope.myDatatwo = [];
  6084. // $scope.gridOptions['sum']=filterData.sum;
  6085. api_cmdb.query(filterData).then(
  6086. function (data) {
  6087. // $scope.callsPending--;
  6088. var filterData = $scope.memoryfilterData;
  6089. var myDatatwo = Restangular.stripRestangular(data);
  6090. $scope.gridOptions["totalItems"] = data.total;
  6091. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6092. myDatatwo.data.node[i].createtime = moment(
  6093. myDatatwo.data.node[i].createtime
  6094. ).format("YYYY-MM-DD");
  6095. }
  6096. $scope.myDatatwo = myDatatwo.data.node;
  6097. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6098. $scope.myDatatwo[i]["item"] =
  6099. i + 1 + filterData.idx * filterData.sum;
  6100. }
  6101. },
  6102. function () { }
  6103. );
  6104. };
  6105. $scope.refreshData("expand-right", defaultFilterData);
  6106. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6107. $scope.gridApi = gridApi;
  6108. gridApi.pagination.on.paginationChanged(
  6109. $scope,
  6110. function (newPage, pageSize) {
  6111. var filtersData = $scope.memoryfilterData;
  6112. filtersData.idx = newPage - 1;
  6113. filtersData.sum = pageSize;
  6114. // $scope.loadData(filtersData);
  6115. $scope.refreshData("expand-right", filtersData);
  6116. //console.log(pageSize);
  6117. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6118. }
  6119. );
  6120. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6121. // $scope.selected.items.push(data.entity);
  6122. //console.log(data);
  6123. gridApi.selection.on.rowSelectionChanged(
  6124. $scope,
  6125. function (scope, ect) {
  6126. if (scope.isSelected) {
  6127. scope.grid.appScope.selected.items.push(scope.entity);
  6128. } else {
  6129. for (
  6130. var i = 0;
  6131. i <= scope.grid.appScope.selected.items.length;
  6132. i++
  6133. ) {
  6134. if (
  6135. scope.grid.appScope.selected.items[i].id ==
  6136. scope.entity.id
  6137. ) {
  6138. scope.grid.appScope.selected.items.splice(i, 1);
  6139. break;
  6140. }
  6141. }
  6142. }
  6143. $scope.mySelectedRows =
  6144. $scope.gridApi.selection.getSelectedRows();
  6145. }
  6146. );
  6147. // });
  6148. gridApi.selection.on.rowSelectionChangedBatch(
  6149. $scope,
  6150. function (rows) {
  6151. // $scope.selected.items = data.entity;
  6152. //console.log(data);
  6153. var selectitem = [];
  6154. selectitem = angular.copy($scope.selected.items);
  6155. for (var j = 0; j < rows.length; j++) {
  6156. if (rows[j].isSelected == true) {
  6157. selectitem.push(rows[j].entity);
  6158. } else {
  6159. delete selectitem[j];
  6160. // rows.splice(j, 1);
  6161. }
  6162. }
  6163. $scope.selected.items = [];
  6164. for (var i = 0; i < selectitem.length; i++) {
  6165. if (selectitem[i]) {
  6166. $scope.selected.items.push(selectitem[i]);
  6167. }
  6168. }
  6169. }
  6170. );
  6171. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6172. // // if (row.entity.age > 45) {
  6173. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6174. // // }
  6175. // };
  6176. gridApi.core.on.filterChanged($scope, function () {
  6177. var grid = this.grid;
  6178. var filtersData = {
  6179. idx: 0,
  6180. sum: 10,
  6181. user: {
  6182. roledata: {
  6183. rolecode: "roleset",
  6184. },
  6185. selectType: "1",
  6186. },
  6187. };
  6188. angular.forEach(grid.columns, function (item) {
  6189. if (item.enableFiltering) {
  6190. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6191. if (
  6192. angular.isDefined(item.filters[0].term) &&
  6193. item.filters[0].term != ""
  6194. ) {
  6195. if (angular.isUndefined(filtersData["user"])) {
  6196. filtersData["user"] = {};
  6197. }
  6198. filtersData["user"][item.field] = item.filters[0].term;
  6199. }
  6200. }
  6201. });
  6202. $scope.memoryfilterData = filtersData;
  6203. // $scope.loadData(filtersData);
  6204. });
  6205. };
  6206. $scope.onDblClick = function (data, event) {
  6207. // $scope.selected.items = data.entity;
  6208. $scope.selectButtonClick(data, event);
  6209. };
  6210. // $scope.loadData = function(filterData) {
  6211. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6212. // items.fetchItems(filterData, APIService).then(function(data) {
  6213. // var myDatatwo = Restangular.stripRestangular(data);
  6214. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6215. // $scope.myDatatwo = myDatatwo.list;
  6216. // });
  6217. // };
  6218. $scope.title = title;
  6219. //树形图
  6220. var apple_selected, tree, treedata_avm, treedata_geography;
  6221. $scope.my_tree_handler = function (branch) {
  6222. //var _ref;
  6223. var classify = ($scope.classify =
  6224. branch.prefix.toLowerCase() + branch.sign);
  6225. api_cmdb
  6226. .query({
  6227. sign: classify,
  6228. })
  6229. .then(function (data) {
  6230. var myDatalingbei = Restangular.stripRestangular(data);
  6231. // console.log(myData.data.node);
  6232. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6233. var ret = myDatalingbei.data;
  6234. redrawSvg(myDatalingbei);
  6235. }
  6236. });
  6237. };
  6238. $scope.my_data = [];
  6239. function convertListToTree(data, treeMap) {
  6240. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6241. var root = null; //Initially set our loop to null
  6242. var parentNode = null;
  6243. //loop over data
  6244. for (var i = 0; i < data.length; i++) {
  6245. var datum = data[i];
  6246. //each node will have children, so let's give it a "children" poperty
  6247. datum.children = [];
  6248. //add an entry for this node to the map so that any future children can
  6249. //lookup the parent
  6250. idToNodeMap[datum.id] = datum;
  6251. //Does this node have a parent?
  6252. if (
  6253. typeof datum.parent === "undefined" ||
  6254. datum.parent == null
  6255. ) {
  6256. //Doesn't look like it, so this node is the root of the tree
  6257. root = datum;
  6258. treeMap[datum.id] = root;
  6259. } else {
  6260. //This node has a parent, so let's look it up using the id
  6261. parentNode = idToNodeMap[datum.parent.id];
  6262. //We don't need this property, so let's delete it.
  6263. delete datum.parent;
  6264. //Let's add the current node as a child of the parent node.
  6265. parentNode.children.push(datum);
  6266. }
  6267. }
  6268. return root;
  6269. }
  6270. function convertParentToChildList(data) {
  6271. var treeMap = {};
  6272. var list = [];
  6273. convertListToTree(data, treeMap);
  6274. angular.forEach(treeMap, function (item) {
  6275. list.push(item);
  6276. });
  6277. return list;
  6278. }
  6279. $scope.my_tree = tree = {};
  6280. $scope.try_async_load = function () {
  6281. $scope.my_data = [];
  6282. $scope.select_treedata = [];
  6283. $scope.doing_async = true;
  6284. api_configure_data
  6285. .fetchDataList("ciclassify", {
  6286. idx: 0,
  6287. sum: 100,
  6288. })
  6289. .then(function (result) {
  6290. //console.log(result['list']);
  6291. $scope.select_treedata = $scope.my_data =
  6292. convertParentToChildList(result["list"]);
  6293. $scope.doing_async = false;
  6294. // tree.expand_all();
  6295. //console.log(treelist);
  6296. });
  6297. };
  6298. $scope.select_treedata = [];
  6299. $scope.propTypeOptions = [];
  6300. $scope.try_async_load();
  6301. $scope.onFilterremove = function (item) {
  6302. console.log(item);
  6303. };
  6304. $scope.searchdata = {};
  6305. $scope.clear = function () {
  6306. $scope.searchdata = {};
  6307. $scope.cifilter_classic = {};
  6308. $scope.try_async_load();
  6309. var fildata = {
  6310. idx: 0,
  6311. sum: 10,
  6312. hw_state: "在库",
  6313. };
  6314. $scope.memoryfilterData = fildata;
  6315. $scope.refreshData("expand-right", fildata);
  6316. };
  6317. $scope.cifilter_classic = {};
  6318. $scope.chiceIncident = function (item) {
  6319. var fildata = defaultFilterData;
  6320. // fildata.applicationForm = {};
  6321. // sign: basehwnwswt
  6322. if (item && item.id) {
  6323. var classify = item.prefix.toLowerCase() + item.sign;
  6324. fildata.sign = classify;
  6325. } else {
  6326. delete fildata.sign;
  6327. }
  6328. $scope.gridOptions.paginationCurrentPage = 1;
  6329. var transitiondata = angular.copy(item);
  6330. $scope.refreshData("expand-right", fildata);
  6331. };
  6332. $scope.applicadata = [];
  6333. $scope.onFilterCallback = function (item) {
  6334. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6335. api_configure_form
  6336. .renderTabForm(tempclassify)
  6337. .then(function (data) {
  6338. var myData = Restangular.stripRestangular(data);
  6339. $scope.applicadata = myData[0].form.fields;
  6340. });
  6341. // }
  6342. };
  6343. // $scope.loadData({
  6344. // idx: 0,
  6345. // sum: 10,
  6346. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6347. // });
  6348. $scope.selected = {
  6349. items: [],
  6350. };
  6351. $scope.ok = function () {
  6352. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6353. // onDataCallback($scope.selected.item, parentScope);
  6354. // }
  6355. $modalInstance.close($scope.selected.items);
  6356. };
  6357. $scope.cancel = function () {
  6358. $modalInstance.dismiss("cancel");
  6359. };
  6360. },
  6361. size: "lg",
  6362. resolve: {
  6363. items: function () {
  6364. return {
  6365. fetchItems: function (filterData, APIService) {
  6366. filterData = filterData || {};
  6367. if (
  6368. angular.isDefined(filterData.idx) &&
  6369. filterData.idx == null
  6370. ) {
  6371. filterData = {
  6372. idx: 0,
  6373. sum: 10,
  6374. user: {
  6375. roledata: {
  6376. rolecode: "roleset",
  6377. },
  6378. selectType: "1",
  6379. },
  6380. };
  6381. }
  6382. return $scope.options.templateOptions.fetchItems(
  6383. filterData,
  6384. APIService
  6385. );
  6386. },
  6387. };
  6388. },
  6389. title: function () {
  6390. return $scope.options.templateOptions.label;
  6391. },
  6392. Restangular: function () {
  6393. return $scope.options.templateOptions.Restangular;
  6394. },
  6395. APIService: function () {
  6396. return $scope.options.templateOptions.ApiService;
  6397. },
  6398. onDataCallback: function () {
  6399. return $scope.options.templateOptions.callback;
  6400. },
  6401. parentScope: function () {
  6402. return $scope.options.templateOptions.that;
  6403. },
  6404. },
  6405. });
  6406. modalInstance.result.then(
  6407. function (selectedItem) {
  6408. // console.log(selectedItem);
  6409. // options.value(selectedItem);
  6410. var filterData = $scope.memoryfilterDatashe;
  6411. $scope.myDatalingbeiall = selectedItem;
  6412. $scope.gridOptions1["totalItems"] =
  6413. $scope.myDatalingbeiall.length;
  6414. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6415. $scope.myDatalingbeiall[i]["item"] =
  6416. i + 1 + filterData.idx * filterData.sum;
  6417. }
  6418. $scope.myDatalingbei = $scope.interceptMydata(
  6419. $scope.myDatalingbeiall,
  6420. 0,
  6421. 10
  6422. );
  6423. $scope.model.assets = $scope.myDatalingbeiall;
  6424. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6425. $scope.myDatalingbeiall;
  6426. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6427. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6428. // }
  6429. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6430. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6431. // }
  6432. },
  6433. function () {
  6434. //console.log('Modal dismissed at: ' + new Date());
  6435. }
  6436. );
  6437. };
  6438. $scope.onDblClick = function (data, event) {
  6439. $scope.selectButtonClick(data, event);
  6440. };
  6441. // $scope.loadData = function(filterData) {};
  6442. // $scope.title = title;
  6443. // $scope.loadData({
  6444. // idx: 0,
  6445. // sum: 20,
  6446. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6447. // });
  6448. $scope.selected = {
  6449. items: [],
  6450. };
  6451. //grid2
  6452. $scope.langs = i18nService.getAllLangs();
  6453. $scope.lang = "zh-cn";
  6454. i18nService.setCurrentLang($scope.lang);
  6455. $scope.gridOptions2 = {};
  6456. $scope.gridOptions2.data = "myDataone";
  6457. $scope.gridOptions2.enableColumnResizing = true;
  6458. $scope.gridOptions2.enableFiltering = false;
  6459. $scope.gridOptions2.enableGridMenu = false;
  6460. $scope.gridOptions2.showGridFooter = true;
  6461. $scope.gridOptions2.showColumnFooter = false;
  6462. $scope.gridOptions2.fastWatch = true;
  6463. $scope.gridOptions2.useExternalFiltering = true;
  6464. $scope.gridOptions2.useExternalPagination = true;
  6465. $scope.gridOptions2.paginationPageSizes = [10];
  6466. $scope.gridOptions2.paginationPageSize = 10;
  6467. $scope.gridOptions2.multiSelect = false;
  6468. // $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>";
  6469. $scope.gridOptions2.columnDefs = [
  6470. {
  6471. name: "item",
  6472. displayName: "序号",
  6473. width: 120,
  6474. },
  6475. {
  6476. name: "name",
  6477. displayName: "耗材名称",
  6478. width: 150,
  6479. enableFiltering: false,
  6480. },
  6481. {
  6482. name: "model",
  6483. displayName: "品牌/型号",
  6484. width: 100,
  6485. enableFiltering: false,
  6486. },
  6487. {
  6488. name: "Specifications",
  6489. displayName: "规格",
  6490. width: 150,
  6491. enableFiltering: false,
  6492. },
  6493. {
  6494. name: "sum",
  6495. displayName: "领用数量",
  6496. enableFiltering: false,
  6497. },
  6498. ];
  6499. // $scope.selectButtonClick
  6500. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6501. $scope.gridApi = gridApi;
  6502. gridApi.pagination.on.paginationChanged(
  6503. $scope,
  6504. function (newPage, pageSize) {
  6505. // var filtersData = $scope.memoryfilterData;
  6506. // filtersData.idx = newPage - 1;
  6507. // filtersData.sum = pageSize;
  6508. // $scope.loadData(filtersData);
  6509. $scope.memoryfilterDatahao.idx = newPage - 1;
  6510. $scope.memoryfilterDatahao.sum = pageSize;
  6511. $scope.myDataone = $scope.interceptMydata(
  6512. $scope.myDataoneall,
  6513. $scope.memoryfilterDatahao.idx,
  6514. 10
  6515. );
  6516. }
  6517. );
  6518. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6519. $scope.selected.items.push(data.entity);
  6520. //console.log(data);
  6521. });
  6522. gridApi.selection.on.rowSelectionChangedBatch(
  6523. $scope,
  6524. function (data) {
  6525. $scope.selected.items.push(data.entity);
  6526. //console.log(data);
  6527. }
  6528. );
  6529. gridApi.core.on.filterChanged($scope, function () {
  6530. var grid = this.grid;
  6531. var filtersData = {
  6532. idx: 0,
  6533. sum: 10,
  6534. user: {
  6535. roledata: {
  6536. rolecode: "roleset",
  6537. },
  6538. selectType: "1",
  6539. },
  6540. };
  6541. angular.forEach(grid.columns, function (item) {
  6542. if (item.enableFiltering) {
  6543. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6544. if (
  6545. angular.isDefined(item.filters[0].term) &&
  6546. item.filters[0].term != ""
  6547. ) {
  6548. if (angular.isUndefined(filtersData["user"])) {
  6549. filtersData["user"] = {};
  6550. }
  6551. filtersData["user"][item.field] = item.filters[0].term;
  6552. }
  6553. }
  6554. });
  6555. $scope.memoryfilterDatahao = filtersData;
  6556. $scope.loadData(filtersData);
  6557. });
  6558. };
  6559. $scope.removehaocai = function (item) {
  6560. event.preventDefault();
  6561. // var modalInstance = $modal.open({
  6562. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6563. // controller: function($scope, $modalInstance) {
  6564. // $scope.title = "修改耗材数量";
  6565. // $scope.consumptive = item;
  6566. // $scope.ok = function() {
  6567. // $modalInstance.close($scope.consumptive);
  6568. // };
  6569. // $scope.cancel = function() {
  6570. // $modalInstance.dismiss('cancel');
  6571. // };
  6572. // },
  6573. // size: 'sm'
  6574. // });
  6575. var modalInstance = $modal.open({
  6576. templateUrl: "assets/views/delete.html",
  6577. controller: function ($scope, $modalInstance, scope) {
  6578. $scope.title = "耗材移除";
  6579. $scope.connect = "确定要移除此设备?";
  6580. $scope.consumptive = scope.selected.items[0];
  6581. $scope.ok = function () {
  6582. $modalInstance.close($scope.consumptive);
  6583. };
  6584. $scope.cancel = function () {
  6585. $modalInstance.dismiss("cancel");
  6586. };
  6587. },
  6588. size: "sm",
  6589. resolve: {
  6590. scope: function () {
  6591. return $scope;
  6592. },
  6593. },
  6594. });
  6595. modalInstance.result.then(function (selectedItem) {
  6596. // angular.forEach($scope.myData3, function(items, index) {
  6597. // if (items.id == selectedItem.id) {
  6598. // $scope.myData3[index] = selectedItem;
  6599. // }
  6600. // })
  6601. // $scope.model.applicationForm.consumables = $scope.myData3;
  6602. angular.forEach($scope.myDataoneall, function (items, index) {
  6603. if (items.id == selectedItem.id) {
  6604. $scope.myDataoneall.splice(index, 1);
  6605. }
  6606. });
  6607. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6608. $scope.myDataoneall[i]["item"] =
  6609. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6610. }
  6611. $scope.myDataone = $scope.interceptMydata(
  6612. $scope.myDataoneall,
  6613. 0,
  6614. 10
  6615. );
  6616. $scope.model.consumables = $scope.myDataoneall;
  6617. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6618. $scope.myDataoneall;
  6619. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6620. $scope.selected = {
  6621. items: [],
  6622. };
  6623. });
  6624. };
  6625. $scope.haocaiadd = function () {
  6626. event.preventDefault();
  6627. var modalInstance = $modal.open({
  6628. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6629. controller: function (
  6630. $scope,
  6631. scope,
  6632. $modalInstance,
  6633. api_wechatfile,
  6634. SweetAlert,
  6635. api_cmdb3
  6636. ) {
  6637. $scope.haocainame = [];
  6638. $scope.pinpai = [];
  6639. $scope.guige = [];
  6640. $scope.consumptive = {};
  6641. $scope.consumpall = {};
  6642. $scope.title = "添加耗材";
  6643. api_wechatfile
  6644. .getDictionaryForList({
  6645. key: "haocaifenlei",
  6646. })
  6647. .then(function (data) {
  6648. $scope.haocainame = data;
  6649. });
  6650. $scope.clearNoNum = function (obj, attr) {
  6651. //先把非数字的都替换掉,除了数字和.
  6652. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6653. //必须保证第一个为数字而不是.
  6654. obj[attr] = obj[attr].replace(/^\./g, "");
  6655. //保证只有出现一个.而没有多个.
  6656. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6657. //保证.只出现一次,而不能出现两次以上
  6658. obj[attr] = obj[attr]
  6659. .replace(".", "$#$")
  6660. .replace(/\./g, "")
  6661. .replace("$#$", ".");
  6662. //小于最大值
  6663. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6664. alert(
  6665. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6666. );
  6667. obj[attr] = "";
  6668. }
  6669. };
  6670. $scope.onChange = function (parent) {
  6671. $scope.consumptive.model = {};
  6672. $scope.consumptive.Specifications = {};
  6673. api_wechatfile
  6674. .getDictionaryForList({
  6675. key: "pinpai",
  6676. parent: parent.id,
  6677. })
  6678. .then(function (data) {
  6679. $scope.pinpai = data;
  6680. });
  6681. api_wechatfile
  6682. .getDictionaryForList({
  6683. key: "guige",
  6684. parent: parent.id,
  6685. })
  6686. .then(function (data) {
  6687. $scope.guige = data;
  6688. });
  6689. };
  6690. $scope.onChangesum = function (item) {
  6691. if (item.name && item.model.id && item.Specifications.id) {
  6692. $scope.consumptive.sum = "";
  6693. var data1 = {
  6694. idx: 0,
  6695. sum: 10,
  6696. consumable: {
  6697. name: item.name.name,
  6698. brandModel: item.model.name,
  6699. specification: item.Specifications.name,
  6700. },
  6701. };
  6702. api_cmdb3
  6703. .fetchDataList("consumable", data1)
  6704. .then(function (data) {
  6705. if (data.status == 200 && data.list.length > 0) {
  6706. var myData = data.list;
  6707. $scope.consumpall = myData[0];
  6708. $scope.maxsum = myData[0].inventoryNum;
  6709. } else {
  6710. SweetAlert.swal({
  6711. title: "不存在该耗材",
  6712. text: "请检查库存后重新填写!",
  6713. type: "error",
  6714. });
  6715. }
  6716. });
  6717. }
  6718. };
  6719. $scope.addhaocai = function () {
  6720. $modalInstance.dismiss("cancel");
  6721. scope.haocaiopen($scope.consumptive);
  6722. };
  6723. $scope.ok = function (item) {
  6724. var items = {};
  6725. // if (item.name && item.model && item.Specifications && item.sum) {
  6726. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6727. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6728. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6729. // $scope.consumpall.sum = item.sum;
  6730. // delete $scope.consumpall.brandModel;
  6731. // delete $scope.consumpall.specification;
  6732. // $modalInstance.close($scope.consumpall);
  6733. // } else {
  6734. // SweetAlert.swal({
  6735. // title: "数据填写不完整!",
  6736. // text: "请检查数据然后提交!",
  6737. // type: "error"
  6738. // });
  6739. // }
  6740. var isold = false;
  6741. if (
  6742. item.name &&
  6743. item.model &&
  6744. JSON.stringify(item.model) != "{}" &&
  6745. item.Specifications &&
  6746. JSON.stringify(item.Specifications) != "{}" &&
  6747. item.sum
  6748. ) {
  6749. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6750. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6751. isold = true;
  6752. }
  6753. }
  6754. if (isold) {
  6755. SweetAlert.swal({
  6756. title: "该耗材已添加!",
  6757. text: "请不要重复添加耗材!",
  6758. type: "error",
  6759. });
  6760. } else {
  6761. $scope.consumpall.model = $scope.consumpall.brandModel;
  6762. $scope.consumpall.Specifications =
  6763. $scope.consumpall.specification;
  6764. $scope.consumpall.sum = item.sum;
  6765. delete $scope.consumpall.brandModel;
  6766. delete $scope.consumpall.specification;
  6767. $modalInstance.close($scope.consumpall);
  6768. }
  6769. } else {
  6770. SweetAlert.swal({
  6771. title: "数据填写不完整!",
  6772. text: "请检查数据然后提交!",
  6773. type: "error",
  6774. });
  6775. }
  6776. // $modalInstance.close(item);
  6777. };
  6778. $scope.cancel = function () {
  6779. $modalInstance.dismiss("cancel");
  6780. };
  6781. },
  6782. size: "sm",
  6783. resolve: {
  6784. scope: function () {
  6785. return $scope;
  6786. },
  6787. },
  6788. });
  6789. modalInstance.result.then(function (selectedItem) {
  6790. $scope.myDataoneall.push(selectedItem);
  6791. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6792. $scope.myDataoneall[i]["item"] =
  6793. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6794. }
  6795. // $scope.model.consumables = $scope.myDataone;
  6796. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6797. $scope.myDataone = $scope.interceptMydata(
  6798. $scope.myDataoneall,
  6799. 0,
  6800. 10
  6801. );
  6802. $scope.model.consumables = $scope.myDataoneall;
  6803. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6804. $scope.myDataoneall;
  6805. });
  6806. };
  6807. $scope.onDblClick = function (data, event) {
  6808. $scope.selectButtonClick(data, event);
  6809. };
  6810. $scope.memoryfilterDatahao = {
  6811. idx: 0,
  6812. sum: 10,
  6813. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6814. };
  6815. $scope.myDataone = [];
  6816. $scope.loadData = function (filterData) { };
  6817. // $scope.title = title;
  6818. $scope.ldloading = {};
  6819. $scope.selected = {
  6820. items: [],
  6821. };
  6822. if ($scope.$parent.$parent.$parent.model.gettype) {
  6823. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6824. if ($scope.model.assets) {
  6825. if (JSON.stringify($scope.model.assets) == "{}") {
  6826. $scope.model.assets = [];
  6827. } else {
  6828. $scope.model.assets = JSON.parse($scope.model.assets);
  6829. }
  6830. $scope.myDatalingbeiall = $scope.model.assets;
  6831. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6832. $scope.myDatalingbeiall[i]["item"] =
  6833. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6834. }
  6835. $scope.gridOptions1["totalItems"] =
  6836. $scope.myDatalingbeiall.length;
  6837. $scope.myDatalingbei = $scope.interceptMydata(
  6838. $scope.myDatalingbeiall,
  6839. 0,
  6840. 10
  6841. );
  6842. }
  6843. if ($scope.model.consumables) {
  6844. if (JSON.stringify($scope.model.consumables) == "{}") {
  6845. $scope.model.consumables = [];
  6846. } else {
  6847. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6848. }
  6849. $scope.myDataoneall = $scope.model.consumables;
  6850. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6851. $scope.myDataoneall[i]["item"] =
  6852. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6853. }
  6854. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6855. $scope.myDataone = $scope.interceptMydata(
  6856. $scope.myDataoneall,
  6857. 0,
  6858. 10
  6859. );
  6860. }
  6861. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6862. $scope.options.templateOptions.getpush({
  6863. hao: true,
  6864. gu: true,
  6865. });
  6866. } else {
  6867. $scope.options.templateOptions.getpush({
  6868. hao: true,
  6869. });
  6870. }
  6871. } else {
  6872. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6873. $scope.options.templateOptions.getpush({
  6874. gu: true,
  6875. });
  6876. }
  6877. }
  6878. }
  6879. },
  6880. ],
  6881. });
  6882. formlyConfigProvider.setType({
  6883. name: "ui-panel",
  6884. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6885. });
  6886. formlyConfigProvider.setType({
  6887. name: "ui-currentuser",
  6888. extends: "input",
  6889. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6890. defaultOptions: function (options) {
  6891. return {
  6892. templateOptions: {
  6893. // link: function() {}
  6894. },
  6895. };
  6896. },
  6897. controller: [
  6898. "$scope",
  6899. function ($scope) {
  6900. if ($scope.options.templateOptions.user) {
  6901. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6902. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6903. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6904. // }
  6905. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6906. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6907. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6908. }
  6909. $scope.model[$scope.options.key] =
  6910. $scope.options.templateOptions.user;
  6911. $scope.options.initialValue = $scope.model[$scope.options.key];
  6912. }
  6913. },
  6914. ],
  6915. });
  6916. //仪表盘
  6917. //待处理变更列表
  6918. formlyConfigProvider.setType({
  6919. name: "ui-ngpchangetable",
  6920. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6921. defaultOptions: function (options) {
  6922. return {
  6923. templateOptions: {
  6924. // relationAction: function() {
  6925. // options.hideExpression = true
  6926. // }
  6927. },
  6928. };
  6929. },
  6930. controller: [
  6931. "$scope",
  6932. "$modal",
  6933. "$timeout",
  6934. "SweetAlert",
  6935. "api_bpm_domain",
  6936. "$rootScope",
  6937. "ngTableParams",
  6938. "$filter",
  6939. "$state",
  6940. function (
  6941. $scope,
  6942. $modal,
  6943. $timeout,
  6944. SweetAlert,
  6945. api_bpm_domain,
  6946. $rootScope,
  6947. ngTableParams,
  6948. $filter,
  6949. $state
  6950. ) {
  6951. // var filterData = {
  6952. // "assignee": $rootScope.user.id,
  6953. // "searchtype": "all",
  6954. // "idx": "0",
  6955. // "sum": "10"
  6956. // };
  6957. var filterData = {
  6958. idx: "0",
  6959. sum: "10",
  6960. assignee: 2,
  6961. searchType: "todo",
  6962. };
  6963. $scope.incidentprocess = function (item) {
  6964. $state.go("app.wt_change.add", {
  6965. taskId: item.taskId,
  6966. processInstanceId: item.processInstanceId,
  6967. });
  6968. };
  6969. $scope.more = function () {
  6970. $state.go("app.wt_change.list", {});
  6971. };
  6972. api_bpm_domain
  6973. .fetchtask("bpm_change", filterData)
  6974. .then(function (data) {
  6975. if (data.data) {
  6976. $scope.myData = data.data;
  6977. } else {
  6978. SweetAlert.swal({
  6979. title: "操作异常!",
  6980. text: "系统异常,请稍后重试,或者联系管理员!",
  6981. type: "error",
  6982. });
  6983. }
  6984. });
  6985. $scope.removes = function () {
  6986. var modalInstance = $modal.open({
  6987. templateUrl: "assets/views/delete.html",
  6988. controller: function ($scope, $modalInstance) {
  6989. $scope.ok = function () {
  6990. $modalInstance.close();
  6991. };
  6992. $scope.cancel = function () {
  6993. $modalInstance.dismiss("cancel");
  6994. };
  6995. },
  6996. size: "sm",
  6997. });
  6998. modalInstance.result.then(function () {
  6999. console.log($scope.$parent.$parent.$parent.$parent);
  7000. for (
  7001. var i = 0;
  7002. i <
  7003. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7004. i++
  7005. ) {
  7006. if (
  7007. $scope.fields.type ==
  7008. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7009. .type
  7010. ) {
  7011. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7012. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7013. i,
  7014. 1
  7015. );
  7016. break;
  7017. }
  7018. }
  7019. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7020. if (vmForm) {
  7021. //console.log("vmForm>>>");//console.log(vmForm);
  7022. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7023. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7024. }
  7025. });
  7026. };
  7027. },
  7028. ],
  7029. });
  7030. //待处理问题列表
  7031. formlyConfigProvider.setType({
  7032. name: "ui-ngproblemtable",
  7033. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7034. defaultOptions: function (options) {
  7035. return {
  7036. templateOptions: {
  7037. // relationAction: function() {
  7038. // options.hideExpression = true
  7039. // }
  7040. },
  7041. };
  7042. },
  7043. controller: [
  7044. "$scope",
  7045. "$modal",
  7046. "$timeout",
  7047. "SweetAlert",
  7048. "api_bpm_data",
  7049. "$rootScope",
  7050. "ngTableParams",
  7051. "$filter",
  7052. "$state",
  7053. function (
  7054. $scope,
  7055. $modal,
  7056. $timeout,
  7057. SweetAlert,
  7058. api_bpm_data,
  7059. $rootScope,
  7060. ngTableParams,
  7061. $filter,
  7062. $state
  7063. ) {
  7064. var filterData = {
  7065. assignee: $rootScope.user.id,
  7066. candidateGroups: $rootScope.user.group[0].id,
  7067. searchtype: "todo",
  7068. idx: 0,
  7069. sum: 10,
  7070. };
  7071. $scope.incidentprocess = function (item) {
  7072. $state.go("app.wt_change.add", {
  7073. taskId: item.taskId,
  7074. processInstanceId: item.processInstanceId,
  7075. });
  7076. };
  7077. $scope.more = function () {
  7078. $state.go("app.wt_change.list", {});
  7079. };
  7080. api_bpm_data
  7081. .fetchDataList("changeclassify", filterData)
  7082. .then(function (data) {
  7083. if (data.data) {
  7084. $scope.myData = data.data;
  7085. } else {
  7086. SweetAlert.swal({
  7087. title: "操作异常!",
  7088. text: "系统异常,请稍后重试,或者联系管理员!",
  7089. type: "error",
  7090. });
  7091. }
  7092. });
  7093. $scope.removes = function () {
  7094. var modalInstance = $modal.open({
  7095. templateUrl: "assets/views/delete.html",
  7096. controller: function ($scope, $modalInstance) {
  7097. $scope.ok = function () {
  7098. $modalInstance.close();
  7099. };
  7100. $scope.cancel = function () {
  7101. $modalInstance.dismiss("cancel");
  7102. };
  7103. },
  7104. size: "sm",
  7105. });
  7106. modalInstance.result.then(function () {
  7107. console.log($scope.$parent.$parent.$parent.$parent);
  7108. for (
  7109. var i = 0;
  7110. i <
  7111. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7112. i++
  7113. ) {
  7114. if (
  7115. $scope.fields.type ==
  7116. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7117. .type
  7118. ) {
  7119. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7120. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7121. i,
  7122. 1
  7123. );
  7124. break;
  7125. }
  7126. }
  7127. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7128. if (vmForm) {
  7129. //console.log("vmForm>>>");//console.log(vmForm);
  7130. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7131. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7132. }
  7133. });
  7134. };
  7135. },
  7136. ],
  7137. });
  7138. //待处理事件列表
  7139. formlyConfigProvider.setType({
  7140. name: "ui-ngtable",
  7141. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7142. defaultOptions: function (options) {
  7143. return {
  7144. templateOptions: {
  7145. // relationAction: function() {
  7146. // options.hideExpression = true
  7147. // }
  7148. },
  7149. };
  7150. },
  7151. controller: [
  7152. "$scope",
  7153. "$modal",
  7154. "$timeout",
  7155. "SweetAlert",
  7156. "api_bpm_domain",
  7157. "$rootScope",
  7158. "ngTableParams",
  7159. "$filter",
  7160. "$state",
  7161. function (
  7162. $scope,
  7163. $modal,
  7164. $timeout,
  7165. SweetAlert,
  7166. api_bpm_domain,
  7167. $rootScope,
  7168. ngTableParams,
  7169. $filter,
  7170. $state
  7171. ) {
  7172. var filterData = {
  7173. assignee: $rootScope.user.id,
  7174. candidateGroups: $rootScope.user.group[0].id,
  7175. searchtype: "done",
  7176. idx: 0,
  7177. sum: 10,
  7178. };
  7179. $scope.incidentprocess = function (item) {
  7180. $state.go("app.incident.editor", {
  7181. taskId: item.taskId,
  7182. processInstanceId: item.processInstanceId,
  7183. });
  7184. };
  7185. $scope.more = function () {
  7186. $state.go("app.incident.list", {});
  7187. };
  7188. api_bpm_domain
  7189. .fetchtask("bpm_incident", filterData)
  7190. .then(function (data) {
  7191. if (data.data) {
  7192. $scope.myData = data.data;
  7193. } else {
  7194. SweetAlert.swal({
  7195. title: "操作异常!",
  7196. text: "系统异常,请稍后重试,或者联系管理员!",
  7197. type: "error",
  7198. });
  7199. }
  7200. });
  7201. $scope.removes = function () {
  7202. var modalInstance = $modal.open({
  7203. templateUrl: "assets/views/delete.html",
  7204. controller: function ($scope, $modalInstance) {
  7205. $scope.ok = function () {
  7206. $modalInstance.close();
  7207. };
  7208. $scope.cancel = function () {
  7209. $modalInstance.dismiss("cancel");
  7210. };
  7211. },
  7212. size: "sm",
  7213. });
  7214. modalInstance.result.then(function () {
  7215. console.log($scope.$parent.$parent.$parent.$parent);
  7216. for (
  7217. var i = 0;
  7218. i <
  7219. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7220. i++
  7221. ) {
  7222. if (
  7223. $scope.fields.type ==
  7224. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7225. .type
  7226. ) {
  7227. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7228. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7229. i,
  7230. 1
  7231. );
  7232. break;
  7233. }
  7234. }
  7235. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7236. if (vmForm) {
  7237. //console.log("vmForm>>>");//console.log(vmForm);
  7238. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7239. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7240. }
  7241. });
  7242. };
  7243. },
  7244. ],
  7245. });
  7246. //知识库列表
  7247. formlyConfigProvider.setType({
  7248. name: "ui-knowledge",
  7249. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7250. defaultOptions: function (options) {
  7251. return {
  7252. templateOptions: {
  7253. // relationAction: function() {
  7254. // options.hideExpression = true
  7255. // }
  7256. },
  7257. };
  7258. },
  7259. controller: [
  7260. "$scope",
  7261. "$modal",
  7262. "$timeout",
  7263. "api_solution",
  7264. "$rootScope",
  7265. "ngTableParams",
  7266. "$filter",
  7267. "$state",
  7268. function (
  7269. $scope,
  7270. $modal,
  7271. $timeout,
  7272. api_solution,
  7273. $rootScope,
  7274. ngTableParams,
  7275. $filter,
  7276. $state
  7277. ) {
  7278. var filterData = {
  7279. key: "null",
  7280. pageIndex: 0,
  7281. pageSum: 6,
  7282. status: 0,
  7283. userId: $rootScope.user.id,
  7284. };
  7285. $scope.model.removereport = false;
  7286. $scope.removes = function () {
  7287. $scope.model.removereport = true;
  7288. };
  7289. $scope.more = function () {
  7290. $state.go("app.knowledge.manager", {});
  7291. };
  7292. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7293. if (data.status == 200) {
  7294. $scope.myData = data.list;
  7295. }
  7296. });
  7297. $scope.removes = function () {
  7298. var modalInstance = $modal.open({
  7299. templateUrl: "assets/views/delete.html",
  7300. controller: function ($scope, $modalInstance) {
  7301. $scope.ok = function () {
  7302. $modalInstance.close();
  7303. };
  7304. $scope.cancel = function () {
  7305. $modalInstance.dismiss("cancel");
  7306. };
  7307. },
  7308. size: "sm",
  7309. });
  7310. modalInstance.result.then(function () {
  7311. for (
  7312. var i = 0;
  7313. i <
  7314. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7315. i++
  7316. ) {
  7317. if (
  7318. $scope.fields.type ==
  7319. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7320. .type
  7321. ) {
  7322. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7323. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7324. i,
  7325. 1
  7326. );
  7327. break;
  7328. }
  7329. }
  7330. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7331. if (vmForm) {
  7332. //console.log("vmForm>>>");//console.log(vmForm);
  7333. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7334. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7335. }
  7336. });
  7337. };
  7338. },
  7339. ],
  7340. });
  7341. //公告列表
  7342. formlyConfigProvider.setType({
  7343. name: "ui-ngnotice",
  7344. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7345. defaultOptions: function (options) {
  7346. return {
  7347. templateOptions: {
  7348. // relationAction: function() {
  7349. // options.hideExpression = true
  7350. // }
  7351. },
  7352. };
  7353. },
  7354. controller: [
  7355. "$scope",
  7356. "$modal",
  7357. "$timeout",
  7358. "SweetAlert",
  7359. "api_user_data",
  7360. "$rootScope",
  7361. "ngTableParams",
  7362. "$filter",
  7363. "$state",
  7364. function (
  7365. $scope,
  7366. $modal,
  7367. $timeout,
  7368. SweetAlert,
  7369. api_user_data,
  7370. $rootScope,
  7371. ngTableParams,
  7372. $filter,
  7373. $state
  7374. ) {
  7375. var filterData = {
  7376. idx: 0,
  7377. sum: 10,
  7378. };
  7379. // $scope.$scope.model.className = "col-xs-12";
  7380. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7381. if (data) {
  7382. $scope.myData = data.data;
  7383. } else {
  7384. SweetAlert.swal({
  7385. title: "操作异常!",
  7386. text: "系统异常,请稍后重试,或者联系管理员!",
  7387. type: "error",
  7388. });
  7389. }
  7390. });
  7391. $scope.more = function () {
  7392. $state.go("app.system.notice.list", {});
  7393. };
  7394. $scope.removes = function () {
  7395. var modalInstance = $modal.open({
  7396. templateUrl: "assets/views/delete.html",
  7397. controller: function ($scope, $modalInstance) {
  7398. $scope.ok = function () {
  7399. $modalInstance.close();
  7400. };
  7401. $scope.cancel = function () {
  7402. $modalInstance.dismiss("cancel");
  7403. };
  7404. },
  7405. size: "sm",
  7406. });
  7407. modalInstance.result.then(function () {
  7408. for (
  7409. var i = 0;
  7410. i <
  7411. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7412. i++
  7413. ) {
  7414. if (
  7415. $scope.fields.type ==
  7416. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7417. .type
  7418. ) {
  7419. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7420. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7421. i,
  7422. 1
  7423. );
  7424. break;
  7425. }
  7426. }
  7427. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7428. if (vmForm) {
  7429. //console.log("vmForm>>>");//console.log(vmForm);
  7430. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7431. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7432. }
  7433. });
  7434. };
  7435. },
  7436. ],
  7437. });
  7438. //事件统计图
  7439. formlyConfigProvider.setType({
  7440. name: "ui-incidentreport",
  7441. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7442. defaultOptions: function (options) {
  7443. return {
  7444. templateOptions: {
  7445. // relationAction: function() {
  7446. // options.hideExpression = true
  7447. // }
  7448. },
  7449. };
  7450. },
  7451. controller: [
  7452. "$scope",
  7453. "$modal",
  7454. "moment",
  7455. "api_report",
  7456. "$cookieStore",
  7457. function ($scope, $modal, moment, api_report, $cookieStore) {
  7458. api_report.getLicenseKey().then(function (response) {
  7459. $cookieStore.put("Auth-Token", response.token);
  7460. $scope.try_async_load();
  7461. });
  7462. $scope.try_async_load = function () {
  7463. $scope.my_data = [];
  7464. api_report.list().then(function (response) {
  7465. var dataList = response;
  7466. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7467. $scope.repoRoot.name = "事件报表";
  7468. convertRepoObject($scope.repoRoot);
  7469. $scope.my_data.push($scope.repoRoot);
  7470. });
  7471. };
  7472. var workspace = {};
  7473. $scope.repoRoot = null;
  7474. function getRepoRoot(repo, path) {
  7475. angular.forEach(repo, function (value, key) {
  7476. if (value.path == path) {
  7477. $scope.repoRoot = value;
  7478. } else {
  7479. if (
  7480. $scope.repoRoot == null &&
  7481. angular.isDefined(value.repoObjects)
  7482. ) {
  7483. getRepoRoot(value.repoObjects, path);
  7484. } else {
  7485. }
  7486. }
  7487. });
  7488. }
  7489. function convertRepoObject(repo) {
  7490. if (angular.isArray(repo)) {
  7491. angular.forEach(repo, function (value, key) {
  7492. convertRepoObject(value);
  7493. });
  7494. } else {
  7495. if (angular.isDefined(repo.name)) {
  7496. if (repo.name.indexOf(".") >= 0) {
  7497. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7498. } else {
  7499. repo.label = repo.name;
  7500. }
  7501. //delete repo.name;
  7502. }
  7503. if (angular.isDefined(repo.repoObjects)) {
  7504. repo.children = [];
  7505. repo.children = repo.repoObjects;
  7506. delete repo.repoObjects;
  7507. convertRepoObject(repo.children);
  7508. }
  7509. }
  7510. }
  7511. function parseDateParameter(parameters) {
  7512. var result = undefined;
  7513. if (angular.isArray(parameters)) {
  7514. // angular.forEach(parmeters,function(param){
  7515. // param.
  7516. // })
  7517. } else {
  7518. result = {};
  7519. for (var k in parameters) {
  7520. if (k.indexOf("Date") > 0) {
  7521. if (angular.isString(parameters[k])) {
  7522. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7523. "YYYY-MM-DD"
  7524. );
  7525. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7526. }
  7527. }
  7528. }
  7529. }
  7530. return result;
  7531. }
  7532. function ConvertDateParameter(parameters) {
  7533. var result = undefined;
  7534. if (angular.isArray(parameters)) {
  7535. //
  7536. } else {
  7537. result = {};
  7538. for (var k in parameters) {
  7539. if (k.indexOf("Date") > 0) {
  7540. if (angular.isDate(parameters[k])) {
  7541. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7542. } else if (angular.isString(parameters[k])) {
  7543. result[k] = parameters[k];
  7544. }
  7545. }
  7546. }
  7547. }
  7548. return result;
  7549. }
  7550. var incidentchart =
  7551. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7552. var queryUUID;
  7553. function genUUID() {
  7554. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7555. .replace(/[xy]/g, function (c) {
  7556. var r = (Math.random() * 16) | 0,
  7557. v = c == "x" ? r : (r & 0x3) | 0x8;
  7558. return v.toString(16);
  7559. })
  7560. .toUpperCase();
  7561. return uuid;
  7562. }
  7563. queryUUID = genUUID();
  7564. var pathincidenttimekey = [];
  7565. var incidenttime = {
  7566. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7567. "YYYYMMDD"
  7568. ),
  7569. endtimes: moment(new Date()).format("YYYYMMDD"),
  7570. };
  7571. var thisday = moment(new Date().getTime() + 86400000).format(
  7572. "YYYYMMDD"
  7573. );
  7574. var thisdaymine = Date.parse(
  7575. thisday.substr(4, 2) +
  7576. "/" +
  7577. thisday.substr(6, 2) +
  7578. "/" +
  7579. thisday.substr(0, 4)
  7580. );
  7581. var averages = [
  7582. [thisdaymine - 86400000 * 14, 0],
  7583. [thisdaymine - 86400000 * 13, 0],
  7584. [thisdaymine - 86400000 * 12, 0],
  7585. [thisdaymine - 86400000 * 11, 0],
  7586. [thisdaymine - 86400000 * 10, 0],
  7587. [thisdaymine - 86400000 * 9, 0],
  7588. [thisdaymine - 86400000 * 8, 0],
  7589. [thisdaymine - 86400000 * 7, 0],
  7590. [thisdaymine - 86400000 * 6, 0],
  7591. [thisdaymine - 86400000 * 5, 0],
  7592. [thisdaymine - 86400000 * 4, 0],
  7593. [thisdaymine - 86400000 * 3, 0],
  7594. [thisdaymine - 86400000 * 2, 0],
  7595. [thisdaymine - 86400000 * 1, 0],
  7596. [thisdaymine, 0],
  7597. ];
  7598. var getreportdata = function (incidenttime, path) {
  7599. api_report.getMdx(path, queryUUID).then(function (response) {
  7600. var mdxquery = response;
  7601. workspace.query = mdxquery;
  7602. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7603. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7604. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7605. weekuser(mdxquery);
  7606. });
  7607. };
  7608. getreportdata(incidenttime, incidentchart);
  7609. var weekuser = function (mdxquery) {
  7610. var key = [];
  7611. api_report.execute(mdxquery).then(function (data) {
  7612. $scope.rheaders = [];
  7613. $scope.rRows = [];
  7614. var reportData = data;
  7615. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7616. $scope.shows = true;
  7617. $scope.empty = "数据为空!";
  7618. } else {
  7619. angular.forEach(reportData.cellset, function (item, i) {
  7620. angular.forEach(averages, function (index, j) {
  7621. // angular.forEach(averages, function(item, index) {
  7622. if (item.length > 1 && i > 0 && item[1].value != "") {
  7623. if (
  7624. index[0] ==
  7625. Date.parse(
  7626. item[0].value.substr(4, 2) +
  7627. "/" +
  7628. item[0].value.substr(6, 2) +
  7629. "/" +
  7630. item[0].value.substr(0, 4)
  7631. ) +
  7632. 86400000
  7633. ) {
  7634. index[1] = Number(item[1].value);
  7635. }
  7636. // 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)]);
  7637. }
  7638. // })
  7639. });
  7640. });
  7641. incidentchartfun(averages);
  7642. }
  7643. });
  7644. };
  7645. var incidentchartfun = function (incidentchartkey) {
  7646. // $scope.isMaskincident = false;
  7647. Highcharts.chart("incidentchart", {
  7648. title: {
  7649. text: "事件近15天趋势图",
  7650. },
  7651. xAxis: {
  7652. type: "datetime",
  7653. labels: {
  7654. align: "left",
  7655. step: 1,
  7656. },
  7657. },
  7658. yAxis: {
  7659. title: {
  7660. text: null,
  7661. },
  7662. },
  7663. tooltip: {
  7664. crosshairs: true,
  7665. shared: true,
  7666. valueSuffix: "条",
  7667. },
  7668. legend: {},
  7669. series: [
  7670. {
  7671. name: "生成事件",
  7672. data: incidentchartkey,
  7673. zIndex: 1,
  7674. marker: {
  7675. fillColor: "white",
  7676. lineWidth: 2,
  7677. lineColor: Highcharts.getOptions().colors[0],
  7678. },
  7679. },
  7680. ],
  7681. });
  7682. };
  7683. $scope.data = {
  7684. labels: [
  7685. "1号",
  7686. "2号",
  7687. "3号",
  7688. "4号",
  7689. "5号",
  7690. "6号",
  7691. "7号",
  7692. "8号",
  7693. "9号",
  7694. "10号",
  7695. "11号",
  7696. "12号",
  7697. "13号",
  7698. "14号",
  7699. "15号",
  7700. ],
  7701. datasets: [
  7702. {
  7703. label: "新增事件数量",
  7704. fillColor: "rgba(220,220,220,0.2)",
  7705. strokeColor: "rgba(220,220,220,1)",
  7706. pointColor: "rgba(220,220,220,1)",
  7707. pointStrokeColor: "#fff",
  7708. pointHighlightFill: "#fff",
  7709. pointHighlightStroke: "rgba(220,220,220,1)",
  7710. data: [
  7711. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7712. ],
  7713. },
  7714. {
  7715. label: "已解决事件数量",
  7716. fillColor: "rgba(151,187,205,0.2)",
  7717. strokeColor: "rgba(151,187,205,1)",
  7718. pointColor: "rgba(151,187,205,1)",
  7719. pointStrokeColor: "#fff",
  7720. pointHighlightFill: "#fff",
  7721. pointHighlightStroke: "rgba(151,187,205,1)",
  7722. data: [
  7723. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7724. ],
  7725. },
  7726. ],
  7727. };
  7728. $scope.removes = function () {
  7729. var modalInstance = $modal.open({
  7730. templateUrl: "assets/views/delete.html",
  7731. controller: function ($scope, $modalInstance) {
  7732. $scope.ok = function () {
  7733. $modalInstance.close();
  7734. };
  7735. $scope.cancel = function () {
  7736. $modalInstance.dismiss("cancel");
  7737. };
  7738. },
  7739. size: "sm",
  7740. });
  7741. modalInstance.result.then(function () {
  7742. for (
  7743. var i = 0;
  7744. i <
  7745. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7746. i++
  7747. ) {
  7748. if (
  7749. $scope.fields.type ==
  7750. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7751. .type
  7752. ) {
  7753. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7754. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7755. i,
  7756. 1
  7757. );
  7758. break;
  7759. }
  7760. }
  7761. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7762. if (vmForm) {
  7763. //console.log("vmForm>>>");//console.log(vmForm);
  7764. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7765. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7766. }
  7767. });
  7768. };
  7769. var addDatas = 0;
  7770. var resolve = 0;
  7771. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7772. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7773. }
  7774. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7775. resolve = resolve + $scope.data.datasets[1].data[i];
  7776. }
  7777. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7778. $scope.opt = {
  7779. maintainAspectRatio: false,
  7780. // Sets the chart to be responsive
  7781. responsive: true,
  7782. ///Boolean - Whether grid lines are shown across the chart
  7783. scaleShowGridLines: true,
  7784. //String - Colour of the grid lines
  7785. scaleGridLineColor: "rgba(0,0,0,.05)",
  7786. //Number - Width of the grid lines
  7787. scaleGridLineWidth: 1,
  7788. //Boolean - Whether the line is curved between points
  7789. bezierCurve: false,
  7790. //Number - Tension of the bezier curve between points
  7791. bezierCurveTension: 0.4,
  7792. //Boolean - Whether to show a dot for each point
  7793. pointDot: true,
  7794. //Number - Radius of each point dot in pixels
  7795. pointDotRadius: 4,
  7796. //Number - Pixel width of point dot stroke
  7797. pointDotStrokeWidth: 1,
  7798. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7799. pointHitDetectionRadius: 20,
  7800. //Boolean - Whether to show a stroke for datasets
  7801. datasetStroke: true,
  7802. //Number - Pixel width of dataset stroke
  7803. datasetStrokeWidth: 2,
  7804. //Boolean - Whether to fill the dataset with a colour
  7805. datasetFill: true,
  7806. // Function - on animation progress
  7807. onAnimationProgress: function () { },
  7808. // Function - on animation complete
  7809. onAnimationComplete: function () { },
  7810. //String - A legend template
  7811. legendTemplate:
  7812. '<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>',
  7813. };
  7814. angular.extend($scope.options, $scope.opt);
  7815. $scope.datamonth = {
  7816. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7817. datasets: [
  7818. {
  7819. label: "新增事件数量",
  7820. fillColor: "rgba(220,220,220,0.5)",
  7821. strokeColor: "rgba(220,220,220,0.8)",
  7822. highlightFill: "rgba(220,220,220,0.75)",
  7823. highlightStroke: "rgba(220,220,220,1)",
  7824. data: [65, 59, 80, 81, 56, 55],
  7825. },
  7826. {
  7827. label: "已解决事件数量",
  7828. fillColor: "rgba(151,187,205,0.5)",
  7829. strokeColor: "rgba(151,187,205,0.8)",
  7830. highlightFill: "rgba(151,187,205,0.75)",
  7831. highlightStroke: "rgba(151,187,205,1)",
  7832. data: [28, 48, 40, 19, 86, 27],
  7833. },
  7834. ],
  7835. };
  7836. // Chart.js Options
  7837. $scope.taption = {
  7838. maintainAspectRatio: false,
  7839. // Sets the chart to be responsive
  7840. responsive: true,
  7841. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7842. scaleBeginAtZero: true,
  7843. //Boolean - Whether grid lines are shown across the chart
  7844. scaleShowGridLines: true,
  7845. //String - Colour of the grid lines
  7846. scaleGridLineColor: "rgba(0,0,0,.05)",
  7847. //Number - Width of the grid lines
  7848. scaleGridLineWidth: 1,
  7849. //Boolean - If there is a stroke on each bar
  7850. barShowStroke: true,
  7851. //Number - Pixel width of the bar stroke
  7852. barStrokeWidth: 2,
  7853. //Number - Spacing between each of the X value sets
  7854. barValueSpacing: 5,
  7855. //Number - Spacing between data sets within X values
  7856. barDatasetSpacing: 1,
  7857. //String - A legend template
  7858. legendTemplate:
  7859. '<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>',
  7860. };
  7861. },
  7862. ],
  7863. });
  7864. //排版日历
  7865. formlyConfigProvider.setType({
  7866. name: "ui-dashcalendar",
  7867. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7868. defaultOptions: function (options) {
  7869. return {
  7870. templateOptions: {
  7871. // relationAction: function() {
  7872. // options.hideExpression = true
  7873. // }
  7874. },
  7875. };
  7876. },
  7877. controller: [
  7878. "$rootScope",
  7879. "$scope",
  7880. "$modal",
  7881. "$aside",
  7882. "calendarConfig",
  7883. "moment",
  7884. "SweetAlert",
  7885. "Restangular",
  7886. "api_bpm_schedule",
  7887. "api_user_data",
  7888. "$state",
  7889. function (
  7890. $rootScope,
  7891. $scope,
  7892. $modal,
  7893. $aside,
  7894. calendarConfig,
  7895. moment,
  7896. SweetAlert,
  7897. Restangular,
  7898. api_bpm_schedule,
  7899. api_user_data,
  7900. $state
  7901. ) {
  7902. var loginUser = $rootScope.user;
  7903. calendarConfig.dateFormatter = "moment";
  7904. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7905. calendarConfig.i18nStrings.timeLabel = "时间";
  7906. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7907. calendarConfig.allDateFormats = {
  7908. angular: {
  7909. date: {
  7910. hour: "ha",
  7911. day: "d MMM",
  7912. month: "MMMM",
  7913. weekDay: "EEEE",
  7914. time: "HH:mm",
  7915. datetime: "MMM d, h:mm a",
  7916. },
  7917. title: {
  7918. day: "yyyy MMMM EEEE d",
  7919. week: "{year}年第{week}周",
  7920. month: "yyyy MMMM",
  7921. year: "yyyy",
  7922. },
  7923. },
  7924. moment: {
  7925. date: {
  7926. hour: "ha",
  7927. day: "MMMDD日",
  7928. month: "MMMM",
  7929. weekDay: "dddd",
  7930. time: "HH:mm",
  7931. datetime: "MMM D, h:mm a",
  7932. },
  7933. title: {
  7934. day: "YYYY年MMMMDD日, dddd ",
  7935. week: "{year}年第{week}周",
  7936. month: "YYYY年MMMM",
  7937. year: "YYYY",
  7938. },
  7939. },
  7940. };
  7941. moment.locale("zh_cn", {
  7942. months:
  7943. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7944. "_"
  7945. ),
  7946. monthsShort:
  7947. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7948. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7949. "_"
  7950. ),
  7951. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7952. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7953. longDateFormat: {
  7954. LT: "Ah点mm分",
  7955. LTS: "Ah点m分s秒",
  7956. L: "YYYY-MM-DD",
  7957. LL: "YYYY年MMMD日",
  7958. LLL: "YYYY年MMMD日Ah点mm分",
  7959. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7960. l: "YYYY-MM-DD",
  7961. ll: "YYYY年MMMD日",
  7962. lll: "YYYY年MMMD日Ah点mm分",
  7963. llll: "YYYY年MMMD日ddddAh点mm分",
  7964. },
  7965. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7966. meridiemHour: function (hour, meridiem) {
  7967. if (hour === 12) {
  7968. hour = 0;
  7969. }
  7970. if (
  7971. meridiem === "凌晨" ||
  7972. meridiem === "早上" ||
  7973. meridiem === "上午"
  7974. ) {
  7975. return hour;
  7976. } else if (meridiem === "下午" || meridiem === "晚上") {
  7977. return hour + 12;
  7978. } else {
  7979. // '中午'
  7980. return hour >= 11 ? hour : hour + 12;
  7981. }
  7982. },
  7983. meridiem: function (hour, minute, isLower) {
  7984. var hm = hour * 100 + minute;
  7985. if (hm < 600) {
  7986. return "凌晨";
  7987. } else if (hm < 900) {
  7988. return "早上";
  7989. } else if (hm < 1130) {
  7990. return "上午";
  7991. } else if (hm < 1230) {
  7992. return "中午";
  7993. } else if (hm < 1800) {
  7994. return "下午";
  7995. } else {
  7996. return "晚上";
  7997. }
  7998. },
  7999. calendar: {
  8000. sameDay: function () {
  8001. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8002. },
  8003. nextDay: function () {
  8004. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8005. },
  8006. lastDay: function () {
  8007. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8008. },
  8009. nextWeek: function () {
  8010. var startOfWeek, prefix;
  8011. startOfWeek = moment().startOf("week");
  8012. prefix =
  8013. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8014. ? "[下]"
  8015. : "[本]";
  8016. return this.minutes() === 0
  8017. ? prefix + "dddAh点整"
  8018. : prefix + "dddAh点mm";
  8019. },
  8020. lastWeek: function () {
  8021. var startOfWeek, prefix;
  8022. startOfWeek = moment().startOf("week");
  8023. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8024. return this.minutes() === 0
  8025. ? prefix + "dddAh点整"
  8026. : prefix + "dddAh点mm";
  8027. },
  8028. sameElse: "LL",
  8029. },
  8030. ordinalParse: /\d{1,2}(日|月|周)/,
  8031. ordinal: function (number, period) {
  8032. switch (period) {
  8033. case "d":
  8034. case "D":
  8035. case "DDD":
  8036. return number + "日";
  8037. case "M":
  8038. return number + "月";
  8039. case "w":
  8040. case "W":
  8041. return number + "周";
  8042. default:
  8043. return number;
  8044. }
  8045. },
  8046. relativeTime: {
  8047. future: "%s内",
  8048. past: "%s前",
  8049. s: "几秒",
  8050. m: "1 分钟",
  8051. mm: "%d 分钟",
  8052. h: "1 小时",
  8053. hh: "%d 小时",
  8054. d: "1 天",
  8055. dd: "%d 天",
  8056. M: "1 个月",
  8057. MM: "%d 个月",
  8058. y: "1 年",
  8059. yy: "%d 年",
  8060. },
  8061. week: {
  8062. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8063. dow: 1, // Monday is the first day of the week.
  8064. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8065. },
  8066. });
  8067. var date = new Date();
  8068. var d = date.getDate();
  8069. var m = date.getMonth();
  8070. var y = date.getFullYear();
  8071. var filterData = {
  8072. userId: loginUser.id,
  8073. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8074. "YYYY-MM-DD HH:mm:ss"
  8075. ),
  8076. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8077. "YYYY-MM-DD HH:mm:ss"
  8078. ),
  8079. };
  8080. var load = ($scope.load = function (filterData) {
  8081. api_bpm_schedule
  8082. .fetchSchedule(
  8083. filterData.userId,
  8084. filterData.startTime,
  8085. filterData.endTime
  8086. )
  8087. .then(function (response) {
  8088. if (response.status == 200) {
  8089. $scope.events = [];
  8090. var myData = response.list;
  8091. angular.forEach(myData, function (item) {
  8092. var eventTemp = {};
  8093. eventTemp.title = item.description;
  8094. eventTemp.type = item.scheduleClass.code;
  8095. eventTemp.startsAt = moment(
  8096. item["scheduleOrderDTO"].startTime
  8097. ).toDate();
  8098. eventTemp.endsAtTime = moment(
  8099. item["scheduleOrderDTO"].endTime
  8100. ).toDate();
  8101. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8102. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8103. //eventTemp.ends_at = moment(item.endTime).toDate();
  8104. eventTemp.id = item.id;
  8105. eventTemp.deletable = false;
  8106. eventTemp.user = item.user;
  8107. $scope.events.push(eventTemp);
  8108. });
  8109. }
  8110. });
  8111. });
  8112. // var load = $scope.load = function(filterData){
  8113. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8114. // console.log("response="+JSON.stringify(response));
  8115. // if(response.status==200){
  8116. // $scope.events = [];
  8117. // console.log(response.list);
  8118. // var myData = response.list;
  8119. // angular.forEach(myData,function(item){
  8120. // var eventTemp = {};
  8121. // eventTemp.title = item.description;
  8122. // eventTemp.type = item.scheduleClass.code;
  8123. // eventTemp.startsAt = moment(item.startTime).toDate();
  8124. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8125. // eventTemp.startTime = item.startTime;
  8126. // eventTemp.endTime = item.endTime;
  8127. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8128. // eventTemp.id = item.id;
  8129. // eventTemp.deletable = false;
  8130. // eventTemp.users = item.users;
  8131. // $scope.events.push(eventTemp);
  8132. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8133. // })
  8134. // }
  8135. // });
  8136. // }
  8137. $scope.scheduleClass = {};
  8138. var convertEvent = function (scheduleorder) {
  8139. var eventTemp = {};
  8140. eventTemp.title = scheduleorder.description;
  8141. eventTemp.type = scheduleorder.scheduleClass.code;
  8142. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8143. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8144. eventTemp.id = scheduleorder.id;
  8145. eventTemp.user = scheduleorder.user;
  8146. eventTemp.deletable = false;
  8147. return eventTemp;
  8148. };
  8149. // var convertEvent = function(scheduleorder){
  8150. // var eventTemp = {};
  8151. // eventTemp.title = scheduleorder.description;
  8152. // eventTemp.type = scheduleorder.scheduleClass.code;
  8153. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8154. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8155. // eventTemp.id = scheduleorder.id;
  8156. // eventTemp.users = scheduleorder.users;
  8157. // eventTemp.deletable = false;
  8158. // return eventTemp;
  8159. // }
  8160. api_bpm_schedule.getScheduleClass().then(function (response) {
  8161. if (response.status == 200) {
  8162. var scheduleClassList = response.list;
  8163. angular.forEach(scheduleClassList, function (item) {
  8164. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8165. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8166. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8167. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8168. $scope.scheduleClass[item["code"]] = item;
  8169. });
  8170. }
  8171. });
  8172. $scope.events = [];
  8173. $scope.calendarView = "month";
  8174. //$scope.calendarDay = new Date();
  8175. $scope.calendarDate = moment().startOf("month").toDate();
  8176. $scope.timeLabel = "时间";
  8177. $scope.eventLabel = "描述";
  8178. function showModal(action, event) {
  8179. // console.log("action="+JSON.stringify(action))
  8180. var modalInstance = $aside.open({
  8181. templateUrl: "scheduleEvent.html",
  8182. placement: "right",
  8183. size: "sm",
  8184. backdrop: true,
  8185. controller: function (
  8186. $scope,
  8187. $modalInstance,
  8188. scheduleClass,
  8189. APIService,
  8190. MementFormat
  8191. ) {
  8192. $scope.$modalInstance = $modalInstance;
  8193. $scope.action = action;
  8194. $scope.event = event;
  8195. $scope.scheduleClassic = scheduleClass;
  8196. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8197. // if(oldvalue == newvalue) return;
  8198. // if(scheduleClass[newvalue]){
  8199. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8200. var em = MementFormat(scheduleClass[newvalue].endTime);
  8201. console.log("sm=" + JSON.stringify(sm));
  8202. event.starts_at = MementFormat(event.startTime)
  8203. .startOf("day")
  8204. .add(sm.hour(), "hour")
  8205. .add(sm.minute(), "minute")
  8206. .add(sm.second(), "second")
  8207. .toDate();
  8208. console.log(
  8209. "event.starts_at=" + JSON.stringify(event.starts_at)
  8210. );
  8211. if (sm.hour() > em.hour()) {
  8212. event.ends_at = MementFormat(event.startTime)
  8213. .startOf("day")
  8214. .add(1, "day")
  8215. .add(em.hour(), "hour")
  8216. .add(em.minute(), "minute")
  8217. .add(em.second(), "second")
  8218. .toDate();
  8219. console.log(
  8220. "event.ends_at=" + JSON.stringify(event.starts_at)
  8221. );
  8222. } else {
  8223. event.ends_at = MementFormat(event.startTime)
  8224. .startOf("day")
  8225. .add(em.hour(), "hour")
  8226. .add(em.minute(), "minute")
  8227. .add(em.second(), "second")
  8228. .toDate();
  8229. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8230. }
  8231. // }
  8232. });
  8233. // $scope.ok = function (event) {
  8234. // console.log("event="+JSON.stringify(event))
  8235. // event.action = action;
  8236. // $modalInstance.close(event);
  8237. // };
  8238. $scope.cancel = function (event) {
  8239. $modalInstance.dismiss();
  8240. };
  8241. var acUserSelect = ($scope.refreshUser = function (key) {
  8242. //for test
  8243. // $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":"管理层"}]}];
  8244. // return;
  8245. var data = {
  8246. idx: "0",
  8247. sum: "5",
  8248. };
  8249. if (key) {
  8250. data["user"] = {
  8251. name: key,
  8252. };
  8253. }
  8254. APIService.fetchDataList("user", data).then(function (
  8255. response
  8256. ) {
  8257. if (response) {
  8258. if ((response.status = 200)) {
  8259. $scope.users = response.list;
  8260. console.log($scope.users);
  8261. }
  8262. }
  8263. });
  8264. });
  8265. if (angular.isDefined(event.users) && event.users.length > 0) {
  8266. }
  8267. $scope.users = [event.user];
  8268. acUserSelect();
  8269. },
  8270. resolve: {
  8271. scheduleClass: function () {
  8272. return $scope.scheduleClass;
  8273. },
  8274. APIService: function () {
  8275. return api_user_data;
  8276. },
  8277. MementFormat: function () {
  8278. return moment;
  8279. },
  8280. },
  8281. });
  8282. modalInstance.result.then(function (selectedEvent) {
  8283. if (selectedEvent.action == "Clicked") {
  8284. // var data = {
  8285. // "scheduleorder":{
  8286. // "id":selectedEvent.id,
  8287. // "description":selectedEvent.title,
  8288. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8289. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8290. // "users":selectedEvent.users,
  8291. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8292. // }
  8293. // };
  8294. // api_bpm_schedule.update(data).then(function(response){
  8295. // if(response.status==200){
  8296. // SweetAlert.swal({
  8297. // title: "操作成功!",
  8298. // text: "排班更新成功!",
  8299. // type: "succes"
  8300. // });
  8301. // angular.forEach($scope.events,function(item){
  8302. // if(item.id==selectedEvent.id){
  8303. // item = selectedEvent;
  8304. // }
  8305. // })
  8306. // }else{
  8307. // SweetAlert.swal({
  8308. // title: "操作失败",
  8309. // text: "排班更新失败,请稍后重试!",
  8310. // type: "error"
  8311. // })
  8312. // }
  8313. // })
  8314. } else {
  8315. //
  8316. }
  8317. });
  8318. }
  8319. $scope.moment = function (string) {
  8320. return moment(string);
  8321. };
  8322. $scope.eventClicked = function (event) {
  8323. // console.log("event="+JSON.stringify(event))
  8324. showModal("Clicked", event);
  8325. };
  8326. $scope.eventEdited = function (event) {
  8327. showModal("Edited", event);
  8328. };
  8329. var updateView = function (newvalue, oldvalue) {
  8330. if (oldvalue == newvalue) return;
  8331. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8332. if ($scope.calendarView == "year") {
  8333. } else if ($scope.calendarView == "month") {
  8334. timeStart = moment(newvalue).startOf("month");
  8335. timeEnd = moment(newvalue).endOf("month");
  8336. } else if ($scope.calendarView == "week") {
  8337. timeStart = moment(newvalue).startOf("week");
  8338. timeEnd = moment(newvalue).endOf("week");
  8339. } else if ($scope.calendarView == "Day") {
  8340. timeStart = moment(newvalue).startOf("day");
  8341. timeEnd = moment(newvalue).endOf("day");
  8342. }
  8343. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8344. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8345. filterData["startTime"] = timeStartSpan;
  8346. filterData["endTime"] = timeEndSpan;
  8347. load(filterData);
  8348. };
  8349. $scope.$watch("calendarDate", updateView);
  8350. $scope.next = function () {
  8351. $scope.calendarControl.next();
  8352. };
  8353. $scope.prev = function () {
  8354. $scope.calendarControl.prev();
  8355. };
  8356. $scope.setCalendarToToday = function () {
  8357. $scope.calendarDay = new Date();
  8358. };
  8359. $scope.toggle = function ($event, field, event) {
  8360. $event.preventDefault();
  8361. $event.stopPropagation();
  8362. event[field] = !event[field];
  8363. };
  8364. $scope.load(filterData);
  8365. $scope.more = function () {
  8366. $state.go("app.scheduling.myscheduling", {});
  8367. };
  8368. $scope.removes = function () {
  8369. var modalInstance = $modal.open({
  8370. templateUrl: "assets/views/delete.html",
  8371. controller: function ($scope, $modalInstance) {
  8372. $scope.ok = function () {
  8373. $modalInstance.close();
  8374. };
  8375. $scope.cancel = function () {
  8376. $modalInstance.dismiss("cancel");
  8377. };
  8378. },
  8379. size: "sm",
  8380. });
  8381. modalInstance.result.then(function () {
  8382. for (
  8383. var i = 0;
  8384. i <
  8385. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8386. i++
  8387. ) {
  8388. if (
  8389. $scope.fields.type ==
  8390. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8391. .type
  8392. ) {
  8393. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8394. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8395. i,
  8396. 1
  8397. );
  8398. break;
  8399. }
  8400. }
  8401. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8402. if (vmForm) {
  8403. //console.log("vmForm>>>");//console.log(vmForm);
  8404. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8405. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8406. }
  8407. });
  8408. };
  8409. },
  8410. ],
  8411. });
  8412. //空格组件
  8413. formlyConfigProvider.setType({
  8414. name: "ui-black",
  8415. /*extends: 'input',*/
  8416. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8417. });
  8418. //请求人最近事件
  8419. formlyConfigProvider.setType({
  8420. name: "ui-recentIncident",
  8421. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8422. controller: [
  8423. "$scope",
  8424. "$modal",
  8425. "api_solution",
  8426. function ($scope, $modal, api_solution) {
  8427. var filterData = {
  8428. incident: {
  8429. requester: {
  8430. id: "",
  8431. },
  8432. },
  8433. idx: 0,
  8434. sum: 3,
  8435. };
  8436. setInterval(function () {
  8437. if (
  8438. filterData.incident.requester.id == "" ||
  8439. filterData.incident.requester.id != $scope.model.requester.id
  8440. ) {
  8441. var requester = $scope.model.requester;
  8442. if (requester != null && angular.isDefined(requester.id)) {
  8443. filterData.incident.requester.id = $scope.model.requester.id;
  8444. $scope.options.templateOptions
  8445. .getWorkernumber(
  8446. $scope.options.templateOptions.ApiService,
  8447. filterData
  8448. )
  8449. .then(function (result) {
  8450. var modelData =
  8451. $scope.options.templateOptions.Restangular.stripRestangular(
  8452. result
  8453. );
  8454. if (modelData.status == 200) {
  8455. $scope.lastrequst = modelData.list;
  8456. }
  8457. });
  8458. requester = null;
  8459. } else {
  8460. }
  8461. } else {
  8462. }
  8463. }, 1000);
  8464. $scope.detail = function (data) {
  8465. var modalInstance = $modal.open({
  8466. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8467. controller: function ($scope, $modalInstance) {
  8468. $scope.entity = {};
  8469. $scope.entity = data;
  8470. $scope.cancel = function () {
  8471. $modalInstance.dismiss("cancel");
  8472. };
  8473. },
  8474. size: "lg",
  8475. });
  8476. };
  8477. },
  8478. ],
  8479. });
  8480. //参数列表
  8481. formlyConfigProvider.setType({
  8482. name: "ui-listinput",
  8483. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8484. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8485. defaultOptions: function (options) {
  8486. return {
  8487. templateOptions: {},
  8488. };
  8489. },
  8490. controller: ["$scope", function ($scope) { }],
  8491. });
  8492. //时间段控件(分)
  8493. formlyConfigProvider.setType({
  8494. name: "ui-timeslot",
  8495. extends: "input",
  8496. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8497. controller: ["$scope", function ($scope) { }],
  8498. });
  8499. //优先级级联-逾期时间
  8500. formlyConfigProvider.setType({
  8501. name: "ui-overtime",
  8502. extends: "input",
  8503. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8504. controller: [
  8505. "$scope",
  8506. "api_bpm_domain",
  8507. function ($scope, api_bpm_domain) {
  8508. var filteData = {};
  8509. var datas = {};
  8510. setInterval(function () {
  8511. if (
  8512. $scope.model.priority &&
  8513. $scope.model.priority.id != null &&
  8514. filteData &&
  8515. datas != $scope.model.priority.id
  8516. ) {
  8517. filteData = "L" + $scope.model.priority.id;
  8518. datas = $scope.model.priority.id;
  8519. // console.log($scope.options.templateOptions)
  8520. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8521. // var overtime=requester.date;
  8522. if (requester.state == 200) {
  8523. // if($scope.options.key=="date"){
  8524. $scope.model[$scope.options.key] = requester.date;
  8525. // }
  8526. }
  8527. });
  8528. }
  8529. }, 1000);
  8530. },
  8531. ],
  8532. });
  8533. formlyConfigProvider.setType({
  8534. name: "ui-responsetime",
  8535. extends: "input",
  8536. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8537. controller: [
  8538. "$scope",
  8539. "api_bpm_domain",
  8540. function ($scope, api_bpm_domain) {
  8541. var filteData = {};
  8542. var datas = {};
  8543. setInterval(function () {
  8544. if (
  8545. $scope.model.priority &&
  8546. $scope.model.priority.id != null &&
  8547. filteData &&
  8548. datas != $scope.model.priority.id
  8549. ) {
  8550. filteData = "L" + $scope.model.priority.id;
  8551. datas = $scope.model.priority.id;
  8552. // console.log($scope.options.templateOptions)
  8553. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8554. // var overtime=requester.date;
  8555. if (requester.state == 200) {
  8556. var keyName = {};
  8557. // $scope.model.overdueTime = requester.date;
  8558. if ($scope.options.key == "expectIntroTime") {
  8559. keyName = "resolveTime";
  8560. } else if ($scope.options.key == "expectResponseTime") {
  8561. keyName = "responseTime";
  8562. }
  8563. $scope.model[$scope.options.key] =
  8564. requester.serviceLevelAgreement[keyName];
  8565. // }
  8566. console.log($scope.$parent.$parent.$parent.model);
  8567. }
  8568. if (requester.date1) {
  8569. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8570. requester.date;
  8571. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8572. requester.date1;
  8573. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8574. requester.serviceLevelAgreement.resolveTime;
  8575. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8576. requester.serviceLevelAgreement.responseTime;
  8577. }
  8578. });
  8579. }
  8580. }, 1000);
  8581. },
  8582. ],
  8583. });
  8584. //知识库按钮组件
  8585. formlyConfigProvider.setType({
  8586. name: "ui-discasecade",
  8587. extends: "input",
  8588. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8589. defaultOptions: function (options) {
  8590. return {
  8591. templateOptions: {
  8592. relationAction: function (fields, modelscope, item) { },
  8593. },
  8594. validators: {
  8595. required: {
  8596. expression: function (viewValue, modelValue) {
  8597. var value = modelValue || viewValue;
  8598. // return value = "true";
  8599. },
  8600. },
  8601. },
  8602. };
  8603. },
  8604. controller: [
  8605. "$scope",
  8606. "$rootScope",
  8607. "$modal",
  8608. "SweetAlert",
  8609. "api_bpm_data",
  8610. "api_solution",
  8611. "$aside",
  8612. "api_zsk",
  8613. "api_bpm_domain",
  8614. function (
  8615. $scope,
  8616. $rootScope,
  8617. $modal,
  8618. SweetAlert,
  8619. api_bpm_data,
  8620. api_solution,
  8621. $aside,
  8622. api_zsk,
  8623. api_bpm_domain
  8624. ) {
  8625. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8626. $scope.searchField = $scope.options.model[$scope.options.key];
  8627. $scope.searchData = "";
  8628. $scope.onChangeadd = function (searchData) {
  8629. $scope.searchKey = searchData.account;
  8630. // $scope.searchDataadd = searchData;
  8631. var requesdata = angular.copy(searchData);
  8632. $scope.requester = requesdata;
  8633. };
  8634. $scope.refreshUseradd = function (searchKey) {
  8635. //主题搜索
  8636. $scope.searchData = searchKey;
  8637. reashdata($scope.searchData);
  8638. };
  8639. $scope.getMydata = function (x) {
  8640. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8641. $scope.searchField = $scope.model[$scope.options.key];
  8642. };
  8643. $scope.getMydataone = function (x) {
  8644. $scope.model[$scope.options.key] = x;
  8645. $scope.searchField = $scope.model[$scope.options.key];
  8646. };
  8647. $scope.fildata = {
  8648. idx: 0,
  8649. sum: 10,
  8650. // 'incident': { 'tilte': item }
  8651. };
  8652. function reashdata(item) {
  8653. if (item && item != "") {
  8654. angular.extend($scope.fildata, {
  8655. incident: {
  8656. title: item,
  8657. },
  8658. });
  8659. } else {
  8660. delete $scope.fildata.incident;
  8661. }
  8662. api_bpm_data
  8663. .fetchDataList("incident", $scope.fildata)
  8664. .then(function (response) {
  8665. if (response) {
  8666. if ((response.status = 200)) {
  8667. var myData = response;
  8668. $scope.myData = myData.list;
  8669. }
  8670. }
  8671. });
  8672. }
  8673. function delHtmlTag(str) {
  8674. return str.replace(/<[^>]+>/g, "");
  8675. }
  8676. // reashdata();
  8677. var changedata = {};
  8678. setInterval(function () {
  8679. if (
  8680. $scope.model.category != null &&
  8681. $scope.model.category.id != changedata.id &&
  8682. $scope.model.titles != $scope.model.category
  8683. ) {
  8684. $scope.searchData = {};
  8685. changedata = angular.copy($scope.model.category);
  8686. if ($scope.options.key == "title") {
  8687. var filterData = {
  8688. idx: 0,
  8689. sum: 1000,
  8690. };
  8691. api_bpm_data
  8692. .fetchDataList("incidentcategory", filterData)
  8693. .then(function (data) {
  8694. var datalist = data.list;
  8695. angular.forEach(datalist, function (item) {
  8696. if (item.id == $scope.model.category.id) {
  8697. $scope.model[$scope.options.key] = item.category;
  8698. $scope.searchField =
  8699. $scope.options.model[$scope.options.key];
  8700. $scope.titles = item.category;
  8701. titles = $scope.model.category;
  8702. }
  8703. });
  8704. });
  8705. }
  8706. }
  8707. }, 1000);
  8708. $scope.open = function (key, options, fildata, $event, model) {
  8709. if (key && key.length > 1) {
  8710. api_zsk
  8711. .solutionData(
  8712. {
  8713. solution: {
  8714. searchWord: key,
  8715. },
  8716. idx: "0",
  8717. sum: "1000",
  8718. },
  8719. "solution"
  8720. )
  8721. .then(function (response) {
  8722. if (response && response.list.length > 0) {
  8723. $scope.dlideboxslide = true;
  8724. angular.forEach(response, function (item) {
  8725. console.log(response);
  8726. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8727. // if (response.status == 200) {
  8728. // var quote = { 'totalNum': response.totalNum }
  8729. // item = angular.extend(item, quote)
  8730. // }
  8731. // })
  8732. $scope.searchData = response.list;
  8733. console.log($scope.searchData);
  8734. });
  8735. $scope.changes = false;
  8736. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8737. // $scope.closepages = function(e) {
  8738. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8739. // event.preventDefault();
  8740. // };
  8741. $scope.shows = false;
  8742. $scope.tempData = {};
  8743. $scope.showpage = function (item) {
  8744. item.content = delHtmlTag(item.content);
  8745. $scope.shows = true;
  8746. $scope.tempData = item;
  8747. if (item.content != null) {
  8748. $scope.tempData.content = $scope.tempData.content
  8749. .replace("<p>", "")
  8750. .replace("</p>", "");
  8751. }
  8752. $scope.knowledgedata = item;
  8753. $scope.pageid = item.id;
  8754. $scope.changes = !$scope.changes;
  8755. api_bpm_domain
  8756. .listAttachments(item.id)
  8757. // api_solution.fetchDataList('file', {
  8758. // "file": {
  8759. // "solutionId": item.id
  8760. // },
  8761. // "idx": "0",
  8762. // "sum": "1000"
  8763. // })
  8764. .then(function (data) {
  8765. if (data) {
  8766. $scope.attachments = data.list;
  8767. $scope.view = function (attachmentId) {
  8768. for (
  8769. var i = 0;
  8770. i < $scope.attachments.length;
  8771. i++
  8772. ) {
  8773. if ($scope.attachments[i].id == attachmentId) {
  8774. window.open($scope.attachments[i].previewUrl);
  8775. }
  8776. }
  8777. };
  8778. $scope.download = function (contentId, filename) {
  8779. api_solution
  8780. .getSolutionDowpath(contentId)
  8781. .then(function (response) {
  8782. var file = new Blob([response], {
  8783. type: "application/octet-stream",
  8784. });
  8785. // var filename = filename;
  8786. var fileURL = URL.createObjectURL(file);
  8787. var a = document.createElement("a");
  8788. a.href = fileURL;
  8789. a.target = "_blank";
  8790. a.download = filename;
  8791. document.body.appendChild(a);
  8792. a.click();
  8793. });
  8794. };
  8795. }
  8796. });
  8797. };
  8798. $scope.related = function (item) {
  8799. if (item.content != null) {
  8800. item.content = item.content
  8801. .replace("<p>", "")
  8802. .replace("</p>", "");
  8803. }
  8804. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8805. options.model.handleDescription = item.content;
  8806. var data = {
  8807. solutionQuote: {
  8808. solutionId: item.id,
  8809. incidentsign: options.model.incidentsign,
  8810. },
  8811. };
  8812. api_zsk.solutionQuote(item.id).then(function (response) {
  8813. if (response.status == 200) {
  8814. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8815. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8816. "close";
  8817. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8818. } else {
  8819. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8820. }
  8821. });
  8822. };
  8823. $scope.close = function () {
  8824. $scope.changes = !$scope.changes;
  8825. event.preventDefault();
  8826. };
  8827. }
  8828. });
  8829. }
  8830. };
  8831. },
  8832. ],
  8833. });
  8834. //侧滑选择重复事件
  8835. formlyConfigProvider.setType({
  8836. name: "ui-repeatIncidentbtn",
  8837. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8838. defaultOptions: function (options) {
  8839. return {
  8840. templateOptions: {
  8841. relationAction: function (fields, modelscope, item) { },
  8842. },
  8843. validators: {
  8844. required: {
  8845. expression: function (viewValue, modelValue) {
  8846. // var value = modelValue || viewValue;
  8847. },
  8848. },
  8849. },
  8850. };
  8851. },
  8852. controller: [
  8853. "$scope",
  8854. "$rootScope",
  8855. "$modal",
  8856. "SweetAlert",
  8857. "api_bpm_data",
  8858. "api_solution",
  8859. "$aside",
  8860. "api_zsk",
  8861. "api_bpm_domain",
  8862. "api_webservice1",
  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. api_webservice1
  8874. ) {
  8875. console.log($scope);
  8876. $scope.selection = {
  8877. id: "",
  8878. };
  8879. //认证计费数据获取
  8880. $scope.sumInfo = {};
  8881. function getSumInfo() {
  8882. $scope.isHk = $rootScope.isHk;
  8883. if($rootScope.isHk){
  8884. //用户信息
  8885. api_webservice1.fetchDataList("queryUser", { "userId": $scope.model.incident.account }).then(function(response) {
  8886. // if (response.status == 200) {
  8887. if (response && response.data) {
  8888. angular.extend($scope.sumInfo, response.data[0]);
  8889. // $scope.sumInfo = response.data[0];
  8890. $scope.sumInfo.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  8891. $scope.sumInfo.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  8892. $scope.sumInfo.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  8893. } else if (response.err) {
  8894. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  8895. }
  8896. // }
  8897. })
  8898. //上网明细
  8899. api_webservice1.fetchDataList("queryOnlineDetail", { "userId": $scope.model.incident.account, "limit": "10", "fromLoginTime": moment(new Date().getTime() - 86400000 * 6).format('YYYY-MM-DD HH:mm:ss'), "toLogoutTime": moment(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss') }).then(function(response) {
  8900. // if (response.status == 200) {
  8901. if (response && response.data) {
  8902. angular.forEach(response.data, function(item, index) {
  8903. if (item.logoutTime) {
  8904. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  8905. }
  8906. if (item.loginTime) {
  8907. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  8908. }
  8909. })
  8910. $scope.logininform_sumInfo = response.data;
  8911. } else if (response.err) {
  8912. SweetAlert.swal("上网明细未取到", "该用户暂无上网明细", "error");
  8913. }
  8914. })
  8915. //黑名单
  8916. // $scope.sumInfo.blacklist = "否"
  8917. api_webservice1.fetchDataList("queryInhibit", { "userId": $scope.model.incident.account }).then(function(response) {
  8918. // if (response.status == 200) {
  8919. // $scope.loginsumInfo = response.data;
  8920. if (response) {
  8921. if (response.data || response.data != null) {
  8922. $scope.sumInfo.blacklist = "是"
  8923. } else {
  8924. if (response.err) {
  8925. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  8926. } else {
  8927. $scope.sumInfo.blacklist = "否"
  8928. }
  8929. }
  8930. }
  8931. // }
  8932. })
  8933. }else{
  8934. // api_bpm_data
  8935. // .sumInfo($scope.model.incident.account)
  8936. // .then(function (data) {
  8937. // console.log(data);
  8938. // if (data) {
  8939. // $scope.sumInfo = data.data || {};
  8940. // }
  8941. // });
  8942. // 取消sum
  8943. $scope.sumInfo = {};
  8944. }
  8945. }
  8946. getSumInfo();
  8947. // 收起重复事件侧滑框
  8948. function reashdata(item) {
  8949. var fildata = {
  8950. idx: 0,
  8951. incident: {
  8952. department: {
  8953. id: $scope.model.incident.department.id,
  8954. },
  8955. },
  8956. sum: 3,
  8957. };
  8958. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8959. console.log(data);
  8960. if (data) {
  8961. $scope.repeatData = data.list;
  8962. }
  8963. });
  8964. }
  8965. reashdata();
  8966. // 确认选中的重复事件
  8967. $scope.repeatIncidentOk = function () {
  8968. if ($scope.selection.id) {
  8969. $scope.model.incident.repeat = $scope.selection;
  8970. $scope.model.isRepeat = true; //隐藏处理信息
  8971. console.log($scope.model);
  8972. }
  8973. angular.element("#repeatIncident").removeClass("active");
  8974. };
  8975. // 取消选中的重复事件
  8976. $scope.repeatIncidentCancle = function () {
  8977. angular.element("#repeatIncident").removeClass("active");
  8978. return;
  8979. };
  8980. },
  8981. ],
  8982. });
  8983. //侧滑选择知识库查询
  8984. formlyConfigProvider.setType({
  8985. name: "ui-knowledgebtn",
  8986. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8987. defaultOptions: function (options) {
  8988. return {
  8989. templateOptions: {
  8990. relationAction: function (fields, modelscope, item) { },
  8991. },
  8992. validators: {
  8993. required: {
  8994. expression: function (viewValue, modelValue) {
  8995. // var value = modelValue || viewValue;
  8996. },
  8997. },
  8998. },
  8999. };
  9000. },
  9001. controller: [
  9002. "$scope",
  9003. "$rootScope",
  9004. "$modal",
  9005. "SweetAlert",
  9006. "api_bpm_data",
  9007. "api_solution",
  9008. "$aside",
  9009. "api_zsk",
  9010. "api_bpm_domain",
  9011. "api_wechatfile",
  9012. "up_down_file",
  9013. function (
  9014. $scope,
  9015. $rootScope,
  9016. $modal,
  9017. SweetAlert,
  9018. api_bpm_data,
  9019. api_solution,
  9020. $aside,
  9021. api_zsk,
  9022. api_bpm_domain,
  9023. api_wechatfile,
  9024. up_down_file
  9025. ) {
  9026. $scope.keypressModel = function (e, key) {
  9027. if (e.keyCode === 13) {
  9028. $scope.openModel(key);
  9029. }
  9030. };
  9031. // 引用知识库点击
  9032. $scope.searchKeyWord = "";
  9033. $scope.openModel = function (key) {
  9034. // alert(1)//重点
  9035. $scope.searchKeyWord = key;
  9036. if (key) {
  9037. api_zsk
  9038. .solutionData(
  9039. {
  9040. solution: {
  9041. threeSearch: key,
  9042. status: { id: 72 }, //已发布
  9043. selectType: "keySearch",
  9044. },
  9045. idx: "0",
  9046. sum: "1000",
  9047. },
  9048. "solution"
  9049. )
  9050. .then(function (response) {
  9051. $scope.searchData = response.list;
  9052. });
  9053. }
  9054. };
  9055. $scope.openModel($scope.model.incident.description);
  9056. // 展开/收起
  9057. $scope.showId = "";
  9058. $scope.ifshow = false;
  9059. $scope.showAll = function (id) {
  9060. $scope.attachments = [];
  9061. if ($scope.showId == id) {
  9062. $scope.ifshow = !$scope.ifshow;
  9063. } else {
  9064. $scope.ifshow = true;
  9065. }
  9066. $scope.showId = id;
  9067. // 获取附件
  9068. api_wechatfile
  9069. .listAttachments("knowledge", $scope.showId)
  9070. .then(function (data) {
  9071. $scope.attachments = data.data;
  9072. $scope.download = function (token, filename) {
  9073. var downUrl = up_down_file
  9074. .downloadAttachment("common/common/downloadAttachment", token)
  9075. .getRequestedUrl();
  9076. // window.open(downUrl);
  9077. var a = document.createElement("a");
  9078. a.href = downUrl;
  9079. a.target = "_blank";
  9080. a.download = filename;
  9081. document.body.appendChild(a);
  9082. a.click();
  9083. };
  9084. });
  9085. };
  9086. // 引用
  9087. $scope.related = function (item) {
  9088. console.log(item, "引用名");
  9089. if (item.content) {
  9090. item.content = item.content
  9091. .replace(/<p>/g, "")
  9092. .replace(/<\/p>/g, "")
  9093. .replace(/&nbsp;/g, "");
  9094. }
  9095. $scope.model.incident.handleDescription = item.content;
  9096. $scope.model.incident.title = $scope.model.incident.description =
  9097. item.title;
  9098. $scope.model.incident.category = item.category;
  9099. if (item.category) {
  9100. $scope.model.incident.priority.id = item.category.priority.id;
  9101. item.category.label = item.category.category;
  9102. }
  9103. var categoryId = item.category ? item.category.id : "";
  9104. // 引用知识库故障现象后,修改故障现象选中状态,故障现象列表重载
  9105. function getres(nodes) {
  9106. if (!nodes || nodes.length == 0) {
  9107. return;
  9108. }
  9109. nodes.forEach((e) => {
  9110. e.selected = false;
  9111. if (e.id == categoryId) {
  9112. e.selected = true;
  9113. return false;
  9114. }
  9115. getres(e.children);
  9116. });
  9117. }
  9118. var categorys = [];
  9119. $scope.fields.forEach((e, i) => {
  9120. if (e.key == "category") {
  9121. categorys = e.templateOptions.options;
  9122. if (categorys.length) {
  9123. getres(categorys);
  9124. $scope.fields[i].templateOptions.options = categorys;
  9125. $scope.$root.refreshSelectedItems();
  9126. }
  9127. return false;
  9128. }
  9129. });
  9130. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9131. $scope.model.candidateGroups = item.category
  9132. ? item.category.group
  9133. : {};
  9134. // 携带关联优先级,事件工单信息的时间
  9135. if (
  9136. $scope.model &&
  9137. $scope.model.incident &&
  9138. item.category &&
  9139. item.category.priority &&
  9140. item.category.priority.id
  9141. ) {
  9142. api_bpm_domain
  9143. .expectedTime("L" + (item.category.priority.id - 1559))
  9144. .then(function (res) {
  9145. $scope.model.incident.expectResponseTime =
  9146. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9147. res.serviceLevelAgreement.responseTime;
  9148. $scope.model.incident.expectIntroTime =
  9149. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9150. res.serviceLevelAgreement.resolveTime;
  9151. $scope.model.incident.overdueTime =
  9152. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9153. res.date;
  9154. });
  9155. }
  9156. api_zsk.solutionQuote(item.id).then(function (response) {
  9157. if (response.status == 200) {
  9158. $("#seachknowledge").removeClass("active");
  9159. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9160. $scope.$parent.$parent.$parent.model.start_code = "close";
  9161. $scope.$parent.$parent.$parent.model.directClose = 0;
  9162. console.log($scope.model);
  9163. } else {
  9164. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9165. }
  9166. });
  9167. };
  9168. },
  9169. ],
  9170. });
  9171. //下拉输入组件
  9172. formlyConfigProvider.setType({
  9173. name: "ui-selectinput",
  9174. extends: "input",
  9175. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9176. defaultOptions: function (options) {
  9177. return {
  9178. templateOptions: {
  9179. refresh: function () { },
  9180. refreshDelay: 0,
  9181. linkage: function (modelName, data) { },
  9182. },
  9183. };
  9184. },
  9185. controller: [
  9186. "$scope",
  9187. "$rootScope",
  9188. "$modal",
  9189. "SweetAlert",
  9190. "api_bpm_data",
  9191. "api_solution",
  9192. "$aside",
  9193. function (
  9194. $scope,
  9195. $rootScope,
  9196. $modal,
  9197. SweetAlert,
  9198. api_bpm_data,
  9199. api_solution,
  9200. $aside
  9201. ) {
  9202. $scope.searchData = "";
  9203. $scope.onChangeadd = function (searchData) {
  9204. // $scope.searchKey = searchData.account;
  9205. // var requesdata = angular.copy(searchData)
  9206. // $scope.requester = requesdata;
  9207. };
  9208. $scope.refreshUseradd = function (searchKey) {
  9209. //主题搜索
  9210. // $scope.searchData = searchKey;
  9211. // reashdata($scope.searchData);
  9212. };
  9213. $scope.getMydata = function (x) {
  9214. $scope.model[$scope.options.key] =
  9215. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9216. $scope.searchField = $scope.model[$scope.options.key];
  9217. };
  9218. $scope.getMydataone = function (x) {
  9219. $scope.model[$scope.options.key] = x;
  9220. $scope.searchField = $scope.model[$scope.options.key];
  9221. if (
  9222. $scope.model[$scope.options.key] &&
  9223. $scope.model[$scope.options.key] != ""
  9224. ) {
  9225. $scope.hidden = false;
  9226. } else {
  9227. $scope.hidden = true;
  9228. }
  9229. };
  9230. function reashdata(item) {
  9231. $scope.myData = $scope.options.templateOptions.mydata;
  9232. }
  9233. reashdata();
  9234. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9235. $scope.options.templateOptions.fetchItems($scope);
  9236. }
  9237. },
  9238. ],
  9239. });
  9240. //重构组件模板
  9241. //获取当前人
  9242. formlyConfigProvider.setType({
  9243. name: "ui-users",
  9244. extends: "input",
  9245. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9246. defaultOptions: function (options) {
  9247. return {
  9248. templateOptions: {
  9249. translate: "",
  9250. refreshDelay: 0,
  9251. },
  9252. };
  9253. },
  9254. controller: [
  9255. "$scope",
  9256. function ($scope) {
  9257. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9258. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9259. },
  9260. ],
  9261. });
  9262. //只读控件
  9263. formlyConfigProvider.setType({
  9264. name: "ui-label",
  9265. extends: "input",
  9266. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9267. defaultOptions: function (options) {
  9268. return {
  9269. templateOptions: {
  9270. translate: "",
  9271. refreshDelay: 0,
  9272. },
  9273. };
  9274. },
  9275. controller: [
  9276. "$scope",
  9277. "$rootScope",
  9278. function ($scope, $rootScope) {
  9279. // console.log($scope.options.templateOptions)
  9280. // console.log($scope.options,'options1122');
  9281. $scope.isSolutionLabel = false;
  9282. $scope.solutionLabelStr = "";
  9283. // console.log($scope.options.templateOptions.solotinLabel);
  9284. if ($scope.options.templateOptions.solotinLabel) {
  9285. $scope.isSolutionLabel = true;
  9286. if ($scope.model[$scope.options.key]) {
  9287. var solutionArr = $scope.model[$scope.options.key].split("/");
  9288. $scope.solutionLabelStr = solutionArr.join(" ");
  9289. }
  9290. }
  9291. var value = $scope.model[$scope.options.key];
  9292. // ----------------
  9293. // ----------------
  9294. // console.log(value, 'pppp')
  9295. function treeDesc(children, key, label) {
  9296. if (label == "") {
  9297. label = children[key];
  9298. } else {
  9299. label = children[key] + "-" + label;
  9300. }
  9301. if (angular.isDefined(children.parent)) {
  9302. treeDesc(children.parent, key, label);
  9303. } else {
  9304. return label;
  9305. }
  9306. }
  9307. if (angular.isArray(value)) {
  9308. var tempValue = "";
  9309. angular.forEach(value, function (item) {
  9310. if (tempValue != "") {
  9311. tempValue = tempValue + ",";
  9312. }
  9313. tempValue =
  9314. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9315. item;
  9316. });
  9317. $scope.options.templateOptions.translate = tempValue;
  9318. } else if (angular.isObject(value)) {
  9319. if (
  9320. angular.isDefined(value.children) ||
  9321. angular.isDefined(value.parent)
  9322. ) {
  9323. //tree
  9324. // console.log("value.parent="+JSON.stringify(value.parent))
  9325. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9326. nameLabel = treeDesc(
  9327. value.parent,
  9328. $scope.options.templateOptions.labelProp,
  9329. nameLabel
  9330. );
  9331. $scope.options.templateOptions.translate = nameLabel;
  9332. } else {
  9333. $scope.options.templateOptions.translate = value;
  9334. }
  9335. } else if (
  9336. angular.isString(value) &&
  9337. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9338. ) {
  9339. // console.log("value=" + value);
  9340. $scope.options.templateOptions.translate = value;
  9341. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9342. // console.log("value="+value);
  9343. // $scope.options.templateOptions.translate = value;
  9344. } else {
  9345. // var datasdf = JSON.parse(value);
  9346. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9347. $scope.options.templateOptions.translate = value;
  9348. }
  9349. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9350. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9351. $scope.options.templateOptions.translate =
  9352. $scope.options.templateOptions.transform(
  9353. $scope.originalModel,
  9354. value,
  9355. $rootScope,
  9356. $scope
  9357. );
  9358. }
  9359. // console.log($scope.options.templateOptions.translate,99999);
  9360. },
  9361. ],
  9362. });
  9363. //小标题组件
  9364. formlyConfigProvider.setType({
  9365. name: "ui-header",
  9366. template:
  9367. '<div class="row"><div class="col-xs-12 col-15 form_heard border-top-left-2 border-top-right-2"> <div class = "pull-left fontcolor-two fontsizes-16 font-weight-500" > {{ options.templateOptions.label }} </div> </div></div>',
  9368. });
  9369. //标题组件
  9370. formlyConfigProvider.setType({
  9371. name: "ui-title",
  9372. template:
  9373. '<section id="page-title-form"><div class="row"><div class="col-sm-8"><h1 class="mainTitle">{{options.templateOptions.label}}<i tooltip={{options.templateOptions.placeholder}} tooltip-placement="right" class="fa ti-help-alt margin-left-10 fontcolor-five pointfont"></i></h1></div></div></section>',
  9374. });
  9375. //标栏是否展示
  9376. formlyConfigProvider.setType({
  9377. name: "ui-orshow",
  9378. template:
  9379. '<div class="panel"><div class="panel-heading px-nested-panel-heading {{options.templateOptions.heard}} clearfix"><h3 class="pull-left panel-title text-head margin-left-10" ng-if="options.templateOptions.label">{{options.templateOptions.label}} </h3><a ng-click="clickshow(model[options.key])" class="pull-right"><i class=" ti-angle-double-up" ng-if="model[options.key]">隐藏</i><i class="ti-angle-double-down" ng-if="!model[options.key]">展示</i></a></div></div>',
  9380. controller: [
  9381. "$scope",
  9382. function ($scope) {
  9383. $scope.clickshow = function (key) {
  9384. // $scope.model[$scope.options.key] != key;
  9385. if (key == false) {
  9386. $scope.model[$scope.options.key] = true;
  9387. } else {
  9388. $scope.model[$scope.options.key] = false;
  9389. }
  9390. };
  9391. },
  9392. ],
  9393. });
  9394. //按钮组
  9395. formlyConfigProvider.setType({
  9396. name: "ui-button",
  9397. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9398. defaultOptions: function (options) {
  9399. return {
  9400. noFormControl: true,
  9401. };
  9402. },
  9403. });
  9404. //3d组link
  9405. formlyConfigProvider.setType({
  9406. name: "ui-link",
  9407. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9408. defaultOptions: function (options) {
  9409. return {
  9410. noFormControl: true,
  9411. };
  9412. },
  9413. });
  9414. //隐藏域组件
  9415. formlyConfigProvider.setType({
  9416. name: "ui-hidden",
  9417. extends: "input",
  9418. template:
  9419. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9420. defaultOptions: function (options) {
  9421. return {
  9422. // noFormControl: true
  9423. };
  9424. },
  9425. });
  9426. //文本框组件
  9427. formlyConfigProvider.setType({
  9428. name: "ui-input",
  9429. extends: "input",
  9430. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9431. defaultOptions: function (options) {
  9432. return {
  9433. templateOptions: {
  9434. transform: function (value) { },
  9435. },
  9436. };
  9437. },
  9438. controller: [
  9439. "$scope",
  9440. "$timeout",
  9441. function ($scope, $timeout) {
  9442. // console.log($scope.model[$scope.options.key]);
  9443. // console.log($scope.options)
  9444. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9445. $scope.model[$scope.options.key] =
  9446. $scope.options.templateOptions.linkData($scope.model);
  9447. }
  9448. },
  9449. ],
  9450. });
  9451. //搜索下拉框-故障地点seimin
  9452. formlyConfigProvider.setType({
  9453. name: "ui-select-search",
  9454. extends: "input",
  9455. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9456. defaultOptions: function (options) {
  9457. return {
  9458. templateOptions: {
  9459. transform: function (value) { },
  9460. },
  9461. };
  9462. },
  9463. controller: [
  9464. "$scope",
  9465. "$rootScope",
  9466. "api_search_area",
  9467. function ($scope, $rootScope, api_search_area) {
  9468. // console.log($scope.options, $scope.model)
  9469. // ----------------分割线 start-----------------
  9470. // 故障地点下拉
  9471. $scope.address_arr = []; //故障地点所有数据
  9472. $scope.addressFlag = false; //默认下拉框列表隐藏
  9473. //点击文本框
  9474. $scope.AddressClickHandle = function () {
  9475. $scope.getDepartmentList();
  9476. angular.element("#bx_address_ul").scrollTop(0);
  9477. };
  9478. //修改文字,实时监听
  9479. $scope.ksChangeHandle = _.debounce(function () {
  9480. $scope.model[$scope.options.key] =
  9481. $scope.model[$scope.options.key] === undefined
  9482. ? ""
  9483. : $scope.model[$scope.options.key];
  9484. $scope.getDepartmentList();
  9485. angular.element("#bx_address_ul").scrollTop(0);
  9486. }, 500);
  9487. //获取故障地点seimin
  9488. $scope.getDepartmentList = function () {
  9489. $scope.model[$scope.options.key] =
  9490. $scope.model[$scope.options.key] === null
  9491. ? ""
  9492. : $scope.model[$scope.options.key];
  9493. api_search_area
  9494. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9495. .then((res) => {
  9496. if (res.state == 200) {
  9497. $scope.address_arr = res.result;
  9498. $scope.addressFlag = true; //显示
  9499. }
  9500. })
  9501. .catch((err) => {
  9502. console.log(err);
  9503. });
  9504. };
  9505. // $scope.getDepartmentList();
  9506. // console.log($scope.model[$scope.options.key])
  9507. //下拉框列表选中
  9508. $scope.addressItemClick = function (obj) {
  9509. $scope.addressFlag = false; //隐藏
  9510. $scope.model[$scope.options.key] = obj.place
  9511. ? obj.area.area + obj.place
  9512. : obj.area;
  9513. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9514. $scope.model.selecthouseNumber = obj;
  9515. console.log($scope, 77777);
  9516. $scope.$root.selecthouseNumber = obj;
  9517. };
  9518. //点击空白处隐藏
  9519. angular.element(document).on("click", function (e) {
  9520. if (e.target !== angular.element("#bx_address").get(0)) {
  9521. $scope.addressFlag = false; //隐藏
  9522. //模拟placeholder
  9523. // if ($('#bx_address').val() == '') {
  9524. // $('#bx_address').val('请选择报修科室');
  9525. // }
  9526. }
  9527. });
  9528. // -----------------分割线 end----------------
  9529. },
  9530. ],
  9531. });
  9532. //知识库关键字组件
  9533. formlyConfigProvider.setType({
  9534. name: "ui-knowledgeKeywords",
  9535. extends: "input",
  9536. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9537. defaultOptions: function (options) {
  9538. return {
  9539. templateOptions: {
  9540. transform: function (value) { },
  9541. },
  9542. };
  9543. },
  9544. controller: [
  9545. "$scope",
  9546. "$timeout",
  9547. "SweetAlert",
  9548. function ($scope, $timeout, SweetAlert) {
  9549. $scope.valueLength = [
  9550. {
  9551. value: "",
  9552. },
  9553. ];
  9554. $scope.valueAll = [];
  9555. if ($scope.model[$scope.options.key]) {
  9556. var valueArr = $scope.model[$scope.options.key].split("/");
  9557. $scope.valueLength = [];
  9558. for (var i = 0; i < valueArr.length; i++) {
  9559. $scope.valueLength.push({
  9560. value: valueArr[i],
  9561. });
  9562. }
  9563. }
  9564. $scope.addIpt = function () {
  9565. if ($scope.valueLength.length < 5) {
  9566. $scope.valueLength.push({
  9567. value: "",
  9568. });
  9569. } else {
  9570. SweetAlert.swal({
  9571. title: "添加失败",
  9572. text: "关键字不能超过5个!",
  9573. type: "error",
  9574. confirmButtonColor: "#DD6B55",
  9575. });
  9576. }
  9577. };
  9578. $scope.closeIpt = function (data) {
  9579. $scope.valueLength.splice(data, 1);
  9580. };
  9581. $scope.toOption = function () {
  9582. $scope.valueAll = [];
  9583. for (var i = 0; i < $scope.valueLength.length; i++) {
  9584. if ($scope.valueLength[i].value != "") {
  9585. $scope.valueAll.push($scope.valueLength[i].value);
  9586. }
  9587. }
  9588. $scope.model.label = $scope.valueAll.join("/");
  9589. };
  9590. },
  9591. ],
  9592. });
  9593. //文本框组件
  9594. formlyConfigProvider.setType({
  9595. name: "ui-num",
  9596. extends: "input",
  9597. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9598. defaultOptions: function (options) {
  9599. return {
  9600. templateOptions: {
  9601. transform: function (value) { },
  9602. },
  9603. };
  9604. },
  9605. controller: [
  9606. "$scope",
  9607. "$timeout",
  9608. function ($scope, $timeout) {
  9609. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9610. $scope.model[$scope.options.key] =
  9611. $scope.options.templateOptions.linkData($scope.model);
  9612. }
  9613. $scope.clearNoNum = function (obj, attr) {
  9614. //先把非数字的都替换掉,除了数字和.
  9615. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9616. //必须保证第一个为数字而不是.
  9617. obj[attr] = obj[attr].replace(/^\./g, "");
  9618. //保证只有出现一个.而没有多个.
  9619. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9620. //保证.只出现一次,而不能出现两次以上
  9621. obj[attr] = obj[attr]
  9622. .replace(".", "$#$")
  9623. .replace(/\./g, "")
  9624. .replace("$#$", ".");
  9625. //小于最大值
  9626. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9627. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9628. // obj[attr] = '';
  9629. // }
  9630. };
  9631. },
  9632. ],
  9633. });
  9634. // //关联请求人文本框组件
  9635. // formlyConfigProvider.setType({
  9636. // name: 'ui-requestinput',
  9637. // extends: 'input',
  9638. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9639. // defaultOptions: function(options) {
  9640. // return {
  9641. // templateOptions: {
  9642. // transform: function(value) {},
  9643. // linkData: function(options) {}
  9644. // }
  9645. // };
  9646. // }
  9647. // });
  9648. //只读文本
  9649. formlyConfigProvider.setType({
  9650. name: "ui-disableinput",
  9651. extends: "input",
  9652. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9653. defaultOptions: function (options) {
  9654. return {
  9655. templateOptions: {
  9656. transform: function (value) {
  9657. var ret = "";
  9658. if (value) {
  9659. ret = "已删除";
  9660. } else {
  9661. ret = "正常";
  9662. }
  9663. return ret;
  9664. },
  9665. },
  9666. };
  9667. },
  9668. });
  9669. formlyConfigProvider.setType({
  9670. name: "ui-disinput",
  9671. extends: "input",
  9672. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9673. defaultOptions: function (options) {
  9674. return {
  9675. templateOptions: {},
  9676. };
  9677. },
  9678. });
  9679. //数字组件
  9680. formlyConfigProvider.setType({
  9681. name: "ui-number",
  9682. extends: "input",
  9683. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9684. defaultOptions: function (options) {
  9685. return {
  9686. templateOptions: {},
  9687. };
  9688. },
  9689. controller: ["$scope", function ($scope) { }],
  9690. });
  9691. //含有周的日期
  9692. formlyConfigProvider.setType({
  9693. name: "ui-datepickerweek",
  9694. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9695. extends: "input",
  9696. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9697. defaultOptions: {
  9698. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9699. templateOptions: {
  9700. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9701. },
  9702. },
  9703. controller: [
  9704. "$scope",
  9705. "$filter",
  9706. function ($scope, $filter) {
  9707. $scope.mindata = new Date(
  9708. $scope.options.templateOptions.transform($scope.model).getTime() +
  9709. 5 * 60 * 1000
  9710. );
  9711. if ($scope.model[$scope.options.key]) {
  9712. } else {
  9713. $scope.model[$scope.options.key] = $filter("date")(
  9714. new Date(new Date().getTime()),
  9715. $scope.options.templateOptions.datepickerPopup
  9716. );
  9717. }
  9718. $scope.options.initialValue = $scope.model[$scope.options.key];
  9719. $scope.endOpen = true;
  9720. $scope.datepicker = {};
  9721. $scope.datepicker.opened = false;
  9722. $scope.datepicker.open = function ($event) {
  9723. $scope.datepicker.opened = true;
  9724. };
  9725. },
  9726. ],
  9727. });
  9728. //lmm
  9729. //分配任务列表
  9730. formlyConfigProvider.setType({
  9731. name: "jry_taskDistributionList",
  9732. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9733. wrapper: ["bootstrapHasError"],
  9734. defaultOptions: function (options, $scope) {
  9735. return {
  9736. templateOptions: {},
  9737. };
  9738. },
  9739. controller: function (
  9740. $rootScope,
  9741. $scope,
  9742. api_user_data,
  9743. $modal,
  9744. api_doc_data,
  9745. i18nService,
  9746. SweetAlert,
  9747. api_wechatfile
  9748. ) {
  9749. // 获取状态
  9750. $scope.stateListData = {};
  9751. $scope.getStateData = function () {
  9752. //lyl
  9753. var data = {
  9754. key: "task_sub_state",
  9755. type: "list",
  9756. };
  9757. api_wechatfile.getDictionary(data).then(function (res) {
  9758. angular.forEach(res, function (v, i) {
  9759. $scope.stateListData[v.value] = v.id;
  9760. });
  9761. });
  9762. };
  9763. $scope.getStateData();
  9764. var loginUser = $rootScope.user;
  9765. $scope.langs = i18nService.getAllLangs();
  9766. $scope.lang = "zh-cn";
  9767. i18nService.setCurrentLang($scope.lang);
  9768. $scope.gridOptions = {};
  9769. $scope.gridOptions.data = "myData";
  9770. $scope.gridOptions.enableColumnResizing = true;
  9771. $scope.gridOptions.enableGridMenu = false;
  9772. $scope.gridOptions.enableRowSelection = true;
  9773. $scope.gridOptions.showGridFooter = true;
  9774. $scope.gridOptions.showColumnFooter = false;
  9775. $scope.gridOptions.fastWatch = true;
  9776. $scope.gridOptions.useExternalFiltering = true;
  9777. $scope.gridOptions.useExternalPagination = true;
  9778. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  9779. $scope.gridOptions.paginationPageSize = 10;
  9780. $scope.gridOptions.multiSelect = true;
  9781. $scope.gridOptions.rowIdentity = function (row) {
  9782. return row.id;
  9783. };
  9784. $scope.gridOptions.getRowIdentity = function (row) {
  9785. return row.id;
  9786. };
  9787. // console.log($scope.model);//lmmmm
  9788. $scope.gridOptions.columnDefs = [
  9789. {
  9790. name: "item",
  9791. displayName: "序号",
  9792. width: "10%",
  9793. cellTemplate:
  9794. "<div>" +
  9795. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9796. "</div>",
  9797. },
  9798. {
  9799. name: "taskDescribe",
  9800. displayName: "任务说明",
  9801. width: "25%",
  9802. enableFiltering: false,
  9803. cellTemplate:
  9804. "<div>" +
  9805. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9806. "</div>",
  9807. },
  9808. {
  9809. name: "assign.name",
  9810. displayName: "指派人",
  9811. width: "5%",
  9812. enableFiltering: false,
  9813. cellTemplate:
  9814. "<div>" +
  9815. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9816. "</div>",
  9817. },
  9818. {
  9819. name: "startTime",
  9820. displayName: "开始时间",
  9821. width: "13%",
  9822. enableFiltering: false,
  9823. cellTemplate:
  9824. "<div>" +
  9825. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9826. "</div>",
  9827. },
  9828. {
  9829. name: "endTime",
  9830. displayName: "结束时间",
  9831. width: "13%",
  9832. enableFiltering: false,
  9833. cellTemplate:
  9834. "<div>" +
  9835. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9836. "</div>",
  9837. },
  9838. {
  9839. name: "priority.name",
  9840. displayName: "优先级",
  9841. width: "5%",
  9842. enableFiltering: false,
  9843. cellTemplate:
  9844. "<div>" +
  9845. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9846. "</div>",
  9847. },
  9848. {
  9849. name: "state.name",
  9850. displayName: "状态",
  9851. width: "5%",
  9852. enableFiltering: false,
  9853. cellTemplate:
  9854. "<div>" +
  9855. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9856. "</div>",
  9857. },
  9858. {
  9859. name: "操作", //lmmm
  9860. cellTemplate:
  9861. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9862. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9863. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9864. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9865. '<a ng-click="grid.appScope.see(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[2]||row.entity.state.id==grid.appScope.stateListData[3]||grid.appScope.model.showSee">查看</a>' +
  9866. "</div></div>",
  9867. enableFiltering: false,
  9868. },
  9869. ];
  9870. // 查看
  9871. $scope.see = function (data) {
  9872. $scope.seeData = data;
  9873. var modalInstance = $modal.open({
  9874. backdrop: false,
  9875. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9876. controller: function (
  9877. $scope,
  9878. scope,
  9879. $modalInstance,
  9880. api_doc_data,
  9881. SweetAlert,
  9882. api_user_data,
  9883. api_wechatfile
  9884. ) {
  9885. $scope.personData = {}; //指派人
  9886. $scope.priorityData = {}; //优先级
  9887. $scope.personListData = {}; //指派人下拉数据
  9888. $scope.priorityListData = {}; //优先级下拉数据
  9889. $scope.startTime = ""; //开始时间
  9890. $scope.releaseShow = "no";
  9891. $scope.subShow = "no";
  9892. $scope.onlySee = "ok";
  9893. $scope.endTime = ""; //结束时间
  9894. $scope.taskDescribe = ""; //任务描述
  9895. $scope.taskDescribe = scope.seeData.taskDescribe;
  9896. $scope.personData.data = scope.seeData.assign;
  9897. $scope.priorityData.data = scope.seeData.priority;
  9898. $scope.startTime = scope.seeData.startTime;
  9899. $scope.endTime = scope.seeData.endTime;
  9900. $scope.done = scope.seeData.done;
  9901. $scope.feedback = scope.seeData.feedback;
  9902. $scope.cancel = function () {
  9903. $modalInstance.dismiss("cancel");
  9904. };
  9905. },
  9906. size: "sm",
  9907. resolve: {
  9908. scope: function () {
  9909. return $scope;
  9910. },
  9911. },
  9912. backdrop: true,
  9913. });
  9914. };
  9915. // 编辑
  9916. $scope.edit = function (data) {
  9917. $scope.editData = data;
  9918. var modalInstance = $modal.open({
  9919. backdrop: false,
  9920. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9921. controller: function (
  9922. $scope,
  9923. scope,
  9924. $modalInstance,
  9925. api_doc_data,
  9926. SweetAlert,
  9927. api_user_data,
  9928. api_wechatfile
  9929. ) {
  9930. console.log(scope.editData);
  9931. $scope.personData = {}; //指派人
  9932. $scope.priorityData = {}; //优先级
  9933. $scope.personListData = {}; //指派人下拉数据
  9934. $scope.priorityListData = {}; //优先级下拉数据
  9935. $scope.startTime = ""; //开始时间
  9936. $scope.releaseShow = "no";
  9937. $scope.endTime = ""; //结束时间
  9938. $scope.taskDescribe = ""; //任务描述
  9939. $scope.taskDescribe = scope.editData.taskDescribe;
  9940. $scope.personData.data = scope.editData.assign;
  9941. $scope.priorityData.data = scope.editData.priority;
  9942. $scope.startTime = scope.editData.startTime;
  9943. $scope.endTime = scope.editData.endTime;
  9944. // 指派人下拉框数据
  9945. $scope.getPersonData = function () {
  9946. var data = {
  9947. idx: 0,
  9948. sum: 1000,
  9949. };
  9950. api_user_data.fetchDataList("user", data).then(function (res) {
  9951. $scope.personListData = res.list;
  9952. });
  9953. };
  9954. $scope.getPersonData();
  9955. //优先级下拉数据
  9956. $scope.getPriorityData = function () {
  9957. var data = {
  9958. key: "change_rick_level",
  9959. type: "list",
  9960. };
  9961. api_wechatfile.getDictionary(data).then(function (res) {
  9962. $scope.priorityListData = res;
  9963. });
  9964. };
  9965. $scope.getPriorityData();
  9966. // 获取状态-lmm
  9967. $scope.stateListData = {};
  9968. $scope.getStateData = function () {
  9969. //lyl
  9970. var data = {
  9971. key: "task_sub_state",
  9972. type: "list",
  9973. };
  9974. api_wechatfile.getDictionary(data).then(function (res) {
  9975. angular.forEach(res, function (v, i) {
  9976. $scope.stateListData[v.value] = v.id;
  9977. });
  9978. });
  9979. };
  9980. $scope.getStateData();
  9981. //时间控件
  9982. $scope.open = function ($event) {
  9983. $event.preventDefault();
  9984. $event.stopPropagation();
  9985. $scope.opened = !$scope.opened;
  9986. };
  9987. $scope.endOpen = function ($event) {
  9988. $event.preventDefault();
  9989. $event.stopPropagation();
  9990. $scope.startOpened = false;
  9991. $scope.endOpened = !$scope.endOpened;
  9992. };
  9993. $scope.startOpen = function ($event) {
  9994. $event.preventDefault();
  9995. $event.stopPropagation();
  9996. $scope.endOpened = false;
  9997. $scope.startOpened = !$scope.startOpened;
  9998. };
  9999. // 确定
  10000. $scope.ok = function (item) {
  10001. if (
  10002. $scope.taskDescribe &&
  10003. $scope.personData.data &&
  10004. $scope.priorityData.data &&
  10005. $scope.startTime &&
  10006. $scope.endTime
  10007. ) {
  10008. $scope.startTime = moment(
  10009. new Date($scope.startTime).getTime()
  10010. ).format("YYYY-MM-DD HH:mm:ss");
  10011. $scope.endTime = moment(
  10012. new Date($scope.endTime).getTime()
  10013. ).format("YYYY-MM-DD HH:mm:ss");
  10014. $scope.addData = {
  10015. taskSub: {
  10016. taskDescribe: $scope.taskDescribe,
  10017. assign: $scope.personData.data,
  10018. priority: $scope.priorityData.data,
  10019. startTime: $scope.startTime,
  10020. endTime: $scope.endTime,
  10021. taskMonth: {
  10022. id: scope.model.taskMonth.id,
  10023. },
  10024. id: scope.editData.id,
  10025. },
  10026. };
  10027. $scope.addData.taskSub["state"] = {
  10028. id: $scope.stateListData[1],
  10029. };
  10030. api_user_data
  10031. .updData("taskSub", $scope.addData)
  10032. .then(function (res) {
  10033. if (res.status == 200) {
  10034. SweetAlert.swal({
  10035. title: "修改成功!",
  10036. type: "success",
  10037. confirmButtonColor: "#007AFF",
  10038. });
  10039. scope.refreshData(scope.jry_filterdata);
  10040. $modalInstance.dismiss("cancel");
  10041. } else {
  10042. SweetAlert.swal({
  10043. title: "修改失败",
  10044. text: "系统错误,请重试!",
  10045. type: "error",
  10046. });
  10047. $modalInstance.dismiss("cancel");
  10048. }
  10049. });
  10050. } else {
  10051. SweetAlert.swal({
  10052. title: "修改失败",
  10053. text: "必填项不能为空!",
  10054. type: "error",
  10055. });
  10056. }
  10057. };
  10058. $scope.cancel = function () {
  10059. $modalInstance.dismiss("cancel");
  10060. };
  10061. },
  10062. size: "sm",
  10063. resolve: {
  10064. scope: function () {
  10065. return $scope;
  10066. },
  10067. },
  10068. backdrop: true,
  10069. });
  10070. };
  10071. // 发布
  10072. $scope.release = function (data) {
  10073. SweetAlert.swal(
  10074. {
  10075. title: "确认发布?",
  10076. text: "请确定发布操作!",
  10077. type: "warning",
  10078. showCancelButton: true,
  10079. confirmButtonColor: "#DD6B55",
  10080. confirmButtonText: "确定",
  10081. cancelButtonText: "取消",
  10082. closeOnConfirm: false,
  10083. closeOnCancel: false,
  10084. },
  10085. function (isConfirm) {
  10086. if (isConfirm) {
  10087. data.state.id = $scope.stateListData[2];
  10088. delete data.item;
  10089. api_user_data
  10090. .updData("taskSub", {
  10091. taskSub: data,
  10092. })
  10093. .then(function (res) {
  10094. if (res.status == 200) {
  10095. SweetAlert.swal({
  10096. title: "发布成功!",
  10097. type: "success",
  10098. confirmButtonColor: "#007AFF",
  10099. });
  10100. $scope.refreshData($scope.jry_filterdata);
  10101. } else {
  10102. SweetAlert.swal({
  10103. title: "删除失败",
  10104. text: "系统错误,请重试!",
  10105. type: "error",
  10106. });
  10107. }
  10108. });
  10109. } else {
  10110. SweetAlert.swal("操作取消", "发布取消", "error");
  10111. }
  10112. }
  10113. );
  10114. };
  10115. // 删除
  10116. $scope.remove = function (data) {
  10117. SweetAlert.swal(
  10118. {
  10119. title: "确认删除?",
  10120. text: "删除的数据不可恢复,请确认继续操作!",
  10121. type: "warning",
  10122. showCancelButton: true,
  10123. confirmButtonColor: "#DD6B55",
  10124. confirmButtonText: "继续删除",
  10125. cancelButtonText: "取消操作",
  10126. closeOnConfirm: false,
  10127. closeOnCancel: false,
  10128. },
  10129. function (isConfirm) {
  10130. if (isConfirm) {
  10131. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10132. if (res.status == 200) {
  10133. SweetAlert.swal({
  10134. title: "删除成功!",
  10135. type: "success",
  10136. confirmButtonColor: "#007AFF",
  10137. });
  10138. $scope.refreshData($scope.jry_filterdata);
  10139. } else {
  10140. SweetAlert.swal({
  10141. title: "删除失败",
  10142. text: "系统错误,请重试!",
  10143. type: "error",
  10144. });
  10145. }
  10146. });
  10147. } else {
  10148. SweetAlert.swal("操作取消", "数据安全", "error");
  10149. }
  10150. }
  10151. );
  10152. };
  10153. $scope.refreshData = function (filterData) {
  10154. // $scope.ldloading[style.replace('-', '_')] = true;
  10155. if (angular.isUndefined(filterData)) {
  10156. filterData = defaultFilterData;
  10157. }
  10158. $scope.myData = [];
  10159. $scope.memoryfilterData = filterData;
  10160. api_doc_data.fetchDataList("taskSub", filterData).then(
  10161. function (data) {
  10162. var myData = data;
  10163. $scope.gridOptions.totalItems = myData.totalNum;
  10164. $scope.removeFileNum = myData.totalNum;
  10165. if (angular.isArray(myData.list)) {
  10166. $scope.myData = myData.list;
  10167. for (var i = 0; i < $scope.myData.length; i++) {
  10168. //添加序号
  10169. $scope.myData[i]["item"] =
  10170. i + 1 + filterData.idx * filterData.sum;
  10171. $scope.myData[i].startTime = moment(
  10172. $scope.myData[i].startTime
  10173. ).format("YYYY-MM-DD HH:mm:ss");
  10174. $scope.myData[i].endTime = moment(
  10175. $scope.myData[i].endTime
  10176. ).format("YYYY-MM-DD HH:mm:ss");
  10177. }
  10178. }
  10179. },
  10180. function () {
  10181. // $scope.ldloading[style.replace('-', '_')] = false;
  10182. }
  10183. );
  10184. };
  10185. //分页控制
  10186. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10187. gridApi.pagination.on.paginationChanged(
  10188. $scope,
  10189. function (newPage, pageSize) {
  10190. $scope.jry_filterdata.idx = newPage - 1;
  10191. $scope.fenye = newPage - 1;
  10192. $scope.jry_filterdata.sum = pageSize;
  10193. $scope.refreshData($scope.jry_filterdata);
  10194. }
  10195. );
  10196. };
  10197. $scope.fenye = 0;
  10198. if ($scope.model.label == "分配任务") {
  10199. $scope.jry_filterdata = {
  10200. idx: $scope.fenye,
  10201. sum: 10,
  10202. taskSub: {
  10203. taskMonth: {
  10204. id: $scope.model.taskMonth.id,
  10205. },
  10206. userid: loginUser.id,
  10207. role: loginUser.role,
  10208. },
  10209. };
  10210. } else {
  10211. $scope.jry_filterdata = {
  10212. idx: $scope.fenye,
  10213. sum: 10,
  10214. taskSub: {
  10215. taskMonth: {
  10216. id: $scope.model.taskMonth.id,
  10217. },
  10218. userid: loginUser.id,
  10219. role: loginUser.role,
  10220. type: 1,
  10221. },
  10222. };
  10223. }
  10224. $scope.refreshData($scope.jry_filterdata);
  10225. //新增模态框
  10226. $scope.newDistribution = function () {
  10227. var modalInstance = $modal.open({
  10228. backdrop: false,
  10229. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10230. controller: function (
  10231. $scope,
  10232. scope,
  10233. $modalInstance,
  10234. api_doc_data,
  10235. SweetAlert,
  10236. api_user_data,
  10237. api_wechatfile
  10238. ) {
  10239. $scope.personData = {}; //指派人
  10240. $scope.priorityData = {}; //优先级
  10241. $scope.personListData = {}; //指派人下拉数据
  10242. $scope.priorityListData = {}; //优先级下拉数据
  10243. $scope.startTime = ""; //开始时间
  10244. $scope.endTime = ""; //结束时间
  10245. $scope.taskDescribe = ""; //任务描述
  10246. $scope.motaikuang = "";
  10247. $scope.shijian = "哈哈";
  10248. // 指派人下拉框数据
  10249. $scope.getPersonData = function () {
  10250. var data = {
  10251. idx: 0,
  10252. sum: 1000,
  10253. };
  10254. api_user_data.fetchDataList("user", data).then(function (res) {
  10255. $scope.personListData = res.list;
  10256. });
  10257. };
  10258. $scope.getPersonData();
  10259. //优先级下拉数据
  10260. $scope.getPriorityData = function () {
  10261. var data = {
  10262. key: "change_rick_level",
  10263. type: "list",
  10264. };
  10265. api_wechatfile.getDictionary(data).then(function (res) {
  10266. $scope.priorityListData = res;
  10267. });
  10268. };
  10269. // 控制结束时间的最大时间
  10270. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10271. // 控制结束时间的最小时间
  10272. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10273. $scope.$watch("startTime", function (n, o) {
  10274. if (n) {
  10275. if (n > scope.model.taskMonth.startTime) {
  10276. $scope.jryEndMinTime = n;
  10277. }
  10278. }
  10279. });
  10280. // 控制开始时间的最小时间
  10281. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10282. // 控制开始时间的最大时间
  10283. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10284. $scope.$watch("endTime", function (n, o) {
  10285. if (n) {
  10286. if (n < scope.model.taskMonth.endTime) {
  10287. $scope.jryStartMaxTime = n;
  10288. }
  10289. }
  10290. });
  10291. $scope.getPriorityData();
  10292. //时间控件
  10293. $scope.open = function ($event) {
  10294. $event.preventDefault();
  10295. $event.stopPropagation();
  10296. $scope.opened = !$scope.opened;
  10297. };
  10298. $scope.endOpen = function ($event) {
  10299. $event.preventDefault();
  10300. $event.stopPropagation();
  10301. $scope.startOpened = false;
  10302. $scope.endOpened = !$scope.endOpened;
  10303. };
  10304. $scope.startOpen = function ($event) {
  10305. $event.preventDefault();
  10306. $event.stopPropagation();
  10307. $scope.endOpened = false;
  10308. $scope.startOpened = !$scope.startOpened;
  10309. };
  10310. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10311. // 获取状态-lmm
  10312. $scope.stateListData = {};
  10313. $scope.getStateData = function () {
  10314. //lyl
  10315. var data = {
  10316. key: "task_sub_state",
  10317. type: "list",
  10318. };
  10319. api_wechatfile.getDictionary(data).then(function (res) {
  10320. angular.forEach(res, function (v, i) {
  10321. $scope.stateListData[v.value] = v.id;
  10322. });
  10323. });
  10324. };
  10325. $scope.getStateData();
  10326. // 草稿保存
  10327. $scope.ok = function (item) {
  10328. if (
  10329. $scope.taskDescribe &&
  10330. $scope.personData.data &&
  10331. $scope.priorityData.data &&
  10332. $scope.startTime &&
  10333. $scope.endTime
  10334. ) {
  10335. $scope.startTime = moment(
  10336. new Date($scope.startTime).getTime()
  10337. ).format("YYYY-MM-DD HH:mm:ss");
  10338. $scope.endTime = moment(
  10339. new Date($scope.endTime).getTime()
  10340. ).format("YYYY-MM-DD HH:mm:ss");
  10341. $scope.addData = {
  10342. taskSub: {
  10343. taskDescribe: $scope.taskDescribe,
  10344. assign: $scope.personData.data,
  10345. priority: $scope.priorityData.data,
  10346. startTime: $scope.startTime,
  10347. endTime: $scope.endTime,
  10348. taskMonth: {
  10349. id: scope.model.taskMonth.id,
  10350. },
  10351. },
  10352. };
  10353. $scope.addData.taskSub["state"] = {
  10354. id: $scope.stateListData[1],
  10355. };
  10356. api_user_data
  10357. .addData("taskSub", $scope.addData)
  10358. .then(function (res) {
  10359. if (res.status == 200) {
  10360. SweetAlert.swal({
  10361. title: "保存成功!",
  10362. type: "success",
  10363. confirmButtonColor: "#007AFF",
  10364. });
  10365. scope.refreshData(scope.jry_filterdata);
  10366. $modalInstance.dismiss("cancel");
  10367. } else {
  10368. SweetAlert.swal({
  10369. title: "保存失败",
  10370. text: "系统错误,请重试!",
  10371. type: "error",
  10372. });
  10373. $modalInstance.dismiss("cancel");
  10374. }
  10375. });
  10376. } else {
  10377. SweetAlert.swal({
  10378. title: "保存失败",
  10379. text: "必填项不能为空!",
  10380. type: "error",
  10381. });
  10382. }
  10383. };
  10384. // 发布
  10385. $scope.release = function () {
  10386. if (
  10387. $scope.taskDescribe &&
  10388. $scope.personData.data &&
  10389. $scope.priorityData.data &&
  10390. $scope.startTime &&
  10391. $scope.endTime
  10392. ) {
  10393. $scope.startTime = moment(
  10394. new Date($scope.startTime).getTime()
  10395. ).format("YYYY-MM-DD HH:mm:ss");
  10396. $scope.endTime = moment(
  10397. new Date($scope.endTime).getTime()
  10398. ).format("YYYY-MM-DD HH:mm:ss");
  10399. $scope.addData = {
  10400. taskSub: {
  10401. taskDescribe: $scope.taskDescribe,
  10402. assign: $scope.personData.data,
  10403. priority: $scope.priorityData.data,
  10404. startTime: $scope.startTime,
  10405. endTime: $scope.endTime,
  10406. taskMonth: {
  10407. id: scope.model.taskMonth.id,
  10408. },
  10409. },
  10410. };
  10411. $scope.addData.taskSub["state"] = {
  10412. id: $scope.stateListData[1],
  10413. };
  10414. api_user_data
  10415. .addData("taskSub", $scope.addData)
  10416. .then(function (res) {
  10417. if (res.status == 200) {
  10418. SweetAlert.swal({
  10419. title: "保存成功!",
  10420. type: "success",
  10421. confirmButtonColor: "#007AFF",
  10422. });
  10423. scope.refreshData(scope.jry_filterdata);
  10424. $modalInstance.dismiss("cancel");
  10425. } else {
  10426. SweetAlert.swal({
  10427. title: "保存失败",
  10428. text: "系统错误,请重试!",
  10429. type: "error",
  10430. });
  10431. $modalInstance.dismiss("cancel");
  10432. }
  10433. });
  10434. } else {
  10435. SweetAlert.swal({
  10436. title: "保存失败",
  10437. text: "必填项不能为空!",
  10438. type: "error",
  10439. });
  10440. }
  10441. };
  10442. $scope.cancel = function () {
  10443. $modalInstance.dismiss("cancel");
  10444. };
  10445. },
  10446. size: "sm",
  10447. resolve: {
  10448. scope: function () {
  10449. return $scope;
  10450. },
  10451. },
  10452. backdrop: true,
  10453. });
  10454. };
  10455. },
  10456. });
  10457. // 多次反馈文本域组件--jry
  10458. formlyConfigProvider.setType({
  10459. name: "ui-feedbacktTextarea",
  10460. extends: "textarea",
  10461. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10462. defaultOptions: function (options) {
  10463. return {
  10464. templateOptions: {
  10465. transform: function (model, value) {
  10466. return value;
  10467. },
  10468. },
  10469. validation: {
  10470. messages: {
  10471. maxlength: function (viewValue, modelValue, scope) {
  10472. if (viewValue != null) {
  10473. if (viewValue.length > scope.to.maxlength) {
  10474. return (
  10475. scope.to.label +
  10476. " 字数(" +
  10477. viewValue.length +
  10478. ")超限(" +
  10479. scope.to.maxlength +
  10480. ")"
  10481. );
  10482. } else {
  10483. return "";
  10484. }
  10485. }
  10486. },
  10487. },
  10488. },
  10489. };
  10490. },
  10491. controller: [
  10492. "$scope",
  10493. "moment",
  10494. function ($scope, moment) {
  10495. // console.log($scope);
  10496. var timeKey = $scope.options.templateOptions.time;
  10497. $scope.time = moment($scope.model[timeKey]).format(
  10498. "YYYY-MM-DD HH:mm:ss"
  10499. );
  10500. var value = $scope.model[$scope.options.key];
  10501. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10502. $scope.model[$scope.options.key] =
  10503. $scope.options.templateOptions.transform(
  10504. $scope.originalModel,
  10505. value
  10506. );
  10507. }
  10508. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10509. $scope.options.templateOptions.felditem($scope);
  10510. }
  10511. },
  10512. ],
  10513. });
  10514. //任务管理开始时间--jry
  10515. formlyConfigProvider.setType({
  10516. name: "ui-jryStartdatepicker",
  10517. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10518. extends: "input",
  10519. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10520. defaultOptions: {
  10521. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10522. templateOptions: {
  10523. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10524. },
  10525. },
  10526. controller: [
  10527. "$scope",
  10528. "$filter",
  10529. function ($scope, $filter) {
  10530. // console.log($scope.model[$scope.options.key],'lmm');
  10531. $scope.mindata = new Date(
  10532. $scope.options.templateOptions.transform($scope.model).getTime() +
  10533. 5 * 60 * 1000
  10534. );
  10535. if ($scope.model[$scope.options.key]) {
  10536. $scope.model[$scope.options.key] = $filter("date")(
  10537. $scope.model[$scope.options.key],
  10538. $scope.options.templateOptions.datepickerPopup
  10539. );
  10540. }
  10541. // console.log($scope.model[$scope.options.key],'lmm');
  10542. // console.log($scope.model,'lmm',$scope.options.key);
  10543. $scope.options.initialValue = $scope.model[$scope.options.key];
  10544. $scope.endOpen = true;
  10545. $scope.datepicker = {};
  10546. $scope.datepicker.opened = false;
  10547. $scope.datepicker.open = function ($event) {
  10548. $scope.datepicker.opened = true;
  10549. };
  10550. },
  10551. ],
  10552. });
  10553. //任务管理结束时间--jry
  10554. formlyConfigProvider.setType({
  10555. name: "ui-jryEnddatepicker",
  10556. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10557. extends: "input",
  10558. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10559. defaultOptions: {
  10560. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10561. templateOptions: {
  10562. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10563. },
  10564. },
  10565. controller: [
  10566. "$scope",
  10567. "$filter",
  10568. function ($scope, $filter) {
  10569. $scope.mindata = new Date(
  10570. $scope.options.templateOptions.transform($scope.model).getTime() +
  10571. 5 * 60 * 1000
  10572. );
  10573. if ($scope.model[$scope.options.key]) {
  10574. $scope.model[$scope.options.key] = $filter("date")(
  10575. $scope.model[$scope.options.key],
  10576. $scope.options.templateOptions.datepickerPopup
  10577. );
  10578. }
  10579. $scope.options.initialValue = $scope.model[$scope.options.key];
  10580. $scope.endOpen = true;
  10581. $scope.datepicker = {};
  10582. $scope.datepicker.opened = false;
  10583. $scope.datepicker.open = function ($event) {
  10584. $scope.datepicker.opened = true;
  10585. };
  10586. },
  10587. ],
  10588. });
  10589. //下拉多选框灵活组件--jry
  10590. formlyConfigProvider.setType({
  10591. name: "ui-jry_multiselectplus",
  10592. extends: "multiCheckbox",
  10593. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10594. defaultOptions: function (options) {
  10595. return {
  10596. templateOptions: {
  10597. refreshData: function (search, options, model, that) {
  10598. // var process = options.templateOptions.ApiService.all("");
  10599. if (search) {
  10600. } else {
  10601. }
  10602. var postData = options.templateOptions.optionsPostData;
  10603. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10604. postData = options.templateOptions.optionsPostData(
  10605. options,
  10606. model,
  10607. that
  10608. );
  10609. }
  10610. options.templateOptions.ApiService.fetchDataList(
  10611. options.templateOptions.optionsUrl,
  10612. options.templateOptions.optionsPostData
  10613. ).then(function (result) {
  10614. // if (!options.templateOptions.options) {
  10615. // options.templateOptions.options = [];
  10616. // }
  10617. if (options.templateOptions.optionsDataKey) {
  10618. options.templateOptions.options =
  10619. result[options.templateOptions.optionsDataKey];
  10620. } else {
  10621. options.templateOptions.options = result;
  10622. }
  10623. if (options.templateOptions.optionsChecked) {
  10624. // return options.value = null;
  10625. options.value(options.model[options.key]);
  10626. }
  10627. });
  10628. },
  10629. refreshDelay: 0,
  10630. // },
  10631. validators: {
  10632. required: {
  10633. expression: function (viewValue, modelValue) {
  10634. var value = modelValue || viewValue;
  10635. return value != null;
  10636. // return value.length>=1;
  10637. // if (modelValue && viewValue) {
  10638. // return value != null;
  10639. // } else {
  10640. // var value = modelValue || viewValue;
  10641. // return value.length > 0;
  10642. // }
  10643. },
  10644. },
  10645. },
  10646. },
  10647. };
  10648. },
  10649. controller: [
  10650. "$scope",
  10651. function ($scope) {
  10652. console.log($scope.to);
  10653. if (angular.isArray($scope.model[$scope.options.key])) {
  10654. } else {
  10655. $scope.model[$scope.options.key] = [];
  10656. }
  10657. },
  10658. ],
  10659. });
  10660. //下拉框组件
  10661. formlyConfigProvider.setType({
  10662. name: "ui-select",
  10663. extends: "select",
  10664. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10665. defaultOptions: function (options, scope) {
  10666. return {
  10667. templateOptions: {
  10668. // refresh: function() {},
  10669. getScope: function () {
  10670. return scope;
  10671. },
  10672. refreshDelay: 0,
  10673. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10674. //POST
  10675. console.log(model, "model");
  10676. angular.extend(data, {
  10677. idx: 0,
  10678. sum: 1000,
  10679. });
  10680. options.templateOptions.APIService.fetchDataList(
  10681. modelName,
  10682. data
  10683. ).then(function (response) {
  10684. var myData =
  10685. options.templateOptions.Restangular.stripRestangular(response);
  10686. var list = myData.list;
  10687. console.log(myData);
  10688. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10689. // console.log('balabalabala');
  10690. // console.log(res);
  10691. // })
  10692. if (list.length == 1) {
  10693. if (options.templateOptions.APIport) {
  10694. options.templateOptions.APIport.expectedTime(
  10695. "L" + list[0][key].id
  10696. ).then(function (response) {
  10697. if (response.state == "200") {
  10698. // if (model.$parent.model && model.$parent.model.incident) {
  10699. // } else {
  10700. // model.$parent.model = { 'incident': {} };
  10701. // }
  10702. var myDatas = response.serviceLevelAgreement;
  10703. //逾期
  10704. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10705. response.date;
  10706. //解决
  10707. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10708. myDatas.resolveTime;
  10709. //响应
  10710. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10711. myDatas.responseTime;
  10712. } else {
  10713. }
  10714. });
  10715. }
  10716. angular.forEach(model.fields, function (item) {
  10717. angular.forEach(model.fields, function (item) {
  10718. if (item.templateOptions.pkey == modelKey + "." + key) {
  10719. item.model.id = "";
  10720. if (key == "place") {
  10721. item.templateOptions.options = list;
  10722. } else if (key == "placeDTO") {
  10723. item.templateOptions.options = list;
  10724. } else if (key == "requester") {
  10725. } else {
  10726. item.value(list[0][key][item.key]);
  10727. }
  10728. }
  10729. });
  10730. });
  10731. } else {
  10732. if (model.fields) {
  10733. angular.forEach(model.fields, function (item) {
  10734. angular.forEach(model.fields, function (item) {
  10735. if (item.templateOptions.pkey == modelKey + "." + key) {
  10736. item.model.id = "";
  10737. if (key == "place") {
  10738. item.templateOptions.isnosearch = true;
  10739. item.templateOptions.options = list;
  10740. }
  10741. if (key == "placeDTO") {
  10742. item.templateOptions.options = list;
  10743. }
  10744. if (key == "requester") {
  10745. }
  10746. if (key == "room") {
  10747. item.templateOptions.options = list;
  10748. }
  10749. }
  10750. });
  10751. });
  10752. } else {
  10753. angular.forEach(
  10754. scope.$parent.$parent.$parent.fields,
  10755. function (item) {
  10756. angular.forEach(
  10757. scope.$parent.$parent.$parent.fields,
  10758. function (item) {
  10759. if (
  10760. item.templateOptions.pkey ==
  10761. modelKey + "." + key
  10762. ) {
  10763. if (key == "place") {
  10764. item.templateOptions.isnosearch = true;
  10765. item.templateOptions.options = list;
  10766. scope.$parent.$parent.$parent.model.incident.place =
  10767. model.incident.place;
  10768. }
  10769. if (key == "placeDTO") {
  10770. item.templateOptions.options = list;
  10771. }
  10772. if (key == "requester") {
  10773. }
  10774. }
  10775. }
  10776. );
  10777. }
  10778. );
  10779. }
  10780. }
  10781. console.log(key);
  10782. //报修科室
  10783. if (key == "dept") {
  10784. // 报修科室单选
  10785. scope.$parent.$parent.$parent.model.incident.department =
  10786. response.list[0];
  10787. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10788. response.list[0].phone;
  10789. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10790. // 选择重复事件侧滑框
  10791. scope.$parent.$parent.$parent.model[
  10792. "repeatIncidentShow"
  10793. ] = false;
  10794. setTimeout(() => {
  10795. scope.$parent.$parent.$parent.model[
  10796. "repeatIncidentShow"
  10797. ] = true;
  10798. }, 500);
  10799. }
  10800. // 报修人
  10801. if (key == "requester") {
  10802. // 报修人单选
  10803. scope.$parent.$parent.$parent.model.incident.requester =
  10804. response.list[0];
  10805. console.log(scope.$parent.$parent.$parent.model);
  10806. scope.$parent.$parent.$parent.model.incident.account =
  10807. response.list[0].account;
  10808. var selectedItem = response.list[0];
  10809. var data = {
  10810. requester: selectedItem,
  10811. };
  10812. scope.$parent.$parent.$parent.model["requestershow"] =
  10813. selectedItem;
  10814. console.log(selectedItem, "----------------------");
  10815. // if (selectedItem.dept.place.place) {
  10816. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10817. // }
  10818. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10819. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10820. scope.$parent.$parent.$parent.model.incident.area.id =
  10821. selectedItem.place ? selectedItem.place.area.id : null;
  10822. scope.$parent.$parent.$parent.model.incident.place.id =
  10823. selectedItem.place ? selectedItem.place.id : null;
  10824. if(scope.$parent.$parent.$parent.model.incident.area.id){
  10825. options.templateOptions.APIService.fetchDataList(
  10826. 'place',
  10827. {"place":{"areaId":scope.$parent.$parent.$parent.model.incident.area.id},"idx":0,"sum":1000}
  10828. ).then(function (response1) {
  10829. for (var i = 0; i < scope.fields.length; i++) {
  10830. if(scope.fields[i].templateOptions.onlyKey == 'place_start'){
  10831. scope.fields[i].templateOptions.options = response1.status == 200?response1.list:[];
  10832. }
  10833. }
  10834. })
  10835. }
  10836. console.log(scope, 89898998);
  10837. // console.log(scope.formData,'接单页面');
  10838. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10839. scope.model.selecthouseNumber = selectedItem.place
  10840. ? selectedItem.place
  10841. : {};
  10842. scope.$root.selecthouseNumber = selectedItem.place
  10843. ? selectedItem.place
  10844. : {};
  10845. // options.templateOptions.ApiService.addData(
  10846. // "requester",
  10847. // data
  10848. // ).then(function (response) {
  10849. // if (response.status == 200) {
  10850. if (scope.$parent.$parent.$parent) {
  10851. if (scope.$parent.$parent.$parent.place) {
  10852. scope.$parent.$parent.$parent.place.id = "";
  10853. }
  10854. if (scope.$parent.$parent.$parent.area) {
  10855. scope.$parent.$parent.$parent.area.id = "";
  10856. }
  10857. scope.$parent.$parent.$parent.model.incident.contacts =
  10858. selectedItem.name;
  10859. if (
  10860. selectedItem.mphone &&
  10861. selectedItem.mphone != null &&
  10862. selectedItem.mphone != ""
  10863. ) {
  10864. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10865. selectedItem.mphone;
  10866. } else {
  10867. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10868. selectedItem.telephone;
  10869. }
  10870. if (
  10871. selectedItem.requesterTypeDTO &&
  10872. selectedItem.requesterTypeDTO.id == 2
  10873. ) {
  10874. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10875. }
  10876. }
  10877. // if (!response.data.id) {
  10878. // response.data.id = selectedItem.id;
  10879. // }
  10880. console.log(scope);
  10881. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10882. // if (selectedItem.place && selectedItem.place.id) {
  10883. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10884. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10885. // };
  10886. // } else {
  10887. // if (selectedItem.place && selectedItem.place.id) {
  10888. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10889. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10890. // };
  10891. // }
  10892. // if(scope.$parent.$parent.$parent.model.incident.area){
  10893. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10894. // }
  10895. if (selectedItem.id) {
  10896. scope.$parent.$parent.$parent.model.incident.account =
  10897. selectedItem.account;
  10898. }
  10899. // 选择重复事件侧滑框
  10900. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10901. scope.$parent.$parent.$parent.model[
  10902. "repeatIncidentShow"
  10903. ] = false;
  10904. setTimeout(() => {
  10905. scope.$parent.$parent.$parent.model[
  10906. "repeatIncidentShow"
  10907. ] = true;
  10908. }, 500);
  10909. // }
  10910. // }
  10911. // });
  10912. }
  10913. //新建事件,选择派单,选择工作组查找处理人baba
  10914. if (key == "handlerUser") {
  10915. model.fields.forEach(function (v) {
  10916. if (v.templateOptions.pkey == "incident.handlerUser") {
  10917. v.templateOptions.options = list;
  10918. if (model.model.incident.handlerUser) {
  10919. if (model.model.incident.handlerUser.id) {
  10920. var flag = list.some(function (v) {
  10921. return v.id == model.model.incident.handlerUser.id;
  10922. });
  10923. if (flag) {
  10924. v.model.id = model.model.incident.handlerUser.id;
  10925. }
  10926. }
  10927. }
  10928. }
  10929. });
  10930. }
  10931. });
  10932. },
  10933. validators: {
  10934. required: {
  10935. expression: function (viewValue, modelValue) {
  10936. var value = modelValue || viewValue;
  10937. return value != null;
  10938. // return value.length>=1;
  10939. // if (modelValue && viewValue) {
  10940. // return value != null;
  10941. // } else {
  10942. // var value = modelValue || viewValue;
  10943. // return value.length > 0;
  10944. // }
  10945. },
  10946. },
  10947. },
  10948. },
  10949. controller: [
  10950. "$scope",
  10951. "$rootScope",
  10952. "api_bpm_domain",
  10953. "$stateParams",
  10954. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10955. // $scope.myFilter = function(item) {
  10956. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10957. // }
  10958. console.log($scope, "风浪");
  10959. if($scope.to.onlyKey === 'inspection.dictionary'){
  10960. //巡检列表-新增-巡检类型baba
  10961. console.log(location)
  10962. var loc = location.href.split('api_bpm_data')[1] || '';
  10963. if(loc.length <= 2){
  10964. // 新增轮询计划的时候
  10965. $scope.model.id = 1715;//默认系统默认
  10966. }
  10967. }
  10968. //工作组添加全部选项
  10969. // if($scope.options.templateOptions.label == '工作组'){
  10970. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10971. // $scope.model._group = 0;
  10972. // }
  10973. if (
  10974. $scope.options.templateOptions.pkey &&
  10975. $scope.options.templateOptions.pkey == "incident.place"
  10976. ) {
  10977. if (
  10978. $scope.$parent &&
  10979. $scope.$parent.$parent.$parent.model &&
  10980. $scope.$parent.$parent.$parent.model.incident.area &&
  10981. $scope.$parent.$parent.$parent.model.incident.area.id
  10982. ) {
  10983. $scope.options.templateOptions.linkage(
  10984. "place",
  10985. {
  10986. place: {
  10987. areaId:
  10988. $scope.$parent.$parent.$parent.model.incident.area.id,
  10989. // area:{
  10990. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  10991. // }
  10992. },
  10993. },
  10994. $scope.$parent.$parent.$parent.model,
  10995. "incident",
  10996. "place"
  10997. );
  10998. }
  10999. }
  11000. $scope.myFilter = $scope;
  11001. // console.log($scope.options.templateOptions)
  11002. console.log($scope, 77777);
  11003. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  11004. var paramsModel = JSON.parse($stateParams.model)
  11005. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  11006. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  11007. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  11008. }
  11009. }
  11010. //处理人根据故障现象自动带入baba
  11011. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  11012. console.log($scope.options.templateOptions.pkey);
  11013. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  11014. if (
  11015. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  11016. ) {
  11017. $scope.$parent.$parent.$parent.model.assignee =
  11018. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11019. $scope.options.model.id =
  11020. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11021. }
  11022. }
  11023. }
  11024. // 关闭事件页面满意度评价下拉框处理
  11025. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  11026. $scope.model.id =
  11027. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  11028. }
  11029. if ($scope.options.templateOptions.initData == 1) {
  11030. $scope.options.templateOptions.onChange(
  11031. $scope.model.id,
  11032. $scope.options,
  11033. $scope
  11034. );
  11035. }
  11036. if ($scope.options.templateOptions.transform) {
  11037. $scope.options.templateOptions.onChange(
  11038. $scope.model.id,
  11039. $scope.options,
  11040. $scope
  11041. );
  11042. }
  11043. if (angular.isFunction($scope.options.templateOptions.translate)) {
  11044. $scope.model[$scope.options.key] =
  11045. $scope.options.templateOptions.translate(
  11046. $scope.options,
  11047. $rootScope,
  11048. $scope
  11049. );
  11050. }
  11051. if (
  11052. angular.isFunction($scope.options.templateOptions.translatefunc)
  11053. ) {
  11054. $scope.model[$scope.options.key] =
  11055. $scope.options.templateOptions.translatefunc(
  11056. $scope.options,
  11057. $rootScope,
  11058. $scope
  11059. );
  11060. }
  11061. if (
  11062. angular.isFunction($scope.options.templateOptions.onlyfunction)
  11063. ) {
  11064. $scope.options.templateOptions.onlyfunction(
  11065. $scope.options,
  11066. $rootScope,
  11067. $scope
  11068. );
  11069. }
  11070. },
  11071. ],
  11072. };
  11073. },
  11074. });
  11075. //下拉框组件(巡检计划-查看)
  11076. formlyConfigProvider.setType({
  11077. name: "ui-select-xj",
  11078. extends: "select",
  11079. templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
  11080. defaultOptions: function (options, scope) {
  11081. return {
  11082. templateOptions: {
  11083. getScope: function () {
  11084. return scope;
  11085. },
  11086. refreshDelay: 0,
  11087. validators: {
  11088. required: {
  11089. expression: function (viewValue, modelValue) {
  11090. var value = modelValue || viewValue;
  11091. return value != null;
  11092. },
  11093. },
  11094. },
  11095. },
  11096. controller: [
  11097. "$scope",
  11098. "$rootScope",
  11099. "api_bpm_domain",
  11100. "$stateParams",
  11101. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  11102. $scope.model[$scope.options.key] = '0';//默认全部
  11103. var arr = [];
  11104. if($scope.model.inspection.batchNos){
  11105. arr = $scope.model.inspection.batchNos.map(v=>({value:v,name:v}));
  11106. }
  11107. arr.unshift({value:'0',name:'全部'});
  11108. $scope.options.templateOptions.options = arr;
  11109. console.log($scope)
  11110. // ts.$parent.fields.forEach(v=>{
  11111. // if(v.templateOptions.onlyKey === "batchNos"){
  11112. // //巡检计划-批次号
  11113. // var batchNos = $scope.model.batchNos === "0"?"":$scope.model.batchNos;
  11114. // v.templateOptions.getScope().refreshData(batchNos)
  11115. // }
  11116. // })
  11117. // ts.$parent.fields.forEach(v=>{if(v.templateOptions.onlyKey === "batchNos"){var batchNos = item == "0"?"":item;v.templateOptions.getScope().refreshData(batchNos);}})
  11118. // console.log($scope.options)
  11119. // console.log($scope.model)
  11120. },
  11121. ],
  11122. };
  11123. },
  11124. });
  11125. //下拉多选框组件
  11126. formlyConfigProvider.setType({
  11127. name: "ui-multiselect",
  11128. extends: "select",
  11129. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11130. defaultOptions: function (options, $scope) {
  11131. return {
  11132. templateOptions: {
  11133. getLoginUser: function () {
  11134. return $scope.$root.user;
  11135. },
  11136. refresh: function () { },
  11137. refreshDelay: 1000,
  11138. },
  11139. };
  11140. },
  11141. controller: [
  11142. "$scope",
  11143. function ($scope) {
  11144. $scope.model[$scope.options.key] = [];
  11145. },
  11146. ],
  11147. });
  11148. //下拉多选全选组件
  11149. formlyConfigProvider.setType({
  11150. name: "ui-isteven",
  11151. extends: "select",
  11152. templateUrl: "assets/views/customform/tpl/ui-isteven.html",
  11153. defaultOptions: function (options,$scope) {
  11154. return {
  11155. templateOptions: {
  11156. refresh: function () {
  11157. console.log(options)
  11158. options.templateOptions
  11159. .refreshData(options.templateOptions.APIService)
  11160. .then(function (result) {
  11161. if(result.status == 200){
  11162. console.log(result.list)
  11163. //树形结构转换
  11164. function formatDataTree2(json){
  11165. var _json = JSON.parse(JSON.stringify(json));
  11166. return _json.filter(p=>{
  11167. var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
  11168. _arr.length && (p.children = _arr);
  11169. return !p.parent;
  11170. })
  11171. }
  11172. console.log(result.list)
  11173. var list = formatDataTree2(result.list);
  11174. console.log(list)
  11175. // $scope.treeList = angular.copy(list);
  11176. var resultList = [];
  11177. //转换数据
  11178. function trasData(list,obj){
  11179. if(obj){
  11180. //有父级
  11181. list.forEach(v=>{
  11182. var type = "<strong>"+ v.parent.type +"</strong>";//父级type
  11183. var i = resultList.findIndex(c=>c.type == type);
  11184. if(v.children){
  11185. resultList.splice(i+1,0,{
  11186. type: "<strong>"+ v.type +"</strong>",
  11187. msId: v.id,
  11188. msGroup: true,
  11189. },{msGroup: false})
  11190. trasData(v.children,v);
  11191. }else{
  11192. resultList.splice(i+1,0,{...v,...{ticked:false}});
  11193. }
  11194. })
  11195. }else{
  11196. //顶级
  11197. list.forEach(v=>{
  11198. if(v.children){
  11199. resultList.push({
  11200. type: "<strong>"+ v.type +"</strong>",
  11201. msId: v.id,
  11202. msGroup: true,
  11203. },{msGroup: false})
  11204. trasData(v.children,v);
  11205. }else{
  11206. resultList.push(...v,...{ticked:false});
  11207. }
  11208. })
  11209. }
  11210. return resultList;
  11211. }
  11212. var __arr = trasData(list,null);
  11213. // console.log(__arr,options.model.typeIds.split(','))
  11214. if(options.model.typeIds){
  11215. //有巡检类型,则需要回显
  11216. __arr.forEach(w=>{
  11217. w.ticked = options.model.typeIds.split(',').includes(w.id+'');
  11218. })
  11219. }
  11220. $scope.webBrowsersGrouped = __arr;
  11221. console.log($scope.webBrowsersGrouped);
  11222. }
  11223. })
  11224. },
  11225. refreshDelay: 1000,
  11226. },
  11227. };
  11228. },
  11229. controller: [
  11230. "$scope",
  11231. function ($scope) {
  11232. console.log($scope)
  11233. $scope.to.refresh();//获取列表数据
  11234. // $scope.model[$scope.options.key] = [];
  11235. //单项点击或菜单
  11236. $scope.fClick = function(data){
  11237. console.log($scope.outputBrowsers)
  11238. $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
  11239. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11240. // if(data.id){
  11241. // //单项点击
  11242. // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
  11243. // //有巡检类型
  11244. // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
  11245. // if(data.ticked){
  11246. // arr.push(data.id);
  11247. // }else{
  11248. // arr = arr.filter(v=>v != data.id);
  11249. // }
  11250. // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11251. // }else{
  11252. // //无巡检类型
  11253. // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
  11254. // if(data.ticked){
  11255. // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
  11256. // }else{
  11257. // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11258. // }
  11259. // }
  11260. // }else{
  11261. // // 菜单点击
  11262. // console.log($scope.webBrowsersGrouped,data.msId);
  11263. // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
  11264. // return v.parent?v.parent.id == data.msId:false;
  11265. // })
  11266. // if(treeResultArr.every(v=>v.ticked)){
  11267. // //全部都是true的情况下,需要移除,否则增加
  11268. // }
  11269. // console.log(treeResultArr)
  11270. // // --------------------------------------
  11271. // // var treeArr = [];
  11272. // // function findParent(treeList){
  11273. // // treeList.forEach(v=>{
  11274. // // if(v.id == data.msId){
  11275. // // treeArr = v.children;
  11276. // // }else{
  11277. // // if(v.children){
  11278. // // findParent(v.children);
  11279. // // }
  11280. // // }
  11281. // // })
  11282. // // return treeArr;
  11283. // // }
  11284. // // var treeResultArr = findParent($scope.treeList);
  11285. // // console.log(treeResultArr)
  11286. // // -----------------------------------
  11287. // }
  11288. }
  11289. // 全选
  11290. $scope.fSelectAll = function(){
  11291. // console.log($scope.webBrowsersGrouped)
  11292. var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
  11293. // console.log(arr);
  11294. $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11295. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11296. }
  11297. // 全不选
  11298. $scope.fSelectNone = function(){
  11299. $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11300. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11301. }
  11302. // 配置信息
  11303. $scope.outputBrowsers = [];
  11304. $scope.localLang = {
  11305. selectAll: "全选",
  11306. selectNone: "全不选",
  11307. nothingSelected: "请选择"
  11308. }
  11309. },
  11310. ],
  11311. });
  11312. //下拉多选框灵活组件
  11313. formlyConfigProvider.setType({
  11314. name: "ui-multiselectplus",
  11315. extends: "multiCheckbox",
  11316. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11317. defaultOptions: function (options, $scope) {
  11318. return {
  11319. templateOptions: {
  11320. getLoginUser: function () {
  11321. return $scope.$root.user;
  11322. },
  11323. refreshData: function (search, options, model, that) {
  11324. console.log(search, options, model, that)
  11325. var process = options.templateOptions.ApiService.all("");
  11326. if (search) {
  11327. } else {
  11328. }
  11329. var postData = options.templateOptions.optionsPostData;
  11330. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11331. postData = options.templateOptions.optionsPostData(
  11332. options,
  11333. model,
  11334. that
  11335. );
  11336. }
  11337. if (options.templateOptions.modelreasondata) {
  11338. postData = options.templateOptions.modelreasondata;
  11339. }
  11340. if (options.templateOptions.isnosearch) {
  11341. return;
  11342. }
  11343. process
  11344. .customPOST(postData, options.templateOptions.optionsUrl)
  11345. .then(function (result) {
  11346. // if (!options.templateOptions.options) {
  11347. // options.templateOptions.options = [];
  11348. // }
  11349. // 过滤下拉列表已选择的值
  11350. var modelVal = $scope.model[$scope.options.key];
  11351. var ides = [];
  11352. var rList = result.list || result;
  11353. if ($scope.options.key == "serviceTypeIds") {
  11354. modelVal = modelVal.map(function (v) {
  11355. if (typeof v !== 'object') {
  11356. return { id: v };
  11357. } else {
  11358. return v;
  11359. }
  11360. })
  11361. }
  11362. for (var i = 0; i < modelVal.length; i++) {
  11363. for (var j = 0; j < rList.length; j++) {
  11364. if (rList[j].id == modelVal[i].id) {
  11365. ides.push(rList[j].id);
  11366. }
  11367. }
  11368. }
  11369. ides.forEach(function (v1) {
  11370. rList.forEach(function (v2) {
  11371. if (v1 == v2.id) {
  11372. rList = rList.filter(v => v.id != v2.id);
  11373. }
  11374. })
  11375. })
  11376. options.templateOptions.options = rList;
  11377. // if (options.templateOptions.optionsDataKey) {
  11378. // options.templateOptions.options =
  11379. // result[options.templateOptions.optionsDataKey];
  11380. // } else {
  11381. // options.templateOptions.options = result;
  11382. // }
  11383. if (options.templateOptions.optionsChecked) {
  11384. // return options.value = null;
  11385. options.value(options.model[options.key]);
  11386. }
  11387. });
  11388. },
  11389. refreshDelay: 0,
  11390. // },
  11391. // validators: {
  11392. // required: {
  11393. // expression: function(viewValue, modelValue) {
  11394. // var value = modelValue || viewValue;
  11395. // // return value.length>=1;
  11396. // // if (modelValue && viewValue) {
  11397. // // return value != null;
  11398. // // } else {
  11399. // // var value = modelValue || viewValue;
  11400. // // return value.length > 0;
  11401. // // }
  11402. // }
  11403. // }
  11404. },
  11405. };
  11406. },
  11407. controller: [
  11408. "$scope",
  11409. function ($scope) {
  11410. if (angular.isArray($scope.model[$scope.options.key])) {
  11411. } else {
  11412. $scope.model[$scope.options.key] = [];
  11413. }
  11414. },
  11415. ],
  11416. });
  11417. //下拉树形多选组件
  11418. formlyConfigProvider.setType({
  11419. name: "ui-multiselect-tree",
  11420. extends: "multiCheckbox",
  11421. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11422. defaultOptions: function (options) {
  11423. return {
  11424. templateOptions: {
  11425. linkage: function (modelName, data, model, modelKey, key) {
  11426. angular.extend(data, {
  11427. idx: 0,
  11428. sum: 10,
  11429. });
  11430. options.templateOptions.APIService.fetchDataList(
  11431. modelName,
  11432. data
  11433. ).then(function (response) {
  11434. var myData =
  11435. options.templateOptions.Restangular.stripRestangular(response);
  11436. var list = myData.list;
  11437. if (list.length == 1) {
  11438. angular.forEach(model.fields, function (item) {
  11439. angular.forEach(model.fields, function (item) {
  11440. if (item.templateOptions.pkey == modelKey + "." + key) {
  11441. item.model.id = "";
  11442. if (key == "place") {
  11443. item.templateOptions.options = list;
  11444. } else {
  11445. item.value(list[0][key][item.key]);
  11446. }
  11447. }
  11448. });
  11449. });
  11450. }
  11451. });
  11452. },
  11453. // my_tree_handler : function(items) {
  11454. // },
  11455. // onFilterCallback : function(items) {
  11456. // },
  11457. // onFilterCallback : function(items) {
  11458. // },
  11459. refresh: function (items) {
  11460. var treedata = [];
  11461. function convertListToTree(data, treeMap) {
  11462. treedata = data;
  11463. for (var i = 0; i < data.length; i++) {
  11464. for (var j = 0; j < data.length; j++) {
  11465. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11466. if (data[i].pid == data[j].id) {
  11467. data[i].parent = data[j];
  11468. }
  11469. }
  11470. }
  11471. }
  11472. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11473. var root = null; //Initially set our loop to null
  11474. //loop over data
  11475. for (var i = 0; i < data.length; i++) {
  11476. var datum = data[i];
  11477. //each node will have children, so let's give it a "children" poperty
  11478. datum.children = [];
  11479. //add an entry for this node to the map so that any future children can
  11480. //lookup the parent
  11481. idToNodeMap[datum.id] = datum;
  11482. //Does this node have a parent?
  11483. if (
  11484. typeof datum.parent === "undefined" ||
  11485. datum.parent === null
  11486. ) {
  11487. //Doesn't look like it, so this node is the root of the tree
  11488. root = datum;
  11489. treeMap[datum.id] = root;
  11490. } else {
  11491. //This node has a parent, so let's look it up using the id
  11492. parentNode = idToNodeMap[datum.parent.id];
  11493. //We don't need this property, so let's delete it.
  11494. delete datum.parent;
  11495. //Let's add the current node as a child of the parent node.
  11496. parentNode.children.push(datum);
  11497. }
  11498. }
  11499. return root;
  11500. }
  11501. function convertParentToChildList(data) {
  11502. // console.log("data="+JSON.stringify(data))
  11503. var treeMap = {};
  11504. var list = [];
  11505. convertListToTree(data, treeMap);
  11506. angular.forEach(treeMap, function (item) {
  11507. list.push(item);
  11508. });
  11509. return list;
  11510. }
  11511. function selectItem(pmodel, childrens) {
  11512. if (angular.isArray(pmodel)) {
  11513. angular.forEach(pmodel, function (index) {
  11514. if (index && index.id) {
  11515. angular.forEach(childrens, function (item) {
  11516. if (item.id == index.id) {
  11517. item.selected = true;
  11518. }
  11519. if (item && item.children) {
  11520. selectItem(pmodel, item.children);
  11521. }
  11522. });
  11523. }
  11524. });
  11525. } else {
  11526. if (pmodel && pmodel.id) {
  11527. angular.forEach(childrens, function (item) {
  11528. if (item.id == pmodel.id) {
  11529. item.selected = true;
  11530. }
  11531. if (item && item.children) {
  11532. selectItem(pmodel, item.children);
  11533. }
  11534. });
  11535. }
  11536. }
  11537. }
  11538. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11539. options.templateOptions
  11540. .refreshData(options.templateOptions.APIService)
  11541. .then(function (result) {
  11542. if (result.status == 200) {
  11543. if (!options.templateOptions.options) {
  11544. options.templateOptions.options = [];
  11545. }
  11546. if (options.templateOptions.optionsDataKey) {
  11547. options.templateOptions.options = convertParentToChildList(
  11548. result[options.templateOptions.optionsDataKey]
  11549. );
  11550. } else {
  11551. options.templateOptions.options =
  11552. convertParentToChildList(result);
  11553. }
  11554. //set default value
  11555. var pmodel,
  11556. i = 0;
  11557. if (options.templateOptions.pkey) {
  11558. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11559. angular.forEach(
  11560. options.templateOptions.pkey.split("."),
  11561. function (p) {
  11562. if (i == 0) {
  11563. if (options.model[p] == null) {
  11564. options.model[p] = {};
  11565. }
  11566. pmodel = options.model[p];
  11567. i++;
  11568. } else {
  11569. if (pmodel[p] == null) {
  11570. pmodel[p] = {};
  11571. }
  11572. pmodel = pmodel[p];
  11573. }
  11574. }
  11575. );
  11576. } else {
  11577. pmodel = options.model;
  11578. }
  11579. }
  11580. if (pmodel) {
  11581. pmodel = pmodel[options.key];
  11582. } else if (options.model) {
  11583. pmodel = options.model[options.key];
  11584. } else {
  11585. pmodel = options.templateOptions.options;
  11586. }
  11587. if (angular.isArray(pmodel)) {
  11588. if (pmodel) {
  11589. // if(options.templateOptions.isMultiSelect==true){
  11590. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11591. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11592. // })
  11593. // }else{
  11594. selectItem(pmodel, options.templateOptions.options);
  11595. // }
  11596. }
  11597. } else {
  11598. if (pmodel && pmodel.id) {
  11599. selectItem(pmodel, options.templateOptions.options);
  11600. }
  11601. }
  11602. items.inputModel = options.templateOptions.options;
  11603. }
  11604. });
  11605. },
  11606. },
  11607. validators: {
  11608. required: {
  11609. expression: function (viewValue, modelValue) {
  11610. var value = modelValue || viewValue;
  11611. if (angular.isArray(value)) {
  11612. for (var i = 0; i < value.length; i++) {
  11613. value[i] = {
  11614. id: value[i].id,
  11615. };
  11616. }
  11617. return value.length > 0;
  11618. } else {
  11619. // console.log(options)
  11620. // return value = "true";
  11621. return value != null;
  11622. }
  11623. },
  11624. },
  11625. },
  11626. };
  11627. },
  11628. controller: [
  11629. "$scope",
  11630. "api_configure_form",
  11631. function ($scope, api_configure_form) {
  11632. if ($scope.options.templateOptions.isMultiSelect) {
  11633. // console.log($scope);
  11634. } else {
  11635. if ($scope.model[$scope.options.key]) {
  11636. }
  11637. }
  11638. },
  11639. ],
  11640. });
  11641. //多选下拉框组件
  11642. formlyConfigProvider.setType({
  11643. name: "ui-multi-select-tree",
  11644. extends: "input",
  11645. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11646. defaultOptions: function (options,scope) {
  11647. return {
  11648. templateOptions: {
  11649. linkage: function (modelName, data, model, modelKey, key) {
  11650. angular.extend(data, {
  11651. idx: 0,
  11652. sum: 10,
  11653. });
  11654. options.templateOptions.APIService.fetchDataList(
  11655. modelName,
  11656. data
  11657. ).then(function (response) {
  11658. var myData =
  11659. options.templateOptions.Restangular.stripRestangular(response);
  11660. var list = myData.list;
  11661. if (list.length == 1) {
  11662. angular.forEach(model.fields, function (item) {
  11663. angular.forEach(model.fields, function (item) {
  11664. if (item.templateOptions.pkey == modelKey + "." + key) {
  11665. item.model.id = "";
  11666. if (key == "place") {
  11667. item.templateOptions.options = list;
  11668. } else {
  11669. item.value(list[0][key][item.key]);
  11670. }
  11671. }
  11672. });
  11673. });
  11674. }
  11675. });
  11676. },
  11677. getparentdata: function (items) {
  11678. // console.log(items)
  11679. },
  11680. refresh: function (items, search, fn) {
  11681. console.log(items, options);
  11682. var treedata = [];
  11683. function convertListToTree(data, treeMap) {
  11684. console.log(data, treeMap)
  11685. treedata = data;
  11686. for (var i = 0; i < data.length; i++) {
  11687. for (var j = 0; j < data.length; j++) {
  11688. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11689. if (data[i].pid == data[j].id) {
  11690. data[i].parent = data[j];
  11691. }
  11692. }
  11693. // if (data[i].id) {
  11694. // if (data[i].id== data[j].id) {
  11695. // data[i].parent = data[j];
  11696. // }
  11697. // }
  11698. }
  11699. }
  11700. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11701. var root = []; //Initially set our loop to null
  11702. if (search == "search" && items.filterKeyword) {
  11703. function transform(nodes) {
  11704. var treeConverter = {
  11705. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11706. attributeName: "id", //节点唯一标识符
  11707. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11708. transform: function (node) {
  11709. //转化递归函数,参数:一个待插入节点
  11710. if (node.parent != null) {
  11711. //该节点有父节点
  11712. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11713. if (this.needFind) {
  11714. for (var i = 0; i < newNode.children.length; i++) {
  11715. //查找要插入的node子节点是否在newNode这个父节点中存在
  11716. if (
  11717. newNode.children[i][this.attributeName] ===
  11718. node[this.attributeName]
  11719. ) {
  11720. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11721. }
  11722. }
  11723. }
  11724. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11725. // delete node.parent; //删除该节点的parent属性,如果有的话
  11726. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11727. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11728. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11729. } else if (node.parent == null) {
  11730. //该叶节点没有父节点,即为根节点
  11731. // delete node.parent; //删除该节点的parent属性,如果有的话
  11732. if (this.result == null) {
  11733. //根节点不存在
  11734. node.children = []; //给该节点增加children:[]属性
  11735. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11736. } else {
  11737. node.children = [];
  11738. // 顶级去重
  11739. for (
  11740. var i = 0;
  11741. i < this.result.children.length;
  11742. i++
  11743. ) {
  11744. if (
  11745. this.result.children[i][this.attributeName] ===
  11746. node[this.attributeName]
  11747. ) {
  11748. return this.result.children[i];
  11749. }
  11750. }
  11751. this.result.children.push(node);
  11752. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11753. }
  11754. }
  11755. },
  11756. getWhole: function (nodes, attributeName) {
  11757. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11758. var _node = {};
  11759. _node.children = [];
  11760. this.result = _node; //重置根节点
  11761. this.attributeName =
  11762. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11763. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11764. nodes.forEach((item) => {
  11765. //循环调用转化方法
  11766. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11767. this.transform(item);
  11768. });
  11769. return this.result; //返回根节点
  11770. },
  11771. };
  11772. var result = treeConverter.getWhole(nodes); //调用
  11773. return result;
  11774. }
  11775. var li = transform(data).children;
  11776. // li=[...new Set(li)]
  11777. console.log(li);
  11778. treeMap = li;
  11779. fn(li);
  11780. return li;
  11781. } else {
  11782. //loop over data
  11783. for (var i = 0; i < data.length; i++) {
  11784. var datum = data[i];
  11785. //each node will have children, so let's give it a "children" poperty
  11786. datum.children = [];
  11787. //add an entry for this node to the map so that any future children can
  11788. //lookup the parent
  11789. idToNodeMap[datum.id] = datum;
  11790. //Does this node have a parent?
  11791. if (
  11792. typeof datum.parent === "undefined" ||
  11793. datum.parent === null
  11794. ) {
  11795. //Doesn't look like it, so this node is the root of the tree
  11796. root = datum;
  11797. treeMap[datum.id] = root;
  11798. } else {
  11799. //This node has a parent, so let's look it up using the id
  11800. parentNode = idToNodeMap[datum.parent.id];
  11801. //We don't need this property, so let's delete it.
  11802. // delete datum.parent;
  11803. //Let's add the current node as a child of the parent node.
  11804. parentNode.children.push(datum);
  11805. }
  11806. }
  11807. }
  11808. console.log(root);
  11809. return root;
  11810. }
  11811. function convertParentToChildList(data) {
  11812. var treeMap = {};
  11813. var list = [];
  11814. if (search == "search" && items.filterKeyword) {
  11815. var lis = convertListToTree(data, treeMap);
  11816. return lis;
  11817. } else {
  11818. if (data[0] && data[0].orders) {
  11819. list = data;
  11820. } else {
  11821. convertListToTree(data, treeMap);
  11822. angular.forEach(treeMap, function (item) {
  11823. // console.log("item="+JSON.stringify(item))
  11824. list.push(item);
  11825. });
  11826. }
  11827. console.log(list);
  11828. return list;
  11829. }
  11830. }
  11831. function selectItem(pmodel, childrens) {
  11832. if (angular.isArray(pmodel)) {
  11833. angular.forEach(pmodel, function (index) {
  11834. if (index && index.id) {
  11835. angular.forEach(childrens, function (item) {
  11836. if (item.id == index.id) {
  11837. item.selected = true;
  11838. }
  11839. if (item && item.children) {
  11840. selectItem(pmodel, item.children);
  11841. }
  11842. });
  11843. // angular.forEach(treedata,function(parentdata){
  11844. // if(parentdata.id == index.id){
  11845. // if(parentdata.parent&&parentdata.parent.id){
  11846. // parentdata.parent.$
  11847. // }
  11848. // item.selected = true;
  11849. // }
  11850. // if (item && item.children) {
  11851. // selectItem(pmodel ,item.children);
  11852. // }
  11853. // });
  11854. }
  11855. });
  11856. } else {
  11857. if (pmodel && pmodel.id) {
  11858. angular.forEach(childrens, function (item, index) {
  11859. if (item.id == pmodel.id) {
  11860. item.selected = true;
  11861. // delete item.children;
  11862. }
  11863. if (item && item.children) {
  11864. selectItem(pmodel, item.children);
  11865. }
  11866. });
  11867. }
  11868. }
  11869. }
  11870. function selectItemchild(pmodel, childrens) {
  11871. if (angular.isArray(pmodel)) {
  11872. angular.forEach(pmodel, function (index) {
  11873. if (index && index.id) {
  11874. angular.forEach(childrens, function (item) {
  11875. if (item.id == index.id) {
  11876. item.selected = true;
  11877. }
  11878. if (item && item.children) {
  11879. selectItem(pmodel, item.children);
  11880. }
  11881. });
  11882. }
  11883. });
  11884. } else {
  11885. if (pmodel && pmodel.id) {
  11886. angular.forEach(childrens, function (item, index) {
  11887. if (item.id == pmodel.id) {
  11888. item.selected = true;
  11889. childrens[index].selected = true;
  11890. }
  11891. if (item && item.children) {
  11892. selectItem(pmodel, item.children);
  11893. }
  11894. });
  11895. }
  11896. }
  11897. }
  11898. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11899. if (search === "search" && items.filterKeyword) {
  11900. // bala:树形模糊搜索
  11901. options.templateOptions
  11902. .bala(options.templateOptions.APIService, items.filterKeyword)
  11903. .then(function (result) {
  11904. result.list = [...new Set(result.list)]; //去重
  11905. if (!options.templateOptions.options) {
  11906. options.templateOptions.options = [];
  11907. }
  11908. if (options.templateOptions.optionsDataKey) {
  11909. options.templateOptions.options = convertParentToChildList(
  11910. result[options.templateOptions.optionsDataKey]
  11911. );
  11912. } else {
  11913. options.templateOptions.options =
  11914. convertParentToChildList(result);
  11915. }
  11916. //set default value
  11917. var pmodel,
  11918. i = 0;
  11919. if (
  11920. options.templateOptions.pkey ||
  11921. options.templateOptions.pkey != ""
  11922. ) {
  11923. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11924. angular.forEach(
  11925. options.templateOptions.pkey.split("."),
  11926. function (p) {
  11927. if (i == 0) {
  11928. if (options.model[p] == null) {
  11929. options.model[p] = {};
  11930. }
  11931. pmodel = options.model[p];
  11932. i++;
  11933. } else {
  11934. if (pmodel[p] == null) {
  11935. pmodel[p] = {};
  11936. }
  11937. pmodel = pmodel[p];
  11938. }
  11939. }
  11940. );
  11941. } else {
  11942. pmodel = options.model;
  11943. }
  11944. }
  11945. var topdata = angular.copy(options.templateOptions.options);
  11946. if (pmodel) {
  11947. pmodel = pmodel[options.key];
  11948. } else if (options.model) {
  11949. pmodel = options.model[options.key];
  11950. }
  11951. if (angular.isArray(pmodel)) {
  11952. if (pmodel) {
  11953. items.inputModel = angular.copy(
  11954. options.templateOptions.options
  11955. );
  11956. selectItem(pmodel, options.templateOptions.options);
  11957. }
  11958. } else {
  11959. if (pmodel && pmodel.id) {
  11960. items.inputModel = angular.copy(
  11961. options.templateOptions.options
  11962. );
  11963. selectItem(pmodel, options.templateOptions.options);
  11964. } else {
  11965. // items.inputModel = options.templateOptions.options;
  11966. }
  11967. }
  11968. // items.inputModel = options.templateOptions.options;
  11969. items.selectModel = options.templateOptions.options;
  11970. // 可在此展开
  11971. if (!items.inputModel) {
  11972. items.inputModel = items.selectModel;
  11973. } else {
  11974. selectItemchild(pmodel, items.inputModel);
  11975. // for (var i = 0; i < items.inputModel.length; i++) {
  11976. // items.inputModel[i].
  11977. // for (var j = 0; j < items.selectModel.length; j++) {
  11978. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11979. // items.inputModel[i].selected = true;
  11980. // }
  11981. // }
  11982. // }
  11983. }
  11984. return items.inputModel;
  11985. // options.templateOptions.options = angular.copy(topdata);
  11986. // console.log(model);
  11987. // console.log(options);
  11988. });
  11989. } else {
  11990. options.templateOptions
  11991. .refreshData(options.templateOptions.APIService,scope.$root.user)
  11992. .then(function (result) {
  11993. //回显故障现象,带出绑定的人或组start caocao
  11994. if (options.templateOptions.onlyKey == 'cate_start' && items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  11995. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  11996. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  11997. return v.id == items.$parent.originalModel.incident.category.id;
  11998. })
  11999. console.log(item)//11615
  12000. if (item) {
  12001. items.$parent.originalModel.incident.branchType = item.branchType;
  12002. if(item.branchType == 0){
  12003. if (item.userOrGroupType === 1) {
  12004. items.$parent.originalModel.start_code = 'assignment';
  12005. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  12006. items.$parent.originalModel.directClose = true;
  12007. items.$parent.originalModel.isHandlerUser = false;
  12008. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  12009. } else if (item.userOrGroupType === 2) {
  12010. items.$parent.originalModel.start_code = 'assignment';
  12011. items.$parent.originalModel.candidateGroups = item.group;
  12012. items.$parent.originalModel.directClose = true;
  12013. items.$parent.originalModel.isHandlerUser = false;
  12014. } else {
  12015. items.$parent.originalModel.start_code = 'close';
  12016. items.$parent.originalModel.directClose = false;
  12017. items.$parent.originalModel.isHandlerUser = false;
  12018. delete items.$parent.originalModel.candidateGroups;
  12019. delete items.$parent.originalModel.incident.handlerUser
  12020. }
  12021. }else if(item.branchType == 1){
  12022. items.$parent.originalModel.incident.branchUserGroups = item.branchUserGroups;
  12023. // items.$parent.originalModel.incident.area.id
  12024. options.templateOptions.APIService.fetchData('area',items.$parent.originalModel.incident.area.id).then(res=>{
  12025. console.log(res)
  12026. if(res.status == 200){
  12027. items.$parent.originalModel.incident.branchId = res.data.branch;
  12028. // res.data.branch
  12029. var branchUserGroup=item.branchUserGroups.find(v=>v.branchId==res.data.branch)||{};
  12030. if(branchUserGroup.branchUserOrGroupType==1){
  12031. items.$parent.originalModel.start_code='assignment';
  12032. items.$parent.originalModel.incident.handlerUser={id:branchUserGroup.userId?branchUserGroup.userId:undefined};
  12033. items.$parent.originalModel.directClose=true;
  12034. items.$parent.originalModel.isHandlerUser=false;
  12035. setTimeout(function(){items.$parent.originalModel.isHandlerUser=true;},0)
  12036. }else if(branchUserGroup.branchUserOrGroupType===2){
  12037. items.$parent.originalModel.start_code='assignment';
  12038. items.$parent.originalModel.candidateGroups=branchUserGroup.groupId?branchUserGroup.groupId:undefined;
  12039. items.$parent.originalModel.directClose=true;
  12040. items.$parent.originalModel.isHandlerUser=false;
  12041. }else{
  12042. items.$parent.originalModel.start_code='close';
  12043. items.$parent.originalModel.directClose=false;
  12044. items.$parent.originalModel.isHandlerUser=false;
  12045. delete items.$parent.originalModel.candidateGroups;
  12046. delete items.$parent.originalModel.incident.handlerUser
  12047. }
  12048. }
  12049. })
  12050. }
  12051. }
  12052. }
  12053. //回显故障现象,带出绑定的人或组end
  12054. if (!options.templateOptions.options) {
  12055. options.templateOptions.options = [];
  12056. }
  12057. if(options.templateOptions.uuKey == 'knowledge_leve.dutyDepartment'){
  12058. let data = result[options.templateOptions.optionsDataKey];
  12059. for (var i = 0; i < data.length; i++) {
  12060. data[i].parent = {id: -data[i].branch, name: data[i].branchName};
  12061. data[i].name = data[i].dept;
  12062. }
  12063. var parentList = []
  12064. var idToNodeMap = {}
  12065. for (var i = 0; i < data.length; i++) {
  12066. idToNodeMap[data[i].parent.id] = [];
  12067. parentList.push(data[i].parent);
  12068. }
  12069. let map = new Map();
  12070. for (let item of parentList) {
  12071. if (!map.has(item.id)) {
  12072. map.set(item.id, item);
  12073. };
  12074. };
  12075. parentList = [...map.values()];
  12076. // console.log(parentList);
  12077. console.log(data);
  12078. //loop over data
  12079. for (var i = 0; i < data.length; i++) {
  12080. var datum = data[i];
  12081. //each node will have children, so let's give it a "children" poperty
  12082. datum.children = [];
  12083. //add an entry for this node to the map so that any future children can
  12084. //lookup the parent
  12085. if(idToNodeMap[datum.parent.id]){
  12086. idToNodeMap[datum.parent.id].push(JSON.parse(JSON.stringify(datum)));
  12087. }
  12088. //Does this node have a parent?
  12089. }
  12090. for (let key in idToNodeMap) {
  12091. let index = parentList.findIndex(v => v.id == key);
  12092. if (index > -1) {
  12093. parentList[index].children = idToNodeMap[key];
  12094. };
  12095. };
  12096. console.log(parentList)
  12097. options.templateOptions.options = parentList;
  12098. }else{
  12099. if (options.templateOptions.optionsDataKey) {
  12100. options.templateOptions.options = convertParentToChildList(
  12101. result[options.templateOptions.optionsDataKey]
  12102. );
  12103. } else {
  12104. options.templateOptions.options =
  12105. convertParentToChildList(result);
  12106. }
  12107. }
  12108. //set default value
  12109. var pmodel,
  12110. i = 0;
  12111. if (
  12112. options.templateOptions.pkey ||
  12113. options.templateOptions.pkey != ""
  12114. ) {
  12115. if (options.templateOptions.pkey.indexOf(".") > 0) {
  12116. angular.forEach(
  12117. options.templateOptions.pkey.split("."),
  12118. function (p) {
  12119. if (i == 0) {
  12120. if (options.model[p] == null) {
  12121. options.model[p] = {};
  12122. }
  12123. pmodel = options.model[p];
  12124. i++;
  12125. } else {
  12126. if (pmodel[p] == null) {
  12127. pmodel[p] = {};
  12128. }
  12129. pmodel = pmodel[p];
  12130. }
  12131. }
  12132. );
  12133. } else {
  12134. pmodel = options.model;
  12135. }
  12136. }
  12137. var topdata = angular.copy(options.templateOptions.options);
  12138. if (pmodel) {
  12139. pmodel = pmodel[options.key];
  12140. } else if (options.model) {
  12141. pmodel = options.model[options.key];
  12142. }
  12143. if (angular.isArray(pmodel)) {
  12144. if (pmodel) {
  12145. items.inputModel = angular.copy(
  12146. options.templateOptions.options
  12147. );
  12148. selectItem(pmodel, options.templateOptions.options);
  12149. }
  12150. } else {
  12151. if (pmodel && pmodel.id) {
  12152. items.inputModel = angular.copy(
  12153. options.templateOptions.options
  12154. );
  12155. selectItem(pmodel, options.templateOptions.options);//baba
  12156. } else {
  12157. // items.inputModel = options.templateOptions.options;
  12158. }
  12159. }
  12160. // items.inputModel = options.templateOptions.options;
  12161. items.selectModel = options.templateOptions.options;
  12162. if (!items.inputModel) {
  12163. items.inputModel = items.selectModel;
  12164. } else {
  12165. selectItemchild(pmodel, items.inputModel);
  12166. // for (var i = 0; i < items.inputModel.length; i++) {
  12167. // for (var j = 0; j < items.selectModel.length; j++) {
  12168. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12169. // items.inputModel[i].selected = true;
  12170. // }
  12171. // }
  12172. // }
  12173. }
  12174. // options.templateOptions.options = angular.copy(topdata);
  12175. // console.log(model);
  12176. // console.log(options);
  12177. });
  12178. }
  12179. },
  12180. },
  12181. validators: {
  12182. required: {
  12183. expression: function (viewValue, modelValue) {
  12184. var value = modelValue || viewValue;
  12185. if (angular.isArray(value)) {
  12186. return value.length > 0;
  12187. } else {
  12188. // console.log(options)
  12189. if (options.templateOptions.required && !value) {
  12190. // return value != null;
  12191. } else {
  12192. return value;
  12193. }
  12194. // return value = "true";
  12195. }
  12196. },
  12197. },
  12198. },
  12199. };
  12200. },
  12201. controller: [
  12202. "$scope",
  12203. "$rootScope",
  12204. "api_configure_form",
  12205. "api_bpm_domain",
  12206. "api_category",
  12207. function ($scope, $rootScope, api_configure_form, api_bpm_domain, api_category) {
  12208. // // 知识库-责任科室
  12209. // if ($scope.to.uuKey === 'knowledge_leve.dutyDepartment') {
  12210. // //处理远程获取数据控件方法调用
  12211. // $scope.to.refresh = function(searchVal){
  12212. // api_category.getOwnDuty({}).then(function(res){
  12213. // if (!$scope.to.options) {
  12214. // $scope.to.options = res.data || [];
  12215. // }
  12216. // })
  12217. // };
  12218. // }
  12219. $rootScope.checkClicked = function (item) {
  12220. angular.forEach($scope.to.options, function (itemone) {
  12221. if (!item.parent) {
  12222. if (item.id == itemone.id) {
  12223. // itemone.isExpanded = true;
  12224. } else {
  12225. itemone.isExpanded = false;
  12226. }
  12227. } else {
  12228. if (item.parent.id == itemone.id) {
  12229. angular.forEach(itemone.children, function (itemtwo) {
  12230. if (item.id == itemtwo.id) {
  12231. } else {
  12232. itemtwo.isExpanded = false;
  12233. }
  12234. });
  12235. }
  12236. }
  12237. });
  12238. // 故障现象带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  12239. console.log($scope, "gsm");
  12240. if (
  12241. $scope.originalModel &&
  12242. $scope.originalModel.incident &&
  12243. item.category &&
  12244. (!item.children || !item.children.length) &&
  12245. item.priority &&
  12246. item.priority.id
  12247. ) {
  12248. api_bpm_domain
  12249. .expectedTime("L" + (item.priority.id - 1559))
  12250. .then(function (res) {
  12251. $scope.originalModel.incident.expectResponseTime =
  12252. res.serviceLevelAgreement.responseTime;
  12253. $scope.originalModel.incident.expectIntroTime =
  12254. res.serviceLevelAgreement.resolveTime;
  12255. $scope.originalModel.incident.overdueTime = res.date;
  12256. });
  12257. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  12258. // setTimeout(() => {
  12259. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  12260. // }, 500);
  12261. // console.log($scope.$parent.$parent.$parent)
  12262. }
  12263. };
  12264. if ($scope.options.templateOptions.isMultiSelect) {
  12265. // console.log($scope);
  12266. } else {
  12267. if ($scope.model[$scope.options.key]) {
  12268. }
  12269. }
  12270. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  12271. // console.log(item)
  12272. // // if(){
  12273. // // }
  12274. // // $scope.model[$scope.options.key]=item.id;
  12275. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  12276. // $scope.propTypeOptions = data;
  12277. // });
  12278. // }
  12279. // $scope.model[$scope.options.key]=[];
  12280. // $scope.fn
  12281. $rootScope.bala1 = function (items, fn) {
  12282. // $scope.fn = fn;
  12283. console.log(items);
  12284. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  12285. $scope.options.templateOptions.refresh(items, "search", fn);
  12286. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  12287. // // return res.list;
  12288. // console.log(666)
  12289. // fn(res.list)
  12290. // })
  12291. };
  12292. },
  12293. ],
  12294. });
  12295. //勾选组件
  12296. formlyConfigProvider.setType({
  12297. name: "ui-checkbox",
  12298. extends: "checkbox",
  12299. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  12300. controller: [
  12301. "$scope",
  12302. function ($scope) {
  12303. console.log($scope)
  12304. if($scope.options.templateOptions.isTrue){
  12305. //是否默认打开
  12306. $scope.model[$scope.options.key] = true;
  12307. }
  12308. // 巡检生成事件,默认派单
  12309. if ($scope.model.isInspection) {
  12310. $scope.model[$scope.options.key] = true;
  12311. }
  12312. if ($scope.model[$scope.options.key] == "true") {
  12313. $scope.model[$scope.options.key] = true;
  12314. }
  12315. if ($scope.model[$scope.options.key] == "false") {
  12316. $scope.model[$scope.options.key] = false;
  12317. }
  12318. },
  12319. ],
  12320. });
  12321. //勾选组件(禁用)--yeye
  12322. formlyConfigProvider.setType({
  12323. name: "ui-checkbox-disabled",
  12324. extends: "checkbox",
  12325. templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.html",
  12326. controller: [
  12327. "$scope",
  12328. function ($scope) {
  12329. // 巡检生成事件,默认派单
  12330. // if ($scope.model.isInspection) {
  12331. // $scope.model[$scope.options.key] = true;
  12332. // }
  12333. // if ($scope.model[$scope.options.key] == "true") {
  12334. // $scope.model[$scope.options.key] = true;
  12335. // }
  12336. // if ($scope.model[$scope.options.key] == "false") {
  12337. // $scope.model[$scope.options.key] = false;
  12338. // }
  12339. },
  12340. ],
  12341. });
  12342. //换行组件
  12343. formlyConfigProvider.setType({
  12344. name: "ui-nextLine",
  12345. /*extends: 'input',*/
  12346. template: "<div></div>",
  12347. });
  12348. //多选框组件
  12349. formlyConfigProvider.setType({
  12350. name: "ui-checklist",
  12351. extends: "multiCheckbox",
  12352. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  12353. defaultOptions: function (options) {
  12354. return {
  12355. templateOptions: {
  12356. refresh: function () { },
  12357. refreshDelay: 0,
  12358. },
  12359. };
  12360. },
  12361. });
  12362. //单选框组件
  12363. formlyConfigProvider.setType({
  12364. name: "ui-radio",
  12365. extends: "radio",
  12366. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  12367. defaultOptions: function (options) {
  12368. return {
  12369. templateOptions: {
  12370. refresh: function () {},
  12371. refreshDelay: 0,
  12372. },
  12373. };
  12374. },
  12375. controller: [
  12376. "$scope",
  12377. "api_wechatfile",
  12378. function ($scope,api_wechatfile) {
  12379. // 新增巡检计划-巡检方式baba
  12380. if($scope.to.onlyKey === 'onlineType'){
  12381. api_wechatfile.getDictionary($scope.to.modelreasondata).then(function (result) {
  12382. $scope.to.options = result;
  12383. if(!$scope.model[$scope.options.key]){
  12384. $scope.model[$scope.options.key] = result[0]?result[0].id:null;
  12385. }
  12386. });
  12387. }
  12388. // 巡检生成事件,默认派单
  12389. if ($scope.model.isInspection) {
  12390. $scope.model[$scope.options.key] = true;
  12391. // $scope.model.isHandlerUser=true;
  12392. $scope.model.start_code = "assignment";
  12393. console.log($scope.model);
  12394. }
  12395. //多次暂存配置
  12396. // console.log($scope);
  12397. if ($scope.model.saveAgain) {
  12398. if (
  12399. $scope.model.directClose == "1" ||
  12400. $scope.model.directClose == true
  12401. ) {
  12402. $scope.model[$scope.options.key] = true;
  12403. // if($scope.model.incident.handlingPersonnelUser){
  12404. // delete $scope.model.incident.handlingPersonnelUser;
  12405. // };
  12406. if ($scope.model.incident.handleDescription) {
  12407. delete $scope.model.incident.handleDescription;
  12408. }
  12409. if ($scope.model.incident.closecode) {
  12410. delete $scope.model.incident.closecode;
  12411. }
  12412. if ($scope.model.incident.degree) {
  12413. delete $scope.model.incident.degree;
  12414. }
  12415. } else {
  12416. $scope.model.incident.handlingPersonnelUser =
  12417. $scope.model.incident.acceptUser;
  12418. $scope.model[$scope.options.key] = false;
  12419. }
  12420. }
  12421. },
  12422. ],
  12423. });
  12424. //文本域组件
  12425. formlyConfigProvider.setWrapper({
  12426. name: "validation",
  12427. types: ["ui-textarea"],
  12428. template:
  12429. '<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>',
  12430. });
  12431. formlyConfigProvider.setType({
  12432. name: "ui-textarea",
  12433. extends: "textarea",
  12434. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12435. defaultOptions: function (options) {
  12436. return {
  12437. templateOptions: {
  12438. transform: function (model, value) {
  12439. return value;
  12440. },
  12441. },
  12442. validation: {
  12443. messages: {
  12444. maxlength: function (viewValue, modelValue, scope) {
  12445. if (viewValue != null) {
  12446. if (viewValue.length > scope.to.maxlength) {
  12447. return (
  12448. scope.to.label +
  12449. " 字数(" +
  12450. viewValue.length +
  12451. ")超限(" +
  12452. scope.to.maxlength +
  12453. ")"
  12454. );
  12455. } else {
  12456. return "";
  12457. }
  12458. }
  12459. },
  12460. },
  12461. },
  12462. };
  12463. },
  12464. controller: [
  12465. "$scope",
  12466. function ($scope) {
  12467. var value = $scope.model[$scope.options.key];
  12468. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12469. $scope.model[$scope.options.key] =
  12470. $scope.options.templateOptions.transform(
  12471. $scope.originalModel,
  12472. value
  12473. );
  12474. }
  12475. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12476. $scope.options.templateOptions.felditem($scope);
  12477. }
  12478. },
  12479. ],
  12480. });
  12481. // div版的textarea(展示富文本框内容用)
  12482. formlyConfigProvider.setType({
  12483. name: "ui-divTextarea",
  12484. extends: "textarea",
  12485. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12486. defaultOptions: function (options) {
  12487. return {
  12488. templateOptions: {
  12489. transform: function (model, value) {
  12490. return value;
  12491. },
  12492. },
  12493. validation: {
  12494. messages: {
  12495. // maxlength: function (viewValue, modelValue, scope) {
  12496. // if (viewValue != null) {
  12497. // if (viewValue.length > scope.to.maxlength) {
  12498. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12499. // } else {
  12500. // return "";
  12501. // }
  12502. // }
  12503. // },
  12504. },
  12505. },
  12506. };
  12507. },
  12508. controller: [
  12509. "$scope",
  12510. function ($scope) {
  12511. var value = $scope.model[$scope.options.key];
  12512. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12513. $scope.model[$scope.options.key] =
  12514. $scope.options.templateOptions.transform(
  12515. $scope.originalModel,
  12516. value
  12517. );
  12518. }
  12519. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12520. $scope.options.templateOptions.felditem($scope);
  12521. }
  12522. },
  12523. ],
  12524. });
  12525. // 带有知识库引用的textarea
  12526. formlyConfigProvider.setType({
  12527. name: "ui-textAreaKnowledge",
  12528. // extends: 'textarea',
  12529. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12530. defaultOptions: function (options) {
  12531. return {
  12532. templateOptions: {
  12533. transform: function (model, value) {
  12534. return value;
  12535. },
  12536. },
  12537. validation: {
  12538. messages: {
  12539. maxlength: function (viewValue, modelValue, scope) {
  12540. if (viewValue != null) {
  12541. if (viewValue.length > scope.to.maxlength) {
  12542. return (
  12543. scope.to.label +
  12544. " 字数(" +
  12545. viewValue.length +
  12546. ")超限(" +
  12547. scope.to.maxlength +
  12548. ")"
  12549. );
  12550. } else {
  12551. return "";
  12552. }
  12553. }
  12554. },
  12555. },
  12556. },
  12557. };
  12558. },
  12559. controller: [
  12560. "$scope",
  12561. "$rootScope",
  12562. "$modal",
  12563. "SweetAlert",
  12564. "api_bpm_data",
  12565. "api_bpm_domain",
  12566. "api_solution",
  12567. "$aside",
  12568. "api_zsk",
  12569. "up_down_file",
  12570. "api_wechatfile",
  12571. function (
  12572. $scope,
  12573. $rootScope,
  12574. $modal,
  12575. SweetAlert,
  12576. api_bpm_data,
  12577. api_bpm_domain,
  12578. api_solution,
  12579. $aside,
  12580. api_zsk,
  12581. up_down_file,
  12582. api_wechatfile
  12583. ) {
  12584. // console.log($scope);
  12585. var value = $scope.model[$scope.options.key];
  12586. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12587. $scope.model[$scope.options.key] =
  12588. $scope.options.templateOptions.transform(
  12589. $scope.originalModel,
  12590. value
  12591. );
  12592. }
  12593. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12594. $scope.options.templateOptions.felditem($scope);
  12595. }
  12596. // 引用知识库点击
  12597. $scope.openSolution = function () {
  12598. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12599. setTimeout(() => {
  12600. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12601. }, 100);
  12602. };
  12603. },
  12604. ],
  12605. });
  12606. //常用语句选择textarea
  12607. formlyConfigProvider.setType({
  12608. name: "ui-textselect",
  12609. extends: "textarea",
  12610. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12611. defaultOptions: function (options) {
  12612. return {
  12613. templateOptions: {
  12614. transform: function (model, value) {
  12615. return value;
  12616. },
  12617. },
  12618. validation: {
  12619. messages: {
  12620. maxlength: function (viewValue, modelValue, scope) {
  12621. if (viewValue != null) {
  12622. if (viewValue.length > scope.to.maxlength) {
  12623. return (
  12624. scope.to.label +
  12625. " 字数(" +
  12626. viewValue.length +
  12627. ")超限(" +
  12628. scope.to.maxlength +
  12629. ")"
  12630. );
  12631. } else {
  12632. return "";
  12633. }
  12634. }
  12635. },
  12636. },
  12637. },
  12638. };
  12639. },
  12640. controller: [
  12641. "$scope",
  12642. function ($scope) {
  12643. var value = $scope.model[$scope.options.key];
  12644. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12645. $scope.model[$scope.options.key] =
  12646. $scope.options.templateOptions.transform(
  12647. $scope.originalModel,
  12648. value
  12649. );
  12650. }
  12651. },
  12652. ],
  12653. });
  12654. //改动的组件 ckeditor封装后的组件
  12655. formlyConfigProvider.setType({
  12656. name: "ui-text-check",
  12657. extends: "textarea",
  12658. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12659. defaultOptions: function (options) {
  12660. return {
  12661. templateOptions: {
  12662. extraPlugins: "uploadimage",
  12663. uploadimageConfig: {
  12664. backend: "basic",
  12665. settings: {
  12666. uploadUrl:
  12667. options.templateOptions.APIService.upload().getRequestedUrl(),
  12668. headers: "",
  12669. downloadUrl:
  12670. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12671. },
  12672. },
  12673. refresh: function (APIService, contentId, data) {
  12674. return APIService.fetchDataList(contentId, data);
  12675. },
  12676. downloadUri: function (APIService, contentId) {
  12677. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12678. },
  12679. upload: function (APIService, contentId) {
  12680. return APIService.getSolutionDowpath(contentId);
  12681. },
  12682. view: function (attachmentId) {
  12683. // return APIService.attachmentsPreviewUrl(contentId);
  12684. },
  12685. refreshDelay: 0,
  12686. transform: function (model, value) {
  12687. return value;
  12688. },
  12689. },
  12690. validation: {
  12691. messages: {
  12692. maxlength: function (viewValue, modelValue, scope) {
  12693. if (viewValue != null) {
  12694. if (viewValue.length > scope.to.maxlength) {
  12695. return (
  12696. scope.to.label +
  12697. " 字数(" +
  12698. viewValue.length +
  12699. ")超限(" +
  12700. scope.to.maxlength +
  12701. ")"
  12702. );
  12703. } else {
  12704. return "";
  12705. }
  12706. }
  12707. },
  12708. },
  12709. },
  12710. };
  12711. },
  12712. controller: [
  12713. "$scope",
  12714. "$rootScope",
  12715. function ($scope, $rootScope) {
  12716. var value = $scope.model[$scope.options.key];
  12717. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12718. $scope.model[$scope.options.key] =
  12719. $scope.options.templateOptions.transform(
  12720. $scope.originalModel,
  12721. value
  12722. );
  12723. }
  12724. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12725. $rootScope.getSession();
  12726. //var expiry={'expiry':14804244006};
  12727. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12728. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12729. $scope.upload = function (contentId, filename) {
  12730. var filename = filename;
  12731. $scope.options.templateOptions
  12732. .upload($scope.options.templateOptions.ApiService, contentId)
  12733. .then(function (response) {
  12734. var file = new Blob([response], {
  12735. type: "application/octet-stream",
  12736. });
  12737. // var filename = filename;
  12738. var fileURL = URL.createObjectURL(file);
  12739. var a = document.createElement("a");
  12740. a.href = fileURL;
  12741. a.target = "_blank";
  12742. a.download = filename;
  12743. document.body.appendChild(a);
  12744. a.click();
  12745. });
  12746. };
  12747. },
  12748. ],
  12749. });
  12750. //改动的组件 ckeditor封装后的附文本组件
  12751. formlyConfigProvider.setType({
  12752. name: "ui-fuwenben",
  12753. extends: "textarea",
  12754. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12755. defaultOptions: function (options) {
  12756. return {
  12757. templateOptions: {
  12758. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12759. extraPlugins: "uploadimage",
  12760. uploadimageConfig: {
  12761. backend: "basic",
  12762. settings: {
  12763. uploadUrl:
  12764. options.templateOptions.APIService.upload(
  12765. -110
  12766. ).getRequestedUrl(),
  12767. headers: "",
  12768. downloadUrl:
  12769. options.templateOptions.APIService.uploadResponseUri(),
  12770. },
  12771. },
  12772. refresh: function (APIService, contentId, data) {
  12773. return APIService.fetchDataList(-110, data);
  12774. },
  12775. downloadUri: function (APIService, contentId) {
  12776. return APIService.downloadAttachment(-110).getRequestedUrl();
  12777. },
  12778. upload: function (APIService, contentId) {
  12779. return APIService.getSolutionDowpath(-110);
  12780. },
  12781. view: function (attachmentId) {
  12782. // return APIService.attachmentsPreviewUrl(contentId);
  12783. },
  12784. refreshDelay: 0,
  12785. transform: function (model, value) {
  12786. return value;
  12787. },
  12788. },
  12789. validation: {
  12790. messages: {
  12791. maxlength: function (viewValue, modelValue, scope) {
  12792. if (viewValue != null) {
  12793. if (viewValue.length > scope.to.maxlength) {
  12794. return (
  12795. scope.to.label +
  12796. " 字数(" +
  12797. viewValue.length +
  12798. ")超限(" +
  12799. scope.to.maxlength +
  12800. ")"
  12801. );
  12802. } else {
  12803. return "";
  12804. }
  12805. }
  12806. },
  12807. },
  12808. },
  12809. };
  12810. },
  12811. controller: [
  12812. "$scope",
  12813. "$rootScope",
  12814. function ($scope, $rootScope) {
  12815. var value = $scope.model[$scope.options.key];
  12816. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12817. $scope.model[$scope.options.key] =
  12818. $scope.options.templateOptions.transform(
  12819. $scope.originalModel,
  12820. value
  12821. );
  12822. }
  12823. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12824. $rootScope.getSession();
  12825. //var expiry={'expiry':14804244006};
  12826. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12827. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12828. $scope.upload = function (contentId, filename) {
  12829. var filename = filename;
  12830. $scope.options.templateOptions
  12831. .upload($scope.options.templateOptions.ApiService, -110)
  12832. .then(function (response) {
  12833. var file = new Blob([response], {
  12834. type: "application/octet-stream",
  12835. });
  12836. // var filename = filename;
  12837. var fileURL = URL.createObjectURL(file);
  12838. var a = document.createElement("a");
  12839. a.href = fileURL;
  12840. a.target = "_blank";
  12841. a.download = filename;
  12842. document.body.appendChild(a);
  12843. a.click();
  12844. });
  12845. };
  12846. },
  12847. ],
  12848. });
  12849. //ui-grid展示控件
  12850. formlyConfigProvider.setType({
  12851. name: "ui-grid-show",
  12852. extends: "multiCheckbox",
  12853. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12854. defaultOptions: function (options,scope) {
  12855. return {
  12856. templateOptions: {
  12857. linkage: function () { },
  12858. getScope: function () {
  12859. return scope;
  12860. },
  12861. },
  12862. };
  12863. },
  12864. controller: function (
  12865. $scope,
  12866. $rootScope,
  12867. i18nService,
  12868. Restangular,
  12869. api_bpm_data
  12870. ) {
  12871. var loginUser = $rootScope.user;
  12872. $scope.langs = i18nService.getAllLangs();
  12873. $scope.lang = "zh-cn";
  12874. i18nService.setCurrentLang($scope.lang);
  12875. $scope.gridOptions = {};
  12876. $scope.gridOptions.data = "myData";
  12877. $scope.gridOptions.enableColumnResizing = true;
  12878. // $scope.gridOptions.enableFiltering = true;
  12879. $scope.gridOptions.enableGridMenu = false;
  12880. $scope.gridOptions.enableRowSelection = true;
  12881. $scope.gridOptions.showGridFooter = true;
  12882. $scope.gridOptions.showColumnFooter = false;
  12883. $scope.gridOptions.fastWatch = true;
  12884. $scope.gridOptions.useExternalFiltering = true;
  12885. $scope.gridOptions.useExternalPagination = true;
  12886. $scope.gridOptions.paginationPageSizes = [10];
  12887. $scope.gridOptions.paginationPageSize = 10;
  12888. $scope.gridOptions.multiSelect = true;
  12889. $scope.gridOptions.rowIdentity = function (row) {
  12890. return row.id;
  12891. };
  12892. $scope.gridOptions.getRowIdentity = function (row) {
  12893. return row.id;
  12894. };
  12895. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12896. $scope.gridOptions.columnDefs = [
  12897. // { name:'id', width:80, enableFiltering:false},
  12898. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12899. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12900. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12901. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12902. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12903. {
  12904. name: "inspection.title",
  12905. displayName: "计划主题",
  12906. width: 120,
  12907. enableFiltering: false,
  12908. },
  12909. {
  12910. name: "sign",
  12911. displayName: "单号",
  12912. width: 140,
  12913. enableFiltering: false,
  12914. },
  12915. {
  12916. name: "inspectionType.type",
  12917. displayName: "巡检分类",
  12918. width: 200,
  12919. enableFiltering: false,
  12920. cellTemplate: '<div>' +
  12921. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  12922. '</div>'
  12923. },
  12924. {
  12925. name: "stateName",
  12926. displayName: "状态",
  12927. width: 80,
  12928. enableFiltering: false,
  12929. },
  12930. {
  12931. name: "processUser.name",
  12932. displayName: "处理人/组",
  12933. width: 120,
  12934. enableFiltering: false,
  12935. cellTemplate: '<div>' +
  12936. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  12937. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  12938. '</div>'
  12939. },
  12940. {
  12941. name: "startDate",
  12942. displayName: "开始时间",
  12943. width: 160,
  12944. enableFiltering: false,
  12945. },
  12946. {
  12947. name: "endTime",
  12948. displayName: "结束时间",
  12949. width: 160,
  12950. enableFiltering: false,
  12951. cellTemplate: '<div>' +
  12952. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  12953. '</div>'
  12954. },
  12955. // {
  12956. // name: "batchNo",
  12957. // displayName: "批次号",
  12958. // width: 160,
  12959. // enableFiltering: false,
  12960. // },
  12961. ];
  12962. var defaultFilterData = {
  12963. idx: 0,
  12964. sum: 10,
  12965. };
  12966. $scope.transferTime = function (time) {
  12967. return moment(time).format("YYYY-MM-DD HH:mm");
  12968. };
  12969. //分页控制
  12970. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12971. gridApi.pagination.on.paginationChanged(
  12972. $scope,
  12973. function (newPage, pageSize) {
  12974. var filtersData = $scope.memoryfilterData;
  12975. filtersData.idx = newPage - 1;
  12976. filtersData.sum = pageSize;
  12977. $scope.refreshData("expand-right", filtersData);
  12978. }
  12979. );
  12980. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12981. data.grid.appScope.selected.items = data.entity;
  12982. });
  12983. };
  12984. //页面获取数据
  12985. $scope.refreshData = function (style, filterData) {
  12986. // $scope.ldloading[style.replace('-', '_')] = true;
  12987. console.log(angular.isUndefined(filterData))
  12988. if (angular.isUndefined(filterData)) {
  12989. filterData = defaultFilterData;
  12990. }
  12991. $scope.myData = [];
  12992. console.log(filterData)
  12993. if(filterData.inspectionProcessActual && filterData.inspectionProcessActual.batchNo){
  12994. filterData.inspectionProcessActual = {
  12995. inspectionid: $scope.model.id,
  12996. batchNo:filterData.inspectionProcessActual.batchNo
  12997. }
  12998. }else{
  12999. filterData.inspectionProcessActual = {
  13000. inspectionid: $scope.model.id
  13001. }
  13002. }
  13003. // angular.extend(filterData, {
  13004. // inspectionProcessActual: {
  13005. // inspectionid: $scope.model.id,
  13006. // },
  13007. // });
  13008. console.log(filterData)
  13009. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  13010. function (data) {
  13011. var myData = Restangular.stripRestangular(data);
  13012. $scope.gridOptions.totalItems = myData.totalNum;
  13013. $scope.myData = myData.list;
  13014. for (var i = 0; i < $scope.myData.length; i++) {
  13015. //添加序号
  13016. $scope.myData[i]["item"] =
  13017. i + 1 + filterData.idx * filterData.sum;
  13018. }
  13019. // $scope.ldloading[style.replace('-', '_')] = false;
  13020. },
  13021. function () {
  13022. // $scope.ldloading[style.replace('-', '_')] = false;
  13023. }
  13024. );
  13025. };
  13026. $scope.refreshData("expand-right", defaultFilterData);
  13027. },
  13028. });
  13029. //文本框自定义选择面板组件
  13030. formlyConfigProvider.setType({
  13031. name: "ui-input-selectmodal",
  13032. extends: "input",
  13033. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  13034. defaultOptions: function (options) {
  13035. return {
  13036. templateOptions: {
  13037. openModal: function (size, options, modal) {
  13038. var modalInstance = modal.open({
  13039. templateUrl: "assets/views/customform/tpl/modal-content.html",
  13040. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  13041. size: size,
  13042. resolve: options.templateOptions.modalParam,
  13043. });
  13044. modalInstance.result.then(
  13045. function (selectedItem) {
  13046. options.value(selectedItem);
  13047. },
  13048. function () {
  13049. //console.log('Modal dismissed at: ' + new Date());
  13050. }
  13051. );
  13052. },
  13053. },
  13054. };
  13055. },
  13056. });
  13057. //日期控件
  13058. var datepicker_attr = [
  13059. "date-disabled",
  13060. "custom-class",
  13061. "show-weeks",
  13062. "starting-day",
  13063. "init-date",
  13064. "min-mode",
  13065. "max-mode",
  13066. "format-day",
  13067. "format-month",
  13068. "format-year",
  13069. "format-day-header",
  13070. "format-day-title",
  13071. "format-month-title",
  13072. "year-range",
  13073. "shortcut-propagation",
  13074. "datepicker-popup",
  13075. "show-button-bar",
  13076. "current-text",
  13077. "clear-text",
  13078. "close-text",
  13079. "close-on-date-selection",
  13080. "datepicker-append-to-body",
  13081. ];
  13082. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  13083. formlyConfigProvider.setType({
  13084. name: "ui-datetime",
  13085. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  13086. extends: "input",
  13087. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13088. defaultOptions: {
  13089. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13090. templateOptions: {
  13091. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13092. },
  13093. },
  13094. controller: [
  13095. "$scope",
  13096. "$filter",
  13097. function ($scope, $filter) {
  13098. $scope.model[$scope.options.key] = $filter("date")(
  13099. new Date(),
  13100. $scope.options.templateOptions.datepickerPopup
  13101. );
  13102. $scope.options.initialValue = $scope.model[$scope.options.key];
  13103. },
  13104. ],
  13105. });
  13106. //日期控件
  13107. formlyConfigProvider.setType({
  13108. name: "ui-datepicker",
  13109. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  13110. extends: "input",
  13111. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13112. defaultOptions: {
  13113. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13114. templateOptions: {
  13115. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13116. },
  13117. },
  13118. controller: [
  13119. "$scope",
  13120. "$filter",
  13121. function ($scope, $filter) {
  13122. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  13123. if ($scope.model[$scope.options.key]) {
  13124. } else {
  13125. $scope.model[$scope.options.key] = $filter("date")(
  13126. new Date(),
  13127. $scope.options.templateOptions.datepickerPopup
  13128. );
  13129. }
  13130. $scope.options.initialValue = $scope.model[$scope.options.key];
  13131. $scope.endOpen = true;
  13132. $scope.datepicker = {};
  13133. $scope.datepicker.opened = false;
  13134. $scope.datepicker.open = function ($event) {
  13135. $scope.datepicker.opened = true;
  13136. };
  13137. },
  13138. ],
  13139. });
  13140. //时分控件
  13141. formlyConfigProvider.setType({
  13142. name: "ui-datehourtime",
  13143. extends: "input",
  13144. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  13145. defaultOptions: function (options) {
  13146. return {
  13147. noFormControl: true,
  13148. // validators:{
  13149. // required:{
  13150. // expression:function(viewValue, modelValue){
  13151. // console.log(options)
  13152. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  13153. // // var value = modelValue.getHours() || viewValue.getHours();
  13154. // return value.length>=1;
  13155. // }
  13156. // }
  13157. // }
  13158. };
  13159. },
  13160. controller: [
  13161. "$scope",
  13162. "$log",
  13163. function ($scope, $log) {
  13164. $scope.hstep = new Date(
  13165. Date.parse($scope.model[$scope.options.key])
  13166. ).getHours();
  13167. $scope.minutes = new Date(
  13168. Date.parse($scope.model[$scope.options.key])
  13169. ).getMinutes();
  13170. $scope.model[$scope.options.key] = new Date(
  13171. Date.parse($scope.model[$scope.options.key])
  13172. );
  13173. },
  13174. ],
  13175. });
  13176. //状态追踪
  13177. formlyConfigProvider.setType({
  13178. name: "ui-followStatus",
  13179. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  13180. controller: [
  13181. "$scope",
  13182. "api_bpm_data",
  13183. "Restangular",
  13184. function ($scope, api_bpm_data, Restangular) {
  13185. setTimeout(function () {
  13186. var pkey = $scope.options.templateOptions.pkey;
  13187. var dataId = $scope.model.id;
  13188. if (dataId) {
  13189. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13190. if (response) {
  13191. var myData = Restangular.stripRestangular(response);
  13192. var processInstanceId = myData.data.processInstanceId;
  13193. $scope.options.templateOptions
  13194. .getData(
  13195. $scope.model,
  13196. $scope.options.templateOptions.ApiService,
  13197. processInstanceId
  13198. )
  13199. .then(function (result) {
  13200. if (result.status == 200) {
  13201. var newData = Restangular.stripRestangular(result);
  13202. $scope.followData = newData.data;
  13203. }
  13204. });
  13205. }
  13206. });
  13207. }
  13208. }, 10);
  13209. },
  13210. ],
  13211. });
  13212. //状态追踪2-事件id
  13213. formlyConfigProvider.setType({
  13214. name: "ui-followStatus2",
  13215. templateUrl: "assets/views/customform/tpl/ui-followStatus2.html",
  13216. controller: [
  13217. "$scope",
  13218. "api_bpm_data",
  13219. "Restangular",
  13220. function ($scope, api_bpm_data, Restangular) {
  13221. setTimeout(function () {
  13222. var pkey = $scope.options.templateOptions.pkey;
  13223. var dataId = $scope.model.id;
  13224. if (dataId) {
  13225. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13226. if (response) {
  13227. var myData = Restangular.stripRestangular(response);
  13228. var incidentId = myData.data.id;
  13229. $scope.options.templateOptions
  13230. .getData(
  13231. $scope.model,
  13232. $scope.options.templateOptions.ApiService,
  13233. incidentId
  13234. )
  13235. .then(function (result) {
  13236. if (result.status == 200) {
  13237. var newData = Restangular.stripRestangular(result);
  13238. $scope.followData = newData.list || [];
  13239. }
  13240. });
  13241. }
  13242. });
  13243. }
  13244. }, 10);
  13245. },
  13246. ],
  13247. });
  13248. //维修记录
  13249. formlyConfigProvider.setType({
  13250. name: "ui-handlerLog",
  13251. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  13252. controller: [
  13253. "$scope",
  13254. "api_bpm_data",
  13255. "Restangular",
  13256. function ($scope, api_bpm_data, Restangular) {
  13257. console.log($scope, 'ui-handlerLog')
  13258. },
  13259. ],
  13260. });
  13261. //资产
  13262. formlyConfigProvider.setType({
  13263. name: "ui-zc",
  13264. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  13265. controller: [
  13266. "$scope",
  13267. "api_bpm_data",
  13268. "Restangular",
  13269. function ($scope, api_bpm_data, Restangular) {
  13270. console.log($scope, 'ui-zc');
  13271. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13272. },
  13273. ],
  13274. });
  13275. //绑定的耗材
  13276. formlyConfigProvider.setType({
  13277. name: "ui-hc",
  13278. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  13279. controller: [
  13280. "$scope",
  13281. "api_cmdb2",
  13282. "Restangular",
  13283. function ($scope, api_cmdb2, Restangular) {
  13284. console.log($scope, 'ui-hc')
  13285. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  13286. $scope.list = [];
  13287. var sjId = $scope.model.incident.id;
  13288. api_cmdb2.getHc(sjId).then(function (response) {
  13289. console.log(response)
  13290. if (response.status == 200) {
  13291. $scope.list = response.data;
  13292. }
  13293. })
  13294. },
  13295. ],
  13296. });
  13297. //历史记录
  13298. formlyConfigProvider.setType({
  13299. name: "ui-history",
  13300. templateUrl: "assets/views/customform/tpl/ui-history.html",
  13301. controller: [
  13302. "$scope",
  13303. "api_bpm_data",
  13304. "Restangular",
  13305. function ($scope, api_bpm_data, Restangular) {
  13306. setTimeout(function () {
  13307. var pkey = $scope.options.templateOptions.pkey;
  13308. var dataId = $scope.model.id;
  13309. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13310. if (response) {
  13311. var myData = Restangular.stripRestangular(response);
  13312. var processInstanceId = myData.data.processInstanceId;
  13313. $scope.options.templateOptions
  13314. .getData(
  13315. $scope.model,
  13316. $scope.options.templateOptions.ApiService,
  13317. processInstanceId
  13318. )
  13319. .then(function (result) {
  13320. if (result.status == 200) {
  13321. var newData = Restangular.stripRestangular(result);
  13322. var long = newData.data.length - 1;
  13323. $scope.followData = newData.data[long];
  13324. }
  13325. });
  13326. }
  13327. });
  13328. }, 10);
  13329. },
  13330. ],
  13331. });
  13332. // //请求人信息显示
  13333. // formlyConfigProvider.setType({
  13334. // name: "ui-disrequester",
  13335. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  13336. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13337. // defaultOptions: function(options) {
  13338. // return {
  13339. // templateOptions: {}
  13340. // };
  13341. // },
  13342. // controller: ['$scope', function($scope) {
  13343. // $scope.options.templateOptions.that = $scope;
  13344. // }]
  13345. // });
  13346. //退回人信息显示
  13347. formlyConfigProvider.setType({
  13348. name: "ui-returnperson",
  13349. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  13350. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13351. defaultOptions: function (options) {
  13352. return {
  13353. templateOptions: {},
  13354. };
  13355. },
  13356. controller: [
  13357. "$scope",
  13358. function ($scope) {
  13359. $scope.group = "";
  13360. $scope.role = "";
  13361. if (
  13362. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13363. $scope.model.handlingPersonnelUser.group.length == 1
  13364. ) {
  13365. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13366. } else {
  13367. for (
  13368. var i = 0;
  13369. i < $scope.model.handlingPersonnelUser.group.length;
  13370. i++
  13371. ) {
  13372. $scope.group +=
  13373. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13374. }
  13375. }
  13376. if (
  13377. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13378. $scope.model.handlingPersonnelUser.role.length == 1
  13379. ) {
  13380. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13381. } else {
  13382. for (
  13383. var i = 0;
  13384. i < $scope.model.handlingPersonnelUser.role.length;
  13385. i++
  13386. ) {
  13387. $scope.role +=
  13388. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13389. }
  13390. }
  13391. $scope.options.templateOptions.that = $scope;
  13392. $scope.options.templateOptions.that = $scope;
  13393. },
  13394. ],
  13395. });
  13396. //退回人信息显示(去掉工作组&角色)
  13397. formlyConfigProvider.setType({
  13398. name: "ui-returnpersonNoGroup",
  13399. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  13400. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13401. defaultOptions: function (options) {
  13402. return {
  13403. templateOptions: {},
  13404. };
  13405. },
  13406. controller: [
  13407. "$scope",
  13408. function ($scope) {
  13409. $scope.group = "";
  13410. $scope.role = "";
  13411. if (
  13412. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13413. $scope.model.handlingPersonnelUser.group.length == 1
  13414. ) {
  13415. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13416. } else {
  13417. for (
  13418. var i = 0;
  13419. i < $scope.model.handlingPersonnelUser.group.length;
  13420. i++
  13421. ) {
  13422. $scope.group +=
  13423. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13424. }
  13425. }
  13426. if (
  13427. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13428. $scope.model.handlingPersonnelUser.role.length == 1
  13429. ) {
  13430. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13431. } else {
  13432. for (
  13433. var i = 0;
  13434. i < $scope.model.handlingPersonnelUser.role.length;
  13435. i++
  13436. ) {
  13437. $scope.role +=
  13438. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13439. }
  13440. }
  13441. $scope.options.templateOptions.that = $scope;
  13442. $scope.options.templateOptions.that = $scope;
  13443. },
  13444. ],
  13445. });
  13446. //指派技术人员
  13447. formlyConfigProvider.setType({
  13448. name: "ui-apiontperson",
  13449. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  13450. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13451. defaultOptions: function (options) {
  13452. return {
  13453. templateOptions: {
  13454. transtlara: function (value, $scope) { },
  13455. },
  13456. };
  13457. },
  13458. controller: [
  13459. "$scope",
  13460. "api_user_data",
  13461. "Restangular",
  13462. function ($scope, api_user_data, Restangular) {
  13463. var filterData = {
  13464. idx: 0,
  13465. sum: 1000,
  13466. };
  13467. api_user_data
  13468. .fetchDataList("group", filterData)
  13469. .then(function (response) {
  13470. if (response.status == 200) {
  13471. $scope.select = {};
  13472. $scope.multipleDemo = {};
  13473. $scope.userdata = {};
  13474. var data = response.list;
  13475. var item = [];
  13476. $scope.multipleDemo = data;
  13477. $scope.multipleDemo;
  13478. }
  13479. });
  13480. $scope.options.templateOptions.onChange = function (
  13481. id,
  13482. options,
  13483. groupdata,
  13484. $event,
  13485. model
  13486. ) {
  13487. if (groupdata.option) {
  13488. $scope.model[$scope.options.key] = {};
  13489. var fildate = {
  13490. idx: 0,
  13491. sum: 1000,
  13492. user: {
  13493. roledata: {
  13494. rolecode: model.currentRole,
  13495. },
  13496. selectType: "1",
  13497. groupdata: {
  13498. id: groupdata.option.id,
  13499. },
  13500. },
  13501. };
  13502. api_user_data
  13503. .fetchDataList("user", fildate)
  13504. .then(function (response) {
  13505. if (response.status == 200) {
  13506. $scope.userdata = {};
  13507. $scope.userdata = response.list;
  13508. }
  13509. });
  13510. } else {
  13511. $scope.model[$scope.options.key] = {
  13512. id: groupdata.id.id,
  13513. };
  13514. $scope.options.templateOptions.transtlara(
  13515. $scope.model[$scope.options.key],
  13516. $scope
  13517. );
  13518. }
  13519. };
  13520. // }
  13521. },
  13522. ],
  13523. });
  13524. //请求科室信息(小蓝框) lmm
  13525. formlyConfigProvider.setType({
  13526. name: "ui-deptinformation",
  13527. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13528. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13529. return {
  13530. templateOptions: {
  13531. checkform: function (options) { },
  13532. },
  13533. };
  13534. },
  13535. controller: [
  13536. "$scope",
  13537. "api_statistic",
  13538. function ($scope, api_statistic) {
  13539. // console.log($scope)
  13540. },
  13541. ],
  13542. });
  13543. //请求人信息
  13544. formlyConfigProvider.setType({
  13545. name: "ui-requesterinformation",
  13546. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13547. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13548. return {
  13549. templateOptions: {
  13550. checkform: function (options) {
  13551. if (options.model.requester) {
  13552. options.value(options.model.requester);
  13553. }
  13554. },
  13555. addRequeter: function (size, options, modal, e) {
  13556. if (e) {
  13557. if (e.clientX === 0) {
  13558. return;
  13559. }
  13560. e.preventDefault();
  13561. }
  13562. var modalInstance = modal.open({
  13563. templateUrl:
  13564. "assets/views/customform/tpl/modal-add-callrequester.html",
  13565. controller: function (
  13566. $scope,
  13567. sco,
  13568. $rootScope,
  13569. $modalInstance,
  13570. items,
  13571. SweetAlert,
  13572. title,
  13573. Restangular,
  13574. APIService,
  13575. UserService,
  13576. api_user_data,
  13577. api_statistic,
  13578. api_wechatfile,
  13579. $stateParams
  13580. ) {
  13581. $modalInstance.SweetAlert = SweetAlert;
  13582. $scope.title = "新增报修人";
  13583. $scope.requester = {};
  13584. $scope.searchData = {};
  13585. $scope.isRoom = sessionStorage.getItem('ifRoom') == 1;
  13586. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13587. var paramsModel = JSON.parse($stateParams.model)
  13588. //来电-添加报修人-回显电话
  13589. if (paramsModel.model.incident.requester.hjzxPhone) {
  13590. $scope.requester.mphone = paramsModel.model.incident.requester.hjzxPhone;
  13591. }
  13592. }
  13593. $scope.onChangeadd = function (searchData) {
  13594. $scope.searchKey = searchData.account;
  13595. // $scope.searchDataadd = searchData;
  13596. var requesdata = angular.copy(searchData);
  13597. if (requesdata.mphone) {
  13598. delete requesdata.mphone;
  13599. }
  13600. $scope.requester = requesdata;
  13601. console.log($scope.requester);
  13602. };
  13603. $scope.refreshUseradd = function (searchKey) {
  13604. //请求人搜索
  13605. $scope.requester.account = searchKey;
  13606. $scope.searchData = searchKey;
  13607. serchdataadd(searchKey);
  13608. };
  13609. $scope.getMydata = function (x) {
  13610. $scope.searchField = JSON.parse(x[0]).account;
  13611. $scope.requester = JSON.parse(x[0]);
  13612. console.log($scope.requester);
  13613. };
  13614. $scope.getMydataone = function (x) {
  13615. $scope.searchField = x;
  13616. $scope.requester.account = x;
  13617. };
  13618. serchdataadd();
  13619. api_wechatfile
  13620. .getDictionary({
  13621. type: "list",
  13622. key: "male",
  13623. })
  13624. .then(function (data) {
  13625. if (data.status == 200) {
  13626. requester.gender = data.list;
  13627. }
  13628. });
  13629. function serchdataadd(searchKey) {
  13630. if (searchKey) {
  13631. var filterData = {
  13632. requester: {
  13633. searchKey: searchKey,
  13634. },
  13635. idx: 0,
  13636. sum: 10,
  13637. };
  13638. } else {
  13639. var filterData = {
  13640. idx: 0,
  13641. sum: 10,
  13642. };
  13643. }
  13644. api_user_data
  13645. .fetchDataList("requester", filterData)
  13646. .then(function (response) {
  13647. var myData = response;
  13648. $scope.myData = myData.list;
  13649. });
  13650. }
  13651. api_user_data
  13652. .fetchDataList("area", {
  13653. idx: 0,
  13654. sum: 1000,
  13655. })
  13656. .then(function (response) {
  13657. if (response.status == 200) {
  13658. $scope.areas = response.list;
  13659. }
  13660. });
  13661. api_wechatfile
  13662. .getDictionary(
  13663. {
  13664. key: "requester_type",
  13665. type: "list",
  13666. },
  13667. {
  13668. idx: 0,
  13669. sum: 100,
  13670. }
  13671. )
  13672. .then(function (response) {
  13673. if (response) {
  13674. $scope.networktypes = response;
  13675. }
  13676. });
  13677. $scope.requesterAreaid = "";
  13678. $scope.onChange = function (item) {
  13679. $scope.requesterAreaid = item.id;
  13680. api_user_data
  13681. .fetchDataList("place", {
  13682. place: {
  13683. area: {
  13684. id: item.id,
  13685. },
  13686. },
  13687. idx: 0,
  13688. sum: 1000,
  13689. })
  13690. .then(function (response) {
  13691. if (response.status == 200) {
  13692. $scope.places = response.list;
  13693. delete $scope.requester.placeDTO;
  13694. }
  13695. });
  13696. };
  13697. // 修改地点
  13698. $scope.requesterPlaceid = "";
  13699. $scope.onChangePlace = function (item) {
  13700. $scope.requesterPlaceid = item.id;
  13701. api_user_data
  13702. .fetchDataList("room", {
  13703. room: {
  13704. place: {
  13705. id: item.id,
  13706. },
  13707. },
  13708. idx: 0,
  13709. sum: 1000,
  13710. })
  13711. .then(function (response) {
  13712. if (response.status == 200) {
  13713. $scope.rooms = response.list;
  13714. }
  13715. });
  13716. };
  13717. $scope.refresh = function (searchVal) {
  13718. var faildata = {};
  13719. if ($scope.requesterAreaid) {
  13720. faildata = {
  13721. idx: 0,
  13722. sum: 1000,
  13723. place: {
  13724. areaId: $scope.requesterAreaid,
  13725. place: searchVal,
  13726. selectType: "pinyin_qs",
  13727. },
  13728. };
  13729. } else {
  13730. faildata = {
  13731. idx: 0,
  13732. sum: 1000,
  13733. place: {
  13734. place: searchVal,
  13735. selectType: "pinyin_qs",
  13736. },
  13737. };
  13738. }
  13739. api_user_data
  13740. .fetchDataList("place", faildata)
  13741. .then(function (response) {
  13742. $scope.places = response.list;
  13743. delete $scope.requester.placeDTO;
  13744. });
  13745. };
  13746. // 初始化房间号
  13747. $scope.refreshPlace = function () {
  13748. var faildata = {};
  13749. if ($scope.requesterPlaceid) {
  13750. faildata = {
  13751. idx: 0,
  13752. sum: 1000,
  13753. room: {
  13754. place: {id:$scope.requesterPlaceid},
  13755. },
  13756. };
  13757. } else {
  13758. faildata = {
  13759. idx: 0,
  13760. sum: 1000,
  13761. room: {
  13762. place: {id:$scope.requesterPlaceid},
  13763. },
  13764. };
  13765. }
  13766. api_user_data
  13767. .fetchDataList("room", faildata)
  13768. .then(function (response) {
  13769. $scope.rooms = response.list;
  13770. });
  13771. };
  13772. $scope.refreshDepts = function (key) {
  13773. var filterData = {
  13774. idx: 0,
  13775. sum: 5,
  13776. dept: {
  13777. name: key,
  13778. },
  13779. };
  13780. UserService.fetchDataList("department", filterData).then(
  13781. function (response) {
  13782. if (response.status == 200) {
  13783. $scope.depts = response.list;
  13784. }
  13785. }
  13786. );
  13787. };
  13788. $scope.ok = function () {
  13789. if (
  13790. angular.isUndefined($scope.requester.account) ||
  13791. $scope.requester.account == null ||
  13792. $scope.requester.account == ""
  13793. ) {
  13794. SweetAlert.swal(
  13795. "报修人员编号未填!",
  13796. "请填写报修人员编号",
  13797. "error"
  13798. );
  13799. } else if (
  13800. angular.isUndefined($scope.requester.name) ||
  13801. $scope.requester.name == null ||
  13802. $scope.requester.name == ""
  13803. ) {
  13804. SweetAlert.swal(
  13805. "报修人姓名未填!",
  13806. "请填写报修人姓名",
  13807. "error"
  13808. );
  13809. } else if (
  13810. angular.isUndefined($scope.requester.requesterType) ||
  13811. $scope.requester.requesterType == null ||
  13812. $scope.requester.requesterTypeDTO == ""
  13813. ) {
  13814. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13815. } else if (
  13816. angular.isUndefined($scope.requester.mphone) ||
  13817. $scope.requester.mphone == null ||
  13818. $scope.requester.mphone == ""
  13819. ) {
  13820. SweetAlert.swal(
  13821. "报修人联系电话未填!",
  13822. "请填写报修人联系电话",
  13823. "error"
  13824. );
  13825. } else {
  13826. $scope.requesterId = $scope.requester.id;
  13827. var data = {
  13828. incident: {
  13829. requester: {
  13830. id: $scope.requesterId,
  13831. },
  13832. },
  13833. idx: 0,
  13834. sum: 3,
  13835. };
  13836. api_statistic
  13837. .tableData(data, "incident")
  13838. .then(function (data) {
  13839. sco.$parent.$parent.$parent.model.incident.tableList =
  13840. data.list;
  13841. });
  13842. $scope.$watch(
  13843. sco.$parent.$parent.$parent.model.incident.tableList,
  13844. function (oldObj, newObj) {
  13845. if (newObj != oldObj) {
  13846. sco.$parent.$parent.$parent.model.incident.tableList =
  13847. newObj;
  13848. }
  13849. }
  13850. );
  13851. console.log($scope.requester);
  13852. $modalInstance.close($scope.requester);
  13853. }
  13854. };
  13855. $scope.cancel = function () {
  13856. $modalInstance.dismiss("cancel");
  13857. };
  13858. },
  13859. resolve: {
  13860. items: function () {
  13861. return {
  13862. fetchItems: function (filterData, APIService) {
  13863. filterData = filterData || {};
  13864. if (!filterData.idx) {
  13865. filterData = {
  13866. idx: 0,
  13867. sum: 10,
  13868. };
  13869. }
  13870. return options.templateOptions.fetchItems(
  13871. filterData,
  13872. APIService
  13873. );
  13874. },
  13875. };
  13876. },
  13877. title: function () {
  13878. return options.templateOptions.modalTitle;
  13879. },
  13880. Restangular: function () {
  13881. return options.templateOptions.Restangular;
  13882. },
  13883. APIService: function () {
  13884. return options.templateOptions.ApiService;
  13885. },
  13886. UserService: function () {
  13887. return options.templateOptions.UserService;
  13888. },
  13889. sco: function () {
  13890. return $scope;
  13891. },
  13892. },
  13893. });
  13894. modalInstance.result.then(
  13895. function (selectedItem) {
  13896. console.log(selectedItem);
  13897. if (selectedItem) {
  13898. var data = {
  13899. requester: selectedItem,
  13900. };
  13901. $scope.searchKey = selectedItem.account;
  13902. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13903. // if (selectedItem.place && selectedItem.place.place) {
  13904. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13905. // }
  13906. options.templateOptions.UserService.addData(
  13907. "requester",
  13908. data
  13909. ).then(function (response) {
  13910. if (response.status == 200) {
  13911. if (options.model) {
  13912. options.model.requester = response.data;
  13913. $scope.$parent.$parent.$parent.model.incident.requester =
  13914. response.data;
  13915. $scope.$parent.$parent.$parent.model.requestershow =
  13916. response.data;
  13917. if (options.model.place) {
  13918. options.model.place.id = "";
  13919. }
  13920. if (options.model.area) {
  13921. options.model.area.id = "";
  13922. }
  13923. options.model.contacts = selectedItem.name;
  13924. if (
  13925. selectedItem.mphone &&
  13926. selectedItem.mphone != null &&
  13927. selectedItem.mphone != ""
  13928. ) {
  13929. options.model.contactsInformation =
  13930. selectedItem.mphone;
  13931. } else {
  13932. options.model.contactsInformation =
  13933. selectedItem.telephone;
  13934. }
  13935. if (
  13936. selectedItem.requesterTypeDTO &&
  13937. selectedItem.requesterTypeDTO.id == 2
  13938. ) {
  13939. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13940. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13941. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13942. }
  13943. }
  13944. if (!response.data.id) {
  13945. response.data.id = selectedItem.id;
  13946. }
  13947. options.value(response.data);
  13948. options.value(response.data);
  13949. console.log($scope, "0000000");
  13950. //新增报修人带入区域地点2020年4月23日19:48:15
  13951. $scope.model.selecthouseNumber = selectedItem.place
  13952. ? selectedItem.place
  13953. : {};
  13954. $scope.$root.selecthouseNumber = selectedItem.place
  13955. ? selectedItem.place
  13956. : {};
  13957. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13958. if (selectedItem.place && selectedItem.place.id) {
  13959. options.model.place.id = selectedItem.place.id;
  13960. options.model.place.area.id =
  13961. selectedItem.place.area.id;
  13962. }
  13963. } else {
  13964. if (selectedItem.place && selectedItem.place.id) {
  13965. options.model.place.id = selectedItem.place.id;
  13966. options.model.area.id = selectedItem.place.area.id;
  13967. }
  13968. }
  13969. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13970. // options.model.area.id = selectedItem.place.area.id
  13971. // }
  13972. if (selectedItem.houseNumber) {
  13973. options.model.houseNumber = selectedItem.houseNumber;
  13974. }
  13975. if (selectedItem.room) {
  13976. options.model.room.id = selectedItem.room.id;
  13977. }
  13978. // if (selectedItem.id) {
  13979. options.model.account = selectedItem.account;
  13980. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  13981. var baoxiuFields =
  13982. $scope.$parent.$parent.$parent.$parent.$parent.vm
  13983. .fields[1].fields;
  13984. var baoxiurenTo;
  13985. baoxiuFields.forEach((e, i) => {
  13986. if (e.key == "account") {
  13987. baoxiurenTo = e.templateOptions;
  13988. baoxiurenTo.APIService.fetchDataList("requester", {
  13989. idx: 0,
  13990. sum: 20,
  13991. requester: {
  13992. searchKey: selectedItem.account,
  13993. },
  13994. }).then((res) => {
  13995. baoxiurenTo.options = res.list;
  13996. options.model.account = selectedItem.account;
  13997. });
  13998. }
  13999. });
  14000. // }
  14001. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  14002. // 选择重复事件侧滑框
  14003. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  14004. $scope.$parent.$parent.$parent.model[
  14005. "repeatIncidentShow"
  14006. ] = false;
  14007. setTimeout(() => {
  14008. $scope.$parent.$parent.$parent.model[
  14009. "repeatIncidentShow"
  14010. ] = true;
  14011. }, 500);
  14012. // }
  14013. } else {
  14014. modalInstance.SweetAlert.swal({
  14015. title: "系统错误",
  14016. text: "账号重复!",
  14017. type: "error",
  14018. });
  14019. }
  14020. });
  14021. }
  14022. },
  14023. function () { }
  14024. );
  14025. },
  14026. changeRequeter: function (
  14027. size,
  14028. options,
  14029. modal,
  14030. modeldata,
  14031. $rootScope
  14032. ) {
  14033. var modalInstance = modal.open({
  14034. templateUrl:
  14035. "assets/views/customform/tpl/modal-change-requester.html",
  14036. controller: function (
  14037. $scope,
  14038. $modalInstance,
  14039. items,
  14040. SweetAlert,
  14041. title,
  14042. Restangular,
  14043. APIService,
  14044. UserService,
  14045. api_user_data,
  14046. $rootScope
  14047. ) {
  14048. $scope.title = "修改报修人";
  14049. $scope.requester = {
  14050. id: modeldata.requester.id,
  14051. account: modeldata.requester.account,
  14052. name: modeldata.requester.name,
  14053. gender: modeldata.requester.gender,
  14054. email: modeldata.requester.email,
  14055. deptName: modeldata.requester.deptName,
  14056. mphone: modeldata.requester.mphone,
  14057. telephone: modeldata.requester.telephone,
  14058. studentNo: modeldata.requester.studentNo,
  14059. areaDTO: modeldata.requester.areaDTO,
  14060. placeDTO: modeldata.requester.placeDTO,
  14061. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  14062. };
  14063. $scope.onChangeadd = function (searchData) {
  14064. console.log(searchData);
  14065. $scope.searchKey = searchData.account;
  14066. var requesdata = angular.copy(searchData);
  14067. if (requesdata.mphone) {
  14068. delete requesdata.mphone;
  14069. }
  14070. $scope.requester = requesdata;
  14071. };
  14072. $scope.refreshUseradd = function (searchKey) {
  14073. //请求人搜索
  14074. $scope.requester.account = searchKey;
  14075. $scope.searchData = searchKey;
  14076. serchdataadd(searchKey);
  14077. };
  14078. $scope.getMydata = function (x) {
  14079. $scope.searchField = JSON.parse(x[0]).account;
  14080. $scope.requester = JSON.parse(x[0]);
  14081. };
  14082. $scope.getMydataone = function (x) {
  14083. $scope.searchField = x;
  14084. $scope.requester.account = x;
  14085. };
  14086. serchdataadd();
  14087. function serchdataadd(searchKey) {
  14088. if (searchKey) {
  14089. var filterData = {
  14090. requester: {
  14091. searchKey: searchKey,
  14092. },
  14093. idx: 0,
  14094. sum: 10,
  14095. };
  14096. } else {
  14097. var filterData = {
  14098. idx: 0,
  14099. sum: 10,
  14100. };
  14101. }
  14102. api_user_data
  14103. .fetchDataList("requester", filterData)
  14104. .then(function (response) {
  14105. var myData = response;
  14106. $scope.myData = myData.list;
  14107. });
  14108. }
  14109. api_user_data
  14110. .fetchDataList("area", {
  14111. idx: 0,
  14112. sum: 1000,
  14113. })
  14114. .then(function (response) {
  14115. if (response.status == 200) {
  14116. $scope.areas = response.list;
  14117. }
  14118. });
  14119. api_user_data
  14120. .fetchDataList("requesterType", {
  14121. idx: 0,
  14122. sum: 100,
  14123. })
  14124. .then(function (response) {
  14125. if (response.status == 200) {
  14126. $scope.networktypes = response.list;
  14127. }
  14128. });
  14129. if (
  14130. $scope.requester.areaDTO &&
  14131. $scope.requester.areaDTO.id &&
  14132. $scope.requester.areaDTO.id != ""
  14133. ) {
  14134. api_user_data
  14135. .fetchDataList("place", {
  14136. place: {
  14137. areaId: $scope.requester.areaDTO.id,
  14138. },
  14139. idx: 0,
  14140. sum: 1000,
  14141. })
  14142. .then(function (response) {
  14143. if (response.status == 200) {
  14144. $scope.places = response.list;
  14145. }
  14146. });
  14147. }
  14148. $scope.onChange = function (item) {
  14149. $scope.requester.placeDTO = {};
  14150. api_user_data
  14151. .fetchDataList("place", {
  14152. place: {
  14153. areaId: item.id,
  14154. },
  14155. idx: 0,
  14156. sum: 1000,
  14157. })
  14158. .then(function (response) {
  14159. if (response.status == 200) {
  14160. $scope.places = response.list;
  14161. }
  14162. });
  14163. };
  14164. $scope.refreshDepts = function (key) {
  14165. var filterData = {
  14166. idx: 0,
  14167. sum: 5,
  14168. dept: {
  14169. name: key,
  14170. },
  14171. };
  14172. UserService.fetchDataList("department", filterData).then(
  14173. function (response) {
  14174. if (response.status == 200) {
  14175. $scope.depts = response.list;
  14176. }
  14177. }
  14178. );
  14179. };
  14180. $scope.ok = function () {
  14181. if (
  14182. $scope.requester.account == "" ||
  14183. $scope.requester.name == ""
  14184. ) {
  14185. SweetAlert.swal(
  14186. "报修人姓名或人员编号号未填!",
  14187. "请补全报修人信息",
  14188. "error"
  14189. );
  14190. } else {
  14191. $modalInstance.close($scope.requester);
  14192. }
  14193. };
  14194. $scope.cancel = function () {
  14195. $modalInstance.dismiss("cancel");
  14196. };
  14197. },
  14198. resolve: {
  14199. items: function () {
  14200. return {
  14201. fetchItems: function (filterData, APIService) {
  14202. filterData = filterData || {};
  14203. if (!filterData.idx) {
  14204. filterData = {
  14205. idx: 0,
  14206. sum: 10,
  14207. };
  14208. }
  14209. return options.templateOptions.fetchItems(
  14210. filterData,
  14211. APIService
  14212. );
  14213. },
  14214. };
  14215. },
  14216. title: function () {
  14217. return options.templateOptions.modalTitle;
  14218. },
  14219. Restangular: function () {
  14220. return options.templateOptions.Restangular;
  14221. },
  14222. APIService: function () {
  14223. return options.templateOptions.ApiService;
  14224. },
  14225. UserService: function () {
  14226. return options.templateOptions.UserService;
  14227. },
  14228. },
  14229. });
  14230. modalInstance.result.then(
  14231. function (selectedItem) {
  14232. console.log(selectedItem);
  14233. if (selectedItem) {
  14234. if (options.model) {
  14235. if (options.model.place) {
  14236. options.model.place.id = "";
  14237. }
  14238. if (options.model.area) {
  14239. options.model.area.id = "";
  14240. }
  14241. options.model.contacts = selectedItem.name;
  14242. if (
  14243. selectedItem.mphone &&
  14244. selectedItem.mphone != null &&
  14245. selectedItem.mphone != ""
  14246. ) {
  14247. options.model.contactsInformation = selectedItem.mphone;
  14248. } else {
  14249. options.model.contactsInformation =
  14250. selectedItem.telephone;
  14251. }
  14252. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14253. options.model.place.id = selectedItem.placeDTO.id;
  14254. }
  14255. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14256. options.model.area.id = selectedItem.areaDTO.id;
  14257. }
  14258. if (
  14259. selectedItem.requesterTypeDTO &&
  14260. selectedItem.requesterTypeDTO.id == 2
  14261. ) {
  14262. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14263. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14264. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14265. }
  14266. }
  14267. var data = {
  14268. requester: selectedItem,
  14269. };
  14270. options.templateOptions.UserService.addData(
  14271. "requester",
  14272. data
  14273. ).then(function (response) {
  14274. if (response.status == 200) {
  14275. $scope.$parent.$parent.$parent.model["requestershow"] =
  14276. selectedItem;
  14277. options.value(response.data);
  14278. } else {
  14279. }
  14280. });
  14281. }
  14282. },
  14283. function () { }
  14284. );
  14285. event.preventDefault();
  14286. },
  14287. },
  14288. };
  14289. },
  14290. controller: [
  14291. "$scope",
  14292. "api_user_data",
  14293. "api_statistic",
  14294. "$stateParams",
  14295. "api_bpm_data",
  14296. function ($scope, api_user_data, api_statistic, $stateParams,api_bpm_data) {
  14297. console.log($stateParams)
  14298. // 一键复制
  14299. $scope.quickCopy = function(model){
  14300. // 姓名,工号,来电电话,地点,详细地址,故障描述 liaomingming
  14301. console.log(model);
  14302. var text = '';
  14303. if(model.place.id){
  14304. api_bpm_data.fetchData("place", model.place.id)
  14305. .then(function (response) {
  14306. if (response.status == 200) {
  14307. text = `姓名:${model.requester?model.requester.name:''}\r\n工号:${model.requester?model.requester.account:''}\r\n来电电话:${model.contactsInformation||''}\r\n地点:${response.data.place||''}\r\n详细地址:${model.houseNumber||''}\r\n故障描述:${model.description||''}`;
  14308. var textarea = document.createElement('textarea');
  14309. document.body.appendChild(textarea);
  14310. // 隐藏此输入框
  14311. textarea.style.position = 'fixed';
  14312. textarea.style.clip = 'rect(0 0 0 0)';
  14313. textarea.style.top = '10px';
  14314. // 赋值
  14315. textarea.value = text;
  14316. // 选中
  14317. textarea.select();
  14318. // 复制
  14319. document.execCommand('copy', true);
  14320. // 移除输入框
  14321. document.body.removeChild(textarea);
  14322. }
  14323. });
  14324. }else{
  14325. text = `姓名:${model.contacts||''}\r\n工号:${model.account||''}\r\n来电电话:${model.contactsInformation||''}\r\n地点:${''}\r\n详细地址:${model.houseNumber||''}\r\n故障描述:${model.description||''}`;
  14326. var textarea = document.createElement('textarea');
  14327. document.body.appendChild(textarea);
  14328. // 隐藏此输入框
  14329. textarea.style.position = 'fixed';
  14330. textarea.style.clip = 'rect(0 0 0 0)';
  14331. textarea.style.top = '10px';
  14332. // 赋值
  14333. textarea.value = text;
  14334. // 选中
  14335. textarea.select();
  14336. // 复制
  14337. document.execCommand('copy', true);
  14338. // 移除输入框
  14339. document.body.removeChild(textarea);
  14340. }
  14341. event.preventDefault();
  14342. //提示
  14343. alert('复制成功');
  14344. }
  14345. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  14346. var paramsModel = JSON.parse($stateParams.model)
  14347. //来电-添加报修人
  14348. if (paramsModel.model.incident.requester.hjzxPhone) {
  14349. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  14350. }
  14351. }
  14352. $scope.options.initialValue = $scope.model[$scope.options.key];
  14353. $scope.saveReqPlace = false;
  14354. $scope.model.saveReqPlace = false;
  14355. $scope.selectGradeBox = function () {
  14356. $scope.saveReqPlace = !$scope.saveReqPlace;
  14357. console.log($scope);
  14358. $scope.model.saveReqPlace = $scope.saveReqPlace;
  14359. };
  14360. if (
  14361. $scope.model.requester &&
  14362. $scope.model.requester.requesterTypeDTO &&
  14363. $scope.model.requester.requesterTypeDTO.id == 2
  14364. ) {
  14365. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14366. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14367. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14368. }
  14369. },
  14370. ],
  14371. });
  14372. // 请求人选控件
  14373. formlyConfigProvider.setType({
  14374. name: "ui-requesterselect",
  14375. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  14376. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14377. defaultOptions: function (options, $scope) {
  14378. return {
  14379. templateOptions: {
  14380. // checkform: function(options) {
  14381. // if (options.model.requestershow) {
  14382. // options.value(options.model.requestershow);
  14383. // }
  14384. // },
  14385. validators: {
  14386. required: {
  14387. expression: function (viewValue, modelValue) {
  14388. var value = modelValue || viewValue;
  14389. return value.length >= 1;
  14390. },
  14391. },
  14392. },
  14393. openModal: function (size, options, modal) {
  14394. //查找弹出框
  14395. var modelObject = options.value();
  14396. var searchModal = function (filterSearchData) {
  14397. var modalInstance = modal.open({
  14398. templateUrl:
  14399. "assets/views/customform/tpl/checktable-modal-content.html",
  14400. controller: function (
  14401. $scope,
  14402. scope,
  14403. i18nService,
  14404. $modalInstance,
  14405. items,
  14406. title,
  14407. Restangular,
  14408. APIService,
  14409. language,
  14410. searchDatas,
  14411. api_bpm_data
  14412. ) {
  14413. $scope.langs = i18nService.getAllLangs();
  14414. $scope.lang = "zh-cn";
  14415. i18nService.setCurrentLang($scope.lang);
  14416. $scope.gridOptions = {};
  14417. $scope.gridOptions.data = "myData";
  14418. $scope.gridOptions.enableColumnResizing = true;
  14419. $scope.gridOptions.enableFiltering = true;
  14420. $scope.gridOptions.enableGridMenu = false;
  14421. $scope.gridOptions.enableRowSelection = true;
  14422. $scope.gridOptions.showGridFooter = true;
  14423. $scope.gridOptions.showColumnFooter = false;
  14424. $scope.gridOptions.fastWatch = true;
  14425. $scope.gridOptions.useExternalFiltering = true;
  14426. $scope.gridOptions.useExternalPagination = true;
  14427. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14428. $scope.gridOptions.paginationPageSize = 10;
  14429. $scope.gridOptions.multiSelect = false;
  14430. $scope.gridOptions.rowIdentity = function (row) {
  14431. return row.id;
  14432. };
  14433. $scope.gridOptions.getRowIdentity = function (row) {
  14434. return row.id;
  14435. };
  14436. $scope.gridOptions.columnDefs = [
  14437. {
  14438. name: "account",
  14439. displayName: "人员编号",
  14440. width: 140,
  14441. },
  14442. {
  14443. name: "name",
  14444. displayName: "姓名",
  14445. width: 100,
  14446. },
  14447. {
  14448. name: "gender.name",
  14449. displayName: "性别",
  14450. width: 80,
  14451. enableFiltering: false,
  14452. },
  14453. {
  14454. name: "mphone",
  14455. displayName: "电话",
  14456. width: 100,
  14457. enableFiltering: false,
  14458. },
  14459. {
  14460. name: "email",
  14461. displayName: "邮件",
  14462. width: 100,
  14463. },
  14464. {
  14465. name: "areaDTO.area",
  14466. displayName: "区域",
  14467. width: 100,
  14468. enableFiltering: false,
  14469. },
  14470. {
  14471. name: "placeDTO.place",
  14472. displayName: "地点",
  14473. enableFiltering: false,
  14474. },
  14475. ];
  14476. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14477. $scope.gridApi = gridApi;
  14478. // var filtersData = $scope.memoryfilterData;
  14479. // filtersData.idx = newPage - 1;
  14480. // filtersData.sum = pageSize;
  14481. gridApi.pagination.on.paginationChanged(
  14482. $scope,
  14483. function (newPage, pageSize) {
  14484. var filtersData = $scope.memoryfilterData;
  14485. filtersData.idx = newPage - 1;
  14486. filtersData.sum = pageSize;
  14487. $scope.loadData(filtersData);
  14488. }
  14489. );
  14490. gridApi.selection.on.rowSelectionChanged(
  14491. $scope,
  14492. function (data) {
  14493. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  14494. $scope.selected.item = data.entity;
  14495. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  14496. }
  14497. );
  14498. gridApi.core.on.filterChanged($scope, function () {
  14499. var grid = this.grid;
  14500. var filtersData = {
  14501. idx: 0,
  14502. sum: 10,
  14503. // 'requester': { 'userType': 1 }
  14504. };
  14505. angular.forEach(grid.columns, function (item) {
  14506. if (item.enableFiltering) {
  14507. if (
  14508. angular.isDefined(item.filters[0].term) &&
  14509. item.filters[0].term != ""
  14510. ) {
  14511. if (angular.isUndefined(filtersData["requester"])) {
  14512. filtersData["requester"] = {};
  14513. }
  14514. filtersData["requester"][item.field] =
  14515. item.filters[0].term;
  14516. }
  14517. }
  14518. });
  14519. $scope.memoryfilterData = filtersData;
  14520. $scope.loadData(filtersData);
  14521. });
  14522. };
  14523. $scope.memoryfilterData = defaultFilterData = {
  14524. idx: 0,
  14525. sum: 10,
  14526. };
  14527. $scope.loadData = function (filterData) {
  14528. if (!filterData.requester) {
  14529. filterData.requester = {};
  14530. }
  14531. if (scope.roleidcode) {
  14532. angular.extend(filterData["requester"], {
  14533. userType: 1,
  14534. });
  14535. }
  14536. items
  14537. .fetchItems(filterData, APIService)
  14538. .then(function (data) {
  14539. var myData = Restangular.stripRestangular(data);
  14540. $scope.gridOptions.totalItems = myData.totalNum;
  14541. $scope.myData = myData.list;
  14542. });
  14543. };
  14544. // $scope.title = title;
  14545. if (searchDatas) {
  14546. $scope.loadData(searchDatas);
  14547. } else {
  14548. $scope.loadData({
  14549. idx: 0,
  14550. sum: 10,
  14551. });
  14552. }
  14553. $scope.selected = {
  14554. item: {},
  14555. };
  14556. $scope.ok = function () {
  14557. $modalInstance.close($scope.selected.item);
  14558. };
  14559. $scope.cancel = function () {
  14560. $modalInstance.dismiss("cancel");
  14561. };
  14562. },
  14563. size: size,
  14564. resolve: {
  14565. items: function () {
  14566. return {
  14567. fetchItems: function (filterData, APIService) {
  14568. filterData = filterData || {};
  14569. if (
  14570. angular.isUndefined(filterData.idx) ||
  14571. filterData.idx == null
  14572. ) {
  14573. filterData = {
  14574. idx: 0,
  14575. sum: 10,
  14576. };
  14577. }
  14578. return options.templateOptions.fetchItems(
  14579. filterData,
  14580. APIService
  14581. );
  14582. },
  14583. };
  14584. },
  14585. title: function () {
  14586. return options.templateOptions.modalTitle;
  14587. },
  14588. Restangular: function () {
  14589. return options.templateOptions.Restangular;
  14590. },
  14591. APIService: function () {
  14592. return options.templateOptions.ApiService;
  14593. },
  14594. language: function () {
  14595. return options.templateOptions.language;
  14596. },
  14597. searchDatas: function () {
  14598. return filterSearchData;
  14599. },
  14600. scope: function () {
  14601. return $scope;
  14602. },
  14603. },
  14604. });
  14605. modalInstance.result.then(
  14606. function (selectedItem) {
  14607. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14608. selectedItem.telephone =
  14609. $scope.model.incident.contactsInformation;
  14610. }
  14611. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14612. selectedItem;
  14613. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14614. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14615. if ($scope.model) {
  14616. if ($scope.model.incident.place) {
  14617. $scope.model.incident.place.id = "";
  14618. }
  14619. if ($scope.model.area) {
  14620. $scope.model.incident.area.id = "";
  14621. }
  14622. $scope.model.incident.contacts = selectedItem.name;
  14623. if (
  14624. selectedItem.mphone &&
  14625. selectedItem.mphone != null &&
  14626. selectedItem.mphone != ""
  14627. ) {
  14628. $scope.model.incident.contactsInformation =
  14629. selectedItem.mphone;
  14630. } else {
  14631. $scope.model.incident.contactsInformation =
  14632. selectedItem.telephone;
  14633. }
  14634. $scope.model.incident.houseNumber = "";
  14635. if (
  14636. selectedItem.requesterTypeDTO &&
  14637. selectedItem.requesterTypeDTO.id == 2
  14638. ) {
  14639. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14640. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14641. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14642. }
  14643. }
  14644. $scope.options.value(selectedItem);
  14645. $scope.searchData = selectedItem.account;
  14646. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14647. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14648. }
  14649. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14650. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14651. }
  14652. if (selectedItem.houseNumber) {
  14653. $scope.model.incident.houseNumber =
  14654. selectedItem.houseNumber;
  14655. }
  14656. if (
  14657. selectedItem.requesterTypeDTO &&
  14658. selectedItem.requesterTypeDTO.id == 2
  14659. ) {
  14660. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14661. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14662. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14663. }
  14664. if (
  14665. options.templateOptions.callback &&
  14666. angular.isFunction(options.templateOptions.callback)
  14667. ) {
  14668. options.templateOptions.callback(selectedItem, options);
  14669. }
  14670. if (!$scope.roleidcode) {
  14671. $scope.charging(selectedItem, modal);
  14672. }
  14673. $scope.recentlyincident(selectedItem);
  14674. },
  14675. function () {
  14676. //console.log('Modal dismissed at: ' + new Date());
  14677. }
  14678. );
  14679. };
  14680. searchModal();
  14681. // }
  14682. },
  14683. },
  14684. };
  14685. },
  14686. controller: [
  14687. "$rootScope",
  14688. "$scope",
  14689. "ngTableParams",
  14690. "$filter",
  14691. "SweetAlert",
  14692. "moment",
  14693. function (
  14694. $rootScope,
  14695. $scope,
  14696. ngTableParams,
  14697. $filter,
  14698. SweetAlert,
  14699. moment
  14700. ) {
  14701. $scope.isHk = $rootScope.isHk;
  14702. $scope.roleidcode = true;
  14703. // $scope.options.initialValue = undefined;
  14704. if ($rootScope.user && $rootScope.user.role) {
  14705. angular.forEach($rootScope.user.role, function (item) {
  14706. if (item.rolecode == "call center") {
  14707. $scope.roleidcode = false;
  14708. }
  14709. });
  14710. }
  14711. $scope.recently = false;
  14712. $scope.recentlyincident = function (key, model) {
  14713. //关联事件
  14714. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14715. idx: 0,
  14716. sum: 4,
  14717. incident: {
  14718. requester: {
  14719. id: key.id,
  14720. },
  14721. },
  14722. }).then(function (response) {
  14723. if (response.status == 200) {
  14724. $scope.recently = true;
  14725. $scope.recentincident = response.list;
  14726. } else {
  14727. $scope.recently = false;
  14728. }
  14729. });
  14730. $scope.bodyHeight = window.innerHeight - 100;
  14731. $(window).resize(function () {
  14732. $scope.bodyHeight = window.innerHeight - 100;
  14733. });
  14734. // $scope.shows = false;
  14735. $scope.tempData = {};
  14736. $scope.close = function () {
  14737. $scope.changes = !$scope.changes;
  14738. event.preventDefault();
  14739. };
  14740. };
  14741. $scope.charging = function (key, model) {
  14742. //计费弹出框
  14743. //用户信息
  14744. $scope.information = {};
  14745. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14746. userId: key.account,
  14747. }).then(function (response) {
  14748. // if (response.status == 200) {
  14749. if (response && response.data) {
  14750. angular.extend($scope.information, response.data[0]);
  14751. // $scope.information = response.data[0];
  14752. $scope.information.autologicDestroyTime = moment(
  14753. response.data[0].autologicDestroyTime
  14754. ).format("YYYY-MM-DD");
  14755. $scope.information.periodStartTime = moment(
  14756. response.data[0].periodStartTime
  14757. ).format("YYYY-MM-DD");
  14758. $scope.information.nextBillingTime = moment(
  14759. response.data[0].nextBillingTime
  14760. ).format("YYYY-MM-DD");
  14761. } else if (response.err) {
  14762. SweetAlert.swal(
  14763. "系统错误!",
  14764. "用户信息未取到,请刷新重试",
  14765. "error"
  14766. );
  14767. }
  14768. // }
  14769. });
  14770. //上网明细
  14771. $scope.options.templateOptions.ApiSer.fetchDataList(
  14772. "queryOnlineDetail",
  14773. {
  14774. userId: key.account,
  14775. limit: "10",
  14776. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14777. "YYYY-MM-DD HH:mm:ss"
  14778. ),
  14779. toLogoutTime: moment(new Date().getTime()).format(
  14780. "YYYY-MM-DD HH:mm:ss"
  14781. ),
  14782. }
  14783. ).then(function (response) {
  14784. // if (response.status == 200) {
  14785. if (response && response.data) {
  14786. angular.forEach(response.data, function (item, index) {
  14787. if (item.logoutTime) {
  14788. response.data[index].logoutTime = moment(
  14789. item.logoutTime
  14790. ).format("YYYY-MM-DD HH:mm:ss");
  14791. }
  14792. if (item.loginTime) {
  14793. response.data[index].loginTime = moment(
  14794. item.loginTime
  14795. ).format("YYYY-MM-DD HH:mm:ss");
  14796. }
  14797. });
  14798. $scope.logininform = response.data;
  14799. } else if (response.err) {
  14800. SweetAlert.swal(
  14801. "系统错误!",
  14802. "上网明细未取到,请刷新重试",
  14803. "error"
  14804. );
  14805. }
  14806. });
  14807. //黑名单
  14808. // $scope.information.blacklist = "否"
  14809. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14810. userId: key.account,
  14811. }).then(function (response) {
  14812. // if (response.status == 200) {
  14813. // $scope.logininformation = response.data;
  14814. if (response) {
  14815. if (response.data || response.data != null) {
  14816. $scope.information.blacklist = "是";
  14817. } else {
  14818. if (response.err) {
  14819. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14820. } else {
  14821. $scope.information.blacklist = "否";
  14822. }
  14823. }
  14824. }
  14825. // }
  14826. });
  14827. $scope.bodyHeight = window.innerHeight - 100;
  14828. $(window).resize(function () {
  14829. $scope.bodyHeight = window.innerHeight - 100;
  14830. });
  14831. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14832. // $scope.closepages = function(e) {
  14833. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14834. // event.preventDefault();
  14835. // };
  14836. // $scope.shows = false;
  14837. $scope.tempData = {};
  14838. $scope.close = function () {
  14839. $scope.changes = !$scope.changes;
  14840. event.preventDefault();
  14841. };
  14842. };
  14843. $scope.options.templateOptions.ApiService.fetchDataList(
  14844. "requesterType",
  14845. {
  14846. idx: 0,
  14847. sum: 100,
  14848. }
  14849. ).then(function (response) {
  14850. if (response.status == 200) {
  14851. $scope.networktypes = response.list;
  14852. } else {
  14853. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14854. }
  14855. });
  14856. function serchdata(searchKey) {
  14857. if (searchKey) {
  14858. var filterData = {
  14859. requester: {
  14860. searchKey: searchKey,
  14861. // 'userType': 1
  14862. },
  14863. idx: 0,
  14864. sum: 10,
  14865. };
  14866. } else {
  14867. var filterData = {
  14868. idx: 0,
  14869. requester: {},
  14870. sum: 10,
  14871. };
  14872. }
  14873. if (
  14874. $scope.model.requester &&
  14875. $scope.model.requester.requesterTypeDTO
  14876. ) {
  14877. angular.extend(filterData.requester, {
  14878. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14879. });
  14880. if (!$scope.options.model.contactsInformation) {
  14881. $scope.options.model.contactsInformation =
  14882. $scope.model.requester.mphone;
  14883. }
  14884. }
  14885. if ($scope.roleidcode) {
  14886. angular.extend(filterData["requester"], {
  14887. userType: 1,
  14888. });
  14889. }
  14890. $scope.options.templateOptions.ApiService.fetchDataList(
  14891. "requester",
  14892. filterData
  14893. ).then(function (response) {
  14894. var myData = response;
  14895. $scope.myData = myData.list;
  14896. });
  14897. }
  14898. $scope.searchData = {};
  14899. $scope.refreshUser = function (searchKey) {
  14900. //请求人搜索
  14901. if (searchKey && searchKey != "") {
  14902. serchdata(searchKey);
  14903. }
  14904. };
  14905. if (
  14906. $scope.$parent.$parent.$parent.model.incident.callID ||
  14907. $scope.$parent.$parent.$parent.model.requestershow
  14908. ) {
  14909. if (!$scope.roleidcode) {
  14910. $scope.charging(
  14911. $scope.$parent.$parent.$parent.model.incident.requester
  14912. );
  14913. }
  14914. $scope.recentlyincident(
  14915. $scope.$parent.$parent.$parent.model.incident.requester
  14916. );
  14917. }
  14918. $scope.onChange = function (searchData) {
  14919. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14920. searchData.telephone = $scope.model.incident.contactsInformation;
  14921. }
  14922. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14923. searchData;
  14924. if (!$scope.roleidcode) {
  14925. $scope.charging(searchData);
  14926. }
  14927. $scope.recentlyincident(searchData);
  14928. $scope.accountshow = false;
  14929. if ($scope.model.incident) {
  14930. if ($scope.model.incident.place) {
  14931. $scope.model.incident.place.id = "";
  14932. }
  14933. if ($scope.model.incident.area) {
  14934. $scope.model.incident.area.id = "";
  14935. }
  14936. $scope.model.incident.contacts = searchData.name;
  14937. if (
  14938. searchData.mphone &&
  14939. searchData.mphone != null &&
  14940. searchData.mphone != ""
  14941. ) {
  14942. $scope.model.incident.contactsInformation = searchData.mphone;
  14943. } else {
  14944. $scope.model.incident.contactsInformation = searchData.telephone;
  14945. }
  14946. $scope.model.incident.houseNumber = "";
  14947. if (
  14948. searchData.requesterTypeDTO &&
  14949. searchData.requesterTypeDTO.id == 2
  14950. ) {
  14951. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14952. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14953. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14954. }
  14955. }
  14956. $scope.options.value(searchData);
  14957. $scope.searchKey = searchData.account;
  14958. if (searchData.placeDTO && searchData.placeDTO.id) {
  14959. $scope.model.incident.place.id = searchData.placeDTO.id;
  14960. }
  14961. if (searchData.areaDTO && searchData.areaDTO.id) {
  14962. $scope.model.incident.area.id = searchData.areaDTO.id;
  14963. }
  14964. if (searchData.houseNumber) {
  14965. $scope.model.incident.houseNumber = searchData.houseNumber;
  14966. }
  14967. if (
  14968. searchData.requesterTypeDTO &&
  14969. searchData.requesterTypeDTO.id == 2
  14970. ) {
  14971. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14972. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14973. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14974. }
  14975. };
  14976. },
  14977. ],
  14978. });
  14979. //ui-grid-table展示控件
  14980. formlyConfigProvider.setType({
  14981. name: "ui-grid-table",
  14982. // extends: 'multiCheckbox',//去掉冒号
  14983. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  14984. defaultOptions: function (options) {
  14985. return {
  14986. templateOptions: {
  14987. linkage: function () { },
  14988. },
  14989. };
  14990. },
  14991. controller: function (
  14992. $scope,
  14993. $rootScope,
  14994. i18nService,
  14995. Restangular,
  14996. api_bpm_data,
  14997. api_statistic,
  14998. $rootScope
  14999. ) {
  15000. var loginUser = $rootScope.user;
  15001. $scope.langs = i18nService.getAllLangs();
  15002. $scope.lang = "zh-cn";
  15003. i18nService.setCurrentLang($scope.lang);
  15004. $scope.gridOptions = {};
  15005. $scope.gridOptions.data = "myData";
  15006. $scope.gridOptions.enableColumnResizing = true;
  15007. $scope.gridOptions.enableGridMenu = false;
  15008. $scope.gridOptions.enableRowSelection = true;
  15009. $scope.gridOptions.showGridFooter = false;
  15010. $scope.gridOptions.showColumnFooter = false;
  15011. $scope.gridOptions.fastWatch = true;
  15012. $scope.gridOptions.useExternalFiltering = true;
  15013. $scope.gridOptions.useExternalPagination = false;
  15014. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15015. $scope.gridOptions.paginationPageSize = 3;
  15016. $scope.gridOptions.multiSelect = false;
  15017. $scope.gridOptions.rowIdentity = function (row) {
  15018. return row.id;
  15019. };
  15020. $scope.gridOptions.getRowIdentity = function (row) {
  15021. return row.id;
  15022. };
  15023. $scope.gridOptions.columnDefs = [
  15024. {
  15025. name: "item",
  15026. displayName: "序号",
  15027. width: 80,
  15028. enableFiltering: false,
  15029. },
  15030. {
  15031. name: "incidentsign",
  15032. displayName: "单号",
  15033. width: 80,
  15034. enableFiltering: false,
  15035. },
  15036. {
  15037. name: "description",
  15038. displayName: "主题",
  15039. width: 80,
  15040. enableFiltering: false,
  15041. },
  15042. {
  15043. name: "state.name",
  15044. displayName: "状态",
  15045. width: 110,
  15046. enableFiltering: false,
  15047. },
  15048. {
  15049. name: "acceptDate",
  15050. displayName: "创建时间",
  15051. width: 160,
  15052. enableFiltering: false,
  15053. },
  15054. {
  15055. name: "requester.name",
  15056. displayName: "请求人",
  15057. width: 80,
  15058. enableFiltering: false,
  15059. },
  15060. {
  15061. name: "handlingPersonnelUser.name",
  15062. displayName: "处理人",
  15063. width: 160,
  15064. enableFiltering: false,
  15065. },
  15066. {
  15067. name: "place.place",
  15068. displayName: "区域地点",
  15069. width: 160,
  15070. enableFiltering: false,
  15071. },
  15072. ];
  15073. // var defaultFilterData = {
  15074. // "idx": 0,
  15075. // "sum": 3
  15076. // };
  15077. // // //分页控制
  15078. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15079. gridApi.pagination.on.paginationChanged(
  15080. $scope,
  15081. function (newPage, pageSize) {
  15082. var filtersData = $scope.memoryfilterData;
  15083. filtersData.idx = newPage - 1;
  15084. filtersData.sum = pageSize;
  15085. $scope.refreshData("expand-right", filtersData);
  15086. }
  15087. );
  15088. // 表格单选事件
  15089. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  15090. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  15091. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  15092. data.entity;
  15093. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  15094. data.entity.id;
  15095. var str =
  15096. data.grid.appScope.$parent.$parent.$parent.model.incident
  15097. .description || "";
  15098. str = str.split("").reverse().join("");
  15099. var del = addstr.split("").reverse().join("");
  15100. // console.log(del);
  15101. var reg = new RegExp(del);
  15102. str = str.replace(reg, "");
  15103. str = str.split("").reverse().join("");
  15104. if (
  15105. data.grid.appScope.$parent.$parent.$parent.model.incident
  15106. .associationType == "事件补充"
  15107. ) {
  15108. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  15109. null;
  15110. str += data.entity.description;
  15111. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15112. data.entity.description;
  15113. } else if (
  15114. data.grid.appScope.$parent.$parent.$parent.model.incident
  15115. .associationType == "事件已解决"
  15116. ) {
  15117. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  15118. "close";
  15119. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15120. "";
  15121. }
  15122. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  15123. str;
  15124. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  15125. data.entity.id;
  15126. });
  15127. };
  15128. // 刷新表格
  15129. setInterval(function () {
  15130. // console.log($scope.myData);
  15131. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  15132. // console.log($scope.myData);
  15133. if ($scope.myData != null) {
  15134. for (var i = 0; i < $scope.myData.length; i++) {
  15135. //添加序号
  15136. $scope.myData[i]["item"] = i + 1;
  15137. }
  15138. }
  15139. }, 1000);
  15140. },
  15141. });
  15142. //处理人信息
  15143. formlyConfigProvider.setType({
  15144. name: "ui-userinformation",
  15145. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  15146. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15147. defaultOptions: function (options) {
  15148. return {
  15149. templateOptions: {},
  15150. };
  15151. },
  15152. controller: [
  15153. "$scope",
  15154. function ($scope) {
  15155. $scope.group = "";
  15156. $scope.role = "";
  15157. if (
  15158. angular.isDefined($scope.model.handlingPersonnelUser) &&
  15159. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15160. $scope.model.handlingPersonnelUser.group.length == 1
  15161. ) {
  15162. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15163. } else {
  15164. for (
  15165. var i = 0;
  15166. i < $scope.model.handlingPersonnelUser.group.length;
  15167. i++
  15168. ) {
  15169. $scope.group +=
  15170. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15171. }
  15172. }
  15173. if (
  15174. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  15175. $scope.model.handlingPersonnelUser.role.length == 1
  15176. ) {
  15177. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  15178. } else {
  15179. for (
  15180. var i = 0;
  15181. i < $scope.model.handlingPersonnelUser.role.length;
  15182. i++
  15183. ) {
  15184. $scope.role +=
  15185. $scope.model.handlingPersonnelUser.role[i].role + ",";
  15186. }
  15187. }
  15188. $scope.options.templateOptions.that = $scope;
  15189. },
  15190. ],
  15191. });
  15192. //处理界面处理人信息
  15193. formlyConfigProvider.setType({
  15194. name: "ui-handler",
  15195. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  15196. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15197. defaultOptions: function (options) {
  15198. return {
  15199. templateOptions: {},
  15200. };
  15201. },
  15202. controller: [
  15203. "$scope",
  15204. function ($scope) {
  15205. $scope.group = "";
  15206. // $scope.role="";
  15207. if (
  15208. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15209. $scope.model.handlingPersonnelUser.group.length == 1
  15210. ) {
  15211. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15212. } else {
  15213. for (
  15214. var i = 0;
  15215. i < $scope.model.handlingPersonnelUser.group.length;
  15216. i++
  15217. ) {
  15218. $scope.group +=
  15219. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15220. }
  15221. }
  15222. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  15223. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  15224. // }else{
  15225. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  15226. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  15227. // }
  15228. // }
  15229. $scope.options.templateOptions.that = $scope;
  15230. },
  15231. ],
  15232. });
  15233. //微信事件流程
  15234. formlyConfigProvider.setType({
  15235. name: "ui-wxIncidentProcess",
  15236. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  15237. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15238. defaultOptions: function (options) {
  15239. return {
  15240. templateOptions: {},
  15241. };
  15242. },
  15243. controller: [
  15244. "$scope",
  15245. function ($scope) {
  15246. console.log($scope.model);
  15247. $scope.pingjia = false;
  15248. $scope.jiejue = false;
  15249. if ($scope.model.incidentState.value == "3") {
  15250. $scope.pingjia = true;
  15251. } else if ($scope.model.incidentState.value == "4") {
  15252. $scope.jiejue = true;
  15253. }
  15254. },
  15255. ],
  15256. });
  15257. //打电话
  15258. formlyConfigProvider.setType({
  15259. name: "ui-inputcall",
  15260. extends: "input",
  15261. templateUrl: "assets/views/customform/tpl/inputcall.html",
  15262. defaultOptions: function (options) {
  15263. return {
  15264. templateOptions: {
  15265. transform: function (value) { },
  15266. },
  15267. };
  15268. },
  15269. controller: [
  15270. "$scope",
  15271. "$rootScope",
  15272. "api_text",
  15273. "SweetAlert",
  15274. function ($scope, $rootScope, api_text, SweetAlert) {
  15275. $scope.dialout = function (teleno) {
  15276. // var gid = "@0";
  15277. // var telephone = "9" + teleno;
  15278. $rootScope.callout = 2;
  15279. // var agcount = tlwsa.tlaGetagentcount();
  15280. // var agcountFlag = false;
  15281. // console.log(teleno)
  15282. // // 查询当前话机是否签入
  15283. // for (var i = 0; i < agcount; i++) {
  15284. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  15285. // agcountFlag = true;
  15286. // }
  15287. // }
  15288. if (localStorage.getItem('fenjiNumber')) {
  15289. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  15290. // console.log(sessionStorage.getItem('phones'))
  15291. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  15292. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  15293. // console.log(isHuajihao)
  15294. // if(isHuajihao){
  15295. // tlwsa.tlaCallagc(teleno);
  15296. // }else{
  15297. // tlwsa.tlaCallout(teleno, caller, 0);
  15298. // }
  15299. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  15300. $rootScope.toggle('off-sidebar');
  15301. // tlwsa.tlaCallout(teleno, caller, 0);
  15302. }else if(localStorage.getItem('hk_phone')){
  15303. var gid = "@0"
  15304. var telephone = '9' + teleno
  15305. $rootScope.callout = 2;
  15306. if ($rootScope.takes) {
  15307. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  15308. if (data.errno == 0) {
  15309. $rootScope.status = 6;
  15310. }
  15311. })
  15312. } else {
  15313. SweetAlert.swal({
  15314. title: "呼叫失败",
  15315. text: "请先签入呼叫中心!",
  15316. type: "error",
  15317. confirmButtonColor: "#DD6B55"
  15318. });
  15319. }
  15320. } else {
  15321. SweetAlert.swal({
  15322. title: "呼叫失败",
  15323. text: "请先签入呼叫中心!",
  15324. type: "error",
  15325. confirmButtonColor: "#DD6B55",
  15326. });
  15327. }
  15328. };
  15329. $scope.options.templateOptions.that = $scope;
  15330. },
  15331. ],
  15332. });
  15333. //关闭界面处理人信息
  15334. formlyConfigProvider.setType({
  15335. name: "ui-closehandler",
  15336. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  15337. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15338. defaultOptions: function (options) {
  15339. return {
  15340. templateOptions: {},
  15341. };
  15342. },
  15343. controller: [
  15344. "$scope",
  15345. "$rootScope",
  15346. "api_text",
  15347. function ($scope, $rootScope, api_text) {
  15348. $scope.dialout = function (teleno) {
  15349. var gid = "@0";
  15350. var telephone = "9" + teleno;
  15351. api_text
  15352. .dialout($rootScope.takes, gid, telephone)
  15353. .then(function (data) {
  15354. if (data.errno == 0) {
  15355. $rootScope.status = 6;
  15356. }
  15357. });
  15358. };
  15359. $scope.options.templateOptions.that = $scope;
  15360. },
  15361. ],
  15362. });
  15363. //用户单选控件
  15364. formlyConfigProvider.setType({
  15365. name: "ui-userselect",
  15366. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  15367. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15368. defaultOptions: function (options) {
  15369. return {
  15370. templateOptions: {
  15371. openModal: function (size, options, modal) {
  15372. var modalInstance = modal.open({
  15373. templateUrl:
  15374. "assets/views/customform/tpl/checktable-modal-content.html",
  15375. controller: function (
  15376. $scope,
  15377. $rootScope,
  15378. i18nService,
  15379. $modalInstance,
  15380. items,
  15381. title,
  15382. Restangular,
  15383. APIService,
  15384. onDataCallback,
  15385. parentScope,
  15386. api_category,
  15387. api_user_data
  15388. ) {
  15389. $scope.isAssign = options.templateOptions.departmentDispatchesOrders;
  15390. $scope.langs = i18nService.getAllLangs();
  15391. $scope.lang = "zh-cn";
  15392. i18nService.setCurrentLang($scope.lang);
  15393. $scope.gridOptions = {};
  15394. $scope.gridOptions.data = "myData";
  15395. $scope.gridOptions.enableColumnResizing = true;
  15396. $scope.gridOptions.enableFiltering = true;
  15397. $scope.gridOptions.enableGridMenu = false;
  15398. $scope.gridOptions.showGridFooter = true;
  15399. $scope.gridOptions.showColumnFooter = false;
  15400. $scope.gridOptions.fastWatch = true;
  15401. $scope.gridOptions.useExternalFiltering = true;
  15402. $scope.gridOptions.useExternalPagination = true;
  15403. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15404. $scope.gridOptions.paginationPageSize = 10;
  15405. $scope.gridOptions.multiSelect = false;
  15406. $scope.searchModel = {
  15407. type:1,//默认科室内转派
  15408. }
  15409. $scope.hospitalList = [];
  15410. $scope.dutyDeptList = [];
  15411. // 修改转派模式
  15412. $scope.changeType = function(type){
  15413. console.log($scope.searchModel.type)
  15414. $scope.gridOptions.totalItems = 0;
  15415. $scope.myData = [];
  15416. $scope.searchModel.department = undefined;
  15417. $scope.searchModel.branch = undefined;
  15418. $scope.dutyDeptList = [];
  15419. if($scope.searchModel.type == 2){
  15420. //跨科室转派
  15421. api_user_data.fetchDataList('branch', {
  15422. "idx": 0,
  15423. "sum": 100
  15424. }).then(function (data) {
  15425. if(data.status == 200){
  15426. $scope.hospitalList = data.list;
  15427. if($rootScope.user.duty){
  15428. // 当前的所属责任科室
  15429. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  15430. // $scope.changeBranch();
  15431. }else if($rootScope.user.branch){
  15432. // 当前的所属院区
  15433. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  15434. // $scope.changeBranch();
  15435. }
  15436. }else{
  15437. SweetAlert.swal({
  15438. title: "系统错误!",
  15439. text: "请刷新重试!",
  15440. type: "error"
  15441. });
  15442. }
  15443. })
  15444. }else if($scope.searchModel.type == 1){
  15445. //科室内转派
  15446. var postData = {
  15447. idx: 0,
  15448. sum: 10,
  15449. user: {
  15450. roledata: {
  15451. rolecode: "first-line support",
  15452. },
  15453. selectType: "1",
  15454. },
  15455. }
  15456. // 判断当前是责任科室还是院区
  15457. if ($rootScope.user.duty) {
  15458. // 当前的所属责任科室
  15459. postData.user.currentDuty = $rootScope.user.duty.id;
  15460. } else if ($rootScope.user.branch) {
  15461. // 当前的所属院区
  15462. $scope.myData = [];
  15463. return;
  15464. }
  15465. $scope.loadData(postData);
  15466. }
  15467. }
  15468. // 修改院区
  15469. $scope.changeBranch = function(keyword=''){
  15470. if(!$scope.searchModel.branch){
  15471. return;
  15472. }
  15473. $scope.searchModel.department = undefined;
  15474. $scope.dutyDeptList = [];
  15475. api_user_data.fetchDataList('dutyDepartment', {
  15476. "idx": 0,
  15477. "sum": 100,
  15478. "dutyDepartment":{
  15479. branch:$scope.searchModel.branch.id,
  15480. dept:keyword,
  15481. selectType: "pinyin_qs"
  15482. }
  15483. }).then(function (data) {
  15484. if(data.status == 200){
  15485. $scope.dutyDeptList = data.list;
  15486. }else{
  15487. SweetAlert.swal({
  15488. title: "系统错误!",
  15489. text: "请刷新重试!",
  15490. type: "error"
  15491. });
  15492. }
  15493. })
  15494. }
  15495. // 修改责任科室
  15496. $scope.changeDutyDept = function(){
  15497. $scope.loadData({
  15498. idx: 0,
  15499. sum: 10,
  15500. user: {
  15501. duty:$scope.searchModel.department,
  15502. roledata: {
  15503. rolecode: "first-line support",
  15504. },
  15505. selectType: "1",
  15506. },
  15507. });
  15508. }
  15509. $scope.gridOptions.rowIdentity = function (row) {
  15510. return row.id;
  15511. };
  15512. $scope.gridOptions.getRowIdentity = function (row) {
  15513. return row.id;
  15514. };
  15515. $scope.gridOptions.rowTemplate =
  15516. '<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>';
  15517. $scope.gridOptions.columnDefs = [
  15518. {
  15519. name: "account",
  15520. displayName: "人员编号",
  15521. width: 120,
  15522. },
  15523. {
  15524. name: "name",
  15525. displayName: "姓名",
  15526. width: 100,
  15527. cellTemplate:
  15528. "<div>" +
  15529. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15530. "</div>",
  15531. },
  15532. // {
  15533. // name: 'gender.name',
  15534. // displayName: '性别',
  15535. // width: 80,
  15536. // enableFiltering: false
  15537. // },
  15538. {
  15539. name: "phone",
  15540. displayName: "电话",
  15541. width: 230,
  15542. enableFiltering: false,
  15543. },
  15544. {
  15545. name: "email",
  15546. displayName: "邮箱",
  15547. width: 180,
  15548. enableFiltering: false,
  15549. },
  15550. {
  15551. name: "dept.dept",
  15552. displayName: "科室",
  15553. width: 130,
  15554. enableFiltering: false,
  15555. },
  15556. {
  15557. name: "taskCount",
  15558. displayName: "处理中事件数",
  15559. enableFiltering: false,
  15560. },
  15561. ];
  15562. // $scope.selectButtonClick
  15563. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15564. $scope.gridApi = gridApi;
  15565. gridApi.pagination.on.paginationChanged(
  15566. $scope,
  15567. function (newPage, pageSize) {
  15568. var postData = {
  15569. idx: newPage - 1,
  15570. sum: pageSize,
  15571. user: {
  15572. roledata: {
  15573. rolecode: "first-line support",
  15574. },
  15575. selectType: "1",
  15576. },
  15577. }
  15578. if($scope.isAssign){
  15579. if($scope.searchModel.type == 1){
  15580. // 判断当前是责任科室还是院区
  15581. if ($rootScope.user.duty) {
  15582. // 当前的所属责任科室
  15583. postData.user.currentDuty = $rootScope.user.duty.id;
  15584. } else if ($rootScope.user.branch) {
  15585. // 当前的所属院区
  15586. $scope.myData = [];
  15587. return;
  15588. }
  15589. }else if($scope.searchModel.type == 2){
  15590. // 跨科室转派
  15591. postData.user.duty = $scope.searchModel.department;
  15592. }
  15593. }
  15594. $scope.loadData(postData);
  15595. }
  15596. );
  15597. gridApi.selection.on.rowSelectionChanged(
  15598. $scope,
  15599. function (data) {
  15600. $scope.selected.items = data.entity;
  15601. //console.log(data);
  15602. }
  15603. );
  15604. gridApi.selection.on.rowSelectionChangedBatch(
  15605. $scope,
  15606. function (data) {
  15607. $scope.selected.items = data.entity;
  15608. //console.log(data);
  15609. }
  15610. );
  15611. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15612. // // if (row.entity.age > 45) {
  15613. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15614. // // }
  15615. // };
  15616. gridApi.core.on.filterChanged($scope, function () {
  15617. var grid = this.grid;
  15618. var filtersData = {
  15619. idx: 0,
  15620. sum: 10,
  15621. user: {
  15622. roledata: {
  15623. rolecode: "roleset",
  15624. },
  15625. selectType: "1",
  15626. },
  15627. };
  15628. angular.forEach(grid.columns, function (item) {
  15629. if (item.enableFiltering) {
  15630. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15631. if (
  15632. angular.isDefined(item.filters[0].term) &&
  15633. item.filters[0].term != ""
  15634. ) {
  15635. if (angular.isUndefined(filtersData["user"])) {
  15636. filtersData["user"] = {};
  15637. }
  15638. filtersData["user"][item.field] =
  15639. item.filters[0].term;
  15640. }
  15641. }
  15642. });
  15643. if($scope.isAssign){
  15644. if($scope.searchModel.type == 1){
  15645. // 判断当前是责任科室还是院区
  15646. if ($rootScope.user.duty) {
  15647. // 当前的所属责任科室
  15648. filtersData.user.currentDuty = $rootScope.user.duty.id;
  15649. } else if ($rootScope.user.branch) {
  15650. // 当前的所属院区
  15651. $scope.myData = [];
  15652. return;
  15653. }
  15654. }else if($scope.searchModel.type == 2){
  15655. // 跨科室转派
  15656. filtersData.user.duty = $scope.searchModel.department;
  15657. }
  15658. }
  15659. // $scope.memoryfilterData = filtersData;
  15660. $scope.loadData(filtersData);
  15661. });
  15662. };
  15663. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15664. // if (row.entity.age > 45) {
  15665. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15666. // }
  15667. // },
  15668. $scope.onDblClick = function (data, event) {
  15669. // $scope.selected.items = data.entity;
  15670. $scope.selectButtonClick(data, event);
  15671. };
  15672. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15673. // $scope.selected.items = data.entity;
  15674. // })
  15675. // };
  15676. $scope.memoryfilterData = {
  15677. idx: 0,
  15678. sum: 10,
  15679. user: {
  15680. roledata: {
  15681. rolecode: "roleset",
  15682. },
  15683. selectType: "1",
  15684. },
  15685. };
  15686. $scope.loadData = function (filterData) {
  15687. // console.log("filtersData=111" + JSON.stringify(filterData))
  15688. items
  15689. .fetchItems(filterData, APIService)
  15690. .then(function (data) {
  15691. var myData = Restangular.stripRestangular(data);
  15692. $scope.gridOptions.totalItems = myData.totalNum;
  15693. $scope.myData = myData.list;
  15694. });
  15695. };
  15696. $scope.title = title;
  15697. $scope.selected = {
  15698. items: {},
  15699. };
  15700. $scope.ok = function () {
  15701. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15702. // onDataCallback($scope.selected.item, parentScope);
  15703. // }
  15704. $modalInstance.close($scope.selected.items);
  15705. };
  15706. $scope.cancel = function () {
  15707. $modalInstance.dismiss("cancel");
  15708. };
  15709. // 初始化
  15710. var postData = {
  15711. idx: 0,
  15712. sum: 10,
  15713. user: {
  15714. roledata: {
  15715. rolecode: "first-line support",
  15716. },
  15717. selectType: "1",
  15718. },
  15719. }
  15720. if($scope.isAssign){
  15721. if($scope.searchModel.type == 1){
  15722. // 判断当前是责任科室还是院区
  15723. if ($rootScope.user.duty) {
  15724. // 当前的所属责任科室
  15725. postData.user.currentDuty = $rootScope.user.duty.id;
  15726. } else if ($rootScope.user.branch) {
  15727. // 当前的所属院区
  15728. $scope.myData = [];
  15729. return;
  15730. }
  15731. }else if($scope.searchModel.type == 2){
  15732. // 跨科室转派
  15733. postData.user.duty = $scope.searchModel.department;
  15734. }
  15735. }
  15736. $scope.loadData(postData);
  15737. },
  15738. size: size,
  15739. resolve: {
  15740. items: function () {
  15741. return {
  15742. fetchItems: function (filterData, APIService) {
  15743. filterData = filterData || {};
  15744. if (
  15745. angular.isDefined(filterData.idx) &&
  15746. filterData.idx == null
  15747. ) {
  15748. filterData = {
  15749. idx: 0,
  15750. sum: 10,
  15751. user: {
  15752. roledata: {
  15753. rolecode: "roleset",
  15754. },
  15755. selectType: "1",
  15756. },
  15757. };
  15758. }
  15759. return options.templateOptions.fetchItems(
  15760. filterData,
  15761. APIService
  15762. );
  15763. },
  15764. };
  15765. },
  15766. title: function () {
  15767. return options.templateOptions.label;
  15768. },
  15769. Restangular: function () {
  15770. return options.templateOptions.Restangular;
  15771. },
  15772. APIService: function () {
  15773. return options.templateOptions.ApiService;
  15774. },
  15775. onDataCallback: function () {
  15776. return options.templateOptions.callback;
  15777. },
  15778. parentScope: function () {
  15779. return options.templateOptions.that;
  15780. },
  15781. },
  15782. });
  15783. modalInstance.result.then(
  15784. function (selectedItem) {
  15785. // console.log(selectedItem);
  15786. options.value(selectedItem);
  15787. if (
  15788. options.templateOptions.callback &&
  15789. angular.isFunction(options.templateOptions.callback)
  15790. ) {
  15791. options.templateOptions.callback(
  15792. selectedItem,
  15793. options.templateOptions.that
  15794. );
  15795. }
  15796. if (
  15797. options.templateOptions.linkData &&
  15798. angular.isFunction(options.templateOptions.linkData)
  15799. ) {
  15800. options.templateOptions.linkData(
  15801. selectedItem,
  15802. options.templateOptions.that
  15803. );
  15804. }
  15805. },
  15806. function () {
  15807. //console.log('Modal dismissed at: ' + new Date());
  15808. }
  15809. );
  15810. },
  15811. },
  15812. };
  15813. },
  15814. controller: [
  15815. "$scope",
  15816. function ($scope) {
  15817. $scope.options.templateOptions.that = $scope;
  15818. // $scope.options.model[$scope.options.key] = {}
  15819. },
  15820. ],
  15821. });
  15822. //用户单选控件(dd 单选input带搜索)liaomingming
  15823. formlyConfigProvider.setType({
  15824. name: "ui-userselectSearch",
  15825. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15826. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15827. defaultOptions: function (options) {
  15828. return {
  15829. templateOptions: {
  15830. openModal: function (size, options, modal) {
  15831. var modalInstance = modal.open({
  15832. templateUrl:
  15833. "assets/views/customform/tpl/checktable-modal-content.html",
  15834. controller: function (
  15835. $scope,
  15836. $rootScope,
  15837. i18nService,
  15838. $modalInstance,
  15839. items,
  15840. title,
  15841. Restangular,
  15842. APIService,
  15843. onDataCallback,
  15844. parentScope,
  15845. api_category,
  15846. api_user_data
  15847. ) {
  15848. $scope.isAssign = options.templateOptions.departmentDispatchesOrders;
  15849. $scope.langs = i18nService.getAllLangs();
  15850. $scope.lang = "zh-cn";
  15851. i18nService.setCurrentLang($scope.lang);
  15852. $scope.gridOptions = {};
  15853. $scope.gridOptions.data = "myData";
  15854. $scope.gridOptions.enableColumnResizing = true;
  15855. $scope.gridOptions.enableFiltering = true;
  15856. $scope.gridOptions.enableGridMenu = false;
  15857. $scope.gridOptions.showGridFooter = true;
  15858. $scope.gridOptions.showColumnFooter = false;
  15859. $scope.gridOptions.fastWatch = true;
  15860. $scope.gridOptions.useExternalFiltering = true;
  15861. $scope.gridOptions.useExternalPagination = true;
  15862. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15863. $scope.gridOptions.paginationPageSize = 10;
  15864. $scope.gridOptions.multiSelect = false;
  15865. $scope.searchModel = {
  15866. type:1,//默认科室内转派
  15867. }
  15868. $scope.hospitalList = [];
  15869. $scope.dutyDeptList = [];
  15870. // 修改转派模式
  15871. $scope.changeType = function(type){
  15872. console.log($scope.searchModel.type)
  15873. $scope.gridOptions.totalItems = 0;
  15874. $scope.myData = [];
  15875. $scope.searchModel.department = undefined;
  15876. $scope.searchModel.branch = undefined;
  15877. $scope.dutyDeptList = [];
  15878. if($scope.searchModel.type == 2){
  15879. //跨科室转派
  15880. api_user_data.fetchDataList('branch', {
  15881. "idx": 0,
  15882. "sum": 100
  15883. }).then(function (data) {
  15884. if(data.status == 200){
  15885. $scope.hospitalList = data.list;
  15886. if($rootScope.user.duty){
  15887. // 当前的所属责任科室
  15888. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  15889. // $scope.changeBranch();
  15890. }else if($rootScope.user.branch){
  15891. // 当前的所属院区
  15892. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  15893. // $scope.changeBranch();
  15894. }
  15895. }else{
  15896. SweetAlert.swal({
  15897. title: "系统错误!",
  15898. text: "请刷新重试!",
  15899. type: "error"
  15900. });
  15901. }
  15902. })
  15903. }else if($scope.searchModel.type == 1){
  15904. //科室内转派
  15905. var postData = {
  15906. idx: 0,
  15907. sum: 10,
  15908. user: {
  15909. roledata: {
  15910. rolecode: "first-line support",
  15911. },
  15912. selectType: "1",
  15913. },
  15914. }
  15915. // 判断当前是责任科室还是院区
  15916. if ($rootScope.user.duty) {
  15917. // 当前的所属责任科室
  15918. postData.user.currentDuty = $rootScope.user.duty.id;
  15919. } else if ($rootScope.user.branch) {
  15920. // 当前的所属院区
  15921. $scope.myData = [];
  15922. return;
  15923. }
  15924. $scope.loadData(postData);
  15925. }
  15926. }
  15927. // 修改院区
  15928. $scope.changeBranch = function(keyword=''){
  15929. if(!$scope.searchModel.branch){
  15930. return;
  15931. }
  15932. $scope.searchModel.department = undefined;
  15933. $scope.dutyDeptList = [];
  15934. api_user_data.fetchDataList('dutyDepartment', {
  15935. "idx": 0,
  15936. "sum": 100,
  15937. "dutyDepartment":{
  15938. branch:$scope.searchModel.branch.id,
  15939. dept:keyword,
  15940. selectType: "pinyin_qs"
  15941. }
  15942. }).then(function (data) {
  15943. if(data.status == 200){
  15944. $scope.dutyDeptList = data.list;
  15945. }else{
  15946. SweetAlert.swal({
  15947. title: "系统错误!",
  15948. text: "请刷新重试!",
  15949. type: "error"
  15950. });
  15951. }
  15952. })
  15953. }
  15954. // 修改责任科室
  15955. $scope.changeDutyDept = function(){
  15956. $scope.loadData({
  15957. idx: 0,
  15958. sum: 10,
  15959. user: {
  15960. duty:$scope.searchModel.department,
  15961. roledata: {
  15962. rolecode: "first-line support",
  15963. },
  15964. selectType: "1",
  15965. },
  15966. });
  15967. }
  15968. $scope.gridOptions.rowIdentity = function (row) {
  15969. return row.id;
  15970. };
  15971. $scope.gridOptions.getRowIdentity = function (row) {
  15972. return row.id;
  15973. };
  15974. $scope.gridOptions.rowTemplate =
  15975. '<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>';
  15976. $scope.gridOptions.columnDefs = [
  15977. {
  15978. name: "account",
  15979. displayName: "人员编号",
  15980. width: 120,
  15981. },
  15982. {
  15983. name: "name",
  15984. displayName: "姓名",
  15985. width: 100,
  15986. cellTemplate:
  15987. "<div>" +
  15988. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15989. "</div>",
  15990. },
  15991. // {
  15992. // name: 'gender.name',
  15993. // displayName: '性别',
  15994. // width: 80,
  15995. // enableFiltering: false
  15996. // },
  15997. {
  15998. name: "phone",
  15999. displayName: "电话",
  16000. width: 230,
  16001. enableFiltering: false,
  16002. },
  16003. {
  16004. name: "email",
  16005. displayName: "邮箱",
  16006. width: 180,
  16007. enableFiltering: false,
  16008. },
  16009. {
  16010. name: "dept.dept",
  16011. displayName: "科室",
  16012. width: 130,
  16013. enableFiltering: false,
  16014. },
  16015. {
  16016. name: "taskCount",
  16017. displayName: "处理中事件数",
  16018. enableFiltering: false,
  16019. },
  16020. ];
  16021. // $scope.selectButtonClick
  16022. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16023. $scope.gridApi = gridApi;
  16024. gridApi.pagination.on.paginationChanged(
  16025. $scope,
  16026. function (newPage, pageSize) {
  16027. var postData = {
  16028. idx: newPage - 1,
  16029. sum: pageSize,
  16030. user: {
  16031. roledata: {
  16032. rolecode: "first-line support",
  16033. },
  16034. selectType: "1",
  16035. },
  16036. }
  16037. if($scope.isAssign){
  16038. if($scope.searchModel.type == 1){
  16039. // 判断当前是责任科室还是院区
  16040. if ($rootScope.user.duty) {
  16041. // 当前的所属责任科室
  16042. postData.user.currentDuty = $rootScope.user.duty.id;
  16043. } else if ($rootScope.user.branch) {
  16044. // 当前的所属院区
  16045. $scope.myData = [];
  16046. return;
  16047. }
  16048. }else if($scope.searchModel.type == 2){
  16049. // 跨科室转派
  16050. postData.user.duty = $scope.searchModel.department;
  16051. }
  16052. }
  16053. $scope.loadData(postData);
  16054. }
  16055. );
  16056. gridApi.selection.on.rowSelectionChanged(
  16057. $scope,
  16058. function (data) {
  16059. $scope.selected.items = data.entity;
  16060. //console.log(data);
  16061. }
  16062. );
  16063. gridApi.selection.on.rowSelectionChangedBatch(
  16064. $scope,
  16065. function (data) {
  16066. $scope.selected.items = data.entity;
  16067. //console.log(data);
  16068. }
  16069. );
  16070. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  16071. // // if (row.entity.age > 45) {
  16072. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16073. // // }
  16074. // };
  16075. gridApi.core.on.filterChanged($scope, function () {
  16076. var grid = this.grid;
  16077. var filtersData = {
  16078. idx: 0,
  16079. sum: 10,
  16080. user: {
  16081. roledata: {
  16082. rolecode: "first-line support",
  16083. },
  16084. selectType: "1",
  16085. },
  16086. };
  16087. angular.forEach(grid.columns, function (item) {
  16088. if (item.enableFiltering) {
  16089. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  16090. if (
  16091. angular.isDefined(item.filters[0].term) &&
  16092. item.filters[0].term != ""
  16093. ) {
  16094. if (angular.isUndefined(filtersData["user"])) {
  16095. filtersData["user"] = {};
  16096. }
  16097. filtersData["user"][item.field] =
  16098. item.filters[0].term;
  16099. }
  16100. }
  16101. });
  16102. if($scope.isAssign){
  16103. if($scope.searchModel.type == 1){
  16104. // 判断当前是责任科室还是院区
  16105. if ($rootScope.user.duty) {
  16106. // 当前的所属责任科室
  16107. filtersData.user.currentDuty = $rootScope.user.duty.id;
  16108. } else if ($rootScope.user.branch) {
  16109. // 当前的所属院区
  16110. $scope.myData = [];
  16111. return;
  16112. }
  16113. }else if($scope.searchModel.type == 2){
  16114. // 跨科室转派
  16115. filtersData.user.duty = $scope.searchModel.department;
  16116. }
  16117. }
  16118. // $scope.memoryfilterData = filtersData;
  16119. $scope.loadData(filtersData);
  16120. });
  16121. };
  16122. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  16123. // if (row.entity.age > 45) {
  16124. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16125. // }
  16126. // },
  16127. $scope.onDblClick = function (data, event) {
  16128. // $scope.selected.items = data.entity;
  16129. $scope.selectButtonClick(data, event);
  16130. };
  16131. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  16132. // $scope.selected.items = data.entity;
  16133. // })
  16134. // };
  16135. $scope.memoryfilterData = {
  16136. idx: 0,
  16137. sum: 10,
  16138. user: {
  16139. roledata: {
  16140. rolecode: "first-line support",
  16141. },
  16142. selectType: "1",
  16143. },
  16144. };
  16145. $scope.loadData = function (filterData) {
  16146. // console.log("filtersData=111" + JSON.stringify(filterData))
  16147. items
  16148. .fetchItems(filterData, APIService)
  16149. .then(function (data) {
  16150. if(($scope.searchModel.type == 1 && filterData.user.duty) || ($scope.searchModel.type == 2 && !filterData.user.duty)){
  16151. $scope.gridOptions.totalItems = 0;
  16152. $scope.myData = [];
  16153. }else{
  16154. var myData = Restangular.stripRestangular(data);
  16155. $scope.gridOptions.totalItems = myData.totalNum;
  16156. $scope.myData = myData.list;
  16157. }
  16158. });
  16159. };
  16160. $scope.title = title;
  16161. $scope.selected = {
  16162. items: {},
  16163. };
  16164. $scope.ok = function () {
  16165. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  16166. // onDataCallback($scope.selected.item, parentScope);
  16167. // }
  16168. $modalInstance.close($scope.selected.items);
  16169. };
  16170. $scope.cancel = function () {
  16171. $modalInstance.dismiss("cancel");
  16172. };
  16173. // 初始化
  16174. var postData = {
  16175. idx: 0,
  16176. sum: 10,
  16177. user: {
  16178. roledata: {
  16179. rolecode: "first-line support",
  16180. },
  16181. selectType: "1",
  16182. },
  16183. }
  16184. if($scope.isAssign){
  16185. if($scope.searchModel.type == 1){
  16186. // 判断当前是责任科室还是院区
  16187. if ($rootScope.user.duty) {
  16188. // 当前的所属责任科室
  16189. postData.user.currentDuty = $rootScope.user.duty.id;
  16190. } else if ($rootScope.user.branch) {
  16191. // 当前的所属院区
  16192. $scope.myData = [];
  16193. return;
  16194. }
  16195. }else if($scope.searchModel.type == 2){
  16196. // 跨科室转派
  16197. postData.user.duty = $scope.searchModel.department;
  16198. }
  16199. }
  16200. $scope.loadData(postData);
  16201. },
  16202. size: size,
  16203. resolve: {
  16204. items: function () {
  16205. return {
  16206. fetchItems: function (filterData, APIService) {
  16207. filterData = filterData || {};
  16208. if (
  16209. angular.isDefined(filterData.idx) &&
  16210. filterData.idx == null
  16211. ) {
  16212. filterData = {
  16213. idx: 0,
  16214. sum: 10,
  16215. user: {
  16216. roledata: {
  16217. rolecode: "first-line support",
  16218. },
  16219. selectType: "1",
  16220. },
  16221. };
  16222. }
  16223. return options.templateOptions.fetchItems(
  16224. filterData,
  16225. APIService
  16226. );
  16227. },
  16228. };
  16229. },
  16230. title: function () {
  16231. return options.templateOptions.label;
  16232. },
  16233. Restangular: function () {
  16234. return options.templateOptions.Restangular;
  16235. },
  16236. APIService: function () {
  16237. return options.templateOptions.ApiService;
  16238. },
  16239. onDataCallback: function () {
  16240. return options.templateOptions.callback;
  16241. },
  16242. parentScope: function () {
  16243. return options.templateOptions.that;
  16244. }
  16245. },
  16246. });
  16247. modalInstance.result.then(
  16248. function (selectedItem) {
  16249. // console.log(selectedItem);
  16250. options.value(selectedItem);
  16251. if (
  16252. options.templateOptions.callback &&
  16253. angular.isFunction(options.templateOptions.callback)
  16254. ) {
  16255. options.templateOptions.callback(
  16256. selectedItem,
  16257. options.templateOptions.that
  16258. );
  16259. }
  16260. if (
  16261. options.templateOptions.linkData &&
  16262. angular.isFunction(options.templateOptions.linkData)
  16263. ) {
  16264. options.templateOptions.linkData(
  16265. selectedItem,
  16266. options.templateOptions.that
  16267. );
  16268. }
  16269. },
  16270. function () {
  16271. //console.log('Modal dismissed at: ' + new Date());
  16272. }
  16273. );
  16274. },
  16275. },
  16276. };
  16277. },
  16278. controller: [
  16279. "$scope",
  16280. function ($scope) {
  16281. $scope.options.templateOptions.that = $scope;
  16282. },
  16283. ],
  16284. });
  16285. //用户多选控件
  16286. formlyConfigProvider.setType({
  16287. name: "ui-multiuserselect",
  16288. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  16289. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16290. defaultOptions: function (options) {
  16291. return {
  16292. templateOptions: {
  16293. openModal: function (size, options, modal, model) {
  16294. var modalInstance = modal.open({
  16295. templateUrl:
  16296. "assets/views/customform/tpl/checktable-modal-content.html",
  16297. controller: function (
  16298. $scope,
  16299. $modalInstance,
  16300. i18nService,
  16301. $timeout,
  16302. items,
  16303. title,
  16304. Restangular,
  16305. APIService,
  16306. selectItems
  16307. ) {
  16308. $scope.langs = i18nService.getAllLangs();
  16309. $scope.lang = "zh-cn";
  16310. i18nService.setCurrentLang($scope.lang);
  16311. $scope.gridOptions = {};
  16312. $scope.gridOptions.data = "myData";
  16313. $scope.gridOptions.enableColumnResizing = true;
  16314. $scope.gridOptions.enableFiltering = true;
  16315. $scope.gridOptions.enableGridMenu = true;
  16316. $scope.gridOptions.showGridFooter = true;
  16317. $scope.gridOptions.showColumnFooter = true;
  16318. $scope.gridOptions.fastWatch = true;
  16319. $scope.gridOptions.useExternalFiltering = true;
  16320. $scope.gridOptions.useExternalPagination = true;
  16321. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16322. $scope.gridOptions.paginationPageSize = 10;
  16323. $scope.gridOptions.multiSelect = true;
  16324. $scope.gridOptions.rowIdentity = function (row) {
  16325. return row.id;
  16326. };
  16327. $scope.gridOptions.getRowIdentity = function (row) {
  16328. return row.id;
  16329. };
  16330. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  16331. $scope.gridOptions.columnDefs = [
  16332. // { name:'id', width:80, enableFiltering:false},
  16333. {
  16334. name: "account",
  16335. displayName: "账号",
  16336. width: 140,
  16337. },
  16338. {
  16339. name: "name",
  16340. displayName: "名称",
  16341. width: 100,
  16342. },
  16343. {
  16344. name: "gender.name",
  16345. displayName: "性别",
  16346. width: 140,
  16347. enableFiltering: false,
  16348. },
  16349. {
  16350. name: "phone",
  16351. displayName: "电话",
  16352. width: 100,
  16353. enableFiltering: false,
  16354. },
  16355. {
  16356. name: "email",
  16357. displayName: "邮件",
  16358. width: 100,
  16359. enableFiltering: false,
  16360. },
  16361. {
  16362. name: "dept.dept",
  16363. displayName: "科室",
  16364. width: 100,
  16365. enableFiltering: false,
  16366. },
  16367. {
  16368. name: "group[0].groupName",
  16369. displayName: "职位",
  16370. width: 100,
  16371. enableFiltering: false,
  16372. },
  16373. ];
  16374. $scope.selected = {
  16375. items: selectItems,
  16376. };
  16377. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16378. $scope.gridApi = gridApi;
  16379. gridApi.pagination.on.paginationChanged(
  16380. $scope,
  16381. function (newPage, pageSize) {
  16382. var filtersData = $scope.memoryfilterData;
  16383. filtersData.idx = newPage - 1;
  16384. filtersData.sum = pageSize;
  16385. $scope.loadData(filtersData);
  16386. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  16387. }
  16388. );
  16389. gridApi.selection.on.rowSelectionChanged(
  16390. $scope,
  16391. function (scope) {
  16392. var j = 0;
  16393. for (
  16394. var i = 0;
  16395. i <= scope.grid.appScope.selected.items.length;
  16396. i++
  16397. ) {
  16398. if (
  16399. scope.grid.appScope.selected.items[i] == scope.entity
  16400. ) {
  16401. j++;
  16402. break;
  16403. }
  16404. }
  16405. if (j == 1) {
  16406. scope.grid.appScope.selected.items.splice(i, 1);
  16407. } else {
  16408. scope.grid.appScope.selected.items.push(scope.entity);
  16409. for (
  16410. var i = 0;
  16411. i < scope.grid.appScope.selected.items.length;
  16412. i++
  16413. ) {
  16414. for (
  16415. var z = 0;
  16416. z < scope.grid.appScope.selected.items.length;
  16417. z++
  16418. ) {
  16419. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  16420. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  16421. if (
  16422. angular.isDefined(
  16423. scope.grid.appScope.selected.items
  16424. ) &&
  16425. scope.grid.appScope.selected.items[i].id ==
  16426. scope.grid.appScope.selected.items[z].id &&
  16427. i != z
  16428. ) {
  16429. scope.grid.appScope.selected.items.splice(i, 1);
  16430. }
  16431. }
  16432. }
  16433. }
  16434. }
  16435. );
  16436. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  16437. // $scope.grid.appScope.selected.items.push($scope.entity);
  16438. // });
  16439. gridApi.core.on.filterChanged($scope, function () {
  16440. var grid = this.grid;
  16441. var filtersData = {
  16442. idx: 0,
  16443. sum: 10,
  16444. user: {
  16445. roledata: {
  16446. rolecode: options.model.currentRole,
  16447. },
  16448. selectType: "1",
  16449. },
  16450. };
  16451. angular.forEach(grid.columns, function (item) {
  16452. if (item.enableFiltering) {
  16453. //console.log("filtersData="+JSON.stringify(filtersData))
  16454. if (
  16455. angular.isDefined(item.filters[0].term) &&
  16456. item.filters[0].term != ""
  16457. ) {
  16458. if (angular.isUndefined(filtersData["user"])) {
  16459. filtersData["user"] = {};
  16460. }
  16461. filtersData["user"][item.field] =
  16462. item.filters[0].term;
  16463. }
  16464. }
  16465. });
  16466. $scope.memoryfilterData = filtersData;
  16467. $scope.loadData(filtersData);
  16468. });
  16469. };
  16470. if (!options.model) {
  16471. var mouse = {
  16472. model: {
  16473. currentRole: "",
  16474. },
  16475. };
  16476. angular.extend(options, mouse);
  16477. }
  16478. $scope.memoryfilterData = {
  16479. idx: 0,
  16480. sum: 10,
  16481. user: {
  16482. roledata: {
  16483. rolecode: options.model.currentRole,
  16484. },
  16485. selectType: "1",
  16486. },
  16487. };
  16488. $scope.loadData = function (filterData) {
  16489. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  16490. items
  16491. .fetchItems(filterData, APIService)
  16492. .then(function (data) {
  16493. var myData = Restangular.stripRestangular(data);
  16494. $scope.gridOptions.totalItems = myData.totalNum;
  16495. $scope.myData = myData.list;
  16496. //console.log($scope.gridOptions.pagination.getTotalPages());
  16497. // if($scope.selected.items){
  16498. // angular.forEach($scope.selected.items,function(selectItem){
  16499. // $scope.gridApi.selection.selectRow(selectItem);
  16500. // });
  16501. // }
  16502. });
  16503. };
  16504. // $scope.title = title;
  16505. $scope.loadData({
  16506. idx: 0,
  16507. sum: 10,
  16508. user: {
  16509. roledata: {
  16510. rolecode: options.model.currentRole,
  16511. },
  16512. selectType: "1",
  16513. },
  16514. });
  16515. // $timeout(function(){
  16516. // if($scope.selected.items){
  16517. // angular.forEach($scope.selected.items,function(selectItem){
  16518. // $scope.gridApi.selection.selectRow(selectItem);
  16519. // });
  16520. // }
  16521. // },2000)
  16522. $scope.ok = function () {
  16523. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  16524. $modalInstance.close($scope.selected.items);
  16525. };
  16526. $scope.cancel = function () {
  16527. $modalInstance.dismiss("cancel");
  16528. };
  16529. },
  16530. size: size,
  16531. resolve: {
  16532. items: function () {
  16533. return {
  16534. fetchItems: function (filterData, APIService) {
  16535. filterData = filterData || {};
  16536. if (
  16537. angular.isDefined(filterData.idx) &&
  16538. filterData.idx == null
  16539. ) {
  16540. filterData = {
  16541. idx: 0,
  16542. sum: 10,
  16543. user: {
  16544. roledata: {
  16545. rolecode: options.model.incident.currentRole,
  16546. },
  16547. selectType: "1",
  16548. },
  16549. };
  16550. }
  16551. return options.templateOptions.fetchItems(
  16552. filterData,
  16553. APIService
  16554. );
  16555. },
  16556. };
  16557. },
  16558. title: function () {
  16559. return options.templateOptions.modalTitle;
  16560. },
  16561. Restangular: function () {
  16562. return options.templateOptions.Restangular;
  16563. },
  16564. APIService: function () {
  16565. return options.templateOptions.ApiService;
  16566. },
  16567. selectItems: function () {
  16568. return model || [];
  16569. },
  16570. },
  16571. });
  16572. modalInstance.result.then(
  16573. function (selectedItem) {
  16574. options.value(selectedItem);
  16575. options.formControl.$validate();
  16576. },
  16577. function () {
  16578. //console.log('Modal dismissed at: ' + new Date());
  16579. }
  16580. );
  16581. },
  16582. },
  16583. validators: {
  16584. required: {
  16585. expression: function (viewValue, modelValue) {
  16586. var value = modelValue || viewValue;
  16587. return value.length >= 1;
  16588. },
  16589. },
  16590. },
  16591. };
  16592. },
  16593. controller: [
  16594. "$scope",
  16595. function ($scope) {
  16596. $scope.model[$scope.options.key] = [];
  16597. $scope.remove = function (itemId) {
  16598. angular.forEach(
  16599. $scope.model[$scope.options.key],
  16600. function (entry, index) {
  16601. if (entry.id == itemId) {
  16602. $scope.model[$scope.options.key].splice(index, 1);
  16603. // console.log($scope.options.formControl)
  16604. $scope.options.formControl.$validate();
  16605. } else {
  16606. }
  16607. }
  16608. );
  16609. };
  16610. },
  16611. ],
  16612. });
  16613. //用户多选控件-字符串展示
  16614. formlyConfigProvider.setType({
  16615. name: "ui-stringuserselect",
  16616. extends: "input",
  16617. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  16618. defaultOptions: function (options) {
  16619. return {
  16620. templateOptions: {
  16621. translate: "",
  16622. refreshDelay: 0,
  16623. },
  16624. };
  16625. },
  16626. controller: [
  16627. "$scope",
  16628. function ($scope) {
  16629. var keydata = "";
  16630. if (angular.isArray($scope.model)) {
  16631. angular.forEach($scope.model, function (item) {
  16632. keydata = keydata + "," + item.name;
  16633. });
  16634. }
  16635. // $scope.model[$scope.options.key] = [];
  16636. },
  16637. ],
  16638. });
  16639. //重复事件
  16640. formlyConfigProvider.setType({
  16641. name: "ui-incidentmodelselect",
  16642. extends: "input",
  16643. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16644. defaultOptions: function (options) {
  16645. return {
  16646. templateOptions: {
  16647. openModal: function (size, options, modal) {
  16648. var modalInstance = modal.open({
  16649. templateUrl:
  16650. "assets/views/customform/tpl/checktable-modal-content.html",
  16651. controller: function (
  16652. $scope,
  16653. $rootScope,
  16654. $modalInstance,
  16655. items,
  16656. title,
  16657. Restangular,
  16658. APIService,
  16659. i18nService,
  16660. api_configure_data,
  16661. api_user_data,
  16662. api_bpm_data
  16663. ) {
  16664. $scope.langs = i18nService.getAllLangs();
  16665. $scope.lang = "zh-cn";
  16666. i18nService.setCurrentLang($scope.lang);
  16667. $scope.gridOptions = {};
  16668. $scope.gridOptions.data = "myData";
  16669. $scope.gridOptions.enableColumnResizing = true;
  16670. $scope.gridOptions.enableFiltering = true;
  16671. $scope.gridOptions.enableGridMenu = false;
  16672. $scope.gridOptions.enableRowSelection = true;
  16673. $scope.gridOptions.showGridFooter = true;
  16674. $scope.gridOptions.showColumnFooter = false;
  16675. $scope.gridOptions.fastWatch = true;
  16676. $scope.gridOptions.useExternalFiltering = true;
  16677. $scope.gridOptions.useExternalPagination = true;
  16678. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16679. $scope.gridOptions.paginationPageSize = 10;
  16680. $scope.gridOptions.multiSelect = false;
  16681. var mun = $scope.gridOptions.paginationPageSize;
  16682. $scope.gridOptions.rowIdentity = function (row) {
  16683. return row.id;
  16684. };
  16685. $scope.gridOptions.getRowIdentity = function (row) {
  16686. return row.id;
  16687. };
  16688. $scope.gridOptions.columnDefs = items.columnDefs();
  16689. $scope.transferTime = function (time) {
  16690. return moment(time).format("YYYY-MM-DD HH:mm");
  16691. };
  16692. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16693. $scope.gridApi = gridApi;
  16694. gridApi.pagination.on.paginationChanged(
  16695. $scope,
  16696. function (newPage, pageSize) {
  16697. // console.log(newPage);
  16698. // console.log(pageSize);
  16699. $scope.loadData({
  16700. idx: newPage - 1,
  16701. sum: pageSize,
  16702. });
  16703. }
  16704. );
  16705. gridApi.core.on.filterChanged($scope, function () {
  16706. var grid = this.grid;
  16707. var filtersData = {
  16708. idx: 0,
  16709. sum: 100,
  16710. };
  16711. angular.forEach(grid.columns, function (item) {
  16712. if (item.enableFiltering) {
  16713. if (
  16714. angular.isDefined(item.filters[0].term) &&
  16715. item.filters[0].term != ""
  16716. ) {
  16717. // console.log("filtersData="+JSON.stringify(filtersData))
  16718. if (angular.isUndefined(filtersData["incident"])) {
  16719. filtersData["incident"] = {};
  16720. }
  16721. filtersData["incident"][item.field] =
  16722. item.filters[0].term;
  16723. if (angular.isUndefined(filtersData["problem"])) {
  16724. filtersData["problem"] = {};
  16725. }
  16726. filtersData["problem"][item.field] =
  16727. item.filters[0].term;
  16728. if (angular.isUndefined(filtersData["change"])) {
  16729. filtersData["change"] = {};
  16730. }
  16731. filtersData["change"][item.field] =
  16732. item.filters[0].term;
  16733. if (angular.isUndefined(filtersData["release"])) {
  16734. filtersData["release"] = {};
  16735. }
  16736. filtersData["release"][item.field] =
  16737. item.filters[0].term;
  16738. }
  16739. }
  16740. });
  16741. $scope.loadData(filtersData);
  16742. });
  16743. gridApi.selection.on.rowSelectionChanged(
  16744. $scope,
  16745. function (data) {
  16746. $scope.selected.item = data.entity;
  16747. //console.log(data);
  16748. }
  16749. );
  16750. };
  16751. //资产
  16752. $scope.cmdb = {};
  16753. //资产状态
  16754. $scope.state_data = [
  16755. {
  16756. name: "全部状态",
  16757. value: "",
  16758. },
  16759. {
  16760. name: "在库",
  16761. value: "1",
  16762. },
  16763. {
  16764. name: "在线",
  16765. value: "2",
  16766. },
  16767. {
  16768. name: "借出",
  16769. value: "3",
  16770. },
  16771. {
  16772. name: "报修",
  16773. value: "4",
  16774. },
  16775. {
  16776. name: "报废",
  16777. value: "5",
  16778. },
  16779. {
  16780. name: "备用",
  16781. value: "6",
  16782. },
  16783. ];
  16784. //资产类型
  16785. $scope.wt_zcfl = function () {
  16786. api_configure_data
  16787. .fetchDataList("ciclassify", {
  16788. idx: 0,
  16789. sum: 100,
  16790. })
  16791. .then(function (data) {
  16792. console.log(data);
  16793. // $scope.wt_zclx = data.list;
  16794. console.log(data);
  16795. $scope.wtData = [];
  16796. if (data.status == 200) {
  16797. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  16798. var root = null; //Initially set our loop to null
  16799. var parentNode = null;
  16800. //loop over data
  16801. // $scope.wtData=data.list;
  16802. data = data.list;
  16803. //知识库分类数据三级处理
  16804. for (var i = 0; i < data.length; i++) {
  16805. // console.log(data[i])
  16806. var datum = data[i];
  16807. //each node will have children, so let's give it a "children" poperty
  16808. // console.log(datum);
  16809. datum.children = [];
  16810. if (!datum.parent) {
  16811. $scope.wtData.push(datum);
  16812. // console.log($scope.wtData)
  16813. } else {
  16814. if ($scope.wtData[0]) {
  16815. if ($scope.wtData[0].id == datum.parent.id) {
  16816. $scope.wtData[0].children.push(datum);
  16817. }
  16818. for (
  16819. var j = 0;
  16820. j < $scope.wtData[0].children.length;
  16821. j++
  16822. ) {
  16823. if (
  16824. $scope.wtData[0].children[j].id ==
  16825. datum.parent.id
  16826. ) {
  16827. $scope.wtData[0].children[j].children.push(
  16828. datum
  16829. );
  16830. }
  16831. }
  16832. }
  16833. if ($scope.wtData[1]) {
  16834. if ($scope.wtData[1].id == datum.parent.id) {
  16835. $scope.wtData[1].children.push(datum);
  16836. }
  16837. for (
  16838. var j = 0;
  16839. j < $scope.wtData[1].children.length;
  16840. j++
  16841. ) {
  16842. if (
  16843. $scope.wtData[1].children[j].id ==
  16844. datum.parent.id
  16845. ) {
  16846. $scope.wtData[1].children[j].children.push(
  16847. datum
  16848. );
  16849. }
  16850. }
  16851. }
  16852. if ($scope.wtData[2]) {
  16853. if ($scope.wtData[2].id == datum.parent.id) {
  16854. $scope.wtData[2].children.push(datum);
  16855. }
  16856. for (
  16857. var j = 0;
  16858. j < $scope.wtData[2].children.length;
  16859. j++
  16860. ) {
  16861. if (
  16862. $scope.wtData[2].children[j].id ==
  16863. datum.parent.id
  16864. ) {
  16865. $scope.wtData[2].children[j].children.push(
  16866. datum
  16867. );
  16868. }
  16869. }
  16870. }
  16871. }
  16872. // console.log($scope.wtData)
  16873. idToNodeMap[datum.id] = datum;
  16874. root = datum;
  16875. // treeMap[datum.id] = root;
  16876. }
  16877. }
  16878. });
  16879. };
  16880. $scope.wt_zcfl();
  16881. //事件
  16882. //受理人,处理人
  16883. $scope.searchkeys = {};
  16884. var fieldata = {
  16885. idx: 0,
  16886. sum: 100,
  16887. flag: -1,
  16888. };
  16889. getUser(fieldata, 3);
  16890. function getUser(fieldatas, it) {
  16891. api_user_data
  16892. .fetchDataList("user", fieldatas)
  16893. .then(function (data) {
  16894. if (it == 1) {
  16895. $scope.acceptUser = data.list;
  16896. } else if (it == 2) {
  16897. $scope.handlingPersonnelUser = data.list;
  16898. } else if (it == 3) {
  16899. $scope.acceptUser = data.list;
  16900. $scope.handlingPersonnelUser = data.list;
  16901. }
  16902. });
  16903. }
  16904. //状态
  16905. $scope.othcode = {};
  16906. api_bpm_data
  16907. .fetchDataList("incidentstatus", {
  16908. idx: 0,
  16909. sum: 100,
  16910. })
  16911. .then(function (response) {
  16912. if (response) {
  16913. if ((response.status = 200)) {
  16914. $scope.state = response.list;
  16915. }
  16916. }
  16917. });
  16918. var defaultFilterData = {
  16919. assignee: $rootScope.user.id,
  16920. searchType: "todo",
  16921. idx: 0,
  16922. sum: mun,
  16923. };
  16924. var defaultFilterData1 = {
  16925. // "searchType": "todo",
  16926. idx: 0,
  16927. sum: mun,
  16928. };
  16929. //搜索
  16930. $scope.chiceIncident = function (parameters, item, stateid) {
  16931. console.log(item, stateid);
  16932. console.log($scope);
  16933. if ($scope.title == "关联资产编号") {
  16934. // alert('222222222222');
  16935. var fildata = defaultFilterData1;
  16936. $scope.gridOptions.paginationCurrentPage = 1;
  16937. var transitiondata = angular.copy(item);
  16938. angular.extend(fildata, transitiondata);
  16939. if (fildata.hw_state) {
  16940. fildata.hw_state = fildata.hw_state.name;
  16941. }
  16942. if (fildata.sign) {
  16943. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  16944. fildata.sign = fildata.sign.split(";");
  16945. fildata.sign = fildata.sign.join("");
  16946. fildata.sign = fildata.sign.toLowerCase();
  16947. }
  16948. if (fildata.keys) {
  16949. fildata["searchCriteria"] = "uuid";
  16950. }
  16951. console.log(fildata);
  16952. $scope.loadData(fildata);
  16953. }
  16954. if ($scope.title == "关联事件工单") {
  16955. // alert('3333333333333333')
  16956. if (stateid && stateid.code) {
  16957. item.statusId = stateid.code;
  16958. }
  16959. var fildata = defaultFilterData;
  16960. // $scope.memoryfilterData = fildata;
  16961. if (!fildata.incident) {
  16962. fildata["incident"] = {};
  16963. }
  16964. $scope.gridOptions.paginationCurrentPage = 1;
  16965. var transitiondata = angular.copy(item);
  16966. angular.extend(fildata.incident, transitiondata);
  16967. console.log(fildata);
  16968. // $scope.loadData(fildata);
  16969. api_bpm_data
  16970. .fetchDataList("incident", fildata)
  16971. .then(function (data) {
  16972. console.log(data);
  16973. if (data) {
  16974. $scope.myData = data.list;
  16975. $scope.gridOptions.totalItems = data.totalNum;
  16976. }
  16977. });
  16978. }
  16979. };
  16980. //重置
  16981. $scope.replacement = function (
  16982. parameters,
  16983. searchkeys,
  16984. othcode
  16985. ) {
  16986. // console.log(parameters, searchkeys, othcode);
  16987. delete defaultFilterData.incident;
  16988. console.log(defaultFilterData);
  16989. $scope.parameters = null;
  16990. $scope.searchkeys = {};
  16991. $scope.othcode = {};
  16992. $scope.wt_zcfl();
  16993. };
  16994. $scope.loadData = function (filterData) {
  16995. items
  16996. .fetchItems(filterData, APIService, $rootScope)
  16997. .then(function (data) {
  16998. var myData = Restangular.stripRestangular(data);
  16999. if (myData.data && myData.data.node) {
  17000. $scope.gridOptions.totalItems = myData.total;
  17001. $scope.myData = myData.data.node;
  17002. } else {
  17003. if (myData.resultCount) {
  17004. $scope.gridOptions["totalItems"] = myData.resultCount;
  17005. } else {
  17006. $scope.gridOptions.totalItems = myData.totalNum;
  17007. }
  17008. if (myData.list) {
  17009. $scope.myData = myData.list;
  17010. } else {
  17011. $scope.myData = myData.data;
  17012. }
  17013. }
  17014. });
  17015. };
  17016. $scope.title = title;
  17017. $scope.loadData({
  17018. idx: 0,
  17019. sum: 10,
  17020. });
  17021. $scope.selected = {
  17022. item: {},
  17023. };
  17024. $scope.ok = function () {
  17025. //console.log($scope.selected.item);
  17026. $modalInstance.close($scope.selected.item);
  17027. };
  17028. $scope.cancel = function () {
  17029. $modalInstance.dismiss("cancel");
  17030. };
  17031. },
  17032. size: size,
  17033. resolve: {
  17034. items: function () {
  17035. return {
  17036. fetchItems: function (filterData, APIService, $rootScope) {
  17037. filterData = filterData || {};
  17038. // if(!filterData.idx){
  17039. if (
  17040. angular.isDefined(filterData.idx) &&
  17041. filterData.idx == null
  17042. ) {
  17043. filterData = {
  17044. idx: 0,
  17045. sum: 10,
  17046. };
  17047. }
  17048. return options.templateOptions.fetchItems(
  17049. filterData,
  17050. APIService,
  17051. $rootScope
  17052. );
  17053. },
  17054. columnDefs: function () {
  17055. return options.templateOptions.columnDefs;
  17056. },
  17057. };
  17058. },
  17059. title: function () {
  17060. return options.templateOptions.modalTitle;
  17061. },
  17062. Restangular: function () {
  17063. return options.templateOptions.Restangular;
  17064. },
  17065. APIService: function () {
  17066. return options.templateOptions.ApiService;
  17067. },
  17068. },
  17069. });
  17070. modalInstance.result.then(
  17071. function (selectedItem) {
  17072. var selectitem = {
  17073. title: selectedItem.title,
  17074. description: selectedItem.description,
  17075. };
  17076. if (options.key == "chuku") {
  17077. if (selectedItem.assets) {
  17078. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  17079. selectedItem.assets;
  17080. }
  17081. if (selectedItem.consumables) {
  17082. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  17083. selectedItem.consumables;
  17084. }
  17085. angular.extend(
  17086. $scope.$parent.$parent.$parent.model,
  17087. selectitem
  17088. );
  17089. options.value(selectedItem);
  17090. // options.model.consumables = JSON.parse(consumables);
  17091. } else if (options.templateOptions.pkey == "change") {
  17092. console.log(options);
  17093. angular.extend(options.model);
  17094. options.value(selectedItem);
  17095. } else if (options.key == "cmdbCode") {
  17096. var zc_selectitem = selectedItem.uuid;
  17097. // angular.extend(options.model,zc_selectitem);
  17098. options.model.cmdbCode = zc_selectitem;
  17099. // angular.extend(options.model,zc_selectitem);
  17100. // options.templateOptions.displayName=zc_selectitem;
  17101. options.value(selectedItem);
  17102. console.log(options.model);
  17103. } else {
  17104. angular.extend(options.model, selectitem);
  17105. options.value(selectedItem);
  17106. }
  17107. },
  17108. function () {
  17109. //console.log('Modal dismissed at: ' + new Date());
  17110. }
  17111. );
  17112. },
  17113. },
  17114. };
  17115. },
  17116. });
  17117. //选项选择控件
  17118. formlyConfigProvider.setType({
  17119. name: "ui-modelselect",
  17120. extends: "input",
  17121. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  17122. defaultOptions: function (options) {
  17123. return {
  17124. templateOptions: {
  17125. openModal: function (size, options, modal) {
  17126. var modalInstance = modal.open({
  17127. templateUrl:
  17128. "assets/views/customform/tpl/checktable-modal-content.html",
  17129. controller: function (
  17130. $scope,
  17131. $modalInstance,
  17132. items,
  17133. title,
  17134. Restangular,
  17135. APIService,
  17136. i18nService
  17137. ) {
  17138. $scope.langs = i18nService.getAllLangs();
  17139. $scope.lang = "zh-cn";
  17140. i18nService.setCurrentLang($scope.lang);
  17141. $scope.gridOptions = {};
  17142. $scope.gridOptions.data = "myData";
  17143. $scope.gridOptions.enableColumnResizing = true;
  17144. $scope.gridOptions.enableFiltering = true;
  17145. $scope.gridOptions.enableGridMenu = false;
  17146. $scope.gridOptions.enableRowSelection = true;
  17147. $scope.gridOptions.showGridFooter = true;
  17148. $scope.gridOptions.showColumnFooter = true;
  17149. $scope.gridOptions.fastWatch = true;
  17150. $scope.gridOptions.useExternalFiltering = true;
  17151. $scope.gridOptions.useExternalPagination = true;
  17152. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  17153. $scope.gridOptions.paginationPageSize = 10;
  17154. $scope.gridOptions.multiSelect = false;
  17155. $scope.gridOptions.rowIdentity = function (row) {
  17156. return row.id;
  17157. };
  17158. $scope.gridOptions.getRowIdentity = function (row) {
  17159. return row.id;
  17160. };
  17161. $scope.gridOptions.columnDefs = items.columnDefs();
  17162. $scope.gridOptions.onRegisterApi = function (gridApi) {
  17163. $scope.gridApi = gridApi;
  17164. gridApi.pagination.on.paginationChanged(
  17165. $scope,
  17166. function (newPage, pageSize) {
  17167. // console.log(newPage);
  17168. // console.log(pageSize);
  17169. $scope.loadData({
  17170. idx: newPage - 1,
  17171. sum: pageSize,
  17172. });
  17173. }
  17174. );
  17175. gridApi.core.on.filterChanged($scope, function () {
  17176. var grid = this.grid;
  17177. var filtersData = {
  17178. idx: 0,
  17179. sum: 10,
  17180. };
  17181. angular.forEach(grid.columns, function (item) {
  17182. if (item.enableFiltering) {
  17183. if (
  17184. angular.isDefined(item.filters[0].term) &&
  17185. item.filters[0].term != ""
  17186. ) {
  17187. // console.log("filtersData="+JSON.stringify(filtersData))
  17188. if (angular.isUndefined(filtersData["incident"])) {
  17189. filtersData["incident"] = {};
  17190. }
  17191. filtersData["incident"][item.field] =
  17192. item.filters[0].term;
  17193. if (angular.isUndefined(filtersData["problem"])) {
  17194. filtersData["problem"] = {};
  17195. }
  17196. filtersData["problem"][item.field] =
  17197. item.filters[0].term;
  17198. if (angular.isUndefined(filtersData["change"])) {
  17199. filtersData["change"] = {};
  17200. }
  17201. filtersData["change"][item.field] =
  17202. item.filters[0].term;
  17203. if (angular.isUndefined(filtersData["release"])) {
  17204. filtersData["release"] = {};
  17205. }
  17206. filtersData["release"][item.field] =
  17207. item.filters[0].term;
  17208. }
  17209. }
  17210. });
  17211. $scope.loadData(filtersData);
  17212. });
  17213. gridApi.selection.on.rowSelectionChanged(
  17214. $scope,
  17215. function (data) {
  17216. $scope.selected.item = data.entity;
  17217. //console.log(data);
  17218. }
  17219. );
  17220. };
  17221. $scope.loadData = function (filterData) {
  17222. items
  17223. .fetchItems(filterData, APIService)
  17224. .then(function (data) {
  17225. var myData = Restangular.stripRestangular(data);
  17226. $scope.gridOptions.totalItems = myData.totalNum;
  17227. $scope.myData = myData.list;
  17228. });
  17229. };
  17230. $scope.title = title;
  17231. $scope.loadData({
  17232. idx: 0,
  17233. sum: 10,
  17234. });
  17235. $scope.selected = {
  17236. item: {},
  17237. };
  17238. $scope.ok = function () {
  17239. if ($scope.selected.item.scheduleOrder) {
  17240. $scope.selected.item.descriptionData =
  17241. "日期:" +
  17242. $scope.selected.item.watchTime +
  17243. ";" +
  17244. "班次:" +
  17245. $scope.selected.item.scheduleOrder.description +
  17246. ";" +
  17247. "值班人:" +
  17248. $scope.selected.item.scheduleOrder.users[0].name;
  17249. }
  17250. //console.log($scope.selected.item);
  17251. $modalInstance.close($scope.selected.item);
  17252. };
  17253. $scope.cancel = function () {
  17254. $modalInstance.dismiss("cancel");
  17255. };
  17256. },
  17257. size: size,
  17258. resolve: {
  17259. items: function () {
  17260. return {
  17261. fetchItems: function (filterData, APIService) {
  17262. filterData = filterData || {};
  17263. // if(!filterData.idx){
  17264. if (
  17265. angular.isDefined(filterData.idx) &&
  17266. filterData.idx == null
  17267. ) {
  17268. filterData = {
  17269. idx: 0,
  17270. sum: 10,
  17271. };
  17272. }
  17273. return options.templateOptions.fetchItems(
  17274. filterData,
  17275. APIService,
  17276. options
  17277. );
  17278. },
  17279. columnDefs: function () {
  17280. return options.templateOptions.columnDefs;
  17281. },
  17282. };
  17283. },
  17284. title: function () {
  17285. return options.templateOptions.modalTitle;
  17286. },
  17287. Restangular: function () {
  17288. return options.templateOptions.Restangular;
  17289. },
  17290. APIService: function () {
  17291. return options.templateOptions.ApiService;
  17292. },
  17293. },
  17294. });
  17295. modalInstance.result.then(
  17296. function (selectedItem) {
  17297. options.value(selectedItem);
  17298. },
  17299. function () {
  17300. //console.log('Modal dismissed at: ' + new Date());
  17301. }
  17302. );
  17303. },
  17304. },
  17305. };
  17306. },
  17307. });
  17308. formlyConfigProvider.setType({
  17309. name: "ui-requestform",
  17310. extends: "input",
  17311. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  17312. controller: [
  17313. "$scope",
  17314. function ($scope) {
  17315. setTimeout(function () {
  17316. var filterData = {
  17317. idx: 0,
  17318. sum: 5,
  17319. incident: {
  17320. requester: {
  17321. id: "",
  17322. },
  17323. },
  17324. };
  17325. $scope.options.templateOptions
  17326. .getWorkernumber(
  17327. $scope.options.templateOptions.ApiService,
  17328. filterData
  17329. )
  17330. .then(function (result) {
  17331. var modelData =
  17332. $scope.options.templateOptions.Restangular.stripRestangular(
  17333. result
  17334. );
  17335. });
  17336. }, 1000);
  17337. },
  17338. ],
  17339. });
  17340. //报修图片展示
  17341. formlyConfigProvider.setType({
  17342. name: "ui-repair-photos",
  17343. // extends: 'label',
  17344. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  17345. controller: [
  17346. "$scope",
  17347. "$rootScope",
  17348. "$modal",
  17349. "api_wechatfile",
  17350. "$stateParams",
  17351. function ($scope, $rootScope, $modal, api_wechatfile, $stateParams) {
  17352. console.log($scope);
  17353. $scope.imgs = [];
  17354. $scope.attachmentAddressSplicing = $rootScope.attachmentAddressSplicing;
  17355. if ($scope.model.wxFile) {
  17356. api_wechatfile
  17357. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  17358. .then(function (res) {
  17359. $scope.imgs = res.data;
  17360. });
  17361. }
  17362. console.log($stateParams);
  17363. if (
  17364. $stateParams &&
  17365. $stateParams.model &&
  17366. JSON.parse($stateParams.model) &&
  17367. JSON.parse($stateParams.model).model &&
  17368. JSON.parse($stateParams.model).model.flow
  17369. ) {
  17370. api_wechatfile
  17371. .listAttachment(
  17372. "wechatRequesterIncident",
  17373. JSON.parse($stateParams.model).model.flow
  17374. )
  17375. .then(function (res) {
  17376. $scope.imgs = res.data;
  17377. });
  17378. }
  17379. if ($scope.model.incident && $scope.model.incident.wxIncidentId) {
  17380. api_wechatfile
  17381. .listAttachment(
  17382. "wechatRequesterIncident",
  17383. $scope.model.incident.wxIncidentId
  17384. )
  17385. .then(function (res) {
  17386. $scope.imgs = res.data;
  17387. });
  17388. }
  17389. // if ($scope.model.flow) {
  17390. // api_wechatfile
  17391. // .listAttachment("wechatRequesterIncident", $scope.model.flow)
  17392. // .then(function (res) {
  17393. // $scope.imgs = res.data;
  17394. // });
  17395. // }
  17396. // 加载事件图片
  17397. // if($scope.model.incident){
  17398. // api_wechatfile
  17399. // .listAttachment("incident", $scope.model.incident.processInstanceId)
  17400. // .then(function (res) {
  17401. // $scope.imgs = res.data;
  17402. // });
  17403. // }
  17404. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  17405. // // setTimeout(function () {
  17406. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  17407. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  17408. // // if (modelData.status == 200) {
  17409. // // $scope.model[$scope.options.key] = modelData.data;
  17410. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  17411. // // }
  17412. // // });
  17413. // // }, 1000);
  17414. // }
  17415. $scope.preview = function (url, idx) {
  17416. var title = $scope.imgs[idx].title;
  17417. $modal.open({
  17418. backdrop: false,
  17419. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17420. controller: function ($scope, $rootScope, scope, $modalInstance) {
  17421. $scope.title = title;
  17422. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  17423. $scope.cancel = function () {
  17424. $modalInstance.dismiss("cancel");
  17425. };
  17426. },
  17427. resolve: {
  17428. scope: function () {
  17429. return $scope;
  17430. },
  17431. },
  17432. });
  17433. };
  17434. },
  17435. ],
  17436. });
  17437. //图片展示
  17438. formlyConfigProvider.setType({
  17439. name: "ui-showImgs",
  17440. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  17441. defaultOptions: function (options) {
  17442. return {
  17443. templateOptions: {
  17444. refresh: function (APIService, processInstanceId, data) {
  17445. return APIService.listAttachments(processInstanceId);
  17446. },
  17447. downloadUri: function (APIService, contentId) {
  17448. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17449. },
  17450. view: function (APIService, contentId) {
  17451. return APIService.attachmentsPreviewUrl(contentId);
  17452. },
  17453. download: function (APIService, contentId, item) {
  17454. var item = {
  17455. url: APIService.download(contentId),
  17456. headers: headers,
  17457. };
  17458. return item;
  17459. },
  17460. refreshDelay: 0,
  17461. },
  17462. };
  17463. },
  17464. controller: [
  17465. "$scope",
  17466. "$timeout",
  17467. "$modal",
  17468. "$rootScope",
  17469. "$http",
  17470. "up_down_file",
  17471. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17472. $scope.attachmentAddressSplicing = $rootScope.attachmentAddressSplicing;
  17473. var _refreshDelayPromise;
  17474. /**
  17475. * refresh
  17476. */
  17477. $scope._refresh = function (refreshAttr) {
  17478. $scope.attachments = [];
  17479. if (refreshAttr !== undefined) {
  17480. if (_refreshDelayPromise) {
  17481. $timeout.cancel(_refreshDelayPromise);
  17482. }
  17483. _refreshDelayPromise = $timeout(function () {
  17484. // 暂存附件
  17485. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17486. $scope.options.templateOptions
  17487. .refresh(
  17488. $scope.options.templateOptions.ApiService,
  17489. $scope.options.templateOptions.processInstanceId,
  17490. {
  17491. idx: 0,
  17492. sum: 1000,
  17493. }
  17494. )
  17495. .then(function (response) {
  17496. var myData =
  17497. $scope.options.templateOptions.Restangular.stripRestangular(
  17498. response
  17499. );
  17500. if (myData) {
  17501. for (var i = 0; i < myData.data.length; i++) {
  17502. $scope.attachments.push(myData.data[i]);
  17503. }
  17504. }
  17505. $scope.options.templateOptions
  17506. .refresh(
  17507. $scope.options.templateOptions.ApiService,
  17508. $scope.$parent.$parent.$parent.model.save_fileId,
  17509. {
  17510. idx: 0,
  17511. sum: 1000,
  17512. }
  17513. )
  17514. .then(function (response2) {
  17515. var myData2 =
  17516. $scope.options.templateOptions.Restangular.stripRestangular(
  17517. response2
  17518. );
  17519. if (myData2) {
  17520. for (var i = 0; i < myData2.data.length; i++) {
  17521. $scope.attachments.push(myData2.data[i]);
  17522. }
  17523. }
  17524. console.log($scope.attachments);
  17525. });
  17526. });
  17527. // 正常附件
  17528. } else {
  17529. $scope.options.templateOptions
  17530. .refresh(
  17531. $scope.options.templateOptions.ApiService,
  17532. $scope.options.templateOptions.processInstanceId,
  17533. {
  17534. idx: 0,
  17535. sum: 1000,
  17536. }
  17537. )
  17538. .then(function (response) {
  17539. var myData =
  17540. $scope.options.templateOptions.Restangular.stripRestangular(
  17541. response
  17542. );
  17543. if (myData) {
  17544. $scope.attachments = [];
  17545. $scope.imgs = [];
  17546. myData.data.forEach((e) => {
  17547. // if (
  17548. // e.suffix == "jpeg" ||
  17549. // e.suffix == "jpg" ||
  17550. // e.suffix == "svg" ||
  17551. // e.suffix == "png" ||
  17552. // e.suffix == "bmp" ||
  17553. // e.suffix == "gif" ||
  17554. // e.suffix == "tif"
  17555. // ) {
  17556. // $scope.imgs.push(e);
  17557. // }
  17558. $scope.imgs.push(e);
  17559. });
  17560. $scope.imgs = $scope.imgs;
  17561. console.log($scope.imgs);
  17562. }
  17563. });
  17564. }
  17565. }, $scope.options.templateOptions.refreshDelay);
  17566. }
  17567. };
  17568. $scope._refresh({});
  17569. // $scope.attachments = $scope.model[$scope.options.key]
  17570. // 预览
  17571. $scope.preview = function (url, idx) {
  17572. var title = $scope.imgs[idx].title;
  17573. $modal.open({
  17574. backdrop: false,
  17575. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17576. controller: function ($scope, $rootScope, scope, $modalInstance) {
  17577. $scope.title = title;
  17578. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  17579. $scope.cancel = function () {
  17580. $modalInstance.dismiss("cancel");
  17581. };
  17582. },
  17583. resolve: {
  17584. scope: function () {
  17585. return $scope;
  17586. },
  17587. },
  17588. });
  17589. };
  17590. },
  17591. ],
  17592. });
  17593. //工单/受理人控件
  17594. formlyConfigProvider.setType({
  17595. name: "ui-workernumbersign",
  17596. // extends: 'label',
  17597. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  17598. controller: [
  17599. "$scope",
  17600. function ($scope) {
  17601. // 2020年4月24日13:20:40
  17602. console.log($scope, "docu");
  17603. // 左侧事件工单区域地点填充
  17604. $scope.model.selecthouseNumber = $scope.model.place;
  17605. if (
  17606. angular.isUndefined($scope.model[$scope.options.key]) ||
  17607. $scope.model[$scope.options.key] == null
  17608. ) {
  17609. setTimeout(function () {
  17610. $scope.options.templateOptions
  17611. .getWorkernumber($scope.options.templateOptions.ApiService)
  17612. .then(function (result) {
  17613. var modelData =
  17614. $scope.options.templateOptions.Restangular.stripRestangular(
  17615. result
  17616. );
  17617. if (modelData.status == 200) {
  17618. $scope.model[$scope.options.key] = modelData.data;
  17619. $scope.options.initialValue =
  17620. $scope.model[$scope.options.key];
  17621. }
  17622. });
  17623. }, 1000);
  17624. }
  17625. if (
  17626. $scope.options.templateOptions.user &&
  17627. (angular.isUndefined($scope.model.acceptUser) ||
  17628. $scope.model.acceptUser == null)
  17629. ) {
  17630. if (angular.isFunction($scope.options.templateOptions.transform)) {
  17631. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  17632. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  17633. // }
  17634. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17635. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17636. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  17637. }
  17638. $scope.model.acceptUser = $scope.options.templateOptions.user;
  17639. // $scope.options.initialValue = $scope.model.acceptUser;
  17640. }
  17641. },
  17642. ],
  17643. });
  17644. //工单控件-only number
  17645. formlyConfigProvider.setType({
  17646. name: "ui-workernumber",
  17647. extends: "input",
  17648. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17649. controller: [
  17650. "$scope",
  17651. function ($scope) {
  17652. if (
  17653. angular.isUndefined($scope.model[$scope.options.key]) ||
  17654. $scope.model[$scope.options.key] == null
  17655. ) {
  17656. setTimeout(function () {
  17657. $scope.options.templateOptions
  17658. .getWorkernumber($scope.options.templateOptions.ApiService)
  17659. .then(function (result) {
  17660. var modelData =
  17661. $scope.options.templateOptions.Restangular.stripRestangular(
  17662. result
  17663. );
  17664. if (modelData.status == 200) {
  17665. $scope.model[$scope.options.key] = modelData.data;
  17666. $scope.options.initialValue =
  17667. $scope.model[$scope.options.key];
  17668. }
  17669. });
  17670. }, 1000);
  17671. }
  17672. },
  17673. ],
  17674. });
  17675. //cmdb工单
  17676. formlyConfigProvider.setType({
  17677. name: "ui-cmdbworkernumber",
  17678. extends: "input",
  17679. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17680. controller: [
  17681. "$scope",
  17682. function ($scope) {
  17683. if (
  17684. angular.isUndefined($scope.model[$scope.options.key]) ||
  17685. $scope.model[$scope.options.key] == null
  17686. ) {
  17687. setTimeout(function () {
  17688. $scope.options.templateOptions
  17689. .getWorkernumber(
  17690. $scope.options.templateOptions.ApiService,
  17691. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  17692. .cifilter_classics.id
  17693. )
  17694. .then(function (result) {
  17695. var modelData =
  17696. $scope.options.templateOptions.Restangular.stripRestangular(
  17697. result
  17698. );
  17699. // if(modelData.status==200){
  17700. $scope.model[$scope.options.key] =
  17701. modelData[$scope.options.key];
  17702. $scope.options.initialValue = $scope.model[$scope.options.key];
  17703. // }
  17704. });
  17705. }, 1000);
  17706. }
  17707. },
  17708. ],
  17709. });
  17710. //简易上传图片组件
  17711. formlyConfigProvider.setType({
  17712. name: "ui-uploadImgs",
  17713. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  17714. wrapper: ["bootstrapHasError"],
  17715. controller: [
  17716. "$scope",
  17717. "fileReader",
  17718. "$parse",
  17719. "$modal",
  17720. function ($scope, fileReader, $parse, $modal) {
  17721. $scope.imgshows = [];
  17722. $scope.uploadimgs = [];
  17723. var model = $parse("upload_img");
  17724. var modelSetter = model.assign;
  17725. var uploader = ($scope.uploader =
  17726. $scope.options.templateOptions.fileUploader);
  17727. uploader.filters.push({
  17728. name: "customFilter",
  17729. fn: function (item /*{File|FileLikeObject}*/, options) {
  17730. return this.queue.length < 10;
  17731. },
  17732. });
  17733. // 添加
  17734. $scope.change = function (event) {
  17735. var element = $(".upinp");
  17736. modelSetter($scope, element[0].files[0]);
  17737. //附件预览
  17738. $scope.imgupload = event.files[0];
  17739. getFile($scope.imgupload, $scope);
  17740. //获得预览图地址并且把file对象放入上传合集内
  17741. function getFile(imgupload, $scope) {
  17742. if (!imgupload) {
  17743. return;
  17744. }
  17745. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  17746. $scope.imgshows.push(result);
  17747. var file = document.querySelector("input[type=file]").files[0];
  17748. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  17749. console.log($scope.imgshows, $scope.uploadimgs);
  17750. if ($scope.imgshows.length < 3) {
  17751. $("#upup").show();
  17752. } else {
  17753. $("#upup").hide();
  17754. }
  17755. });
  17756. }
  17757. };
  17758. // 删除
  17759. $scope.uploadimg_del = function (index, imgs) {
  17760. console.log(index, imgs);
  17761. $scope.imgshows.splice(index, 1);
  17762. $scope.uploadimgs.splice(index, 1);
  17763. if ($scope.imgshows.length < 3) {
  17764. $("#upup").show();
  17765. } else {
  17766. $("#upup").hide();
  17767. }
  17768. };
  17769. // 预览
  17770. $scope.preview = function (url, idx) {
  17771. var name = $scope.uploadimgs[idx].name;
  17772. $modal.open({
  17773. backdrop: false,
  17774. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17775. controller: function ($scope, scope, $modalInstance) {
  17776. $scope.title = name;
  17777. $scope.imageurl = url;
  17778. $scope.cancel = function () {
  17779. $modalInstance.dismiss("cancel");
  17780. };
  17781. },
  17782. resolve: {
  17783. scope: function () {
  17784. return $scope;
  17785. },
  17786. },
  17787. });
  17788. };
  17789. if (uploader) {
  17790. uploader.onWhenAddingFileFailed = function (
  17791. item /*{File|FileLikeObject}*/,
  17792. filter,
  17793. options
  17794. ) {
  17795. console.info("onWhenAddingFileFailed", item, filter, options);
  17796. };
  17797. uploader.onAfterAddingFile = function (fileItem) {
  17798. console.info("onAfterAddingFile", fileItem);
  17799. };
  17800. uploader.onAfterAddingAll = function (addedFileItems) {
  17801. console.info("onAfterAddingAll", addedFileItems);
  17802. };
  17803. uploader.onBeforeUploadItem = function (item) {
  17804. console.info("onBeforeUploadItem", item);
  17805. };
  17806. uploader.onProgressItem = function (fileItem, progress) {
  17807. console.info("onProgressItem", fileItem, progress);
  17808. };
  17809. uploader.onProgressAll = function (progress) {
  17810. console.info("onProgressAll", progress);
  17811. };
  17812. uploader.onSuccessItem = function (
  17813. fileItem,
  17814. response,
  17815. status,
  17816. headers
  17817. ) {
  17818. console.info("onSuccessItem", fileItem, response, status, headers);
  17819. };
  17820. uploader.onErrorItem = function (
  17821. fileItem,
  17822. response,
  17823. status,
  17824. headers
  17825. ) {
  17826. console.info("onErrorItem", fileItem, response, status, headers);
  17827. };
  17828. uploader.onCancelItem = function (
  17829. fileItem,
  17830. response,
  17831. status,
  17832. headers
  17833. ) {
  17834. console.info("onCancelItem", fileItem, response, status, headers);
  17835. };
  17836. uploader.onCompleteItem = function (
  17837. fileItem,
  17838. response,
  17839. status,
  17840. headers
  17841. ) {
  17842. console.info("onCompleteItem", fileItem, response, status, headers);
  17843. };
  17844. uploader.onCompleteAll = function () {
  17845. console.info("onCompleteAll");
  17846. };
  17847. }
  17848. // console.log(modelSetter)
  17849. },
  17850. ],
  17851. });
  17852. //jry-上传下载一体
  17853. formlyConfigProvider.setType({
  17854. name: "ui-upDropFile",
  17855. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  17856. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17857. defaultOptions: function (options) {
  17858. return {
  17859. templateOptions: {
  17860. view: function (APIService, contentId) {
  17861. return APIService.downloadAttachment(contentId);
  17862. },
  17863. // ApiService: 'api_wechatfile',
  17864. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  17865. // upUrl: 'common/common/uploadAttachment',
  17866. // listAttachmentUrl: 'common/common/listAttachment',
  17867. // downUrl: 'common/common/downloadAttachment',
  17868. // bindType: 'incident',
  17869. // bindId: 2323
  17870. },
  17871. // validators: {
  17872. // required: {
  17873. // expression: function(viewValue, modelValue) {
  17874. // var value = modelValue || viewValue;
  17875. // return value.length >= 1;
  17876. // }
  17877. // }
  17878. // }
  17879. };
  17880. },
  17881. controller: [
  17882. "$scope",
  17883. "$rootScope",
  17884. "Restangular",
  17885. "up_down_file",
  17886. "$http",
  17887. "api_bpm",
  17888. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  17889. console.log($scope);
  17890. $scope.showFileUp = true;
  17891. if ($scope.model.isKnowledge_detail) {
  17892. $scope.showFileUp = false;
  17893. }
  17894. if (angular.isUndefined($scope.form.dropState)) {
  17895. $scope.form.dropState = false;
  17896. }
  17897. if ($scope.model.incident) {
  17898. if ($scope.model.incident.alarm) {
  17899. console.log($scope);
  17900. if ($scope.model.incident.alarm) {
  17901. if ($scope.model.incident.alarm.alarmExtension) {
  17902. $scope.model.incident.alarm.alarmExtension =
  17903. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  17904. $scope.model.incident.alarm.alarmExtension =
  17905. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  17906. $scope.model.incident.description =
  17907. $scope.model.incident.alarm.alarmExtension;
  17908. console.log($scope.model.incident.description);
  17909. $scope.model.incident.description =
  17910. '"' +
  17911. "告警名称" +
  17912. '":' +
  17913. '"' +
  17914. $scope.model.incident.alarm.alarmSystem +
  17915. '",' +
  17916. '"' +
  17917. "告警状态" +
  17918. '":' +
  17919. '"' +
  17920. $scope.model.incident.alarm.alarmStatus +
  17921. '",' +
  17922. '"' +
  17923. "告警内容" +
  17924. '":' +
  17925. '"' +
  17926. $scope.model.incident.alarm.alarmContent +
  17927. '",' +
  17928. $scope.model.incident.description;
  17929. } else {
  17930. $scope.model.incident.description =
  17931. '"' +
  17932. "告警名称" +
  17933. '":' +
  17934. '"' +
  17935. $scope.model.incident.alarm.alarmSystem +
  17936. '",' +
  17937. '"' +
  17938. "告警状态" +
  17939. '":' +
  17940. '"' +
  17941. $scope.model.incident.alarm.alarmStatus +
  17942. '",' +
  17943. '"' +
  17944. "告警内容" +
  17945. '":' +
  17946. '"' +
  17947. $scope.model.incident.alarm.alarmContent +
  17948. '",';
  17949. }
  17950. $scope.model.incident.description =
  17951. $scope.model.incident.description.replace(/,/g, "\n");
  17952. console.log($scope.model.incident.description);
  17953. }
  17954. }
  17955. api_bpm
  17956. .tellCategory($scope.model.incident.category.id)
  17957. .then(function (wt_data) {
  17958. console.log(wt_data);
  17959. if (wt_data) {
  17960. $rootScope.wt_category = wt_data.data;
  17961. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  17962. $rootScope.wt_child = wt_data.child;
  17963. }
  17964. });
  17965. if ($scope.model.titleName == "接单") {
  17966. $scope.model.receive_code = "handler";
  17967. if (
  17968. $scope.model.incident.groupLeader &&
  17969. !$scope.model.incident.repeat
  17970. ) {
  17971. $scope.model.isHandlerUser = true;
  17972. }
  17973. }
  17974. if ($scope.model.titleName == "事件处理") {
  17975. console.log($scope.model.cmdbCode);
  17976. if ($scope.model.cmdbCode) {
  17977. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  17978. }
  17979. }
  17980. } else {
  17981. $rootScope.wt_category = "";
  17982. }
  17983. //附件上传数据
  17984. if ($scope.options.templateOptions.fileUploader) {
  17985. var uploader = ($scope.uploader =
  17986. $scope.options.templateOptions.fileUploader);
  17987. //$scope.options.templateOptions.uploader();
  17988. console.log(uploader);
  17989. // FILTERS
  17990. uploader.filters.push({
  17991. name: "customFilter",
  17992. fn: function (item /*{File|FileLikeObject}*/, options) {
  17993. return this.queue.length < 10;
  17994. },
  17995. });
  17996. }
  17997. var to = $scope.options.templateOptions;
  17998. // var bindType = $scope.model.bindType;
  17999. if (to.bindType == "incident") {
  18000. var bindId = $scope.model[to.bindType].processInstanceId;
  18001. } else if (to.bindType == "change") {
  18002. var bindId = $scope.model[to.bindType].processInstanceId;
  18003. } else {
  18004. var bindId = $scope.model[to.bindType].id;
  18005. }
  18006. //获取附件列表
  18007. $scope.listAttachmen = function () {
  18008. to.ApiService.listAttachment(
  18009. to.listAttachmentUrl,
  18010. to.bindType,
  18011. bindId
  18012. ).then(function (result) {
  18013. var myData = Restangular.stripRestangular(result);
  18014. // $scope.listAttachmens = myData;
  18015. $scope.attachments = myData.data;
  18016. });
  18017. };
  18018. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  18019. $scope.listAttachmen();
  18020. } else if (to.bindType && $scope.model[to.bindType].id) {
  18021. $scope.listAttachmen();
  18022. }
  18023. //附件上传
  18024. $scope.isUpfload = to.isUpfload;
  18025. $scope.dropfile = function (
  18026. APIService,
  18027. processInstanceId,
  18028. taskId,
  18029. userId
  18030. ) {
  18031. uploader.onBeforeUploadItem = function (item) {
  18032. angular.extend(item.headers, $rootScope.getSession());
  18033. item.url = to.ApiService.saveAttachments(
  18034. to.uploadUrl,
  18035. to.bindType,
  18036. bindId
  18037. ).getRequestedUrl();
  18038. item.formData.push({
  18039. filename: item.file.name,
  18040. });
  18041. };
  18042. uploader.uploadAll();
  18043. };
  18044. //附件下载
  18045. $scope.download = function (token, filename) {
  18046. var downUrl = to.ApiService.downloadAttachment(
  18047. to.downUrl,
  18048. token
  18049. ).getRequestedUrl();
  18050. // window.open(downUrl);
  18051. var a = document.createElement("a");
  18052. a.href = downUrl;
  18053. a.target = "_blank";
  18054. a.download = filename;
  18055. document.body.appendChild(a);
  18056. a.click();
  18057. };
  18058. //附件预览
  18059. $scope.view = function (id, previewUrl) {
  18060. if (previewUrl) {
  18061. window.open(previewUrl);
  18062. }
  18063. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  18064. // if (response.state == 200) {
  18065. // window.open(response.previewUrl);
  18066. // }
  18067. // })
  18068. };
  18069. // CALLBACKS
  18070. if (uploader) {
  18071. uploader.onWhenAddingFileFailed = function (
  18072. item /*{File|FileLikeObject}*/,
  18073. filter,
  18074. options
  18075. ) {
  18076. console.info("onWhenAddingFileFailed", item, filter, options);
  18077. };
  18078. uploader.onAfterAddingFile = function (fileItem) {
  18079. console.info("onAfterAddingFile", fileItem);
  18080. };
  18081. uploader.onAfterAddingAll = function (addedFileItems) {
  18082. console.info("onAfterAddingAll", addedFileItems);
  18083. };
  18084. uploader.onBeforeUploadItem = function (item) {
  18085. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18086. // // $scope.uploader.options.url();
  18087. // $scope.uploader.onBeforeUploadItem = function(item) {
  18088. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18089. // console.info('onBeforeUploadItem', item);
  18090. // };
  18091. // $scope.uploader.uploadAll();
  18092. // }
  18093. console.info("onBeforeUploadItem", item);
  18094. };
  18095. uploader.onProgressItem = function (fileItem, progress) {
  18096. console.info("onProgressItem", fileItem, progress);
  18097. };
  18098. uploader.onProgressAll = function (progress) {
  18099. console.info("onProgressAll", progress);
  18100. };
  18101. uploader.onSuccessItem = function (
  18102. fileItem,
  18103. response,
  18104. status,
  18105. headers
  18106. ) {
  18107. console.info("onSuccessItem", fileItem, response, status, headers);
  18108. if (response.status == 200) {
  18109. $scope.listAttachmen();
  18110. }
  18111. };
  18112. uploader.onErrorItem = function (
  18113. fileItem,
  18114. response,
  18115. status,
  18116. headers
  18117. ) {
  18118. console.info("onErrorItem", fileItem, response, status, headers);
  18119. };
  18120. uploader.onCancelItem = function (
  18121. fileItem,
  18122. response,
  18123. status,
  18124. headers
  18125. ) {
  18126. console.info("onCancelItem", fileItem, response, status, headers);
  18127. };
  18128. uploader.onCompleteItem = function (
  18129. fileItem,
  18130. response,
  18131. status,
  18132. headers
  18133. ) {
  18134. console.info("onCompleteItem", fileItem, response, status, headers);
  18135. };
  18136. uploader.onCompleteAll = function () {
  18137. console.info("onCompleteAll");
  18138. };
  18139. }
  18140. },
  18141. ],
  18142. });
  18143. //简易上传下载附件组件
  18144. formlyConfigProvider.setType({
  18145. name: "ui-upDownFiles",
  18146. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  18147. wrapper: ["bootstrapHasError"],
  18148. defaultOptions: function (options) {
  18149. return {
  18150. templateOptions: {
  18151. refresh: function (APIService, processInstanceId, data) {
  18152. return APIService.listAttachments(processInstanceId);
  18153. },
  18154. downloadUri: function (APIService, contentId) {
  18155. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18156. },
  18157. view: function (APIService, contentId) {
  18158. return APIService.attachmentsPreviewUrl(contentId);
  18159. },
  18160. download: function (APIService, contentId, item) {
  18161. var item = {
  18162. url: APIService.download(contentId),
  18163. headers: headers,
  18164. };
  18165. return item;
  18166. },
  18167. refreshDelay: 0,
  18168. },
  18169. };
  18170. },
  18171. controller: [
  18172. "$scope",
  18173. "$timeout",
  18174. "$modal",
  18175. "$rootScope",
  18176. "$http",
  18177. "up_down_file",
  18178. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18179. if (angular.isUndefined($scope.form.dropState)) {
  18180. $scope.form.dropState = false;
  18181. }
  18182. //附件上传数据
  18183. var uploader = ($scope.uploader =
  18184. $scope.options.templateOptions.fileUploader);
  18185. //$scope.options.templateOptions.uploader();
  18186. // FILTERS
  18187. uploader.filters.push({
  18188. name: "customFilter",
  18189. fn: function (item /*{File|FileLikeObject}*/, options) {
  18190. return this.queue.length < 10;
  18191. },
  18192. });
  18193. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  18194. // uploader.onBeforeUploadItem = function (item) {
  18195. // angular.extend(item.headers, $rootScope.getSession());
  18196. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  18197. // item.formData.push({
  18198. // 'fileName': item.file.name
  18199. // });
  18200. // console.info('onBeforeUploadItem', item);
  18201. // };
  18202. // }
  18203. // CALLBACKS
  18204. uploader.onWhenAddingFileFailed = function (
  18205. item /*{File|FileLikeObject}*/,
  18206. filter,
  18207. options
  18208. ) {
  18209. console.info("onWhenAddingFileFailed", item, filter, options);
  18210. };
  18211. uploader.onAfterAddingFile = function (fileItem) {
  18212. console.info("onAfterAddingFile", fileItem);
  18213. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18214. alert("文件过大");
  18215. fileItem.uploader.queue.pop();
  18216. console.log($scope);
  18217. }
  18218. };
  18219. uploader.onAfterAddingAll = function (addedFileItems) {
  18220. // console.info('onAfterAddingAll', addedFileItems);
  18221. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18222. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18223. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18224. // console.log(123)
  18225. };
  18226. uploader.onBeforeUploadItem = function (item) {
  18227. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18228. // // $scope.uploader.options.url();
  18229. // $scope.uploader.onBeforeUploadItem = function(item) {
  18230. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18231. // console.info('onBeforeUploadItem', item);
  18232. // };
  18233. // $scope.uploader.uploadAll();
  18234. // }
  18235. console.info("onBeforeUploadItem", item);
  18236. };
  18237. uploader.onProgressItem = function (fileItem, progress) {
  18238. console.info("onProgressItem", fileItem, progress);
  18239. };
  18240. uploader.onProgressAll = function (progress) {
  18241. console.info("onProgressAll", progress);
  18242. };
  18243. uploader.onSuccessItem = function (
  18244. fileItem,
  18245. response,
  18246. status,
  18247. headers
  18248. ) {
  18249. console.info("onSuccessItem", fileItem, response, status, headers);
  18250. };
  18251. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18252. console.info("onErrorItem", fileItem, response, status, headers);
  18253. };
  18254. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18255. console.info("onCancelItem", fileItem, response, status, headers);
  18256. };
  18257. uploader.onCompleteItem = function (
  18258. fileItem,
  18259. response,
  18260. status,
  18261. headers
  18262. ) {
  18263. console.info("onCompleteItem", fileItem, response, status, headers);
  18264. };
  18265. uploader.onCompleteAll = function () {
  18266. console.info("onCompleteAll");
  18267. };
  18268. var _refreshDelayPromise;
  18269. // 下载
  18270. $scope.download = function (contentId, filename, token) {
  18271. // console.log(contentId, filename, token)
  18272. //附件下载
  18273. var downUrl = up_down_file
  18274. .downloadAttachment("common/common/downloadAttachment", token)
  18275. .getRequestedUrl();
  18276. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18277. // console.log(downUrl)
  18278. var a = document.createElement("a");
  18279. a.href = downUrl;
  18280. a.target = "_blank";
  18281. a.download = filename;
  18282. document.body.appendChild(a);
  18283. a.click();
  18284. };
  18285. $scope._refresh = function (refreshAttr) {
  18286. $scope.attachments = [];
  18287. if (refreshAttr !== undefined) {
  18288. if (_refreshDelayPromise) {
  18289. $timeout.cancel(_refreshDelayPromise);
  18290. }
  18291. _refreshDelayPromise = $timeout(function () {
  18292. // 暂存附件
  18293. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18294. $scope.options.templateOptions
  18295. .refresh(
  18296. $scope.options.templateOptions.ApiService,
  18297. $scope.options.templateOptions.processInstanceId,
  18298. {
  18299. idx: 0,
  18300. sum: 1000,
  18301. }
  18302. )
  18303. .then(function (response) {
  18304. var myData =
  18305. $scope.options.templateOptions.Restangular.stripRestangular(
  18306. response
  18307. );
  18308. if (myData) {
  18309. for (var i = 0; i < myData.data.length; i++) {
  18310. $scope.attachments.push(myData.data[i]);
  18311. }
  18312. }
  18313. $scope.options.templateOptions
  18314. .refresh(
  18315. $scope.options.templateOptions.ApiService,
  18316. $scope.$parent.$parent.$parent.model.save_fileId,
  18317. {
  18318. idx: 0,
  18319. sum: 1000,
  18320. }
  18321. )
  18322. .then(function (response2) {
  18323. var myData2 =
  18324. $scope.options.templateOptions.Restangular.stripRestangular(
  18325. response2
  18326. );
  18327. if (myData2) {
  18328. for (var i = 0; i < myData2.data.length; i++) {
  18329. $scope.attachments.push(myData2.data[i]);
  18330. }
  18331. // 只展示除图片以外的附件
  18332. var a = [];
  18333. $scope.attachments.forEach((e) => {
  18334. if (
  18335. e.suffix == "jpeg" ||
  18336. e.suffix == "jpg" ||
  18337. e.suffix == "svg" ||
  18338. e.suffix == "png" ||
  18339. e.suffix == "bmp" ||
  18340. e.suffix == "gif" ||
  18341. e.suffix == "tif"
  18342. ) {
  18343. // $scope.imgs.push(e)
  18344. } else {
  18345. a.push(e);
  18346. }
  18347. });
  18348. $scope.attachments = a;
  18349. }
  18350. console.log($scope.attachments);
  18351. });
  18352. });
  18353. // 正常附件
  18354. } else {
  18355. $scope.options.templateOptions
  18356. .refresh(
  18357. $scope.options.templateOptions.ApiService,
  18358. $scope.options.templateOptions.processInstanceId,
  18359. {
  18360. idx: 0,
  18361. sum: 1000,
  18362. }
  18363. )
  18364. .then(function (response) {
  18365. var myData =
  18366. $scope.options.templateOptions.Restangular.stripRestangular(
  18367. response
  18368. );
  18369. if (myData) {
  18370. $scope.attachments = myData.data;
  18371. // 只展示除图片以外的附件
  18372. var a = [];
  18373. $scope.attachments.forEach((e) => {
  18374. if (
  18375. e.suffix == "jpeg" ||
  18376. e.suffix == "jpg" ||
  18377. e.suffix == "svg" ||
  18378. e.suffix == "png" ||
  18379. e.suffix == "bmp" ||
  18380. e.suffix == "gif" ||
  18381. e.suffix == "tif"
  18382. ) {
  18383. // $scope.imgs.push(e)
  18384. } else {
  18385. a.push(e);
  18386. }
  18387. });
  18388. $scope.attachments = a;
  18389. }
  18390. });
  18391. }
  18392. }, $scope.options.templateOptions.refreshDelay);
  18393. }
  18394. };
  18395. $scope._refresh({});
  18396. },
  18397. ],
  18398. });
  18399. //简易上传附件组件
  18400. formlyConfigProvider.setType({
  18401. name: "ui-uploadFiles",
  18402. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  18403. wrapper: ["bootstrapHasError"],
  18404. controller: [
  18405. "$scope",
  18406. function ($scope) {
  18407. if (angular.isUndefined($scope.form.dropState)) {
  18408. $scope.form.dropState = false;
  18409. }
  18410. //附件上传数据
  18411. var uploader = ($scope.uploader =
  18412. $scope.options.templateOptions.fileUploader);
  18413. //$scope.options.templateOptions.uploader();
  18414. // FILTERS
  18415. uploader.filters.push({
  18416. name: "customFilter",
  18417. fn: function (item /*{File|FileLikeObject}*/, options) {
  18418. return this.queue.length < 10;
  18419. },
  18420. });
  18421. $scope.dropfile = function (
  18422. APIService,
  18423. processInstanceId,
  18424. taskId,
  18425. userId
  18426. ) {
  18427. uploader.onBeforeUploadItem = function (item) {
  18428. angular.extend(item.headers, $rootScope.getSession());
  18429. item.url = APIService.saveAttachments(
  18430. processInstanceId,
  18431. taskId,
  18432. userId
  18433. ).getRequestedUrl();
  18434. item.formData.push({
  18435. fileName: item.file.name,
  18436. });
  18437. console.info("onBeforeUploadItem", item);
  18438. };
  18439. };
  18440. // CALLBACKS
  18441. uploader.onWhenAddingFileFailed = function (
  18442. item /*{File|FileLikeObject}*/,
  18443. filter,
  18444. options
  18445. ) {
  18446. console.info("onWhenAddingFileFailed", item, filter, options);
  18447. };
  18448. uploader.onAfterAddingFile = function (fileItem) {
  18449. console.info("onAfterAddingFile", fileItem);
  18450. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18451. alert("文件过大");
  18452. fileItem.uploader.queue.pop();
  18453. console.log($scope);
  18454. }
  18455. };
  18456. uploader.onAfterAddingAll = function (addedFileItems) {
  18457. // console.info('onAfterAddingAll', addedFileItems);
  18458. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18459. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18460. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18461. // console.log(123)
  18462. };
  18463. uploader.onBeforeUploadItem = function (item) {
  18464. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18465. // // $scope.uploader.options.url();
  18466. // $scope.uploader.onBeforeUploadItem = function(item) {
  18467. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18468. // console.info('onBeforeUploadItem', item);
  18469. // };
  18470. // $scope.uploader.uploadAll();
  18471. // }
  18472. console.info("onBeforeUploadItem", item);
  18473. };
  18474. uploader.onProgressItem = function (fileItem, progress) {
  18475. console.info("onProgressItem", fileItem, progress);
  18476. };
  18477. uploader.onProgressAll = function (progress) {
  18478. console.info("onProgressAll", progress);
  18479. };
  18480. uploader.onSuccessItem = function (
  18481. fileItem,
  18482. response,
  18483. status,
  18484. headers
  18485. ) {
  18486. console.info("onSuccessItem", fileItem, response, status, headers);
  18487. };
  18488. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18489. console.info("onErrorItem", fileItem, response, status, headers);
  18490. };
  18491. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18492. console.info("onCancelItem", fileItem, response, status, headers);
  18493. };
  18494. uploader.onCompleteItem = function (
  18495. fileItem,
  18496. response,
  18497. status,
  18498. headers
  18499. ) {
  18500. console.info("onCompleteItem", fileItem, response, status, headers);
  18501. };
  18502. uploader.onCompleteAll = function () {
  18503. console.info("onCompleteAll");
  18504. };
  18505. },
  18506. ],
  18507. });
  18508. //无上传按钮附件上传组件
  18509. formlyConfigProvider.setType({
  18510. name: "ui-dropfilenotup",
  18511. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18512. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18513. controller: [
  18514. "$scope",
  18515. function ($scope) {
  18516. if (angular.isUndefined($scope.form.dropState)) {
  18517. $scope.form.dropState = false;
  18518. }
  18519. //附件上传数据
  18520. var uploader = ($scope.uploader =
  18521. $scope.options.templateOptions.fileUploader);
  18522. //$scope.options.templateOptions.uploader();
  18523. // FILTERS
  18524. uploader.filters.push({
  18525. name: "customFilter",
  18526. fn: function (item /*{File|FileLikeObject}*/, options) {
  18527. return this.queue.length < 10;
  18528. },
  18529. });
  18530. $scope.dropfile = function (
  18531. APIService,
  18532. processInstanceId,
  18533. taskId,
  18534. userId
  18535. ) {
  18536. uploader.onBeforeUploadItem = function (item) {
  18537. angular.extend(item.headers, $rootScope.getSession());
  18538. item.url = APIService.saveAttachments(
  18539. processInstanceId,
  18540. taskId,
  18541. userId
  18542. ).getRequestedUrl();
  18543. item.formData.push({
  18544. fileName: item.file.name,
  18545. });
  18546. console.info("onBeforeUploadItem", item);
  18547. };
  18548. uploader.uploadAll();
  18549. };
  18550. // CALLBACKS
  18551. uploader.onWhenAddingFileFailed = function (
  18552. item /*{File|FileLikeObject}*/,
  18553. filter,
  18554. options
  18555. ) {
  18556. console.info("onWhenAddingFileFailed", item, filter, options);
  18557. };
  18558. uploader.onAfterAddingFile = function (fileItem) {
  18559. console.info("onAfterAddingFile", fileItem);
  18560. };
  18561. uploader.onAfterAddingAll = function (addedFileItems) {
  18562. console.info("onAfterAddingAll", addedFileItems);
  18563. };
  18564. uploader.onBeforeUploadItem = function (item) {
  18565. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18566. // // $scope.uploader.options.url();
  18567. // $scope.uploader.onBeforeUploadItem = function(item) {
  18568. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18569. // console.info('onBeforeUploadItem', item);
  18570. // };
  18571. // $scope.uploader.uploadAll();
  18572. // }
  18573. console.info("onBeforeUploadItem", item);
  18574. };
  18575. uploader.onProgressItem = function (fileItem, progress) {
  18576. console.info("onProgressItem", fileItem, progress);
  18577. };
  18578. uploader.onProgressAll = function (progress) {
  18579. console.info("onProgressAll", progress);
  18580. };
  18581. uploader.onSuccessItem = function (
  18582. fileItem,
  18583. response,
  18584. status,
  18585. headers
  18586. ) {
  18587. console.info("onSuccessItem", fileItem, response, status, headers);
  18588. };
  18589. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18590. console.info("onErrorItem", fileItem, response, status, headers);
  18591. };
  18592. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18593. console.info("onCancelItem", fileItem, response, status, headers);
  18594. };
  18595. uploader.onCompleteItem = function (
  18596. fileItem,
  18597. response,
  18598. status,
  18599. headers
  18600. ) {
  18601. console.info("onCompleteItem", fileItem, response, status, headers);
  18602. };
  18603. uploader.onCompleteAll = function () {
  18604. console.info("onCompleteAll");
  18605. };
  18606. },
  18607. ],
  18608. });
  18609. //无按钮知识库上传
  18610. formlyConfigProvider.setType({
  18611. name: "ui-dropfielkn",
  18612. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18613. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18614. controller: [
  18615. "$scope",
  18616. function ($scope) {
  18617. if (angular.isUndefined($scope.form.dropState)) {
  18618. $scope.form.dropState = false;
  18619. }
  18620. //附件上传数据
  18621. var uploader = ($scope.uploader =
  18622. $scope.options.templateOptions.fileUploader);
  18623. //$scope.options.templateOptions.uploader();
  18624. // FILTERS
  18625. uploader.filters.push({
  18626. name: "customFilter",
  18627. fn: function (item /*{File|FileLikeObject}*/, options) {
  18628. return this.queue.length < 10;
  18629. },
  18630. });
  18631. $scope.dropfile = function (
  18632. APIService,
  18633. processInstanceId,
  18634. taskId,
  18635. userId
  18636. ) {
  18637. uploader.onBeforeUploadItem = function (item) {
  18638. angular.extend(item.headers, $rootScope.getSession());
  18639. item.url = APIService.addFile(
  18640. processInstanceId,
  18641. taskId,
  18642. userId
  18643. ).getRequestedUrl();
  18644. item.formData.push({
  18645. fileName: item.file.name,
  18646. });
  18647. console.info("onBeforeUploadItem", item);
  18648. };
  18649. uploader.uploadAll();
  18650. };
  18651. // CALLBACKS
  18652. uploader.onWhenAddingFileFailed = function (
  18653. item /*{File|FileLikeObject}*/,
  18654. filter,
  18655. options
  18656. ) {
  18657. console.info("onWhenAddingFileFailed", item, filter, options);
  18658. };
  18659. uploader.onAfterAddingFile = function (fileItem) {
  18660. console.info("onAfterAddingFile", fileItem);
  18661. };
  18662. uploader.onAfterAddingAll = function (addedFileItems) {
  18663. console.info("onAfterAddingAll", addedFileItems);
  18664. };
  18665. uploader.onBeforeUploadItem = function (item) {
  18666. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18667. // // $scope.uploader.options.url();
  18668. // $scope.uploader.onBeforeUploadItem = function(item) {
  18669. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18670. // console.info('onBeforeUploadItem', item);
  18671. // };
  18672. // $scope.uploader.uploadAll();
  18673. // }
  18674. console.info("onBeforeUploadItem", item);
  18675. };
  18676. uploader.onProgressItem = function (fileItem, progress) {
  18677. console.info("onProgressItem", fileItem, progress);
  18678. };
  18679. uploader.onProgressAll = function (progress) {
  18680. console.info("onProgressAll", progress);
  18681. };
  18682. uploader.onSuccessItem = function (
  18683. fileItem,
  18684. response,
  18685. status,
  18686. headers
  18687. ) {
  18688. console.info("onSuccessItem", fileItem, response, status, headers);
  18689. };
  18690. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18691. console.info("onErrorItem", fileItem, response, status, headers);
  18692. };
  18693. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18694. console.info("onCancelItem", fileItem, response, status, headers);
  18695. };
  18696. uploader.onCompleteItem = function (
  18697. fileItem,
  18698. response,
  18699. status,
  18700. headers
  18701. ) {
  18702. console.info("onCompleteItem", fileItem, response, status, headers);
  18703. };
  18704. uploader.onCompleteAll = function () {
  18705. console.info("onCompleteAll");
  18706. };
  18707. },
  18708. ],
  18709. });
  18710. //附件上传列表组件
  18711. formlyConfigProvider.setType({
  18712. name: "ui-dropfile",
  18713. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18714. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18715. controller: [
  18716. "$scope",
  18717. "$rootScope",
  18718. function ($scope, $rootScope) {
  18719. if (angular.isUndefined($scope.form.dropState)) {
  18720. $scope.form.dropState = false;
  18721. }
  18722. //附件上传数据
  18723. var uploader = ($scope.uploader =
  18724. $scope.options.templateOptions.fileUploader);
  18725. //$scope.options.templateOptions.uploader();
  18726. // FILTERS
  18727. uploader.filters.push({
  18728. name: "customFilter",
  18729. fn: function (item /*{File|FileLikeObject}*/, options) {
  18730. return this.queue.length < 10;
  18731. },
  18732. });
  18733. $scope.dropfile = function (
  18734. APIService,
  18735. processInstanceId,
  18736. taskId,
  18737. userId
  18738. ) {
  18739. uploader.onBeforeUploadItem = function (item) {
  18740. angular.extend(item.headers, $rootScope.getSession());
  18741. if (
  18742. $scope.options.templateOptions.upservice &&
  18743. $scope.options.templateOptions.formname
  18744. ) {
  18745. // if ($scope.options.templateOptions.formket) {
  18746. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  18747. // } else {
  18748. item.url = APIService[$scope.options.templateOptions.upservice](
  18749. $scope.model[$scope.options.templateOptions.formname].id,
  18750. taskId,
  18751. userId
  18752. ).getRequestedUrl();
  18753. // }
  18754. } else {
  18755. item.url = APIService.saveAttachments(
  18756. processInstanceId,
  18757. taskId,
  18758. userId
  18759. ).getRequestedUrl();
  18760. }
  18761. item.formData.push({
  18762. filename: item.file.name,
  18763. });
  18764. console.info("onBeforeUploadItem", item);
  18765. };
  18766. uploader.uploadAll();
  18767. };
  18768. // CALLBACKS
  18769. uploader.onWhenAddingFileFailed = function (
  18770. item /*{File|FileLikeObject}*/,
  18771. filter,
  18772. options
  18773. ) {
  18774. console.info("onWhenAddingFileFailed", item, filter, options);
  18775. };
  18776. uploader.onAfterAddingFile = function (fileItem) {
  18777. console.info("onAfterAddingFile", fileItem);
  18778. };
  18779. uploader.onAfterAddingAll = function (addedFileItems) {
  18780. console.info("onAfterAddingAll", addedFileItems);
  18781. };
  18782. uploader.onBeforeUploadItem = function (item) {
  18783. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18784. // // $scope.uploader.options.url();
  18785. // $scope.uploader.onBeforeUploadItem = function(item) {
  18786. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18787. // console.info('onBeforeUploadItem', item);
  18788. // };
  18789. // $scope.uploader.uploadAll();
  18790. // }
  18791. console.info("onBeforeUploadItem", item);
  18792. };
  18793. uploader.onProgressItem = function (fileItem, progress) {
  18794. console.info("onProgressItem", fileItem, progress);
  18795. };
  18796. uploader.onProgressAll = function (progress) {
  18797. console.info("onProgressAll", progress);
  18798. };
  18799. uploader.onSuccessItem = function (
  18800. fileItem,
  18801. response,
  18802. status,
  18803. headers
  18804. ) {
  18805. console.info("onSuccessItem", fileItem, response, status, headers);
  18806. };
  18807. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18808. console.info("onErrorItem", fileItem, response, status, headers);
  18809. };
  18810. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18811. console.info("onCancelItem", fileItem, response, status, headers);
  18812. };
  18813. uploader.onCompleteItem = function (
  18814. fileItem,
  18815. response,
  18816. status,
  18817. headers
  18818. ) {
  18819. console.info("onCompleteItem", fileItem, response, status, headers);
  18820. };
  18821. uploader.onCompleteAll = function () {
  18822. console.info("onCompleteAll");
  18823. };
  18824. },
  18825. ],
  18826. });
  18827. //简易附件展示下载列表组件
  18828. formlyConfigProvider.setType({
  18829. name: "ui-dropFiles",
  18830. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  18831. defaultOptions: function (options) {
  18832. return {
  18833. templateOptions: {
  18834. refresh: function (APIService, processInstanceId, data) {
  18835. return APIService.listAttachments(processInstanceId);
  18836. },
  18837. downloadUri: function (APIService, contentId) {
  18838. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18839. },
  18840. view: function (APIService, contentId) {
  18841. return APIService.attachmentsPreviewUrl(contentId);
  18842. },
  18843. download: function (APIService, contentId, item) {
  18844. var item = {
  18845. url: APIService.download(contentId),
  18846. headers: headers,
  18847. };
  18848. return item;
  18849. },
  18850. refreshDelay: 0,
  18851. },
  18852. };
  18853. },
  18854. controller: [
  18855. "$scope",
  18856. "$timeout",
  18857. "$modal",
  18858. "$rootScope",
  18859. "$http",
  18860. "up_down_file",
  18861. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18862. var _refreshDelayPromise;
  18863. // $scope.downloadUrl = function(contentId){
  18864. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18865. // };
  18866. $scope.download = function (contentId, filename, token) {
  18867. // console.log(contentId, filename, token)
  18868. //附件下载
  18869. var downUrl = up_down_file
  18870. .downloadAttachment("common/common/downloadAttachment", token)
  18871. .getRequestedUrl();
  18872. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18873. // console.log(downUrl)
  18874. var a = document.createElement("a");
  18875. a.href = downUrl;
  18876. a.target = "_blank";
  18877. a.download = filename;
  18878. document.body.appendChild(a);
  18879. a.click();
  18880. };
  18881. $scope.view = function (contentId, token, filename, type) {
  18882. $scope.options.templateOptions
  18883. .view($scope.options.templateOptions.ApiService, contentId)
  18884. .then(function (response) {
  18885. if (response.state == 200) {
  18886. window.open(response.previewUrl);
  18887. }
  18888. });
  18889. };
  18890. /**
  18891. * refresh
  18892. */
  18893. $scope._refresh = function (refreshAttr) {
  18894. $scope.attachments = [];
  18895. if (refreshAttr !== undefined) {
  18896. if (_refreshDelayPromise) {
  18897. $timeout.cancel(_refreshDelayPromise);
  18898. }
  18899. _refreshDelayPromise = $timeout(function () {
  18900. // 暂存附件
  18901. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18902. $scope.options.templateOptions
  18903. .refresh(
  18904. $scope.options.templateOptions.ApiService,
  18905. $scope.options.templateOptions.processInstanceId,
  18906. {
  18907. idx: 0,
  18908. sum: 1000,
  18909. }
  18910. )
  18911. .then(function (response) {
  18912. var myData =
  18913. $scope.options.templateOptions.Restangular.stripRestangular(
  18914. response
  18915. );
  18916. if (myData) {
  18917. for (var i = 0; i < myData.data.length; i++) {
  18918. $scope.attachments.push(myData.data[i]);
  18919. }
  18920. }
  18921. $scope.options.templateOptions
  18922. .refresh(
  18923. $scope.options.templateOptions.ApiService,
  18924. $scope.$parent.$parent.$parent.model.save_fileId,
  18925. {
  18926. idx: 0,
  18927. sum: 1000,
  18928. }
  18929. )
  18930. .then(function (response2) {
  18931. var myData2 =
  18932. $scope.options.templateOptions.Restangular.stripRestangular(
  18933. response2
  18934. );
  18935. if (myData2) {
  18936. for (var i = 0; i < myData2.data.length; i++) {
  18937. $scope.attachments.push(myData2.data[i]);
  18938. }
  18939. // 只展示除图片以外的附件
  18940. var a = [];
  18941. $scope.attachments.forEach((e) => {
  18942. if (
  18943. e.suffix == "jpeg" ||
  18944. e.suffix == "jpg" ||
  18945. e.suffix == "svg" ||
  18946. e.suffix == "png" ||
  18947. e.suffix == "bmp" ||
  18948. e.suffix == "gif" ||
  18949. e.suffix == "tif"
  18950. ) {
  18951. // $scope.imgs.push(e)
  18952. } else {
  18953. a.push(e);
  18954. }
  18955. });
  18956. $scope.attachments = a;
  18957. }
  18958. console.log($scope.attachments);
  18959. });
  18960. });
  18961. // 正常附件
  18962. } else {
  18963. $scope.options.templateOptions
  18964. .refresh(
  18965. $scope.options.templateOptions.ApiService,
  18966. $scope.options.templateOptions.processInstanceId,
  18967. {
  18968. idx: 0,
  18969. sum: 1000,
  18970. }
  18971. )
  18972. .then(function (response) {
  18973. var myData =
  18974. $scope.options.templateOptions.Restangular.stripRestangular(
  18975. response
  18976. );
  18977. if (myData) {
  18978. $scope.attachments = myData.data;
  18979. // 只展示除图片以外的附件
  18980. var a = [];
  18981. $scope.attachments.forEach((e) => {
  18982. if (
  18983. e.suffix == "jpeg" ||
  18984. e.suffix == "jpg" ||
  18985. e.suffix == "svg" ||
  18986. e.suffix == "png" ||
  18987. e.suffix == "bmp" ||
  18988. e.suffix == "gif" ||
  18989. e.suffix == "tif"
  18990. ) {
  18991. // $scope.imgs.push(e)
  18992. } else {
  18993. a.push(e);
  18994. }
  18995. });
  18996. $scope.attachments = a;
  18997. console.log($scope.attachments);
  18998. }
  18999. });
  19000. }
  19001. }, $scope.options.templateOptions.refreshDelay);
  19002. }
  19003. };
  19004. $scope._refresh({});
  19005. // $scope.attachments = $scope.model[$scope.options.key]
  19006. },
  19007. ],
  19008. });
  19009. //知识库附件上传
  19010. formlyConfigProvider.setType({
  19011. name: "ui-dropfielknow",
  19012. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  19013. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  19014. controller: [
  19015. "$scope",
  19016. "$rootScope",
  19017. function ($scope, $rootScope) {
  19018. if (angular.isUndefined($scope.form.dropState)) {
  19019. $scope.form.dropState = false;
  19020. }
  19021. //附件上传数据
  19022. var uploader = ($scope.uploader =
  19023. $scope.options.templateOptions.fileUploader);
  19024. //$scope.options.templateOptions.uploader();
  19025. // FILTERS
  19026. uploader.filters.push({
  19027. name: "customFilter",
  19028. fn: function (item /*{File|FileLikeObject}*/, options) {
  19029. return this.queue.length < 10;
  19030. },
  19031. });
  19032. $scope.dropfile = function (
  19033. APIService,
  19034. processInstanceId,
  19035. taskId,
  19036. userId
  19037. ) {
  19038. uploader.onBeforeUploadItem = function (item) {
  19039. angular.extend(item.headers, $rootScope.getSession());
  19040. item.url = APIService.upload(
  19041. processInstanceId,
  19042. taskId,
  19043. userId
  19044. ).getRequestedUrl();
  19045. item.formData.push({
  19046. fileName: item.file.name,
  19047. type: "solution",
  19048. solutionId: $scope.model.knowledge.id,
  19049. });
  19050. console.info("onBeforeUploadItem", item);
  19051. };
  19052. uploader.uploadAll();
  19053. };
  19054. // CALLBACKS
  19055. uploader.onWhenAddingFileFailed = function (
  19056. item /*{File|FileLikeObject}*/,
  19057. filter,
  19058. options
  19059. ) {
  19060. console.info("onWhenAddingFileFailed", item, filter, options);
  19061. };
  19062. uploader.onAfterAddingFile = function (fileItem) {
  19063. console.info("onAfterAddingFile", fileItem);
  19064. };
  19065. uploader.onAfterAddingAll = function (addedFileItems) {
  19066. console.info("onAfterAddingAll", addedFileItems);
  19067. };
  19068. uploader.onBeforeUploadItem = function (item) {
  19069. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  19070. // // $scope.uploader.options.url();
  19071. // $scope.uploader.onBeforeUploadItem = function(item) {
  19072. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  19073. // console.info('onBeforeUploadItem', item);
  19074. // };
  19075. // $scope.uploader.uploadAll();
  19076. // }
  19077. console.info("onBeforeUploadItem", item);
  19078. };
  19079. uploader.onProgressItem = function (fileItem, progress) {
  19080. console.info("onProgressItem", fileItem, progress);
  19081. };
  19082. uploader.onProgressAll = function (progress) {
  19083. console.info("onProgressAll", progress);
  19084. };
  19085. uploader.onSuccessItem = function (
  19086. fileItem,
  19087. response,
  19088. status,
  19089. headers
  19090. ) {
  19091. console.info("onSuccessItem", fileItem, response, status, headers);
  19092. };
  19093. uploader.onErrorItem = function (fileItem, response, status, headers) {
  19094. console.info("onErrorItem", fileItem, response, status, headers);
  19095. };
  19096. uploader.onCancelItem = function (fileItem, response, status, headers) {
  19097. console.info("onCancelItem", fileItem, response, status, headers);
  19098. };
  19099. uploader.onCompleteItem = function (
  19100. fileItem,
  19101. response,
  19102. status,
  19103. headers
  19104. ) {
  19105. console.info("onCompleteItem", fileItem, response, status, headers);
  19106. };
  19107. uploader.onCompleteAll = function () {
  19108. console.info("onCompleteAll");
  19109. };
  19110. },
  19111. ],
  19112. });
  19113. //知识库附件下载列表
  19114. formlyConfigProvider.setType({
  19115. name: "ui-dropfileknowledge",
  19116. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  19117. defaultOptions: function (options) {
  19118. return {
  19119. templateOptions: {
  19120. refresh: function (APIService, contentId, data) {
  19121. return APIService.fetchDataList(contentId, data);
  19122. },
  19123. downloadUri: function (APIService, contentId) {
  19124. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19125. },
  19126. download: function (APIService, contentId) {
  19127. return APIService.getSolutionDowpath(contentId);
  19128. },
  19129. view: function (attachmentId) {
  19130. // return APIService.attachmentsPreviewUrl(contentId);
  19131. },
  19132. refreshDelay: 0,
  19133. },
  19134. };
  19135. },
  19136. controller: [
  19137. "$scope",
  19138. "$timeout",
  19139. "$modal",
  19140. "$rootScope",
  19141. "api_solution",
  19142. "$http",
  19143. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  19144. var _refreshDelayPromise;
  19145. $scope.attachments = [];
  19146. $scope.downloadUrl = function (contentId) {
  19147. return (
  19148. $scope.options.templateOptions.downloadUri(
  19149. $scope.options.templateOptions.ApiService,
  19150. contentId
  19151. ) || "#"
  19152. );
  19153. };
  19154. $scope.download = function (contentId, filename) {
  19155. $http({
  19156. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  19157. contentId
  19158. ).getRequestedUrl(),
  19159. method: "GET",
  19160. headers: {
  19161. //'Content-type' : 'application/xls',
  19162. Accept: "*/*",
  19163. },
  19164. responseType: "arraybuffer",
  19165. })
  19166. .success(function (data, status, headers, config) {
  19167. var file = new Blob([data], {
  19168. type: "application/octet-stream",
  19169. });
  19170. //trick to download store a file having its URL
  19171. var fileURL = URL.createObjectURL(file);
  19172. var a = document.createElement("a");
  19173. a.href = fileURL;
  19174. a.target = "_blank";
  19175. a.download = filename;
  19176. document.body.appendChild(a);
  19177. a.click();
  19178. })
  19179. .error(function (data, status, headers, config) {
  19180. // console.log(data);
  19181. });
  19182. };
  19183. $scope.view = function (contentId, filename, attachment) {
  19184. var index = filename.indexOf(".");
  19185. var type = filename.substring(index + 1);
  19186. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19187. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  19188. // var modalInstance = $modal.open({
  19189. // backdrop: false,
  19190. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19191. // controller: function($scope, scope, $modalInstance, filename) {
  19192. // $scope.title = filename;
  19193. // $scope.imageurl = scope.imageurl;
  19194. // $scope.cancel = function() {
  19195. // $modalInstance.dismiss('cancel');
  19196. // }
  19197. // },
  19198. // resolve: {
  19199. // scope: function() {
  19200. // return $scope;
  19201. // },
  19202. // filename: function() {
  19203. // return filename;
  19204. // }
  19205. // }
  19206. // });
  19207. // event.preventDefault();
  19208. // } else {
  19209. // for (var i = 0; i < $scope.attachments.length; i++) {
  19210. // if ($scope.attachments[i].id == attachmentId) {
  19211. window.open(attachment.previewUrl);
  19212. // }
  19213. // }
  19214. // }
  19215. };
  19216. $scope._refresh = function (refreshAttr) {
  19217. if (refreshAttr !== undefined) {
  19218. if (_refreshDelayPromise) {
  19219. $timeout.cancel(_refreshDelayPromise);
  19220. }
  19221. _refreshDelayPromise = $timeout(function () {
  19222. $scope.options.templateOptions
  19223. .refresh($scope.options.templateOptions.ApiService, "file", {
  19224. file: {
  19225. solutionId: $scope.model.knowledge.id,
  19226. },
  19227. idx: "0",
  19228. sum: "1000",
  19229. })
  19230. .then(function (response) {
  19231. var myData =
  19232. $scope.options.templateOptions.Restangular.stripRestangular(
  19233. response
  19234. );
  19235. if (myData) {
  19236. $scope.attachments = myData.list;
  19237. // $scope.view = function(attachmentId) {
  19238. // for (var i = 0; i < $scope.attachments.length; i++) {
  19239. // if ($scope.attachments[i].id == attachmentId) {
  19240. // window.open($scope.attachments[i].previewUrl);
  19241. // // var modalInstance = $modal.open({
  19242. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  19243. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  19244. // // }
  19245. // // });
  19246. // }
  19247. // }
  19248. // };
  19249. }
  19250. });
  19251. }, $scope.options.templateOptions.refreshDelay);
  19252. }
  19253. };
  19254. $scope._refresh({});
  19255. // $scope.attachments = $scope.model[$scope.options.key]
  19256. },
  19257. ],
  19258. });
  19259. //附件图片下载
  19260. formlyConfigProvider.setType({
  19261. name: "ui-downimage",
  19262. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  19263. defaultOptions: function (options) {
  19264. return {
  19265. templateOptions: {
  19266. refresh: function (APIService, processInstanceId, data) {
  19267. return APIService.listAttachments(processInstanceId, data);
  19268. },
  19269. downloadUri: function (APIService, contentId) {
  19270. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19271. },
  19272. view: function (APIService, contentId) {
  19273. return APIService.attachmentsPreviewUrl(contentId);
  19274. },
  19275. download: function (APIService, contentId, item) {
  19276. var item = {
  19277. url: APIService.download(contentId),
  19278. headers: headers,
  19279. };
  19280. return item;
  19281. },
  19282. refreshDelay: 0,
  19283. },
  19284. };
  19285. },
  19286. controller: [
  19287. "$scope",
  19288. "$timeout",
  19289. "$rootScope",
  19290. "$http",
  19291. function ($scope, $timeout, $rootScope, $http) {
  19292. var _refreshDelayPromise;
  19293. // $scope.downloadUrl = function(contentId){
  19294. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19295. // };
  19296. $scope.download = function (contentId, filename) {
  19297. // var headers=
  19298. $http({
  19299. url: $scope.options.templateOptions.ApiService.download(
  19300. contentId
  19301. ).getRequestedUrl(),
  19302. method: "GET",
  19303. headers: {
  19304. //'Content-type' : 'application/xls',
  19305. Accept: "*/*",
  19306. },
  19307. responseType: "arraybuffer",
  19308. })
  19309. .success(function (data, status, headers, config) {
  19310. var file = new Blob([data], {
  19311. type: "application/octet-stream",
  19312. });
  19313. //trick to download store a file having its URL
  19314. var fileURL = URL.createObjectURL(file);
  19315. var a = document.createElement("a");
  19316. a.href = fileURL;
  19317. a.target = "_blank";
  19318. a.download = filename;
  19319. document.body.appendChild(a);
  19320. a.click();
  19321. })
  19322. .error(function (data, status, headers, config) {
  19323. // console.log(data);
  19324. });
  19325. };
  19326. $scope.view = function (contentId) {
  19327. $scope.imageurl =
  19328. $scope.options.templateOptions.ApiService.download(
  19329. contentId
  19330. ).getRequestedUrl();
  19331. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  19332. // if (response.state == 200) {
  19333. // window.open(response.previewUrl);
  19334. // }
  19335. // })
  19336. };
  19337. /**
  19338. * refresh
  19339. */
  19340. $scope._refresh = function (refreshAttr) {
  19341. if (refreshAttr !== undefined) {
  19342. if (_refreshDelayPromise) {
  19343. $timeout.cancel(_refreshDelayPromise);
  19344. }
  19345. _refreshDelayPromise = $timeout(function () {
  19346. $scope.options.templateOptions
  19347. .refresh(
  19348. $scope.options.templateOptions.ApiService,
  19349. $scope.options.templateOptions.processInstanceId,
  19350. {
  19351. idx: 0,
  19352. sum: 1000,
  19353. }
  19354. )
  19355. .then(function (response) {
  19356. var myData =
  19357. $scope.options.templateOptions.Restangular.stripRestangular(
  19358. response
  19359. );
  19360. if (myData) {
  19361. $scope.attachments = myData.data;
  19362. }
  19363. });
  19364. }, $scope.options.templateOptions.refreshDelay);
  19365. }
  19366. };
  19367. $scope._refresh({});
  19368. // $scope.attachments = $scope.model[$scope.options.key]
  19369. },
  19370. ],
  19371. });
  19372. //附件下载列表组件
  19373. formlyConfigProvider.setType({
  19374. name: "ui-dropfiletable",
  19375. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  19376. defaultOptions: function (options) {
  19377. return {
  19378. templateOptions: {
  19379. refresh: function (APIService, processInstanceId, data) {
  19380. return APIService.listAttachments(processInstanceId, data);
  19381. },
  19382. downloadUri: function (APIService, contentId) {
  19383. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19384. },
  19385. view: function (APIService, contentId) {
  19386. return APIService.attachmentsPreviewUrl(contentId);
  19387. },
  19388. download: function (APIService, contentId, item) {
  19389. var item = {
  19390. url: APIService.download(contentId),
  19391. headers: headers,
  19392. };
  19393. return item;
  19394. },
  19395. refreshDelay: 0,
  19396. },
  19397. };
  19398. },
  19399. controller: [
  19400. "$scope",
  19401. "$timeout",
  19402. "$modal",
  19403. "$rootScope",
  19404. "$http",
  19405. function ($scope, $timeout, $modal, $rootScope, $http) {
  19406. var _refreshDelayPromise;
  19407. // $scope.downloadUrl = function(contentId){
  19408. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19409. // };
  19410. $scope.download = function (contentId, filename) {
  19411. // var headers=
  19412. $http({
  19413. url: $scope.options.templateOptions.ApiService.download(
  19414. contentId
  19415. ).getRequestedUrl(),
  19416. method: "GET",
  19417. headers: {
  19418. //'Content-type' : 'application/xls',
  19419. Accept: "*/*",
  19420. },
  19421. responseType: "arraybuffer",
  19422. })
  19423. .success(function (data, status, headers, config) {
  19424. var file = new Blob([data], {
  19425. type: "application/octet-stream",
  19426. });
  19427. //trick to download store a file having its URL
  19428. var fileURL = URL.createObjectURL(file);
  19429. var a = document.createElement("a");
  19430. a.href = fileURL;
  19431. a.target = "_blank";
  19432. a.download = filename;
  19433. document.body.appendChild(a);
  19434. a.click();
  19435. })
  19436. .error(function (data, status, headers, config) {
  19437. // console.log(data);
  19438. });
  19439. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  19440. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  19441. // var file = new Blob([response], {
  19442. // type : 'application/octet-stream'
  19443. // });
  19444. // // var filename = filename;
  19445. // //var file = new Blob([response], {type: 'application/pdf'});
  19446. // var fileURL = URL.createObjectURL(file);
  19447. // var a = document.createElement('a');
  19448. // a.href = fileURL;
  19449. // a.target = '_blank';
  19450. // a.download = filename ;
  19451. // document.body.appendChild(a);
  19452. // a.click();
  19453. // })
  19454. };
  19455. $scope.view = function (contentId, token, filename, type) {
  19456. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19457. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  19458. // var modalInstance = $modal.open({
  19459. // backdrop: false,
  19460. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19461. // controller: function($scope, scope, $modalInstance, filename) {
  19462. // $scope.title = filename;
  19463. // $scope.imageurl = scope.imageurl;
  19464. // $scope.cancel = function() {
  19465. // $modalInstance.dismiss('cancel');
  19466. // }
  19467. // },
  19468. // resolve: {
  19469. // scope: function() {
  19470. // return $scope;
  19471. // },
  19472. // filename: function() {
  19473. // return filename;
  19474. // }
  19475. // }
  19476. // });
  19477. // event.preventDefault();
  19478. // } else {
  19479. $scope.options.templateOptions
  19480. .view($scope.options.templateOptions.ApiService, contentId)
  19481. .then(function (response) {
  19482. if (response.state == 200) {
  19483. window.open(response.previewUrl);
  19484. }
  19485. });
  19486. // }
  19487. };
  19488. /**
  19489. * refresh
  19490. */
  19491. $scope._refresh = function (refreshAttr) {
  19492. if (refreshAttr !== undefined) {
  19493. if (_refreshDelayPromise) {
  19494. $timeout.cancel(_refreshDelayPromise);
  19495. }
  19496. _refreshDelayPromise = $timeout(function () {
  19497. $scope.options.templateOptions
  19498. .refresh(
  19499. $scope.options.templateOptions.ApiService,
  19500. $scope.options.templateOptions.processInstanceId,
  19501. {
  19502. idx: 0,
  19503. sum: 1000,
  19504. }
  19505. )
  19506. .then(function (response) {
  19507. var myData =
  19508. $scope.options.templateOptions.Restangular.stripRestangular(
  19509. response
  19510. );
  19511. if (myData) {
  19512. $scope.attachments = myData.data;
  19513. }
  19514. });
  19515. }, $scope.options.templateOptions.refreshDelay);
  19516. }
  19517. };
  19518. $scope._refresh({});
  19519. // $scope.attachments = $scope.model[$scope.options.key]
  19520. },
  19521. ],
  19522. });
  19523. //微信附件下载列表组件
  19524. formlyConfigProvider.setType({
  19525. name: "ui-dropfilewechat",
  19526. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  19527. defaultOptions: function (options) {
  19528. return {
  19529. templateOptions: {
  19530. // refresh: function(APIService, processInstanceId, data) {
  19531. // return APIService.listAttachments(processInstanceId, data);
  19532. // },
  19533. // downloadUri: function(APIService, contentId) {
  19534. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  19535. // },
  19536. view: function (APIService, contentId) {
  19537. // return APIService.attachmentsPreviewUrl(contentId);
  19538. return APIService.attachmentsPreviewUrl(contentId);
  19539. },
  19540. download: function (APIService, contentId, item) {
  19541. var item = {
  19542. url: APIService.download(contentId),
  19543. headers: headers,
  19544. };
  19545. return item;
  19546. },
  19547. // download: function(APIService, contentId, item) {
  19548. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  19549. // return item;
  19550. // },
  19551. refreshDelay: 0,
  19552. },
  19553. };
  19554. },
  19555. controller: [
  19556. "$scope",
  19557. "$timeout",
  19558. "$modal",
  19559. "$stateParams",
  19560. "$rootScope",
  19561. "$http",
  19562. "api_wechatfile",
  19563. function (
  19564. $scope,
  19565. $timeout,
  19566. $modal,
  19567. $stateParams,
  19568. $rootScope,
  19569. $http,
  19570. api_wechatfile
  19571. ) {
  19572. var _refreshDelayPromise;
  19573. // $scope.downloadUrl = function(contentId){
  19574. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19575. // };
  19576. $scope.attachments = {};
  19577. $scope.previewUrl = "";
  19578. $scope.download = function (token, filename) {
  19579. // var headers=
  19580. console.log($scope);
  19581. $http({
  19582. url: $scope.options.templateOptions.ApiService.jry_download(
  19583. token
  19584. ).getRequestedUrl(),
  19585. method: "GET",
  19586. headers: {
  19587. //'Content-type' : 'application/xls',
  19588. Accept: "*/*",
  19589. },
  19590. responseType: "arraybuffer",
  19591. })
  19592. .success(function (data, status, headers, config) {
  19593. var file = new Blob([data], {
  19594. type: "application/octet-stream",
  19595. });
  19596. //trick to download store a file having its URL
  19597. var fileURL = URL.createObjectURL(file);
  19598. var a = document.createElement("a");
  19599. a.href = fileURL;
  19600. a.target = "_blank";
  19601. a.download = filename;
  19602. document.body.appendChild(a);
  19603. a.click();
  19604. })
  19605. .error(function (data, status, headers, config) {
  19606. // console.log(data);
  19607. });
  19608. };
  19609. $scope.view = function (contentId, token, filename, type, previewUrl) {
  19610. // if (type) {
  19611. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  19612. // var modalInstance = $modal.open({
  19613. // backdrop: false,
  19614. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19615. // controller: function($scope, scope, $modalInstance, filename) {
  19616. // $scope.title = filename;
  19617. // $scope.imageurl = scope.imageurl;
  19618. // $scope.cancel = function() {
  19619. // $modalInstance.dismiss('cancel');
  19620. // }
  19621. // },
  19622. // resolve: {
  19623. // scope: function() {
  19624. // return $scope;
  19625. // },
  19626. // filename: function() {
  19627. // return filename;
  19628. // }
  19629. // }
  19630. // });
  19631. // event.preventDefault();
  19632. // } else {
  19633. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  19634. // if (response.state == 200) {
  19635. // window.open(response.previewUrl);
  19636. // }
  19637. // })
  19638. window.open(previewUrl);
  19639. // }
  19640. };
  19641. /**
  19642. * refresh
  19643. */
  19644. $scope._refresh = function (refreshAttr) {
  19645. if (refreshAttr !== undefined) {
  19646. if (_refreshDelayPromise) {
  19647. $timeout.cancel(_refreshDelayPromise);
  19648. }
  19649. _refreshDelayPromise = $timeout(function () {
  19650. // console.log(JSON.parse($stateParams.model))
  19651. var incidentChart = {};
  19652. if ($stateParams.model) {
  19653. incidentChart = JSON.parse($stateParams.model).model;
  19654. }
  19655. $scope.options.templateOptions
  19656. .refresh(
  19657. $scope.options.templateOptions.ApiService,
  19658. $scope.model
  19659. )
  19660. .then(function (response) {
  19661. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  19662. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  19663. var myData =
  19664. $scope.options.templateOptions.Restangular.stripRestangular(
  19665. response
  19666. );
  19667. if (myData) {
  19668. $scope.attachments = myData.data;
  19669. }
  19670. });
  19671. }, $scope.options.templateOptions.refreshDelay);
  19672. }
  19673. };
  19674. $scope._refresh({});
  19675. // $scope.attachments = $scope.model[$scope.options.key]
  19676. },
  19677. ],
  19678. });
  19679. formlyConfigProvider.setType({
  19680. name: "ui-paralleltask",
  19681. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  19682. defaultOptions: function (options) {
  19683. return {
  19684. templateOptions: {
  19685. refresh: function (APIService, processInstanceId, data) {
  19686. //return APIService.listAttachments(processInstanceId, data);
  19687. },
  19688. refreshDelay: 0,
  19689. },
  19690. };
  19691. },
  19692. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  19693. });
  19694. //repeatSection
  19695. //
  19696. formlyConfigProvider.setType({
  19697. name: "ui-repeatSection",
  19698. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  19699. defaultOptions: function (options) {
  19700. return {
  19701. templateOptions: {
  19702. unique: 1,
  19703. initDisplay: false,
  19704. },
  19705. };
  19706. },
  19707. controller: function ($scope) {
  19708. //$scope.options.templateOptions.unique;
  19709. $scope.formOptions = {
  19710. formState: $scope.formState,
  19711. };
  19712. $scope.addNew = addNew;
  19713. $scope.copyFields = copyFields;
  19714. function copyFields(fields) {
  19715. fields = angular.copy(fields);
  19716. addRandomIds(fields);
  19717. return fields;
  19718. }
  19719. function addNew() {
  19720. $scope.model[$scope.options.key] =
  19721. $scope.model[$scope.options.key] || [];
  19722. var repeatsection = $scope.model[$scope.options.key];
  19723. var lastSection = repeatsection[repeatsection.length - 1];
  19724. var newsection = {};
  19725. repeatsection.push(newsection);
  19726. }
  19727. function addRandomIds(fields) {
  19728. $scope.options.templateOptions.unique++;
  19729. angular.forEach(fields, function (field, index) {
  19730. if (field.fieldGroup) {
  19731. addRandomIds(field.fieldGroup);
  19732. return; // fieldGroups don't need an ID
  19733. }
  19734. if (field.templateOptions && field.templateOptions.fields) {
  19735. addRandomIds(field.templateOptions.fields);
  19736. }
  19737. field.id =
  19738. field.id ||
  19739. field.key +
  19740. "_" +
  19741. index +
  19742. "_" +
  19743. $scope.options.templateOptions.unique +
  19744. getRandomInt(0, 9999);
  19745. });
  19746. }
  19747. function getRandomInt(min, max) {
  19748. return Math.floor(Math.random() * (max - min)) + min;
  19749. }
  19750. if ($scope.options.templateOptions.initDisplay) {
  19751. addNew();
  19752. }
  19753. },
  19754. });
  19755. //时间轴任务列表组件
  19756. //cmdb控件
  19757. formlyConfigProvider.setType({
  19758. name: "ui-cmdb",
  19759. extends: "input",
  19760. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  19761. defaultOptions: function (options) {
  19762. return {
  19763. templateOptions: {
  19764. onClick: function (size, options, modal, event, model) {
  19765. var modalInstance = modal.open({
  19766. templateUrl:
  19767. "assets/views/customform/tpl/cmdb-modal-content.html",
  19768. controller: function (
  19769. $scope,
  19770. $modalInstance,
  19771. title,
  19772. Restangular,
  19773. APIService,
  19774. ConfigDataService,
  19775. ConfigFormService,
  19776. SweetAlert,
  19777. Toaster,
  19778. api_wechatfile
  19779. ) {
  19780. var width = ($scope.width = 600);
  19781. var height = ($scope.height = 400);
  19782. var tree;
  19783. var d3 = window.d3;
  19784. $scope.my_tree_handler = function (branch) {
  19785. //var _ref;
  19786. var classify = ($scope.classify =
  19787. branch.prefix.toLowerCase() + branch.sign);
  19788. APIService.query({
  19789. sign: classify,
  19790. }).then(function (data) {
  19791. var myData = Restangular.stripRestangular(data);
  19792. // console.log(myData.data.node);
  19793. if (myData.data && myData.status == 200) {
  19794. var ret = myData.data;
  19795. redrawSvg(myData);
  19796. }
  19797. });
  19798. };
  19799. $scope.my_data = [];
  19800. function convertListToTree(data, treeMap) {
  19801. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  19802. var root = null; //Initially set our loop to null
  19803. var parentNode = null;
  19804. //loop over data
  19805. for (var i = 0; i < data.length; i++) {
  19806. var datum = data[i];
  19807. //each node will have children, so let's give it a "children" poperty
  19808. datum.children = [];
  19809. //add an entry for this node to the map so that any future children can
  19810. //lookup the parent
  19811. idToNodeMap[datum.id] = datum;
  19812. //Does this node have a parent?
  19813. if (
  19814. typeof datum.parent === "undefined" ||
  19815. datum.parent == null
  19816. ) {
  19817. //Doesn't look like it, so this node is the root of the tree
  19818. root = datum;
  19819. treeMap[datum.id] = root;
  19820. } else {
  19821. //This node has a parent, so let's look it up using the id
  19822. parentNode = idToNodeMap[datum.parent.id];
  19823. //We don't need this property, so let's delete it.
  19824. delete datum.parent;
  19825. //Let's add the current node as a child of the parent node.
  19826. parentNode.children.push(datum);
  19827. }
  19828. }
  19829. return root;
  19830. }
  19831. function convertParentToChildList(data) {
  19832. var treeMap = {};
  19833. var list = [];
  19834. convertListToTree(data, treeMap);
  19835. angular.forEach(treeMap, function (item) {
  19836. list.push(item);
  19837. });
  19838. return list;
  19839. }
  19840. $scope.my_tree = tree = {};
  19841. $scope.try_async_load = function () {
  19842. $scope.my_data = [];
  19843. $scope.select_treedata = [];
  19844. $scope.doing_async = true;
  19845. ConfigDataService.fetchDataList("ciclassify", {
  19846. idx: 0,
  19847. sum: 100,
  19848. }).then(function (result) {
  19849. $scope.select_treedata = $scope.my_data =
  19850. convertParentToChildList(result["list"]);
  19851. $scope.doing_async = false;
  19852. });
  19853. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  19854. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  19855. // $scope.doing_async = false;
  19856. // });
  19857. };
  19858. $scope.select_treedata = [];
  19859. $scope.propTypeOptions = [];
  19860. $scope.try_async_load();
  19861. $scope.onFilterCallback = function (item) {
  19862. //console.log(item);
  19863. if (
  19864. angular.isDefined(item.children) &&
  19865. item.children.length >= 1
  19866. ) {
  19867. //not valid
  19868. } else {
  19869. var tempclassify = item.prefix.toLowerCase() + item.sign;
  19870. $scope.cifilter_classic = tempclassify;
  19871. ConfigFormService.renderTabForm(tempclassify).then(
  19872. function (data) {
  19873. var myData = Restangular.stripRestangular(data);
  19874. $scope.propTypeOptions = myData;
  19875. }
  19876. );
  19877. }
  19878. };
  19879. $scope.onPropTypeChange = function (form) {
  19880. $scope.propOptions = form.fields;
  19881. };
  19882. $scope.onPropChange = function (prop) {
  19883. $scope.cifilter_prop = prop;
  19884. };
  19885. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  19886. //if(searchKey!=null&&searchKey.length>1){
  19887. var searchData = {};
  19888. if (angular.isUndefined(propObj)) {
  19889. propObj = $scope.cifilter_prop;
  19890. }
  19891. if (angular.isUndefined(ciclassify)) {
  19892. ciclassify = $scope.cifilter_classic;
  19893. }
  19894. searchData["sign"] = ciclassify;
  19895. if (angular.isDefined(propObj)) {
  19896. searchData[propObj.key] = searchKey;
  19897. }
  19898. APIService.query(searchData).then(function (response) {
  19899. var data = Restangular.stripRestangular(response);
  19900. //此处不清空nodes
  19901. var node = data.data.node;
  19902. var tempNode = [];
  19903. //nodes 或者links 要去重
  19904. for (var i = 0; i < node.length; i++) {
  19905. var tmp = 0;
  19906. for (var j = 0; j < nodes.length; j++) {
  19907. if (node[i].uuid == nodes[j].uuid) {
  19908. tmp++;
  19909. break;
  19910. }
  19911. }
  19912. if (tmp == 0) {
  19913. tempNode.push(node[i]);
  19914. }
  19915. }
  19916. for (var i = 0; i < tempNode.length; i++) {
  19917. //nodes 不清空
  19918. nodes.push(tempNode[i]);
  19919. }
  19920. restart();
  19921. });
  19922. };
  19923. $scope.refresh = function () {
  19924. nodes.length = 0;
  19925. links.length = 0;
  19926. restart();
  19927. };
  19928. $scope.traversal = function () {
  19929. if ($scope.selected_node == null) {
  19930. SweetAlert.swal({
  19931. title: "错误的操作!",
  19932. text: "没有配置项被选中!",
  19933. type: "error",
  19934. });
  19935. } else {
  19936. var uuid = $scope.selected_node.uuid;
  19937. APIService.traversal(uuid).then(function (response) {
  19938. var d = response.data;
  19939. var node = d.node;
  19940. var link = d.edge;
  19941. var tempNode = [];
  19942. var tempLink = [];
  19943. //nodes 或者links 要去重
  19944. for (var i = 0; i < node.length; i++) {
  19945. var tmp = 0;
  19946. for (var j = 0; j < nodes.length; j++) {
  19947. if (node[i].id == nodes[j].id) {
  19948. tmp++;
  19949. break;
  19950. }
  19951. }
  19952. if (tmp == 0) {
  19953. tempNode.push(node[i]);
  19954. }
  19955. }
  19956. for (var i = 0; i < link.length; i++) {
  19957. var tmp = 0;
  19958. for (var j = 0; j < links.length; j++) {
  19959. if (link[i].id == links[j].id) {
  19960. tmp++;
  19961. break;
  19962. }
  19963. }
  19964. if (tmp == 0) {
  19965. tempLink.push(link[i]);
  19966. }
  19967. }
  19968. //数据写入页面
  19969. for (var i = 0; i < tempNode.length; i++) {
  19970. //nodes 不清空
  19971. nodes.push(tempNode[i]);
  19972. }
  19973. for (var i = 0; i < tempLink.length; i++) {
  19974. //link 不清空
  19975. links.push(tempLink[i]);
  19976. }
  19977. //links转换
  19978. for (var i = 0; i < links.length; i++) {
  19979. for (var j = 0; j < nodes.length; j++) {
  19980. if (links[i].source == nodes[j].id) {
  19981. links[i].source = nodes[j];
  19982. }
  19983. if (links[i].target == nodes[j].id) {
  19984. links[i].target = nodes[j];
  19985. }
  19986. }
  19987. }
  19988. restart();
  19989. });
  19990. }
  19991. };
  19992. var svg;
  19993. var force;
  19994. var drag_line, path, circle;
  19995. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  19996. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19997. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19998. var nodes = [],
  19999. links = [];
  20000. var treeNodes = [];
  20001. //读取labels (node)
  20002. var labels = [];
  20003. function redrawSvg(json) {
  20004. nodes.length = 0; //先清空
  20005. links.length = 0;
  20006. var data = json.data;
  20007. for (var i = 0; i < data.node.length; i++) {
  20008. nodes.push(data.node[i]);
  20009. }
  20010. restart();
  20011. }
  20012. //读取status (节点 连线)
  20013. var statuses = [];
  20014. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  20015. // if (result && result.status == 200) {
  20016. // d3.select('#nodeStatus').selectAll('option')
  20017. // .data(statuses).enter()
  20018. // .append('option')
  20019. // .attr('value', function(d) { return d.code; })
  20020. // .html(function(d) { return d.desc; });
  20021. // } else {
  20022. // SweetAlert.swal({
  20023. // title: "提示!",
  20024. // text: "服务器请求异常!",
  20025. // type: "error"
  20026. // });
  20027. // }
  20028. // });
  20029. api_wechatfile
  20030. .getDictionary({
  20031. key: "cmdb_status",
  20032. type: "list",
  20033. })
  20034. .then(function (result) {
  20035. if (result) {
  20036. d3.select("#nodeStatus")
  20037. .selectAll("option")
  20038. .data(statuses)
  20039. .enter()
  20040. .append("option")
  20041. .attr("value", function (d) {
  20042. return d.code;
  20043. })
  20044. .html(function (d) {
  20045. return d.desc;
  20046. });
  20047. } else {
  20048. SweetAlert.swal({
  20049. title: "提示!",
  20050. text: "服务器请求异常!",
  20051. type: "error",
  20052. });
  20053. }
  20054. });
  20055. //查询relationship_type表 name 为表里的type,label为显示值
  20056. var linkType = [];
  20057. function fetchEdgeTypes() {
  20058. ConfigDataService.fetchDataList("ciedgetype", {
  20059. idx: 0,
  20060. sum: 100,
  20061. }).then(function (response) {
  20062. if (response) {
  20063. if (response["list"]) {
  20064. linkType = response["list"];
  20065. // d3.select('#linkName').selectAll('option')
  20066. // .data(linkType).enter()
  20067. // .append('option')
  20068. // .attr('value',function(d){return d.type;})
  20069. // .html(function(d){ return d.label;});
  20070. } else {
  20071. SweetAlert.swal({
  20072. title: "提示!",
  20073. text: "服务器请求异常!",
  20074. type: "error",
  20075. });
  20076. }
  20077. } else {
  20078. SweetAlert.swal({
  20079. title: "提示!",
  20080. text: "服务器请求异常!",
  20081. type: "error",
  20082. });
  20083. }
  20084. });
  20085. }
  20086. // fetchEdgeTypes();
  20087. /*
  20088. // init D3 force layout
  20089. var force = d3.layout.force()
  20090. .nodes(nodes)
  20091. .links(links)
  20092. .size([width, height])
  20093. .gravity(.05)
  20094. .linkDistance(150)
  20095. .linkStrength(2)
  20096. .charge(-500)
  20097. .on('tick', tick);
  20098. // define arrow markers for graph links
  20099. svg.append('svg:defs').append('svg:marker')
  20100. .attr('id', 'end-arrow')
  20101. .attr('viewBox', '0 -5 10 10')
  20102. .attr('refX', 6)
  20103. .attr('markerWidth', 3)
  20104. .attr('markerHeight', 3)
  20105. .attr('orient', 'auto')
  20106. .append('svg:path')
  20107. .attr('d', 'M0,-5L10,0L0,5')
  20108. .attr('fill', '#000');
  20109. svg.append('svg:defs').append('svg:marker')
  20110. .attr('id', 'start-arrow')
  20111. .attr('viewBox', '0 -5 10 10')
  20112. .attr('refX', 4)
  20113. .attr('markerWidth', 3)
  20114. .attr('markerHeight', 3)
  20115. .attr('orient', 'auto')
  20116. .append('svg:path')
  20117. .attr('d', 'M10,-5L0,0L10,5')
  20118. .attr('fill', '#000');
  20119. // line displayed when dragging new nodes
  20120. var drag_line = svg.append('svg:path')
  20121. .attr('class', 'link dragline hidden')
  20122. .attr('d', 'M0,0L0,0');
  20123. // handles to link and node element groups
  20124. //(1)var path = svg.append('svg:g').selectAll('g')
  20125. var path = svg.append('svg:g').selectAll('g'),
  20126. circle = svg.append('svg:g').selectAll('g');
  20127. */
  20128. // mouse event vars
  20129. var selected_node = null,
  20130. selected_link = null,
  20131. mousedown_link = null,
  20132. mousedown_node = null,
  20133. mouseup_node = null;
  20134. function resetMouseVars() {
  20135. mousedown_node = null;
  20136. mouseup_node = null;
  20137. mousedown_link = null;
  20138. }
  20139. // update force layout (called automatically each iteration)
  20140. function tick() {
  20141. // draw directed edges with proper padding from node centers
  20142. path.selectAll("path").attr("d", function (d) {
  20143. var deltaX = d.target.x - d.source.x,
  20144. deltaY = d.target.y - d.source.y,
  20145. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  20146. normX = deltaX / dist,
  20147. normY = deltaY / dist,
  20148. sourcePadding = d.left ? 27 : 22,
  20149. targetPadding = d.right ? 27 : 22,
  20150. sourceX = d.source.x + sourcePadding * normX,
  20151. sourceY = d.source.y + sourcePadding * normY,
  20152. targetX = d.target.x - targetPadding * normX,
  20153. targetY = d.target.y - targetPadding * normY;
  20154. return (
  20155. "M" +
  20156. sourceX +
  20157. "," +
  20158. sourceY +
  20159. "L" +
  20160. targetX +
  20161. "," +
  20162. targetY
  20163. );
  20164. });
  20165. circle.attr("transform", function (d) {
  20166. return "translate(" + d.x + "," + d.y + ")";
  20167. });
  20168. }
  20169. // update graph (called when needed)
  20170. function restart() {
  20171. //绑定link 数据
  20172. path.datum(links);
  20173. // path (link) group
  20174. path = path.data(links, function (d) {
  20175. return d.id;
  20176. });
  20177. var p = path.enter().append("svg:g");
  20178. //update existing links
  20179. path
  20180. .selectAll("path")
  20181. .classed("selected", function (d) {
  20182. return d === selected_link;
  20183. })
  20184. .style("marker-start", function (d) {
  20185. return d.left ? "url(#start-arrow)" : "";
  20186. })
  20187. .style("marker-end", function (d) {
  20188. return d.right ? "url(#end-arrow)" : "";
  20189. });
  20190. // add new links
  20191. p.append("svg:path")
  20192. .attr("class", "link")
  20193. .attr("id", function (d) {
  20194. return "path_" + d.id;
  20195. })
  20196. // .attr('startOffset', '0%')
  20197. .classed("selected", function (d) {
  20198. return d === selected_link;
  20199. })
  20200. .style("marker-start", function (d) {
  20201. return d.left ? "url(#start-arrow)" : "";
  20202. })
  20203. .style("marker-end", function (d) {
  20204. return d.right ? "url(#end-arrow)" : "";
  20205. })
  20206. .on("mousedown", function (d) {
  20207. if (d3.event.ctrlKey) return;
  20208. //去除没有提交的连线
  20209. for (var i = 0; i < links.length; i++) {
  20210. if (links[i].id == -1 && d.id != -1) {
  20211. links.splice(i, 1);
  20212. }
  20213. }
  20214. // select link
  20215. mousedown_link = d;
  20216. if (mousedown_link === selected_link) {
  20217. selected_link = $scope.selected_link = null;
  20218. selected_node = $scope.selected_node = null;
  20219. // d3.select("#linkDetail").attr('style','display:none');
  20220. //hideLinkForm(true);//return ;
  20221. } else {
  20222. selected_link = $scope.selected_link = mousedown_link;
  20223. selected_node = $scope.selected_node = null;
  20224. }
  20225. selected_node = $scope.selected_node = null;
  20226. restart();
  20227. });
  20228. p.append("svg:text")
  20229. .attr("x", 30)
  20230. .attr("y", 20)
  20231. .attr("class", "fontM")
  20232. .append("textPath")
  20233. .attr("xlink:xlink:href", function (d, i) {
  20234. return "#path_" + d.id;
  20235. })
  20236. .html(function (d) {
  20237. for (var i = 0; i < linkType.length; i++) {
  20238. if (linkType[i].type == d.name) {
  20239. return linkType[i].label;
  20240. }
  20241. }
  20242. });
  20243. // remove old links
  20244. path.exit().remove();
  20245. // circle (node) group
  20246. // NB: the function arg is crucial here! nodes are known by id, not by index!
  20247. circle.datum(nodes);
  20248. circle = circle.data(nodes, function (d) {
  20249. return d.id;
  20250. });
  20251. // update existing nodes (reflexive & selected visual states)
  20252. circle
  20253. .selectAll("circle")
  20254. .style("fill", function (d) {
  20255. return d === selected_node
  20256. ? d3.rgb(colors(d.label)).brighter().toString()
  20257. : colors(d.label);
  20258. })
  20259. .style("fill-opacity", 0.75) // add by xi
  20260. .classed("reflexive", function (d) {
  20261. return d.reflexive;
  20262. });
  20263. // add new nodes
  20264. var g = circle.enter().append("svg:g");
  20265. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  20266. //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');
  20267. g.append("svg:circle")
  20268. .attr("r", 24)
  20269. .style("fill", function (d) {
  20270. return d === selected_node
  20271. ? "rgb(153,153,153)"
  20272. : "rgb(255,255,255)";
  20273. })
  20274. .style("stroke", function (d) {
  20275. return d3.rgb(colors(d.label)).darker().toString();
  20276. })
  20277. .style("stroke-width", "2");
  20278. g.append("svg:circle")
  20279. .attr("class", "node")
  20280. .attr("r", 18)
  20281. .style("fill", function (d) {
  20282. return d === selected_node
  20283. ? d3.rgb(colors(d.label)).brighter().toString()
  20284. : colors(d.label);
  20285. })
  20286. .style("stroke", function (d) {
  20287. return d3.rgb(colors(d.label)).darker().toString();
  20288. })
  20289. .style("fill-opacity", 0.25) //add by xj
  20290. .style("stroke-opacity", 0.5) //add by xj
  20291. .classed("reflexive", function (d) {
  20292. return d.reflexive;
  20293. });
  20294. g.on("mouseover", function (d) {
  20295. //if(!mousedown_node || d === mousedown_node) return;
  20296. // enlarge target node
  20297. //d3.select(this).attr('transform', 'scale(1.1)');
  20298. })
  20299. .on("mouseout", function (d) {
  20300. //if(!mousedown_node || d === mousedown_node) return;
  20301. // unenlarge target node
  20302. //d3.select(this).attr('transform', '');
  20303. })
  20304. .on("mousedown", function (d) {
  20305. if (d3.event.ctrlKey) return;
  20306. //hideLinkForm(true);
  20307. //去除没有提交的连线
  20308. for (var i = 0; i < links.length; i++) {
  20309. if (links[i].id == -1) {
  20310. links.splice(i, 1);
  20311. }
  20312. }
  20313. // select node
  20314. mousedown_node = d;
  20315. if (mousedown_node === selected_node) {
  20316. selected_node = $scope.selected_node = null;
  20317. } else {
  20318. selected_node = $scope.selected_node = mousedown_node;
  20319. selected_link = $scope.selected_link = null;
  20320. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  20321. APIService.findRefById(selected_node.id).then(function (
  20322. result
  20323. ) {
  20324. var d = result.data;
  20325. var node = d.node;
  20326. var link = d.edge;
  20327. var tempNode = [];
  20328. var tempLink = [];
  20329. //nodes 或者links 要去重
  20330. for (var i = 0; i < node.length; i++) {
  20331. var tmp = 0;
  20332. for (var j = 0; j < nodes.length; j++) {
  20333. if (node[i].id == nodes[j].id) {
  20334. tmp++;
  20335. break;
  20336. }
  20337. }
  20338. if (tmp == 0) {
  20339. tempNode.push(node[i]);
  20340. }
  20341. }
  20342. for (var i = 0; i < link.length; i++) {
  20343. var tmp = 0;
  20344. for (var j = 0; j < links.length; j++) {
  20345. if (link[i].id == links[j].id) {
  20346. tmp++;
  20347. break;
  20348. }
  20349. }
  20350. if (tmp == 0) {
  20351. tempLink.push(link[i]);
  20352. }
  20353. }
  20354. //数据写入页面
  20355. for (var i = 0; i < tempNode.length; i++) {
  20356. //nodes 不清空
  20357. nodes.push(tempNode[i]);
  20358. }
  20359. for (var i = 0; i < tempLink.length; i++) {
  20360. //link 不清空
  20361. links.push(tempLink[i]);
  20362. }
  20363. //links转换
  20364. for (var i = 0; i < links.length; i++) {
  20365. for (var j = 0; j < nodes.length; j++) {
  20366. if (links[i].source == nodes[j].id) {
  20367. links[i].source = nodes[j];
  20368. }
  20369. if (links[i].target == nodes[j].id) {
  20370. links[i].target = nodes[j];
  20371. }
  20372. }
  20373. }
  20374. restart();
  20375. });
  20376. }
  20377. // reposition drag line
  20378. drag_line
  20379. .style("marker-end", "url(#end-arrow)")
  20380. .classed("hidden", false)
  20381. .attr(
  20382. "d",
  20383. "M" +
  20384. mousedown_node.x +
  20385. "," +
  20386. mousedown_node.y +
  20387. "L" +
  20388. mousedown_node.x +
  20389. "," +
  20390. mousedown_node.y
  20391. );
  20392. restart();
  20393. })
  20394. .on("mouseup", function (d) {
  20395. if (!mousedown_node) return;
  20396. });
  20397. // show node name
  20398. g.append("svg:text")
  20399. .attr("x", 0)
  20400. .attr("y", 34)
  20401. .attr("class", "id")
  20402. .text(function (d) {
  20403. return d.name;
  20404. }); //TODO 改为 d.name
  20405. //设置图片
  20406. g.append("svg:foreignObject")
  20407. .attr("width", 32)
  20408. .attr("height", 32)
  20409. .attr("x", "-16px")
  20410. .attr("y", "-11px")
  20411. .html(function (d) {
  20412. for (var i = 0; i < labels.length; i++) {
  20413. if (d.label == labels[i].sign) {
  20414. return (
  20415. '<i class="icon iconfont">' +
  20416. labels[i].iconname +
  20417. "</i>"
  20418. );
  20419. }
  20420. }
  20421. });
  20422. // remove old nodes
  20423. circle.exit().remove();
  20424. // set the graph in motion
  20425. force.start();
  20426. }
  20427. function mousedown() {
  20428. // prevent I-bar on drag
  20429. //d3.event.preventDefault();
  20430. // because :active only works in WebKit?
  20431. svg.classed("active", true);
  20432. if (mousedown_node) {
  20433. viewNode(mousedown_node);
  20434. }
  20435. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  20436. return;
  20437. restart();
  20438. }
  20439. function mousemove() {
  20440. if (!mousedown_node) return;
  20441. // update drag line
  20442. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  20443. //restart();
  20444. }
  20445. function mouseup() {
  20446. if (mousedown_node) {
  20447. // hide drag line
  20448. drag_line.classed("hidden", true).style("marker-end", "");
  20449. }
  20450. // because :active only works in WebKit?
  20451. svg.classed("active", false);
  20452. // clear mouse event vars
  20453. resetMouseVars();
  20454. }
  20455. function spliceLinksForNode(node) {
  20456. var toSplice = links.filter(function (l) {
  20457. return l.source === node || l.target === node;
  20458. });
  20459. toSplice.map(function (l) {
  20460. links.splice(links.indexOf(l), 1);
  20461. });
  20462. }
  20463. // only respond once per keydown
  20464. var lastKeyDown = -1;
  20465. function keydown() {
  20466. //d3.event.preventDefault();
  20467. if (lastKeyDown !== -1) return;
  20468. lastKeyDown = d3.event.keyCode;
  20469. // ctrl
  20470. if (d3.event.keyCode === 17) {
  20471. circle.call(force.drag);
  20472. svg.classed("ctrl", true);
  20473. }
  20474. if (!selected_node && !selected_link) return;
  20475. switch (d3.event.keyCode) {
  20476. case 8: // backspace
  20477. case 66: // B
  20478. if (selected_link) {
  20479. // set link direction to both left and right
  20480. selected_link.left = true;
  20481. selected_link.right = true;
  20482. }
  20483. restart();
  20484. break;
  20485. case 76: // L
  20486. if (selected_link) {
  20487. // set link direction to left only
  20488. selected_link.left = true;
  20489. selected_link.right = false;
  20490. }
  20491. restart();
  20492. break;
  20493. case 82: // R
  20494. if (selected_node) {
  20495. // toggle node reflexivity
  20496. selected_node.reflexive = !selected_node.reflexive;
  20497. } else if (selected_link) {
  20498. // set link direction to right only
  20499. selected_link.left = false;
  20500. selected_link.right = true;
  20501. }
  20502. restart();
  20503. break;
  20504. }
  20505. }
  20506. function keyup() {
  20507. lastKeyDown = -1;
  20508. // ctrl
  20509. if (d3.event.keyCode === 17) {
  20510. circle
  20511. .on("mousedown.drag", null)
  20512. .on("touchstart.drag", null);
  20513. svg.classed("ctrl", false);
  20514. }
  20515. }
  20516. function viewNode(node) {
  20517. // console.log(svg.attr('left'));
  20518. //var el = angular.element('div.modal-dialog')[0];
  20519. var title =
  20520. $scope.selected_node.name +
  20521. "-[" +
  20522. $scope.selected_node.uuid +
  20523. "]";
  20524. if (!$scope.selected_node.props.state) {
  20525. $scope.selected_node.props.state = "空";
  20526. } else if ($scope.selected_node.props.state) {
  20527. if ($scope.selected_node.props.state == "1") {
  20528. $scope.selected_node.props.state = "未审核";
  20529. } else if ($scope.selected_node.props.state == "2") {
  20530. $scope.selected_node.props.state = "已审核";
  20531. } else if ($scope.selected_node.props.state == "3") {
  20532. $scope.selected_node.props.state = "不匹配";
  20533. } else if ($scope.selected_node.props.state == "4") {
  20534. $scope.selected_node.props.state = "丢失";
  20535. }
  20536. }
  20537. if (!$scope.selected_node.name) {
  20538. $scope.selected_node.name = "空";
  20539. }
  20540. if (!$scope.selected_node.status) {
  20541. $scope.selected_node.statu = "空";
  20542. }
  20543. if (!$scope.selected_node.props.useradmin) {
  20544. $scope.selected_node.props.useradmin = "空";
  20545. }
  20546. Toaster.pop({
  20547. // type: 'info',
  20548. // title: title,
  20549. body:
  20550. "<br/><p>搜索代码:" +
  20551. $scope.selected_node.uuid +
  20552. "</p>" +
  20553. "<p>配置标题:" +
  20554. $scope.selected_node.name +
  20555. "</p>" +
  20556. "<p>状态:" +
  20557. $scope.selected_node.status +
  20558. "</p>" +
  20559. "<p>审核状态:" +
  20560. $scope.selected_node.props.state +
  20561. "</p>" +
  20562. "<p>维护人员:" +
  20563. $scope.selected_node.props.useradmin +
  20564. "</p>",
  20565. bodyOutputType: "trustedHtml",
  20566. timeout: 3000,
  20567. });
  20568. }
  20569. //GT 颜色与数值对照表
  20570. function colors(sign) {
  20571. //num=num>20?num%20:parseInt(num);
  20572. for (var i = 0; i < labels.length; i++) {
  20573. var entity = labels[i];
  20574. if (sign == entity.sign) {
  20575. return entity.color;
  20576. }
  20577. if (i == labels.length - 1 && sign != entity.sign) {
  20578. return "#ffeeee";
  20579. }
  20580. }
  20581. }
  20582. $scope.init = function () {
  20583. svg = d3
  20584. .select("#cmdbSVG")
  20585. .append("svg")
  20586. .attr("width", width)
  20587. .attr("height", height);
  20588. // init D3 force layout
  20589. force = d3.layout
  20590. .force()
  20591. .nodes(nodes)
  20592. .links(links)
  20593. .size([width, height])
  20594. .gravity(0.05)
  20595. .linkDistance(150)
  20596. .linkStrength(2)
  20597. .charge(-500)
  20598. .on("tick", tick);
  20599. // define arrow markers for graph links
  20600. svg
  20601. .append("svg:defs")
  20602. .append("svg:marker")
  20603. .attr("id", "end-arrow")
  20604. .attr("viewBox", "0 -5 10 10")
  20605. .attr("refX", 6)
  20606. .attr("markerWidth", 3)
  20607. .attr("markerHeight", 3)
  20608. .attr("orient", "auto")
  20609. .append("svg:path")
  20610. .attr("d", "M0,-5L10,0L0,5")
  20611. .attr("fill", "#000");
  20612. svg
  20613. .append("svg:defs")
  20614. .append("svg:marker")
  20615. .attr("id", "start-arrow")
  20616. .attr("viewBox", "0 -5 10 10")
  20617. .attr("refX", 4)
  20618. .attr("markerWidth", 3)
  20619. .attr("markerHeight", 3)
  20620. .attr("orient", "auto")
  20621. .append("svg:path")
  20622. .attr("d", "M10,-5L0,0L10,5")
  20623. .attr("fill", "#000");
  20624. // line displayed when dragging new nodes
  20625. drag_line = svg
  20626. .append("svg:path")
  20627. .attr("class", "link dragline hidden")
  20628. .attr("d", "M0,0L0,0");
  20629. // handles to link and node element groups
  20630. //(1)var path = svg.append('svg:g').selectAll('g')
  20631. path = svg.append("svg:g").selectAll("g");
  20632. circle = svg.append("svg:g").selectAll("g");
  20633. svg
  20634. .on("mousedown", mousedown)
  20635. .on("mousemove", mousemove)
  20636. .on("mouseup", mouseup);
  20637. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  20638. };
  20639. var CI = {};
  20640. window.CI = CI;
  20641. $scope.ok = function () {
  20642. $modalInstance.close($scope.selected_node);
  20643. };
  20644. $scope.cancel = function () {
  20645. $modalInstance.dismiss("cancel");
  20646. };
  20647. },
  20648. size: size,
  20649. resolve: {
  20650. title: function () {
  20651. return options.templateOptions.title;
  20652. },
  20653. Restangular: function () {
  20654. return options.templateOptions.Restangular;
  20655. },
  20656. APIService: function () {
  20657. return options.templateOptions.ApiService;
  20658. },
  20659. ConfigDataService: function () {
  20660. return options.templateOptions.ConfigDataService;
  20661. },
  20662. ConfigFormService: function () {
  20663. return options.templateOptions.ConfigFormService;
  20664. },
  20665. SweetAlert: function () {
  20666. return options.templateOptions.Alert;
  20667. },
  20668. Toaster: function () {
  20669. return options.templateOptions.toaster;
  20670. },
  20671. },
  20672. });
  20673. modalInstance.result.then(
  20674. function (selectedItem) {
  20675. options.value(selectedItem.name + "-" + selectedItem.uuid);
  20676. },
  20677. function () {
  20678. //console.log('Modal dismissed at: ' + new Date());
  20679. }
  20680. );
  20681. },
  20682. },
  20683. };
  20684. },
  20685. controller: [
  20686. "$scope",
  20687. function ($scope) {
  20688. // setTimeout(function(){
  20689. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  20690. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  20691. // if(modelData.status==200){
  20692. // $scope.model[$scope.options.key] = modelData.data;
  20693. // $scope.options.initialValue = $scope.model[$scope.options.key];
  20694. // }
  20695. // });
  20696. // },1000);
  20697. },
  20698. ],
  20699. });
  20700. });
  20701. appFormly.run(function (formlyConfig, $parse) {
  20702. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  20703. var removeOnHideTransformer = function (fields, model) {
  20704. return fields.map(function (field) {
  20705. if (
  20706. field.hideExpression &&
  20707. (!field.data || !field.data.dontRemoveOnHidden)
  20708. ) {
  20709. addFieldRemoveOnHideWatcher(field);
  20710. }
  20711. if (field.type == "ui-title") {
  20712. addFieldRemoveOnHideWatcher(field);
  20713. }
  20714. return field;
  20715. });
  20716. };
  20717. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  20718. function addFieldRemoveOnHideWatcher(field) {
  20719. var watcher = getWatcher();
  20720. if (field.watcher) {
  20721. if (!angular.isArray(field.watcher)) {
  20722. field.watcher = [field.watcher];
  20723. }
  20724. field.watcher.push(watcher);
  20725. } else {
  20726. field.watcher = watcher;
  20727. }
  20728. }
  20729. function getWatcher() {
  20730. return {
  20731. expression: function (field) {
  20732. return field.hide;
  20733. },
  20734. listener: function (field, newHide, oldHide, scope) {
  20735. if (field.hide) {
  20736. if (field.templateOptions.pkey) {
  20737. if (field.key == "transferuser") {
  20738. $parse(field.templateOptions.pkey + "." + field.key).assign(
  20739. scope.model,
  20740. undefined
  20741. );
  20742. }
  20743. } else if(typeof field.key =='string') {
  20744. $parse(field.key).assign(scope.model, undefined);
  20745. }
  20746. }
  20747. if (field.type == "ui-title") {
  20748. $parse(field.key).assign(scope.model, undefined);
  20749. }
  20750. },
  20751. };
  20752. }
  20753. });
  20754. appFormly.controller("CustomformCtrl", [
  20755. "$rootScope",
  20756. "$scope",
  20757. "$parse",
  20758. "$injector",
  20759. "$http",
  20760. "$q",
  20761. "$state",
  20762. "$stateParams",
  20763. "$modal",
  20764. "$timeout",
  20765. "$interval",
  20766. "SweetAlert",
  20767. "FileUploader",
  20768. "i18nService",
  20769. "Restangular",
  20770. "UserRestangular",
  20771. "BpmRestangular",
  20772. "SimpleRestangular",
  20773. "WechatRestangular",
  20774. "api_configure_form",
  20775. "api_bpm_domain",
  20776. "api_bpm_domain1",
  20777. "api_simple",
  20778. "api_bpm",
  20779. "api_bpm_data",
  20780. "api_user_data",
  20781. "api_statistic",
  20782. "up_down_file",
  20783. "fileReader",
  20784. "api_wechatfile",
  20785. "api_category",
  20786. function (
  20787. $rootScope,
  20788. $scope,
  20789. $parse,
  20790. $injector,
  20791. $http,
  20792. $q,
  20793. $state,
  20794. $stateParams,
  20795. $modal,
  20796. $timeout,
  20797. $interval,
  20798. SweetAlert,
  20799. FileUploader,
  20800. i18nService,
  20801. Restangular,
  20802. UserRestangular,
  20803. BpmRestangular,
  20804. SimpleRestangular,
  20805. WechatRestangular,
  20806. api_configure_form,
  20807. api_bpm_domain,
  20808. api_bpm_domain1,
  20809. api_simple,
  20810. api_bpm,
  20811. api_bpm_data,
  20812. api_user_data,
  20813. api_statistic,
  20814. up_down_file,
  20815. fileReader,
  20816. api_wechatfile,
  20817. api_category
  20818. ) {
  20819. //console.log($parse('Restangular')($scope));
  20820. //console.log($injector.get('Restangular'));
  20821. //console.log($stateParams);
  20822. //保存报修主体
  20823. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  20824. $scope.imgUrlList = [];
  20825. $scope.uploadimg_del = function () {
  20826. console.log(123);
  20827. };
  20828. var vm = this;
  20829. vm.options = {};
  20830. vm.exampleTitle = ["expressionProperties", "model property"];
  20831. vm.fields = [];
  20832. vm.model = {};
  20833. $scope.langs = i18nService.getAllLangs();
  20834. $scope.lang = "zh-cn";
  20835. i18nService.setCurrentLang($scope.lang);
  20836. //alert($rootScope.user.id,null,2);
  20837. vm.model["loginUser"] = $rootScope.user;
  20838. var loginUser = $rootScope.user;
  20839. // console.log(vm);
  20840. var that = $injector;
  20841. var parse = $parse;
  20842. var formKey = "";
  20843. var pdKey = "";
  20844. var modelWatch = "";
  20845. // 房间号是否显示
  20846. vm.model.isRoom = sessionStorage.getItem('ifRoom') == 1;
  20847. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20848. modelWatch = JSON.parse($stateParams.model);
  20849. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  20850. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  20851. console.log(modelWatch, $rootScope);
  20852. // if(modelWatch.model.incident){
  20853. // if(modelWatch.model.incident.place){
  20854. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  20855. // }else{
  20856. // $rootScope.selecthouseNumber = undefined;
  20857. // }
  20858. // }
  20859. // 初始化的时候判断是否是简单处理
  20860. if(modelWatch.model && modelWatch.model.incident && modelWatch.model.incident.category){
  20861. if (modelWatch.model.incident.category.hasSimple == 1) {
  20862. vm.model.isHasSimple = true;
  20863. }else{
  20864. vm.model.isHasSimple = false;
  20865. }
  20866. }
  20867. }
  20868. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  20869. pdKey = $state.current.pdKey;
  20870. } else if ($stateParams.pdKey) {
  20871. pdKey = $stateParams.pdKey;
  20872. }
  20873. // console.log("pdKey::" + JSON.stringify($state.current.title));
  20874. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  20875. formKey = $stateParams.formKey;
  20876. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  20877. }
  20878. if (angular.isDefined($stateParams.model)) {
  20879. var formModel = $stateParams.model;
  20880. }
  20881. //用户测试数据,后续从header的auth中获取
  20882. var userId = 2;
  20883. userId = $rootScope.user.id;
  20884. //==============处理表单设计数据 开始====================
  20885. //处理组件加载后台数据选项的方法
  20886. function refreshSelectOptions(searchVal, field) {
  20887. if (
  20888. field.templateOptions.optionsUrl &&
  20889. !field.templateOptions.isnosearch
  20890. ) {
  20891. var process = BpmRestangular.all("");
  20892. if (field.templateOptions.ApiService) {
  20893. process = UserRestangular.all("");
  20894. }
  20895. if (field.templateOptions.Apicommon) {
  20896. process = WechatRestangular.all("");
  20897. }
  20898. var datakey = {
  20899. idx: 0,
  20900. sum: 1000,
  20901. };
  20902. if (field.templateOptions.modelreasondata) {
  20903. datakey = field.templateOptions.modelreasondata;
  20904. }
  20905. process
  20906. .customPOST(datakey, field.templateOptions.optionsUrl)
  20907. .then(function (result) {
  20908. if (!field.templateOptions.options) {
  20909. field.templateOptions.options = [];
  20910. }
  20911. if (field.templateOptions.optionsDataKey) {
  20912. field.templateOptions.options =
  20913. result[field.templateOptions.optionsDataKey];
  20914. } else {
  20915. field.templateOptions.options = result;
  20916. }
  20917. });
  20918. }
  20919. }
  20920. //获取表单后数据处理
  20921. function formfield(field, result) {
  20922. // angular.forEach(fields.fields, function(field) {
  20923. if (field.key == "") {
  20924. delete field.key;
  20925. }
  20926. if (angular.isDefined(field.extjson)) {
  20927. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  20928. angular.extend(field.templateOptions, extObj.templateOptions);
  20929. delete extObj.templateOptions;
  20930. for (var prop in extObj) {
  20931. if (new RegExp("Expression").test(prop)) {
  20932. //var obj = $scope.$eval(extObj[prop]);
  20933. //extObj[prop] = $scope.$eval(extObj[prop]);
  20934. if (extObj[prop] != null) {
  20935. if (new RegExp("function").test(extObj[prop])) {
  20936. var propValue = eval(extObj[prop]);
  20937. extObj[prop] = propValue;
  20938. } else {
  20939. //console.log(extObj[prop]);
  20940. var obj = $scope.$eval(extObj[prop]);
  20941. extObj[prop] = obj;
  20942. //console.log(obj);
  20943. }
  20944. }
  20945. } else if (new RegExp("expressionProperties").test(prop)) {
  20946. for (var p in extObj[prop]) {
  20947. if (new RegExp("function").test(extObj[prop][p])) {
  20948. var propValue = eval(extObj[prop][p]);
  20949. extObj[prop][p] = propValue;
  20950. } else {
  20951. //if(p.indexOf("'")>=0){
  20952. // var obj = $scope.$eval(extObj[prop][p]);
  20953. // extObj[prop][$scope.$eval(p)]=obj;
  20954. //}
  20955. }
  20956. }
  20957. } else if ("watcher" == prop) {
  20958. if (angular.isArray(extObj[prop])) {
  20959. angular.forEach(extObj[prop], function (item, index) {
  20960. for (var p in item) {
  20961. if (new RegExp("function").test(item[p])) {
  20962. var propValue = eval(item[p]);
  20963. extObj[prop][index][p] = propValue;
  20964. }
  20965. }
  20966. });
  20967. } else if (angular.isObject(extObj[prop])) {
  20968. for (var p in extObj[prop]) {
  20969. if (new RegExp("function").test(extObj[prop][p])) {
  20970. var propValue = eval(extObj[prop][p]);
  20971. extObj[prop][p] = propValue;
  20972. }
  20973. }
  20974. }
  20975. }
  20976. }
  20977. angular.extend(field, extObj);
  20978. delete field.extjson;
  20979. }
  20980. if (angular.isDefined(field.templateOptions)) {
  20981. var templateOs = field.templateOptions;
  20982. // console.log(templateOs,'come')
  20983. for (var property in templateOs) {
  20984. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  20985. if (angular.isString(templateOs[property])) {
  20986. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  20987. if (new RegExp("function").test(templateOs[property])) {
  20988. var propValue = eval(templateOs[property]);
  20989. field.templateOptions[property] = propValue;
  20990. } else {
  20991. if (that.has(templateOs[property])) {
  20992. field.templateOptions[property] = that.get(
  20993. templateOs[property]
  20994. );
  20995. } else {
  20996. field.templateOptions[property] = templateOs[property];
  20997. }
  20998. }
  20999. } else if (templateOs[property] == null) {
  21000. //delete field.templateOptions[property];
  21001. } else {
  21002. }
  21003. }
  21004. }
  21005. if (
  21006. angular.isDefined(field.templateOptions) &&
  21007. angular.isDefined(field.templateOptions.extjson)
  21008. ) {
  21009. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  21010. angular.extend(field.templateOptions, extObj);
  21011. delete field.templateOptions.extjson;
  21012. }
  21013. // ...
  21014. if (field.templateOptions) {
  21015. //处理远程获取数据控件方法调用
  21016. if (
  21017. field.templateOptions.optionsUrl &&
  21018. !field.templateOptions.refresh
  21019. ) {
  21020. // if (!field.templateOptions.isnoreash) {
  21021. field.templateOptions.refresh = refreshSelectOptions;
  21022. // }
  21023. }
  21024. //处理嵌套属性数据绑定/
  21025. if (field.templateOptions.pkey) {
  21026. var pmodel,
  21027. i = 0;
  21028. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  21029. if (i == 0) {
  21030. if (result.model[p] == null) {
  21031. result.model[p] = {};
  21032. }
  21033. pmodel = result.model[p];
  21034. i++;
  21035. } else {
  21036. if (pmodel[p] == null) {
  21037. pmodel[p] = {};
  21038. }
  21039. pmodel = pmodel[p];
  21040. }
  21041. });
  21042. if (pmodel != null) {
  21043. field.model = pmodel;
  21044. if (pmodel[field.key] == null) {
  21045. pmodel[field.key] = null;
  21046. }
  21047. }
  21048. } else {
  21049. if (result.model[field.key] == null) {
  21050. result.model[field.key] = null;
  21051. }
  21052. }
  21053. //处理弹出框组件初始化
  21054. if (field.type == "ui-input-selectmodal") {
  21055. field.templateOptions.modal = $modal;
  21056. //field.templateOptions.Restangular = Restangular;
  21057. } else if (field.type == "ui-requesterselect") {
  21058. //field.templateOptions.language = $scope.lang;
  21059. field.templateOptions.modal = $modal;
  21060. field.templateOptions.UserService = api_user_data;
  21061. } else if (field.type == "ui-deptinformation") {
  21062. field.templateOptions.modal = $modal;
  21063. field.templateOptions.UserService = api_user_data;
  21064. } else if (field.type == "ui-requesterinformation") {
  21065. field.templateOptions.modal = $modal;
  21066. field.templateOptions.UserService = api_user_data;
  21067. } else if (field.type == "ui-userselect") {
  21068. field.templateOptions.modal = $modal;
  21069. //field.templateOptions.Restangular = Restangular;
  21070. } else if (field.type == "ui-userselectSearch") {
  21071. field.templateOptions.modal = $modal;
  21072. //field.templateOptions.Restangular = Restangular;
  21073. } else if (field.type == "ui-multiuserselect") {
  21074. field.templateOptions.modal = $modal;
  21075. } else if (field.type == "ui-stringuserselect") {
  21076. field.templateOptions.modal = $modal;
  21077. } else if (field.type == "ui-search") {
  21078. field.templateOptions.modal = $modal;
  21079. } else if (field.type == "ui-modelselect") {
  21080. field.templateOptions.modal = $modal;
  21081. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  21082. field.templateOptions.loginUser = $rootScope.user;
  21083. //field.templateOptions.Restangular = Restangular;
  21084. } else if (field.type == "ui-incidentmodelselect") {
  21085. field.templateOptions.modal = $modal;
  21086. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  21087. field.templateOptions.loginUser = $rootScope.user;
  21088. //field.templateOptions.Restangular = Restangular;
  21089. } else if (field.type == "ui-dropfile") {
  21090. $scope.fileUploader = field.templateOptions.fileUploader =
  21091. new FileUploader({
  21092. url: "/uploader",
  21093. });
  21094. field.templateOptions.taskId = $stateParams.taskId;
  21095. field.templateOptions.processInstanceId =
  21096. $stateParams.processInstanceId;
  21097. field.templateOptions.userId = $rootScope.user.id;
  21098. } else if (field.type == "ui-dropfielknow") {
  21099. $scope.fileUploader = field.templateOptions.fileUploader =
  21100. new FileUploader({
  21101. url: "/uploader",
  21102. });
  21103. field.templateOptions.taskId = $stateParams.taskId;
  21104. field.templateOptions.processInstanceId =
  21105. $stateParams.processInstanceId;
  21106. field.templateOptions.userId = $rootScope.user.id;
  21107. } else if (field.type == "ui-upDropFile") {
  21108. $scope.fileUploader = field.templateOptions.fileUploader =
  21109. new FileUploader({
  21110. url: "/uploader",
  21111. });
  21112. field.templateOptions.taskId = $stateParams.taskId;
  21113. field.templateOptions.processInstanceId =
  21114. $stateParams.processInstanceId;
  21115. field.templateOptions.userId = $rootScope.user.id;
  21116. } else if (field.type == "ui-dropfilenotup") {
  21117. $scope.fileUploader = field.templateOptions.fileUploader =
  21118. new FileUploader({
  21119. url: "/uploader",
  21120. });
  21121. field.templateOptions.taskId = $stateParams.taskId;
  21122. field.templateOptions.processInstanceId =
  21123. $stateParams.processInstanceId;
  21124. field.templateOptions.userId = $rootScope.user.id;
  21125. //field.ApiService=api_bpm_domain;
  21126. } else if (field.type == "ui-uploadFiles") {
  21127. $scope.fileUploader = field.templateOptions.fileUploader =
  21128. new FileUploader({
  21129. url: "/uploader",
  21130. });
  21131. field.templateOptions.taskId = $stateParams.taskId;
  21132. field.templateOptions.processInstanceId =
  21133. $stateParams.processInstanceId;
  21134. field.templateOptions.userId = $rootScope.user.id;
  21135. //field.ApiService=api_bpm_domain;
  21136. } else if (field.type == "ui-upDownFiles") {
  21137. $scope.fileUploader = field.templateOptions.fileUploader =
  21138. new FileUploader({
  21139. url: "/uploader",
  21140. });
  21141. field.templateOptions.taskId = $stateParams.taskId;
  21142. field.templateOptions.processInstanceId =
  21143. $stateParams.processInstanceId;
  21144. field.templateOptions.userId = $rootScope.user.id;
  21145. //field.ApiService=api_bpm_domain;
  21146. } else if (field.type == "ui-uploadImgs") {
  21147. $scope.fileUploader = field.templateOptions.fileUploader =
  21148. new FileUploader({
  21149. url: "/uploader",
  21150. });
  21151. field.templateOptions.taskId = $stateParams.taskId;
  21152. field.templateOptions.processInstanceId =
  21153. $stateParams.processInstanceId;
  21154. field.templateOptions.userId = $rootScope.user.id;
  21155. //field.ApiService=api_bpm_domain;
  21156. } else if (field.type == "ui-dropfiletable") {
  21157. if (field.templateOptions.processInstanceId) {
  21158. } else {
  21159. field.templateOptions.processInstanceId =
  21160. $stateParams.processInstanceId;
  21161. }
  21162. } else if (field.type == "ui-dropFiles") {
  21163. if (field.templateOptions.processInstanceId) {
  21164. } else {
  21165. field.templateOptions.processInstanceId =
  21166. $stateParams.processInstanceId;
  21167. }
  21168. } else if (field.type == "ui-showImgs") {
  21169. if (field.templateOptions.processInstanceId) {
  21170. } else {
  21171. field.templateOptions.processInstanceId =
  21172. $stateParams.processInstanceId;
  21173. }
  21174. } else if (field.type == "ui-repeatSection") {
  21175. var repeatForm = {
  21176. model: {},
  21177. fields: field.templateOptions.fields,
  21178. };
  21179. repeatForm.model[field.key] = [];
  21180. decodeVMForm(repeatForm);
  21181. } else if (field.type == "ui-currentuser") {
  21182. field.templateOptions.user = vm.model["loginUser"];
  21183. } else if (field.type == "ui-workernumbersign") {
  21184. field.templateOptions.user = vm.model["loginUser"];
  21185. } else if (field.type == "ui-repair-photos") {
  21186. field.templateOptions.user = vm.model["loginUser"];
  21187. }
  21188. }
  21189. }
  21190. //解析自定义表单设计数据
  21191. $scope.oldfromtype = true;
  21192. function decodeVMForm(vmForm) {
  21193. if (vmForm.formType == "1") {
  21194. $scope.oldfromtype = false;
  21195. } else {
  21196. $scope.oldfromtype = true;
  21197. }
  21198. var result = {
  21199. model: {},
  21200. fields: [],
  21201. };
  21202. //设置模型实体数据 begin
  21203. // var mdata = vmForm.model;
  21204. //解析数据实体
  21205. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  21206. angular.extend(result.model, mdata);
  21207. if (modelWatch != null && modelWatch != "") {
  21208. //angular.extend(result.model.incident,modelWatch.incident);
  21209. //result.model.alarmType = modelWatch.alarmType;
  21210. // vmForm.cancelUrl = modelWatch.cancelUrl;
  21211. // console.log(modelWatch.cancelUrl)
  21212. for (var index in modelWatch.model) {
  21213. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  21214. if (result.model[index] != null) {
  21215. angular.extend(result.model[index], modelWatch.model[index]);
  21216. } else {
  21217. result.model[index] = modelWatch.model[index];
  21218. }
  21219. }
  21220. }
  21221. //设置模型实体数据 end
  21222. //解析设计数据生成表单项 begin
  21223. var fields = [];
  21224. //处理修改设计数据中展示设置
  21225. angular.forEach(vmForm.fields, function (fields) {
  21226. if (vmForm.formType == "1") {
  21227. angular.forEach(fields.fields, function (field) {
  21228. formfield(field, result);
  21229. });
  21230. } else {
  21231. formfield(fields, result);
  21232. }
  21233. // console.log(field);
  21234. result.fields.push(fields);
  21235. });
  21236. angular.extend($scope.vm.fields, result.fields);
  21237. angular.extend($scope.vm.model, result.model);
  21238. vm.model["loginUser"] = $rootScope.user;
  21239. //增加识别报修主体seimin
  21240. vm.model.repairType = $scope.repairMain.valueconfig;
  21241. if (vm.model.incident) {
  21242. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  21243. }
  21244. console.log(vm, "repairType"); //lmm
  21245. if (
  21246. modelWatch != null &&
  21247. modelWatch != "" &&
  21248. modelWatch.cancelUrl != null &&
  21249. modelWatch.cancelUrl != ""
  21250. ) {
  21251. vmForm.cancelUrl = modelWatch.cancelUrl;
  21252. }
  21253. $scope.formData = vmForm;
  21254. console.log($scope.formData, 4444444);
  21255. // console.log($scope.formData.url);
  21256. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  21257. if ($scope.formData.url == "start") {
  21258. $scope.Reset = true;
  21259. $scope.close = true;
  21260. $rootScope.isMask = false;
  21261. } else if ($scope.formData.url == "complete") {
  21262. $scope.Reset = false;
  21263. $scope.close = true;
  21264. }
  21265. //解析设计数据生成表单项 end
  21266. return result;
  21267. }
  21268. //======================处理表单设计数据 结束========================
  21269. $scope.ldloading = {};
  21270. function filter(obj) {
  21271. angular.forEach(obj, function (key, value) {
  21272. if (value === "" || value === null) {
  21273. delete obj[key];
  21274. } else if (
  21275. Object.prototype.toString.call(value) === "[object Object]"
  21276. ) {
  21277. filter(value);
  21278. } else if (angular.isArray(value)) {
  21279. angular.forEach(value, function (item) {
  21280. filter(item);
  21281. });
  21282. }
  21283. });
  21284. }
  21285. $scope.closeModel = function () {
  21286. // console.log($stateParams);
  21287. $state.go($scope.formData.cancelUrl, {});
  21288. event.preventDefault();
  21289. };
  21290. // console.log(vm);
  21291. // 暂存
  21292. $scope.save = function (data) {
  21293. console.log(vm);
  21294. if (vm.model.startSave) {
  21295. vm.model["initUser"] = $rootScope.user.id;
  21296. vm.model.start_code = "temporary";
  21297. //处理请求数据0327
  21298. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21299. delete data0327.repairType;
  21300. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  21301. if (
  21302. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21303. .selecthouseNumber
  21304. ) {
  21305. data0327.incident.place = {
  21306. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21307. .selecthouseNumber.id,
  21308. };
  21309. }
  21310. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  21311. if (response) {
  21312. var resData = Restangular.stripRestangular(response);
  21313. if (resData) {
  21314. if (
  21315. $scope.fileUploader != null &&
  21316. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  21317. resData.id
  21318. ) {
  21319. $scope.fileUploader.onBeforeUploadItem = function (item) {
  21320. angular.extend(item.headers, $rootScope.getSession());
  21321. item.url = api_bpm_domain
  21322. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  21323. .getRequestedUrl();
  21324. item.formData.push({
  21325. fileName: item.file.name,
  21326. });
  21327. //console.log();
  21328. };
  21329. $scope.fileUploader.uploadAll();
  21330. }
  21331. }
  21332. SweetAlert.swal(
  21333. {
  21334. title: "提交成功!",
  21335. type: "success",
  21336. confirmButtonColor: "#007AFF",
  21337. },
  21338. function () {
  21339. $state.go($scope.formData.cancelUrl);
  21340. }
  21341. );
  21342. } else {
  21343. SweetAlert.swal({
  21344. title: "系统错误",
  21345. text: "系统错误,请稍后重试!",
  21346. type: "error",
  21347. confirmButtonColor: "#DD6B55",
  21348. });
  21349. }
  21350. $scope.ldloading[style.replace("-", "_")] = false;
  21351. });
  21352. event.preventDefault();
  21353. } else if (vm.model.saveAgain) {
  21354. var toData = {
  21355. incident: vm.model.incident,
  21356. };
  21357. api_user_data.updData("incident", toData).then(function (response) {
  21358. if (response) {
  21359. var resData = Restangular.stripRestangular(response);
  21360. SweetAlert.swal(
  21361. {
  21362. title: "提交成功!",
  21363. type: "success",
  21364. confirmButtonColor: "#007AFF",
  21365. },
  21366. function () {
  21367. $state.go($scope.formData.cancelUrl);
  21368. }
  21369. );
  21370. } else {
  21371. SweetAlert.swal({
  21372. title: "系统错误",
  21373. text: "系统错误,请稍后重试!",
  21374. type: "error",
  21375. confirmButtonColor: "#DD6B55",
  21376. });
  21377. }
  21378. $scope.ldloading[style.replace("-", "_")] = false;
  21379. });
  21380. event.preventDefault();
  21381. } else {
  21382. SweetAlert.swal({
  21383. title: "系统错误",
  21384. text: "系统错误,请稍后重试!",
  21385. type: "error",
  21386. confirmButtonColor: "#DD6B55",
  21387. });
  21388. }
  21389. };
  21390. // 巡检生成事件
  21391. $scope.inspectionToIncident = function () {
  21392. var userData = {
  21393. idx: 0,
  21394. sum: 10,
  21395. requester: {
  21396. name: loginUser.name,
  21397. },
  21398. };
  21399. api_user_data.fetchDataList("requester", userData).then(function (res) {
  21400. console.log(res);
  21401. var toUser = {};
  21402. if (res.list.length > 0) {
  21403. toUser = res.list[0];
  21404. } else {
  21405. toUser = loginUser;
  21406. }
  21407. console.log(vm);
  21408. var incidentDescription = "";
  21409. console.log($stateParams.formUiEdit);
  21410. if ($stateParams.formUiEdit == "inspection_LinHu_confirm") {
  21411. var fields = vm.fields
  21412. .filter((v) => {
  21413. v.key = (v.key || "").toString();
  21414. return v.key.indexOf("sdCheckEnable") > -1;
  21415. })
  21416. .map((v) => ({
  21417. key: v.key,
  21418. name: v.templateOptions.label,
  21419. value: vm.model[v.key],
  21420. }));
  21421. fields.forEach(v=>{
  21422. if (vm.model[v.key]) {
  21423. incidentDescription =
  21424. incidentDescription.concat(v.name);
  21425. }
  21426. })
  21427. if (vm.model.descriptionTextarea) {
  21428. incidentDescription = incidentDescription.concat(
  21429. " " + "整改意见:" + vm.model.descriptionTextarea
  21430. );
  21431. }
  21432. }
  21433. // console.log(incidentDescription)
  21434. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  21435. var formdata = {
  21436. model: {
  21437. // 'isInspection': true,
  21438. // 'start_code':'assignment',
  21439. // 'isHandlerUser':false,
  21440. incident: {
  21441. requester: bxr,
  21442. area: bxr.place.area,
  21443. place: bxr.place,
  21444. houseNumber: bxr.houseNumber,
  21445. contacts: bxr.name,
  21446. contactsInformation: bxr.mphone,
  21447. // 'category': data.wxIncidentClassifyDTO.category,
  21448. description: incidentDescription,
  21449. source: {
  21450. id: 1552,
  21451. },
  21452. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  21453. // 'sourceType': data.incident.sourceType,
  21454. // 'fileUrl': data.incident.fileUrl
  21455. },
  21456. // 'requestershow': toUser,//2020年4月27日22:29:15
  21457. // 'flow': data.incident.id
  21458. // 'assignee': loginUser.id//2020年4月27日22:29:25
  21459. },
  21460. };
  21461. // console.log(formdata,toUser,'1111');
  21462. console.log(formdata, "1111");
  21463. // return;
  21464. $state.go("app.incident.chart", {
  21465. model: JSON.stringify(formdata),
  21466. });
  21467. });
  21468. // var formdata = {
  21469. // model:$rootScope.login_requester
  21470. // };
  21471. // console.log(formdata,'00000')
  21472. // return;
  21473. // $state.go("app.incident.chart", {
  21474. // 'model': JSON.stringify(formdata)
  21475. // });
  21476. event.preventDefault();
  21477. };
  21478. // console.log(vm);
  21479. // 创建事件seimin
  21480. vm.submit = function (data, style) {
  21481. console.log(vm, 22222);
  21482. // return;
  21483. if (vm.model.handler_code == undefined) {
  21484. vm.model.handler_code = "resolve";
  21485. }
  21486. if (
  21487. vm.model.change &&
  21488. vm.model.change.requestingPerson &&
  21489. vm.model.change.requestingPerson.menu
  21490. ) {
  21491. delete vm.model.change.requestingPerson.menu;
  21492. }
  21493. // var pdKey = $stateParams.pdKey;
  21494. if (vm.form.$valid) {
  21495. if (data.incident && data.incident.synergetic) {
  21496. console.log(data.incident.synergetic);
  21497. var synergetic = [];
  21498. for (var i = 0; i < data.incident.synergetic.length; i++) {
  21499. synergetic.push({
  21500. id: data.incident.synergetic[i],
  21501. });
  21502. }
  21503. data.incident.synergetic = synergetic;
  21504. vm.model.incident.synergetic = synergetic;
  21505. }
  21506. $scope.ldloading[style.replace("-", "_")] = true;
  21507. var startsub = true;
  21508. if (pdKey == "bpm_incident") {
  21509. angular.forEach(vm.fields, function (item) {
  21510. angular.forEach(item.fields, function (index) {
  21511. if (index.templateOptions.required && !index.hide) {
  21512. if (index.model) {
  21513. if(Object.prototype.toString.call(index.model[index.key]).slice(8, -1).toLowerCase() === 'object' && !index.model[index.key].id){
  21514. startsub = false;
  21515. $scope.ldloading.expand_right = false;
  21516. console.log(vm);
  21517. SweetAlert.swal({
  21518. title: index.templateOptions.label + "未填",
  21519. text: "请填写此项!",
  21520. type: "error",
  21521. confirmButtonColor: "#DD6B55",
  21522. });
  21523. }else if (
  21524. angular.isDefined(index.model[index.key]) &&
  21525. index.model[index.key] != null
  21526. ) {
  21527. if (
  21528. index.model[index.key].id &&
  21529. index.model[index.key].id == ""
  21530. ) {
  21531. startsub = false;
  21532. $scope.ldloading.expand_right = false;
  21533. SweetAlert.swal({
  21534. title: index.templateOptions.label + "未填",
  21535. text: "请填写此项!",
  21536. type: "error",
  21537. confirmButtonColor: "#DD6B55",
  21538. });
  21539. } else {
  21540. }
  21541. } else {
  21542. startsub = false;
  21543. $scope.ldloading.expand_right = false;
  21544. console.log(vm);
  21545. SweetAlert.swal({
  21546. title: index.templateOptions.label + "未填",
  21547. text: "请填写此项!",
  21548. type: "error",
  21549. confirmButtonColor: "#DD6B55",
  21550. });
  21551. }
  21552. } else {
  21553. if (
  21554. data[index.key] &&
  21555. data[index.key] != "" &&
  21556. data[index.key] != null
  21557. ) {
  21558. } else {
  21559. startsub = false;
  21560. $scope.ldloading.expand_right = false;
  21561. SweetAlert.swal({
  21562. title: index.templateOptions.label + "未填",
  21563. text: "请填写此项!",
  21564. type: "error",
  21565. confirmButtonColor: "#DD6B55",
  21566. });
  21567. }
  21568. }
  21569. }
  21570. });
  21571. });
  21572. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  21573. // startsub = false;
  21574. // $scope.ldloading.expand_right = false;
  21575. // SweetAlert.swal({
  21576. // title: '保修人未填',
  21577. // text: "请填写此项!",
  21578. // type: "error",
  21579. // confirmButtonColor: "#DD6B55"
  21580. // });
  21581. // }
  21582. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  21583. // } else {
  21584. // startsub = false;
  21585. // $scope.ldloading.expand_right = false;
  21586. // SweetAlert.swal({
  21587. // title: '故障现象未填',
  21588. // text: "请填写此项!",
  21589. // type: "error",
  21590. // confirmButtonColor: "#DD6B55"
  21591. // });
  21592. // }
  21593. }
  21594. if (startsub) {
  21595. $scope.ldloading[style.replace("-", "_")] = true;
  21596. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  21597. // console.log("vm.options:"+ JSON.stringify(vm.options));
  21598. vm.options.updateInitialValue();
  21599. // console.log("dfjkasdhfkhskjf ")
  21600. var _ = window._;
  21601. vm.model = (function filter(obj) {
  21602. var dateTransKeys = [];
  21603. var filtered = _.pick(obj, function (v, k, obj) {
  21604. if (_.isDate(v)) {
  21605. dateTransKeys.push(k);
  21606. }
  21607. return (
  21608. angular.isDefined(v) &&
  21609. v !== null &&
  21610. (angular.isArray(v) ? v.length > 0 : true) &&
  21611. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  21612. );
  21613. });
  21614. return _.cloneDeep(filtered, function (v, index, object) {
  21615. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  21616. angular.forEach(dateTransKeys, function (item) {
  21617. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  21618. });
  21619. dateTransKey = [];
  21620. return v;
  21621. }
  21622. return !_.isEmpty(filtered) &&
  21623. v !== filtered &&
  21624. _.isPlainObject(v)
  21625. ? filter(v)
  21626. : undefined;
  21627. });
  21628. })(vm.model);
  21629. if (pdKey != "") {
  21630. if ($scope.oprcode == "save") {
  21631. //保存
  21632. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  21633. if (response) {
  21634. var resData = Restangular.stripRestangular(response);
  21635. SweetAlert.swal(
  21636. {
  21637. title: "保存成功!",
  21638. confirmButtonColor: "#007AFF",
  21639. },
  21640. function () {
  21641. $state.go($scope.formData.cancelUri);
  21642. }
  21643. );
  21644. // if(resData.status){
  21645. // resData
  21646. // }
  21647. } else {
  21648. SweetAlert.swal({
  21649. title: "系统错误",
  21650. text: "系统错误,请稍后重试!",
  21651. type: "error",
  21652. confirmButtonColor: "#DD6B55",
  21653. });
  21654. }
  21655. $scope.ldloading[style.replace("-", "_")] = false;
  21656. });
  21657. } else {
  21658. console.log($scope.formData.url, "zzzz");
  21659. var integralMechanism = sessionStorage.getItem('integralMechanism');
  21660. switch ($scope.formData.url) {
  21661. case "start":
  21662. vm.model["initUser"] = $rootScope.user.id;
  21663. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  21664. } else {
  21665. vm.model["assignee"] = $rootScope.user.id;
  21666. }
  21667. if (
  21668. vm.model["candidateGroups"] &&
  21669. vm.model.candidateGroups.id
  21670. ) {
  21671. vm.model.candidateGroups = vm.model.candidateGroups.id;
  21672. }
  21673. if (pdKey == "bpm_service_request") {
  21674. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  21675. angular.extend(vm.model.serviceCatalogueProcessActual, {
  21676. category: {
  21677. id: $stateParams.userId,
  21678. },
  21679. });
  21680. }
  21681. if (vm.model.schedule && vm.model.schedule.initUser) {
  21682. delete vm.model.schedule.initUser.menu;
  21683. }
  21684. if (
  21685. vm.model.isHandlerUser == "true" ||
  21686. vm.model.isHandlerUser == true
  21687. ) {
  21688. delete vm.model.candidateGroups;
  21689. }
  21690. if (vm.model.start_code == "close") {
  21691. // 直接处理
  21692. vm.model.incident.handlingPersonnelUser =
  21693. vm.model.incident.acceptUser;
  21694. delete vm.model.incident.handlerUser;
  21695. delete vm.model.candidateGroups;
  21696. } else if (vm.model.start_code == "assignment") {
  21697. // 派单
  21698. delete vm.model.incident.handlingPersonnelUser;
  21699. }
  21700. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  21701. $scope.jry_processInstanceId =
  21702. $stateParams.processInstanceId;
  21703. }
  21704. if ($scope.jry_processInstanceId) {
  21705. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  21706. }
  21707. //事件暂存判断
  21708. if (vm.model.saveAgain) {
  21709. if (
  21710. vm.model.directClose == "1" ||
  21711. vm.model.directClose == true
  21712. ) {
  21713. vm.model.start_code = "assignment";
  21714. vm.model.temporary_code = "assignment";
  21715. } else {
  21716. vm.model.start_code = "close";
  21717. vm.model.temporary_code = "close";
  21718. }
  21719. if (
  21720. vm.model.isHandlerUser == "true" ||
  21721. vm.model.isHandlerUser == true
  21722. ) {
  21723. delete vm.model.candidateGroups;
  21724. }
  21725. }
  21726. //处理请求数据0327
  21727. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21728. delete data0327.repairType;
  21729. if (data0327.start_code == "close") {
  21730. data0327.incident.directProcess = 1;
  21731. }
  21732. console.log(vm);
  21733. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  21734. var paramsModel = JSON.parse($stateParams.model)
  21735. //来电-传话机id
  21736. if (paramsModel.model.incident.sockid) {
  21737. data0327.incident.callID = paramsModel.model.incident.sockid;
  21738. }
  21739. }
  21740. // --------------------------- start----------------------------------------
  21741. // 积分机制,直接处理
  21742. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21743. $modal.open({
  21744. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21745. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21746. console.log(incidentData,currentUserId);
  21747. $scope.flag = false;
  21748. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21749. $scope.complexityFn = function(category){
  21750. if(category.complexity){
  21751. return category.complexity.value;
  21752. }else if(category.parent){
  21753. return $scope.complexityFn(category.parent);
  21754. }else{
  21755. return $scope.list[0]?$scope.list[0].value:1;
  21756. }
  21757. }
  21758. $scope.list = [];
  21759. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21760. $scope.list = res;
  21761. if(incidentData.category && incidentData.category.id){
  21762. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21763. if(result.status == 200){
  21764. $scope.complexity = $scope.complexityFn(result.data);
  21765. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21766. }
  21767. })
  21768. }
  21769. })
  21770. $scope.onChangeComplexity = function(item){
  21771. }
  21772. $scope.ok = function () {
  21773. if (!$scope.complexityConfirm.complexity){
  21774. Alert.swal({
  21775. title: "操作失败",
  21776. text: "请选择工时!",
  21777. type: "error"
  21778. });
  21779. return;
  21780. }
  21781. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21782. Alert.swal({
  21783. title: "操作失败",
  21784. text: "请填写升级原因!",
  21785. type: "error"
  21786. });
  21787. return;
  21788. }
  21789. $modalInstance.close('success');
  21790. handlerStart();
  21791. scope.complexity = $scope.complexity;
  21792. scope.complexityConfirm = $scope.complexityConfirm;
  21793. // 暂存--后面直接处理后调用积分接口
  21794. }
  21795. $scope.cancel = function () {
  21796. scope.ldloading.expand_right = false;
  21797. $modalInstance.dismiss('cancel');
  21798. }
  21799. },
  21800. size: 'sm',
  21801. resolve: {
  21802. scope: function () {
  21803. return $scope;
  21804. },
  21805. api_bpm: function () {
  21806. return api_bpm;
  21807. },
  21808. incidentData: function () {
  21809. return data0327.incident;
  21810. },
  21811. currentUserId: function () {
  21812. return loginUser.id;
  21813. },
  21814. Alert: function () {
  21815. return SweetAlert;
  21816. },
  21817. api_user_data: function () {
  21818. return api_user_data;
  21819. },
  21820. api_wechatfile: function () {
  21821. return api_wechatfile;
  21822. }
  21823. }
  21824. });
  21825. }else{
  21826. handlerStart();
  21827. }
  21828. // -------------------------------end------------------------------------
  21829. function handlerStart(){
  21830. api_bpm_domain
  21831. .start(pdKey, data0327)
  21832. .then(function (response) {
  21833. if (response) {
  21834. var resData = Restangular.stripRestangular(response);
  21835. if (resData) {
  21836. if (resData) {
  21837. if (
  21838. $scope.fileUploader != null &&
  21839. $scope.fileUploader.getNotUploadedItems().length >
  21840. 0 &&
  21841. resData.id
  21842. ) {
  21843. $scope.fileUploader.onBeforeUploadItem =
  21844. function (item) {
  21845. angular.extend(
  21846. item.headers,
  21847. $rootScope.getSession()
  21848. );
  21849. item.url = api_bpm_domain
  21850. .uploadAttachment(
  21851. resData.id,
  21852. "00000",
  21853. $rootScope.user.id
  21854. )
  21855. .getRequestedUrl();
  21856. item.formData.push({
  21857. fileName: item.file.name,
  21858. });
  21859. //console.log();
  21860. };
  21861. $scope.fileUploader.uploadAll();
  21862. }
  21863. }
  21864. }
  21865. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21866. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21867. var auditState = res.find(v=>v.value == 0);
  21868. var postData = {
  21869. incidentIntegral: {
  21870. incidentId:resData.bussId,
  21871. auditState:auditState,
  21872. handlerUser:$rootScope.user.id,
  21873. handlerUserName:$rootScope.user.name,
  21874. sourceScore:$scope.complexity,
  21875. currentScore:$scope.complexityConfirm.complexity.value,
  21876. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21877. }
  21878. }
  21879. console.log(postData)
  21880. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21881. console.log(response)
  21882. if (response.status == 200) {
  21883. SweetAlert.swal(
  21884. {
  21885. title: "提交成功!",
  21886. type: "success",
  21887. confirmButtonColor: "#007AFF",
  21888. },
  21889. function () {
  21890. if (
  21891. vm.model.incident &&
  21892. vm.model.incident.callID &&
  21893. vm.model.incident.callID != ""
  21894. ) {
  21895. $rootScope.app.layout.isSidebarClosed = false;
  21896. if ($scope.login && !$rootScope.busy) {
  21897. $rootScope.setidle();
  21898. }
  21899. }
  21900. $state.go($scope.formData.cancelUrl);
  21901. }
  21902. );
  21903. } else {
  21904. Alert.swal({
  21905. title: "操作失败",
  21906. text: "操作失败, 请稍后再试!",
  21907. type: "error"
  21908. });
  21909. }
  21910. });
  21911. })
  21912. }else{
  21913. SweetAlert.swal(
  21914. {
  21915. title: "提交成功!",
  21916. type: "success",
  21917. confirmButtonColor: "#007AFF",
  21918. },
  21919. function () {
  21920. if (
  21921. vm.model.incident &&
  21922. vm.model.incident.callID &&
  21923. vm.model.incident.callID != ""
  21924. ) {
  21925. $rootScope.app.layout.isSidebarClosed = false;
  21926. if ($scope.login && !$rootScope.busy) {
  21927. $rootScope.setidle();
  21928. }
  21929. }
  21930. $state.go($scope.formData.cancelUrl);
  21931. }
  21932. );
  21933. }
  21934. } else {
  21935. SweetAlert.swal({
  21936. title: "系统错误",
  21937. text: "系统错误,请稍后重试!",
  21938. type: "error",
  21939. confirmButtonColor: "#DD6B55",
  21940. });
  21941. }
  21942. $scope.ldloading[style.replace("-", "_")] = false;
  21943. });
  21944. }
  21945. break;
  21946. case "complete":
  21947. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  21948. //console.log("complete taskId::"+$stateParams.taskId);
  21949. if (
  21950. $scope.formData.name == "transferform" &&
  21951. vm.model.ishandlers &&
  21952. !vm.model.incident.handlerUser
  21953. ) {
  21954. SweetAlert.swal({
  21955. title: "处理人未填",
  21956. text: "请填写此项!",
  21957. type: "error",
  21958. confirmButtonColor: "#DD6B55",
  21959. });
  21960. return;
  21961. }
  21962. console.log(vm);
  21963. // 积分机制,事件状态是“处理中”
  21964. if($scope.formData.name === 'handlerform'&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21965. $modal.open({
  21966. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21967. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21968. console.log(incidentData,currentUserId);
  21969. $scope.flag = true;
  21970. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21971. $scope.complexityFn = function(category){
  21972. if(category.complexity){
  21973. return category.complexity.value;
  21974. }else if(category.parent){
  21975. return $scope.complexityFn(category.parent);
  21976. }else{
  21977. return $scope.list[0]?$scope.list[0].value:1;
  21978. }
  21979. }
  21980. $scope.list = [];
  21981. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21982. $scope.list = res;
  21983. if(incidentData.category && incidentData.category.id){
  21984. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21985. if(result.status == 200){
  21986. $scope.complexity = $scope.complexityFn(result.data);
  21987. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21988. }
  21989. })
  21990. }
  21991. })
  21992. $scope.onChangeComplexity = function(item){
  21993. if($scope.complexityConfirm.complexity.value == $scope.complexity){
  21994. $scope.complexityConfirm.updateReason = '';
  21995. }
  21996. }
  21997. $scope.ok = function () {
  21998. if (!$scope.complexityConfirm.complexity){
  21999. Alert.swal({
  22000. title: "操作失败",
  22001. text: "请选择工时!",
  22002. type: "error"
  22003. });
  22004. return;
  22005. }
  22006. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  22007. Alert.swal({
  22008. title: "操作失败",
  22009. text: "请填写升级原因!",
  22010. type: "error"
  22011. });
  22012. return;
  22013. }
  22014. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  22015. // var auditState = $scope.complexityConfirm.complexity.value == $scope.complexity?res.find(v=>v.value == 1):res.find(v=>v.value == 0);
  22016. var auditState = res.find(v=>v.value == 0);
  22017. var postData = {
  22018. incidentIntegral: {
  22019. incidentId:incidentData.id,
  22020. auditState:auditState,
  22021. handlerUser:$rootScope.user.id,
  22022. handlerUserName:$rootScope.user.name,
  22023. sourceScore:$scope.complexity,
  22024. currentScore:$scope.complexityConfirm.complexity.value,
  22025. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  22026. }
  22027. }
  22028. console.log(postData)
  22029. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  22030. console.log(response)
  22031. if (response.status == 200) {
  22032. $modalInstance.close('success');
  22033. handlerLogFn();
  22034. } else {
  22035. Alert.swal({
  22036. title: "操作失败",
  22037. text: "操作失败, 请稍后再试!",
  22038. type: "error"
  22039. });
  22040. }
  22041. });
  22042. })
  22043. }
  22044. $scope.cancel = function () {
  22045. scope.ldloading.expand_right = false;
  22046. $modalInstance.dismiss('cancel');
  22047. }
  22048. },
  22049. size: 'sm',
  22050. resolve: {
  22051. scope: function () {
  22052. return $scope;
  22053. },
  22054. api_bpm: function () {
  22055. return api_bpm;
  22056. },
  22057. incidentData: function () {
  22058. return $scope.formData.model.incident;
  22059. },
  22060. currentUserId: function () {
  22061. return loginUser.id;
  22062. },
  22063. Alert: function () {
  22064. return SweetAlert;
  22065. },
  22066. api_user_data: function () {
  22067. return api_user_data;
  22068. },
  22069. api_wechatfile: function () {
  22070. return api_wechatfile;
  22071. }
  22072. }
  22073. });
  22074. }else{
  22075. handlerLogFn();
  22076. }
  22077. function handlerLogFn(){
  22078. //维修记录
  22079. // 维修记录不为空并且事件是处理中状态
  22080. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  22081. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  22082. baseHandler();
  22083. })
  22084. } else {
  22085. if($stateParams.formUiEdit === 'inspection_LinHu_confirm'){
  22086. //巡检计划
  22087. if(vm.model.inspectionProcessActual.group&&vm.model.inspectionProcessActual.group.id){
  22088. api_bpm.assign({ids:$stateParams.dataId.toString(),userId:$rootScope.user.id}).then(function (response) {
  22089. if (response.status == 200) {
  22090. baseHandler();
  22091. } else {
  22092. Alert.swal({
  22093. title: "操作失败",
  22094. text: "操作失败, 请稍后再试!",
  22095. type: "error"
  22096. });
  22097. }
  22098. });
  22099. }else{
  22100. baseHandler();
  22101. }
  22102. }else{
  22103. baseHandler();
  22104. }
  22105. }
  22106. }
  22107. // return;
  22108. function baseHandler() {
  22109. api_bpm_domain
  22110. .complete($stateParams.taskId, userId, vm.model)
  22111. .then(function (response) {
  22112. if (response) {
  22113. var resData = Restangular.stripRestangular(response);
  22114. SweetAlert.swal(
  22115. {
  22116. title: "提交成功!",
  22117. type: "success",
  22118. confirmButtonColor: "#007AFF",
  22119. },
  22120. function () {
  22121. if (
  22122. $scope.fileUploader != null &&
  22123. $scope.fileUploader.getNotUploadedItems().length >
  22124. 0
  22125. ) {
  22126. console.log(vm);
  22127. if (vm.model.incident) {
  22128. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  22129. // angular.extend(item.headers, $rootScope.getSession());
  22130. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  22131. // item.formData.push({
  22132. // 'fileName': item.file.name
  22133. // });
  22134. // };
  22135. // $scope.fileUploader.uploadAll();
  22136. $scope.fileUploader.onBeforeUploadItem =
  22137. function (item) {
  22138. angular.extend(
  22139. item.headers,
  22140. $rootScope.getSession()
  22141. );
  22142. item.url = api_bpm_domain
  22143. .uploadAttachment(
  22144. vm.model.incident.processInstanceId,
  22145. "00000",
  22146. $rootScope.user.id
  22147. )
  22148. .getRequestedUrl();
  22149. item.formData.push({
  22150. fileName: item.file.name,
  22151. });
  22152. //console.log();
  22153. };
  22154. $scope.fileUploader.uploadAll();
  22155. } else if (vm.model.problem) {
  22156. $scope.fileUploader.onBeforeUploadItem =
  22157. function (item) {
  22158. angular.extend(
  22159. item.headers,
  22160. $rootScope.getSession()
  22161. );
  22162. item.url = api_bpm_domain
  22163. .uploadAttachmentJryModel(
  22164. "problem",
  22165. vm.model.problem.id,
  22166. "00000",
  22167. $rootScope.user.id
  22168. )
  22169. .getRequestedUrl();
  22170. item.formData.push({
  22171. fileName: item.file.name,
  22172. });
  22173. };
  22174. $scope.fileUploader.uploadAll();
  22175. } else if (vm.model.change) {
  22176. }else if(vm.model.inspectionProcessActual){
  22177. //巡检图片上传yeye
  22178. $scope.fileUploader.onBeforeUploadItem =
  22179. function (item) {
  22180. angular.extend(
  22181. item.headers,
  22182. $rootScope.getSession()
  22183. );
  22184. item.url = api_bpm_domain1
  22185. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  22186. .getRequestedUrl();
  22187. item.formData.push({
  22188. fileName: item.file.name,
  22189. });
  22190. //console.log();
  22191. };
  22192. $scope.fileUploader.uploadAll();
  22193. }
  22194. }
  22195. $state.go($scope.formData.cancelUrl);
  22196. }
  22197. );
  22198. } else {
  22199. SweetAlert.swal({
  22200. title: "系统错误",
  22201. text: "系统错误,请稍后重试!",
  22202. type: "error",
  22203. confirmButtonColor: "#DD6B55",
  22204. });
  22205. }
  22206. $scope.ldloading[style.replace("-", "_")] = false;
  22207. });
  22208. }
  22209. break;
  22210. case "back":
  22211. $state.go($scope.formData.cancelUrl);
  22212. break;
  22213. default:
  22214. $scope.ldloading[style.replace("-", "_")] = false;
  22215. break;
  22216. }
  22217. }
  22218. // var submitFunc = api_bpm_domain[$scope.formData.url]
  22219. // if(anuglar.isFunction(submitFunc)){
  22220. // submitFunc.apply(null, pdKey)
  22221. // }
  22222. }
  22223. }
  22224. } else {
  22225. // console.log(data)
  22226. // angular.forEach(vm.form.$error.required, function(item){
  22227. // var i=(item.$name).substring(item.$name.length-2)
  22228. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  22229. // for(var i=0;i<vm.fields.length;i++){
  22230. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  22231. SweetAlert.swal({
  22232. title: vm.fields[i].templateOptions.label + "未填",
  22233. text: "请填写此项!",
  22234. type: "error",
  22235. confirmButtonColor: "#DD6B55",
  22236. });
  22237. }
  22238. // }
  22239. // angular.forEach(vm.fields,function(f){
  22240. // if(f.name == item.$name){
  22241. // f.validation.show = true;
  22242. // SweetAlert.swal({
  22243. // title: f.templateOptions.label+'未填',
  22244. // text: "请填写此项!",
  22245. // type: "error",
  22246. // confirmButtonColor: "#DD6B55"
  22247. // });
  22248. // }
  22249. // });
  22250. // })
  22251. }
  22252. };
  22253. $scope.vm = vm;
  22254. console.log($stateParams, pdKey, 88888);
  22255. console.log($scope.vm, "assdfsdf");
  22256. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  22257. var processInstanceId = $stateParams.processInstanceId;
  22258. var itemId = $stateParams.dataId;
  22259. console.log($stateParams);
  22260. if (
  22261. angular.isDefined($stateParams.pdKey) &&
  22262. $stateParams.pdKey == "bpm_inspection"
  22263. ) {
  22264. api_configure_form
  22265. .renderForm(
  22266. $stateParams.formUiEdit,
  22267. userId,
  22268. processInstanceId,
  22269. itemId
  22270. )
  22271. .then(function (responseData) {
  22272. if (responseData) {
  22273. //console.log("responseData>>>");//console.log(responseData);
  22274. var vmForm = Restangular.stripRestangular(responseData);
  22275. if (vmForm) {
  22276. //console.log("vmForm>>>");//console.log(vmForm);
  22277. decodeVMForm(vmForm);
  22278. }
  22279. }
  22280. });
  22281. } else if (
  22282. angular.isDefined($stateParams.pdKey) &&
  22283. $stateParams.pdKey == "bpm_service_request"
  22284. ) {
  22285. api_configure_form
  22286. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  22287. .then(function (responseData) {
  22288. if (responseData) {
  22289. //console.log("responseData>>>");//console.log(responseData);
  22290. var vmForm = Restangular.stripRestangular(responseData);
  22291. if (vmForm) {
  22292. //console.log("vmForm>>>");//console.log(vmForm);
  22293. decodeVMForm(vmForm);
  22294. }
  22295. }
  22296. });
  22297. } else {
  22298. api_bpm_domain
  22299. .taskformkey($stateParams.taskId)
  22300. .then(function (response) {
  22301. if (response) {
  22302. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  22303. api_configure_form
  22304. .renderForm(myData.data, userId, processInstanceId, itemId)
  22305. .then(function (responseData) {
  22306. if (responseData) {
  22307. //console.log("responseData>>>");//console.log(responseData);
  22308. var vmForm = Restangular.stripRestangular(responseData);
  22309. if (vmForm) {
  22310. //console.log("vmForm>>>");//console.log(vmForm);
  22311. decodeVMForm(vmForm);
  22312. console.log(vmForm, 111111);
  22313. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  22314. console.log($scope, "今天"); //2020年4月24日11:40:55
  22315. }
  22316. }
  22317. });
  22318. }
  22319. });
  22320. }
  22321. } else {
  22322. // create process instance
  22323. if (pdKey != "") {
  22324. //for process
  22325. if (pdKey == "bpm_service_request") {
  22326. api_configure_form
  22327. .renderForm($stateParams.formUiStart, userId)
  22328. .then(function (responseData) {
  22329. if (responseData) {
  22330. var vmForm = Restangular.stripRestangular(responseData);
  22331. if (vmForm) {
  22332. decodeVMForm(vmForm);
  22333. }
  22334. }
  22335. });
  22336. } else {
  22337. api_bpm_domain.startformkey(pdKey).then(function (response) {
  22338. if (response) {
  22339. var myData = Restangular.stripRestangular(response);
  22340. //myData.data = "arrangeform";
  22341. api_configure_form
  22342. .renderForm(myData.data, userId)
  22343. .then(function (responseData) {
  22344. if (responseData) {
  22345. var vmForm = Restangular.stripRestangular(responseData);
  22346. if (vmForm) {
  22347. decodeVMForm(vmForm);
  22348. }
  22349. }
  22350. });
  22351. }
  22352. });
  22353. }
  22354. } else {
  22355. //for form
  22356. //TODO
  22357. //测试数据 开始
  22358. var testJson = {
  22359. fields: [
  22360. {
  22361. fields: [
  22362. {
  22363. className: "col-xs-12",
  22364. noFormControl: true,
  22365. key: "formtitle",
  22366. templateOptions: {
  22367. readOnly: false,
  22368. placeholder: "新建事件单",
  22369. hidden: false,
  22370. label: "事件工单",
  22371. required: false,
  22372. },
  22373. type: "ui-title",
  22374. },
  22375. ],
  22376. },
  22377. {
  22378. fields: [
  22379. {
  22380. key: "selectUser",
  22381. type: "ui-deptinformation",
  22382. className: "col-xs-12",
  22383. templateOptions: {
  22384. label: "请求人信息",
  22385. modalTitle: "请求人列表",
  22386. fetchItems: function (filterData, APIService) {
  22387. return APIService.fetchDataList("requester", filterData);
  22388. },
  22389. Restangular: Restangular,
  22390. ApiService: api_user_data,
  22391. // onClick:function(val, options, field, event , model){
  22392. // console.log(options);
  22393. // }
  22394. },
  22395. },
  22396. ],
  22397. },
  22398. {
  22399. fields: [
  22400. {
  22401. key: "first",
  22402. type: "ui-workernumber",
  22403. className: "col-xs-12",
  22404. templateOptions: {
  22405. type: "input",
  22406. label: "事件单号",
  22407. pkey: "name",
  22408. },
  22409. },
  22410. ],
  22411. },
  22412. {
  22413. fields: [
  22414. {
  22415. type: "ui-header",
  22416. key: "title",
  22417. className: "col-xs-12",
  22418. templateOptions: {
  22419. label: "报修人",
  22420. pkey: "change",
  22421. },
  22422. },
  22423. {
  22424. type: "ui-input",
  22425. key: "title",
  22426. className: "col-xs-4",
  22427. templateOptions: {
  22428. label: "报修人",
  22429. pkey: "change",
  22430. },
  22431. },
  22432. {
  22433. type: "ui-input",
  22434. key: "title",
  22435. className: "col-xs-4",
  22436. templateOptions: {
  22437. label: "联系人",
  22438. pkey: "change",
  22439. },
  22440. },
  22441. {
  22442. type: "ui-input",
  22443. key: "title",
  22444. className: "col-xs-4",
  22445. templateOptions: {
  22446. label: "联系电话",
  22447. pkey: "change",
  22448. },
  22449. },
  22450. ],
  22451. },
  22452. {
  22453. fields: [
  22454. {
  22455. type: "ui-header",
  22456. key: "title1",
  22457. className: "col-xs-12",
  22458. templateOptions: {
  22459. label: "报修人",
  22460. pkey: "change",
  22461. },
  22462. },
  22463. {
  22464. type: "ui-input",
  22465. key: "title2",
  22466. className: "col-xs-4",
  22467. templateOptions: {
  22468. label: "报修人",
  22469. pkey: "change",
  22470. },
  22471. },
  22472. {
  22473. type: "ui-input",
  22474. key: "title3",
  22475. className: "col-xs-4",
  22476. templateOptions: {
  22477. label: "联系人",
  22478. pkey: "change",
  22479. },
  22480. },
  22481. {
  22482. type: "ui-input",
  22483. key: "title4",
  22484. className: "col-xs-4",
  22485. templateOptions: {
  22486. label: "联系电话",
  22487. pkey: "change",
  22488. },
  22489. },
  22490. ],
  22491. },
  22492. ],
  22493. model: [
  22494. {
  22495. username: "robin lau",
  22496. password: "123456",
  22497. chkme: false,
  22498. start_code: 0,
  22499. formtitle: "Hey!I am title value!",
  22500. name: {
  22501. first: "robin",
  22502. last: "lau",
  22503. },
  22504. multiselectItem: [],
  22505. //date:"2015-09-15 00:00:00"
  22506. },
  22507. ],
  22508. // }
  22509. };
  22510. setTimeout(function () {
  22511. decodeVMForm(testJson);
  22512. $scope.$apply();
  22513. }, 500);
  22514. //测试数据结束
  22515. }
  22516. }
  22517. //console.log("end decode");
  22518. },
  22519. ]);