customformCtrl.js 852 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122
  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. user: {
  1751. engineer: 1,
  1752. }
  1753. })
  1754. .then(function (data) {
  1755. $scope.handlingPersonnelUser = data.list;
  1756. });
  1757. $scope.gridOptions.columnDefs = items.columnDefs();
  1758. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1759. $scope.gridApi = gridApi;
  1760. gridApi.pagination.on.paginationChanged(
  1761. $scope,
  1762. function (newPage, pageSize) {
  1763. // console.log(newPage);
  1764. // console.log(pageSize);
  1765. $scope.loadData({
  1766. idx: newPage - 1,
  1767. sum: pageSize,
  1768. });
  1769. }
  1770. );
  1771. gridApi.core.on.filterChanged($scope, function () { });
  1772. gridApi.selection.on.rowSelectionChanged(
  1773. $scope,
  1774. function (data) {
  1775. $scope.selected.item = data.entity;
  1776. //console.log(data);
  1777. }
  1778. );
  1779. };
  1780. $scope.loadData = function (filterData) {
  1781. items.fetchItems(filterData, APIService).then(function (data) {
  1782. var myData = Restangular.stripRestangular(data);
  1783. $scope.gridOptions.totalItems = myData.totalNum;
  1784. $scope.myData = myData.list;
  1785. for (var i = 0; i < $scope.myData.length; i++) {
  1786. $scope.myData[i]["item"] =
  1787. i + 1 + filterData.idx * filterData.sum;
  1788. }
  1789. });
  1790. };
  1791. $scope.title = title;
  1792. $scope.loadData({
  1793. idx: 0,
  1794. sum: 10,
  1795. assignee: $rootScope.user.id,
  1796. candidateGroups: $rootScope.user.group[0].id,
  1797. searchType: "todo",
  1798. });
  1799. $scope.selected = {
  1800. item: {},
  1801. };
  1802. $scope.ok = function () {
  1803. //console.log($scope.selected.item);
  1804. $modalInstance.close($scope.selected.item);
  1805. };
  1806. $scope.cancel = function () {
  1807. $modalInstance.dismiss("cancel");
  1808. };
  1809. },
  1810. size: "lg",
  1811. resolve: {
  1812. items: function () {
  1813. return {
  1814. fetchItems: function (filterData, APIService) {
  1815. filterData = filterData || {};
  1816. // if(!filterData.idx){
  1817. if (
  1818. angular.isDefined(filterData.idx) &&
  1819. filterData.idx == null
  1820. ) {
  1821. filterData = {
  1822. idx: 0,
  1823. sum: 10,
  1824. };
  1825. }
  1826. return options.templateOptions.fetchItems(
  1827. filterData,
  1828. APIService,
  1829. options
  1830. );
  1831. },
  1832. columnDefs: function () {
  1833. return options.templateOptions.columnDefs;
  1834. },
  1835. };
  1836. },
  1837. title: function () {
  1838. return options.templateOptions.modalTitle;
  1839. },
  1840. Restangular: function () {
  1841. return options.templateOptions.Restangular;
  1842. },
  1843. APIService: function () {
  1844. return options.templateOptions.ApiService;
  1845. },
  1846. },
  1847. });
  1848. modalInstance.result.then(
  1849. function (selectedItem) {
  1850. var selectitem = {
  1851. title: selectedItem.title,
  1852. description: selectedItem.description,
  1853. };
  1854. if (options.key == "chuku") {
  1855. if (selectedItem.assets) {
  1856. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1857. selectedItem.assets;
  1858. }
  1859. if (selectedItem.consumables) {
  1860. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1861. selectedItem.consumables;
  1862. }
  1863. angular.extend(
  1864. $scope.$parent.$parent.$parent.model,
  1865. selectitem
  1866. );
  1867. options.value(selectedItem);
  1868. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1869. } else {
  1870. angular.extend(options.model, selectitem);
  1871. options.value(selectedItem);
  1872. }
  1873. },
  1874. function () {
  1875. //console.log('Modal dismissed at: ' + new Date());
  1876. }
  1877. );
  1878. };
  1879. },
  1880. ],
  1881. });
  1882. //文本框
  1883. formlyConfigProvider.setType({
  1884. name: "ui-textcmdb",
  1885. extends: "",
  1886. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1887. defaultOptions: function (options) {
  1888. return {
  1889. templateOptions: {
  1890. transform: function (model, value) {
  1891. return value;
  1892. },
  1893. },
  1894. validation: {
  1895. messages: {
  1896. maxlength: function (viewValue, modelValue, scope) {
  1897. if (viewValue != null) {
  1898. if (viewValue.length > scope.to.maxlength) {
  1899. return (
  1900. scope.to.label +
  1901. " 字数(" +
  1902. viewValue.length +
  1903. ")超限(" +
  1904. scope.to.maxlength +
  1905. ")"
  1906. );
  1907. } else {
  1908. return "";
  1909. }
  1910. }
  1911. },
  1912. },
  1913. },
  1914. };
  1915. },
  1916. controller: [
  1917. "$scope",
  1918. function ($scope) {
  1919. var value = $scope.model[$scope.options.key];
  1920. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1921. $scope.model[$scope.options.key] =
  1922. $scope.options.templateOptions.transform(
  1923. $scope.originalModel,
  1924. value
  1925. );
  1926. }
  1927. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1928. $scope.options.templateOptions.felditem($scope);
  1929. }
  1930. },
  1931. ],
  1932. });
  1933. //设备组件
  1934. formlyConfigProvider.setType({
  1935. name: "ui-applist",
  1936. extends: "radio",
  1937. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1938. defaultOptions: function (options) {
  1939. return {
  1940. templateOptions: {
  1941. refresh: function () { },
  1942. refreshDelay: 0,
  1943. },
  1944. };
  1945. },
  1946. controller: [
  1947. "$scope",
  1948. "$filter",
  1949. "ngTableParams",
  1950. function ($scope, $filter, ngTableParams) {
  1951. var data = [];
  1952. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1953. // data = JSON.parse($scope.model.consumables);
  1954. if (angular.isArray($scope.model.consumables)) {
  1955. data = $scope.model.consumables;
  1956. } else {
  1957. data = JSON.parse($scope.model.consumables);
  1958. }
  1959. $scope.model.consumables = data;
  1960. angular.forEach(data, function (item, index) {
  1961. data[index].item = index + 1;
  1962. });
  1963. }
  1964. if ($scope.model.assets && $scope.options.key == "assets") {
  1965. if (angular.isArray($scope.model.assets)) {
  1966. data = $scope.model.assets;
  1967. } else {
  1968. data = JSON.parse($scope.model.assets);
  1969. }
  1970. // data = JSON.parse($scope.model.assets);
  1971. $scope.model.assets = data;
  1972. angular.forEach(data, function (item, index) {
  1973. data[index].item = index + 1;
  1974. });
  1975. }
  1976. $scope.tableParams = new ngTableParams(
  1977. {
  1978. page: 1,
  1979. count: 5,
  1980. },
  1981. {
  1982. total: data.length,
  1983. getData: function ($defer, params) {
  1984. var orderedData = params.sorting()
  1985. ? $filter("orderBy")(data, params.orderBy())
  1986. : data;
  1987. $defer.resolve(
  1988. orderedData.slice(
  1989. (params.page() - 1) * params.count(),
  1990. params.page() * params.count()
  1991. )
  1992. );
  1993. },
  1994. }
  1995. );
  1996. $scope.editId = -1;
  1997. $scope.setEditId = function (pid) {
  1998. $scope.editId = pid;
  1999. };
  2000. },
  2001. ],
  2002. });
  2003. //list组件
  2004. formlyConfigProvider.setType({
  2005. name: "ui-gudinglist",
  2006. extends: "radio",
  2007. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2008. defaultOptions: function (options) {
  2009. return {
  2010. templateOptions: {
  2011. refresh: function () { },
  2012. refreshDelay: 0,
  2013. },
  2014. };
  2015. },
  2016. controller: [
  2017. "$scope",
  2018. "$filter",
  2019. "ngTableParams",
  2020. function ($scope, $filter, ngTableParams) {
  2021. var data = [];
  2022. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2023. // data = JSON.parse($scope.model.consumables);
  2024. if (angular.isArray($scope.model.consumables)) {
  2025. data = $scope.model.consumables;
  2026. } else {
  2027. data = JSON.parse($scope.model.consumables);
  2028. }
  2029. $scope.model.consumables = data;
  2030. angular.forEach(data, function (item, index) {
  2031. data[index].item = index + 1;
  2032. });
  2033. }
  2034. if ($scope.model.assets && $scope.options.key == "assets") {
  2035. if (angular.isArray($scope.model.assets)) {
  2036. data = $scope.model.assets;
  2037. } else {
  2038. data = JSON.parse($scope.model.assets);
  2039. }
  2040. // data = JSON.parse($scope.model.assets);
  2041. $scope.model.assets = data;
  2042. angular.forEach(data, function (item, index) {
  2043. data[index].item = index + 1;
  2044. });
  2045. }
  2046. $scope.tableParams = new ngTableParams(
  2047. {
  2048. page: 1,
  2049. count: 5,
  2050. },
  2051. {
  2052. total: data.length,
  2053. getData: function ($defer, params) {
  2054. var orderedData = params.sorting()
  2055. ? $filter("orderBy")(data, params.orderBy())
  2056. : data;
  2057. $defer.resolve(
  2058. orderedData.slice(
  2059. (params.page() - 1) * params.count(),
  2060. params.page() * params.count()
  2061. )
  2062. );
  2063. },
  2064. }
  2065. );
  2066. $scope.editId = -1;
  2067. $scope.setEditId = function (pid) {
  2068. $scope.editId = pid;
  2069. };
  2070. },
  2071. ],
  2072. });
  2073. //other list tab组件
  2074. formlyConfigProvider.setType({
  2075. name: "ui-otherlisttab",
  2076. extends: "",
  2077. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2078. defaultOptions: function (options) {
  2079. return {
  2080. templateOptions: {
  2081. refresh: function () { },
  2082. refreshDelay: 0,
  2083. },
  2084. };
  2085. },
  2086. controller: [
  2087. "$scope",
  2088. "$filter",
  2089. "ngTableParams",
  2090. function ($scope, $filter, ngTableParams) { },
  2091. ],
  2092. });
  2093. //审核查看组件
  2094. formlyConfigProvider.setType({
  2095. name: "ui-aprovelist",
  2096. extends: "",
  2097. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2098. defaultOptions: function (options) {
  2099. return {
  2100. templateOptions: {
  2101. refresh: function () { },
  2102. refreshDelay: 0,
  2103. },
  2104. };
  2105. },
  2106. controller: [
  2107. "$scope",
  2108. "$filter",
  2109. "ngTableParams",
  2110. function ($scope, $filter, ngTableParams) {
  2111. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2112. $scope.isAgree = "同意";
  2113. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2114. $scope.isAgree = "同意";
  2115. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2116. $scope.isAgree = "返回修改";
  2117. }
  2118. },
  2119. ],
  2120. });
  2121. //other list组件
  2122. formlyConfigProvider.setType({
  2123. name: "ui-otherlist",
  2124. extends: "",
  2125. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2126. defaultOptions: function (options) {
  2127. return {
  2128. templateOptions: {
  2129. refresh: function () { },
  2130. refreshDelay: 0,
  2131. },
  2132. };
  2133. },
  2134. controller: [
  2135. "$rootScope",
  2136. "$scope",
  2137. "$parse",
  2138. "$injector",
  2139. "$http",
  2140. "$q",
  2141. "$state",
  2142. "$stateParams",
  2143. "$modal",
  2144. "$timeout",
  2145. "$interval",
  2146. "i18nService",
  2147. "SweetAlert",
  2148. "FileUploader",
  2149. "Restangular",
  2150. "UserRestangular",
  2151. "BpmRestangular",
  2152. "api_configure_form",
  2153. "api_configure_data",
  2154. "api_bpm_domain",
  2155. "api_bpm_data",
  2156. "api_user_data",
  2157. "api_cmdb",
  2158. "api_sysinfo",
  2159. function (
  2160. $rootScope,
  2161. $scope,
  2162. $parse,
  2163. $injector,
  2164. $http,
  2165. $q,
  2166. $state,
  2167. $stateParams,
  2168. $modal,
  2169. $timeout,
  2170. $interval,
  2171. i18nService,
  2172. SweetAlert,
  2173. FileUploader,
  2174. Restangular,
  2175. UserRestangular,
  2176. BpmRestangular,
  2177. api_configure_form,
  2178. api_configure_data,
  2179. api_bpm_domain,
  2180. api_bpm_data,
  2181. api_user_data,
  2182. api_cmdb,
  2183. api_sysinfo
  2184. ) {
  2185. console.log("哈哈");
  2186. console.log($scope);
  2187. $scope.langs = i18nService.getAllLangs();
  2188. $scope.lang = "zh-cn";
  2189. i18nService.setCurrentLang($scope.lang);
  2190. var vm = this;
  2191. vm.options = {};
  2192. vm.exampleTitle = ["expressionProperties", "model property"];
  2193. vm.fields = [];
  2194. vm.models = {};
  2195. // vm.models["loginUser"] = $rootScope.user;
  2196. var that = $injector;
  2197. var parse = $parse;
  2198. var formKey = "";
  2199. var pdKey = "";
  2200. if (
  2201. angular.isDefined($state.current.pdKey) &&
  2202. $state.current.pdKey != ""
  2203. ) {
  2204. pdKey = $state.current.pdKey;
  2205. //console.log("pdKey::"+$state.current.pdKey);
  2206. }
  2207. if (
  2208. angular.isDefined($stateParams.formKey) &&
  2209. $stateParams.formKey != ""
  2210. ) {
  2211. formKey = $stateParams.formKey;
  2212. //console.log("formKey::"+$stateParams.formKey);
  2213. }
  2214. //用户测试数据,后续从header的auth中获取
  2215. var userId = 2;
  2216. userId = $rootScope.user.id;
  2217. //==============处理表单设计数据 开始====================
  2218. //处理组件加载后台数据选项的方法
  2219. function refreshSelectOptions(searchVal, field) {
  2220. if (field.templateOptions.optionsUrl) {
  2221. var process = BpmRestangular.all("");
  2222. if (field.templateOptions.ApiService) {
  2223. process = UserRestangular.all("");
  2224. }
  2225. process
  2226. .customPOST(
  2227. {
  2228. idx: 0,
  2229. sum: 1000,
  2230. },
  2231. field.templateOptions.optionsUrl
  2232. )
  2233. .then(function (result) {
  2234. if (!field.templateOptions.options) {
  2235. field.templateOptions.options = [];
  2236. }
  2237. if (field.templateOptions.optionsDataKey) {
  2238. field.templateOptions.options =
  2239. result[field.templateOptions.optionsDataKey];
  2240. } else {
  2241. field.templateOptions.options = result;
  2242. }
  2243. });
  2244. }
  2245. }
  2246. function decodeVMTabForm(model, tabs) {
  2247. var result = {
  2248. model: {},
  2249. tabs: [],
  2250. };
  2251. var mdata = angular.fromJson(model);
  2252. angular.extend(result.model, mdata);
  2253. angular.forEach(tabs, function (tab) {
  2254. tab.form.model = vm.models;
  2255. angular.forEach(tab.form.fields, function (field) {
  2256. if (field.key == "") {
  2257. delete field.key;
  2258. }
  2259. field.type = "ui-otherlisttab";
  2260. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2261. var extObj = angular.fromJson(field.extjson);
  2262. angular.extend(field.templateOptions, extObj.templateOptions);
  2263. delete extObj.templateOptions;
  2264. for (var prop in extObj) {
  2265. if (new RegExp("Expression").test(prop)) {
  2266. //var obj = $scope.$eval(extObj[prop]);
  2267. //extObj[prop] = $scope.$eval(extObj[prop]);
  2268. if (extObj[prop] != null) {
  2269. if (new RegExp("function").test(extObj[prop])) {
  2270. var propValue = eval(extObj[prop]);
  2271. extObj[prop] = propValue;
  2272. } else {
  2273. //console.log(extObj[prop]);
  2274. var obj = $scope.$eval(extObj[prop]);
  2275. extObj[prop] = obj;
  2276. //console.log(obj);
  2277. }
  2278. }
  2279. } else if (new RegExp("expressionProperties").test(prop)) {
  2280. for (var p in extObj[prop]) {
  2281. if (new RegExp("function").test(extObj[prop][p])) {
  2282. var propValue = eval(extObj[prop][p]);
  2283. extObj[prop][p] = propValue;
  2284. } else {
  2285. //if(p.indexOf("'")>=0){
  2286. // var obj = $scope.$eval(extObj[prop][p]);
  2287. // extObj[prop][$scope.$eval(p)]=obj;
  2288. //}
  2289. }
  2290. }
  2291. } else if ("watcher" == prop) {
  2292. if (angular.isArray(extObj[prop])) {
  2293. angular.forEach(extObj[prop], function (item, index) {
  2294. for (var p in item) {
  2295. if (new RegExp("function").test(item[p])) {
  2296. var propValue = eval(item[p]);
  2297. extObj[prop][index][p] = propValue;
  2298. }
  2299. }
  2300. });
  2301. } else if (angular.isObject(extObj[prop])) {
  2302. for (var p in extObj[prop]) {
  2303. if (new RegExp("function").test(extObj[prop][p])) {
  2304. var propValue = eval(extObj[prop][p]);
  2305. extObj[prop][p] = propValue;
  2306. }
  2307. }
  2308. }
  2309. }
  2310. }
  2311. angular.extend(field, extObj);
  2312. delete field.extjson;
  2313. }
  2314. if (field.extjson == "") {
  2315. delete field.extjson;
  2316. }
  2317. if (angular.isDefined(field.templateOptions)) {
  2318. var templateOs = field.templateOptions;
  2319. for (var property in templateOs) {
  2320. //console.log(property);
  2321. if (
  2322. angular.isString(templateOs[property]) &&
  2323. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2324. ) {
  2325. if (new RegExp("function").test(templateOs[property])) {
  2326. var propValue = eval(templateOs[property]);
  2327. field.templateOptions[property] = propValue;
  2328. } else {
  2329. if (that.has(templateOs[property])) {
  2330. field.templateOptions[property] = that.get(
  2331. templateOs[property]
  2332. );
  2333. } else {
  2334. field.templateOptions[property] = templateOs[property];
  2335. }
  2336. }
  2337. } else if (templateOs[property] == null) {
  2338. //delete field.templateOptions[property];
  2339. } else {
  2340. }
  2341. }
  2342. }
  2343. if (
  2344. angular.isDefined(field.templateOptions) &&
  2345. angular.isDefined(field.templateOptions.extjson)
  2346. ) {
  2347. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2348. angular.extend(field.templateOptions, extObj);
  2349. delete field.templateOptions.extjson;
  2350. }
  2351. //...
  2352. if (field.templateOptions) {
  2353. //处理远程获取数据控件方法调用
  2354. if (field.templateOptions.optionsUrl) {
  2355. field.templateOptions.refresh = refreshSelectOptions;
  2356. }
  2357. //处理嵌套属性数据绑定/
  2358. if (field.templateOptions.pkey) {
  2359. var pmodel,
  2360. i = 0;
  2361. angular.forEach(
  2362. field.templateOptions.pkey.split("."),
  2363. function (p) {
  2364. if (i == 0) {
  2365. if (result.model[p] == null) {
  2366. result.model[p] = {};
  2367. }
  2368. pmodel = result.model[p];
  2369. i++;
  2370. } else {
  2371. if (pmodel[p] == null) {
  2372. pmodel[p] = {};
  2373. }
  2374. pmodel = pmodel[p];
  2375. }
  2376. }
  2377. );
  2378. if (pmodel != null) {
  2379. field.model = pmodel;
  2380. if (pmodel[field.key] == null) {
  2381. pmodel[field.key] = null;
  2382. }
  2383. }
  2384. } else {
  2385. if (result.model[field.key] == null) {
  2386. result.model[field.key] = null;
  2387. }
  2388. }
  2389. //处理弹出框组件初始化
  2390. if (field.type == "ui-input-selectmodal") {
  2391. field.templateOptions.modal = $modal;
  2392. //field.templateOptions.Restangular = Restangular;
  2393. } else if (field.type == "ui-userselect") {
  2394. field.templateOptions.modal = $modal;
  2395. //field.templateOptions.Restangular = Restangular;
  2396. } else if (field.type == "ui-multiuserselect") {
  2397. field.templateOptions.modal = $modal;
  2398. } else if (field.type == "ui-modelselect") {
  2399. field.templateOptions.modal = $modal;
  2400. //field.templateOptions.Restangular = Restangular;
  2401. } else if (field.type == "ui-cmdbuplode") {
  2402. $scope.fileUploader = field.templateOptions.fileUploader =
  2403. new FileUploader({
  2404. url: "/uploader",
  2405. queueLimit: 1, //文件个数
  2406. autoUpload: true,
  2407. });
  2408. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2409. } else if (field.type == "ui-dropfile") {
  2410. field.templateOptions.fileUploader = new FileUploader({
  2411. url: "/uploader",
  2412. });
  2413. field.templateOptions.taskId = $stateParams.taskId;
  2414. field.templateOptions.processInstanceId =
  2415. $stateParams.processInstanceId;
  2416. field.templateOptions.userId = $rootScope.user.id;
  2417. //field.ApiService=api_bpm_domain;
  2418. } else if (field.type == "ui-dropfiletable") {
  2419. if (field.templateOptions.processInstanceId) {
  2420. } else {
  2421. field.templateOptions.processInstanceId =
  2422. $stateParams.processInstanceId;
  2423. }
  2424. } else if (field.type == "ui-repeatSection") {
  2425. var repeatForm = {
  2426. model: {},
  2427. fields: field.templateOptions.fields,
  2428. };
  2429. repeatForm.model[field.key] = [];
  2430. decodeVMTabForm(repeatForm);
  2431. }
  2432. }
  2433. // console.log(field);
  2434. //field
  2435. //result.fields.push(field);
  2436. });
  2437. });
  2438. vm.originalTabs = angular.copy(vm.form);
  2439. }
  2440. //======================处理表单设计数据 结束========================
  2441. $scope.ldloading = {};
  2442. function filter(obj) {
  2443. angular.forEach(obj, function (key, value) {
  2444. if (value === "" || value === null) {
  2445. delete obj[key];
  2446. } else if (
  2447. Object.prototype.toString.call(value) === "[object Object]"
  2448. ) {
  2449. filter(value);
  2450. } else if (angular.isArray(value)) {
  2451. angular.forEach(value, function (item) {
  2452. filter(item);
  2453. });
  2454. }
  2455. });
  2456. }
  2457. function invokeOnAllFormOptions(fn) {
  2458. angular.forEach(vm.tabs, function (tab) {
  2459. if (tab.form.options && tab.form.options[fn]) {
  2460. tab.form.options[fn]();
  2461. }
  2462. });
  2463. }
  2464. function encodeCIData(data, ciId) {
  2465. /*
  2466. create/update state:未审核
  2467. create createtime:系统时间
  2468. create/update lastupdatetime : 系统时间
  2469. label:ci分类
  2470. */
  2471. if (ciId) {
  2472. var baseprop = [
  2473. "uuid",
  2474. "name",
  2475. "type",
  2476. "label",
  2477. "status",
  2478. "createtime",
  2479. "lastupdatetime",
  2480. "props",
  2481. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2482. var extraprop = "props";
  2483. data[extraprop] = {};
  2484. for (var key in data) {
  2485. console.log(data[key]);
  2486. if (_.indexOf(baseprop, key) >= 0) {
  2487. continue;
  2488. } else {
  2489. data[extraprop][key] = data[key];
  2490. delete data[key];
  2491. }
  2492. }
  2493. if ($rootScope.user) {
  2494. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2495. data[extraprop]["configperson"] = $rootScope.user.name;
  2496. var isCMAdminFlag = false;
  2497. angular.forEach($rootScope.user.role, function (roleItem) {
  2498. if (roleItem.rolecode == "cmdb charge") {
  2499. isCMAdminFlag = true;
  2500. }
  2501. });
  2502. if (!isCMAdminFlag) {
  2503. data[extraprop]["state"] = "1";
  2504. }
  2505. }
  2506. if (data.props.id) {
  2507. } else {
  2508. data.label = ciId;
  2509. }
  2510. return data;
  2511. }
  2512. return undefined;
  2513. }
  2514. function decodeCIModel(data) {
  2515. var extraprop = "props";
  2516. if (data[extraprop]) {
  2517. for (var key in data[extraprop]) {
  2518. data[key] = data[extraprop][key];
  2519. }
  2520. delete data[extraprop];
  2521. }
  2522. data["iscmadmin"] = false;
  2523. angular.forEach($rootScope.user.role, function (roleItem) {
  2524. if (roleItem.rolecode == "cmdb charge") {
  2525. data["iscmadmin"] = true;
  2526. }
  2527. });
  2528. return data;
  2529. }
  2530. function formValid() {
  2531. angular.forEach(vm.tabs, function (item) {
  2532. //item.
  2533. });
  2534. }
  2535. $scope.vm = vm;
  2536. $scope.refreshcmdbform = function (item) {
  2537. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2538. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2539. var myData = Restangular.stripRestangular(data);
  2540. $scope.propTypeOptions = myData;
  2541. $scope.templateProps = myData;
  2542. $scope.vm.tabs = myData;
  2543. if ($scope.model.assets) {
  2544. vm.models = JSON.parse($scope.model.assets);
  2545. }
  2546. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2547. if (vm.models.vtvmvtm_kaiji) {
  2548. vm.models.vtvmvtm_kaiji = "是";
  2549. } else {
  2550. vm.models.vtvmvtm_kaiji = "否";
  2551. }
  2552. }
  2553. decodeVMTabForm(vm.models, vm.tabs);
  2554. });
  2555. // }
  2556. };
  2557. var cifilterClassic = {};
  2558. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2559. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2560. $scope.refreshcmdbform(
  2561. $scope.$parent.$parent.$parent.model.cifilterClassic
  2562. );
  2563. // } else {}
  2564. },
  2565. ],
  2566. });
  2567. //固定资产下载
  2568. formlyConfigProvider.setType({
  2569. name: "ui-dropupload",
  2570. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2571. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2572. defaultOptions: function (options) {
  2573. return {
  2574. templateOptions: {
  2575. view: function (APIService, contentId) {
  2576. return APIService.downloadAttachment(contentId);
  2577. },
  2578. },
  2579. };
  2580. },
  2581. controller: [
  2582. "$scope",
  2583. "$rootScope",
  2584. "Restangular",
  2585. function ($scope, $rootScope, Restangular) {
  2586. if (angular.isUndefined($scope.form.dropState)) {
  2587. $scope.form.dropState = false;
  2588. }
  2589. var to = $scope.options.templateOptions;
  2590. var bindId = $scope.model[to.bindType].processInstanceId;
  2591. //获取附件列表
  2592. $scope.listAttachmen = function () {
  2593. to.ApiService.listAttachment(
  2594. to.listAttachmentUrl,
  2595. to.bindType,
  2596. bindId
  2597. ).then(function (result) {
  2598. var myData = Restangular.stripRestangular(result);
  2599. // $scope.listAttachmens = myData;
  2600. $scope.attachments = myData.data;
  2601. });
  2602. };
  2603. $scope.listAttachmen();
  2604. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2605. // $scope.listAttachmen();
  2606. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2607. // $scope.listAttachmen();
  2608. // }
  2609. //附件下载
  2610. $scope.download = function (token, filename) {
  2611. var downUrl = to.ApiService.downloadAttachment(
  2612. to.downUrl,
  2613. token
  2614. ).getRequestedUrl();
  2615. var a = document.createElement("a");
  2616. a.href = downUrl;
  2617. a.target = "_blank";
  2618. a.download = filename;
  2619. document.body.appendChild(a);
  2620. a.click();
  2621. };
  2622. //附件预览
  2623. $scope.view = function (id, previewUrl) {
  2624. if (previewUrl) {
  2625. window.open(previewUrl);
  2626. }
  2627. };
  2628. },
  2629. ],
  2630. });
  2631. formlyConfigProvider.setType({
  2632. name: "ui-form",
  2633. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2634. defaultOptions: function (options) {
  2635. return {
  2636. templateOptions: {
  2637. // link: function() {}
  2638. },
  2639. };
  2640. },
  2641. controller: [
  2642. "$rootScope",
  2643. "$scope",
  2644. "$parse",
  2645. "$injector",
  2646. "$http",
  2647. "$q",
  2648. "$state",
  2649. "$stateParams",
  2650. "$modal",
  2651. "$timeout",
  2652. "$interval",
  2653. "i18nService",
  2654. "SweetAlert",
  2655. "FileUploader",
  2656. "Restangular",
  2657. "UserRestangular",
  2658. "BpmRestangular",
  2659. "api_configure_form",
  2660. "api_configure_data",
  2661. "api_bpm_domain",
  2662. "api_bpm_data",
  2663. "api_user_data",
  2664. "api_cmdb",
  2665. "api_sysinfo",
  2666. function (
  2667. $rootScope,
  2668. $scope,
  2669. $parse,
  2670. $injector,
  2671. $http,
  2672. $q,
  2673. $state,
  2674. $stateParams,
  2675. $modal,
  2676. $timeout,
  2677. $interval,
  2678. i18nService,
  2679. SweetAlert,
  2680. FileUploader,
  2681. Restangular,
  2682. UserRestangular,
  2683. BpmRestangular,
  2684. api_configure_form,
  2685. api_configure_data,
  2686. api_bpm_domain,
  2687. api_bpm_data,
  2688. api_user_data,
  2689. api_cmdb,
  2690. api_sysinfo
  2691. ) {
  2692. $scope.langs = i18nService.getAllLangs();
  2693. $scope.lang = "zh-cn";
  2694. i18nService.setCurrentLang($scope.lang);
  2695. var vm = this;
  2696. vm.options = {};
  2697. vm.exampleTitle = ["expressionProperties", "model property"];
  2698. vm.fields = [];
  2699. vm.models = {};
  2700. // vm.models["loginUser"] = $rootScope.user;
  2701. var that = $injector;
  2702. var parse = $parse;
  2703. var formKey = "";
  2704. var pdKey = "";
  2705. if (
  2706. angular.isDefined($state.current.pdKey) &&
  2707. $state.current.pdKey != ""
  2708. ) {
  2709. pdKey = $state.current.pdKey;
  2710. //console.log("pdKey::"+$state.current.pdKey);
  2711. }
  2712. if (
  2713. angular.isDefined($stateParams.formKey) &&
  2714. $stateParams.formKey != ""
  2715. ) {
  2716. formKey = $stateParams.formKey;
  2717. //console.log("formKey::"+$stateParams.formKey);
  2718. }
  2719. //用户测试数据,后续从header的auth中获取
  2720. var userId = 2;
  2721. userId = $rootScope.user.id;
  2722. //==============处理表单设计数据 开始====================
  2723. //处理组件加载后台数据选项的方法
  2724. function refreshSelectOptions(searchVal, field) {
  2725. if (field.templateOptions.optionsUrl) {
  2726. var process = BpmRestangular.all("");
  2727. if (field.templateOptions.ApiService) {
  2728. process = UserRestangular.all("");
  2729. }
  2730. process
  2731. .customPOST(
  2732. {
  2733. idx: 0,
  2734. sum: 1000,
  2735. },
  2736. field.templateOptions.optionsUrl
  2737. )
  2738. .then(function (result) {
  2739. if (!field.templateOptions.options) {
  2740. field.templateOptions.options = [];
  2741. }
  2742. if (field.templateOptions.optionsDataKey) {
  2743. field.templateOptions.options =
  2744. result[field.templateOptions.optionsDataKey];
  2745. } else {
  2746. field.templateOptions.options = result;
  2747. }
  2748. });
  2749. }
  2750. }
  2751. function decodeVMTabForm(model, tabs) {
  2752. var result = {
  2753. model: {},
  2754. tabs: [],
  2755. };
  2756. var mdata = angular.fromJson(model);
  2757. angular.extend(result.model, mdata);
  2758. angular.forEach(tabs, function (tab) {
  2759. tab.form.model = vm.models;
  2760. angular.forEach(tab.form.fields, function (field) {
  2761. if (field.key == "") {
  2762. delete field.key;
  2763. }
  2764. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2765. var extObj = angular.fromJson(field.extjson);
  2766. angular.extend(field.templateOptions, extObj.templateOptions);
  2767. delete extObj.templateOptions;
  2768. for (var prop in extObj) {
  2769. if (new RegExp("Expression").test(prop)) {
  2770. //var obj = $scope.$eval(extObj[prop]);
  2771. //extObj[prop] = $scope.$eval(extObj[prop]);
  2772. if (extObj[prop] != null) {
  2773. if (new RegExp("function").test(extObj[prop])) {
  2774. var propValue = eval(extObj[prop]);
  2775. extObj[prop] = propValue;
  2776. } else {
  2777. //console.log(extObj[prop]);
  2778. var obj = $scope.$eval(extObj[prop]);
  2779. extObj[prop] = obj;
  2780. //console.log(obj);
  2781. }
  2782. }
  2783. } else if (new RegExp("expressionProperties").test(prop)) {
  2784. for (var p in extObj[prop]) {
  2785. if (new RegExp("function").test(extObj[prop][p])) {
  2786. var propValue = eval(extObj[prop][p]);
  2787. extObj[prop][p] = propValue;
  2788. } else {
  2789. //if(p.indexOf("'")>=0){
  2790. // var obj = $scope.$eval(extObj[prop][p]);
  2791. // extObj[prop][$scope.$eval(p)]=obj;
  2792. //}
  2793. }
  2794. }
  2795. } else if ("watcher" == prop) {
  2796. if (angular.isArray(extObj[prop])) {
  2797. angular.forEach(extObj[prop], function (item, index) {
  2798. for (var p in item) {
  2799. if (new RegExp("function").test(item[p])) {
  2800. var propValue = eval(item[p]);
  2801. extObj[prop][index][p] = propValue;
  2802. }
  2803. }
  2804. });
  2805. } else if (angular.isObject(extObj[prop])) {
  2806. for (var p in extObj[prop]) {
  2807. if (new RegExp("function").test(extObj[prop][p])) {
  2808. var propValue = eval(extObj[prop][p]);
  2809. extObj[prop][p] = propValue;
  2810. }
  2811. }
  2812. }
  2813. }
  2814. }
  2815. angular.extend(field, extObj);
  2816. delete field.extjson;
  2817. }
  2818. if (field.extjson == "") {
  2819. delete field.extjson;
  2820. }
  2821. if (angular.isDefined(field.templateOptions)) {
  2822. var templateOs = field.templateOptions;
  2823. for (var property in templateOs) {
  2824. //console.log(property);
  2825. if (
  2826. angular.isString(templateOs[property]) &&
  2827. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2828. ) {
  2829. if (new RegExp("function").test(templateOs[property])) {
  2830. var propValue = eval(templateOs[property]);
  2831. field.templateOptions[property] = propValue;
  2832. } else {
  2833. if (that.has(templateOs[property])) {
  2834. field.templateOptions[property] = that.get(
  2835. templateOs[property]
  2836. );
  2837. } else {
  2838. field.templateOptions[property] = templateOs[property];
  2839. }
  2840. }
  2841. } else if (templateOs[property] == null) {
  2842. //delete field.templateOptions[property];
  2843. } else {
  2844. }
  2845. }
  2846. }
  2847. if (
  2848. angular.isDefined(field.templateOptions) &&
  2849. angular.isDefined(field.templateOptions.extjson)
  2850. ) {
  2851. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2852. angular.extend(field.templateOptions, extObj);
  2853. delete field.templateOptions.extjson;
  2854. }
  2855. //...
  2856. if (field.templateOptions) {
  2857. //处理远程获取数据控件方法调用
  2858. if (field.templateOptions.optionsUrl) {
  2859. field.templateOptions.refresh = refreshSelectOptions;
  2860. }
  2861. //处理嵌套属性数据绑定/
  2862. if (field.templateOptions.pkey) {
  2863. var pmodel,
  2864. i = 0;
  2865. angular.forEach(
  2866. field.templateOptions.pkey.split("."),
  2867. function (p) {
  2868. if (i == 0) {
  2869. if (result.model[p] == null) {
  2870. result.model[p] = {};
  2871. }
  2872. pmodel = result.model[p];
  2873. i++;
  2874. } else {
  2875. if (pmodel[p] == null) {
  2876. pmodel[p] = {};
  2877. }
  2878. pmodel = pmodel[p];
  2879. }
  2880. }
  2881. );
  2882. if (pmodel != null) {
  2883. field.model = pmodel;
  2884. if (pmodel[field.key] == null) {
  2885. pmodel[field.key] = null;
  2886. }
  2887. }
  2888. } else {
  2889. if (result.model[field.key] == null) {
  2890. result.model[field.key] = null;
  2891. }
  2892. }
  2893. //处理弹出框组件初始化
  2894. if (field.type == "ui-input-selectmodal") {
  2895. field.templateOptions.modal = $modal;
  2896. //field.templateOptions.Restangular = Restangular;
  2897. } else if (field.type == "ui-userselect") {
  2898. field.templateOptions.modal = $modal;
  2899. //field.templateOptions.Restangular = Restangular;
  2900. } else if (field.type == "ui-multiuserselect") {
  2901. field.templateOptions.modal = $modal;
  2902. } else if (field.type == "ui-modelselect") {
  2903. field.templateOptions.modal = $modal;
  2904. //field.templateOptions.Restangular = Restangular;
  2905. } else if (field.type == "ui-dropfile") {
  2906. field.templateOptions.fileUploader = new FileUploader({
  2907. url: "/uploader",
  2908. });
  2909. field.templateOptions.taskId = $stateParams.taskId;
  2910. field.templateOptions.processInstanceId =
  2911. $stateParams.processInstanceId;
  2912. field.templateOptions.userId = $rootScope.user.id;
  2913. //field.ApiService=api_bpm_domain;
  2914. // }else if (field.type == "ui-uploadFile") {
  2915. // field.templateOptions.fileUploader = new FileUploader({
  2916. // url: '/uploader'
  2917. // });
  2918. // field.templateOptions.taskId = $stateParams.taskId;
  2919. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2920. // field.templateOptions.userId = $rootScope.user.id;
  2921. //field.ApiService=api_bpm_domain;
  2922. } else if (field.type == "ui-dropfiletable") {
  2923. if (field.templateOptions.processInstanceId) {
  2924. } else {
  2925. field.templateOptions.processInstanceId =
  2926. $stateParams.processInstanceId;
  2927. }
  2928. } else if (field.type == "ui-dropFiles") {
  2929. if (field.templateOptions.processInstanceId) {
  2930. } else {
  2931. field.templateOptions.processInstanceId =
  2932. $stateParams.processInstanceId;
  2933. }
  2934. } else if (field.type == "ui-showImgs") {
  2935. if (field.templateOptions.processInstanceId) {
  2936. } else {
  2937. field.templateOptions.processInstanceId =
  2938. $stateParams.processInstanceId;
  2939. }
  2940. } else if (field.type == "ui-repeatSection") {
  2941. var repeatForm = {
  2942. model: {},
  2943. fields: field.templateOptions.fields,
  2944. };
  2945. repeatForm.model[field.key] = [];
  2946. decodeVMTabForm(repeatForm);
  2947. }
  2948. }
  2949. // console.log(field);
  2950. //field
  2951. //result.fields.push(field);
  2952. });
  2953. });
  2954. vm.originalTabs = angular.copy(vm.form);
  2955. }
  2956. //解析自定义表单设计数据
  2957. function decodeVMForm(vmForm) {
  2958. var result = {
  2959. model: {},
  2960. tabs: [],
  2961. };
  2962. //设置模型实体数据 begin
  2963. // var mdata = vmForm.model;
  2964. //解析数据实体
  2965. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2966. angular.extend(result.model, mdata);
  2967. //设置模型实体数据 end
  2968. //解析设计数据生成表单项 begin
  2969. var fields = [];
  2970. //处理修改设计数据中展示设置
  2971. angular.forEach(vmForm.tabs, function (field) {
  2972. if (field.key == "") {
  2973. delete field.key;
  2974. }
  2975. if (angular.isDefined(field.extjson)) {
  2976. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2977. angular.extend(field.templateOptions, extObj.templateOptions);
  2978. delete extObj.templateOptions;
  2979. for (var prop in extObj) {
  2980. if (new RegExp("Expression").test(prop)) {
  2981. //var obj = $scope.$eval(extObj[prop]);
  2982. //extObj[prop] = $scope.$eval(extObj[prop]);
  2983. if (extObj[prop] != null) {
  2984. if (new RegExp("function").test(extObj[prop])) {
  2985. var propValue = eval(extObj[prop]);
  2986. extObj[prop] = propValue;
  2987. } else {
  2988. //console.log(extObj[prop]);
  2989. var obj = $scope.$eval(extObj[prop]);
  2990. extObj[prop] = obj;
  2991. //console.log(obj);
  2992. }
  2993. }
  2994. } else if (new RegExp("expressionProperties").test(prop)) {
  2995. for (var p in extObj[prop]) {
  2996. if (new RegExp("function").test(extObj[prop][p])) {
  2997. var propValue = eval(extObj[prop][p]);
  2998. extObj[prop][p] = propValue;
  2999. } else {
  3000. //if(p.indexOf("'")>=0){
  3001. // var obj = $scope.$eval(extObj[prop][p]);
  3002. // extObj[prop][$scope.$eval(p)]=obj;
  3003. //}
  3004. }
  3005. }
  3006. } else if ("watcher" == prop) {
  3007. if (angular.isArray(extObj[prop])) {
  3008. angular.forEach(extObj[prop], function (item, index) {
  3009. for (var p in item) {
  3010. if (new RegExp("function").test(item[p])) {
  3011. var propValue = eval(item[p]);
  3012. extObj[prop][index][p] = propValue;
  3013. }
  3014. }
  3015. });
  3016. } else if (angular.isObject(extObj[prop])) {
  3017. for (var p in extObj[prop]) {
  3018. if (new RegExp("function").test(extObj[prop][p])) {
  3019. var propValue = eval(extObj[prop][p]);
  3020. extObj[prop][p] = propValue;
  3021. }
  3022. }
  3023. }
  3024. }
  3025. }
  3026. angular.extend(field, extObj);
  3027. delete field.extjson;
  3028. }
  3029. if (angular.isDefined(field.templateOptions)) {
  3030. var templateOs = field.templateOptions;
  3031. for (var property in templateOs) {
  3032. //console.log(property);
  3033. if (
  3034. angular.isString(templateOs[property]) &&
  3035. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3036. ) {
  3037. if (new RegExp("function").test(templateOs[property])) {
  3038. var propValue = eval(templateOs[property]);
  3039. field.templateOptions[property] = propValue;
  3040. } else {
  3041. if (that.has(templateOs[property])) {
  3042. field.templateOptions[property] = that.get(
  3043. templateOs[property]
  3044. );
  3045. } else {
  3046. field.templateOptions[property] = templateOs[property];
  3047. }
  3048. }
  3049. } else if (templateOs[property] == null) {
  3050. //delete field.templateOptions[property];
  3051. } else {
  3052. }
  3053. }
  3054. }
  3055. if (
  3056. angular.isDefined(field.templateOptions) &&
  3057. angular.isDefined(field.templateOptions.extjson)
  3058. ) {
  3059. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3060. angular.extend(field.templateOptions, extObj);
  3061. delete field.templateOptions.extjson;
  3062. }
  3063. //...
  3064. if (field.templateOptions) {
  3065. //处理远程获取数据控件方法调用
  3066. if (field.templateOptions.optionsUrl) {
  3067. field.templateOptions.refresh = refreshSelectOptions;
  3068. }
  3069. //处理嵌套属性数据绑定/
  3070. if (field.templateOptions.pkey) {
  3071. var pmodel,
  3072. i = 0;
  3073. angular.forEach(
  3074. field.templateOptions.pkey.split("."),
  3075. function (p) {
  3076. if (i == 0) {
  3077. if (result.model[p] == null) {
  3078. result.model[p] = {};
  3079. }
  3080. pmodel = result.model[p];
  3081. i++;
  3082. } else {
  3083. if (pmodel[p] == null) {
  3084. pmodel[p] = {};
  3085. }
  3086. pmodel = pmodel[p];
  3087. }
  3088. }
  3089. );
  3090. if (pmodel != null) {
  3091. field.model = pmodel;
  3092. if (pmodel[field.key] == null) {
  3093. pmodel[field.key] = null;
  3094. }
  3095. }
  3096. } else {
  3097. if (result.model[field.key] == null) {
  3098. result.model[field.key] = null;
  3099. }
  3100. }
  3101. //处理弹出框组件初始化
  3102. if (field.type == "ui-input-selectmodal") {
  3103. field.templateOptions.modal = $modal;
  3104. //field.templateOptions.Restangular = Restangular;
  3105. } else if (field.type == "ui-userselect") {
  3106. field.templateOptions.modal = $modal;
  3107. //field.templateOptions.Restangular = Restangular;
  3108. } else if (field.type == "ui-multiuserselect") {
  3109. field.templateOptions.modal = $modal;
  3110. } else if (field.type == "ui-modelselect") {
  3111. field.templateOptions.modal = $modal;
  3112. //field.templateOptions.Restangular = Restangular;
  3113. } else if (field.type == "ui-dropfile") {
  3114. field.templateOptions.fileUploader = new FileUploader({
  3115. url: "/uploader",
  3116. });
  3117. field.templateOptions.taskId = $stateParams.taskId;
  3118. field.templateOptions.processInstanceId =
  3119. $stateParams.processInstanceId;
  3120. field.templateOptions.userId = $rootScope.user.id;
  3121. //field.ApiService=api_bpm_domain;
  3122. } else if (field.type == "ui-dropfiletable") {
  3123. if (field.templateOptions.processInstanceId) {
  3124. } else {
  3125. field.templateOptions.processInstanceId =
  3126. $stateParams.processInstanceId;
  3127. }
  3128. } else if (field.type == "ui-dropFiles") {
  3129. if (field.templateOptions.processInstanceId) {
  3130. } else {
  3131. field.templateOptions.processInstanceId =
  3132. $stateParams.processInstanceId;
  3133. }
  3134. } else if (field.type == "ui-showImgs") {
  3135. if (field.templateOptions.processInstanceId) {
  3136. } else {
  3137. field.templateOptions.processInstanceId =
  3138. $stateParams.processInstanceId;
  3139. }
  3140. } else if (field.type == "ui-repeatSection") {
  3141. var repeatForm = {
  3142. model: {},
  3143. fields: field.templateOptions.fields,
  3144. };
  3145. repeatForm.model[field.key] = [];
  3146. decodeVMForm(repeatForm);
  3147. }
  3148. }
  3149. // console.log(field);
  3150. result.fields.push(field);
  3151. });
  3152. angular.extend($scope.vm.fields, result.fields);
  3153. angular.extend($scope.vm.models, result.model);
  3154. $scope.formData = vmForm;
  3155. //console.log($scope.vm);
  3156. //解析设计数据生成表单项 end
  3157. return result;
  3158. }
  3159. //======================处理表单设计数据 结束========================
  3160. $scope.ldloading = {};
  3161. function filter(obj) {
  3162. angular.forEach(obj, function (key, value) {
  3163. if (value === "" || value === null) {
  3164. delete obj[key];
  3165. } else if (
  3166. Object.prototype.toString.call(value) === "[object Object]"
  3167. ) {
  3168. filter(value);
  3169. } else if (angular.isArray(value)) {
  3170. angular.forEach(value, function (item) {
  3171. filter(item);
  3172. });
  3173. }
  3174. });
  3175. }
  3176. function invokeOnAllFormOptions(fn) {
  3177. angular.forEach(vm.tabs, function (tab) {
  3178. if (tab.form.options && tab.form.options[fn]) {
  3179. tab.form.options[fn]();
  3180. }
  3181. });
  3182. }
  3183. function encodeCIData(data, ciId) {
  3184. /*
  3185. create/update state:未审核
  3186. create createtime:系统时间
  3187. create/update lastupdatetime : 系统时间
  3188. label:ci分类
  3189. */
  3190. if (ciId) {
  3191. var baseprop = [
  3192. "uuid",
  3193. "name",
  3194. "type",
  3195. "label",
  3196. "status",
  3197. "createtime",
  3198. "lastupdatetime",
  3199. "props",
  3200. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3201. var extraprop = "props";
  3202. data[extraprop] = {};
  3203. for (var key in data) {
  3204. console.log(data[key]);
  3205. if (_.indexOf(baseprop, key) >= 0) {
  3206. continue;
  3207. } else {
  3208. data[extraprop][key] = data[key];
  3209. delete data[key];
  3210. }
  3211. }
  3212. if ($rootScope.user) {
  3213. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3214. data[extraprop]["configperson"] = $rootScope.user.name;
  3215. var isCMAdminFlag = false;
  3216. angular.forEach($rootScope.user.role, function (roleItem) {
  3217. if (roleItem.rolecode == "cmdb charge") {
  3218. isCMAdminFlag = true;
  3219. }
  3220. });
  3221. if (!isCMAdminFlag) {
  3222. data[extraprop]["state"] = "1";
  3223. }
  3224. }
  3225. if (data.props.id) {
  3226. } else {
  3227. data.label = ciId;
  3228. }
  3229. return data;
  3230. }
  3231. return undefined;
  3232. }
  3233. function decodeCIModel(data) {
  3234. var extraprop = "props";
  3235. if (data[extraprop]) {
  3236. for (var key in data[extraprop]) {
  3237. data[key] = data[extraprop][key];
  3238. }
  3239. delete data[extraprop];
  3240. }
  3241. data["iscmadmin"] = false;
  3242. angular.forEach($rootScope.user.role, function (roleItem) {
  3243. if (roleItem.rolecode == "cmdb charge") {
  3244. data["iscmadmin"] = true;
  3245. }
  3246. });
  3247. return data;
  3248. }
  3249. vm.remove = function (data, style) {
  3250. $scope.ldloading[style.replace("-", "_")] = true;
  3251. var modalInstance = $modal.open({
  3252. templateUrl: "assets/views/delete.html",
  3253. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3254. var cidata = {
  3255. label: data.label,
  3256. id: data.id,
  3257. uuid: data.uuid,
  3258. name: data.name,
  3259. props: {},
  3260. };
  3261. if (cidata.id) {
  3262. cidata.props["removeflag"] = true;
  3263. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3264. $scope.ok = function () {
  3265. $modalInstance.close(cidata);
  3266. };
  3267. $scope.cancel = function () {
  3268. $modalInstance.dismiss("cancel");
  3269. };
  3270. }
  3271. },
  3272. size: "sm",
  3273. resolve: {
  3274. scope: function () {
  3275. return $scope;
  3276. },
  3277. },
  3278. });
  3279. modalInstance.result.then(function (selectedItem) {
  3280. if (selectedItem) {
  3281. // if (selectedItem.length > 0) {
  3282. api_cmdb
  3283. .put(selectedItem, selectedItem.id)
  3284. .then(function (response) {
  3285. if (response) {
  3286. var resData = Restangular.stripRestangular(response);
  3287. SweetAlert.swal(
  3288. {
  3289. title: "删除成功!",
  3290. confirmButtonColor: "#007AFF",
  3291. },
  3292. function () {
  3293. $state.go("app.means.list");
  3294. // $scope.refreshform();
  3295. // reinitTabForm($scope.classify);
  3296. }
  3297. );
  3298. } else {
  3299. SweetAlert.swal({
  3300. title: "系统错误",
  3301. text: "系统错误,请稍后重试!",
  3302. type: "error",
  3303. confirmButtonColor: "#DD6B55",
  3304. });
  3305. }
  3306. $scope.ldloading[style.replace("-", "_")] = false;
  3307. });
  3308. }
  3309. });
  3310. };
  3311. function formValid() {
  3312. angular.forEach(vm.tabs, function (item) {
  3313. //item.
  3314. });
  3315. }
  3316. $scope.closeModel = function () {
  3317. console.log($stateParams);
  3318. if (
  3319. angular.isDefined($stateParams.formKey) &&
  3320. $stateParams.formKey != ""
  3321. ) {
  3322. if (
  3323. $stateParams.formKey == "means_editor" ||
  3324. $stateParams.formKey == "means_edit"
  3325. ) {
  3326. $state.go("app.means.list", {});
  3327. }
  3328. event.preventDefault();
  3329. }
  3330. };
  3331. // setInterval(function() {
  3332. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3333. // cifilter_classic = $scope.model.cifilter_classic;
  3334. // $scope.refreshcmdbform(cifilter_classic);
  3335. // } else {}
  3336. // }, 100);
  3337. vm.models = (function filter(obj) {
  3338. var filtered = _.pick(obj, function (v) {
  3339. return (
  3340. angular.isDefined(v) &&
  3341. v !== null &&
  3342. (angular.isArray(v) ? v.length > 0 : true) &&
  3343. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3344. );
  3345. });
  3346. return _.cloneDeep(filtered, function (v) {
  3347. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3348. });
  3349. })(vm.models);
  3350. // setInterval(function() {
  3351. // if ($scope.model.type == 0) {
  3352. // $scope.model[$scope.options.key] = vm.models;
  3353. // }
  3354. // }, 100);
  3355. setInterval(function () {
  3356. if (vm.form && vm.form.$$parentForm.$valid) {
  3357. if (
  3358. $scope.$parent &&
  3359. $scope.$parent.$parent &&
  3360. $scope.$parent.$parent.$parent &&
  3361. $scope.$parent.$parent.$parent.model
  3362. ) {
  3363. vm.models.hw_cifilterClassic =
  3364. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3365. $scope.model[$scope.options.key] = vm.models;
  3366. }
  3367. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3368. // $scope.model[$scope.options.key] = vm.models;
  3369. }
  3370. }, 100);
  3371. vm.submit = function (data, ciId, templateitem, style) {
  3372. // $scope.ldloading[style.replace('-', '_')] = true;
  3373. console.log(vm.form.$$parentForm.$valid);
  3374. if (vm.form.$$parentForm.$valid) {
  3375. invokeOnAllFormOptions("updateInitialValue");
  3376. //alert(JSON.stringify(vm.model), null, 2);
  3377. //vm.options.updateInitialValue();
  3378. //console.log(vm.model);
  3379. var cidata = encodeCIData(vm.models, ciId);
  3380. if (cidata) {
  3381. //var cidata = ;
  3382. if (cidata.props.id) {
  3383. //修改
  3384. api_cmdb.put(cidata, ciId).then(function (response) {
  3385. if (response) {
  3386. var resData = Restangular.stripRestangular(response);
  3387. SweetAlert.swal(
  3388. {
  3389. title: "保存成功!",
  3390. confirmButtonColor: "#007AFF",
  3391. },
  3392. function () {
  3393. $scope.ldloading[style.replace("-", "_")] = false;
  3394. // $scope.refreshform();
  3395. $state.go("app.means.list");
  3396. }
  3397. );
  3398. } else {
  3399. SweetAlert.swal({
  3400. title: "系统错误",
  3401. text: "系统错误,请稍后重试!",
  3402. type: "error",
  3403. confirmButtonColor: "#DD6B55",
  3404. });
  3405. }
  3406. $scope.ldloading[style.replace("-", "_")] = false;
  3407. });
  3408. } else {
  3409. //新建
  3410. var type = 2;
  3411. api_sysinfo
  3412. .getSerialnumber(type, templateitem.id)
  3413. .then(function (data) {
  3414. if (data && data.status == 200) {
  3415. cidata.uuid = data.uuid;
  3416. api_cmdb.create(cidata).then(function (response) {
  3417. if (response) {
  3418. var resData = Restangular.stripRestangular(response);
  3419. SweetAlert.swal(
  3420. {
  3421. title: "保存成功!",
  3422. text: "内部编号:" + cidata.uuid,
  3423. confirmButtonColor: "#007AFF",
  3424. },
  3425. function () {
  3426. $state.go("app.means.list");
  3427. }
  3428. );
  3429. // if(resData.status){
  3430. // resData
  3431. // }
  3432. } else {
  3433. SweetAlert.swal({
  3434. title: "系统错误",
  3435. text: "系统错误,请稍后重试!",
  3436. type: "error",
  3437. confirmButtonColor: "#DD6B55",
  3438. });
  3439. }
  3440. $scope.ldloading[style.replace("-", "_")] = false;
  3441. });
  3442. } else {
  3443. SweetAlert.swal({
  3444. title: "系统错误",
  3445. text: "内部编号生成出错!",
  3446. type: "error",
  3447. confirmButtonColor: "#DD6B55",
  3448. });
  3449. }
  3450. });
  3451. }
  3452. } else {
  3453. SweetAlert.swal({
  3454. title: "错误",
  3455. text: "错误,请选择资产分类!",
  3456. type: "error",
  3457. confirmButtonColor: "#DD6B55",
  3458. });
  3459. }
  3460. //alert(JSON.stringify(cidata), null, 2);
  3461. $scope.ldloading[style.replace("-", "_")] = true;
  3462. return;
  3463. var _ = window._;
  3464. vm.models = (function filter(obj) {
  3465. var filtered = _.pick(obj, function (v) {
  3466. return (
  3467. angular.isDefined(v) &&
  3468. v !== null &&
  3469. (angular.isArray(v) ? v.length > 0 : true) &&
  3470. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3471. );
  3472. });
  3473. return _.cloneDeep(filtered, function (v) {
  3474. return v !== filtered && _.isPlainObject(v)
  3475. ? filter(v)
  3476. : undefined;
  3477. });
  3478. })(vm.models);
  3479. } else {
  3480. if (vm.form.$$parentForm.$error) {
  3481. SweetAlert.swal({
  3482. title: "校验错误",
  3483. text: "请填写必填项!",
  3484. type: "error",
  3485. confirmButtonColor: "#DD6B55",
  3486. });
  3487. angular.forEach(
  3488. vm.form.$$parentForm.$error.required,
  3489. function (item) {
  3490. angular.forEach(vm.tabs, function (tab) {
  3491. angular.forEach(tab.form.fields, function (f) {
  3492. if (f.name == item.$name) {
  3493. f.validation.show = true;
  3494. tab.active = true;
  3495. }
  3496. });
  3497. });
  3498. }
  3499. );
  3500. $scope.ldloading[style.replace("-", "_")] = false;
  3501. }
  3502. }
  3503. };
  3504. $scope.vm = vm;
  3505. $scope.refreshcmdbform = function (item) {
  3506. // if ($stateParams.model) {
  3507. // var modeldata = JSON.parse($stateParams.model)
  3508. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3509. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3510. var myData = Restangular.stripRestangular(data);
  3511. $scope.propTypeOptions = myData;
  3512. $scope.templateProps = myData;
  3513. $scope.vm.tabs = myData;
  3514. if ($scope.model.asset && $scope.model.asset.length != "") {
  3515. vm.models = JSON.parse($scope.model.asset);
  3516. }
  3517. decodeVMTabForm(vm.models, vm.tabs);
  3518. });
  3519. // }
  3520. };
  3521. var cifilterClassic = {};
  3522. setInterval(function () {
  3523. if (
  3524. $scope.$parent.$parent &&
  3525. $scope.$parent.$parent.$parent &&
  3526. $scope.$parent.$parent.$parent.model &&
  3527. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3528. cifilterClassic.id !=
  3529. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3530. ) {
  3531. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3532. cifilterClassic =
  3533. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3534. $scope.refreshcmdbform(cifilterClassic);
  3535. } else {
  3536. }
  3537. }, 100);
  3538. },
  3539. ],
  3540. });
  3541. //请求人信息
  3542. formlyConfigProvider.setType({
  3543. name: "ui-cmdbinformation",
  3544. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3545. wrapper: ["bootstrapHasError"],
  3546. defaultOptions: function (options, $scope) {
  3547. return {
  3548. templateOptions: {
  3549. // checkform: function(options) {
  3550. // if (options.model.requester) {
  3551. // options.value(options.model.requester);
  3552. // }
  3553. // },
  3554. },
  3555. };
  3556. },
  3557. controller: [
  3558. "$scope",
  3559. "api_user_data",
  3560. function ($scope, api_user_data) {
  3561. if ($scope.options.templateOptions.loginUser) {
  3562. if (
  3563. $scope.model[$scope.options.key] &&
  3564. $scope.model[$scope.options.key].id
  3565. ) {
  3566. } else {
  3567. $scope.model[$scope.options.key] =
  3568. $scope.options.templateOptions.loginUser;
  3569. }
  3570. $scope.options.initialValue = $scope.model[$scope.options.key];
  3571. }
  3572. },
  3573. ],
  3574. });
  3575. //资产属性
  3576. formlyConfigProvider.setType({
  3577. name: "ui-cmdbtype",
  3578. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3579. wrapper: ["bootstrapHasError"],
  3580. defaultOptions: function (options, $scope) {
  3581. return {
  3582. templateOptions: {
  3583. // checkform: function(options) {
  3584. // if (options.model.requester) {
  3585. // options.value(options.model.requester);
  3586. // }
  3587. // },
  3588. },
  3589. };
  3590. },
  3591. controller: [
  3592. "$scope",
  3593. "api_user_data",
  3594. function ($scope, api_user_data) {
  3595. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3596. $scope.property = {
  3597. hw_change: $scope.to.loginUser,
  3598. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3599. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3600. };
  3601. if ($scope.$parent.$parent.$parent.model.assets) {
  3602. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3603. }
  3604. },
  3605. ],
  3606. });
  3607. //申请单信息
  3608. formlyConfigProvider.setType({
  3609. name: "ui-cmdbformimform",
  3610. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3611. wrapper: ["bootstrapHasError"],
  3612. defaultOptions: function (options, $scope) {
  3613. return {
  3614. templateOptions: {
  3615. // checkform: function(options) {
  3616. // if (options.model.requester) {
  3617. // options.value(options.model.requester);
  3618. // }
  3619. // },
  3620. },
  3621. };
  3622. },
  3623. controller: [
  3624. "$scope",
  3625. "api_user_data",
  3626. function ($scope, api_user_data) {
  3627. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3628. $scope.getininform = {
  3629. serialNumbe:
  3630. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3631. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3632. };
  3633. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3634. $scope.getininform.types = "新资产入库";
  3635. } else if (
  3636. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3637. ) {
  3638. $scope.getininform.types = "资产归还";
  3639. }
  3640. },
  3641. ],
  3642. });
  3643. //出库单信息
  3644. formlyConfigProvider.setType({
  3645. name: "ui-outinformation",
  3646. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3647. wrapper: ["bootstrapHasError"],
  3648. defaultOptions: function (options, $scope) {
  3649. return {
  3650. templateOptions: {
  3651. // checkform: function(options) {
  3652. // if (options.model.requester) {
  3653. // options.value(options.model.requester);
  3654. // }
  3655. // },
  3656. },
  3657. };
  3658. },
  3659. controller: [
  3660. "$scope",
  3661. "api_user_data",
  3662. function ($scope, api_user_data) {
  3663. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3664. $scope.getininform = {
  3665. serialNumbe:
  3666. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3667. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3668. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3669. sourceId:
  3670. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3671. describe:
  3672. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3673. };
  3674. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3675. $scope.getininform.types = "新设备领用出库";
  3676. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3677. $scope.getininform.types = "设备更换";
  3678. }
  3679. $scope.getininform.source_id =
  3680. $scope.$parent.$parent.$parent.model.source.value;
  3681. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3682. $scope.getininform.source = "事件";
  3683. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3684. $scope.getininform.source = "变更";
  3685. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3686. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3687. $scope.getininform.source = "其它";
  3688. }
  3689. },
  3690. ],
  3691. });
  3692. //资产附件上传
  3693. formlyConfigProvider.setType({
  3694. name: "ui-cmdbuplode",
  3695. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3696. wrapper: ["bootstrapHasError"],
  3697. defaultOptions: function (options, $scope) {
  3698. return {
  3699. templateOptions: {
  3700. // checkform: function(options) {
  3701. // if (options.model.requester) {
  3702. // options.value(options.model.requester);
  3703. // }
  3704. // },
  3705. },
  3706. };
  3707. },
  3708. controller: [
  3709. "$scope",
  3710. "$rootScope",
  3711. "$http",
  3712. "SweetAlert",
  3713. "FileUploader",
  3714. "api_user_data",
  3715. "i18nService",
  3716. "$modal",
  3717. "Restangular",
  3718. "api_configure_data",
  3719. "api_cmdb",
  3720. "api_cmdb_new",
  3721. "api_wechatfile",
  3722. "api_sysinfo",
  3723. function (
  3724. $scope,
  3725. $rootScope,
  3726. $http,
  3727. SweetAlert,
  3728. FileUploader,
  3729. api_user_data,
  3730. i18nService,
  3731. $modal,
  3732. Restangular,
  3733. api_configure_data,
  3734. api_cmdb,
  3735. api_cmdb_new,
  3736. api_wechatfile,
  3737. api_sysinfo
  3738. ) {
  3739. $scope.state = 1;
  3740. $scope.myData3all = [];
  3741. $scope.myData3 = [];
  3742. $scope.memoryfilterDatahao = {
  3743. idx: 0,
  3744. sum: 10,
  3745. };
  3746. $scope.selected = {
  3747. items: [],
  3748. };
  3749. $scope.interceptMydata = function (mydate, idx, sum) {
  3750. return mydate.slice(idx * sum, (idx + 1) * sum);
  3751. };
  3752. // $scope.importnext = function() {
  3753. // $scope.state = 2;
  3754. // event.preventDefault();
  3755. // }
  3756. $scope.workspaces = [];
  3757. $scope.options.templateOptions.getpush = function (item) {
  3758. $scope.workspaces = [];
  3759. if (item.gu) {
  3760. $scope.workspaces.push({
  3761. id: 1,
  3762. name: "固定资产",
  3763. active: true,
  3764. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3765. });
  3766. }
  3767. if (item.hao) {
  3768. $scope.workspaces.push({
  3769. id: 2,
  3770. name: "耗材资产",
  3771. active: true,
  3772. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3773. });
  3774. }
  3775. };
  3776. //获取附件列表
  3777. $scope.listAttachmen = function () {
  3778. to.ApiService.listAttachment(
  3779. to.listAttachmentUrl,
  3780. to.bindType,
  3781. bindId
  3782. ).then(function (result) {
  3783. var myData = Restangular.stripRestangular(result);
  3784. // $scope.listAttachmens = myData;
  3785. $scope.attachments = myData.data;
  3786. });
  3787. };
  3788. //附件列表
  3789. if ($scope.options.templateOptions.bindType) {
  3790. if (angular.isUndefined($scope.form.dropState)) {
  3791. $scope.form.dropState = false;
  3792. }
  3793. var to = $scope.options.templateOptions;
  3794. var bindId = $scope.model[to.bindType].processInstanceId;
  3795. $scope.listAttachmen();
  3796. }
  3797. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3798. // $scope.listAttachmen();
  3799. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3800. // $scope.listAttachmen();
  3801. // }
  3802. //附件下载
  3803. $scope.download = function (token, filename) {
  3804. var downUrl = to.ApiService.downloadAttachment(
  3805. to.downUrl,
  3806. token
  3807. ).getRequestedUrl();
  3808. // window.open(downUrl);
  3809. var a = document.createElement("a");
  3810. a.href = downUrl;
  3811. a.target = "_blank";
  3812. a.download = filename;
  3813. document.body.appendChild(a);
  3814. a.click();
  3815. };
  3816. //附件预览
  3817. $scope.view = function (id, previewUrl) {
  3818. if (previewUrl) {
  3819. window.open(previewUrl);
  3820. }
  3821. };
  3822. //下载资产模版
  3823. $scope.filenum = 0;
  3824. $scope.openmeans = function () {
  3825. var modalInstance = $modal.open({
  3826. templateUrl: "assets/views/means/tpl/meansdown.html",
  3827. controller: function ($scope, scope, $modalInstance) {
  3828. $scope.item = {};
  3829. $scope.title = "选择下载模版";
  3830. $scope.lable = "资产模版下载";
  3831. function foreachdata(my_datas) {
  3832. // angular.forEach(my_datas, function(item, index) {
  3833. // if (item.children && item.children.length > 0) {
  3834. // foreachdata(item.children);
  3835. // } else {
  3836. // my_datas[index].checks = true;
  3837. // }
  3838. // })
  3839. for (var i = 0; i < my_datas.length; i++) {
  3840. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3841. foreachdata(my_datas[i].children);
  3842. console.log($scope);
  3843. } else {
  3844. my_datas[i].checks = true;
  3845. }
  3846. }
  3847. }
  3848. function foreachtree(data) {
  3849. angular.forEach(data, function (item) {
  3850. // if (item.checks != true) {
  3851. item.checks = true;
  3852. item.expanded = true;
  3853. if (item.children && item.children.length > 0) {
  3854. foreachtree(item.children);
  3855. } else {
  3856. $scope.getslowtree.push(item);
  3857. }
  3858. // }
  3859. });
  3860. }
  3861. $scope.getslowtree = [];
  3862. $scope.slowtree = function (tree) {
  3863. foreachtree(tree);
  3864. return $scope.getslowtree;
  3865. };
  3866. $scope.all = function (c, v) {
  3867. //全选
  3868. if (c == true) {
  3869. $scope.formdashboard($scope.slowtree(v));
  3870. } else {
  3871. $scope.my_data_after = [];
  3872. angular.forEach($scope.my_data, function (item, index) {
  3873. $scope.my_data[index].checks = false;
  3874. $scope.my_data[index].expanded = false;
  3875. if (item.children && item.children.length > 0) {
  3876. angular.forEach(
  3877. item.children,
  3878. function (itemone, indexone) {
  3879. $scope.my_data[index].children[
  3880. indexone
  3881. ].checks = false;
  3882. $scope.my_data[index].children[
  3883. indexone
  3884. ].expanded = false;
  3885. if (itemone.children && itemone.children.length > 0) {
  3886. angular.forEach(
  3887. itemone.children,
  3888. function (itemtwo, indextwo) {
  3889. $scope.my_data[index].children[
  3890. indexone
  3891. ].children[indextwo].checks = false;
  3892. }
  3893. );
  3894. } else {
  3895. }
  3896. }
  3897. );
  3898. } else {
  3899. }
  3900. });
  3901. $scope.mydatacate = [];
  3902. $scope.getslowtree = [];
  3903. // }
  3904. }
  3905. };
  3906. // $scope.searchone = function(search) {
  3907. // angular.forEach($scope.my_data, function(item) {
  3908. // if (item.indexOf(search) > 0) {
  3909. // }
  3910. // })
  3911. // }
  3912. $scope.checkall = function () {
  3913. angular.forEach($scope.my_data, function (item, index) {
  3914. scope.my_data[index].checks = true;
  3915. });
  3916. };
  3917. $scope.selectitem = [];
  3918. $scope.choiceitem = function (item) {
  3919. // if (item.checkeds) {
  3920. // item.checkeds = false;
  3921. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3922. // // if ($scope.selectitem[i].id == item.id) {
  3923. // // $scope.selectitem.splice(i, 1)
  3924. // // }
  3925. // // }
  3926. // for (var i = 0; i < $scope.my_data_after; i++) {
  3927. // if ($scope.my_data_after[i].id == item.id) {
  3928. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3929. // // $scope.selectitem.splice(i, 1)
  3930. // }
  3931. // }
  3932. // } else {
  3933. // item.checkeds = true;
  3934. // $scope.selectitem.push(item)
  3935. // }
  3936. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3937. if ($scope.my_data_after[i].id == item.id) {
  3938. $scope.my_data_after[i].checkeds
  3939. ? ($scope.my_data_after[i].checkeds = false)
  3940. : ($scope.my_data_after[i].checkeds = true);
  3941. }
  3942. }
  3943. };
  3944. $scope.remove = function (removeitem) {
  3945. var realdat = angular.copy($scope.my_data_after);
  3946. // angular.extend(realdat, $scope.selectitem);
  3947. $scope.my_data_after = [];
  3948. angular.forEach(realdat, function (item) {
  3949. if (!item.checkeds) {
  3950. $scope.my_data_after.push(item);
  3951. }
  3952. });
  3953. $scope.mydatacate = angular.copy($scope.my_data_after);
  3954. };
  3955. $scope.try_async_loads = function (item, search) {
  3956. var fildatas = {
  3957. idx: 0,
  3958. sum: 1000,
  3959. };
  3960. $scope.my_data = [];
  3961. // $scope.try_async_load = true;
  3962. if (item) {
  3963. angular.extend(fildatas, item);
  3964. }
  3965. api_configure_data
  3966. .fetchDataList("ciclassify", fildatas)
  3967. .then(function (response) {
  3968. if (response.status == 200) {
  3969. var data = response.list;
  3970. var objects = [];
  3971. for (var i = 0; i < data.length; i++) {
  3972. var object = {};
  3973. object.id = data[i].id;
  3974. if (search) {
  3975. delete data[i].parent;
  3976. } else {
  3977. if (data[i].parent && data[i].parent.id != 0) {
  3978. object.parent = data[i].parent.id;
  3979. }
  3980. }
  3981. angular.extend(object, data[i]);
  3982. objects.push(object);
  3983. }
  3984. $scope.my_data = convertParentToChildList(objects);
  3985. $scope.tree_data = angular.copy($scope.my_data);
  3986. if ($scope.my_data.length > 0) {
  3987. $scope.try_async_load = false;
  3988. }
  3989. } else {
  3990. SweetAlert.swal({
  3991. title: "系统错误!",
  3992. text: "请刷新重试!",
  3993. type: "error",
  3994. });
  3995. }
  3996. });
  3997. };
  3998. function convertListToTree(data, treeMap) {
  3999. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  4000. var root = null; //Initially set our loop to null
  4001. //loop over data
  4002. for (var i = 0; i < data.length; i++) {
  4003. var datum = data[i];
  4004. //each node will have children, so let's give it a "children" poperty
  4005. datum.children = [];
  4006. //add an entry for this node to the map so that any future children can
  4007. //lookup the parent
  4008. idToNodeMap[datum.id] = datum;
  4009. //Does this node have a parent?
  4010. // console.log("datum="+JSON.stringify(datum))
  4011. if (
  4012. typeof datum.parent === "undefined" ||
  4013. datum.parent === null
  4014. ) {
  4015. //Doesn't look like it, so this node is the root of the tree
  4016. root = datum;
  4017. treeMap[datum.id] = root;
  4018. } else {
  4019. //This node has a parent, so let's look it up using the id
  4020. parentNode = idToNodeMap[datum.parent.id];
  4021. //We don't need this property, so let's delete it.
  4022. // delete datum.parent;
  4023. //Let's add the current node as a child of the parent node.
  4024. parentNode.children.push(datum);
  4025. }
  4026. }
  4027. return root;
  4028. }
  4029. function convertParentToChildList(data) {
  4030. var treeMap = {};
  4031. var list = [];
  4032. convertListToTree(data, treeMap);
  4033. angular.forEach(treeMap, function (item) {
  4034. list.push(item);
  4035. });
  4036. return list;
  4037. }
  4038. function convertParentToChild(datato) {
  4039. var treeMapto = {};
  4040. var listto = [];
  4041. convertListToTree(datato, treeMapto);
  4042. angular.forEach(treeMapto, function (items) {
  4043. listto.push(items);
  4044. });
  4045. return listto;
  4046. }
  4047. $scope.try_async_loads();
  4048. $scope.searchdown = function (key) {
  4049. if (key && key != "") {
  4050. $scope.try_async_loads(
  4051. {
  4052. ciclassify: {
  4053. label: key,
  4054. },
  4055. },
  4056. "search"
  4057. );
  4058. } else {
  4059. $scope.try_async_loads();
  4060. }
  4061. // var mydatacatedown = angular.copy($scope.my_data);
  4062. // $scope.my_data = [];
  4063. // var objects = [];
  4064. // angular.forEach(mydatacatedown, function(item) {
  4065. // if (item.label.match(key)) {
  4066. // objects.push(item)
  4067. // } else {
  4068. // // $scope.my_data_after.push(item)
  4069. // }
  4070. // })
  4071. // $scope.my_data = convertParentToChildList(objects);
  4072. // $scope.tree_data = angular.copy($scope.my_data);
  4073. };
  4074. $scope.mydatacate = [];
  4075. $scope.searchup = function (key) {
  4076. // var mydatacate = angular.copy($scope.my_data_after);
  4077. $scope.my_data_after = [];
  4078. angular.forEach($scope.mydatacate, function (item) {
  4079. if (item.label.match(key)) {
  4080. $scope.my_data_after.push(item);
  4081. } else {
  4082. }
  4083. });
  4084. };
  4085. //角色树
  4086. $scope.my_tree = [];
  4087. $scope.tree_data_after = [];
  4088. $scope.my_data = [];
  4089. $scope.my_data_after = [];
  4090. $scope.formdashboard = function (item) {
  4091. $scope.my_data_after = [];
  4092. angular.forEach(item, function (infox) {
  4093. if (infox.children.length == 0) {
  4094. $scope.my_data_after.push(infox);
  4095. }
  4096. });
  4097. $scope.mydatacate = angular.copy($scope.my_data_after);
  4098. };
  4099. $scope.ok = function (item) {
  4100. $modalInstance.close(item);
  4101. };
  4102. $scope.cancel = function () {
  4103. $modalInstance.dismiss("cancel");
  4104. };
  4105. },
  4106. // size: 'sm',
  4107. resolve: {
  4108. scope: function () {
  4109. return $scope;
  4110. },
  4111. },
  4112. });
  4113. modalInstance.result.then(function (selectedItem) {
  4114. // $rootScope.isMask = true;
  4115. if (selectedItem) {
  4116. var type = 1;
  4117. var fildat = {
  4118. configure: selectedItem,
  4119. };
  4120. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4121. // // if (data.errno == 0) {
  4122. // var file = new Blob([data], {
  4123. // // 'Accept': '*/*'
  4124. // type: 'application/octet-stream'
  4125. // // type: 'application/vnd.ms-excel'
  4126. // });
  4127. // //trick to download store a file having its URL
  4128. // var fileURL = URL.createObjectURL(file);
  4129. // var a = document.createElement('a');
  4130. // a.href = fileURL;
  4131. // a.target = '_blank';
  4132. // a.download = "资产导入模版.xlsx";
  4133. // document.body.appendChild(a);
  4134. // a.click();
  4135. // // }
  4136. // })
  4137. $http({
  4138. url: api_configure_data
  4139. .downModels("export/cmdb", fildat)
  4140. .getRequestedUrl(),
  4141. method: "POST",
  4142. data: JSON.stringify(fildat),
  4143. headers: {
  4144. // 'Content-type': 'application/xls',
  4145. Accept: "*/*",
  4146. },
  4147. responseType: "arraybuffer",
  4148. })
  4149. .success(function (data, status, headers, config) {
  4150. $rootScope.isMask = false;
  4151. var file = new Blob([data], {
  4152. type: "application/octet-stream",
  4153. // type : 'application/vnd.ms-excel'
  4154. });
  4155. //trick to download store a file having its URL
  4156. var fileURL = URL.createObjectURL(file);
  4157. var a = document.createElement("a");
  4158. a.href = fileURL;
  4159. a.target = "_blank";
  4160. a.download = "资产导入模版.xlsx";
  4161. document.body.appendChild(a);
  4162. a.click();
  4163. })
  4164. .error(function (data, status, headers, config) {
  4165. // console.log(data);
  4166. $rootScope.isMask = false;
  4167. });
  4168. // break;
  4169. // }
  4170. // }
  4171. // }
  4172. // })
  4173. } else {
  4174. SweetAlert.swal(
  4175. {
  4176. title: "未选择资产分类!",
  4177. text: "请选择资产分类",
  4178. type: "error",
  4179. },
  4180. function () {
  4181. $rootScope.isMask = false;
  4182. }
  4183. );
  4184. }
  4185. // }
  4186. });
  4187. };
  4188. $scope.wrongdata = [];
  4189. var uploader = ($scope.uploader =
  4190. $scope.options.templateOptions.fileUploader);
  4191. var uploadermeans = ($scope.uploadermeans =
  4192. $scope.options.templateOptions.fileUploadermeans);
  4193. $scope.importopen = function () {
  4194. //导入触发事件
  4195. if (angular.isUndefined($scope.form.dropState)) {
  4196. $scope.form.dropState = false;
  4197. }
  4198. //附件上传数据
  4199. //$scope.options.templateOptions.uploader();
  4200. // FILTERS
  4201. uploader.filters.push({
  4202. name: "customFilter",
  4203. fn: function (item /*{File|FileLikeObject}*/, options) {
  4204. return this.queue.length < 2;
  4205. },
  4206. });
  4207. // CALLBACKS
  4208. uploader.onWhenAddingFileFailed = function (
  4209. item /*{File|FileLikeObject}*/,
  4210. filter,
  4211. options
  4212. ) {
  4213. console.info("onWhenAddingFileFailed", item, filter, options);
  4214. };
  4215. uploader.onAfterAddingFile = function (fileItem) {
  4216. console.info("onAfterAddingFile", fileItem);
  4217. };
  4218. uploader.onAfterAddingAll = function (addedFileItems) {
  4219. console.info("onAfterAddingAll", addedFileItems);
  4220. };
  4221. uploader.onBeforeUploadItem = function (item) {
  4222. console.info("onBeforeUploadItem", item);
  4223. };
  4224. uploader.onProgressItem = function (fileItem, progress) {
  4225. console.info("onProgressItem", fileItem, progress);
  4226. };
  4227. uploader.onProgressAll = function (progress) {
  4228. console.info("onProgressAll", progress);
  4229. };
  4230. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4231. // console.info('onSuccessItem', fileItem, response, status, headers);
  4232. // };
  4233. uploader.onErrorItem = function (
  4234. fileItem,
  4235. response,
  4236. status,
  4237. headers
  4238. ) {
  4239. console.info("onErrorItem", fileItem, response, status, headers);
  4240. };
  4241. uploader.onCancelItem = function (
  4242. fileItem,
  4243. response,
  4244. status,
  4245. headers
  4246. ) {
  4247. console.info("onCancelItem", fileItem, response, status, headers);
  4248. };
  4249. uploader.onCompleteItem = function (
  4250. fileItem,
  4251. response,
  4252. status,
  4253. headers
  4254. ) {
  4255. console.info("onCompleteItem", fileItem, response, status, headers);
  4256. };
  4257. uploader.onCompleteAll = function () {
  4258. console.info("onCompleteAll");
  4259. };
  4260. };
  4261. // $scope.importnext = function() {
  4262. // $scope.state = 2;
  4263. // event.preventDefault();
  4264. // }
  4265. $scope.importnext = function () {
  4266. event.preventDefault();
  4267. // $rootScope.isMask = true;
  4268. $rootScope.loading = true;
  4269. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4270. uploader.onBeforeUploadItem = function (item) {
  4271. angular.extend(item.headers, $rootScope.getSession());
  4272. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4273. // if (item.index > 1) {
  4274. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4275. // }
  4276. // item.index = 1;
  4277. item.formData = [
  4278. {
  4279. filename: item.file.name,
  4280. },
  4281. ];
  4282. console.info("onBeforeUploadItem", item);
  4283. };
  4284. uploader.uploadAll();
  4285. uploader.onSuccessItem = function (
  4286. fileItem,
  4287. response,
  4288. status,
  4289. headers
  4290. ) {
  4291. if (response.status == 200) {
  4292. $scope.wrongdata = [];
  4293. $rootScope.loading = false;
  4294. if (response.abnormal) {
  4295. $scope.state = 2;
  4296. angular.forEach(response.msg, function (item) {
  4297. $scope.wrongdata.push({
  4298. name: item.assetName,
  4299. line: item.row,
  4300. cmdbname: item.name,
  4301. errotip: [
  4302. {
  4303. label: item.msg,
  4304. },
  4305. ],
  4306. });
  4307. });
  4308. } else {
  4309. $scope.state = 3;
  4310. }
  4311. } else {
  4312. $rootScope.loading = false;
  4313. $scope.state = 2;
  4314. }
  4315. };
  4316. };
  4317. $scope.clearItems = function () {
  4318. //重新选择文件时,清空队列,达到覆盖文件的效果
  4319. uploader.clearQueue();
  4320. // uploader.remove();
  4321. // uploader.cancel();
  4322. // uploader.onChange();
  4323. };
  4324. uploader.onAfterAddingFile = function (fileItem) {
  4325. $scope.fileItem = fileItem._file;
  4326. // $scope.$apply();
  4327. // $scope.fileItem = filenum;
  4328. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4329. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4330. $scope.filenum++;
  4331. };
  4332. uploader.onSuccessItem = function (
  4333. fileItem,
  4334. response,
  4335. status,
  4336. headers
  4337. ) {
  4338. $scope.uploadStatus = true; //上传成功则把状态改为true
  4339. // alert(response.path);
  4340. };
  4341. $scope.importnext = function () {
  4342. event.preventDefault();
  4343. // uploader.onChange();
  4344. $rootScope.loading = true;
  4345. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4346. uploader.onBeforeUploadItem = function (item) {
  4347. angular.extend(item.headers, $rootScope.getSession());
  4348. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4349. // if (item.index > 1) {
  4350. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4351. // }
  4352. // item.index = 1;
  4353. item.formData = [
  4354. {
  4355. filename: item.file.name,
  4356. },
  4357. ];
  4358. console.info("onBeforeUploadItem", item);
  4359. };
  4360. uploader.uploadAll();
  4361. uploader.onSuccessItem = function (
  4362. fileItem,
  4363. response,
  4364. status,
  4365. headers
  4366. ) {
  4367. if (response.status == 200) {
  4368. $scope.wrongdata = [];
  4369. // uploader.queue = [];
  4370. $rootScope.loading = false;
  4371. if (response.abnormal) {
  4372. $scope.state = 2;
  4373. uploader.clearQueue();
  4374. angular.forEach(response.msg, function (item) {
  4375. $scope.wrongdata.push({
  4376. name: item.assetName,
  4377. line: item.row,
  4378. cmdbname: item.name,
  4379. errotip: [
  4380. {
  4381. label: item.msg,
  4382. },
  4383. ],
  4384. });
  4385. });
  4386. } else {
  4387. $scope.state = 3;
  4388. }
  4389. } else {
  4390. uploader.clearQueue();
  4391. $rootScope.loading = false;
  4392. $scope.state = 2;
  4393. }
  4394. };
  4395. };
  4396. var setAllInactive = function () {
  4397. angular.forEach($scope.workspaces, function (workspace) {
  4398. workspace.active = false;
  4399. });
  4400. };
  4401. //添加
  4402. var addNewWorkspace = function (name, contentUrl) {
  4403. var id = $scope.workspaces.length + 1;
  4404. $scope.workspaces.push({
  4405. id: id,
  4406. name: name,
  4407. active: true,
  4408. contentUrl: "main/html/content.html",
  4409. });
  4410. };
  4411. //关闭
  4412. $scope.closeopen = function (closedata) {
  4413. event.preventDefault();
  4414. angular.forEach($scope.workspaces, function (item, index) {
  4415. if (closedata.id == item.id) {
  4416. if (closedata.id == 1) {
  4417. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4418. } else {
  4419. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4420. }
  4421. $scope.workspaces.splice(index, 1);
  4422. }
  4423. });
  4424. };
  4425. // $scope.workspaces = [
  4426. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4427. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4428. // ];
  4429. $scope.addWorkspace = function (contentUrl, name) {
  4430. setAllInactive();
  4431. addNewWorkspace(name, contentUrl);
  4432. };
  4433. // $rootScope.addWorkspace = $scope.addWorkspace;
  4434. $scope.close = function (idNumber) {
  4435. var index = 0; //记录当前元素下标
  4436. angular.forEach($scope.workspaces, function (workspace) {
  4437. if (workspace.id === idNumber) {
  4438. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4439. }
  4440. index++;
  4441. });
  4442. };
  4443. //grid2
  4444. $scope.langs = i18nService.getAllLangs();
  4445. $scope.lang = "zh-cn";
  4446. i18nService.setCurrentLang($scope.lang);
  4447. $scope.gridOptions2 = {};
  4448. $scope.gridOptions2.data = "myData3";
  4449. $scope.gridOptions2.enableColumnResizing = true;
  4450. $scope.gridOptions2.enableFiltering = false;
  4451. $scope.gridOptions2.enableGridMenu = false;
  4452. $scope.gridOptions2.showGridFooter = true;
  4453. $scope.gridOptions2.showColumnFooter = false;
  4454. $scope.gridOptions2.fastWatch = true;
  4455. $scope.gridOptions2.useExternalFiltering = true;
  4456. $scope.gridOptions2.useExternalPagination = true;
  4457. $scope.gridOptions2.paginationPageSizes = [10];
  4458. $scope.gridOptions2.paginationPageSize = 10;
  4459. $scope.gridOptions2.multiSelect = false;
  4460. // $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>";
  4461. $scope.gridOptions2.columnDefs = [
  4462. {
  4463. name: "item",
  4464. displayName: "序号",
  4465. width: 120,
  4466. },
  4467. {
  4468. name: "name",
  4469. displayName: "耗材名称",
  4470. width: 80,
  4471. enableFiltering: false,
  4472. },
  4473. {
  4474. name: "model",
  4475. displayName: "品牌/型号",
  4476. width: 100,
  4477. enableFiltering: false,
  4478. },
  4479. {
  4480. name: "Specifications",
  4481. displayName: "规格",
  4482. width: 150,
  4483. enableFiltering: false,
  4484. },
  4485. {
  4486. name: "sum",
  4487. displayName: "数量",
  4488. enableFiltering: false,
  4489. },
  4490. {
  4491. name: "操作",
  4492. cellTemplate:
  4493. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4494. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4495. "</div></div>",
  4496. enableFiltering: false,
  4497. },
  4498. ];
  4499. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4500. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4501. $scope.myData3all = JSON.parse(
  4502. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4503. );
  4504. for (var i = 0; i < $scope.myData3all.length; i++) {
  4505. $scope.myData3all[i]["item"] =
  4506. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4507. }
  4508. // $scope.model.consumables = $scope.myDataone;
  4509. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4510. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4511. $scope.model.applicationForm.consumables = $scope.myData3all;
  4512. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4513. $scope.options.templateOptions.getpush({
  4514. hao: true,
  4515. gu: true,
  4516. });
  4517. } else {
  4518. $scope.options.templateOptions.getpush({
  4519. hao: true,
  4520. });
  4521. }
  4522. } else {
  4523. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4524. $scope.options.templateOptions.getpush({
  4525. gu: true,
  4526. });
  4527. }
  4528. }
  4529. }
  4530. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4531. $scope.changecai = function (item) {
  4532. event.preventDefault();
  4533. var modalInstance = $modal.open({
  4534. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4535. controller: function ($scope, $modalInstance) {
  4536. $scope.title = "修改耗材数量";
  4537. $scope.consumptive = angular.copy(item);
  4538. $scope.ok = function () {
  4539. $modalInstance.close($scope.consumptive);
  4540. };
  4541. $scope.cancel = function () {
  4542. $modalInstance.dismiss("cancel");
  4543. };
  4544. },
  4545. size: "sm",
  4546. });
  4547. modalInstance.result.then(function (selectedItem) {
  4548. // angular.forEach($scope.myData3, function(items, index) {
  4549. // if (items.id == selectedItem.id) {
  4550. // $scope.myData3[index] = selectedItem;
  4551. // }
  4552. // })
  4553. // // $scope.myData3.push(selectedItem);
  4554. // $scope.model.applicationForm.consumables = $scope.myData3;
  4555. angular.forEach($scope.myData3all, function (items, index) {
  4556. if (
  4557. items.modelid == selectedItem.modelid &&
  4558. items.nameid == selectedItem.nameid &&
  4559. items.Specificationsid == selectedItem.Specificationsid
  4560. ) {
  4561. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4562. angular.extend($scope.myData3all[index], selectedItem);
  4563. }
  4564. });
  4565. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4566. $scope.myData3 = $scope.interceptMydata(
  4567. $scope.myData3all,
  4568. $scope.memoryfilterDatahao.idx,
  4569. 10
  4570. );
  4571. $scope.model.applicationForm.consumables = $scope.myData3all;
  4572. });
  4573. };
  4574. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4575. $scope.gridApi = gridApi;
  4576. gridApi.pagination.on.paginationChanged(
  4577. $scope,
  4578. function (newPage, pageSize) {
  4579. // var filtersData = $scope.memoryfilterDatahao;
  4580. // filtersData.idx = newPage - 1;
  4581. // filtersData.sum = pageSize;
  4582. // $scope.loadData(filtersData);
  4583. $scope.memoryfilterDatahao.idx = newPage - 1;
  4584. $scope.memoryfilterDatahao.sum = pageSize;
  4585. $scope.myData3 = $scope.interceptMydata(
  4586. $scope.myData3all,
  4587. $scope.memoryfilterDatahao.idx,
  4588. 10
  4589. );
  4590. }
  4591. );
  4592. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4593. $scope.selected.items = data.entity;
  4594. //console.log(data);
  4595. });
  4596. gridApi.selection.on.rowSelectionChangedBatch(
  4597. $scope,
  4598. function (data) {
  4599. $scope.selected.items = data.entity;
  4600. //console.log(data);
  4601. }
  4602. );
  4603. gridApi.core.on.filterChanged($scope, function () {
  4604. var grid = this.grid;
  4605. var filtersData = {
  4606. idx: 0,
  4607. sum: 10,
  4608. };
  4609. $scope.memoryfilterDatahao = filtersData;
  4610. // $scope.loadData(filtersData);
  4611. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4612. // $scope.memoryfilterDatahao.sum = pageSize;
  4613. $scope.myData3 = $scope.interceptMydata(
  4614. $scope.myData3all,
  4615. $scope.memoryfilterDatahao.idx,
  4616. 10
  4617. );
  4618. });
  4619. };
  4620. $scope.haocaiopen = function (items) {
  4621. event.preventDefault();
  4622. var modalInstance = $modal.open({
  4623. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4624. controller: function ($scope, $modalInstance, SweetAlert) {
  4625. $scope.consumptive = {};
  4626. $scope.title = "新增耗材";
  4627. if (items.name) {
  4628. $scope.consumptive.name = items.name.name;
  4629. }
  4630. $scope.clearNoNum = function (obj, attr) {
  4631. //先把非数字的都替换掉,除了数字和.
  4632. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4633. //必须保证第一个为数字而不是.
  4634. obj[attr] = obj[attr].replace(/^\./g, "");
  4635. //保证只有出现一个.而没有多个.
  4636. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4637. //保证.只出现一次,而不能出现两次以上
  4638. obj[attr] = obj[attr]
  4639. .replace(".", "$#$")
  4640. .replace(/\./g, "")
  4641. .replace("$#$", ".");
  4642. //小于最大值
  4643. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4644. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4645. // obj[attr] = '';
  4646. // }
  4647. };
  4648. $scope.ok = function (item) {
  4649. // if (item.name && item.model && item.Specifications && item.sum) {
  4650. if (
  4651. item.name &&
  4652. item.model &&
  4653. JSON.stringify(item.model) != "{}" &&
  4654. item.Specifications &&
  4655. JSON.stringify(item.Specifications) != "{}" &&
  4656. item.sum
  4657. ) {
  4658. $modalInstance.close(item);
  4659. } else {
  4660. SweetAlert.swal({
  4661. title: "数据填写不完整!",
  4662. text: "请检查数据然后提交!",
  4663. type: "error",
  4664. });
  4665. }
  4666. };
  4667. $scope.cancel = function () {
  4668. $modalInstance.dismiss("cancel");
  4669. };
  4670. },
  4671. size: "sm",
  4672. resolve: {
  4673. SweetAlert: function () {
  4674. return SweetAlert;
  4675. },
  4676. },
  4677. });
  4678. modalInstance.result.then(function (selectedItem) {
  4679. api_sysinfo
  4680. .addData("dictionaryTree", {
  4681. // "type": "list",
  4682. key: "haocaifenlei",
  4683. name: selectedItem.name,
  4684. parent: selectedItem.id,
  4685. value: selectedItem.name,
  4686. deleted: false,
  4687. level: 1,
  4688. })
  4689. .then(function (data) {
  4690. // $scope.haocainame.name = data.list;
  4691. api_sysinfo
  4692. .addData("dictionaryTree", {
  4693. // "type": "list",
  4694. key: "pinpai",
  4695. name: selectedItem.model,
  4696. parent: data.id,
  4697. value: selectedItem.model,
  4698. deleted: false,
  4699. level: 2,
  4700. })
  4701. .then(function (data) {
  4702. // $scope.haocainame = data.list;
  4703. });
  4704. api_sysinfo
  4705. .addData({
  4706. // "type": "list",
  4707. key: "guige",
  4708. name: selectedItem.Specifications,
  4709. parent: data.id,
  4710. value: selectedItem.Specifications,
  4711. deleted: false,
  4712. level: 2,
  4713. })
  4714. .then(function (data) {
  4715. // $scope.haocainame = data.list;
  4716. });
  4717. });
  4718. // $scope.myData3.push(selectedItem);
  4719. // for (var i = 0; i < $scope.myData3.length; i++) {
  4720. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4721. // }
  4722. // $scope.model.applicationForm.consumables = $scope.myData3;
  4723. $scope.myData3all.push(selectedItem);
  4724. for (var i = 0; i < $scope.myData3all.length; i++) {
  4725. $scope.myData3all[i]["item"] = i + 1;
  4726. }
  4727. // $scope.model.consumables = $scope.myDataone;
  4728. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4729. $scope.myData3 = $scope.interceptMydata(
  4730. $scope.myData3all,
  4731. $scope.memoryfilterDatahao.idx,
  4732. 10
  4733. );
  4734. $scope.model.applicationForm.consumables = $scope.myData3all;
  4735. });
  4736. };
  4737. $scope.haocaiadd = function () {
  4738. event.preventDefault();
  4739. var modalInstance = $modal.open({
  4740. templateUrl:
  4741. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4742. controller: function (
  4743. $scope,
  4744. scope,
  4745. $modalInstance,
  4746. api_wechatfile,
  4747. SweetAlert,
  4748. api_cmdb3
  4749. ) {
  4750. $scope.haocainame = [];
  4751. $scope.pinpai = [];
  4752. $scope.guige = [];
  4753. $scope.consumptive = {};
  4754. $scope.consumpall = {};
  4755. $scope.title = "添加耗材";
  4756. api_wechatfile
  4757. .getDictionary({
  4758. key: "haocaifenlei",
  4759. type: "tree",
  4760. })
  4761. .then(function (data) {
  4762. $scope.haocainame = data;
  4763. });
  4764. $scope.clearNoNum = function (obj, attr) {
  4765. //先把非数字的都替换掉,除了数字和.
  4766. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4767. //必须保证第一个为数字而不是.
  4768. obj[attr] = obj[attr].replace(/^\./g, "");
  4769. //保证只有出现一个.而没有多个.
  4770. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4771. //保证.只出现一次,而不能出现两次以上
  4772. obj[attr] = obj[attr]
  4773. .replace(".", "$#$")
  4774. .replace(/\./g, "")
  4775. .replace("$#$", ".");
  4776. //小于最大值
  4777. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4778. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4779. // obj[attr] = '';
  4780. // }
  4781. };
  4782. $scope.onChange = function (parent) {
  4783. $scope.consumptive.model = {};
  4784. $scope.consumptive.Specifications = {};
  4785. api_wechatfile
  4786. .getDictionaryForList({
  4787. key: "pinpai",
  4788. parent: parent.id,
  4789. })
  4790. .then(function (data) {
  4791. $scope.pinpai = data;
  4792. });
  4793. api_wechatfile
  4794. .getDictionaryForList({
  4795. key: "guige",
  4796. parent: parent.id,
  4797. })
  4798. .then(function (data) {
  4799. $scope.guige = data;
  4800. });
  4801. };
  4802. $scope.addhaocai = function () {
  4803. $modalInstance.dismiss("cancel");
  4804. scope.haocaiopen($scope.consumptive);
  4805. };
  4806. $scope.ok = function (item) {
  4807. var items = {};
  4808. var submittrue = true;
  4809. if (
  4810. item.name &&
  4811. item.model &&
  4812. JSON.stringify(item.model) != "{}" &&
  4813. item.Specifications &&
  4814. JSON.stringify(item.Specifications) != "{}" &&
  4815. item.sum
  4816. ) {
  4817. items = {
  4818. modelid: item.model.id,
  4819. nameid: item.name.id,
  4820. Specificationsid: item.Specifications.id,
  4821. name: item.name.name,
  4822. model: item.model.name,
  4823. Specifications: item.Specifications.name,
  4824. sum: item.sum,
  4825. };
  4826. angular.forEach(scope.myData3all, function (itemsdata) {
  4827. if (
  4828. item.model.id == itemsdata.modelid &&
  4829. item.name.id == itemsdata.nameid &&
  4830. item.Specifications.id == itemsdata.Specificationsid
  4831. ) {
  4832. submittrue = false;
  4833. }
  4834. });
  4835. if (submittrue) {
  4836. $modalInstance.close(items);
  4837. } else {
  4838. SweetAlert.swal({
  4839. title: "该耗材已有添加",
  4840. text: "请检查数据然后提交!",
  4841. type: "error",
  4842. });
  4843. }
  4844. } else {
  4845. SweetAlert.swal({
  4846. title: "数据填写不完整!",
  4847. text: "请检查数据然后提交!",
  4848. type: "error",
  4849. });
  4850. }
  4851. // var isold = false;
  4852. // if (item.name && item.model && item.Specifications && item.sum) {
  4853. // for (var i = 0; i < scope.myData3all.length; i++) {
  4854. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4855. // isold = true;
  4856. // }
  4857. // }
  4858. // if (isold) {
  4859. // SweetAlert.swal({
  4860. // title: "该耗材已添加!",
  4861. // text: "请不要重复添加耗材!",
  4862. // type: "error"
  4863. // });
  4864. // } else {
  4865. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4866. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4867. // $scope.consumpall.sum = item.sum;
  4868. // delete $scope.consumpall.brandModel;
  4869. // delete $scope.consumpall.specification;
  4870. // $modalInstance.close($scope.consumpall);
  4871. // }
  4872. // } else {
  4873. // SweetAlert.swal({
  4874. // title: "数据填写不完整!",
  4875. // text: "请检查数据然后提交!",
  4876. // type: "error"
  4877. // });
  4878. // }
  4879. };
  4880. $scope.cancel = function () {
  4881. $modalInstance.dismiss("cancel");
  4882. };
  4883. },
  4884. size: "sm",
  4885. resolve: {
  4886. scope: function () {
  4887. return $scope;
  4888. },
  4889. },
  4890. });
  4891. modalInstance.result.then(function (selectedItem) {
  4892. $scope.myData3all.push(selectedItem);
  4893. for (var i = 0; i < $scope.myData3all.length; i++) {
  4894. $scope.myData3all[i]["item"] = i + 1;
  4895. }
  4896. // $scope.model.consumables = $scope.myDataone;
  4897. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4898. $scope.myData3 = $scope.interceptMydata(
  4899. $scope.myData3all,
  4900. $scope.memoryfilterDatahao.idx,
  4901. 10
  4902. );
  4903. $scope.model.applicationForm.consumables = $scope.myData3all;
  4904. });
  4905. };
  4906. $scope.onDblClick = function (data, event) {
  4907. $scope.selectButtonClick(data, event);
  4908. };
  4909. // $scope.memoryfilterDatahao = {
  4910. // "idx": 0,
  4911. // "sum": 10,
  4912. // }
  4913. // $scope.loadData = function(filterData) {};
  4914. // $scope.title = title;
  4915. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4916. $scope.options.templateOptions.transform(
  4917. $scope.options,
  4918. $rootScope,
  4919. $scope
  4920. );
  4921. }
  4922. },
  4923. ],
  4924. });
  4925. //归还设备耗材tab
  4926. formlyConfigProvider.setType({
  4927. name: "ui-cmdbreturntab",
  4928. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4929. wrapper: ["bootstrapHasError"],
  4930. defaultOptions: function (options, $scope) {
  4931. return {
  4932. templateOptions: {
  4933. // checkform: function(options) {
  4934. // if (options.model.requester) {
  4935. // options.value(options.model.requester);
  4936. // }
  4937. // },
  4938. },
  4939. };
  4940. },
  4941. controller: [
  4942. "$scope",
  4943. "$modal",
  4944. "api_user_data",
  4945. "i18nService",
  4946. "api_wechatfile",
  4947. "api_cmdb3",
  4948. function (
  4949. $scope,
  4950. $modal,
  4951. api_user_data,
  4952. i18nService,
  4953. api_wechatfile,
  4954. api_cmdb3
  4955. ) {
  4956. var setAllInactive = function () {
  4957. angular.forEach($scope.workspaces, function (workspace) {
  4958. workspace.active = false;
  4959. });
  4960. };
  4961. $scope.memoryfilterData = {
  4962. idx: 0,
  4963. sum: 10,
  4964. };
  4965. //添加
  4966. var addNewWorkspace = function (name, contentUrl) {
  4967. var id = $scope.workspaces.length + 1;
  4968. $scope.workspaces.push({
  4969. id: id,
  4970. name: name,
  4971. active: true,
  4972. contentUrl: "main/html/content.html",
  4973. });
  4974. };
  4975. $scope.workspaces = [
  4976. {
  4977. id: 1,
  4978. name: "归还设备",
  4979. active: true,
  4980. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4981. },
  4982. {
  4983. id: 2,
  4984. name: "归还耗材",
  4985. active: true,
  4986. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4987. },
  4988. ];
  4989. $scope.addWorkspace = function (contentUrl, name) {
  4990. setAllInactive();
  4991. addNewWorkspace(name, contentUrl);
  4992. };
  4993. // $rootScope.addWorkspace = $scope.addWorkspace;
  4994. $scope.close = function (idNumber) {
  4995. var index = 0; //记录当前元素下标
  4996. angular.forEach($scope.workspaces, function (workspace) {
  4997. if (workspace.id === idNumber) {
  4998. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4999. }
  5000. index++;
  5001. });
  5002. };
  5003. $scope.memoryfilterDataguishe = {
  5004. idx: 0,
  5005. sum: 10,
  5006. };
  5007. //grid1
  5008. $scope.langs = i18nService.getAllLangs();
  5009. $scope.lang = "zh-cn";
  5010. i18nService.setCurrentLang($scope.lang);
  5011. $scope.gridOptions1 = {};
  5012. $scope.gridOptions1.data = "myData1";
  5013. $scope.gridOptions1.enableColumnResizing = true;
  5014. $scope.gridOptions1.enableFiltering = false;
  5015. $scope.gridOptions1.enableGridMenu = false;
  5016. $scope.gridOptions1.showGridFooter = true;
  5017. $scope.gridOptions1.showColumnFooter = false;
  5018. $scope.gridOptions1.fastWatch = true;
  5019. $scope.gridOptions1.useExternalFiltering = true;
  5020. $scope.gridOptions1.useExternalPagination = true;
  5021. $scope.gridOptions1.paginationPageSizes = [10];
  5022. $scope.gridOptions1.paginationPageSize = 10;
  5023. $scope.gridOptions1.multiSelect = false;
  5024. // $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>";
  5025. $scope.gridOptions1.columnDefs = [
  5026. {
  5027. name: "item",
  5028. displayName: "序号",
  5029. width: 120,
  5030. },
  5031. {
  5032. name: "props.hw_cifilterClassic",
  5033. displayName: "设备类型",
  5034. width: 150,
  5035. enableFiltering: false,
  5036. },
  5037. {
  5038. name: "props.hw_mingcheng",
  5039. displayName: "设备名称",
  5040. width: 180,
  5041. enableFiltering: false,
  5042. },
  5043. {
  5044. name: "uuid",
  5045. displayName: "设备编号",
  5046. width: 180,
  5047. enableFiltering: false,
  5048. },
  5049. {
  5050. name: "props.hw_state",
  5051. width: 150,
  5052. displayName: "状态",
  5053. enableFiltering: false,
  5054. },
  5055. {
  5056. name: "操作",
  5057. cellTemplate:
  5058. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5059. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5060. "</div></div>",
  5061. enableFiltering: false,
  5062. },
  5063. ];
  5064. // $scope.selectButtonClick
  5065. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5066. $scope.gridApi = gridApi;
  5067. gridApi.pagination.on.paginationChanged(
  5068. $scope,
  5069. function (newPage, pageSize) {
  5070. // var filtersData = $scope.memoryfilterData;
  5071. // filtersData.idx = newPage - 1;
  5072. // filtersData.sum = pageSize;
  5073. // $scope.loadData(filtersData);
  5074. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5075. $scope.memoryfilterDataguishe.sum = pageSize;
  5076. $scope.myData1 = $scope.interceptMydata(
  5077. $scope.myData2all,
  5078. $scope.memoryfilterDataguishe.idx,
  5079. 10
  5080. );
  5081. }
  5082. );
  5083. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5084. $scope.selected.items = data.entity;
  5085. //console.log(data);
  5086. });
  5087. gridApi.selection.on.rowSelectionChangedBatch(
  5088. $scope,
  5089. function (data) {
  5090. $scope.selected.items = data.entity;
  5091. //console.log(data);
  5092. }
  5093. );
  5094. gridApi.core.on.filterChanged($scope, function () {
  5095. // var grid = this.grid;
  5096. // var filtersData = {
  5097. // idx: 0,
  5098. // sum: 20,
  5099. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5100. // };
  5101. // angular.forEach(grid.columns, function(item) {
  5102. // if (item.enableFiltering) {
  5103. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5104. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5105. // if (angular.isUndefined(filtersData['user'])) {
  5106. // filtersData['user'] = {};
  5107. // }
  5108. // filtersData['user'][item.field] = item.filters[0].term;
  5109. // }
  5110. // }
  5111. // });
  5112. // $scope.memoryfilterData = filtersData;
  5113. // $scope.loadData(filtersData);
  5114. });
  5115. };
  5116. $scope.changegu = function (item) {
  5117. event.preventDefault();
  5118. var modalInstance = $modal.open({
  5119. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5120. controller: function ($scope, $modalInstance) {
  5121. $scope.title = "修改设备状态";
  5122. $scope.hw_state = {};
  5123. if (item.status) {
  5124. $scope.hw_state.name = item.hw_state;
  5125. }
  5126. // $scope.consumptive = item;
  5127. $scope.stateshe = [
  5128. {
  5129. id: 2,
  5130. name: "在库",
  5131. },
  5132. {
  5133. id: 4,
  5134. name: "报修",
  5135. },
  5136. {
  5137. id: 3,
  5138. name: "报废",
  5139. },
  5140. ];
  5141. $scope.ok = function (item) {
  5142. $modalInstance.close($scope.hw_state);
  5143. };
  5144. $scope.cancel = function () {
  5145. $modalInstance.dismiss("cancel");
  5146. };
  5147. },
  5148. size: "sm",
  5149. });
  5150. modalInstance.result.then(function (selectedItem) {
  5151. angular.forEach($scope.myData1, function (items, index) {
  5152. if (items.id == item.id) {
  5153. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5154. }
  5155. });
  5156. $scope.model.assets = $scope.myData1;
  5157. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5158. $scope.model.assets;
  5159. });
  5160. };
  5161. $scope.onDblClick = function (data, event) {
  5162. $scope.selectButtonClick(data, event);
  5163. };
  5164. $scope.memoryfilterData = {
  5165. idx: 0,
  5166. sum: 10,
  5167. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5168. };
  5169. // $scope.myData = {};
  5170. $scope.loadData = function (filterData) { };
  5171. // $scope.title = title;
  5172. $scope.loadData({
  5173. idx: 0,
  5174. sum: 10,
  5175. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5176. });
  5177. $scope.selected = {
  5178. items: [],
  5179. };
  5180. $scope.myData2 = [];
  5181. $scope.consumptive = {};
  5182. $scope.myDataguibeiall = [];
  5183. $scope.haocaiopen = function (items) {
  5184. event.preventDefault();
  5185. var modalInstance = $modal.open({
  5186. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5187. controller: function (
  5188. $scope,
  5189. $modalInstance,
  5190. SweetAlert,
  5191. api_wechatfile,
  5192. api_sysinfo
  5193. ) {
  5194. $scope.consumptive = {};
  5195. $scope.title = "新增耗材";
  5196. if (items.name) {
  5197. $scope.consumptive.name = items.name.name;
  5198. }
  5199. $scope.ok = function (item) {
  5200. if (
  5201. item.name &&
  5202. item.model &&
  5203. JSON.stringify(item.model) != "{}" &&
  5204. item.Specifications &&
  5205. JSON.stringify(item.Specifications) != "{}" &&
  5206. item.sum
  5207. ) {
  5208. $modalInstance.close(item);
  5209. } else {
  5210. SweetAlert.swal({
  5211. title: "数据填写不完整!",
  5212. text: "请检查数据然后提交!",
  5213. type: "error",
  5214. });
  5215. }
  5216. };
  5217. $scope.cancel = function () {
  5218. $modalInstance.dismiss("cancel");
  5219. };
  5220. },
  5221. size: "sm",
  5222. });
  5223. modalInstance.result.then(function (selectedItem) {
  5224. api_sysinfo
  5225. .addData({
  5226. type: "list",
  5227. key: "haocaifenlei",
  5228. name: selectedItem.name,
  5229. parent: selectedItem.id,
  5230. value: "1",
  5231. })
  5232. .then(function (data) {
  5233. // $scope.haocainame.name = data.list;
  5234. api_wechatfile
  5235. .addDictionary({
  5236. type: "list",
  5237. key: "pinpai",
  5238. name: selectedItem.model,
  5239. parent: data.id,
  5240. value: "1",
  5241. })
  5242. .then(function (data) {
  5243. // $scope.haocainame = data.list;
  5244. });
  5245. api_wechatfile
  5246. .addDictionary({
  5247. type: "list",
  5248. key: "guige",
  5249. name: selectedItem.Specifications,
  5250. parent: data.id,
  5251. value: "1",
  5252. })
  5253. .then(function (data) {
  5254. // $scope.haocainame = data.list;
  5255. });
  5256. });
  5257. $scope.myData2.push(selectedItem);
  5258. for (var i = 0; i < $scope.myData2.length; i++) {
  5259. $scope.myData2[i]["item"] =
  5260. i + 1 + $scope.memoryfilterData.idx * 10;
  5261. }
  5262. // $scope.model.applicationForm.consumables = $scope.myData2;
  5263. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5264. if (items.id == selectedItem.id) {
  5265. $scope.myDataguibeiall.splice(index, 1);
  5266. }
  5267. });
  5268. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5269. $scope.model.consumables = $scope.myDataguibeiall;
  5270. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5271. $scope.model.consumables;
  5272. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5273. });
  5274. };
  5275. //grid2
  5276. $scope.langs = i18nService.getAllLangs();
  5277. $scope.lang = "zh-cn";
  5278. i18nService.setCurrentLang($scope.lang);
  5279. $scope.gridOptions2 = {};
  5280. $scope.gridOptions2.data = "myData2";
  5281. $scope.gridOptions2.enableColumnResizing = true;
  5282. $scope.gridOptions2.enableFiltering = false;
  5283. $scope.gridOptions2.enableGridMenu = false;
  5284. $scope.gridOptions2.showGridFooter = true;
  5285. $scope.gridOptions2.showColumnFooter = false;
  5286. $scope.gridOptions2.fastWatch = true;
  5287. $scope.gridOptions2.useExternalFiltering = true;
  5288. $scope.gridOptions2.useExternalPagination = true;
  5289. $scope.gridOptions2.paginationPageSizes = [10];
  5290. $scope.gridOptions2.paginationPageSize = 10;
  5291. $scope.gridOptions2.multiSelect = false;
  5292. // $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>";
  5293. $scope.modelcons = {};
  5294. $scope.modelass = {};
  5295. $scope.myData2all = [];
  5296. $scope.myData1all = [];
  5297. $scope.memoryfilterDatagui = {
  5298. idx: 0,
  5299. sum: 10,
  5300. };
  5301. setInterval(function () {
  5302. if ($scope.model.assets) {
  5303. if (
  5304. $scope.model.assets != $scope.modelass &&
  5305. typeof $scope.model.assets == "string"
  5306. ) {
  5307. $scope.modelass = $scope.model.assets;
  5308. if (JSON.stringify($scope.model.assets) == "{}") {
  5309. $scope.model.assets = [];
  5310. } else {
  5311. $scope.model.assets = JSON.parse($scope.model.assets);
  5312. }
  5313. // $scope.myData1 = $scope.model.assets;
  5314. // for (var i = 0; i < $scope.myData1.length; i++) {
  5315. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5316. // }
  5317. $scope.myData1all = $scope.model.assets;
  5318. for (var i = 0; i < $scope.myData1all.length; i++) {
  5319. $scope.myData1all[i]["item"] =
  5320. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5321. }
  5322. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5323. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5324. }
  5325. }
  5326. if ($scope.model.consumables) {
  5327. if (
  5328. $scope.model.consumables != $scope.modelcons &&
  5329. typeof $scope.model.consumables == "string"
  5330. ) {
  5331. $scope.modelass = $scope.model.consumables;
  5332. if (JSON.stringify($scope.model.consumables) == "{}") {
  5333. $scope.model.consumables = [];
  5334. } else {
  5335. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5336. }
  5337. // $scope.myData2 = $scope.model.consumables;
  5338. // for (var i = 0; i < $scope.myData2.length; i++) {
  5339. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5340. // }
  5341. $scope.myData2all = $scope.model.consumables;
  5342. for (var i = 0; i < $scope.myData2all.length; i++) {
  5343. $scope.myData2all[i]["item"] =
  5344. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5345. }
  5346. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5347. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5348. // $scope.model.consumables = $scope.myData2all;
  5349. }
  5350. }
  5351. }, 100);
  5352. $scope.gridOptions2.columnDefs = [
  5353. {
  5354. name: "item",
  5355. displayName: "序号",
  5356. width: 120,
  5357. },
  5358. {
  5359. name: "name",
  5360. displayName: "耗材名称",
  5361. width: 180,
  5362. enableFiltering: false,
  5363. },
  5364. {
  5365. name: "model",
  5366. displayName: "品牌/型号",
  5367. width: 180,
  5368. enableFiltering: false,
  5369. },
  5370. {
  5371. name: "Specifications",
  5372. displayName: "规格",
  5373. width: 150,
  5374. enableFiltering: false,
  5375. },
  5376. {
  5377. name: "sum",
  5378. width: 150,
  5379. displayName: "数量",
  5380. enableFiltering: false,
  5381. },
  5382. {
  5383. name: "操作",
  5384. cellTemplate:
  5385. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5386. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5387. "</div></div>",
  5388. enableFiltering: false,
  5389. },
  5390. ];
  5391. // $scope.selectButtonClick
  5392. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5393. $scope.gridApi = gridApi;
  5394. gridApi.pagination.on.paginationChanged(
  5395. $scope,
  5396. function (newPage, pageSize) {
  5397. // var filtersData = $scope.memoryfilterDatagui;
  5398. // filtersData.idx = newPage - 1;
  5399. // filtersData.sum = pageSize;
  5400. $scope.memoryfilterDatagui.idx = newPage - 1;
  5401. $scope.memoryfilterDatagui.sum = pageSize;
  5402. $scope.myData2 = $scope.interceptMydata(
  5403. $scope.myData2all,
  5404. $scope.memoryfilterDatagui.idx,
  5405. 10
  5406. );
  5407. }
  5408. );
  5409. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5410. $scope.selected.items = data.entity;
  5411. //console.log(data);
  5412. });
  5413. gridApi.selection.on.rowSelectionChangedBatch(
  5414. $scope,
  5415. function (data) {
  5416. $scope.selected.items = data.entity;
  5417. //console.log(data);
  5418. }
  5419. );
  5420. gridApi.core.on.filterChanged($scope, function () {
  5421. var grid = this.grid;
  5422. var filtersData = {
  5423. idx: 0,
  5424. sum: 10,
  5425. };
  5426. angular.forEach(grid.columns, function (item) {
  5427. if (item.enableFiltering) {
  5428. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5429. if (
  5430. angular.isDefined(item.filters[0].term) &&
  5431. item.filters[0].term != ""
  5432. ) {
  5433. if (angular.isUndefined(filtersData["user"])) {
  5434. filtersData["user"] = {};
  5435. }
  5436. filtersData["user"][item.field] = item.filters[0].term;
  5437. }
  5438. }
  5439. });
  5440. $scope.memoryfilterData = filtersData;
  5441. $scope.loadData(filtersData);
  5442. });
  5443. };
  5444. $scope.changecai = function (item) {
  5445. event.preventDefault();
  5446. var modalInstance = $modal.open({
  5447. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5448. controller: function ($scope, $modalInstance) {
  5449. $scope.title = "修改耗材数量";
  5450. $scope.consumptive = angular.copy(item);
  5451. // $scope.consumptive = item;
  5452. $scope.maxsum = item.inventoryNum;
  5453. $scope.clearNoNum = function (obj, attr) {
  5454. //先把非数字的都替换掉,除了数字和.
  5455. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5456. //必须保证第一个为数字而不是.
  5457. obj[attr] = obj[attr].replace(/^\./g, "");
  5458. //保证只有出现一个.而没有多个.
  5459. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5460. //保证.只出现一次,而不能出现两次以上
  5461. obj[attr] = obj[attr]
  5462. .replace(".", "$#$")
  5463. .replace(/\./g, "")
  5464. .replace("$#$", ".");
  5465. //小于最大值
  5466. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5467. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5468. // obj[attr] = '';
  5469. // }
  5470. };
  5471. $scope.ok = function () {
  5472. $modalInstance.close($scope.consumptive);
  5473. };
  5474. $scope.cancel = function () {
  5475. $modalInstance.dismiss("cancel");
  5476. };
  5477. },
  5478. size: "sm",
  5479. });
  5480. modalInstance.result.then(function (selectedItem) {
  5481. angular.forEach($scope.myData2all, function (items, index) {
  5482. // if (items.id == selectedItem.id) {
  5483. if (
  5484. items.modelid == selectedItem.modelid &&
  5485. items.nameid == selectedItem.nameid &&
  5486. items.Specificationsid == selectedItem.Specificationsid
  5487. ) {
  5488. angular.extend($scope.myData2all[index], selectedItem);
  5489. }
  5490. });
  5491. // $scope.model.consumables = $scope.myData2;
  5492. // $scope.myData2 = $scope.model.consumables;
  5493. // $scope.myData2all.push(selectedItem);
  5494. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5495. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5496. // }
  5497. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5498. $scope.myData2 = $scope.interceptMydata(
  5499. $scope.myData2all,
  5500. $scope.memoryfilterDatagui.idx,
  5501. 10
  5502. );
  5503. $scope.model.consumables = $scope.myData2all;
  5504. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5505. $scope.model.consumables;
  5506. });
  5507. };
  5508. $scope.interceptMydata = function (mydate, idx, sum) {
  5509. return mydate.slice(idx * sum, (idx + 1) * sum);
  5510. };
  5511. $scope.haocaiadd = function () {
  5512. event.preventDefault();
  5513. var modalInstance = $modal.open({
  5514. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5515. controller: function (
  5516. $scope,
  5517. scope,
  5518. $modalInstance,
  5519. api_wechatfile,
  5520. SweetAlert
  5521. ) {
  5522. $scope.haocainame = [];
  5523. $scope.pinpai = [];
  5524. $scope.guige = [];
  5525. $scope.consumptive = {};
  5526. $scope.consumptiveall = {};
  5527. $scope.title = "添加耗材";
  5528. api_wechatfile
  5529. .getDictionaryForList({
  5530. key: "haocaifenlei",
  5531. })
  5532. .then(function (data) {
  5533. $scope.haocainame = data;
  5534. });
  5535. $scope.clearNoNum = function (obj, attr) {
  5536. //先把非数字的都替换掉,除了数字和.
  5537. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5538. //必须保证第一个为数字而不是.
  5539. obj[attr] = obj[attr].replace(/^\./g, "");
  5540. //保证只有出现一个.而没有多个.
  5541. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5542. //保证.只出现一次,而不能出现两次以上
  5543. obj[attr] = obj[attr]
  5544. .replace(".", "$#$")
  5545. .replace(/\./g, "")
  5546. .replace("$#$", ".");
  5547. //小于最大值
  5548. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5549. alert(
  5550. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5551. );
  5552. obj[attr] = "";
  5553. }
  5554. };
  5555. $scope.onChange = function (parent) {
  5556. $scope.consumptive.model = {};
  5557. $scope.consumptive.Specifications = {};
  5558. api_wechatfile
  5559. .getDictionaryForList({
  5560. key: "pinpai",
  5561. parent: parent.id,
  5562. })
  5563. .then(function (data) {
  5564. $scope.pinpai = data;
  5565. });
  5566. api_wechatfile
  5567. .getDictionaryForList({
  5568. key: "guige",
  5569. parent: parent.id,
  5570. })
  5571. .then(function (data) {
  5572. $scope.guige = data;
  5573. });
  5574. };
  5575. // $scope.onChangesum = function(item) {
  5576. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5577. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5578. // $scope.consumptiveall = data1;
  5579. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5580. // // if (data.list && data.list.length != 0) {
  5581. // // var myData = data.list;
  5582. // // $scope.consumptiveall = myData[0];
  5583. // // $scope.maxsum = myData[0].inventoryNum;
  5584. // // } else if (data.list && data.list.length == 0) {
  5585. // // SweetAlert.swal({
  5586. // // title: "库存数据存在问题!",
  5587. // // text: "请检查库存数据!",
  5588. // // type: "error"
  5589. // // });
  5590. // // }
  5591. // // });
  5592. // }
  5593. // }
  5594. $scope.addhaocai = function () {
  5595. $modalInstance.dismiss("cancel");
  5596. scope.haocaiopen($scope.consumptive);
  5597. };
  5598. $scope.ok = function (item) {
  5599. var submittrue = true;
  5600. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5601. var data = {
  5602. modelid: item.model.id,
  5603. nameid: item.name.id,
  5604. Specificationsid: item.Specifications.id,
  5605. name: item.name.name,
  5606. model: item.model.name,
  5607. Specifications: item.Specifications.name,
  5608. sum: item.sum,
  5609. };
  5610. if (
  5611. item.name &&
  5612. item.model &&
  5613. JSON.stringify(item.model) != "{}" &&
  5614. item.Specifications &&
  5615. JSON.stringify(item.Specifications) != "{}" &&
  5616. item.sum
  5617. ) {
  5618. // $modalInstance.close(data);
  5619. angular.forEach(scope.myData2all, function (itemsdata) {
  5620. // if (item.model.id == itemsdata.id) {
  5621. if (
  5622. item.model.id == itemsdata.modelid &&
  5623. item.name.id == itemsdata.nameid &&
  5624. item.Specifications.id == itemsdata.Specificationsid
  5625. ) {
  5626. submittrue = false;
  5627. }
  5628. });
  5629. if (submittrue) {
  5630. $modalInstance.close(data);
  5631. } else {
  5632. SweetAlert.swal({
  5633. title: "该耗材已有添加",
  5634. text: "请检查数据然后提交!",
  5635. type: "error",
  5636. });
  5637. }
  5638. } else {
  5639. SweetAlert.swal({
  5640. title: "数据填写不完整!",
  5641. text: "请检查数据然后提交!",
  5642. type: "error",
  5643. });
  5644. }
  5645. };
  5646. $scope.cancel = function () {
  5647. $modalInstance.dismiss("cancel");
  5648. };
  5649. },
  5650. size: "sm",
  5651. resolve: {
  5652. scope: function () {
  5653. return $scope;
  5654. },
  5655. },
  5656. });
  5657. modalInstance.result.then(function (selectedItem) {
  5658. // $scope.myData2.push(selectedItem);
  5659. // for (var i = 0; i < $scope.myData2.length; i++) {
  5660. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5661. // }
  5662. // $scope.model.consumables = $scope.myData2;
  5663. $scope.myData2all.push(selectedItem);
  5664. for (var i = 0; i < $scope.myData2all.length; i++) {
  5665. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5666. $scope.myData2all[i]["item"] = i + 1;
  5667. }
  5668. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5669. $scope.myData2 = $scope.interceptMydata(
  5670. $scope.myData2all,
  5671. $scope.memoryfilterDatagui.idx,
  5672. 10
  5673. );
  5674. $scope.model.consumables = $scope.myData2all;
  5675. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5676. $scope.model.consumables;
  5677. });
  5678. };
  5679. $scope.onDblClick = function (data, event) {
  5680. $scope.selectButtonClick(data, event);
  5681. };
  5682. $scope.memoryfilterData = {
  5683. idx: 0,
  5684. sum: 20,
  5685. user: {
  5686. roledata: {
  5687. rolecode: "roleset",
  5688. },
  5689. selectType: "1",
  5690. },
  5691. };
  5692. $scope.myData = {};
  5693. $scope.loadData = function (filterData) { };
  5694. // $scope.title = title;
  5695. $scope.loadData({
  5696. idx: 0,
  5697. sum: 20,
  5698. user: {
  5699. roledata: {
  5700. rolecode: "roleset",
  5701. },
  5702. selectType: "1",
  5703. },
  5704. });
  5705. $scope.selected = {
  5706. items: {},
  5707. };
  5708. },
  5709. ],
  5710. });
  5711. //tab 列表
  5712. formlyConfigProvider.setType({
  5713. name: "ui-cmdbtab",
  5714. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5715. wrapper: ["bootstrapHasError"],
  5716. defaultOptions: function (options, $scope) {
  5717. return {
  5718. templateOptions: {},
  5719. };
  5720. },
  5721. controller: [
  5722. "$scope",
  5723. "api_user_data",
  5724. "i18nService",
  5725. "$modal",
  5726. "api_cmdb",
  5727. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5728. $scope.memoryfilterDatashe = {
  5729. idx: 0,
  5730. sum: 10,
  5731. };
  5732. $scope.myDataoneall = [];
  5733. var setAllInactive = function () {
  5734. angular.forEach($scope.workspaces, function (workspace) {
  5735. workspace.active = false;
  5736. });
  5737. };
  5738. //添加
  5739. var addNewWorkspace = function (name, contentUrl) {
  5740. var id = $scope.workspaces.length + 1;
  5741. $scope.workspaces.push({
  5742. id: id,
  5743. name: name,
  5744. active: true,
  5745. contentUrl: "main/html/content.html",
  5746. });
  5747. };
  5748. //关闭
  5749. $scope.remove = function (closedata) {
  5750. event.preventDefault();
  5751. angular.forEach($scope.workspaces, function (item, index) {
  5752. if (closedata.id == item.id) {
  5753. if (closedata.id == 1) {
  5754. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5755. } else {
  5756. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5757. }
  5758. $scope.workspaces.splice(index, 1);
  5759. }
  5760. });
  5761. };
  5762. $scope.workspaces = [];
  5763. $scope.options.templateOptions.getpush = function (item) {
  5764. $scope.workspaces = [];
  5765. if (item.gu) {
  5766. $scope.workspaces.push({
  5767. id: 1,
  5768. name: "领用设备",
  5769. active: true,
  5770. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5771. });
  5772. }
  5773. if (item.hao) {
  5774. $scope.workspaces.push({
  5775. id: 2,
  5776. name: "领用耗材",
  5777. active: true,
  5778. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5779. });
  5780. }
  5781. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5782. };
  5783. $scope.addWorkspace = function (contentUrl, name) {
  5784. setAllInactive();
  5785. addNewWorkspace(name, contentUrl);
  5786. };
  5787. // $rootScope.addWorkspace = $scope.addWorkspace;
  5788. // $scope.remove = function(idNumber) {
  5789. // var index = 0; //记录当前元素下标
  5790. // angular.forEach($scope.workspaces, function(workspace) {
  5791. // if (workspace.id === idNumber.id) {
  5792. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5793. // }
  5794. // index++;
  5795. // });
  5796. // };
  5797. // setInterval(function() {
  5798. // if ($scope.model.assets) {
  5799. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5800. // $scope.modelass = $scope.model.assets;
  5801. // if (JSON.stringify($scope.model.assets) == "{}") {
  5802. // $scope.model.assets = []
  5803. // } else {
  5804. // $scope.model.assets = JSON.parse($scope.model.assets);
  5805. // }
  5806. // $scope.myDatalingbeiall = $scope.model.assets;
  5807. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5808. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5809. // }
  5810. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5811. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5812. // }
  5813. // }
  5814. // if ($scope.model.consumables) {
  5815. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5816. // $scope.modelass = $scope.model.consumables;
  5817. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5818. // $scope.model.consumables = [];
  5819. // } else {
  5820. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5821. // }
  5822. // $scope.myDatalingbeiall = $scope.model.consumables;
  5823. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5824. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5825. // }
  5826. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5827. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5828. // // $scope.model.consumables = $scope.myData2all;
  5829. // }
  5830. // }
  5831. // }, 100);
  5832. //grid1
  5833. $scope.langs = i18nService.getAllLangs();
  5834. $scope.lang = "zh-cn";
  5835. i18nService.setCurrentLang($scope.lang);
  5836. $scope.gridOptions1 = {};
  5837. $scope.gridOptions1.data = "myDatalingbei";
  5838. $scope.gridOptions1.enableColumnResizing = true;
  5839. $scope.gridOptions1.enableFiltering = false;
  5840. $scope.gridOptions1.enableGridMenu = false;
  5841. $scope.gridOptions1.showGridFooter = true;
  5842. $scope.gridOptions1.showColumnFooter = false;
  5843. $scope.gridOptions1.fastWatch = true;
  5844. $scope.gridOptions1.useExternalFiltering = true;
  5845. $scope.gridOptions1.useExternalPagination = true;
  5846. $scope.gridOptions1.paginationPageSizes = [10];
  5847. $scope.gridOptions1.paginationPageSize = 10;
  5848. $scope.gridOptions1.multiSelect = false;
  5849. // $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>";
  5850. $scope.gridOptions1.columnDefs = [
  5851. {
  5852. name: "item",
  5853. displayName: "序号",
  5854. width: 120,
  5855. },
  5856. {
  5857. name: "props.hw_cifilterClassic",
  5858. displayName: "设备类型",
  5859. width: 150,
  5860. enableFiltering: false,
  5861. },
  5862. {
  5863. name: "props.hw_mingcheng",
  5864. displayName: "设备名称",
  5865. width: 100,
  5866. enableFiltering: false,
  5867. },
  5868. {
  5869. name: "uuid",
  5870. displayName: "设备编号",
  5871. enableFiltering: false,
  5872. },
  5873. ];
  5874. $scope.myDatalingbeiall = [];
  5875. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5876. $scope.gridApi = gridApi;
  5877. gridApi.pagination.on.paginationChanged(
  5878. $scope,
  5879. function (newPage, pageSize) {
  5880. // var filtersData = $scope.memoryfilterData;
  5881. // filtersData.idx = newPage - 1;
  5882. // filtersData.sum = pageSize;
  5883. // $scope.loadData(filtersData);
  5884. $scope.memoryfilterDatashe.idx = newPage - 1;
  5885. $scope.memoryfilterDatashe.sum = pageSize;
  5886. $scope.myDatalingbei = $scope.interceptMydata(
  5887. $scope.myDatalingbeiall,
  5888. $scope.memoryfilterDatashe.idx,
  5889. 10
  5890. );
  5891. }
  5892. );
  5893. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5894. $scope.selected.items = data.entity;
  5895. //console.log(data);
  5896. });
  5897. gridApi.selection.on.rowSelectionChangedBatch(
  5898. $scope,
  5899. function (data) {
  5900. $scope.selected.items = data.entity;
  5901. //console.log(data);
  5902. }
  5903. );
  5904. gridApi.core.on.filterChanged($scope, function () {
  5905. var grid = this.grid;
  5906. var filtersData = {
  5907. idx: 0,
  5908. sum: 20,
  5909. user: {
  5910. roledata: {
  5911. rolecode: "roleset",
  5912. },
  5913. selectType: "1",
  5914. },
  5915. };
  5916. angular.forEach(grid.columns, function (item) {
  5917. if (item.enableFiltering) {
  5918. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5919. if (
  5920. angular.isDefined(item.filters[0].term) &&
  5921. item.filters[0].term != ""
  5922. ) {
  5923. if (angular.isUndefined(filtersData["user"])) {
  5924. filtersData["user"] = {};
  5925. }
  5926. filtersData["user"][item.field] = item.filters[0].term;
  5927. }
  5928. }
  5929. });
  5930. $scope.memoryfilterDatashe = filtersData;
  5931. // $scope.loadData(filtersData);
  5932. });
  5933. };
  5934. $scope.interceptMydata = function (mydate, idx, sum) {
  5935. return mydate.slice(idx * sum, (idx + 1) * sum);
  5936. };
  5937. $scope.removeshebei = function (item) {
  5938. event.preventDefault();
  5939. var modalInstance = $modal.open({
  5940. templateUrl: "assets/views/delete.html",
  5941. controller: function ($scope, $modalInstance, scope) {
  5942. $scope.title = "设备移除";
  5943. $scope.connect = "确定要移除此设备?";
  5944. $scope.consumptive = scope.selected.items;
  5945. $scope.ok = function () {
  5946. $modalInstance.close($scope.consumptive);
  5947. };
  5948. $scope.cancel = function () {
  5949. $modalInstance.dismiss("cancel");
  5950. };
  5951. },
  5952. size: "sm",
  5953. resolve: {
  5954. scope: function () {
  5955. return $scope;
  5956. },
  5957. },
  5958. });
  5959. modalInstance.result.then(function (selectedItem) {
  5960. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5961. if (items.id == selectedItem.id) {
  5962. $scope.myDatalingbeiall.splice(index, 1);
  5963. }
  5964. });
  5965. // $scope.myData3.push(selectedItem);
  5966. $scope.model.consumables = $scope.myDatalingbeiall;
  5967. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5968. $scope.myDatalingbeiall;
  5969. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5970. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5971. $scope.myDatalingbeiall[i]["item"] =
  5972. i +
  5973. 1 +
  5974. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5975. }
  5976. $scope.myDatalingbei = $scope.interceptMydata(
  5977. $scope.myDatalingbeiall,
  5978. 0,
  5979. 10
  5980. );
  5981. });
  5982. };
  5983. $scope.addshebei = function () {
  5984. event.preventDefault();
  5985. var modalInstance = $modal.open({
  5986. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5987. controller: function (
  5988. $scope,
  5989. i18nService,
  5990. $modalInstance,
  5991. items,
  5992. title,
  5993. Restangular,
  5994. APIService,
  5995. onDataCallback,
  5996. parentScope,
  5997. api_configure_data,
  5998. api_configure_form
  5999. ) {
  6000. $scope.langs = i18nService.getAllLangs();
  6001. $scope.lang = "zh-cn";
  6002. i18nService.setCurrentLang($scope.lang);
  6003. $scope.gridOptions = {};
  6004. $scope.gridOptions.data = "myDatatwo";
  6005. $scope.gridOptions.enableColumnResizing = true;
  6006. $scope.gridOptions.enableFiltering = false;
  6007. $scope.gridOptions.enableGridMenu = false;
  6008. $scope.gridOptions.showGridFooter = true;
  6009. $scope.gridOptions.showColumnFooter = false;
  6010. $scope.gridOptions.fastWatch = true;
  6011. $scope.gridOptions.useExternalFiltering = true;
  6012. $scope.gridOptions.useExternalPagination = true;
  6013. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  6014. $scope.gridOptions.paginationPageSize = 10;
  6015. $scope.gridOptions.multiSelect = true;
  6016. $scope.gridOptions.rowIdentity = function (row) {
  6017. return row.id;
  6018. };
  6019. $scope.gridOptions.getRowIdentity = function (row) {
  6020. return row.id;
  6021. };
  6022. // $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>";
  6023. $scope.gridOptions.columnDefs = [
  6024. {
  6025. name: "item",
  6026. displayName: "序号",
  6027. width: 80,
  6028. enableFiltering: false,
  6029. },
  6030. {
  6031. name: "uuid",
  6032. displayName: "内部编号",
  6033. width: 175,
  6034. },
  6035. {
  6036. name: "props.hw_mingcheng",
  6037. displayName: "资产名称",
  6038. width: 120,
  6039. },
  6040. {
  6041. name: "props.hw_cifilterClassic",
  6042. displayName: "资产类型",
  6043. width: 80,
  6044. enableFiltering: false,
  6045. },
  6046. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6047. {
  6048. name: "props.hw_state",
  6049. displayName: "资产状态",
  6050. width: 150,
  6051. enableFiltering: false,
  6052. },
  6053. {
  6054. name: "props.hwnw_area",
  6055. displayName: "资产地点",
  6056. width: 130,
  6057. enableFiltering: false,
  6058. },
  6059. {
  6060. name: "createtime",
  6061. displayName: "申请时间",
  6062. enableFiltering: false,
  6063. },
  6064. ];
  6065. // $scope.selectButtonClick
  6066. var defaultFilterData = {
  6067. // "assignee":2,
  6068. // "sign":"basehwitndl",
  6069. // "applicationForm": { "hw_state": "在线" },
  6070. hw_state: "在库",
  6071. idx: 0,
  6072. sum: 10,
  6073. };
  6074. $scope.memoryfilterData = {
  6075. // "assignee":2,
  6076. // "sign":"basehwitndl",
  6077. // "applicationForm": { "hw_state": "在线" },
  6078. hw_state: "在库",
  6079. idx: 0,
  6080. sum: 10,
  6081. };
  6082. $scope.refreshData = function (style, filterData) {
  6083. if (angular.isUndefined(filterData)) {
  6084. filterData = defaultFilterData;
  6085. }
  6086. $scope.myDatatwo = [];
  6087. // $scope.gridOptions['sum']=filterData.sum;
  6088. api_cmdb.query(filterData).then(
  6089. function (data) {
  6090. // $scope.callsPending--;
  6091. var filterData = $scope.memoryfilterData;
  6092. var myDatatwo = Restangular.stripRestangular(data);
  6093. $scope.gridOptions["totalItems"] = data.total;
  6094. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6095. myDatatwo.data.node[i].createtime = moment(
  6096. myDatatwo.data.node[i].createtime
  6097. ).format("YYYY-MM-DD");
  6098. }
  6099. $scope.myDatatwo = myDatatwo.data.node;
  6100. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6101. $scope.myDatatwo[i]["item"] =
  6102. i + 1 + filterData.idx * filterData.sum;
  6103. }
  6104. },
  6105. function () { }
  6106. );
  6107. };
  6108. $scope.refreshData("expand-right", defaultFilterData);
  6109. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6110. $scope.gridApi = gridApi;
  6111. gridApi.pagination.on.paginationChanged(
  6112. $scope,
  6113. function (newPage, pageSize) {
  6114. var filtersData = $scope.memoryfilterData;
  6115. filtersData.idx = newPage - 1;
  6116. filtersData.sum = pageSize;
  6117. // $scope.loadData(filtersData);
  6118. $scope.refreshData("expand-right", filtersData);
  6119. //console.log(pageSize);
  6120. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6121. }
  6122. );
  6123. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6124. // $scope.selected.items.push(data.entity);
  6125. //console.log(data);
  6126. gridApi.selection.on.rowSelectionChanged(
  6127. $scope,
  6128. function (scope, ect) {
  6129. if (scope.isSelected) {
  6130. scope.grid.appScope.selected.items.push(scope.entity);
  6131. } else {
  6132. for (
  6133. var i = 0;
  6134. i <= scope.grid.appScope.selected.items.length;
  6135. i++
  6136. ) {
  6137. if (
  6138. scope.grid.appScope.selected.items[i].id ==
  6139. scope.entity.id
  6140. ) {
  6141. scope.grid.appScope.selected.items.splice(i, 1);
  6142. break;
  6143. }
  6144. }
  6145. }
  6146. $scope.mySelectedRows =
  6147. $scope.gridApi.selection.getSelectedRows();
  6148. }
  6149. );
  6150. // });
  6151. gridApi.selection.on.rowSelectionChangedBatch(
  6152. $scope,
  6153. function (rows) {
  6154. // $scope.selected.items = data.entity;
  6155. //console.log(data);
  6156. var selectitem = [];
  6157. selectitem = angular.copy($scope.selected.items);
  6158. for (var j = 0; j < rows.length; j++) {
  6159. if (rows[j].isSelected == true) {
  6160. selectitem.push(rows[j].entity);
  6161. } else {
  6162. delete selectitem[j];
  6163. // rows.splice(j, 1);
  6164. }
  6165. }
  6166. $scope.selected.items = [];
  6167. for (var i = 0; i < selectitem.length; i++) {
  6168. if (selectitem[i]) {
  6169. $scope.selected.items.push(selectitem[i]);
  6170. }
  6171. }
  6172. }
  6173. );
  6174. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6175. // // if (row.entity.age > 45) {
  6176. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6177. // // }
  6178. // };
  6179. gridApi.core.on.filterChanged($scope, function () {
  6180. var grid = this.grid;
  6181. var filtersData = {
  6182. idx: 0,
  6183. sum: 10,
  6184. user: {
  6185. roledata: {
  6186. rolecode: "roleset",
  6187. },
  6188. selectType: "1",
  6189. },
  6190. };
  6191. angular.forEach(grid.columns, function (item) {
  6192. if (item.enableFiltering) {
  6193. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6194. if (
  6195. angular.isDefined(item.filters[0].term) &&
  6196. item.filters[0].term != ""
  6197. ) {
  6198. if (angular.isUndefined(filtersData["user"])) {
  6199. filtersData["user"] = {};
  6200. }
  6201. filtersData["user"][item.field] = item.filters[0].term;
  6202. }
  6203. }
  6204. });
  6205. $scope.memoryfilterData = filtersData;
  6206. // $scope.loadData(filtersData);
  6207. });
  6208. };
  6209. $scope.onDblClick = function (data, event) {
  6210. // $scope.selected.items = data.entity;
  6211. $scope.selectButtonClick(data, event);
  6212. };
  6213. // $scope.loadData = function(filterData) {
  6214. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6215. // items.fetchItems(filterData, APIService).then(function(data) {
  6216. // var myDatatwo = Restangular.stripRestangular(data);
  6217. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6218. // $scope.myDatatwo = myDatatwo.list;
  6219. // });
  6220. // };
  6221. $scope.title = title;
  6222. //树形图
  6223. var apple_selected, tree, treedata_avm, treedata_geography;
  6224. $scope.my_tree_handler = function (branch) {
  6225. //var _ref;
  6226. var classify = ($scope.classify =
  6227. branch.prefix.toLowerCase() + branch.sign);
  6228. api_cmdb
  6229. .query({
  6230. sign: classify,
  6231. })
  6232. .then(function (data) {
  6233. var myDatalingbei = Restangular.stripRestangular(data);
  6234. // console.log(myData.data.node);
  6235. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6236. var ret = myDatalingbei.data;
  6237. redrawSvg(myDatalingbei);
  6238. }
  6239. });
  6240. };
  6241. $scope.my_data = [];
  6242. function convertListToTree(data, treeMap) {
  6243. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6244. var root = null; //Initially set our loop to null
  6245. var parentNode = null;
  6246. //loop over data
  6247. for (var i = 0; i < data.length; i++) {
  6248. var datum = data[i];
  6249. //each node will have children, so let's give it a "children" poperty
  6250. datum.children = [];
  6251. //add an entry for this node to the map so that any future children can
  6252. //lookup the parent
  6253. idToNodeMap[datum.id] = datum;
  6254. //Does this node have a parent?
  6255. if (
  6256. typeof datum.parent === "undefined" ||
  6257. datum.parent == null
  6258. ) {
  6259. //Doesn't look like it, so this node is the root of the tree
  6260. root = datum;
  6261. treeMap[datum.id] = root;
  6262. } else {
  6263. //This node has a parent, so let's look it up using the id
  6264. parentNode = idToNodeMap[datum.parent.id];
  6265. //We don't need this property, so let's delete it.
  6266. delete datum.parent;
  6267. //Let's add the current node as a child of the parent node.
  6268. parentNode.children.push(datum);
  6269. }
  6270. }
  6271. return root;
  6272. }
  6273. function convertParentToChildList(data) {
  6274. var treeMap = {};
  6275. var list = [];
  6276. convertListToTree(data, treeMap);
  6277. angular.forEach(treeMap, function (item) {
  6278. list.push(item);
  6279. });
  6280. return list;
  6281. }
  6282. $scope.my_tree = tree = {};
  6283. $scope.try_async_load = function () {
  6284. $scope.my_data = [];
  6285. $scope.select_treedata = [];
  6286. $scope.doing_async = true;
  6287. api_configure_data
  6288. .fetchDataList("ciclassify", {
  6289. idx: 0,
  6290. sum: 100,
  6291. })
  6292. .then(function (result) {
  6293. //console.log(result['list']);
  6294. $scope.select_treedata = $scope.my_data =
  6295. convertParentToChildList(result["list"]);
  6296. $scope.doing_async = false;
  6297. // tree.expand_all();
  6298. //console.log(treelist);
  6299. });
  6300. };
  6301. $scope.select_treedata = [];
  6302. $scope.propTypeOptions = [];
  6303. $scope.try_async_load();
  6304. $scope.onFilterremove = function (item) {
  6305. console.log(item);
  6306. };
  6307. $scope.searchdata = {};
  6308. $scope.clear = function () {
  6309. $scope.searchdata = {};
  6310. $scope.cifilter_classic = {};
  6311. $scope.try_async_load();
  6312. var fildata = {
  6313. idx: 0,
  6314. sum: 10,
  6315. hw_state: "在库",
  6316. };
  6317. $scope.memoryfilterData = fildata;
  6318. $scope.refreshData("expand-right", fildata);
  6319. };
  6320. $scope.cifilter_classic = {};
  6321. $scope.chiceIncident = function (item) {
  6322. var fildata = defaultFilterData;
  6323. // fildata.applicationForm = {};
  6324. // sign: basehwnwswt
  6325. if (item && item.id) {
  6326. var classify = item.prefix.toLowerCase() + item.sign;
  6327. fildata.sign = classify;
  6328. } else {
  6329. delete fildata.sign;
  6330. }
  6331. $scope.gridOptions.paginationCurrentPage = 1;
  6332. var transitiondata = angular.copy(item);
  6333. $scope.refreshData("expand-right", fildata);
  6334. };
  6335. $scope.applicadata = [];
  6336. $scope.onFilterCallback = function (item) {
  6337. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6338. api_configure_form
  6339. .renderTabForm(tempclassify)
  6340. .then(function (data) {
  6341. var myData = Restangular.stripRestangular(data);
  6342. $scope.applicadata = myData[0].form.fields;
  6343. });
  6344. // }
  6345. };
  6346. // $scope.loadData({
  6347. // idx: 0,
  6348. // sum: 10,
  6349. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6350. // });
  6351. $scope.selected = {
  6352. items: [],
  6353. };
  6354. $scope.ok = function () {
  6355. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6356. // onDataCallback($scope.selected.item, parentScope);
  6357. // }
  6358. $modalInstance.close($scope.selected.items);
  6359. };
  6360. $scope.cancel = function () {
  6361. $modalInstance.dismiss("cancel");
  6362. };
  6363. },
  6364. size: "lg",
  6365. resolve: {
  6366. items: function () {
  6367. return {
  6368. fetchItems: function (filterData, APIService) {
  6369. filterData = filterData || {};
  6370. if (
  6371. angular.isDefined(filterData.idx) &&
  6372. filterData.idx == null
  6373. ) {
  6374. filterData = {
  6375. idx: 0,
  6376. sum: 10,
  6377. user: {
  6378. roledata: {
  6379. rolecode: "roleset",
  6380. },
  6381. selectType: "1",
  6382. },
  6383. };
  6384. }
  6385. return $scope.options.templateOptions.fetchItems(
  6386. filterData,
  6387. APIService
  6388. );
  6389. },
  6390. };
  6391. },
  6392. title: function () {
  6393. return $scope.options.templateOptions.label;
  6394. },
  6395. Restangular: function () {
  6396. return $scope.options.templateOptions.Restangular;
  6397. },
  6398. APIService: function () {
  6399. return $scope.options.templateOptions.ApiService;
  6400. },
  6401. onDataCallback: function () {
  6402. return $scope.options.templateOptions.callback;
  6403. },
  6404. parentScope: function () {
  6405. return $scope.options.templateOptions.that;
  6406. },
  6407. },
  6408. });
  6409. modalInstance.result.then(
  6410. function (selectedItem) {
  6411. // console.log(selectedItem);
  6412. // options.value(selectedItem);
  6413. var filterData = $scope.memoryfilterDatashe;
  6414. $scope.myDatalingbeiall = selectedItem;
  6415. $scope.gridOptions1["totalItems"] =
  6416. $scope.myDatalingbeiall.length;
  6417. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6418. $scope.myDatalingbeiall[i]["item"] =
  6419. i + 1 + filterData.idx * filterData.sum;
  6420. }
  6421. $scope.myDatalingbei = $scope.interceptMydata(
  6422. $scope.myDatalingbeiall,
  6423. 0,
  6424. 10
  6425. );
  6426. $scope.model.assets = $scope.myDatalingbeiall;
  6427. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6428. $scope.myDatalingbeiall;
  6429. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6430. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6431. // }
  6432. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6433. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6434. // }
  6435. },
  6436. function () {
  6437. //console.log('Modal dismissed at: ' + new Date());
  6438. }
  6439. );
  6440. };
  6441. $scope.onDblClick = function (data, event) {
  6442. $scope.selectButtonClick(data, event);
  6443. };
  6444. // $scope.loadData = function(filterData) {};
  6445. // $scope.title = title;
  6446. // $scope.loadData({
  6447. // idx: 0,
  6448. // sum: 20,
  6449. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6450. // });
  6451. $scope.selected = {
  6452. items: [],
  6453. };
  6454. //grid2
  6455. $scope.langs = i18nService.getAllLangs();
  6456. $scope.lang = "zh-cn";
  6457. i18nService.setCurrentLang($scope.lang);
  6458. $scope.gridOptions2 = {};
  6459. $scope.gridOptions2.data = "myDataone";
  6460. $scope.gridOptions2.enableColumnResizing = true;
  6461. $scope.gridOptions2.enableFiltering = false;
  6462. $scope.gridOptions2.enableGridMenu = false;
  6463. $scope.gridOptions2.showGridFooter = true;
  6464. $scope.gridOptions2.showColumnFooter = false;
  6465. $scope.gridOptions2.fastWatch = true;
  6466. $scope.gridOptions2.useExternalFiltering = true;
  6467. $scope.gridOptions2.useExternalPagination = true;
  6468. $scope.gridOptions2.paginationPageSizes = [10];
  6469. $scope.gridOptions2.paginationPageSize = 10;
  6470. $scope.gridOptions2.multiSelect = false;
  6471. // $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>";
  6472. $scope.gridOptions2.columnDefs = [
  6473. {
  6474. name: "item",
  6475. displayName: "序号",
  6476. width: 120,
  6477. },
  6478. {
  6479. name: "name",
  6480. displayName: "耗材名称",
  6481. width: 150,
  6482. enableFiltering: false,
  6483. },
  6484. {
  6485. name: "model",
  6486. displayName: "品牌/型号",
  6487. width: 100,
  6488. enableFiltering: false,
  6489. },
  6490. {
  6491. name: "Specifications",
  6492. displayName: "规格",
  6493. width: 150,
  6494. enableFiltering: false,
  6495. },
  6496. {
  6497. name: "sum",
  6498. displayName: "领用数量",
  6499. enableFiltering: false,
  6500. },
  6501. ];
  6502. // $scope.selectButtonClick
  6503. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6504. $scope.gridApi = gridApi;
  6505. gridApi.pagination.on.paginationChanged(
  6506. $scope,
  6507. function (newPage, pageSize) {
  6508. // var filtersData = $scope.memoryfilterData;
  6509. // filtersData.idx = newPage - 1;
  6510. // filtersData.sum = pageSize;
  6511. // $scope.loadData(filtersData);
  6512. $scope.memoryfilterDatahao.idx = newPage - 1;
  6513. $scope.memoryfilterDatahao.sum = pageSize;
  6514. $scope.myDataone = $scope.interceptMydata(
  6515. $scope.myDataoneall,
  6516. $scope.memoryfilterDatahao.idx,
  6517. 10
  6518. );
  6519. }
  6520. );
  6521. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6522. $scope.selected.items.push(data.entity);
  6523. //console.log(data);
  6524. });
  6525. gridApi.selection.on.rowSelectionChangedBatch(
  6526. $scope,
  6527. function (data) {
  6528. $scope.selected.items.push(data.entity);
  6529. //console.log(data);
  6530. }
  6531. );
  6532. gridApi.core.on.filterChanged($scope, function () {
  6533. var grid = this.grid;
  6534. var filtersData = {
  6535. idx: 0,
  6536. sum: 10,
  6537. user: {
  6538. roledata: {
  6539. rolecode: "roleset",
  6540. },
  6541. selectType: "1",
  6542. },
  6543. };
  6544. angular.forEach(grid.columns, function (item) {
  6545. if (item.enableFiltering) {
  6546. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6547. if (
  6548. angular.isDefined(item.filters[0].term) &&
  6549. item.filters[0].term != ""
  6550. ) {
  6551. if (angular.isUndefined(filtersData["user"])) {
  6552. filtersData["user"] = {};
  6553. }
  6554. filtersData["user"][item.field] = item.filters[0].term;
  6555. }
  6556. }
  6557. });
  6558. $scope.memoryfilterDatahao = filtersData;
  6559. $scope.loadData(filtersData);
  6560. });
  6561. };
  6562. $scope.removehaocai = function (item) {
  6563. event.preventDefault();
  6564. // var modalInstance = $modal.open({
  6565. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6566. // controller: function($scope, $modalInstance) {
  6567. // $scope.title = "修改耗材数量";
  6568. // $scope.consumptive = item;
  6569. // $scope.ok = function() {
  6570. // $modalInstance.close($scope.consumptive);
  6571. // };
  6572. // $scope.cancel = function() {
  6573. // $modalInstance.dismiss('cancel');
  6574. // };
  6575. // },
  6576. // size: 'sm'
  6577. // });
  6578. var modalInstance = $modal.open({
  6579. templateUrl: "assets/views/delete.html",
  6580. controller: function ($scope, $modalInstance, scope) {
  6581. $scope.title = "耗材移除";
  6582. $scope.connect = "确定要移除此设备?";
  6583. $scope.consumptive = scope.selected.items[0];
  6584. $scope.ok = function () {
  6585. $modalInstance.close($scope.consumptive);
  6586. };
  6587. $scope.cancel = function () {
  6588. $modalInstance.dismiss("cancel");
  6589. };
  6590. },
  6591. size: "sm",
  6592. resolve: {
  6593. scope: function () {
  6594. return $scope;
  6595. },
  6596. },
  6597. });
  6598. modalInstance.result.then(function (selectedItem) {
  6599. // angular.forEach($scope.myData3, function(items, index) {
  6600. // if (items.id == selectedItem.id) {
  6601. // $scope.myData3[index] = selectedItem;
  6602. // }
  6603. // })
  6604. // $scope.model.applicationForm.consumables = $scope.myData3;
  6605. angular.forEach($scope.myDataoneall, function (items, index) {
  6606. if (items.id == selectedItem.id) {
  6607. $scope.myDataoneall.splice(index, 1);
  6608. }
  6609. });
  6610. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6611. $scope.myDataoneall[i]["item"] =
  6612. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6613. }
  6614. $scope.myDataone = $scope.interceptMydata(
  6615. $scope.myDataoneall,
  6616. 0,
  6617. 10
  6618. );
  6619. $scope.model.consumables = $scope.myDataoneall;
  6620. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6621. $scope.myDataoneall;
  6622. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6623. $scope.selected = {
  6624. items: [],
  6625. };
  6626. });
  6627. };
  6628. $scope.haocaiadd = function () {
  6629. event.preventDefault();
  6630. var modalInstance = $modal.open({
  6631. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6632. controller: function (
  6633. $scope,
  6634. scope,
  6635. $modalInstance,
  6636. api_wechatfile,
  6637. SweetAlert,
  6638. api_cmdb3
  6639. ) {
  6640. $scope.haocainame = [];
  6641. $scope.pinpai = [];
  6642. $scope.guige = [];
  6643. $scope.consumptive = {};
  6644. $scope.consumpall = {};
  6645. $scope.title = "添加耗材";
  6646. api_wechatfile
  6647. .getDictionaryForList({
  6648. key: "haocaifenlei",
  6649. })
  6650. .then(function (data) {
  6651. $scope.haocainame = data;
  6652. });
  6653. $scope.clearNoNum = function (obj, attr) {
  6654. //先把非数字的都替换掉,除了数字和.
  6655. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6656. //必须保证第一个为数字而不是.
  6657. obj[attr] = obj[attr].replace(/^\./g, "");
  6658. //保证只有出现一个.而没有多个.
  6659. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6660. //保证.只出现一次,而不能出现两次以上
  6661. obj[attr] = obj[attr]
  6662. .replace(".", "$#$")
  6663. .replace(/\./g, "")
  6664. .replace("$#$", ".");
  6665. //小于最大值
  6666. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6667. alert(
  6668. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6669. );
  6670. obj[attr] = "";
  6671. }
  6672. };
  6673. $scope.onChange = function (parent) {
  6674. $scope.consumptive.model = {};
  6675. $scope.consumptive.Specifications = {};
  6676. api_wechatfile
  6677. .getDictionaryForList({
  6678. key: "pinpai",
  6679. parent: parent.id,
  6680. })
  6681. .then(function (data) {
  6682. $scope.pinpai = data;
  6683. });
  6684. api_wechatfile
  6685. .getDictionaryForList({
  6686. key: "guige",
  6687. parent: parent.id,
  6688. })
  6689. .then(function (data) {
  6690. $scope.guige = data;
  6691. });
  6692. };
  6693. $scope.onChangesum = function (item) {
  6694. if (item.name && item.model.id && item.Specifications.id) {
  6695. $scope.consumptive.sum = "";
  6696. var data1 = {
  6697. idx: 0,
  6698. sum: 10,
  6699. consumable: {
  6700. name: item.name.name,
  6701. brandModel: item.model.name,
  6702. specification: item.Specifications.name,
  6703. },
  6704. };
  6705. api_cmdb3
  6706. .fetchDataList("consumable", data1)
  6707. .then(function (data) {
  6708. if (data.status == 200 && data.list.length > 0) {
  6709. var myData = data.list;
  6710. $scope.consumpall = myData[0];
  6711. $scope.maxsum = myData[0].inventoryNum;
  6712. } else {
  6713. SweetAlert.swal({
  6714. title: "不存在该耗材",
  6715. text: "请检查库存后重新填写!",
  6716. type: "error",
  6717. });
  6718. }
  6719. });
  6720. }
  6721. };
  6722. $scope.addhaocai = function () {
  6723. $modalInstance.dismiss("cancel");
  6724. scope.haocaiopen($scope.consumptive);
  6725. };
  6726. $scope.ok = function (item) {
  6727. var items = {};
  6728. // if (item.name && item.model && item.Specifications && item.sum) {
  6729. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6730. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6731. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6732. // $scope.consumpall.sum = item.sum;
  6733. // delete $scope.consumpall.brandModel;
  6734. // delete $scope.consumpall.specification;
  6735. // $modalInstance.close($scope.consumpall);
  6736. // } else {
  6737. // SweetAlert.swal({
  6738. // title: "数据填写不完整!",
  6739. // text: "请检查数据然后提交!",
  6740. // type: "error"
  6741. // });
  6742. // }
  6743. var isold = false;
  6744. if (
  6745. item.name &&
  6746. item.model &&
  6747. JSON.stringify(item.model) != "{}" &&
  6748. item.Specifications &&
  6749. JSON.stringify(item.Specifications) != "{}" &&
  6750. item.sum
  6751. ) {
  6752. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6753. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6754. isold = true;
  6755. }
  6756. }
  6757. if (isold) {
  6758. SweetAlert.swal({
  6759. title: "该耗材已添加!",
  6760. text: "请不要重复添加耗材!",
  6761. type: "error",
  6762. });
  6763. } else {
  6764. $scope.consumpall.model = $scope.consumpall.brandModel;
  6765. $scope.consumpall.Specifications =
  6766. $scope.consumpall.specification;
  6767. $scope.consumpall.sum = item.sum;
  6768. delete $scope.consumpall.brandModel;
  6769. delete $scope.consumpall.specification;
  6770. $modalInstance.close($scope.consumpall);
  6771. }
  6772. } else {
  6773. SweetAlert.swal({
  6774. title: "数据填写不完整!",
  6775. text: "请检查数据然后提交!",
  6776. type: "error",
  6777. });
  6778. }
  6779. // $modalInstance.close(item);
  6780. };
  6781. $scope.cancel = function () {
  6782. $modalInstance.dismiss("cancel");
  6783. };
  6784. },
  6785. size: "sm",
  6786. resolve: {
  6787. scope: function () {
  6788. return $scope;
  6789. },
  6790. },
  6791. });
  6792. modalInstance.result.then(function (selectedItem) {
  6793. $scope.myDataoneall.push(selectedItem);
  6794. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6795. $scope.myDataoneall[i]["item"] =
  6796. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6797. }
  6798. // $scope.model.consumables = $scope.myDataone;
  6799. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6800. $scope.myDataone = $scope.interceptMydata(
  6801. $scope.myDataoneall,
  6802. 0,
  6803. 10
  6804. );
  6805. $scope.model.consumables = $scope.myDataoneall;
  6806. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6807. $scope.myDataoneall;
  6808. });
  6809. };
  6810. $scope.onDblClick = function (data, event) {
  6811. $scope.selectButtonClick(data, event);
  6812. };
  6813. $scope.memoryfilterDatahao = {
  6814. idx: 0,
  6815. sum: 10,
  6816. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6817. };
  6818. $scope.myDataone = [];
  6819. $scope.loadData = function (filterData) { };
  6820. // $scope.title = title;
  6821. $scope.ldloading = {};
  6822. $scope.selected = {
  6823. items: [],
  6824. };
  6825. if ($scope.$parent.$parent.$parent.model.gettype) {
  6826. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6827. if ($scope.model.assets) {
  6828. if (JSON.stringify($scope.model.assets) == "{}") {
  6829. $scope.model.assets = [];
  6830. } else {
  6831. $scope.model.assets = JSON.parse($scope.model.assets);
  6832. }
  6833. $scope.myDatalingbeiall = $scope.model.assets;
  6834. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6835. $scope.myDatalingbeiall[i]["item"] =
  6836. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6837. }
  6838. $scope.gridOptions1["totalItems"] =
  6839. $scope.myDatalingbeiall.length;
  6840. $scope.myDatalingbei = $scope.interceptMydata(
  6841. $scope.myDatalingbeiall,
  6842. 0,
  6843. 10
  6844. );
  6845. }
  6846. if ($scope.model.consumables) {
  6847. if (JSON.stringify($scope.model.consumables) == "{}") {
  6848. $scope.model.consumables = [];
  6849. } else {
  6850. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6851. }
  6852. $scope.myDataoneall = $scope.model.consumables;
  6853. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6854. $scope.myDataoneall[i]["item"] =
  6855. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6856. }
  6857. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6858. $scope.myDataone = $scope.interceptMydata(
  6859. $scope.myDataoneall,
  6860. 0,
  6861. 10
  6862. );
  6863. }
  6864. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6865. $scope.options.templateOptions.getpush({
  6866. hao: true,
  6867. gu: true,
  6868. });
  6869. } else {
  6870. $scope.options.templateOptions.getpush({
  6871. hao: true,
  6872. });
  6873. }
  6874. } else {
  6875. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6876. $scope.options.templateOptions.getpush({
  6877. gu: true,
  6878. });
  6879. }
  6880. }
  6881. }
  6882. },
  6883. ],
  6884. });
  6885. formlyConfigProvider.setType({
  6886. name: "ui-panel",
  6887. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6888. });
  6889. formlyConfigProvider.setType({
  6890. name: "ui-currentuser",
  6891. extends: "input",
  6892. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6893. defaultOptions: function (options) {
  6894. return {
  6895. templateOptions: {
  6896. // link: function() {}
  6897. },
  6898. };
  6899. },
  6900. controller: [
  6901. "$scope",
  6902. function ($scope) {
  6903. if ($scope.options.templateOptions.user) {
  6904. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6905. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6906. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6907. // }
  6908. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6909. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6910. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6911. }
  6912. $scope.model[$scope.options.key] =
  6913. $scope.options.templateOptions.user;
  6914. $scope.options.initialValue = $scope.model[$scope.options.key];
  6915. }
  6916. },
  6917. ],
  6918. });
  6919. //仪表盘
  6920. //待处理变更列表
  6921. formlyConfigProvider.setType({
  6922. name: "ui-ngpchangetable",
  6923. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6924. defaultOptions: function (options) {
  6925. return {
  6926. templateOptions: {
  6927. // relationAction: function() {
  6928. // options.hideExpression = true
  6929. // }
  6930. },
  6931. };
  6932. },
  6933. controller: [
  6934. "$scope",
  6935. "$modal",
  6936. "$timeout",
  6937. "SweetAlert",
  6938. "api_bpm_domain",
  6939. "$rootScope",
  6940. "ngTableParams",
  6941. "$filter",
  6942. "$state",
  6943. function (
  6944. $scope,
  6945. $modal,
  6946. $timeout,
  6947. SweetAlert,
  6948. api_bpm_domain,
  6949. $rootScope,
  6950. ngTableParams,
  6951. $filter,
  6952. $state
  6953. ) {
  6954. // var filterData = {
  6955. // "assignee": $rootScope.user.id,
  6956. // "searchtype": "all",
  6957. // "idx": "0",
  6958. // "sum": "10"
  6959. // };
  6960. var filterData = {
  6961. idx: "0",
  6962. sum: "10",
  6963. assignee: 2,
  6964. searchType: "todo",
  6965. };
  6966. $scope.incidentprocess = function (item) {
  6967. $state.go("app.wt_change.add", {
  6968. taskId: item.taskId,
  6969. processInstanceId: item.processInstanceId,
  6970. });
  6971. };
  6972. $scope.more = function () {
  6973. $state.go("app.wt_change.list", {});
  6974. };
  6975. api_bpm_domain
  6976. .fetchtask("bpm_change", filterData)
  6977. .then(function (data) {
  6978. if (data.data) {
  6979. $scope.myData = data.data;
  6980. } else {
  6981. SweetAlert.swal({
  6982. title: "操作异常!",
  6983. text: "系统异常,请稍后重试,或者联系管理员!",
  6984. type: "error",
  6985. });
  6986. }
  6987. });
  6988. $scope.removes = function () {
  6989. var modalInstance = $modal.open({
  6990. templateUrl: "assets/views/delete.html",
  6991. controller: function ($scope, $modalInstance) {
  6992. $scope.ok = function () {
  6993. $modalInstance.close();
  6994. };
  6995. $scope.cancel = function () {
  6996. $modalInstance.dismiss("cancel");
  6997. };
  6998. },
  6999. size: "sm",
  7000. });
  7001. modalInstance.result.then(function () {
  7002. console.log($scope.$parent.$parent.$parent.$parent);
  7003. for (
  7004. var i = 0;
  7005. i <
  7006. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7007. i++
  7008. ) {
  7009. if (
  7010. $scope.fields.type ==
  7011. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7012. .type
  7013. ) {
  7014. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7015. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7016. i,
  7017. 1
  7018. );
  7019. break;
  7020. }
  7021. }
  7022. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7023. if (vmForm) {
  7024. //console.log("vmForm>>>");//console.log(vmForm);
  7025. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7026. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7027. }
  7028. });
  7029. };
  7030. },
  7031. ],
  7032. });
  7033. //待处理问题列表
  7034. formlyConfigProvider.setType({
  7035. name: "ui-ngproblemtable",
  7036. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7037. defaultOptions: function (options) {
  7038. return {
  7039. templateOptions: {
  7040. // relationAction: function() {
  7041. // options.hideExpression = true
  7042. // }
  7043. },
  7044. };
  7045. },
  7046. controller: [
  7047. "$scope",
  7048. "$modal",
  7049. "$timeout",
  7050. "SweetAlert",
  7051. "api_bpm_data",
  7052. "$rootScope",
  7053. "ngTableParams",
  7054. "$filter",
  7055. "$state",
  7056. function (
  7057. $scope,
  7058. $modal,
  7059. $timeout,
  7060. SweetAlert,
  7061. api_bpm_data,
  7062. $rootScope,
  7063. ngTableParams,
  7064. $filter,
  7065. $state
  7066. ) {
  7067. var filterData = {
  7068. assignee: $rootScope.user.id,
  7069. candidateGroups: $rootScope.user.group[0].id,
  7070. searchtype: "todo",
  7071. idx: 0,
  7072. sum: 10,
  7073. };
  7074. $scope.incidentprocess = function (item) {
  7075. $state.go("app.wt_change.add", {
  7076. taskId: item.taskId,
  7077. processInstanceId: item.processInstanceId,
  7078. });
  7079. };
  7080. $scope.more = function () {
  7081. $state.go("app.wt_change.list", {});
  7082. };
  7083. api_bpm_data
  7084. .fetchDataList("changeclassify", filterData)
  7085. .then(function (data) {
  7086. if (data.data) {
  7087. $scope.myData = data.data;
  7088. } else {
  7089. SweetAlert.swal({
  7090. title: "操作异常!",
  7091. text: "系统异常,请稍后重试,或者联系管理员!",
  7092. type: "error",
  7093. });
  7094. }
  7095. });
  7096. $scope.removes = function () {
  7097. var modalInstance = $modal.open({
  7098. templateUrl: "assets/views/delete.html",
  7099. controller: function ($scope, $modalInstance) {
  7100. $scope.ok = function () {
  7101. $modalInstance.close();
  7102. };
  7103. $scope.cancel = function () {
  7104. $modalInstance.dismiss("cancel");
  7105. };
  7106. },
  7107. size: "sm",
  7108. });
  7109. modalInstance.result.then(function () {
  7110. console.log($scope.$parent.$parent.$parent.$parent);
  7111. for (
  7112. var i = 0;
  7113. i <
  7114. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7115. i++
  7116. ) {
  7117. if (
  7118. $scope.fields.type ==
  7119. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7120. .type
  7121. ) {
  7122. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7123. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7124. i,
  7125. 1
  7126. );
  7127. break;
  7128. }
  7129. }
  7130. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7131. if (vmForm) {
  7132. //console.log("vmForm>>>");//console.log(vmForm);
  7133. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7134. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7135. }
  7136. });
  7137. };
  7138. },
  7139. ],
  7140. });
  7141. //待处理事件列表
  7142. formlyConfigProvider.setType({
  7143. name: "ui-ngtable",
  7144. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7145. defaultOptions: function (options) {
  7146. return {
  7147. templateOptions: {
  7148. // relationAction: function() {
  7149. // options.hideExpression = true
  7150. // }
  7151. },
  7152. };
  7153. },
  7154. controller: [
  7155. "$scope",
  7156. "$modal",
  7157. "$timeout",
  7158. "SweetAlert",
  7159. "api_bpm_domain",
  7160. "$rootScope",
  7161. "ngTableParams",
  7162. "$filter",
  7163. "$state",
  7164. function (
  7165. $scope,
  7166. $modal,
  7167. $timeout,
  7168. SweetAlert,
  7169. api_bpm_domain,
  7170. $rootScope,
  7171. ngTableParams,
  7172. $filter,
  7173. $state
  7174. ) {
  7175. var filterData = {
  7176. assignee: $rootScope.user.id,
  7177. candidateGroups: $rootScope.user.group[0].id,
  7178. searchtype: "done",
  7179. idx: 0,
  7180. sum: 10,
  7181. };
  7182. $scope.incidentprocess = function (item) {
  7183. $state.go("app.incident.editor", {
  7184. taskId: item.taskId,
  7185. processInstanceId: item.processInstanceId,
  7186. });
  7187. };
  7188. $scope.more = function () {
  7189. $state.go("app.incident.list", {});
  7190. };
  7191. api_bpm_domain
  7192. .fetchtask("bpm_incident", filterData)
  7193. .then(function (data) {
  7194. if (data.data) {
  7195. $scope.myData = data.data;
  7196. } else {
  7197. SweetAlert.swal({
  7198. title: "操作异常!",
  7199. text: "系统异常,请稍后重试,或者联系管理员!",
  7200. type: "error",
  7201. });
  7202. }
  7203. });
  7204. $scope.removes = function () {
  7205. var modalInstance = $modal.open({
  7206. templateUrl: "assets/views/delete.html",
  7207. controller: function ($scope, $modalInstance) {
  7208. $scope.ok = function () {
  7209. $modalInstance.close();
  7210. };
  7211. $scope.cancel = function () {
  7212. $modalInstance.dismiss("cancel");
  7213. };
  7214. },
  7215. size: "sm",
  7216. });
  7217. modalInstance.result.then(function () {
  7218. console.log($scope.$parent.$parent.$parent.$parent);
  7219. for (
  7220. var i = 0;
  7221. i <
  7222. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7223. i++
  7224. ) {
  7225. if (
  7226. $scope.fields.type ==
  7227. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7228. .type
  7229. ) {
  7230. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7231. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7232. i,
  7233. 1
  7234. );
  7235. break;
  7236. }
  7237. }
  7238. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7239. if (vmForm) {
  7240. //console.log("vmForm>>>");//console.log(vmForm);
  7241. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7242. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7243. }
  7244. });
  7245. };
  7246. },
  7247. ],
  7248. });
  7249. //知识库列表
  7250. formlyConfigProvider.setType({
  7251. name: "ui-knowledge",
  7252. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7253. defaultOptions: function (options) {
  7254. return {
  7255. templateOptions: {
  7256. // relationAction: function() {
  7257. // options.hideExpression = true
  7258. // }
  7259. },
  7260. };
  7261. },
  7262. controller: [
  7263. "$scope",
  7264. "$modal",
  7265. "$timeout",
  7266. "api_solution",
  7267. "$rootScope",
  7268. "ngTableParams",
  7269. "$filter",
  7270. "$state",
  7271. function (
  7272. $scope,
  7273. $modal,
  7274. $timeout,
  7275. api_solution,
  7276. $rootScope,
  7277. ngTableParams,
  7278. $filter,
  7279. $state
  7280. ) {
  7281. var filterData = {
  7282. key: "null",
  7283. pageIndex: 0,
  7284. pageSum: 6,
  7285. status: 0,
  7286. userId: $rootScope.user.id,
  7287. };
  7288. $scope.model.removereport = false;
  7289. $scope.removes = function () {
  7290. $scope.model.removereport = true;
  7291. };
  7292. $scope.more = function () {
  7293. $state.go("app.knowledge.manager", {});
  7294. };
  7295. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7296. if (data.status == 200) {
  7297. $scope.myData = data.list;
  7298. }
  7299. });
  7300. $scope.removes = function () {
  7301. var modalInstance = $modal.open({
  7302. templateUrl: "assets/views/delete.html",
  7303. controller: function ($scope, $modalInstance) {
  7304. $scope.ok = function () {
  7305. $modalInstance.close();
  7306. };
  7307. $scope.cancel = function () {
  7308. $modalInstance.dismiss("cancel");
  7309. };
  7310. },
  7311. size: "sm",
  7312. });
  7313. modalInstance.result.then(function () {
  7314. for (
  7315. var i = 0;
  7316. i <
  7317. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7318. i++
  7319. ) {
  7320. if (
  7321. $scope.fields.type ==
  7322. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7323. .type
  7324. ) {
  7325. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7326. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7327. i,
  7328. 1
  7329. );
  7330. break;
  7331. }
  7332. }
  7333. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7334. if (vmForm) {
  7335. //console.log("vmForm>>>");//console.log(vmForm);
  7336. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7337. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7338. }
  7339. });
  7340. };
  7341. },
  7342. ],
  7343. });
  7344. //公告列表
  7345. formlyConfigProvider.setType({
  7346. name: "ui-ngnotice",
  7347. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7348. defaultOptions: function (options) {
  7349. return {
  7350. templateOptions: {
  7351. // relationAction: function() {
  7352. // options.hideExpression = true
  7353. // }
  7354. },
  7355. };
  7356. },
  7357. controller: [
  7358. "$scope",
  7359. "$modal",
  7360. "$timeout",
  7361. "SweetAlert",
  7362. "api_user_data",
  7363. "$rootScope",
  7364. "ngTableParams",
  7365. "$filter",
  7366. "$state",
  7367. function (
  7368. $scope,
  7369. $modal,
  7370. $timeout,
  7371. SweetAlert,
  7372. api_user_data,
  7373. $rootScope,
  7374. ngTableParams,
  7375. $filter,
  7376. $state
  7377. ) {
  7378. var filterData = {
  7379. idx: 0,
  7380. sum: 10,
  7381. };
  7382. // $scope.$scope.model.className = "col-xs-12";
  7383. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7384. if (data) {
  7385. $scope.myData = data.data;
  7386. } else {
  7387. SweetAlert.swal({
  7388. title: "操作异常!",
  7389. text: "系统异常,请稍后重试,或者联系管理员!",
  7390. type: "error",
  7391. });
  7392. }
  7393. });
  7394. $scope.more = function () {
  7395. $state.go("app.system.notice.list", {});
  7396. };
  7397. $scope.removes = function () {
  7398. var modalInstance = $modal.open({
  7399. templateUrl: "assets/views/delete.html",
  7400. controller: function ($scope, $modalInstance) {
  7401. $scope.ok = function () {
  7402. $modalInstance.close();
  7403. };
  7404. $scope.cancel = function () {
  7405. $modalInstance.dismiss("cancel");
  7406. };
  7407. },
  7408. size: "sm",
  7409. });
  7410. modalInstance.result.then(function () {
  7411. for (
  7412. var i = 0;
  7413. i <
  7414. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7415. i++
  7416. ) {
  7417. if (
  7418. $scope.fields.type ==
  7419. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7420. .type
  7421. ) {
  7422. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7423. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7424. i,
  7425. 1
  7426. );
  7427. break;
  7428. }
  7429. }
  7430. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7431. if (vmForm) {
  7432. //console.log("vmForm>>>");//console.log(vmForm);
  7433. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7434. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7435. }
  7436. });
  7437. };
  7438. },
  7439. ],
  7440. });
  7441. //事件统计图
  7442. formlyConfigProvider.setType({
  7443. name: "ui-incidentreport",
  7444. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7445. defaultOptions: function (options) {
  7446. return {
  7447. templateOptions: {
  7448. // relationAction: function() {
  7449. // options.hideExpression = true
  7450. // }
  7451. },
  7452. };
  7453. },
  7454. controller: [
  7455. "$scope",
  7456. "$modal",
  7457. "moment",
  7458. "api_report",
  7459. "$cookieStore",
  7460. function ($scope, $modal, moment, api_report, $cookieStore) {
  7461. api_report.getLicenseKey().then(function (response) {
  7462. $cookieStore.put("Auth-Token", response.token);
  7463. $scope.try_async_load();
  7464. });
  7465. $scope.try_async_load = function () {
  7466. $scope.my_data = [];
  7467. api_report.list().then(function (response) {
  7468. var dataList = response;
  7469. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7470. $scope.repoRoot.name = "事件报表";
  7471. convertRepoObject($scope.repoRoot);
  7472. $scope.my_data.push($scope.repoRoot);
  7473. });
  7474. };
  7475. var workspace = {};
  7476. $scope.repoRoot = null;
  7477. function getRepoRoot(repo, path) {
  7478. angular.forEach(repo, function (value, key) {
  7479. if (value.path == path) {
  7480. $scope.repoRoot = value;
  7481. } else {
  7482. if (
  7483. $scope.repoRoot == null &&
  7484. angular.isDefined(value.repoObjects)
  7485. ) {
  7486. getRepoRoot(value.repoObjects, path);
  7487. } else {
  7488. }
  7489. }
  7490. });
  7491. }
  7492. function convertRepoObject(repo) {
  7493. if (angular.isArray(repo)) {
  7494. angular.forEach(repo, function (value, key) {
  7495. convertRepoObject(value);
  7496. });
  7497. } else {
  7498. if (angular.isDefined(repo.name)) {
  7499. if (repo.name.indexOf(".") >= 0) {
  7500. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7501. } else {
  7502. repo.label = repo.name;
  7503. }
  7504. //delete repo.name;
  7505. }
  7506. if (angular.isDefined(repo.repoObjects)) {
  7507. repo.children = [];
  7508. repo.children = repo.repoObjects;
  7509. delete repo.repoObjects;
  7510. convertRepoObject(repo.children);
  7511. }
  7512. }
  7513. }
  7514. function parseDateParameter(parameters) {
  7515. var result = undefined;
  7516. if (angular.isArray(parameters)) {
  7517. // angular.forEach(parmeters,function(param){
  7518. // param.
  7519. // })
  7520. } else {
  7521. result = {};
  7522. for (var k in parameters) {
  7523. if (k.indexOf("Date") > 0) {
  7524. if (angular.isString(parameters[k])) {
  7525. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7526. "YYYY-MM-DD"
  7527. );
  7528. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7529. }
  7530. }
  7531. }
  7532. }
  7533. return result;
  7534. }
  7535. function ConvertDateParameter(parameters) {
  7536. var result = undefined;
  7537. if (angular.isArray(parameters)) {
  7538. //
  7539. } else {
  7540. result = {};
  7541. for (var k in parameters) {
  7542. if (k.indexOf("Date") > 0) {
  7543. if (angular.isDate(parameters[k])) {
  7544. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7545. } else if (angular.isString(parameters[k])) {
  7546. result[k] = parameters[k];
  7547. }
  7548. }
  7549. }
  7550. }
  7551. return result;
  7552. }
  7553. var incidentchart =
  7554. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7555. var queryUUID;
  7556. function genUUID() {
  7557. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7558. .replace(/[xy]/g, function (c) {
  7559. var r = (Math.random() * 16) | 0,
  7560. v = c == "x" ? r : (r & 0x3) | 0x8;
  7561. return v.toString(16);
  7562. })
  7563. .toUpperCase();
  7564. return uuid;
  7565. }
  7566. queryUUID = genUUID();
  7567. var pathincidenttimekey = [];
  7568. var incidenttime = {
  7569. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7570. "YYYYMMDD"
  7571. ),
  7572. endtimes: moment(new Date()).format("YYYYMMDD"),
  7573. };
  7574. var thisday = moment(new Date().getTime() + 86400000).format(
  7575. "YYYYMMDD"
  7576. );
  7577. var thisdaymine = Date.parse(
  7578. thisday.substr(4, 2) +
  7579. "/" +
  7580. thisday.substr(6, 2) +
  7581. "/" +
  7582. thisday.substr(0, 4)
  7583. );
  7584. var averages = [
  7585. [thisdaymine - 86400000 * 14, 0],
  7586. [thisdaymine - 86400000 * 13, 0],
  7587. [thisdaymine - 86400000 * 12, 0],
  7588. [thisdaymine - 86400000 * 11, 0],
  7589. [thisdaymine - 86400000 * 10, 0],
  7590. [thisdaymine - 86400000 * 9, 0],
  7591. [thisdaymine - 86400000 * 8, 0],
  7592. [thisdaymine - 86400000 * 7, 0],
  7593. [thisdaymine - 86400000 * 6, 0],
  7594. [thisdaymine - 86400000 * 5, 0],
  7595. [thisdaymine - 86400000 * 4, 0],
  7596. [thisdaymine - 86400000 * 3, 0],
  7597. [thisdaymine - 86400000 * 2, 0],
  7598. [thisdaymine - 86400000 * 1, 0],
  7599. [thisdaymine, 0],
  7600. ];
  7601. var getreportdata = function (incidenttime, path) {
  7602. api_report.getMdx(path, queryUUID).then(function (response) {
  7603. var mdxquery = response;
  7604. workspace.query = mdxquery;
  7605. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7606. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7607. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7608. weekuser(mdxquery);
  7609. });
  7610. };
  7611. getreportdata(incidenttime, incidentchart);
  7612. var weekuser = function (mdxquery) {
  7613. var key = [];
  7614. api_report.execute(mdxquery).then(function (data) {
  7615. $scope.rheaders = [];
  7616. $scope.rRows = [];
  7617. var reportData = data;
  7618. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7619. $scope.shows = true;
  7620. $scope.empty = "数据为空!";
  7621. } else {
  7622. angular.forEach(reportData.cellset, function (item, i) {
  7623. angular.forEach(averages, function (index, j) {
  7624. // angular.forEach(averages, function(item, index) {
  7625. if (item.length > 1 && i > 0 && item[1].value != "") {
  7626. if (
  7627. index[0] ==
  7628. Date.parse(
  7629. item[0].value.substr(4, 2) +
  7630. "/" +
  7631. item[0].value.substr(6, 2) +
  7632. "/" +
  7633. item[0].value.substr(0, 4)
  7634. ) +
  7635. 86400000
  7636. ) {
  7637. index[1] = Number(item[1].value);
  7638. }
  7639. // 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)]);
  7640. }
  7641. // })
  7642. });
  7643. });
  7644. incidentchartfun(averages);
  7645. }
  7646. });
  7647. };
  7648. var incidentchartfun = function (incidentchartkey) {
  7649. // $scope.isMaskincident = false;
  7650. Highcharts.chart("incidentchart", {
  7651. title: {
  7652. text: "事件近15天趋势图",
  7653. },
  7654. xAxis: {
  7655. type: "datetime",
  7656. labels: {
  7657. align: "left",
  7658. step: 1,
  7659. },
  7660. },
  7661. yAxis: {
  7662. title: {
  7663. text: null,
  7664. },
  7665. },
  7666. tooltip: {
  7667. crosshairs: true,
  7668. shared: true,
  7669. valueSuffix: "条",
  7670. },
  7671. legend: {},
  7672. series: [
  7673. {
  7674. name: "生成事件",
  7675. data: incidentchartkey,
  7676. zIndex: 1,
  7677. marker: {
  7678. fillColor: "white",
  7679. lineWidth: 2,
  7680. lineColor: Highcharts.getOptions().colors[0],
  7681. },
  7682. },
  7683. ],
  7684. });
  7685. };
  7686. $scope.data = {
  7687. labels: [
  7688. "1号",
  7689. "2号",
  7690. "3号",
  7691. "4号",
  7692. "5号",
  7693. "6号",
  7694. "7号",
  7695. "8号",
  7696. "9号",
  7697. "10号",
  7698. "11号",
  7699. "12号",
  7700. "13号",
  7701. "14号",
  7702. "15号",
  7703. ],
  7704. datasets: [
  7705. {
  7706. label: "新增事件数量",
  7707. fillColor: "rgba(220,220,220,0.2)",
  7708. strokeColor: "rgba(220,220,220,1)",
  7709. pointColor: "rgba(220,220,220,1)",
  7710. pointStrokeColor: "#fff",
  7711. pointHighlightFill: "#fff",
  7712. pointHighlightStroke: "rgba(220,220,220,1)",
  7713. data: [
  7714. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7715. ],
  7716. },
  7717. {
  7718. label: "已解决事件数量",
  7719. fillColor: "rgba(151,187,205,0.2)",
  7720. strokeColor: "rgba(151,187,205,1)",
  7721. pointColor: "rgba(151,187,205,1)",
  7722. pointStrokeColor: "#fff",
  7723. pointHighlightFill: "#fff",
  7724. pointHighlightStroke: "rgba(151,187,205,1)",
  7725. data: [
  7726. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7727. ],
  7728. },
  7729. ],
  7730. };
  7731. $scope.removes = function () {
  7732. var modalInstance = $modal.open({
  7733. templateUrl: "assets/views/delete.html",
  7734. controller: function ($scope, $modalInstance) {
  7735. $scope.ok = function () {
  7736. $modalInstance.close();
  7737. };
  7738. $scope.cancel = function () {
  7739. $modalInstance.dismiss("cancel");
  7740. };
  7741. },
  7742. size: "sm",
  7743. });
  7744. modalInstance.result.then(function () {
  7745. for (
  7746. var i = 0;
  7747. i <
  7748. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7749. i++
  7750. ) {
  7751. if (
  7752. $scope.fields.type ==
  7753. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7754. .type
  7755. ) {
  7756. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7757. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7758. i,
  7759. 1
  7760. );
  7761. break;
  7762. }
  7763. }
  7764. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7765. if (vmForm) {
  7766. //console.log("vmForm>>>");//console.log(vmForm);
  7767. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7768. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7769. }
  7770. });
  7771. };
  7772. var addDatas = 0;
  7773. var resolve = 0;
  7774. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7775. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7776. }
  7777. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7778. resolve = resolve + $scope.data.datasets[1].data[i];
  7779. }
  7780. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7781. $scope.opt = {
  7782. maintainAspectRatio: false,
  7783. // Sets the chart to be responsive
  7784. responsive: true,
  7785. ///Boolean - Whether grid lines are shown across the chart
  7786. scaleShowGridLines: true,
  7787. //String - Colour of the grid lines
  7788. scaleGridLineColor: "rgba(0,0,0,.05)",
  7789. //Number - Width of the grid lines
  7790. scaleGridLineWidth: 1,
  7791. //Boolean - Whether the line is curved between points
  7792. bezierCurve: false,
  7793. //Number - Tension of the bezier curve between points
  7794. bezierCurveTension: 0.4,
  7795. //Boolean - Whether to show a dot for each point
  7796. pointDot: true,
  7797. //Number - Radius of each point dot in pixels
  7798. pointDotRadius: 4,
  7799. //Number - Pixel width of point dot stroke
  7800. pointDotStrokeWidth: 1,
  7801. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7802. pointHitDetectionRadius: 20,
  7803. //Boolean - Whether to show a stroke for datasets
  7804. datasetStroke: true,
  7805. //Number - Pixel width of dataset stroke
  7806. datasetStrokeWidth: 2,
  7807. //Boolean - Whether to fill the dataset with a colour
  7808. datasetFill: true,
  7809. // Function - on animation progress
  7810. onAnimationProgress: function () { },
  7811. // Function - on animation complete
  7812. onAnimationComplete: function () { },
  7813. //String - A legend template
  7814. legendTemplate:
  7815. '<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>',
  7816. };
  7817. angular.extend($scope.options, $scope.opt);
  7818. $scope.datamonth = {
  7819. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7820. datasets: [
  7821. {
  7822. label: "新增事件数量",
  7823. fillColor: "rgba(220,220,220,0.5)",
  7824. strokeColor: "rgba(220,220,220,0.8)",
  7825. highlightFill: "rgba(220,220,220,0.75)",
  7826. highlightStroke: "rgba(220,220,220,1)",
  7827. data: [65, 59, 80, 81, 56, 55],
  7828. },
  7829. {
  7830. label: "已解决事件数量",
  7831. fillColor: "rgba(151,187,205,0.5)",
  7832. strokeColor: "rgba(151,187,205,0.8)",
  7833. highlightFill: "rgba(151,187,205,0.75)",
  7834. highlightStroke: "rgba(151,187,205,1)",
  7835. data: [28, 48, 40, 19, 86, 27],
  7836. },
  7837. ],
  7838. };
  7839. // Chart.js Options
  7840. $scope.taption = {
  7841. maintainAspectRatio: false,
  7842. // Sets the chart to be responsive
  7843. responsive: true,
  7844. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7845. scaleBeginAtZero: true,
  7846. //Boolean - Whether grid lines are shown across the chart
  7847. scaleShowGridLines: true,
  7848. //String - Colour of the grid lines
  7849. scaleGridLineColor: "rgba(0,0,0,.05)",
  7850. //Number - Width of the grid lines
  7851. scaleGridLineWidth: 1,
  7852. //Boolean - If there is a stroke on each bar
  7853. barShowStroke: true,
  7854. //Number - Pixel width of the bar stroke
  7855. barStrokeWidth: 2,
  7856. //Number - Spacing between each of the X value sets
  7857. barValueSpacing: 5,
  7858. //Number - Spacing between data sets within X values
  7859. barDatasetSpacing: 1,
  7860. //String - A legend template
  7861. legendTemplate:
  7862. '<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>',
  7863. };
  7864. },
  7865. ],
  7866. });
  7867. //排版日历
  7868. formlyConfigProvider.setType({
  7869. name: "ui-dashcalendar",
  7870. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7871. defaultOptions: function (options) {
  7872. return {
  7873. templateOptions: {
  7874. // relationAction: function() {
  7875. // options.hideExpression = true
  7876. // }
  7877. },
  7878. };
  7879. },
  7880. controller: [
  7881. "$rootScope",
  7882. "$scope",
  7883. "$modal",
  7884. "$aside",
  7885. "calendarConfig",
  7886. "moment",
  7887. "SweetAlert",
  7888. "Restangular",
  7889. "api_bpm_schedule",
  7890. "api_user_data",
  7891. "$state",
  7892. function (
  7893. $rootScope,
  7894. $scope,
  7895. $modal,
  7896. $aside,
  7897. calendarConfig,
  7898. moment,
  7899. SweetAlert,
  7900. Restangular,
  7901. api_bpm_schedule,
  7902. api_user_data,
  7903. $state
  7904. ) {
  7905. var loginUser = $rootScope.user;
  7906. calendarConfig.dateFormatter = "moment";
  7907. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7908. calendarConfig.i18nStrings.timeLabel = "时间";
  7909. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7910. calendarConfig.allDateFormats = {
  7911. angular: {
  7912. date: {
  7913. hour: "ha",
  7914. day: "d MMM",
  7915. month: "MMMM",
  7916. weekDay: "EEEE",
  7917. time: "HH:mm",
  7918. datetime: "MMM d, h:mm a",
  7919. },
  7920. title: {
  7921. day: "yyyy MMMM EEEE d",
  7922. week: "{year}年第{week}周",
  7923. month: "yyyy MMMM",
  7924. year: "yyyy",
  7925. },
  7926. },
  7927. moment: {
  7928. date: {
  7929. hour: "ha",
  7930. day: "MMMDD日",
  7931. month: "MMMM",
  7932. weekDay: "dddd",
  7933. time: "HH:mm",
  7934. datetime: "MMM D, h:mm a",
  7935. },
  7936. title: {
  7937. day: "YYYY年MMMMDD日, dddd ",
  7938. week: "{year}年第{week}周",
  7939. month: "YYYY年MMMM",
  7940. year: "YYYY",
  7941. },
  7942. },
  7943. };
  7944. moment.locale("zh_cn", {
  7945. months:
  7946. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7947. "_"
  7948. ),
  7949. monthsShort:
  7950. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7951. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7952. "_"
  7953. ),
  7954. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7955. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7956. longDateFormat: {
  7957. LT: "Ah点mm分",
  7958. LTS: "Ah点m分s秒",
  7959. L: "YYYY-MM-DD",
  7960. LL: "YYYY年MMMD日",
  7961. LLL: "YYYY年MMMD日Ah点mm分",
  7962. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7963. l: "YYYY-MM-DD",
  7964. ll: "YYYY年MMMD日",
  7965. lll: "YYYY年MMMD日Ah点mm分",
  7966. llll: "YYYY年MMMD日ddddAh点mm分",
  7967. },
  7968. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7969. meridiemHour: function (hour, meridiem) {
  7970. if (hour === 12) {
  7971. hour = 0;
  7972. }
  7973. if (
  7974. meridiem === "凌晨" ||
  7975. meridiem === "早上" ||
  7976. meridiem === "上午"
  7977. ) {
  7978. return hour;
  7979. } else if (meridiem === "下午" || meridiem === "晚上") {
  7980. return hour + 12;
  7981. } else {
  7982. // '中午'
  7983. return hour >= 11 ? hour : hour + 12;
  7984. }
  7985. },
  7986. meridiem: function (hour, minute, isLower) {
  7987. var hm = hour * 100 + minute;
  7988. if (hm < 600) {
  7989. return "凌晨";
  7990. } else if (hm < 900) {
  7991. return "早上";
  7992. } else if (hm < 1130) {
  7993. return "上午";
  7994. } else if (hm < 1230) {
  7995. return "中午";
  7996. } else if (hm < 1800) {
  7997. return "下午";
  7998. } else {
  7999. return "晚上";
  8000. }
  8001. },
  8002. calendar: {
  8003. sameDay: function () {
  8004. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8005. },
  8006. nextDay: function () {
  8007. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8008. },
  8009. lastDay: function () {
  8010. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8011. },
  8012. nextWeek: function () {
  8013. var startOfWeek, prefix;
  8014. startOfWeek = moment().startOf("week");
  8015. prefix =
  8016. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8017. ? "[下]"
  8018. : "[本]";
  8019. return this.minutes() === 0
  8020. ? prefix + "dddAh点整"
  8021. : prefix + "dddAh点mm";
  8022. },
  8023. lastWeek: function () {
  8024. var startOfWeek, prefix;
  8025. startOfWeek = moment().startOf("week");
  8026. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8027. return this.minutes() === 0
  8028. ? prefix + "dddAh点整"
  8029. : prefix + "dddAh点mm";
  8030. },
  8031. sameElse: "LL",
  8032. },
  8033. ordinalParse: /\d{1,2}(日|月|周)/,
  8034. ordinal: function (number, period) {
  8035. switch (period) {
  8036. case "d":
  8037. case "D":
  8038. case "DDD":
  8039. return number + "日";
  8040. case "M":
  8041. return number + "月";
  8042. case "w":
  8043. case "W":
  8044. return number + "周";
  8045. default:
  8046. return number;
  8047. }
  8048. },
  8049. relativeTime: {
  8050. future: "%s内",
  8051. past: "%s前",
  8052. s: "几秒",
  8053. m: "1 分钟",
  8054. mm: "%d 分钟",
  8055. h: "1 小时",
  8056. hh: "%d 小时",
  8057. d: "1 天",
  8058. dd: "%d 天",
  8059. M: "1 个月",
  8060. MM: "%d 个月",
  8061. y: "1 年",
  8062. yy: "%d 年",
  8063. },
  8064. week: {
  8065. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8066. dow: 1, // Monday is the first day of the week.
  8067. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8068. },
  8069. });
  8070. var date = new Date();
  8071. var d = date.getDate();
  8072. var m = date.getMonth();
  8073. var y = date.getFullYear();
  8074. var filterData = {
  8075. userId: loginUser.id,
  8076. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8077. "YYYY-MM-DD HH:mm:ss"
  8078. ),
  8079. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8080. "YYYY-MM-DD HH:mm:ss"
  8081. ),
  8082. };
  8083. var load = ($scope.load = function (filterData) {
  8084. api_bpm_schedule
  8085. .fetchSchedule(
  8086. filterData.userId,
  8087. filterData.startTime,
  8088. filterData.endTime
  8089. )
  8090. .then(function (response) {
  8091. if (response.status == 200) {
  8092. $scope.events = [];
  8093. var myData = response.list;
  8094. angular.forEach(myData, function (item) {
  8095. var eventTemp = {};
  8096. eventTemp.title = item.description;
  8097. eventTemp.type = item.scheduleClass.code;
  8098. eventTemp.startsAt = moment(
  8099. item["scheduleOrderDTO"].startTime
  8100. ).toDate();
  8101. eventTemp.endsAtTime = moment(
  8102. item["scheduleOrderDTO"].endTime
  8103. ).toDate();
  8104. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8105. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8106. //eventTemp.ends_at = moment(item.endTime).toDate();
  8107. eventTemp.id = item.id;
  8108. eventTemp.deletable = false;
  8109. eventTemp.user = item.user;
  8110. $scope.events.push(eventTemp);
  8111. });
  8112. }
  8113. });
  8114. });
  8115. // var load = $scope.load = function(filterData){
  8116. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8117. // console.log("response="+JSON.stringify(response));
  8118. // if(response.status==200){
  8119. // $scope.events = [];
  8120. // console.log(response.list);
  8121. // var myData = response.list;
  8122. // angular.forEach(myData,function(item){
  8123. // var eventTemp = {};
  8124. // eventTemp.title = item.description;
  8125. // eventTemp.type = item.scheduleClass.code;
  8126. // eventTemp.startsAt = moment(item.startTime).toDate();
  8127. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8128. // eventTemp.startTime = item.startTime;
  8129. // eventTemp.endTime = item.endTime;
  8130. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8131. // eventTemp.id = item.id;
  8132. // eventTemp.deletable = false;
  8133. // eventTemp.users = item.users;
  8134. // $scope.events.push(eventTemp);
  8135. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8136. // })
  8137. // }
  8138. // });
  8139. // }
  8140. $scope.scheduleClass = {};
  8141. var convertEvent = function (scheduleorder) {
  8142. var eventTemp = {};
  8143. eventTemp.title = scheduleorder.description;
  8144. eventTemp.type = scheduleorder.scheduleClass.code;
  8145. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8146. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8147. eventTemp.id = scheduleorder.id;
  8148. eventTemp.user = scheduleorder.user;
  8149. eventTemp.deletable = false;
  8150. return eventTemp;
  8151. };
  8152. // var convertEvent = function(scheduleorder){
  8153. // var eventTemp = {};
  8154. // eventTemp.title = scheduleorder.description;
  8155. // eventTemp.type = scheduleorder.scheduleClass.code;
  8156. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8157. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8158. // eventTemp.id = scheduleorder.id;
  8159. // eventTemp.users = scheduleorder.users;
  8160. // eventTemp.deletable = false;
  8161. // return eventTemp;
  8162. // }
  8163. api_bpm_schedule.getScheduleClass().then(function (response) {
  8164. if (response.status == 200) {
  8165. var scheduleClassList = response.list;
  8166. angular.forEach(scheduleClassList, function (item) {
  8167. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8168. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8169. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8170. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8171. $scope.scheduleClass[item["code"]] = item;
  8172. });
  8173. }
  8174. });
  8175. $scope.events = [];
  8176. $scope.calendarView = "month";
  8177. //$scope.calendarDay = new Date();
  8178. $scope.calendarDate = moment().startOf("month").toDate();
  8179. $scope.timeLabel = "时间";
  8180. $scope.eventLabel = "描述";
  8181. function showModal(action, event) {
  8182. // console.log("action="+JSON.stringify(action))
  8183. var modalInstance = $aside.open({
  8184. templateUrl: "scheduleEvent.html",
  8185. placement: "right",
  8186. size: "sm",
  8187. backdrop: true,
  8188. controller: function (
  8189. $scope,
  8190. $modalInstance,
  8191. scheduleClass,
  8192. APIService,
  8193. MementFormat
  8194. ) {
  8195. $scope.$modalInstance = $modalInstance;
  8196. $scope.action = action;
  8197. $scope.event = event;
  8198. $scope.scheduleClassic = scheduleClass;
  8199. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8200. // if(oldvalue == newvalue) return;
  8201. // if(scheduleClass[newvalue]){
  8202. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8203. var em = MementFormat(scheduleClass[newvalue].endTime);
  8204. console.log("sm=" + JSON.stringify(sm));
  8205. event.starts_at = MementFormat(event.startTime)
  8206. .startOf("day")
  8207. .add(sm.hour(), "hour")
  8208. .add(sm.minute(), "minute")
  8209. .add(sm.second(), "second")
  8210. .toDate();
  8211. console.log(
  8212. "event.starts_at=" + JSON.stringify(event.starts_at)
  8213. );
  8214. if (sm.hour() > em.hour()) {
  8215. event.ends_at = MementFormat(event.startTime)
  8216. .startOf("day")
  8217. .add(1, "day")
  8218. .add(em.hour(), "hour")
  8219. .add(em.minute(), "minute")
  8220. .add(em.second(), "second")
  8221. .toDate();
  8222. console.log(
  8223. "event.ends_at=" + JSON.stringify(event.starts_at)
  8224. );
  8225. } else {
  8226. event.ends_at = MementFormat(event.startTime)
  8227. .startOf("day")
  8228. .add(em.hour(), "hour")
  8229. .add(em.minute(), "minute")
  8230. .add(em.second(), "second")
  8231. .toDate();
  8232. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8233. }
  8234. // }
  8235. });
  8236. // $scope.ok = function (event) {
  8237. // console.log("event="+JSON.stringify(event))
  8238. // event.action = action;
  8239. // $modalInstance.close(event);
  8240. // };
  8241. $scope.cancel = function (event) {
  8242. $modalInstance.dismiss();
  8243. };
  8244. var acUserSelect = ($scope.refreshUser = function (key) {
  8245. //for test
  8246. // $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":"管理层"}]}];
  8247. // return;
  8248. var data = {
  8249. idx: "0",
  8250. sum: "5",
  8251. user: {
  8252. engineer: 1,
  8253. }
  8254. };
  8255. if (key) {
  8256. data.user.name = key;
  8257. }
  8258. APIService.fetchDataList("user", data).then(function (
  8259. response
  8260. ) {
  8261. if (response) {
  8262. if ((response.status = 200)) {
  8263. $scope.users = response.list;
  8264. console.log($scope.users);
  8265. }
  8266. }
  8267. });
  8268. });
  8269. if (angular.isDefined(event.users) && event.users.length > 0) {
  8270. }
  8271. $scope.users = [event.user];
  8272. acUserSelect();
  8273. },
  8274. resolve: {
  8275. scheduleClass: function () {
  8276. return $scope.scheduleClass;
  8277. },
  8278. APIService: function () {
  8279. return api_user_data;
  8280. },
  8281. MementFormat: function () {
  8282. return moment;
  8283. },
  8284. },
  8285. });
  8286. modalInstance.result.then(function (selectedEvent) {
  8287. if (selectedEvent.action == "Clicked") {
  8288. // var data = {
  8289. // "scheduleorder":{
  8290. // "id":selectedEvent.id,
  8291. // "description":selectedEvent.title,
  8292. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8293. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8294. // "users":selectedEvent.users,
  8295. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8296. // }
  8297. // };
  8298. // api_bpm_schedule.update(data).then(function(response){
  8299. // if(response.status==200){
  8300. // SweetAlert.swal({
  8301. // title: "操作成功!",
  8302. // text: "排班更新成功!",
  8303. // type: "succes"
  8304. // });
  8305. // angular.forEach($scope.events,function(item){
  8306. // if(item.id==selectedEvent.id){
  8307. // item = selectedEvent;
  8308. // }
  8309. // })
  8310. // }else{
  8311. // SweetAlert.swal({
  8312. // title: "操作失败",
  8313. // text: "排班更新失败,请稍后重试!",
  8314. // type: "error"
  8315. // })
  8316. // }
  8317. // })
  8318. } else {
  8319. //
  8320. }
  8321. });
  8322. }
  8323. $scope.moment = function (string) {
  8324. return moment(string);
  8325. };
  8326. $scope.eventClicked = function (event) {
  8327. // console.log("event="+JSON.stringify(event))
  8328. showModal("Clicked", event);
  8329. };
  8330. $scope.eventEdited = function (event) {
  8331. showModal("Edited", event);
  8332. };
  8333. var updateView = function (newvalue, oldvalue) {
  8334. if (oldvalue == newvalue) return;
  8335. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8336. if ($scope.calendarView == "year") {
  8337. } else if ($scope.calendarView == "month") {
  8338. timeStart = moment(newvalue).startOf("month");
  8339. timeEnd = moment(newvalue).endOf("month");
  8340. } else if ($scope.calendarView == "week") {
  8341. timeStart = moment(newvalue).startOf("week");
  8342. timeEnd = moment(newvalue).endOf("week");
  8343. } else if ($scope.calendarView == "Day") {
  8344. timeStart = moment(newvalue).startOf("day");
  8345. timeEnd = moment(newvalue).endOf("day");
  8346. }
  8347. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8348. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8349. filterData["startTime"] = timeStartSpan;
  8350. filterData["endTime"] = timeEndSpan;
  8351. load(filterData);
  8352. };
  8353. $scope.$watch("calendarDate", updateView);
  8354. $scope.next = function () {
  8355. $scope.calendarControl.next();
  8356. };
  8357. $scope.prev = function () {
  8358. $scope.calendarControl.prev();
  8359. };
  8360. $scope.setCalendarToToday = function () {
  8361. $scope.calendarDay = new Date();
  8362. };
  8363. $scope.toggle = function ($event, field, event) {
  8364. $event.preventDefault();
  8365. $event.stopPropagation();
  8366. event[field] = !event[field];
  8367. };
  8368. $scope.load(filterData);
  8369. $scope.more = function () {
  8370. $state.go("app.scheduling.myscheduling", {});
  8371. };
  8372. $scope.removes = function () {
  8373. var modalInstance = $modal.open({
  8374. templateUrl: "assets/views/delete.html",
  8375. controller: function ($scope, $modalInstance) {
  8376. $scope.ok = function () {
  8377. $modalInstance.close();
  8378. };
  8379. $scope.cancel = function () {
  8380. $modalInstance.dismiss("cancel");
  8381. };
  8382. },
  8383. size: "sm",
  8384. });
  8385. modalInstance.result.then(function () {
  8386. for (
  8387. var i = 0;
  8388. i <
  8389. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8390. i++
  8391. ) {
  8392. if (
  8393. $scope.fields.type ==
  8394. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8395. .type
  8396. ) {
  8397. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8398. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8399. i,
  8400. 1
  8401. );
  8402. break;
  8403. }
  8404. }
  8405. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8406. if (vmForm) {
  8407. //console.log("vmForm>>>");//console.log(vmForm);
  8408. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8409. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8410. }
  8411. });
  8412. };
  8413. },
  8414. ],
  8415. });
  8416. //空格组件
  8417. formlyConfigProvider.setType({
  8418. name: "ui-black",
  8419. /*extends: 'input',*/
  8420. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8421. });
  8422. //请求人最近事件
  8423. formlyConfigProvider.setType({
  8424. name: "ui-recentIncident",
  8425. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8426. controller: [
  8427. "$scope",
  8428. "$modal",
  8429. "api_solution",
  8430. function ($scope, $modal, api_solution) {
  8431. var filterData = {
  8432. incident: {
  8433. requester: {
  8434. id: "",
  8435. },
  8436. },
  8437. idx: 0,
  8438. sum: 3,
  8439. };
  8440. setInterval(function () {
  8441. if (
  8442. filterData.incident.requester.id == "" ||
  8443. filterData.incident.requester.id != $scope.model.requester.id
  8444. ) {
  8445. var requester = $scope.model.requester;
  8446. if (requester != null && angular.isDefined(requester.id)) {
  8447. filterData.incident.requester.id = $scope.model.requester.id;
  8448. $scope.options.templateOptions
  8449. .getWorkernumber(
  8450. $scope.options.templateOptions.ApiService,
  8451. filterData
  8452. )
  8453. .then(function (result) {
  8454. var modelData =
  8455. $scope.options.templateOptions.Restangular.stripRestangular(
  8456. result
  8457. );
  8458. if (modelData.status == 200) {
  8459. $scope.lastrequst = modelData.list;
  8460. }
  8461. });
  8462. requester = null;
  8463. } else {
  8464. }
  8465. } else {
  8466. }
  8467. }, 1000);
  8468. $scope.detail = function (data) {
  8469. var modalInstance = $modal.open({
  8470. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8471. controller: function ($scope, $modalInstance) {
  8472. $scope.entity = {};
  8473. $scope.entity = data;
  8474. $scope.cancel = function () {
  8475. $modalInstance.dismiss("cancel");
  8476. };
  8477. },
  8478. size: "lg",
  8479. });
  8480. };
  8481. },
  8482. ],
  8483. });
  8484. //参数列表
  8485. formlyConfigProvider.setType({
  8486. name: "ui-listinput",
  8487. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8488. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8489. defaultOptions: function (options) {
  8490. return {
  8491. templateOptions: {},
  8492. };
  8493. },
  8494. controller: ["$scope", function ($scope) { }],
  8495. });
  8496. //时间段控件(分)
  8497. formlyConfigProvider.setType({
  8498. name: "ui-timeslot",
  8499. extends: "input",
  8500. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8501. controller: ["$scope", function ($scope) { }],
  8502. });
  8503. //优先级级联-逾期时间
  8504. formlyConfigProvider.setType({
  8505. name: "ui-overtime",
  8506. extends: "input",
  8507. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8508. controller: [
  8509. "$scope",
  8510. "api_bpm_domain",
  8511. function ($scope, api_bpm_domain) {
  8512. var filteData = {};
  8513. var datas = {};
  8514. setInterval(function () {
  8515. if (
  8516. $scope.model.priority &&
  8517. $scope.model.priority.id != null &&
  8518. filteData &&
  8519. datas != $scope.model.priority.id
  8520. ) {
  8521. filteData = "L" + $scope.model.priority.id;
  8522. datas = $scope.model.priority.id;
  8523. // console.log($scope.options.templateOptions)
  8524. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8525. // var overtime=requester.date;
  8526. if (requester.state == 200) {
  8527. // if($scope.options.key=="date"){
  8528. $scope.model[$scope.options.key] = requester.date;
  8529. // }
  8530. }
  8531. });
  8532. }
  8533. }, 1000);
  8534. },
  8535. ],
  8536. });
  8537. formlyConfigProvider.setType({
  8538. name: "ui-responsetime",
  8539. extends: "input",
  8540. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8541. controller: [
  8542. "$scope",
  8543. "api_bpm_domain",
  8544. function ($scope, api_bpm_domain) {
  8545. var filteData = {};
  8546. var datas = {};
  8547. setInterval(function () {
  8548. if (
  8549. $scope.model.priority &&
  8550. $scope.model.priority.id != null &&
  8551. filteData &&
  8552. datas != $scope.model.priority.id
  8553. ) {
  8554. filteData = "L" + $scope.model.priority.id;
  8555. datas = $scope.model.priority.id;
  8556. // console.log($scope.options.templateOptions)
  8557. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8558. // var overtime=requester.date;
  8559. if (requester.state == 200) {
  8560. var keyName = {};
  8561. // $scope.model.overdueTime = requester.date;
  8562. if ($scope.options.key == "expectIntroTime") {
  8563. keyName = "resolveTime";
  8564. } else if ($scope.options.key == "expectResponseTime") {
  8565. keyName = "responseTime";
  8566. }
  8567. $scope.model[$scope.options.key] =
  8568. requester.serviceLevelAgreement[keyName];
  8569. // }
  8570. console.log($scope.$parent.$parent.$parent.model);
  8571. }
  8572. if (requester.date1) {
  8573. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8574. requester.date;
  8575. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8576. requester.date1;
  8577. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8578. requester.serviceLevelAgreement.resolveTime;
  8579. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8580. requester.serviceLevelAgreement.responseTime;
  8581. }
  8582. });
  8583. }
  8584. }, 1000);
  8585. },
  8586. ],
  8587. });
  8588. //知识库按钮组件
  8589. formlyConfigProvider.setType({
  8590. name: "ui-discasecade",
  8591. extends: "input",
  8592. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8593. defaultOptions: function (options) {
  8594. return {
  8595. templateOptions: {
  8596. relationAction: function (fields, modelscope, item) { },
  8597. },
  8598. validators: {
  8599. required: {
  8600. expression: function (viewValue, modelValue) {
  8601. var value = modelValue || viewValue;
  8602. // return value = "true";
  8603. },
  8604. },
  8605. },
  8606. };
  8607. },
  8608. controller: [
  8609. "$scope",
  8610. "$rootScope",
  8611. "$modal",
  8612. "SweetAlert",
  8613. "api_bpm_data",
  8614. "api_solution",
  8615. "$aside",
  8616. "api_zsk",
  8617. "api_bpm_domain",
  8618. function (
  8619. $scope,
  8620. $rootScope,
  8621. $modal,
  8622. SweetAlert,
  8623. api_bpm_data,
  8624. api_solution,
  8625. $aside,
  8626. api_zsk,
  8627. api_bpm_domain
  8628. ) {
  8629. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8630. $scope.searchField = $scope.options.model[$scope.options.key];
  8631. $scope.searchData = "";
  8632. $scope.onChangeadd = function (searchData) {
  8633. $scope.searchKey = searchData.account;
  8634. // $scope.searchDataadd = searchData;
  8635. var requesdata = angular.copy(searchData);
  8636. $scope.requester = requesdata;
  8637. };
  8638. $scope.refreshUseradd = function (searchKey) {
  8639. //主题搜索
  8640. $scope.searchData = searchKey;
  8641. reashdata($scope.searchData);
  8642. };
  8643. $scope.getMydata = function (x) {
  8644. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8645. $scope.searchField = $scope.model[$scope.options.key];
  8646. };
  8647. $scope.getMydataone = function (x) {
  8648. $scope.model[$scope.options.key] = x;
  8649. $scope.searchField = $scope.model[$scope.options.key];
  8650. };
  8651. $scope.fildata = {
  8652. idx: 0,
  8653. sum: 10,
  8654. // 'incident': { 'tilte': item }
  8655. };
  8656. function reashdata(item) {
  8657. if (item && item != "") {
  8658. angular.extend($scope.fildata, {
  8659. incident: {
  8660. title: item,
  8661. },
  8662. });
  8663. } else {
  8664. delete $scope.fildata.incident;
  8665. }
  8666. api_bpm_data
  8667. .fetchDataList("incident", $scope.fildata)
  8668. .then(function (response) {
  8669. if (response) {
  8670. if ((response.status = 200)) {
  8671. var myData = response;
  8672. $scope.myData = myData.list;
  8673. }
  8674. }
  8675. });
  8676. }
  8677. function delHtmlTag(str) {
  8678. return str.replace(/<[^>]+>/g, "");
  8679. }
  8680. // reashdata();
  8681. var changedata = {};
  8682. setInterval(function () {
  8683. if (
  8684. $scope.model.category != null &&
  8685. $scope.model.category.id != changedata.id &&
  8686. $scope.model.titles != $scope.model.category
  8687. ) {
  8688. $scope.searchData = {};
  8689. changedata = angular.copy($scope.model.category);
  8690. if ($scope.options.key == "title") {
  8691. var filterData = {
  8692. idx: 0,
  8693. sum: 1000,
  8694. };
  8695. api_bpm_data
  8696. .fetchDataList("incidentcategory", filterData)
  8697. .then(function (data) {
  8698. var datalist = data.list;
  8699. angular.forEach(datalist, function (item) {
  8700. if (item.id == $scope.model.category.id) {
  8701. $scope.model[$scope.options.key] = item.category;
  8702. $scope.searchField =
  8703. $scope.options.model[$scope.options.key];
  8704. $scope.titles = item.category;
  8705. titles = $scope.model.category;
  8706. }
  8707. });
  8708. });
  8709. }
  8710. }
  8711. }, 1000);
  8712. $scope.open = function (key, options, fildata, $event, model) {
  8713. if (key && key.length > 1) {
  8714. api_zsk
  8715. .solutionData(
  8716. {
  8717. solution: {
  8718. searchWord: key,
  8719. },
  8720. idx: "0",
  8721. sum: "1000",
  8722. },
  8723. "solution"
  8724. )
  8725. .then(function (response) {
  8726. if (response && response.list.length > 0) {
  8727. $scope.dlideboxslide = true;
  8728. angular.forEach(response, function (item) {
  8729. console.log(response);
  8730. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8731. // if (response.status == 200) {
  8732. // var quote = { 'totalNum': response.totalNum }
  8733. // item = angular.extend(item, quote)
  8734. // }
  8735. // })
  8736. $scope.searchData = response.list;
  8737. console.log($scope.searchData);
  8738. });
  8739. $scope.changes = false;
  8740. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8741. // $scope.closepages = function(e) {
  8742. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8743. // event.preventDefault();
  8744. // };
  8745. $scope.shows = false;
  8746. $scope.tempData = {};
  8747. $scope.showpage = function (item) {
  8748. item.content = delHtmlTag(item.content);
  8749. $scope.shows = true;
  8750. $scope.tempData = item;
  8751. if (item.content != null) {
  8752. $scope.tempData.content = $scope.tempData.content
  8753. .replace("<p>", "")
  8754. .replace("</p>", "");
  8755. }
  8756. $scope.knowledgedata = item;
  8757. $scope.pageid = item.id;
  8758. $scope.changes = !$scope.changes;
  8759. api_bpm_domain
  8760. .listAttachments(item.id)
  8761. // api_solution.fetchDataList('file', {
  8762. // "file": {
  8763. // "solutionId": item.id
  8764. // },
  8765. // "idx": "0",
  8766. // "sum": "1000"
  8767. // })
  8768. .then(function (data) {
  8769. if (data) {
  8770. $scope.attachments = data.list;
  8771. $scope.view = function (attachmentId) {
  8772. for (
  8773. var i = 0;
  8774. i < $scope.attachments.length;
  8775. i++
  8776. ) {
  8777. if ($scope.attachments[i].id == attachmentId) {
  8778. window.open($scope.attachments[i].previewUrl);
  8779. }
  8780. }
  8781. };
  8782. $scope.download = function (contentId, filename) {
  8783. api_solution
  8784. .getSolutionDowpath(contentId)
  8785. .then(function (response) {
  8786. var file = new Blob([response], {
  8787. type: "application/octet-stream",
  8788. });
  8789. // var filename = filename;
  8790. var fileURL = URL.createObjectURL(file);
  8791. var a = document.createElement("a");
  8792. a.href = fileURL;
  8793. a.target = "_blank";
  8794. a.download = filename;
  8795. document.body.appendChild(a);
  8796. a.click();
  8797. });
  8798. };
  8799. }
  8800. });
  8801. };
  8802. $scope.related = function (item) {
  8803. if (item.content != null) {
  8804. item.content = item.content
  8805. .replace("<p>", "")
  8806. .replace("</p>", "");
  8807. }
  8808. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8809. options.model.handleDescription = item.content;
  8810. var data = {
  8811. solutionQuote: {
  8812. solutionId: item.id,
  8813. incidentsign: options.model.incidentsign,
  8814. },
  8815. };
  8816. api_zsk.solutionQuote(item.id).then(function (response) {
  8817. if (response.status == 200) {
  8818. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8819. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8820. "close";
  8821. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8822. } else {
  8823. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8824. }
  8825. });
  8826. };
  8827. $scope.close = function () {
  8828. $scope.changes = !$scope.changes;
  8829. event.preventDefault();
  8830. };
  8831. }
  8832. });
  8833. }
  8834. };
  8835. },
  8836. ],
  8837. });
  8838. //侧滑选择重复事件
  8839. formlyConfigProvider.setType({
  8840. name: "ui-repeatIncidentbtn",
  8841. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8842. defaultOptions: function (options) {
  8843. return {
  8844. templateOptions: {
  8845. relationAction: function (fields, modelscope, item) { },
  8846. },
  8847. validators: {
  8848. required: {
  8849. expression: function (viewValue, modelValue) {
  8850. // var value = modelValue || viewValue;
  8851. },
  8852. },
  8853. },
  8854. };
  8855. },
  8856. controller: [
  8857. "$scope",
  8858. "$rootScope",
  8859. "$modal",
  8860. "SweetAlert",
  8861. "api_bpm_data",
  8862. "api_solution",
  8863. "$aside",
  8864. "api_zsk",
  8865. "api_bpm_domain",
  8866. "api_webservice1",
  8867. function (
  8868. $scope,
  8869. $rootScope,
  8870. $modal,
  8871. SweetAlert,
  8872. api_bpm_data,
  8873. api_solution,
  8874. $aside,
  8875. api_zsk,
  8876. api_bpm_domain,
  8877. api_webservice1
  8878. ) {
  8879. console.log($scope);
  8880. $scope.selection = {
  8881. id: "",
  8882. };
  8883. //认证计费数据获取
  8884. $scope.sumInfo = {};
  8885. function getSumInfo() {
  8886. $scope.isHk = $rootScope.isHk;
  8887. if($rootScope.isHk){
  8888. //用户信息
  8889. api_webservice1.fetchDataList("queryUser", { "userId": $scope.model.incident.account }).then(function(response) {
  8890. // if (response.status == 200) {
  8891. if (response && response.data) {
  8892. angular.extend($scope.sumInfo, response.data[0]);
  8893. // $scope.sumInfo = response.data[0];
  8894. $scope.sumInfo.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  8895. $scope.sumInfo.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  8896. $scope.sumInfo.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  8897. } else if (response.err) {
  8898. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  8899. }
  8900. // }
  8901. })
  8902. //上网明细
  8903. 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) {
  8904. // if (response.status == 200) {
  8905. if (response && response.data) {
  8906. angular.forEach(response.data, function(item, index) {
  8907. if (item.logoutTime) {
  8908. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  8909. }
  8910. if (item.loginTime) {
  8911. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  8912. }
  8913. })
  8914. $scope.logininform_sumInfo = response.data;
  8915. } else if (response.err) {
  8916. SweetAlert.swal("上网明细未取到", "该用户暂无上网明细", "error");
  8917. }
  8918. })
  8919. //黑名单
  8920. // $scope.sumInfo.blacklist = "否"
  8921. api_webservice1.fetchDataList("queryInhibit", { "userId": $scope.model.incident.account }).then(function(response) {
  8922. // if (response.status == 200) {
  8923. // $scope.loginsumInfo = response.data;
  8924. if (response) {
  8925. if (response.data || response.data != null) {
  8926. $scope.sumInfo.blacklist = "是"
  8927. } else {
  8928. if (response.err) {
  8929. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  8930. } else {
  8931. $scope.sumInfo.blacklist = "否"
  8932. }
  8933. }
  8934. }
  8935. // }
  8936. })
  8937. }else{
  8938. // api_bpm_data
  8939. // .sumInfo($scope.model.incident.account)
  8940. // .then(function (data) {
  8941. // console.log(data);
  8942. // if (data) {
  8943. // $scope.sumInfo = data.data || {};
  8944. // }
  8945. // });
  8946. // 取消sum
  8947. $scope.sumInfo = {};
  8948. }
  8949. }
  8950. getSumInfo();
  8951. // 收起重复事件侧滑框
  8952. function reashdata(item) {
  8953. var fildata = {
  8954. idx: 0,
  8955. incident: {
  8956. department: {
  8957. id: $scope.model.incident.department.id,
  8958. },
  8959. },
  8960. sum: 3,
  8961. };
  8962. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8963. console.log(data);
  8964. if (data) {
  8965. $scope.repeatData = data.list;
  8966. }
  8967. });
  8968. }
  8969. reashdata();
  8970. // 确认选中的重复事件
  8971. $scope.repeatIncidentOk = function () {
  8972. if ($scope.selection.id) {
  8973. $scope.model.incident.repeat = $scope.selection;
  8974. $scope.model.isRepeat = true; //隐藏处理信息
  8975. console.log($scope.model);
  8976. }
  8977. angular.element("#repeatIncident").removeClass("active");
  8978. };
  8979. // 取消选中的重复事件
  8980. $scope.repeatIncidentCancle = function () {
  8981. angular.element("#repeatIncident").removeClass("active");
  8982. return;
  8983. };
  8984. },
  8985. ],
  8986. });
  8987. //侧滑选择知识库查询
  8988. formlyConfigProvider.setType({
  8989. name: "ui-knowledgebtn",
  8990. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8991. defaultOptions: function (options) {
  8992. return {
  8993. templateOptions: {
  8994. relationAction: function (fields, modelscope, item) { },
  8995. },
  8996. validators: {
  8997. required: {
  8998. expression: function (viewValue, modelValue) {
  8999. // var value = modelValue || viewValue;
  9000. },
  9001. },
  9002. },
  9003. };
  9004. },
  9005. controller: [
  9006. "$scope",
  9007. "$rootScope",
  9008. "$modal",
  9009. "SweetAlert",
  9010. "api_bpm_data",
  9011. "api_solution",
  9012. "$aside",
  9013. "api_zsk",
  9014. "api_bpm_domain",
  9015. "api_wechatfile",
  9016. "up_down_file",
  9017. function (
  9018. $scope,
  9019. $rootScope,
  9020. $modal,
  9021. SweetAlert,
  9022. api_bpm_data,
  9023. api_solution,
  9024. $aside,
  9025. api_zsk,
  9026. api_bpm_domain,
  9027. api_wechatfile,
  9028. up_down_file
  9029. ) {
  9030. $scope.keypressModel = function (e, key) {
  9031. if (e.keyCode === 13) {
  9032. $scope.openModel(key);
  9033. }
  9034. };
  9035. // 引用知识库点击
  9036. $scope.searchKeyWord = "";
  9037. $scope.openModel = function (key) {
  9038. // alert(1)//重点
  9039. $scope.searchKeyWord = key;
  9040. if (key) {
  9041. api_zsk
  9042. .solutionData(
  9043. {
  9044. solution: {
  9045. threeSearch: key,
  9046. status: { id: 72 }, //已发布
  9047. selectType: "keySearch",
  9048. },
  9049. idx: "0",
  9050. sum: "1000",
  9051. },
  9052. "solution"
  9053. )
  9054. .then(function (response) {
  9055. $scope.searchData = response.list;
  9056. });
  9057. }
  9058. };
  9059. $scope.openModel($scope.model.incident.description);
  9060. // 展开/收起
  9061. $scope.showId = "";
  9062. $scope.ifshow = false;
  9063. $scope.showAll = function (id) {
  9064. $scope.attachments = [];
  9065. if ($scope.showId == id) {
  9066. $scope.ifshow = !$scope.ifshow;
  9067. } else {
  9068. $scope.ifshow = true;
  9069. }
  9070. $scope.showId = id;
  9071. // 获取附件
  9072. api_wechatfile
  9073. .listAttachments("knowledge", $scope.showId)
  9074. .then(function (data) {
  9075. $scope.attachments = data.data;
  9076. $scope.download = function (token, filename) {
  9077. var downUrl = up_down_file
  9078. .downloadAttachment("common/common/downloadAttachment", token)
  9079. .getRequestedUrl();
  9080. // window.open(downUrl);
  9081. var a = document.createElement("a");
  9082. a.href = downUrl;
  9083. a.target = "_blank";
  9084. a.download = filename;
  9085. document.body.appendChild(a);
  9086. a.click();
  9087. };
  9088. });
  9089. };
  9090. // 引用
  9091. $scope.related = function (item) {
  9092. console.log(item, "引用名");
  9093. if (item.content) {
  9094. item.content = item.content
  9095. .replace(/<p>/g, "")
  9096. .replace(/<\/p>/g, "")
  9097. .replace(/&nbsp;/g, "");
  9098. }
  9099. $scope.model.incident.handleDescription = item.content;
  9100. $scope.model.incident.title = $scope.model.incident.description =
  9101. item.title;
  9102. $scope.model.incident.category = item.category;
  9103. if (item.category) {
  9104. $scope.model.incident.priority.id = item.category.priority.id;
  9105. item.category.label = item.category.category;
  9106. }
  9107. var categoryId = item.category ? item.category.id : "";
  9108. // 引用知识库故障现象后,修改故障现象选中状态,故障现象列表重载
  9109. function getres(nodes) {
  9110. if (!nodes || nodes.length == 0) {
  9111. return;
  9112. }
  9113. nodes.forEach((e) => {
  9114. e.selected = false;
  9115. if (e.id == categoryId) {
  9116. e.selected = true;
  9117. return false;
  9118. }
  9119. getres(e.children);
  9120. });
  9121. }
  9122. var categorys = [];
  9123. $scope.fields.forEach((e, i) => {
  9124. if (e.key == "category") {
  9125. categorys = e.templateOptions.options;
  9126. if (categorys.length) {
  9127. getres(categorys);
  9128. $scope.fields[i].templateOptions.options = categorys;
  9129. $scope.$root.refreshSelectedItems();
  9130. }
  9131. return false;
  9132. }
  9133. });
  9134. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9135. $scope.model.candidateGroups = item.category
  9136. ? item.category.group
  9137. : {};
  9138. // 携带关联优先级,事件工单信息的时间
  9139. if (
  9140. $scope.model &&
  9141. $scope.model.incident &&
  9142. item.category &&
  9143. item.category.priority &&
  9144. item.category.priority.id
  9145. ) {
  9146. api_bpm_domain
  9147. .expectedTime("L" + (item.category.priority.id - 1559))
  9148. .then(function (res) {
  9149. $scope.model.incident.expectResponseTime =
  9150. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9151. res.serviceLevelAgreement.responseTime;
  9152. $scope.model.incident.expectIntroTime =
  9153. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9154. res.serviceLevelAgreement.resolveTime;
  9155. $scope.model.incident.overdueTime =
  9156. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9157. res.date;
  9158. });
  9159. }
  9160. api_zsk.solutionQuote(item.id).then(function (response) {
  9161. if (response.status == 200) {
  9162. $("#seachknowledge").removeClass("active");
  9163. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9164. $scope.$parent.$parent.$parent.model.start_code = "close";
  9165. $scope.$parent.$parent.$parent.model.directClose = 0;
  9166. console.log($scope.model);
  9167. } else {
  9168. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9169. }
  9170. });
  9171. };
  9172. },
  9173. ],
  9174. });
  9175. //下拉输入组件
  9176. formlyConfigProvider.setType({
  9177. name: "ui-selectinput",
  9178. extends: "input",
  9179. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9180. defaultOptions: function (options) {
  9181. return {
  9182. templateOptions: {
  9183. refresh: function () { },
  9184. refreshDelay: 0,
  9185. linkage: function (modelName, data) { },
  9186. },
  9187. };
  9188. },
  9189. controller: [
  9190. "$scope",
  9191. "$rootScope",
  9192. "$modal",
  9193. "SweetAlert",
  9194. "api_bpm_data",
  9195. "api_solution",
  9196. "$aside",
  9197. function (
  9198. $scope,
  9199. $rootScope,
  9200. $modal,
  9201. SweetAlert,
  9202. api_bpm_data,
  9203. api_solution,
  9204. $aside
  9205. ) {
  9206. $scope.searchData = "";
  9207. $scope.onChangeadd = function (searchData) {
  9208. // $scope.searchKey = searchData.account;
  9209. // var requesdata = angular.copy(searchData)
  9210. // $scope.requester = requesdata;
  9211. };
  9212. $scope.refreshUseradd = function (searchKey) {
  9213. //主题搜索
  9214. // $scope.searchData = searchKey;
  9215. // reashdata($scope.searchData);
  9216. };
  9217. $scope.getMydata = function (x) {
  9218. $scope.model[$scope.options.key] =
  9219. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9220. $scope.searchField = $scope.model[$scope.options.key];
  9221. };
  9222. $scope.getMydataone = function (x) {
  9223. $scope.model[$scope.options.key] = x;
  9224. $scope.searchField = $scope.model[$scope.options.key];
  9225. if (
  9226. $scope.model[$scope.options.key] &&
  9227. $scope.model[$scope.options.key] != ""
  9228. ) {
  9229. $scope.hidden = false;
  9230. } else {
  9231. $scope.hidden = true;
  9232. }
  9233. };
  9234. function reashdata(item) {
  9235. $scope.myData = $scope.options.templateOptions.mydata;
  9236. }
  9237. reashdata();
  9238. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9239. $scope.options.templateOptions.fetchItems($scope);
  9240. }
  9241. },
  9242. ],
  9243. });
  9244. //重构组件模板
  9245. //获取当前人
  9246. formlyConfigProvider.setType({
  9247. name: "ui-users",
  9248. extends: "input",
  9249. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9250. defaultOptions: function (options) {
  9251. return {
  9252. templateOptions: {
  9253. translate: "",
  9254. refreshDelay: 0,
  9255. },
  9256. };
  9257. },
  9258. controller: [
  9259. "$scope",
  9260. function ($scope) {
  9261. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9262. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9263. },
  9264. ],
  9265. });
  9266. //只读控件
  9267. formlyConfigProvider.setType({
  9268. name: "ui-label",
  9269. extends: "input",
  9270. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9271. defaultOptions: function (options) {
  9272. return {
  9273. templateOptions: {
  9274. translate: "",
  9275. refreshDelay: 0,
  9276. },
  9277. };
  9278. },
  9279. controller: [
  9280. "$scope",
  9281. "$rootScope",
  9282. function ($scope, $rootScope) {
  9283. // console.log($scope.options.templateOptions)
  9284. // console.log($scope.options,'options1122');
  9285. $scope.isSolutionLabel = false;
  9286. $scope.solutionLabelStr = "";
  9287. // console.log($scope.options.templateOptions.solotinLabel);
  9288. if ($scope.options.templateOptions.solotinLabel) {
  9289. $scope.isSolutionLabel = true;
  9290. if ($scope.model[$scope.options.key]) {
  9291. var solutionArr = $scope.model[$scope.options.key].split("/");
  9292. $scope.solutionLabelStr = solutionArr.join(" ");
  9293. }
  9294. }
  9295. var value = $scope.model[$scope.options.key];
  9296. // ----------------
  9297. // ----------------
  9298. // console.log(value, 'pppp')
  9299. function treeDesc(children, key, label) {
  9300. if (label == "") {
  9301. label = children[key];
  9302. } else {
  9303. label = children[key] + "-" + label;
  9304. }
  9305. if (angular.isDefined(children.parent)) {
  9306. treeDesc(children.parent, key, label);
  9307. } else {
  9308. return label;
  9309. }
  9310. }
  9311. if (angular.isArray(value)) {
  9312. var tempValue = "";
  9313. angular.forEach(value, function (item) {
  9314. if (tempValue != "") {
  9315. tempValue = tempValue + ",";
  9316. }
  9317. tempValue =
  9318. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9319. item;
  9320. });
  9321. $scope.options.templateOptions.translate = tempValue;
  9322. } else if (angular.isObject(value)) {
  9323. if (
  9324. angular.isDefined(value.children) ||
  9325. angular.isDefined(value.parent)
  9326. ) {
  9327. //tree
  9328. // console.log("value.parent="+JSON.stringify(value.parent))
  9329. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9330. nameLabel = treeDesc(
  9331. value.parent,
  9332. $scope.options.templateOptions.labelProp,
  9333. nameLabel
  9334. );
  9335. $scope.options.templateOptions.translate = nameLabel;
  9336. } else {
  9337. $scope.options.templateOptions.translate = value;
  9338. }
  9339. } else if (
  9340. angular.isString(value) &&
  9341. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9342. ) {
  9343. // console.log("value=" + value);
  9344. $scope.options.templateOptions.translate = value;
  9345. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9346. // console.log("value="+value);
  9347. // $scope.options.templateOptions.translate = value;
  9348. } else {
  9349. // var datasdf = JSON.parse(value);
  9350. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9351. $scope.options.templateOptions.translate = value;
  9352. }
  9353. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9354. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9355. $scope.options.templateOptions.translate =
  9356. $scope.options.templateOptions.transform(
  9357. $scope.originalModel,
  9358. value,
  9359. $rootScope,
  9360. $scope
  9361. );
  9362. }
  9363. // console.log($scope.options.templateOptions.translate,99999);
  9364. },
  9365. ],
  9366. });
  9367. //小标题组件
  9368. formlyConfigProvider.setType({
  9369. name: "ui-header",
  9370. template:
  9371. '<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>',
  9372. });
  9373. //标题组件
  9374. formlyConfigProvider.setType({
  9375. name: "ui-title",
  9376. template:
  9377. '<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>',
  9378. });
  9379. //标栏是否展示
  9380. formlyConfigProvider.setType({
  9381. name: "ui-orshow",
  9382. template:
  9383. '<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>',
  9384. controller: [
  9385. "$scope",
  9386. function ($scope) {
  9387. $scope.clickshow = function (key) {
  9388. // $scope.model[$scope.options.key] != key;
  9389. if (key == false) {
  9390. $scope.model[$scope.options.key] = true;
  9391. } else {
  9392. $scope.model[$scope.options.key] = false;
  9393. }
  9394. };
  9395. },
  9396. ],
  9397. });
  9398. //按钮组
  9399. formlyConfigProvider.setType({
  9400. name: "ui-button",
  9401. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9402. defaultOptions: function (options) {
  9403. return {
  9404. noFormControl: true,
  9405. };
  9406. },
  9407. });
  9408. //3d组link
  9409. formlyConfigProvider.setType({
  9410. name: "ui-link",
  9411. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9412. defaultOptions: function (options) {
  9413. return {
  9414. noFormControl: true,
  9415. };
  9416. },
  9417. });
  9418. //隐藏域组件
  9419. formlyConfigProvider.setType({
  9420. name: "ui-hidden",
  9421. extends: "input",
  9422. template:
  9423. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9424. defaultOptions: function (options) {
  9425. return {
  9426. // noFormControl: true
  9427. };
  9428. },
  9429. });
  9430. //文本框组件
  9431. formlyConfigProvider.setType({
  9432. name: "ui-input",
  9433. extends: "input",
  9434. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9435. defaultOptions: function (options) {
  9436. return {
  9437. templateOptions: {
  9438. transform: function (value) { },
  9439. },
  9440. };
  9441. },
  9442. controller: [
  9443. "$scope",
  9444. "$timeout",
  9445. function ($scope, $timeout) {
  9446. // console.log($scope.model[$scope.options.key]);
  9447. // console.log($scope.options)
  9448. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9449. $scope.model[$scope.options.key] =
  9450. $scope.options.templateOptions.linkData($scope.model);
  9451. }
  9452. },
  9453. ],
  9454. });
  9455. //搜索下拉框-故障地点seimin
  9456. formlyConfigProvider.setType({
  9457. name: "ui-select-search",
  9458. extends: "input",
  9459. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9460. defaultOptions: function (options) {
  9461. return {
  9462. templateOptions: {
  9463. transform: function (value) { },
  9464. },
  9465. };
  9466. },
  9467. controller: [
  9468. "$scope",
  9469. "$rootScope",
  9470. "api_search_area",
  9471. function ($scope, $rootScope, api_search_area) {
  9472. // console.log($scope.options, $scope.model)
  9473. // ----------------分割线 start-----------------
  9474. // 故障地点下拉
  9475. $scope.address_arr = []; //故障地点所有数据
  9476. $scope.addressFlag = false; //默认下拉框列表隐藏
  9477. //点击文本框
  9478. $scope.AddressClickHandle = function () {
  9479. $scope.getDepartmentList();
  9480. angular.element("#bx_address_ul").scrollTop(0);
  9481. };
  9482. //修改文字,实时监听
  9483. $scope.ksChangeHandle = _.debounce(function () {
  9484. $scope.model[$scope.options.key] =
  9485. $scope.model[$scope.options.key] === undefined
  9486. ? ""
  9487. : $scope.model[$scope.options.key];
  9488. $scope.getDepartmentList();
  9489. angular.element("#bx_address_ul").scrollTop(0);
  9490. }, 500);
  9491. //获取故障地点seimin
  9492. $scope.getDepartmentList = function () {
  9493. $scope.model[$scope.options.key] =
  9494. $scope.model[$scope.options.key] === null
  9495. ? ""
  9496. : $scope.model[$scope.options.key];
  9497. api_search_area
  9498. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9499. .then((res) => {
  9500. if (res.state == 200) {
  9501. $scope.address_arr = res.result;
  9502. $scope.addressFlag = true; //显示
  9503. }
  9504. })
  9505. .catch((err) => {
  9506. console.log(err);
  9507. });
  9508. };
  9509. // $scope.getDepartmentList();
  9510. // console.log($scope.model[$scope.options.key])
  9511. //下拉框列表选中
  9512. $scope.addressItemClick = function (obj) {
  9513. $scope.addressFlag = false; //隐藏
  9514. $scope.model[$scope.options.key] = obj.place
  9515. ? obj.area.area + obj.place
  9516. : obj.area;
  9517. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9518. $scope.model.selecthouseNumber = obj;
  9519. console.log($scope, 77777);
  9520. $scope.$root.selecthouseNumber = obj;
  9521. };
  9522. //点击空白处隐藏
  9523. angular.element(document).on("click", function (e) {
  9524. if (e.target !== angular.element("#bx_address").get(0)) {
  9525. $scope.addressFlag = false; //隐藏
  9526. //模拟placeholder
  9527. // if ($('#bx_address').val() == '') {
  9528. // $('#bx_address').val('请选择报修科室');
  9529. // }
  9530. }
  9531. });
  9532. // -----------------分割线 end----------------
  9533. },
  9534. ],
  9535. });
  9536. //知识库关键字组件
  9537. formlyConfigProvider.setType({
  9538. name: "ui-knowledgeKeywords",
  9539. extends: "input",
  9540. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9541. defaultOptions: function (options) {
  9542. return {
  9543. templateOptions: {
  9544. transform: function (value) { },
  9545. },
  9546. };
  9547. },
  9548. controller: [
  9549. "$scope",
  9550. "$timeout",
  9551. "SweetAlert",
  9552. function ($scope, $timeout, SweetAlert) {
  9553. $scope.valueLength = [
  9554. {
  9555. value: "",
  9556. },
  9557. ];
  9558. $scope.valueAll = [];
  9559. if ($scope.model[$scope.options.key]) {
  9560. var valueArr = $scope.model[$scope.options.key].split("/");
  9561. $scope.valueLength = [];
  9562. for (var i = 0; i < valueArr.length; i++) {
  9563. $scope.valueLength.push({
  9564. value: valueArr[i],
  9565. });
  9566. }
  9567. }
  9568. $scope.addIpt = function () {
  9569. if ($scope.valueLength.length < 5) {
  9570. $scope.valueLength.push({
  9571. value: "",
  9572. });
  9573. } else {
  9574. SweetAlert.swal({
  9575. title: "添加失败",
  9576. text: "关键字不能超过5个!",
  9577. type: "error",
  9578. confirmButtonColor: "#DD6B55",
  9579. });
  9580. }
  9581. };
  9582. $scope.closeIpt = function (data) {
  9583. $scope.valueLength.splice(data, 1);
  9584. };
  9585. $scope.toOption = function () {
  9586. $scope.valueAll = [];
  9587. for (var i = 0; i < $scope.valueLength.length; i++) {
  9588. if ($scope.valueLength[i].value != "") {
  9589. $scope.valueAll.push($scope.valueLength[i].value);
  9590. }
  9591. }
  9592. $scope.model.label = $scope.valueAll.join("/");
  9593. };
  9594. },
  9595. ],
  9596. });
  9597. //文本框组件
  9598. formlyConfigProvider.setType({
  9599. name: "ui-num",
  9600. extends: "input",
  9601. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9602. defaultOptions: function (options) {
  9603. return {
  9604. templateOptions: {
  9605. transform: function (value) { },
  9606. },
  9607. };
  9608. },
  9609. controller: [
  9610. "$scope",
  9611. "$timeout",
  9612. function ($scope, $timeout) {
  9613. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9614. $scope.model[$scope.options.key] =
  9615. $scope.options.templateOptions.linkData($scope.model);
  9616. }
  9617. $scope.clearNoNum = function (obj, attr) {
  9618. //先把非数字的都替换掉,除了数字和.
  9619. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9620. //必须保证第一个为数字而不是.
  9621. obj[attr] = obj[attr].replace(/^\./g, "");
  9622. //保证只有出现一个.而没有多个.
  9623. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9624. //保证.只出现一次,而不能出现两次以上
  9625. obj[attr] = obj[attr]
  9626. .replace(".", "$#$")
  9627. .replace(/\./g, "")
  9628. .replace("$#$", ".");
  9629. //小于最大值
  9630. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9631. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9632. // obj[attr] = '';
  9633. // }
  9634. };
  9635. },
  9636. ],
  9637. });
  9638. // //关联请求人文本框组件
  9639. // formlyConfigProvider.setType({
  9640. // name: 'ui-requestinput',
  9641. // extends: 'input',
  9642. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9643. // defaultOptions: function(options) {
  9644. // return {
  9645. // templateOptions: {
  9646. // transform: function(value) {},
  9647. // linkData: function(options) {}
  9648. // }
  9649. // };
  9650. // }
  9651. // });
  9652. //只读文本
  9653. formlyConfigProvider.setType({
  9654. name: "ui-disableinput",
  9655. extends: "input",
  9656. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9657. defaultOptions: function (options) {
  9658. return {
  9659. templateOptions: {
  9660. transform: function (value) {
  9661. var ret = "";
  9662. if (value) {
  9663. ret = "已删除";
  9664. } else {
  9665. ret = "正常";
  9666. }
  9667. return ret;
  9668. },
  9669. },
  9670. };
  9671. },
  9672. });
  9673. formlyConfigProvider.setType({
  9674. name: "ui-disinput",
  9675. extends: "input",
  9676. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9677. defaultOptions: function (options) {
  9678. return {
  9679. templateOptions: {},
  9680. };
  9681. },
  9682. });
  9683. //数字组件
  9684. formlyConfigProvider.setType({
  9685. name: "ui-number",
  9686. extends: "input",
  9687. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9688. defaultOptions: function (options) {
  9689. return {
  9690. templateOptions: {},
  9691. };
  9692. },
  9693. controller: ["$scope", function ($scope) { }],
  9694. });
  9695. //含有周的日期
  9696. formlyConfigProvider.setType({
  9697. name: "ui-datepickerweek",
  9698. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9699. extends: "input",
  9700. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9701. defaultOptions: {
  9702. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9703. templateOptions: {
  9704. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9705. },
  9706. },
  9707. controller: [
  9708. "$scope",
  9709. "$filter",
  9710. function ($scope, $filter) {
  9711. $scope.mindata = new Date(
  9712. $scope.options.templateOptions.transform($scope.model).getTime() +
  9713. 5 * 60 * 1000
  9714. );
  9715. if ($scope.model[$scope.options.key]) {
  9716. } else {
  9717. $scope.model[$scope.options.key] = $filter("date")(
  9718. new Date(new Date().getTime()),
  9719. $scope.options.templateOptions.datepickerPopup
  9720. );
  9721. }
  9722. $scope.options.initialValue = $scope.model[$scope.options.key];
  9723. $scope.endOpen = true;
  9724. $scope.datepicker = {};
  9725. $scope.datepicker.opened = false;
  9726. $scope.datepicker.open = function ($event) {
  9727. $scope.datepicker.opened = true;
  9728. };
  9729. },
  9730. ],
  9731. });
  9732. //lmm
  9733. //分配任务列表
  9734. formlyConfigProvider.setType({
  9735. name: "jry_taskDistributionList",
  9736. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9737. wrapper: ["bootstrapHasError"],
  9738. defaultOptions: function (options, $scope) {
  9739. return {
  9740. templateOptions: {},
  9741. };
  9742. },
  9743. controller: function (
  9744. $rootScope,
  9745. $scope,
  9746. api_user_data,
  9747. $modal,
  9748. api_doc_data,
  9749. i18nService,
  9750. SweetAlert,
  9751. api_wechatfile
  9752. ) {
  9753. // 获取状态
  9754. $scope.stateListData = {};
  9755. $scope.getStateData = function () {
  9756. //lyl
  9757. var data = {
  9758. key: "task_sub_state",
  9759. type: "list",
  9760. };
  9761. api_wechatfile.getDictionary(data).then(function (res) {
  9762. angular.forEach(res, function (v, i) {
  9763. $scope.stateListData[v.value] = v.id;
  9764. });
  9765. });
  9766. };
  9767. $scope.getStateData();
  9768. var loginUser = $rootScope.user;
  9769. $scope.langs = i18nService.getAllLangs();
  9770. $scope.lang = "zh-cn";
  9771. i18nService.setCurrentLang($scope.lang);
  9772. $scope.gridOptions = {};
  9773. $scope.gridOptions.data = "myData";
  9774. $scope.gridOptions.enableColumnResizing = true;
  9775. $scope.gridOptions.enableGridMenu = false;
  9776. $scope.gridOptions.enableRowSelection = true;
  9777. $scope.gridOptions.showGridFooter = true;
  9778. $scope.gridOptions.showColumnFooter = false;
  9779. $scope.gridOptions.fastWatch = true;
  9780. $scope.gridOptions.useExternalFiltering = true;
  9781. $scope.gridOptions.useExternalPagination = true;
  9782. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  9783. $scope.gridOptions.paginationPageSize = 10;
  9784. $scope.gridOptions.multiSelect = true;
  9785. $scope.gridOptions.rowIdentity = function (row) {
  9786. return row.id;
  9787. };
  9788. $scope.gridOptions.getRowIdentity = function (row) {
  9789. return row.id;
  9790. };
  9791. // console.log($scope.model);//lmmmm
  9792. $scope.gridOptions.columnDefs = [
  9793. {
  9794. name: "item",
  9795. displayName: "序号",
  9796. width: "10%",
  9797. cellTemplate:
  9798. "<div>" +
  9799. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9800. "</div>",
  9801. },
  9802. {
  9803. name: "taskDescribe",
  9804. displayName: "任务说明",
  9805. width: "25%",
  9806. enableFiltering: false,
  9807. cellTemplate:
  9808. "<div>" +
  9809. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9810. "</div>",
  9811. },
  9812. {
  9813. name: "assign.name",
  9814. displayName: "指派人",
  9815. width: "5%",
  9816. enableFiltering: false,
  9817. cellTemplate:
  9818. "<div>" +
  9819. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9820. "</div>",
  9821. },
  9822. {
  9823. name: "startTime",
  9824. displayName: "开始时间",
  9825. width: "13%",
  9826. enableFiltering: false,
  9827. cellTemplate:
  9828. "<div>" +
  9829. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9830. "</div>",
  9831. },
  9832. {
  9833. name: "endTime",
  9834. displayName: "结束时间",
  9835. width: "13%",
  9836. enableFiltering: false,
  9837. cellTemplate:
  9838. "<div>" +
  9839. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9840. "</div>",
  9841. },
  9842. {
  9843. name: "priority.name",
  9844. displayName: "优先级",
  9845. width: "5%",
  9846. enableFiltering: false,
  9847. cellTemplate:
  9848. "<div>" +
  9849. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9850. "</div>",
  9851. },
  9852. {
  9853. name: "state.name",
  9854. displayName: "状态",
  9855. width: "5%",
  9856. enableFiltering: false,
  9857. cellTemplate:
  9858. "<div>" +
  9859. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9860. "</div>",
  9861. },
  9862. {
  9863. name: "操作", //lmmm
  9864. cellTemplate:
  9865. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9866. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9867. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9868. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9869. '<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>' +
  9870. "</div></div>",
  9871. enableFiltering: false,
  9872. },
  9873. ];
  9874. // 查看
  9875. $scope.see = function (data) {
  9876. $scope.seeData = data;
  9877. var modalInstance = $modal.open({
  9878. backdrop: false,
  9879. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9880. controller: function (
  9881. $scope,
  9882. scope,
  9883. $modalInstance,
  9884. api_doc_data,
  9885. SweetAlert,
  9886. api_user_data,
  9887. api_wechatfile
  9888. ) {
  9889. $scope.personData = {}; //指派人
  9890. $scope.priorityData = {}; //优先级
  9891. $scope.personListData = {}; //指派人下拉数据
  9892. $scope.priorityListData = {}; //优先级下拉数据
  9893. $scope.startTime = ""; //开始时间
  9894. $scope.releaseShow = "no";
  9895. $scope.subShow = "no";
  9896. $scope.onlySee = "ok";
  9897. $scope.endTime = ""; //结束时间
  9898. $scope.taskDescribe = ""; //任务描述
  9899. $scope.taskDescribe = scope.seeData.taskDescribe;
  9900. $scope.personData.data = scope.seeData.assign;
  9901. $scope.priorityData.data = scope.seeData.priority;
  9902. $scope.startTime = scope.seeData.startTime;
  9903. $scope.endTime = scope.seeData.endTime;
  9904. $scope.done = scope.seeData.done;
  9905. $scope.feedback = scope.seeData.feedback;
  9906. $scope.cancel = function () {
  9907. $modalInstance.dismiss("cancel");
  9908. };
  9909. },
  9910. size: "sm",
  9911. resolve: {
  9912. scope: function () {
  9913. return $scope;
  9914. },
  9915. },
  9916. backdrop: true,
  9917. });
  9918. };
  9919. // 编辑
  9920. $scope.edit = function (data) {
  9921. $scope.editData = data;
  9922. var modalInstance = $modal.open({
  9923. backdrop: false,
  9924. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9925. controller: function (
  9926. $scope,
  9927. scope,
  9928. $modalInstance,
  9929. api_doc_data,
  9930. SweetAlert,
  9931. api_user_data,
  9932. api_wechatfile
  9933. ) {
  9934. console.log(scope.editData);
  9935. $scope.personData = {}; //指派人
  9936. $scope.priorityData = {}; //优先级
  9937. $scope.personListData = {}; //指派人下拉数据
  9938. $scope.priorityListData = {}; //优先级下拉数据
  9939. $scope.startTime = ""; //开始时间
  9940. $scope.releaseShow = "no";
  9941. $scope.endTime = ""; //结束时间
  9942. $scope.taskDescribe = ""; //任务描述
  9943. $scope.taskDescribe = scope.editData.taskDescribe;
  9944. $scope.personData.data = scope.editData.assign;
  9945. $scope.priorityData.data = scope.editData.priority;
  9946. $scope.startTime = scope.editData.startTime;
  9947. $scope.endTime = scope.editData.endTime;
  9948. // 指派人下拉框数据
  9949. $scope.getPersonData = function () {
  9950. var data = {
  9951. idx: 0,
  9952. sum: 1000,
  9953. user: {
  9954. engineer: 1,
  9955. }
  9956. };
  9957. api_user_data.fetchDataList("user", data).then(function (res) {
  9958. $scope.personListData = res.list;
  9959. });
  9960. };
  9961. $scope.getPersonData();
  9962. //优先级下拉数据
  9963. $scope.getPriorityData = function () {
  9964. var data = {
  9965. key: "change_rick_level",
  9966. type: "list",
  9967. };
  9968. api_wechatfile.getDictionary(data).then(function (res) {
  9969. $scope.priorityListData = res;
  9970. });
  9971. };
  9972. $scope.getPriorityData();
  9973. // 获取状态-lmm
  9974. $scope.stateListData = {};
  9975. $scope.getStateData = function () {
  9976. //lyl
  9977. var data = {
  9978. key: "task_sub_state",
  9979. type: "list",
  9980. };
  9981. api_wechatfile.getDictionary(data).then(function (res) {
  9982. angular.forEach(res, function (v, i) {
  9983. $scope.stateListData[v.value] = v.id;
  9984. });
  9985. });
  9986. };
  9987. $scope.getStateData();
  9988. //时间控件
  9989. $scope.open = function ($event) {
  9990. $event.preventDefault();
  9991. $event.stopPropagation();
  9992. $scope.opened = !$scope.opened;
  9993. };
  9994. $scope.endOpen = function ($event) {
  9995. $event.preventDefault();
  9996. $event.stopPropagation();
  9997. $scope.startOpened = false;
  9998. $scope.endOpened = !$scope.endOpened;
  9999. };
  10000. $scope.startOpen = function ($event) {
  10001. $event.preventDefault();
  10002. $event.stopPropagation();
  10003. $scope.endOpened = false;
  10004. $scope.startOpened = !$scope.startOpened;
  10005. };
  10006. // 确定
  10007. $scope.ok = function (item) {
  10008. if (
  10009. $scope.taskDescribe &&
  10010. $scope.personData.data &&
  10011. $scope.priorityData.data &&
  10012. $scope.startTime &&
  10013. $scope.endTime
  10014. ) {
  10015. $scope.startTime = moment(
  10016. new Date($scope.startTime).getTime()
  10017. ).format("YYYY-MM-DD HH:mm:ss");
  10018. $scope.endTime = moment(
  10019. new Date($scope.endTime).getTime()
  10020. ).format("YYYY-MM-DD HH:mm:ss");
  10021. $scope.addData = {
  10022. taskSub: {
  10023. taskDescribe: $scope.taskDescribe,
  10024. assign: $scope.personData.data,
  10025. priority: $scope.priorityData.data,
  10026. startTime: $scope.startTime,
  10027. endTime: $scope.endTime,
  10028. taskMonth: {
  10029. id: scope.model.taskMonth.id,
  10030. },
  10031. id: scope.editData.id,
  10032. },
  10033. };
  10034. $scope.addData.taskSub["state"] = {
  10035. id: $scope.stateListData[1],
  10036. };
  10037. api_user_data
  10038. .updData("taskSub", $scope.addData)
  10039. .then(function (res) {
  10040. if (res.status == 200) {
  10041. SweetAlert.swal({
  10042. title: "修改成功!",
  10043. type: "success",
  10044. confirmButtonColor: "#007AFF",
  10045. });
  10046. scope.refreshData(scope.jry_filterdata);
  10047. $modalInstance.dismiss("cancel");
  10048. } else {
  10049. SweetAlert.swal({
  10050. title: "修改失败",
  10051. text: "系统错误,请重试!",
  10052. type: "error",
  10053. });
  10054. $modalInstance.dismiss("cancel");
  10055. }
  10056. });
  10057. } else {
  10058. SweetAlert.swal({
  10059. title: "修改失败",
  10060. text: "必填项不能为空!",
  10061. type: "error",
  10062. });
  10063. }
  10064. };
  10065. $scope.cancel = function () {
  10066. $modalInstance.dismiss("cancel");
  10067. };
  10068. },
  10069. size: "sm",
  10070. resolve: {
  10071. scope: function () {
  10072. return $scope;
  10073. },
  10074. },
  10075. backdrop: true,
  10076. });
  10077. };
  10078. // 发布
  10079. $scope.release = function (data) {
  10080. SweetAlert.swal(
  10081. {
  10082. title: "确认发布?",
  10083. text: "请确定发布操作!",
  10084. type: "warning",
  10085. showCancelButton: true,
  10086. confirmButtonColor: "#DD6B55",
  10087. confirmButtonText: "确定",
  10088. cancelButtonText: "取消",
  10089. closeOnConfirm: false,
  10090. closeOnCancel: false,
  10091. },
  10092. function (isConfirm) {
  10093. if (isConfirm) {
  10094. data.state.id = $scope.stateListData[2];
  10095. delete data.item;
  10096. api_user_data
  10097. .updData("taskSub", {
  10098. taskSub: data,
  10099. })
  10100. .then(function (res) {
  10101. if (res.status == 200) {
  10102. SweetAlert.swal({
  10103. title: "发布成功!",
  10104. type: "success",
  10105. confirmButtonColor: "#007AFF",
  10106. });
  10107. $scope.refreshData($scope.jry_filterdata);
  10108. } else {
  10109. SweetAlert.swal({
  10110. title: "删除失败",
  10111. text: "系统错误,请重试!",
  10112. type: "error",
  10113. });
  10114. }
  10115. });
  10116. } else {
  10117. SweetAlert.swal("操作取消", "发布取消", "error");
  10118. }
  10119. }
  10120. );
  10121. };
  10122. // 删除
  10123. $scope.remove = function (data) {
  10124. SweetAlert.swal(
  10125. {
  10126. title: "确认删除?",
  10127. text: "删除的数据不可恢复,请确认继续操作!",
  10128. type: "warning",
  10129. showCancelButton: true,
  10130. confirmButtonColor: "#DD6B55",
  10131. confirmButtonText: "继续删除",
  10132. cancelButtonText: "取消操作",
  10133. closeOnConfirm: false,
  10134. closeOnCancel: false,
  10135. },
  10136. function (isConfirm) {
  10137. if (isConfirm) {
  10138. api_user_data.rmvData("taskSub", [data.id]).then(function (res) {
  10139. if (res.status == 200) {
  10140. SweetAlert.swal({
  10141. title: "删除成功!",
  10142. type: "success",
  10143. confirmButtonColor: "#007AFF",
  10144. });
  10145. $scope.refreshData($scope.jry_filterdata);
  10146. } else {
  10147. SweetAlert.swal({
  10148. title: "删除失败",
  10149. text: "系统错误,请重试!",
  10150. type: "error",
  10151. });
  10152. }
  10153. });
  10154. } else {
  10155. SweetAlert.swal("操作取消", "数据安全", "error");
  10156. }
  10157. }
  10158. );
  10159. };
  10160. $scope.refreshData = function (filterData) {
  10161. // $scope.ldloading[style.replace('-', '_')] = true;
  10162. if (angular.isUndefined(filterData)) {
  10163. filterData = defaultFilterData;
  10164. }
  10165. $scope.myData = [];
  10166. $scope.memoryfilterData = filterData;
  10167. api_doc_data.fetchDataList("taskSub", filterData).then(
  10168. function (data) {
  10169. var myData = data;
  10170. $scope.gridOptions.totalItems = myData.totalNum;
  10171. $scope.removeFileNum = myData.totalNum;
  10172. if (angular.isArray(myData.list)) {
  10173. $scope.myData = myData.list;
  10174. for (var i = 0; i < $scope.myData.length; i++) {
  10175. //添加序号
  10176. $scope.myData[i]["item"] =
  10177. i + 1 + filterData.idx * filterData.sum;
  10178. $scope.myData[i].startTime = moment(
  10179. $scope.myData[i].startTime
  10180. ).format("YYYY-MM-DD HH:mm:ss");
  10181. $scope.myData[i].endTime = moment(
  10182. $scope.myData[i].endTime
  10183. ).format("YYYY-MM-DD HH:mm:ss");
  10184. }
  10185. }
  10186. },
  10187. function () {
  10188. // $scope.ldloading[style.replace('-', '_')] = false;
  10189. }
  10190. );
  10191. };
  10192. //分页控制
  10193. $scope.gridOptions.onRegisterApi = function (gridApi) {
  10194. gridApi.pagination.on.paginationChanged(
  10195. $scope,
  10196. function (newPage, pageSize) {
  10197. $scope.jry_filterdata.idx = newPage - 1;
  10198. $scope.fenye = newPage - 1;
  10199. $scope.jry_filterdata.sum = pageSize;
  10200. $scope.refreshData($scope.jry_filterdata);
  10201. }
  10202. );
  10203. };
  10204. $scope.fenye = 0;
  10205. if ($scope.model.label == "分配任务") {
  10206. $scope.jry_filterdata = {
  10207. idx: $scope.fenye,
  10208. sum: 10,
  10209. taskSub: {
  10210. taskMonth: {
  10211. id: $scope.model.taskMonth.id,
  10212. },
  10213. userid: loginUser.id,
  10214. role: loginUser.role,
  10215. },
  10216. };
  10217. } else {
  10218. $scope.jry_filterdata = {
  10219. idx: $scope.fenye,
  10220. sum: 10,
  10221. taskSub: {
  10222. taskMonth: {
  10223. id: $scope.model.taskMonth.id,
  10224. },
  10225. userid: loginUser.id,
  10226. role: loginUser.role,
  10227. type: 1,
  10228. },
  10229. };
  10230. }
  10231. $scope.refreshData($scope.jry_filterdata);
  10232. //新增模态框
  10233. $scope.newDistribution = function () {
  10234. var modalInstance = $modal.open({
  10235. backdrop: false,
  10236. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  10237. controller: function (
  10238. $scope,
  10239. scope,
  10240. $modalInstance,
  10241. api_doc_data,
  10242. SweetAlert,
  10243. api_user_data,
  10244. api_wechatfile
  10245. ) {
  10246. $scope.personData = {}; //指派人
  10247. $scope.priorityData = {}; //优先级
  10248. $scope.personListData = {}; //指派人下拉数据
  10249. $scope.priorityListData = {}; //优先级下拉数据
  10250. $scope.startTime = ""; //开始时间
  10251. $scope.endTime = ""; //结束时间
  10252. $scope.taskDescribe = ""; //任务描述
  10253. $scope.motaikuang = "";
  10254. $scope.shijian = "哈哈";
  10255. // 指派人下拉框数据
  10256. $scope.getPersonData = function () {
  10257. var data = {
  10258. idx: 0,
  10259. sum: 1000,
  10260. user: {
  10261. engineer: 1,
  10262. }
  10263. };
  10264. api_user_data.fetchDataList("user", data).then(function (res) {
  10265. $scope.personListData = res.list;
  10266. });
  10267. };
  10268. $scope.getPersonData();
  10269. //优先级下拉数据
  10270. $scope.getPriorityData = function () {
  10271. var data = {
  10272. key: "change_rick_level",
  10273. type: "list",
  10274. };
  10275. api_wechatfile.getDictionary(data).then(function (res) {
  10276. $scope.priorityListData = res;
  10277. });
  10278. };
  10279. // 控制结束时间的最大时间
  10280. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10281. // 控制结束时间的最小时间
  10282. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10283. $scope.$watch("startTime", function (n, o) {
  10284. if (n) {
  10285. if (n > scope.model.taskMonth.startTime) {
  10286. $scope.jryEndMinTime = n;
  10287. }
  10288. }
  10289. });
  10290. // 控制开始时间的最小时间
  10291. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10292. // 控制开始时间的最大时间
  10293. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10294. $scope.$watch("endTime", function (n, o) {
  10295. if (n) {
  10296. if (n < scope.model.taskMonth.endTime) {
  10297. $scope.jryStartMaxTime = n;
  10298. }
  10299. }
  10300. });
  10301. $scope.getPriorityData();
  10302. //时间控件
  10303. $scope.open = function ($event) {
  10304. $event.preventDefault();
  10305. $event.stopPropagation();
  10306. $scope.opened = !$scope.opened;
  10307. };
  10308. $scope.endOpen = function ($event) {
  10309. $event.preventDefault();
  10310. $event.stopPropagation();
  10311. $scope.startOpened = false;
  10312. $scope.endOpened = !$scope.endOpened;
  10313. };
  10314. $scope.startOpen = function ($event) {
  10315. $event.preventDefault();
  10316. $event.stopPropagation();
  10317. $scope.endOpened = false;
  10318. $scope.startOpened = !$scope.startOpened;
  10319. };
  10320. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10321. // 获取状态-lmm
  10322. $scope.stateListData = {};
  10323. $scope.getStateData = function () {
  10324. //lyl
  10325. var data = {
  10326. key: "task_sub_state",
  10327. type: "list",
  10328. };
  10329. api_wechatfile.getDictionary(data).then(function (res) {
  10330. angular.forEach(res, function (v, i) {
  10331. $scope.stateListData[v.value] = v.id;
  10332. });
  10333. });
  10334. };
  10335. $scope.getStateData();
  10336. // 草稿保存
  10337. $scope.ok = function (item) {
  10338. if (
  10339. $scope.taskDescribe &&
  10340. $scope.personData.data &&
  10341. $scope.priorityData.data &&
  10342. $scope.startTime &&
  10343. $scope.endTime
  10344. ) {
  10345. $scope.startTime = moment(
  10346. new Date($scope.startTime).getTime()
  10347. ).format("YYYY-MM-DD HH:mm:ss");
  10348. $scope.endTime = moment(
  10349. new Date($scope.endTime).getTime()
  10350. ).format("YYYY-MM-DD HH:mm:ss");
  10351. $scope.addData = {
  10352. taskSub: {
  10353. taskDescribe: $scope.taskDescribe,
  10354. assign: $scope.personData.data,
  10355. priority: $scope.priorityData.data,
  10356. startTime: $scope.startTime,
  10357. endTime: $scope.endTime,
  10358. taskMonth: {
  10359. id: scope.model.taskMonth.id,
  10360. },
  10361. },
  10362. };
  10363. $scope.addData.taskSub["state"] = {
  10364. id: $scope.stateListData[1],
  10365. };
  10366. api_user_data
  10367. .addData("taskSub", $scope.addData)
  10368. .then(function (res) {
  10369. if (res.status == 200) {
  10370. SweetAlert.swal({
  10371. title: "保存成功!",
  10372. type: "success",
  10373. confirmButtonColor: "#007AFF",
  10374. });
  10375. scope.refreshData(scope.jry_filterdata);
  10376. $modalInstance.dismiss("cancel");
  10377. } else {
  10378. SweetAlert.swal({
  10379. title: "保存失败",
  10380. text: "系统错误,请重试!",
  10381. type: "error",
  10382. });
  10383. $modalInstance.dismiss("cancel");
  10384. }
  10385. });
  10386. } else {
  10387. SweetAlert.swal({
  10388. title: "保存失败",
  10389. text: "必填项不能为空!",
  10390. type: "error",
  10391. });
  10392. }
  10393. };
  10394. // 发布
  10395. $scope.release = function () {
  10396. if (
  10397. $scope.taskDescribe &&
  10398. $scope.personData.data &&
  10399. $scope.priorityData.data &&
  10400. $scope.startTime &&
  10401. $scope.endTime
  10402. ) {
  10403. $scope.startTime = moment(
  10404. new Date($scope.startTime).getTime()
  10405. ).format("YYYY-MM-DD HH:mm:ss");
  10406. $scope.endTime = moment(
  10407. new Date($scope.endTime).getTime()
  10408. ).format("YYYY-MM-DD HH:mm:ss");
  10409. $scope.addData = {
  10410. taskSub: {
  10411. taskDescribe: $scope.taskDescribe,
  10412. assign: $scope.personData.data,
  10413. priority: $scope.priorityData.data,
  10414. startTime: $scope.startTime,
  10415. endTime: $scope.endTime,
  10416. taskMonth: {
  10417. id: scope.model.taskMonth.id,
  10418. },
  10419. },
  10420. };
  10421. $scope.addData.taskSub["state"] = {
  10422. id: $scope.stateListData[1],
  10423. };
  10424. api_user_data
  10425. .addData("taskSub", $scope.addData)
  10426. .then(function (res) {
  10427. if (res.status == 200) {
  10428. SweetAlert.swal({
  10429. title: "保存成功!",
  10430. type: "success",
  10431. confirmButtonColor: "#007AFF",
  10432. });
  10433. scope.refreshData(scope.jry_filterdata);
  10434. $modalInstance.dismiss("cancel");
  10435. } else {
  10436. SweetAlert.swal({
  10437. title: "保存失败",
  10438. text: "系统错误,请重试!",
  10439. type: "error",
  10440. });
  10441. $modalInstance.dismiss("cancel");
  10442. }
  10443. });
  10444. } else {
  10445. SweetAlert.swal({
  10446. title: "保存失败",
  10447. text: "必填项不能为空!",
  10448. type: "error",
  10449. });
  10450. }
  10451. };
  10452. $scope.cancel = function () {
  10453. $modalInstance.dismiss("cancel");
  10454. };
  10455. },
  10456. size: "sm",
  10457. resolve: {
  10458. scope: function () {
  10459. return $scope;
  10460. },
  10461. },
  10462. backdrop: true,
  10463. });
  10464. };
  10465. },
  10466. });
  10467. // 多次反馈文本域组件--jry
  10468. formlyConfigProvider.setType({
  10469. name: "ui-feedbacktTextarea",
  10470. extends: "textarea",
  10471. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10472. defaultOptions: function (options) {
  10473. return {
  10474. templateOptions: {
  10475. transform: function (model, value) {
  10476. return value;
  10477. },
  10478. },
  10479. validation: {
  10480. messages: {
  10481. maxlength: function (viewValue, modelValue, scope) {
  10482. if (viewValue != null) {
  10483. if (viewValue.length > scope.to.maxlength) {
  10484. return (
  10485. scope.to.label +
  10486. " 字数(" +
  10487. viewValue.length +
  10488. ")超限(" +
  10489. scope.to.maxlength +
  10490. ")"
  10491. );
  10492. } else {
  10493. return "";
  10494. }
  10495. }
  10496. },
  10497. },
  10498. },
  10499. };
  10500. },
  10501. controller: [
  10502. "$scope",
  10503. "moment",
  10504. function ($scope, moment) {
  10505. // console.log($scope);
  10506. var timeKey = $scope.options.templateOptions.time;
  10507. $scope.time = moment($scope.model[timeKey]).format(
  10508. "YYYY-MM-DD HH:mm:ss"
  10509. );
  10510. var value = $scope.model[$scope.options.key];
  10511. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10512. $scope.model[$scope.options.key] =
  10513. $scope.options.templateOptions.transform(
  10514. $scope.originalModel,
  10515. value
  10516. );
  10517. }
  10518. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10519. $scope.options.templateOptions.felditem($scope);
  10520. }
  10521. },
  10522. ],
  10523. });
  10524. //任务管理开始时间--jry
  10525. formlyConfigProvider.setType({
  10526. name: "ui-jryStartdatepicker",
  10527. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10528. extends: "input",
  10529. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10530. defaultOptions: {
  10531. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10532. templateOptions: {
  10533. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10534. },
  10535. },
  10536. controller: [
  10537. "$scope",
  10538. "$filter",
  10539. function ($scope, $filter) {
  10540. // console.log($scope.model[$scope.options.key],'lmm');
  10541. $scope.mindata = new Date(
  10542. $scope.options.templateOptions.transform($scope.model).getTime() +
  10543. 5 * 60 * 1000
  10544. );
  10545. if ($scope.model[$scope.options.key]) {
  10546. $scope.model[$scope.options.key] = $filter("date")(
  10547. $scope.model[$scope.options.key],
  10548. $scope.options.templateOptions.datepickerPopup
  10549. );
  10550. }
  10551. // console.log($scope.model[$scope.options.key],'lmm');
  10552. // console.log($scope.model,'lmm',$scope.options.key);
  10553. $scope.options.initialValue = $scope.model[$scope.options.key];
  10554. $scope.endOpen = true;
  10555. $scope.datepicker = {};
  10556. $scope.datepicker.opened = false;
  10557. $scope.datepicker.open = function ($event) {
  10558. $scope.datepicker.opened = true;
  10559. };
  10560. },
  10561. ],
  10562. });
  10563. //任务管理结束时间--jry
  10564. formlyConfigProvider.setType({
  10565. name: "ui-jryEnddatepicker",
  10566. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10567. extends: "input",
  10568. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10569. defaultOptions: {
  10570. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10571. templateOptions: {
  10572. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10573. },
  10574. },
  10575. controller: [
  10576. "$scope",
  10577. "$filter",
  10578. function ($scope, $filter) {
  10579. $scope.mindata = new Date(
  10580. $scope.options.templateOptions.transform($scope.model).getTime() +
  10581. 5 * 60 * 1000
  10582. );
  10583. if ($scope.model[$scope.options.key]) {
  10584. $scope.model[$scope.options.key] = $filter("date")(
  10585. $scope.model[$scope.options.key],
  10586. $scope.options.templateOptions.datepickerPopup
  10587. );
  10588. }
  10589. $scope.options.initialValue = $scope.model[$scope.options.key];
  10590. $scope.endOpen = true;
  10591. $scope.datepicker = {};
  10592. $scope.datepicker.opened = false;
  10593. $scope.datepicker.open = function ($event) {
  10594. $scope.datepicker.opened = true;
  10595. };
  10596. },
  10597. ],
  10598. });
  10599. //下拉多选框灵活组件--jry
  10600. formlyConfigProvider.setType({
  10601. name: "ui-jry_multiselectplus",
  10602. extends: "multiCheckbox",
  10603. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10604. defaultOptions: function (options) {
  10605. return {
  10606. templateOptions: {
  10607. refreshData: function (search, options, model, that) {
  10608. // var process = options.templateOptions.ApiService.all("");
  10609. if (search) {
  10610. } else {
  10611. }
  10612. var postData = options.templateOptions.optionsPostData;
  10613. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10614. postData = options.templateOptions.optionsPostData(
  10615. options,
  10616. model,
  10617. that
  10618. );
  10619. }
  10620. options.templateOptions.ApiService.fetchDataList(
  10621. options.templateOptions.optionsUrl,
  10622. options.templateOptions.optionsPostData
  10623. ).then(function (result) {
  10624. // if (!options.templateOptions.options) {
  10625. // options.templateOptions.options = [];
  10626. // }
  10627. if (options.templateOptions.optionsDataKey) {
  10628. options.templateOptions.options =
  10629. result[options.templateOptions.optionsDataKey];
  10630. } else {
  10631. options.templateOptions.options = result;
  10632. }
  10633. if (options.templateOptions.optionsChecked) {
  10634. // return options.value = null;
  10635. options.value(options.model[options.key]);
  10636. }
  10637. });
  10638. },
  10639. refreshDelay: 0,
  10640. // },
  10641. validators: {
  10642. required: {
  10643. expression: function (viewValue, modelValue) {
  10644. var value = modelValue || viewValue;
  10645. return value != null;
  10646. // return value.length>=1;
  10647. // if (modelValue && viewValue) {
  10648. // return value != null;
  10649. // } else {
  10650. // var value = modelValue || viewValue;
  10651. // return value.length > 0;
  10652. // }
  10653. },
  10654. },
  10655. },
  10656. },
  10657. };
  10658. },
  10659. controller: [
  10660. "$scope",
  10661. function ($scope) {
  10662. console.log($scope.to);
  10663. if (angular.isArray($scope.model[$scope.options.key])) {
  10664. } else {
  10665. $scope.model[$scope.options.key] = [];
  10666. }
  10667. },
  10668. ],
  10669. });
  10670. //下拉框组件
  10671. formlyConfigProvider.setType({
  10672. name: "ui-select",
  10673. extends: "select",
  10674. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10675. defaultOptions: function (options, scope) {
  10676. return {
  10677. templateOptions: {
  10678. // refresh: function() {},
  10679. getScope: function () {
  10680. return scope;
  10681. },
  10682. refreshDelay: 0,
  10683. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10684. //POST
  10685. console.log(model, "model");
  10686. angular.extend(data, {
  10687. idx: 0,
  10688. sum: 1000,
  10689. });
  10690. options.templateOptions.APIService.fetchDataList(
  10691. modelName,
  10692. data
  10693. ).then(function (response) {
  10694. var myData =
  10695. options.templateOptions.Restangular.stripRestangular(response);
  10696. var list = myData.list;
  10697. console.log(myData);
  10698. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10699. // console.log('balabalabala');
  10700. // console.log(res);
  10701. // })
  10702. if (list.length == 1) {
  10703. if (options.templateOptions.APIport) {
  10704. options.templateOptions.APIport.expectedTime(
  10705. "L" + list[0][key].id
  10706. ).then(function (response) {
  10707. if (response.state == "200") {
  10708. // if (model.$parent.model && model.$parent.model.incident) {
  10709. // } else {
  10710. // model.$parent.model = { 'incident': {} };
  10711. // }
  10712. var myDatas = response.serviceLevelAgreement;
  10713. //逾期
  10714. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10715. response.date;
  10716. //解决
  10717. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10718. myDatas.resolveTime;
  10719. //响应
  10720. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10721. myDatas.responseTime;
  10722. } else {
  10723. }
  10724. });
  10725. }
  10726. angular.forEach(model.fields, function (item) {
  10727. angular.forEach(model.fields, function (item) {
  10728. if (item.templateOptions.pkey == modelKey + "." + key) {
  10729. item.model.id = "";
  10730. if (key == "place") {
  10731. item.templateOptions.options = list;
  10732. } else if (key == "placeDTO") {
  10733. item.templateOptions.options = list;
  10734. } else if (key == "requester") {
  10735. } else {
  10736. item.value(list[0][key][item.key]);
  10737. }
  10738. }
  10739. });
  10740. });
  10741. } else {
  10742. if (model.fields) {
  10743. angular.forEach(model.fields, function (item) {
  10744. angular.forEach(model.fields, function (item) {
  10745. if (item.templateOptions.pkey == modelKey + "." + key) {
  10746. item.model.id = "";
  10747. if (key == "place") {
  10748. item.templateOptions.isnosearch = true;
  10749. item.templateOptions.options = list;
  10750. }
  10751. if (key == "placeDTO") {
  10752. item.templateOptions.options = list;
  10753. }
  10754. if (key == "requester") {
  10755. }
  10756. if (key == "room") {
  10757. item.templateOptions.options = list;
  10758. }
  10759. }
  10760. });
  10761. });
  10762. } else {
  10763. angular.forEach(
  10764. scope.$parent.$parent.$parent.fields,
  10765. function (item) {
  10766. angular.forEach(
  10767. scope.$parent.$parent.$parent.fields,
  10768. function (item) {
  10769. if (
  10770. item.templateOptions.pkey ==
  10771. modelKey + "." + key
  10772. ) {
  10773. if (key == "place") {
  10774. item.templateOptions.isnosearch = true;
  10775. item.templateOptions.options = list;
  10776. scope.$parent.$parent.$parent.model.incident.place =
  10777. model.incident.place;
  10778. }
  10779. if (key == "placeDTO") {
  10780. item.templateOptions.options = list;
  10781. }
  10782. if (key == "requester") {
  10783. }
  10784. }
  10785. }
  10786. );
  10787. }
  10788. );
  10789. }
  10790. }
  10791. console.log(key);
  10792. //报修科室
  10793. if (key == "dept") {
  10794. // 报修科室单选
  10795. scope.$parent.$parent.$parent.model.incident.department =
  10796. response.list[0];
  10797. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10798. response.list[0].phone;
  10799. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10800. // 选择重复事件侧滑框
  10801. scope.$parent.$parent.$parent.model[
  10802. "repeatIncidentShow"
  10803. ] = false;
  10804. setTimeout(() => {
  10805. scope.$parent.$parent.$parent.model[
  10806. "repeatIncidentShow"
  10807. ] = true;
  10808. }, 500);
  10809. }
  10810. // 报修人
  10811. if (key == "requester") {
  10812. // 报修人单选
  10813. scope.$parent.$parent.$parent.model.incident.requester =
  10814. response.list[0];
  10815. console.log(scope.$parent.$parent.$parent.model);
  10816. scope.$parent.$parent.$parent.model.incident.account =
  10817. response.list[0].account;
  10818. var selectedItem = response.list[0];
  10819. var data = {
  10820. requester: selectedItem,
  10821. };
  10822. scope.$parent.$parent.$parent.model["requestershow"] =
  10823. selectedItem;
  10824. console.log(selectedItem, "----------------------");
  10825. // if (selectedItem.dept.place.place) {
  10826. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10827. // }
  10828. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10829. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10830. scope.$parent.$parent.$parent.model.incident.area.id =
  10831. selectedItem.place ? selectedItem.place.area.id : null;
  10832. scope.$parent.$parent.$parent.model.incident.place.id =
  10833. selectedItem.place ? selectedItem.place.id : null;
  10834. if(scope.$parent.$parent.$parent.model.incident.area.id){
  10835. options.templateOptions.APIService.fetchDataList(
  10836. 'place',
  10837. {"place":{"areaId":scope.$parent.$parent.$parent.model.incident.area.id},"idx":0,"sum":1000}
  10838. ).then(function (response1) {
  10839. for (var i = 0; i < scope.fields.length; i++) {
  10840. if(scope.fields[i].templateOptions.onlyKey == 'place_start'){
  10841. scope.fields[i].templateOptions.options = response1.status == 200?response1.list:[];
  10842. }
  10843. }
  10844. })
  10845. }
  10846. console.log(scope, 89898998);
  10847. // console.log(scope.formData,'接单页面');
  10848. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10849. scope.model.selecthouseNumber = selectedItem.place
  10850. ? selectedItem.place
  10851. : {};
  10852. scope.$root.selecthouseNumber = selectedItem.place
  10853. ? selectedItem.place
  10854. : {};
  10855. // options.templateOptions.ApiService.addData(
  10856. // "requester",
  10857. // data
  10858. // ).then(function (response) {
  10859. // if (response.status == 200) {
  10860. if (scope.$parent.$parent.$parent) {
  10861. if (scope.$parent.$parent.$parent.place) {
  10862. scope.$parent.$parent.$parent.place.id = "";
  10863. }
  10864. if (scope.$parent.$parent.$parent.area) {
  10865. scope.$parent.$parent.$parent.area.id = "";
  10866. }
  10867. scope.$parent.$parent.$parent.model.incident.contacts =
  10868. selectedItem.name;
  10869. if (
  10870. selectedItem.phone &&
  10871. selectedItem.phone != null &&
  10872. selectedItem.phone != ""
  10873. ) {
  10874. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10875. selectedItem.phone;
  10876. } else {
  10877. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10878. selectedItem.telephone;
  10879. }
  10880. if (
  10881. selectedItem.requesterTypeDTO &&
  10882. selectedItem.requesterTypeDTO.id == 2
  10883. ) {
  10884. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10885. }
  10886. }
  10887. // if (!response.data.id) {
  10888. // response.data.id = selectedItem.id;
  10889. // }
  10890. console.log(scope);
  10891. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10892. // if (selectedItem.place && selectedItem.place.id) {
  10893. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10894. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10895. // };
  10896. // } else {
  10897. // if (selectedItem.place && selectedItem.place.id) {
  10898. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10899. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10900. // };
  10901. // }
  10902. // if(scope.$parent.$parent.$parent.model.incident.area){
  10903. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10904. // }
  10905. if (selectedItem.id) {
  10906. scope.$parent.$parent.$parent.model.incident.account =
  10907. selectedItem.account;
  10908. }
  10909. // 选择重复事件侧滑框
  10910. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10911. scope.$parent.$parent.$parent.model[
  10912. "repeatIncidentShow"
  10913. ] = false;
  10914. setTimeout(() => {
  10915. scope.$parent.$parent.$parent.model[
  10916. "repeatIncidentShow"
  10917. ] = true;
  10918. }, 500);
  10919. // }
  10920. // }
  10921. // });
  10922. }
  10923. //新建事件,选择派单,选择工作组查找处理人baba
  10924. if (key == "handlerUser") {
  10925. model.fields.forEach(function (v) {
  10926. if (v.templateOptions.pkey == "incident.handlerUser") {
  10927. v.templateOptions.options = list;
  10928. if (model.model.incident.handlerUser) {
  10929. if (model.model.incident.handlerUser.id) {
  10930. var flag = list.some(function (v) {
  10931. return v.id == model.model.incident.handlerUser.id;
  10932. });
  10933. if (flag) {
  10934. v.model.id = model.model.incident.handlerUser.id;
  10935. }
  10936. }
  10937. }
  10938. }
  10939. });
  10940. }
  10941. });
  10942. },
  10943. validators: {
  10944. required: {
  10945. expression: function (viewValue, modelValue) {
  10946. var value = modelValue || viewValue;
  10947. return value != null;
  10948. // return value.length>=1;
  10949. // if (modelValue && viewValue) {
  10950. // return value != null;
  10951. // } else {
  10952. // var value = modelValue || viewValue;
  10953. // return value.length > 0;
  10954. // }
  10955. },
  10956. },
  10957. },
  10958. },
  10959. controller: [
  10960. "$scope",
  10961. "$rootScope",
  10962. "api_bpm_domain",
  10963. "$stateParams",
  10964. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10965. // $scope.myFilter = function(item) {
  10966. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10967. // }
  10968. console.log($scope, "风浪");
  10969. if($scope.to.onlyKey === 'inspection.dictionary'){
  10970. //巡检列表-新增-巡检类型baba
  10971. console.log(location)
  10972. var loc = location.href.split('api_bpm_data')[1] || '';
  10973. if(loc.length <= 2){
  10974. // 新增轮询计划的时候
  10975. $scope.model.id = 1715;//默认系统默认
  10976. }
  10977. }
  10978. //工作组添加全部选项
  10979. // if($scope.options.templateOptions.label == '工作组'){
  10980. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  10981. // $scope.model._group = 0;
  10982. // }
  10983. if (
  10984. $scope.options.templateOptions.pkey &&
  10985. $scope.options.templateOptions.pkey == "incident.place"
  10986. ) {
  10987. if (
  10988. $scope.$parent &&
  10989. $scope.$parent.$parent.$parent.model &&
  10990. $scope.$parent.$parent.$parent.model.incident.area &&
  10991. $scope.$parent.$parent.$parent.model.incident.area.id
  10992. ) {
  10993. $scope.options.templateOptions.linkage(
  10994. "place",
  10995. {
  10996. place: {
  10997. areaId:
  10998. $scope.$parent.$parent.$parent.model.incident.area.id,
  10999. // area:{
  11000. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  11001. // }
  11002. },
  11003. },
  11004. $scope.$parent.$parent.$parent.model,
  11005. "incident",
  11006. "place"
  11007. );
  11008. }
  11009. }
  11010. $scope.myFilter = $scope;
  11011. // console.log($scope.options.templateOptions)
  11012. console.log($scope, 77777);
  11013. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  11014. var paramsModel = JSON.parse($stateParams.model)
  11015. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  11016. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  11017. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  11018. }
  11019. }
  11020. //处理人根据故障现象自动带入baba
  11021. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  11022. console.log($scope.options.templateOptions.pkey);
  11023. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  11024. if (
  11025. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  11026. ) {
  11027. $scope.$parent.$parent.$parent.model.assignee =
  11028. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11029. $scope.options.model.id =
  11030. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11031. }
  11032. }
  11033. }
  11034. // 关闭事件页面满意度评价下拉框处理
  11035. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  11036. $scope.model.id =
  11037. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  11038. }
  11039. if ($scope.options.templateOptions.initData == 1) {
  11040. $scope.options.templateOptions.onChange(
  11041. $scope.model.id,
  11042. $scope.options,
  11043. $scope
  11044. );
  11045. }
  11046. if ($scope.options.templateOptions.transform) {
  11047. $scope.options.templateOptions.onChange(
  11048. $scope.model.id,
  11049. $scope.options,
  11050. $scope
  11051. );
  11052. }
  11053. if (angular.isFunction($scope.options.templateOptions.translate)) {
  11054. $scope.model[$scope.options.key] =
  11055. $scope.options.templateOptions.translate(
  11056. $scope.options,
  11057. $rootScope,
  11058. $scope
  11059. );
  11060. }
  11061. if (
  11062. angular.isFunction($scope.options.templateOptions.translatefunc)
  11063. ) {
  11064. $scope.model[$scope.options.key] =
  11065. $scope.options.templateOptions.translatefunc(
  11066. $scope.options,
  11067. $rootScope,
  11068. $scope
  11069. );
  11070. }
  11071. if (
  11072. angular.isFunction($scope.options.templateOptions.onlyfunction)
  11073. ) {
  11074. $scope.options.templateOptions.onlyfunction(
  11075. $scope.options,
  11076. $rootScope,
  11077. $scope
  11078. );
  11079. }
  11080. },
  11081. ],
  11082. };
  11083. },
  11084. });
  11085. //下拉框组件(巡检计划-查看)
  11086. formlyConfigProvider.setType({
  11087. name: "ui-select-xj",
  11088. extends: "select",
  11089. templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
  11090. defaultOptions: function (options, scope) {
  11091. return {
  11092. templateOptions: {
  11093. getScope: function () {
  11094. return scope;
  11095. },
  11096. refreshDelay: 0,
  11097. validators: {
  11098. required: {
  11099. expression: function (viewValue, modelValue) {
  11100. var value = modelValue || viewValue;
  11101. return value != null;
  11102. },
  11103. },
  11104. },
  11105. },
  11106. controller: [
  11107. "$scope",
  11108. "$rootScope",
  11109. "api_bpm_domain",
  11110. "$stateParams",
  11111. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  11112. $scope.model[$scope.options.key] = '0';//默认全部
  11113. var arr = [];
  11114. if($scope.model.inspection.batchNos){
  11115. arr = $scope.model.inspection.batchNos.map(v=>({value:v,name:v}));
  11116. }
  11117. arr.unshift({value:'0',name:'全部'});
  11118. $scope.options.templateOptions.options = arr;
  11119. console.log($scope)
  11120. // ts.$parent.fields.forEach(v=>{
  11121. // if(v.templateOptions.onlyKey === "batchNos"){
  11122. // //巡检计划-批次号
  11123. // var batchNos = $scope.model.batchNos === "0"?"":$scope.model.batchNos;
  11124. // v.templateOptions.getScope().refreshData(batchNos)
  11125. // }
  11126. // })
  11127. // ts.$parent.fields.forEach(v=>{if(v.templateOptions.onlyKey === "batchNos"){var batchNos = item == "0"?"":item;v.templateOptions.getScope().refreshData(batchNos);}})
  11128. // console.log($scope.options)
  11129. // console.log($scope.model)
  11130. },
  11131. ],
  11132. };
  11133. },
  11134. });
  11135. //下拉多选框组件
  11136. formlyConfigProvider.setType({
  11137. name: "ui-multiselect",
  11138. extends: "select",
  11139. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11140. defaultOptions: function (options, $scope) {
  11141. return {
  11142. templateOptions: {
  11143. getLoginUser: function () {
  11144. return $scope.$root.user;
  11145. },
  11146. refresh: function () { },
  11147. refreshDelay: 1000,
  11148. },
  11149. };
  11150. },
  11151. controller: [
  11152. "$scope",
  11153. function ($scope) {
  11154. $scope.model[$scope.options.key] = [];
  11155. },
  11156. ],
  11157. });
  11158. //下拉多选全选组件
  11159. formlyConfigProvider.setType({
  11160. name: "ui-isteven",
  11161. extends: "select",
  11162. templateUrl: "assets/views/customform/tpl/ui-isteven.html",
  11163. defaultOptions: function (options,$scope) {
  11164. return {
  11165. templateOptions: {
  11166. refresh: function () {
  11167. console.log(options)
  11168. options.templateOptions
  11169. .refreshData(options.templateOptions.APIService)
  11170. .then(function (result) {
  11171. if(result.status == 200){
  11172. console.log(result.list)
  11173. //树形结构转换
  11174. function formatDataTree2(json){
  11175. var _json = JSON.parse(JSON.stringify(json));
  11176. return _json.filter(p=>{
  11177. var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
  11178. _arr.length && (p.children = _arr);
  11179. return !p.parent;
  11180. })
  11181. }
  11182. console.log(result.list)
  11183. var list = formatDataTree2(result.list);
  11184. console.log(list)
  11185. // $scope.treeList = angular.copy(list);
  11186. var resultList = [];
  11187. //转换数据
  11188. function trasData(list,obj){
  11189. if(obj){
  11190. //有父级
  11191. list.forEach(v=>{
  11192. var type = "<strong>"+ v.parent.type +"</strong>";//父级type
  11193. var i = resultList.findIndex(c=>c.type == type);
  11194. if(v.children){
  11195. resultList.splice(i+1,0,{
  11196. type: "<strong>"+ v.type +"</strong>",
  11197. msId: v.id,
  11198. msGroup: true,
  11199. },{msGroup: false})
  11200. trasData(v.children,v);
  11201. }else{
  11202. resultList.splice(i+1,0,{...v,...{ticked:false}});
  11203. }
  11204. })
  11205. }else{
  11206. //顶级
  11207. list.forEach(v=>{
  11208. if(v.children){
  11209. resultList.push({
  11210. type: "<strong>"+ v.type +"</strong>",
  11211. msId: v.id,
  11212. msGroup: true,
  11213. },{msGroup: false})
  11214. trasData(v.children,v);
  11215. }else{
  11216. resultList.push(...v,...{ticked:false});
  11217. }
  11218. })
  11219. }
  11220. return resultList;
  11221. }
  11222. var __arr = trasData(list,null);
  11223. // console.log(__arr,options.model.typeIds.split(','))
  11224. if(options.model.typeIds){
  11225. //有巡检类型,则需要回显
  11226. __arr.forEach(w=>{
  11227. w.ticked = options.model.typeIds.split(',').includes(w.id+'');
  11228. })
  11229. }
  11230. $scope.webBrowsersGrouped = __arr;
  11231. console.log($scope.webBrowsersGrouped);
  11232. }
  11233. })
  11234. },
  11235. refreshDelay: 1000,
  11236. },
  11237. };
  11238. },
  11239. controller: [
  11240. "$scope",
  11241. function ($scope) {
  11242. console.log($scope)
  11243. $scope.to.refresh();//获取列表数据
  11244. // $scope.model[$scope.options.key] = [];
  11245. //单项点击或菜单
  11246. $scope.fClick = function(data){
  11247. console.log($scope.outputBrowsers)
  11248. $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
  11249. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11250. // if(data.id){
  11251. // //单项点击
  11252. // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
  11253. // //有巡检类型
  11254. // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
  11255. // if(data.ticked){
  11256. // arr.push(data.id);
  11257. // }else{
  11258. // arr = arr.filter(v=>v != data.id);
  11259. // }
  11260. // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11261. // }else{
  11262. // //无巡检类型
  11263. // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
  11264. // if(data.ticked){
  11265. // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
  11266. // }else{
  11267. // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11268. // }
  11269. // }
  11270. // }else{
  11271. // // 菜单点击
  11272. // console.log($scope.webBrowsersGrouped,data.msId);
  11273. // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
  11274. // return v.parent?v.parent.id == data.msId:false;
  11275. // })
  11276. // if(treeResultArr.every(v=>v.ticked)){
  11277. // //全部都是true的情况下,需要移除,否则增加
  11278. // }
  11279. // console.log(treeResultArr)
  11280. // // --------------------------------------
  11281. // // var treeArr = [];
  11282. // // function findParent(treeList){
  11283. // // treeList.forEach(v=>{
  11284. // // if(v.id == data.msId){
  11285. // // treeArr = v.children;
  11286. // // }else{
  11287. // // if(v.children){
  11288. // // findParent(v.children);
  11289. // // }
  11290. // // }
  11291. // // })
  11292. // // return treeArr;
  11293. // // }
  11294. // // var treeResultArr = findParent($scope.treeList);
  11295. // // console.log(treeResultArr)
  11296. // // -----------------------------------
  11297. // }
  11298. }
  11299. // 全选
  11300. $scope.fSelectAll = function(){
  11301. // console.log($scope.webBrowsersGrouped)
  11302. var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
  11303. // console.log(arr);
  11304. $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11305. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11306. }
  11307. // 全不选
  11308. $scope.fSelectNone = function(){
  11309. $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11310. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11311. }
  11312. // 配置信息
  11313. $scope.outputBrowsers = [];
  11314. $scope.localLang = {
  11315. selectAll: "全选",
  11316. selectNone: "全不选",
  11317. nothingSelected: "请选择"
  11318. }
  11319. },
  11320. ],
  11321. });
  11322. //下拉多选框灵活组件
  11323. formlyConfigProvider.setType({
  11324. name: "ui-multiselectplus",
  11325. extends: "multiCheckbox",
  11326. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11327. defaultOptions: function (options, $scope) {
  11328. return {
  11329. templateOptions: {
  11330. getLoginUser: function () {
  11331. return $scope.$root.user;
  11332. },
  11333. refreshData: function (search, options, model, that) {
  11334. console.log(search, options, model, that)
  11335. var process = options.templateOptions.ApiService.all("");
  11336. if (search) {
  11337. } else {
  11338. }
  11339. var postData = options.templateOptions.optionsPostData;
  11340. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11341. postData = options.templateOptions.optionsPostData(
  11342. options,
  11343. model,
  11344. that
  11345. );
  11346. }
  11347. if (options.templateOptions.modelreasondata) {
  11348. postData = options.templateOptions.modelreasondata;
  11349. }
  11350. if (options.templateOptions.isnosearch) {
  11351. return;
  11352. }
  11353. process
  11354. .customPOST(postData, options.templateOptions.optionsUrl)
  11355. .then(function (result) {
  11356. // if (!options.templateOptions.options) {
  11357. // options.templateOptions.options = [];
  11358. // }
  11359. // 过滤下拉列表已选择的值
  11360. var modelVal = $scope.model[$scope.options.key];
  11361. var ides = [];
  11362. var rList = result.list || result;
  11363. if ($scope.options.key == "serviceTypeIds") {
  11364. modelVal = modelVal.map(function (v) {
  11365. if (typeof v !== 'object') {
  11366. return { id: v };
  11367. } else {
  11368. return v;
  11369. }
  11370. })
  11371. }
  11372. for (var i = 0; i < modelVal.length; i++) {
  11373. for (var j = 0; j < rList.length; j++) {
  11374. if (rList[j].id == modelVal[i].id) {
  11375. ides.push(rList[j].id);
  11376. }
  11377. }
  11378. }
  11379. ides.forEach(function (v1) {
  11380. rList.forEach(function (v2) {
  11381. if (v1 == v2.id) {
  11382. rList = rList.filter(v => v.id != v2.id);
  11383. }
  11384. })
  11385. })
  11386. options.templateOptions.options = rList;
  11387. // if (options.templateOptions.optionsDataKey) {
  11388. // options.templateOptions.options =
  11389. // result[options.templateOptions.optionsDataKey];
  11390. // } else {
  11391. // options.templateOptions.options = result;
  11392. // }
  11393. if (options.templateOptions.optionsChecked) {
  11394. // return options.value = null;
  11395. options.value(options.model[options.key]);
  11396. }
  11397. });
  11398. },
  11399. refreshDelay: 0,
  11400. // },
  11401. // validators: {
  11402. // required: {
  11403. // expression: function(viewValue, modelValue) {
  11404. // var value = modelValue || viewValue;
  11405. // // return value.length>=1;
  11406. // // if (modelValue && viewValue) {
  11407. // // return value != null;
  11408. // // } else {
  11409. // // var value = modelValue || viewValue;
  11410. // // return value.length > 0;
  11411. // // }
  11412. // }
  11413. // }
  11414. },
  11415. };
  11416. },
  11417. controller: [
  11418. "$scope",
  11419. function ($scope) {
  11420. if (angular.isArray($scope.model[$scope.options.key])) {
  11421. } else {
  11422. $scope.model[$scope.options.key] = [];
  11423. }
  11424. },
  11425. ],
  11426. });
  11427. //下拉树形多选组件
  11428. formlyConfigProvider.setType({
  11429. name: "ui-multiselect-tree",
  11430. extends: "multiCheckbox",
  11431. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11432. defaultOptions: function (options) {
  11433. return {
  11434. templateOptions: {
  11435. linkage: function (modelName, data, model, modelKey, key) {
  11436. angular.extend(data, {
  11437. idx: 0,
  11438. sum: 10,
  11439. });
  11440. options.templateOptions.APIService.fetchDataList(
  11441. modelName,
  11442. data
  11443. ).then(function (response) {
  11444. var myData =
  11445. options.templateOptions.Restangular.stripRestangular(response);
  11446. var list = myData.list;
  11447. if (list.length == 1) {
  11448. angular.forEach(model.fields, function (item) {
  11449. angular.forEach(model.fields, function (item) {
  11450. if (item.templateOptions.pkey == modelKey + "." + key) {
  11451. item.model.id = "";
  11452. if (key == "place") {
  11453. item.templateOptions.options = list;
  11454. } else {
  11455. item.value(list[0][key][item.key]);
  11456. }
  11457. }
  11458. });
  11459. });
  11460. }
  11461. });
  11462. },
  11463. // my_tree_handler : function(items) {
  11464. // },
  11465. // onFilterCallback : function(items) {
  11466. // },
  11467. // onFilterCallback : function(items) {
  11468. // },
  11469. refresh: function (items) {
  11470. var treedata = [];
  11471. function convertListToTree(data, treeMap) {
  11472. treedata = data;
  11473. for (var i = 0; i < data.length; i++) {
  11474. for (var j = 0; j < data.length; j++) {
  11475. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11476. if (data[i].pid == data[j].id) {
  11477. data[i].parent = data[j];
  11478. }
  11479. }
  11480. }
  11481. }
  11482. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11483. var root = null; //Initially set our loop to null
  11484. //loop over data
  11485. for (var i = 0; i < data.length; i++) {
  11486. var datum = data[i];
  11487. //each node will have children, so let's give it a "children" poperty
  11488. datum.children = [];
  11489. //add an entry for this node to the map so that any future children can
  11490. //lookup the parent
  11491. idToNodeMap[datum.id] = datum;
  11492. //Does this node have a parent?
  11493. if (
  11494. typeof datum.parent === "undefined" ||
  11495. datum.parent === null
  11496. ) {
  11497. //Doesn't look like it, so this node is the root of the tree
  11498. root = datum;
  11499. treeMap[datum.id] = root;
  11500. } else {
  11501. //This node has a parent, so let's look it up using the id
  11502. parentNode = idToNodeMap[datum.parent.id];
  11503. //We don't need this property, so let's delete it.
  11504. delete datum.parent;
  11505. //Let's add the current node as a child of the parent node.
  11506. parentNode.children.push(datum);
  11507. }
  11508. }
  11509. return root;
  11510. }
  11511. function convertParentToChildList(data) {
  11512. // console.log("data="+JSON.stringify(data))
  11513. var treeMap = {};
  11514. var list = [];
  11515. convertListToTree(data, treeMap);
  11516. angular.forEach(treeMap, function (item) {
  11517. list.push(item);
  11518. });
  11519. return list;
  11520. }
  11521. function selectItem(pmodel, childrens) {
  11522. if (angular.isArray(pmodel)) {
  11523. angular.forEach(pmodel, function (index) {
  11524. if (index && index.id) {
  11525. angular.forEach(childrens, function (item) {
  11526. if (item.id == index.id) {
  11527. item.selected = true;
  11528. }
  11529. if (item && item.children) {
  11530. selectItem(pmodel, item.children);
  11531. }
  11532. });
  11533. }
  11534. });
  11535. } else {
  11536. if (pmodel && pmodel.id) {
  11537. angular.forEach(childrens, function (item) {
  11538. if (item.id == pmodel.id) {
  11539. item.selected = true;
  11540. }
  11541. if (item && item.children) {
  11542. selectItem(pmodel, item.children);
  11543. }
  11544. });
  11545. }
  11546. }
  11547. }
  11548. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11549. options.templateOptions
  11550. .refreshData(options.templateOptions.APIService)
  11551. .then(function (result) {
  11552. if (result.status == 200) {
  11553. if (!options.templateOptions.options) {
  11554. options.templateOptions.options = [];
  11555. }
  11556. if (options.templateOptions.optionsDataKey) {
  11557. options.templateOptions.options = convertParentToChildList(
  11558. result[options.templateOptions.optionsDataKey]
  11559. );
  11560. } else {
  11561. options.templateOptions.options =
  11562. convertParentToChildList(result);
  11563. }
  11564. //set default value
  11565. var pmodel,
  11566. i = 0;
  11567. if (options.templateOptions.pkey) {
  11568. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11569. angular.forEach(
  11570. options.templateOptions.pkey.split("."),
  11571. function (p) {
  11572. if (i == 0) {
  11573. if (options.model[p] == null) {
  11574. options.model[p] = {};
  11575. }
  11576. pmodel = options.model[p];
  11577. i++;
  11578. } else {
  11579. if (pmodel[p] == null) {
  11580. pmodel[p] = {};
  11581. }
  11582. pmodel = pmodel[p];
  11583. }
  11584. }
  11585. );
  11586. } else {
  11587. pmodel = options.model;
  11588. }
  11589. }
  11590. if (pmodel) {
  11591. pmodel = pmodel[options.key];
  11592. } else if (options.model) {
  11593. pmodel = options.model[options.key];
  11594. } else {
  11595. pmodel = options.templateOptions.options;
  11596. }
  11597. if (angular.isArray(pmodel)) {
  11598. if (pmodel) {
  11599. // if(options.templateOptions.isMultiSelect==true){
  11600. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11601. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11602. // })
  11603. // }else{
  11604. selectItem(pmodel, options.templateOptions.options);
  11605. // }
  11606. }
  11607. } else {
  11608. if (pmodel && pmodel.id) {
  11609. selectItem(pmodel, options.templateOptions.options);
  11610. }
  11611. }
  11612. items.inputModel = options.templateOptions.options;
  11613. }
  11614. });
  11615. },
  11616. },
  11617. validators: {
  11618. required: {
  11619. expression: function (viewValue, modelValue) {
  11620. var value = modelValue || viewValue;
  11621. if (angular.isArray(value)) {
  11622. for (var i = 0; i < value.length; i++) {
  11623. value[i] = {
  11624. id: value[i].id,
  11625. };
  11626. }
  11627. return value.length > 0;
  11628. } else {
  11629. // console.log(options)
  11630. // return value = "true";
  11631. return value != null;
  11632. }
  11633. },
  11634. },
  11635. },
  11636. };
  11637. },
  11638. controller: [
  11639. "$scope",
  11640. "api_configure_form",
  11641. function ($scope, api_configure_form) {
  11642. if ($scope.options.templateOptions.isMultiSelect) {
  11643. // console.log($scope);
  11644. } else {
  11645. if ($scope.model[$scope.options.key]) {
  11646. }
  11647. }
  11648. },
  11649. ],
  11650. });
  11651. //多选下拉框组件
  11652. formlyConfigProvider.setType({
  11653. name: "ui-multi-select-tree",
  11654. extends: "input",
  11655. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11656. defaultOptions: function (options,scope) {
  11657. return {
  11658. templateOptions: {
  11659. linkage: function (modelName, data, model, modelKey, key) {
  11660. angular.extend(data, {
  11661. idx: 0,
  11662. sum: 10,
  11663. });
  11664. options.templateOptions.APIService.fetchDataList(
  11665. modelName,
  11666. data
  11667. ).then(function (response) {
  11668. var myData =
  11669. options.templateOptions.Restangular.stripRestangular(response);
  11670. var list = myData.list;
  11671. if (list.length == 1) {
  11672. angular.forEach(model.fields, function (item) {
  11673. angular.forEach(model.fields, function (item) {
  11674. if (item.templateOptions.pkey == modelKey + "." + key) {
  11675. item.model.id = "";
  11676. if (key == "place") {
  11677. item.templateOptions.options = list;
  11678. } else {
  11679. item.value(list[0][key][item.key]);
  11680. }
  11681. }
  11682. });
  11683. });
  11684. }
  11685. });
  11686. },
  11687. getparentdata: function (items) {
  11688. // console.log(items)
  11689. },
  11690. refresh: function (items, search, fn) {
  11691. console.log(items, options);
  11692. var treedata = [];
  11693. function convertListToTree(data, treeMap) {
  11694. console.log(data, treeMap)
  11695. treedata = data;
  11696. for (var i = 0; i < data.length; i++) {
  11697. for (var j = 0; j < data.length; j++) {
  11698. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11699. if (data[i].pid == data[j].id) {
  11700. data[i].parent = data[j];
  11701. }
  11702. }
  11703. // if (data[i].id) {
  11704. // if (data[i].id== data[j].id) {
  11705. // data[i].parent = data[j];
  11706. // }
  11707. // }
  11708. }
  11709. }
  11710. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11711. var root = []; //Initially set our loop to null
  11712. if (search == "search" && items.filterKeyword) {
  11713. function transform(nodes) {
  11714. var treeConverter = {
  11715. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11716. attributeName: "id", //节点唯一标识符
  11717. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11718. transform: function (node) {
  11719. //转化递归函数,参数:一个待插入节点
  11720. if (node.parent != null) {
  11721. //该节点有父节点
  11722. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11723. if (this.needFind) {
  11724. for (var i = 0; i < newNode.children.length; i++) {
  11725. //查找要插入的node子节点是否在newNode这个父节点中存在
  11726. if (
  11727. newNode.children[i][this.attributeName] ===
  11728. node[this.attributeName]
  11729. ) {
  11730. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11731. }
  11732. }
  11733. }
  11734. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11735. // delete node.parent; //删除该节点的parent属性,如果有的话
  11736. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11737. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11738. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11739. } else if (node.parent == null) {
  11740. //该叶节点没有父节点,即为根节点
  11741. // delete node.parent; //删除该节点的parent属性,如果有的话
  11742. if (this.result == null) {
  11743. //根节点不存在
  11744. node.children = []; //给该节点增加children:[]属性
  11745. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11746. } else {
  11747. node.children = [];
  11748. // 顶级去重
  11749. for (
  11750. var i = 0;
  11751. i < this.result.children.length;
  11752. i++
  11753. ) {
  11754. if (
  11755. this.result.children[i][this.attributeName] ===
  11756. node[this.attributeName]
  11757. ) {
  11758. return this.result.children[i];
  11759. }
  11760. }
  11761. this.result.children.push(node);
  11762. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11763. }
  11764. }
  11765. },
  11766. getWhole: function (nodes, attributeName) {
  11767. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11768. var _node = {};
  11769. _node.children = [];
  11770. this.result = _node; //重置根节点
  11771. this.attributeName =
  11772. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11773. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11774. nodes.forEach((item) => {
  11775. //循环调用转化方法
  11776. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11777. this.transform(item);
  11778. });
  11779. return this.result; //返回根节点
  11780. },
  11781. };
  11782. var result = treeConverter.getWhole(nodes); //调用
  11783. return result;
  11784. }
  11785. var li = transform(data).children;
  11786. // li=[...new Set(li)]
  11787. console.log(li);
  11788. treeMap = li;
  11789. fn(li);
  11790. return li;
  11791. } else {
  11792. //loop over data
  11793. for (var i = 0; i < data.length; i++) {
  11794. var datum = data[i];
  11795. //each node will have children, so let's give it a "children" poperty
  11796. datum.children = [];
  11797. //add an entry for this node to the map so that any future children can
  11798. //lookup the parent
  11799. idToNodeMap[datum.id] = datum;
  11800. //Does this node have a parent?
  11801. if (
  11802. typeof datum.parent === "undefined" ||
  11803. datum.parent === null
  11804. ) {
  11805. //Doesn't look like it, so this node is the root of the tree
  11806. root = datum;
  11807. treeMap[datum.id] = root;
  11808. } else {
  11809. //This node has a parent, so let's look it up using the id
  11810. parentNode = idToNodeMap[datum.parent.id];
  11811. //We don't need this property, so let's delete it.
  11812. // delete datum.parent;
  11813. //Let's add the current node as a child of the parent node.
  11814. parentNode.children.push(datum);
  11815. }
  11816. }
  11817. }
  11818. console.log(root);
  11819. return root;
  11820. }
  11821. function convertParentToChildList(data) {
  11822. var treeMap = {};
  11823. var list = [];
  11824. if (search == "search" && items.filterKeyword) {
  11825. var lis = convertListToTree(data, treeMap);
  11826. return lis;
  11827. } else {
  11828. if (data[0] && data[0].orders) {
  11829. list = data;
  11830. } else {
  11831. convertListToTree(data, treeMap);
  11832. angular.forEach(treeMap, function (item) {
  11833. // console.log("item="+JSON.stringify(item))
  11834. list.push(item);
  11835. });
  11836. }
  11837. console.log(list);
  11838. return list;
  11839. }
  11840. }
  11841. function selectItem(pmodel, childrens) {
  11842. if (angular.isArray(pmodel)) {
  11843. angular.forEach(pmodel, function (index) {
  11844. if (index && index.id) {
  11845. angular.forEach(childrens, function (item) {
  11846. if (item.id == index.id) {
  11847. item.selected = true;
  11848. }
  11849. if (item && item.children) {
  11850. selectItem(pmodel, item.children);
  11851. }
  11852. });
  11853. // angular.forEach(treedata,function(parentdata){
  11854. // if(parentdata.id == index.id){
  11855. // if(parentdata.parent&&parentdata.parent.id){
  11856. // parentdata.parent.$
  11857. // }
  11858. // item.selected = true;
  11859. // }
  11860. // if (item && item.children) {
  11861. // selectItem(pmodel ,item.children);
  11862. // }
  11863. // });
  11864. }
  11865. });
  11866. } else {
  11867. if (pmodel && pmodel.id) {
  11868. angular.forEach(childrens, function (item, index) {
  11869. if (item.id == pmodel.id) {
  11870. item.selected = true;
  11871. // delete item.children;
  11872. }
  11873. if (item && item.children) {
  11874. selectItem(pmodel, item.children);
  11875. }
  11876. });
  11877. }
  11878. }
  11879. }
  11880. function selectItemchild(pmodel, childrens) {
  11881. if (angular.isArray(pmodel)) {
  11882. angular.forEach(pmodel, function (index) {
  11883. if (index && index.id) {
  11884. angular.forEach(childrens, function (item) {
  11885. if (item.id == index.id) {
  11886. item.selected = true;
  11887. }
  11888. if (item && item.children) {
  11889. selectItem(pmodel, item.children);
  11890. }
  11891. });
  11892. }
  11893. });
  11894. } else {
  11895. if (pmodel && pmodel.id) {
  11896. angular.forEach(childrens, function (item, index) {
  11897. if (item.id == pmodel.id) {
  11898. item.selected = true;
  11899. childrens[index].selected = true;
  11900. }
  11901. if (item && item.children) {
  11902. selectItem(pmodel, item.children);
  11903. }
  11904. });
  11905. }
  11906. }
  11907. }
  11908. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11909. if (search === "search" && items.filterKeyword) {
  11910. // bala:树形模糊搜索
  11911. options.templateOptions
  11912. .bala(options.templateOptions.APIService, items.filterKeyword)
  11913. .then(function (result) {
  11914. result.list = [...new Set(result.list)]; //去重
  11915. if (!options.templateOptions.options) {
  11916. options.templateOptions.options = [];
  11917. }
  11918. if (options.templateOptions.optionsDataKey) {
  11919. options.templateOptions.options = convertParentToChildList(
  11920. result[options.templateOptions.optionsDataKey]
  11921. );
  11922. } else {
  11923. options.templateOptions.options =
  11924. convertParentToChildList(result);
  11925. }
  11926. //set default value
  11927. var pmodel,
  11928. i = 0;
  11929. if (
  11930. options.templateOptions.pkey ||
  11931. options.templateOptions.pkey != ""
  11932. ) {
  11933. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11934. angular.forEach(
  11935. options.templateOptions.pkey.split("."),
  11936. function (p) {
  11937. if (i == 0) {
  11938. if (options.model[p] == null) {
  11939. options.model[p] = {};
  11940. }
  11941. pmodel = options.model[p];
  11942. i++;
  11943. } else {
  11944. if (pmodel[p] == null) {
  11945. pmodel[p] = {};
  11946. }
  11947. pmodel = pmodel[p];
  11948. }
  11949. }
  11950. );
  11951. } else {
  11952. pmodel = options.model;
  11953. }
  11954. }
  11955. var topdata = angular.copy(options.templateOptions.options);
  11956. if (pmodel) {
  11957. pmodel = pmodel[options.key];
  11958. } else if (options.model) {
  11959. pmodel = options.model[options.key];
  11960. }
  11961. if (angular.isArray(pmodel)) {
  11962. if (pmodel) {
  11963. items.inputModel = angular.copy(
  11964. options.templateOptions.options
  11965. );
  11966. selectItem(pmodel, options.templateOptions.options);
  11967. }
  11968. } else {
  11969. if (pmodel && pmodel.id) {
  11970. items.inputModel = angular.copy(
  11971. options.templateOptions.options
  11972. );
  11973. selectItem(pmodel, options.templateOptions.options);
  11974. } else {
  11975. // items.inputModel = options.templateOptions.options;
  11976. }
  11977. }
  11978. // items.inputModel = options.templateOptions.options;
  11979. items.selectModel = options.templateOptions.options;
  11980. // 可在此展开
  11981. if (!items.inputModel) {
  11982. items.inputModel = items.selectModel;
  11983. } else {
  11984. selectItemchild(pmodel, items.inputModel);
  11985. // for (var i = 0; i < items.inputModel.length; i++) {
  11986. // items.inputModel[i].
  11987. // for (var j = 0; j < items.selectModel.length; j++) {
  11988. // if (items.selectModel[j].id == items.inputModel[i].id) {
  11989. // items.inputModel[i].selected = true;
  11990. // }
  11991. // }
  11992. // }
  11993. }
  11994. return items.inputModel;
  11995. // options.templateOptions.options = angular.copy(topdata);
  11996. // console.log(model);
  11997. // console.log(options);
  11998. });
  11999. } else {
  12000. options.templateOptions
  12001. .refreshData(options.templateOptions.APIService,scope.$root.user)
  12002. .then(function (result) {
  12003. //回显故障现象,带出绑定的人或组start caocao
  12004. if (options.templateOptions.onlyKey == 'cate_start' && items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  12005. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  12006. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  12007. return v.id == items.$parent.originalModel.incident.category.id;
  12008. })
  12009. console.log(item)//11615
  12010. if (item) {
  12011. items.$parent.originalModel.incident.branchType = item.branchType;
  12012. if(item.branchType == 0){
  12013. if (item.userOrGroupType === 1) {
  12014. items.$parent.originalModel.start_code = 'assignment';
  12015. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  12016. items.$parent.originalModel.directClose = true;
  12017. items.$parent.originalModel.isHandlerUser = false;
  12018. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  12019. } else if (item.userOrGroupType === 2) {
  12020. items.$parent.originalModel.start_code = 'assignment';
  12021. items.$parent.originalModel.candidateGroups = item.group;
  12022. items.$parent.originalModel.directClose = true;
  12023. items.$parent.originalModel.isHandlerUser = false;
  12024. } else {
  12025. items.$parent.originalModel.start_code = 'close';
  12026. items.$parent.originalModel.directClose = false;
  12027. items.$parent.originalModel.isHandlerUser = false;
  12028. delete items.$parent.originalModel.candidateGroups;
  12029. delete items.$parent.originalModel.incident.handlerUser
  12030. }
  12031. }else if(item.branchType == 1){
  12032. items.$parent.originalModel.incident.branchUserGroups = item.branchUserGroups;
  12033. // items.$parent.originalModel.incident.area.id
  12034. options.templateOptions.APIService.fetchData('area',items.$parent.originalModel.incident.area.id).then(res=>{
  12035. console.log(res)
  12036. if(res.status == 200){
  12037. items.$parent.originalModel.incident.branchId = res.data.branch;
  12038. // res.data.branch
  12039. var branchUserGroup=item.branchUserGroups.find(v=>v.branchId==res.data.branch)||{};
  12040. if(branchUserGroup.branchUserOrGroupType==1){
  12041. items.$parent.originalModel.start_code='assignment';
  12042. items.$parent.originalModel.incident.handlerUser={id:branchUserGroup.userId?branchUserGroup.userId:undefined};
  12043. items.$parent.originalModel.directClose=true;
  12044. items.$parent.originalModel.isHandlerUser=false;
  12045. setTimeout(function(){items.$parent.originalModel.isHandlerUser=true;},0)
  12046. }else if(branchUserGroup.branchUserOrGroupType===2){
  12047. items.$parent.originalModel.start_code='assignment';
  12048. items.$parent.originalModel.candidateGroups=branchUserGroup.groupId?branchUserGroup.groupId:undefined;
  12049. items.$parent.originalModel.directClose=true;
  12050. items.$parent.originalModel.isHandlerUser=false;
  12051. }else{
  12052. items.$parent.originalModel.start_code='close';
  12053. items.$parent.originalModel.directClose=false;
  12054. items.$parent.originalModel.isHandlerUser=false;
  12055. delete items.$parent.originalModel.candidateGroups;
  12056. delete items.$parent.originalModel.incident.handlerUser
  12057. }
  12058. }
  12059. })
  12060. }
  12061. }
  12062. }
  12063. //回显故障现象,带出绑定的人或组end
  12064. if (!options.templateOptions.options) {
  12065. options.templateOptions.options = [];
  12066. }
  12067. if(options.templateOptions.uuKey == 'knowledge_leve.dutyDepartment'){
  12068. let data = result[options.templateOptions.optionsDataKey];
  12069. for (var i = 0; i < data.length; i++) {
  12070. data[i].parent = {id: -data[i].branch, name: data[i].branchName};
  12071. data[i].name = data[i].dept;
  12072. }
  12073. var parentList = []
  12074. var idToNodeMap = {}
  12075. for (var i = 0; i < data.length; i++) {
  12076. idToNodeMap[data[i].parent.id] = [];
  12077. parentList.push(data[i].parent);
  12078. }
  12079. let map = new Map();
  12080. for (let item of parentList) {
  12081. if (!map.has(item.id)) {
  12082. map.set(item.id, item);
  12083. };
  12084. };
  12085. parentList = [...map.values()];
  12086. // console.log(parentList);
  12087. console.log(data);
  12088. //loop over data
  12089. for (var i = 0; i < data.length; i++) {
  12090. var datum = data[i];
  12091. //each node will have children, so let's give it a "children" poperty
  12092. datum.children = [];
  12093. //add an entry for this node to the map so that any future children can
  12094. //lookup the parent
  12095. if(idToNodeMap[datum.parent.id]){
  12096. idToNodeMap[datum.parent.id].push(JSON.parse(JSON.stringify(datum)));
  12097. }
  12098. //Does this node have a parent?
  12099. }
  12100. for (let key in idToNodeMap) {
  12101. let index = parentList.findIndex(v => v.id == key);
  12102. if (index > -1) {
  12103. parentList[index].children = idToNodeMap[key];
  12104. };
  12105. };
  12106. console.log(parentList)
  12107. options.templateOptions.options = parentList;
  12108. }else{
  12109. if (options.templateOptions.optionsDataKey) {
  12110. options.templateOptions.options = convertParentToChildList(
  12111. result[options.templateOptions.optionsDataKey]
  12112. );
  12113. } else {
  12114. options.templateOptions.options =
  12115. convertParentToChildList(result);
  12116. }
  12117. }
  12118. //set default value
  12119. var pmodel,
  12120. i = 0;
  12121. if (
  12122. options.templateOptions.pkey ||
  12123. options.templateOptions.pkey != ""
  12124. ) {
  12125. if (options.templateOptions.pkey.indexOf(".") > 0) {
  12126. angular.forEach(
  12127. options.templateOptions.pkey.split("."),
  12128. function (p) {
  12129. if (i == 0) {
  12130. if (options.model[p] == null) {
  12131. options.model[p] = {};
  12132. }
  12133. pmodel = options.model[p];
  12134. i++;
  12135. } else {
  12136. if (pmodel[p] == null) {
  12137. pmodel[p] = {};
  12138. }
  12139. pmodel = pmodel[p];
  12140. }
  12141. }
  12142. );
  12143. } else {
  12144. pmodel = options.model;
  12145. }
  12146. }
  12147. var topdata = angular.copy(options.templateOptions.options);
  12148. if (pmodel) {
  12149. pmodel = pmodel[options.key];
  12150. } else if (options.model) {
  12151. pmodel = options.model[options.key];
  12152. }
  12153. if (angular.isArray(pmodel)) {
  12154. if (pmodel) {
  12155. items.inputModel = angular.copy(
  12156. options.templateOptions.options
  12157. );
  12158. selectItem(pmodel, options.templateOptions.options);
  12159. }
  12160. } else {
  12161. if (pmodel && pmodel.id) {
  12162. items.inputModel = angular.copy(
  12163. options.templateOptions.options
  12164. );
  12165. selectItem(pmodel, options.templateOptions.options);//baba
  12166. } else {
  12167. // items.inputModel = options.templateOptions.options;
  12168. }
  12169. }
  12170. // items.inputModel = options.templateOptions.options;
  12171. items.selectModel = options.templateOptions.options;
  12172. if (!items.inputModel) {
  12173. items.inputModel = items.selectModel;
  12174. } else {
  12175. selectItemchild(pmodel, items.inputModel);
  12176. // for (var i = 0; i < items.inputModel.length; i++) {
  12177. // for (var j = 0; j < items.selectModel.length; j++) {
  12178. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12179. // items.inputModel[i].selected = true;
  12180. // }
  12181. // }
  12182. // }
  12183. }
  12184. // options.templateOptions.options = angular.copy(topdata);
  12185. // console.log(model);
  12186. // console.log(options);
  12187. });
  12188. }
  12189. },
  12190. },
  12191. validators: {
  12192. required: {
  12193. expression: function (viewValue, modelValue) {
  12194. var value = modelValue || viewValue;
  12195. if (angular.isArray(value)) {
  12196. return value.length > 0;
  12197. } else {
  12198. // console.log(options)
  12199. if (options.templateOptions.required && !value) {
  12200. // return value != null;
  12201. } else {
  12202. return value;
  12203. }
  12204. // return value = "true";
  12205. }
  12206. },
  12207. },
  12208. },
  12209. };
  12210. },
  12211. controller: [
  12212. "$scope",
  12213. "$rootScope",
  12214. "api_configure_form",
  12215. "api_bpm_domain",
  12216. "api_category",
  12217. function ($scope, $rootScope, api_configure_form, api_bpm_domain, api_category) {
  12218. // // 知识库-责任科室
  12219. // if ($scope.to.uuKey === 'knowledge_leve.dutyDepartment') {
  12220. // //处理远程获取数据控件方法调用
  12221. // $scope.to.refresh = function(searchVal){
  12222. // api_category.getOwnDuty({}).then(function(res){
  12223. // if (!$scope.to.options) {
  12224. // $scope.to.options = res.data || [];
  12225. // }
  12226. // })
  12227. // };
  12228. // }
  12229. $rootScope.checkClicked = function (item) {
  12230. angular.forEach($scope.to.options, function (itemone) {
  12231. if (!item.parent) {
  12232. if (item.id == itemone.id) {
  12233. // itemone.isExpanded = true;
  12234. } else {
  12235. itemone.isExpanded = false;
  12236. }
  12237. } else {
  12238. if (item.parent.id == itemone.id) {
  12239. angular.forEach(itemone.children, function (itemtwo) {
  12240. if (item.id == itemtwo.id) {
  12241. } else {
  12242. itemtwo.isExpanded = false;
  12243. }
  12244. });
  12245. }
  12246. }
  12247. });
  12248. // 故障现象带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  12249. console.log($scope, "gsm");
  12250. if (
  12251. $scope.originalModel &&
  12252. $scope.originalModel.incident &&
  12253. item.category &&
  12254. (!item.children || !item.children.length) &&
  12255. item.priority &&
  12256. item.priority.id
  12257. ) {
  12258. api_bpm_domain
  12259. .expectedTime("L" + (item.priority.id - 1559))
  12260. .then(function (res) {
  12261. $scope.originalModel.incident.expectResponseTime =
  12262. res.serviceLevelAgreement.responseTime;
  12263. $scope.originalModel.incident.expectIntroTime =
  12264. res.serviceLevelAgreement.resolveTime;
  12265. $scope.originalModel.incident.overdueTime = res.date;
  12266. });
  12267. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  12268. // setTimeout(() => {
  12269. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  12270. // }, 500);
  12271. // console.log($scope.$parent.$parent.$parent)
  12272. }
  12273. };
  12274. if ($scope.options.templateOptions.isMultiSelect) {
  12275. // console.log($scope);
  12276. } else {
  12277. if ($scope.model[$scope.options.key]) {
  12278. }
  12279. }
  12280. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  12281. // console.log(item)
  12282. // // if(){
  12283. // // }
  12284. // // $scope.model[$scope.options.key]=item.id;
  12285. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  12286. // $scope.propTypeOptions = data;
  12287. // });
  12288. // }
  12289. // $scope.model[$scope.options.key]=[];
  12290. // $scope.fn
  12291. $rootScope.bala1 = function (items, fn) {
  12292. // $scope.fn = fn;
  12293. console.log(items);
  12294. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  12295. $scope.options.templateOptions.refresh(items, "search", fn);
  12296. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  12297. // // return res.list;
  12298. // console.log(666)
  12299. // fn(res.list)
  12300. // })
  12301. };
  12302. },
  12303. ],
  12304. });
  12305. //勾选组件
  12306. formlyConfigProvider.setType({
  12307. name: "ui-checkbox",
  12308. extends: "checkbox",
  12309. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  12310. controller: [
  12311. "$scope",
  12312. function ($scope) {
  12313. console.log($scope)
  12314. if($scope.options.templateOptions.isTrue){
  12315. //是否默认打开
  12316. $scope.model[$scope.options.key] = true;
  12317. }
  12318. // 巡检生成事件,默认派单
  12319. if ($scope.model.isInspection) {
  12320. $scope.model[$scope.options.key] = true;
  12321. }
  12322. if ($scope.model[$scope.options.key] == "true") {
  12323. $scope.model[$scope.options.key] = true;
  12324. }
  12325. if ($scope.model[$scope.options.key] == "false") {
  12326. $scope.model[$scope.options.key] = false;
  12327. }
  12328. },
  12329. ],
  12330. });
  12331. //勾选组件(禁用)--yeye
  12332. formlyConfigProvider.setType({
  12333. name: "ui-checkbox-disabled",
  12334. extends: "checkbox",
  12335. templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.html",
  12336. controller: [
  12337. "$scope",
  12338. function ($scope) {
  12339. // 巡检生成事件,默认派单
  12340. // if ($scope.model.isInspection) {
  12341. // $scope.model[$scope.options.key] = true;
  12342. // }
  12343. // if ($scope.model[$scope.options.key] == "true") {
  12344. // $scope.model[$scope.options.key] = true;
  12345. // }
  12346. // if ($scope.model[$scope.options.key] == "false") {
  12347. // $scope.model[$scope.options.key] = false;
  12348. // }
  12349. },
  12350. ],
  12351. });
  12352. //换行组件
  12353. formlyConfigProvider.setType({
  12354. name: "ui-nextLine",
  12355. /*extends: 'input',*/
  12356. template: "<div></div>",
  12357. });
  12358. //多选框组件
  12359. formlyConfigProvider.setType({
  12360. name: "ui-checklist",
  12361. extends: "multiCheckbox",
  12362. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  12363. defaultOptions: function (options) {
  12364. return {
  12365. templateOptions: {
  12366. refresh: function () { },
  12367. refreshDelay: 0,
  12368. },
  12369. };
  12370. },
  12371. });
  12372. //单选框组件
  12373. formlyConfigProvider.setType({
  12374. name: "ui-radio",
  12375. extends: "radio",
  12376. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  12377. defaultOptions: function (options) {
  12378. return {
  12379. templateOptions: {
  12380. refresh: function () {},
  12381. refreshDelay: 0,
  12382. },
  12383. };
  12384. },
  12385. controller: [
  12386. "$scope",
  12387. "api_wechatfile",
  12388. function ($scope,api_wechatfile) {
  12389. // 新增巡检计划-巡检方式baba
  12390. if($scope.to.onlyKey === 'onlineType'){
  12391. api_wechatfile.getDictionary($scope.to.modelreasondata).then(function (result) {
  12392. $scope.to.options = result;
  12393. if(!$scope.model[$scope.options.key]){
  12394. $scope.model[$scope.options.key] = result[0]?result[0].id:null;
  12395. }
  12396. });
  12397. }
  12398. // 巡检生成事件,默认派单
  12399. if ($scope.model.isInspection) {
  12400. $scope.model[$scope.options.key] = true;
  12401. // $scope.model.isHandlerUser=true;
  12402. $scope.model.start_code = "assignment";
  12403. console.log($scope.model);
  12404. }
  12405. //多次暂存配置
  12406. // console.log($scope);
  12407. if ($scope.model.saveAgain) {
  12408. if (
  12409. $scope.model.directClose == "1" ||
  12410. $scope.model.directClose == true
  12411. ) {
  12412. $scope.model[$scope.options.key] = true;
  12413. // if($scope.model.incident.handlingPersonnelUser){
  12414. // delete $scope.model.incident.handlingPersonnelUser;
  12415. // };
  12416. if ($scope.model.incident.handleDescription) {
  12417. delete $scope.model.incident.handleDescription;
  12418. }
  12419. if ($scope.model.incident.closecode) {
  12420. delete $scope.model.incident.closecode;
  12421. }
  12422. if ($scope.model.incident.degree) {
  12423. delete $scope.model.incident.degree;
  12424. }
  12425. } else {
  12426. $scope.model.incident.handlingPersonnelUser =
  12427. $scope.model.incident.acceptUser;
  12428. $scope.model[$scope.options.key] = false;
  12429. }
  12430. }
  12431. },
  12432. ],
  12433. });
  12434. //文本域组件
  12435. formlyConfigProvider.setWrapper({
  12436. name: "validation",
  12437. types: ["ui-textarea"],
  12438. template:
  12439. '<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>',
  12440. });
  12441. formlyConfigProvider.setType({
  12442. name: "ui-textarea",
  12443. extends: "textarea",
  12444. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12445. defaultOptions: function (options) {
  12446. return {
  12447. templateOptions: {
  12448. transform: function (model, value) {
  12449. return value;
  12450. },
  12451. },
  12452. validation: {
  12453. messages: {
  12454. maxlength: function (viewValue, modelValue, scope) {
  12455. if (viewValue != null) {
  12456. if (viewValue.length > scope.to.maxlength) {
  12457. return (
  12458. scope.to.label +
  12459. " 字数(" +
  12460. viewValue.length +
  12461. ")超限(" +
  12462. scope.to.maxlength +
  12463. ")"
  12464. );
  12465. } else {
  12466. return "";
  12467. }
  12468. }
  12469. },
  12470. },
  12471. },
  12472. };
  12473. },
  12474. controller: [
  12475. "$scope",
  12476. function ($scope) {
  12477. var value = $scope.model[$scope.options.key];
  12478. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12479. $scope.model[$scope.options.key] =
  12480. $scope.options.templateOptions.transform(
  12481. $scope.originalModel,
  12482. value
  12483. );
  12484. }
  12485. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12486. $scope.options.templateOptions.felditem($scope);
  12487. }
  12488. },
  12489. ],
  12490. });
  12491. // div版的textarea(展示富文本框内容用)
  12492. formlyConfigProvider.setType({
  12493. name: "ui-divTextarea",
  12494. extends: "textarea",
  12495. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12496. defaultOptions: function (options) {
  12497. return {
  12498. templateOptions: {
  12499. transform: function (model, value) {
  12500. return value;
  12501. },
  12502. },
  12503. validation: {
  12504. messages: {
  12505. // maxlength: function (viewValue, modelValue, scope) {
  12506. // if (viewValue != null) {
  12507. // if (viewValue.length > scope.to.maxlength) {
  12508. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12509. // } else {
  12510. // return "";
  12511. // }
  12512. // }
  12513. // },
  12514. },
  12515. },
  12516. };
  12517. },
  12518. controller: [
  12519. "$scope",
  12520. function ($scope) {
  12521. var value = $scope.model[$scope.options.key];
  12522. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12523. $scope.model[$scope.options.key] =
  12524. $scope.options.templateOptions.transform(
  12525. $scope.originalModel,
  12526. value
  12527. );
  12528. }
  12529. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12530. $scope.options.templateOptions.felditem($scope);
  12531. }
  12532. },
  12533. ],
  12534. });
  12535. // 带有知识库引用的textarea
  12536. formlyConfigProvider.setType({
  12537. name: "ui-textAreaKnowledge",
  12538. // extends: 'textarea',
  12539. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12540. defaultOptions: function (options) {
  12541. return {
  12542. templateOptions: {
  12543. transform: function (model, value) {
  12544. return value;
  12545. },
  12546. },
  12547. validation: {
  12548. messages: {
  12549. maxlength: function (viewValue, modelValue, scope) {
  12550. if (viewValue != null) {
  12551. if (viewValue.length > scope.to.maxlength) {
  12552. return (
  12553. scope.to.label +
  12554. " 字数(" +
  12555. viewValue.length +
  12556. ")超限(" +
  12557. scope.to.maxlength +
  12558. ")"
  12559. );
  12560. } else {
  12561. return "";
  12562. }
  12563. }
  12564. },
  12565. },
  12566. },
  12567. };
  12568. },
  12569. controller: [
  12570. "$scope",
  12571. "$rootScope",
  12572. "$modal",
  12573. "SweetAlert",
  12574. "api_bpm_data",
  12575. "api_bpm_domain",
  12576. "api_solution",
  12577. "$aside",
  12578. "api_zsk",
  12579. "up_down_file",
  12580. "api_wechatfile",
  12581. function (
  12582. $scope,
  12583. $rootScope,
  12584. $modal,
  12585. SweetAlert,
  12586. api_bpm_data,
  12587. api_bpm_domain,
  12588. api_solution,
  12589. $aside,
  12590. api_zsk,
  12591. up_down_file,
  12592. api_wechatfile
  12593. ) {
  12594. // console.log($scope);
  12595. var value = $scope.model[$scope.options.key];
  12596. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12597. $scope.model[$scope.options.key] =
  12598. $scope.options.templateOptions.transform(
  12599. $scope.originalModel,
  12600. value
  12601. );
  12602. }
  12603. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12604. $scope.options.templateOptions.felditem($scope);
  12605. }
  12606. // 引用知识库点击
  12607. $scope.openSolution = function () {
  12608. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12609. setTimeout(() => {
  12610. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12611. }, 100);
  12612. };
  12613. },
  12614. ],
  12615. });
  12616. //常用语句选择textarea
  12617. formlyConfigProvider.setType({
  12618. name: "ui-textselect",
  12619. extends: "textarea",
  12620. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12621. defaultOptions: function (options) {
  12622. return {
  12623. templateOptions: {
  12624. transform: function (model, value) {
  12625. return value;
  12626. },
  12627. },
  12628. validation: {
  12629. messages: {
  12630. maxlength: function (viewValue, modelValue, scope) {
  12631. if (viewValue != null) {
  12632. if (viewValue.length > scope.to.maxlength) {
  12633. return (
  12634. scope.to.label +
  12635. " 字数(" +
  12636. viewValue.length +
  12637. ")超限(" +
  12638. scope.to.maxlength +
  12639. ")"
  12640. );
  12641. } else {
  12642. return "";
  12643. }
  12644. }
  12645. },
  12646. },
  12647. },
  12648. };
  12649. },
  12650. controller: [
  12651. "$scope",
  12652. function ($scope) {
  12653. var value = $scope.model[$scope.options.key];
  12654. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12655. $scope.model[$scope.options.key] =
  12656. $scope.options.templateOptions.transform(
  12657. $scope.originalModel,
  12658. value
  12659. );
  12660. }
  12661. },
  12662. ],
  12663. });
  12664. //改动的组件 ckeditor封装后的组件
  12665. formlyConfigProvider.setType({
  12666. name: "ui-text-check",
  12667. extends: "textarea",
  12668. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12669. defaultOptions: function (options) {
  12670. return {
  12671. templateOptions: {
  12672. extraPlugins: "uploadimage",
  12673. uploadimageConfig: {
  12674. backend: "basic",
  12675. settings: {
  12676. uploadUrl:
  12677. options.templateOptions.APIService.upload().getRequestedUrl(),
  12678. headers: "",
  12679. downloadUrl:
  12680. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12681. },
  12682. },
  12683. refresh: function (APIService, contentId, data) {
  12684. return APIService.fetchDataList(contentId, data);
  12685. },
  12686. downloadUri: function (APIService, contentId) {
  12687. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12688. },
  12689. upload: function (APIService, contentId) {
  12690. return APIService.getSolutionDowpath(contentId);
  12691. },
  12692. view: function (attachmentId) {
  12693. // return APIService.attachmentsPreviewUrl(contentId);
  12694. },
  12695. refreshDelay: 0,
  12696. transform: function (model, value) {
  12697. return value;
  12698. },
  12699. },
  12700. validation: {
  12701. messages: {
  12702. maxlength: function (viewValue, modelValue, scope) {
  12703. if (viewValue != null) {
  12704. if (viewValue.length > scope.to.maxlength) {
  12705. return (
  12706. scope.to.label +
  12707. " 字数(" +
  12708. viewValue.length +
  12709. ")超限(" +
  12710. scope.to.maxlength +
  12711. ")"
  12712. );
  12713. } else {
  12714. return "";
  12715. }
  12716. }
  12717. },
  12718. },
  12719. },
  12720. };
  12721. },
  12722. controller: [
  12723. "$scope",
  12724. "$rootScope",
  12725. function ($scope, $rootScope) {
  12726. var value = $scope.model[$scope.options.key];
  12727. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12728. $scope.model[$scope.options.key] =
  12729. $scope.options.templateOptions.transform(
  12730. $scope.originalModel,
  12731. value
  12732. );
  12733. }
  12734. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12735. $rootScope.getSession();
  12736. //var expiry={'expiry':14804244006};
  12737. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12738. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12739. $scope.upload = function (contentId, filename) {
  12740. var filename = filename;
  12741. $scope.options.templateOptions
  12742. .upload($scope.options.templateOptions.ApiService, contentId)
  12743. .then(function (response) {
  12744. var file = new Blob([response], {
  12745. type: "application/octet-stream",
  12746. });
  12747. // var filename = filename;
  12748. var fileURL = URL.createObjectURL(file);
  12749. var a = document.createElement("a");
  12750. a.href = fileURL;
  12751. a.target = "_blank";
  12752. a.download = filename;
  12753. document.body.appendChild(a);
  12754. a.click();
  12755. });
  12756. };
  12757. },
  12758. ],
  12759. });
  12760. //改动的组件 ckeditor封装后的附文本组件
  12761. formlyConfigProvider.setType({
  12762. name: "ui-fuwenben",
  12763. extends: "textarea",
  12764. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12765. defaultOptions: function (options) {
  12766. return {
  12767. templateOptions: {
  12768. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12769. extraPlugins: "uploadimage",
  12770. uploadimageConfig: {
  12771. backend: "basic",
  12772. settings: {
  12773. uploadUrl:
  12774. options.templateOptions.APIService.upload(
  12775. -110
  12776. ).getRequestedUrl(),
  12777. headers: "",
  12778. downloadUrl:
  12779. options.templateOptions.APIService.uploadResponseUri(),
  12780. },
  12781. },
  12782. refresh: function (APIService, contentId, data) {
  12783. return APIService.fetchDataList(-110, data);
  12784. },
  12785. downloadUri: function (APIService, contentId) {
  12786. return APIService.downloadAttachment(-110).getRequestedUrl();
  12787. },
  12788. upload: function (APIService, contentId) {
  12789. return APIService.getSolutionDowpath(-110);
  12790. },
  12791. view: function (attachmentId) {
  12792. // return APIService.attachmentsPreviewUrl(contentId);
  12793. },
  12794. refreshDelay: 0,
  12795. transform: function (model, value) {
  12796. return value;
  12797. },
  12798. },
  12799. validation: {
  12800. messages: {
  12801. maxlength: function (viewValue, modelValue, scope) {
  12802. if (viewValue != null) {
  12803. if (viewValue.length > scope.to.maxlength) {
  12804. return (
  12805. scope.to.label +
  12806. " 字数(" +
  12807. viewValue.length +
  12808. ")超限(" +
  12809. scope.to.maxlength +
  12810. ")"
  12811. );
  12812. } else {
  12813. return "";
  12814. }
  12815. }
  12816. },
  12817. },
  12818. },
  12819. };
  12820. },
  12821. controller: [
  12822. "$scope",
  12823. "$rootScope",
  12824. function ($scope, $rootScope) {
  12825. var value = $scope.model[$scope.options.key];
  12826. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12827. $scope.model[$scope.options.key] =
  12828. $scope.options.templateOptions.transform(
  12829. $scope.originalModel,
  12830. value
  12831. );
  12832. }
  12833. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12834. $rootScope.getSession();
  12835. //var expiry={'expiry':14804244006};
  12836. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12837. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12838. $scope.upload = function (contentId, filename) {
  12839. var filename = filename;
  12840. $scope.options.templateOptions
  12841. .upload($scope.options.templateOptions.ApiService, -110)
  12842. .then(function (response) {
  12843. var file = new Blob([response], {
  12844. type: "application/octet-stream",
  12845. });
  12846. // var filename = filename;
  12847. var fileURL = URL.createObjectURL(file);
  12848. var a = document.createElement("a");
  12849. a.href = fileURL;
  12850. a.target = "_blank";
  12851. a.download = filename;
  12852. document.body.appendChild(a);
  12853. a.click();
  12854. });
  12855. };
  12856. },
  12857. ],
  12858. });
  12859. //ui-grid展示控件
  12860. formlyConfigProvider.setType({
  12861. name: "ui-grid-show",
  12862. extends: "multiCheckbox",
  12863. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12864. defaultOptions: function (options,scope) {
  12865. return {
  12866. templateOptions: {
  12867. linkage: function () { },
  12868. getScope: function () {
  12869. return scope;
  12870. },
  12871. },
  12872. };
  12873. },
  12874. controller: function (
  12875. $scope,
  12876. $rootScope,
  12877. i18nService,
  12878. Restangular,
  12879. api_bpm_data
  12880. ) {
  12881. var loginUser = $rootScope.user;
  12882. $scope.langs = i18nService.getAllLangs();
  12883. $scope.lang = "zh-cn";
  12884. i18nService.setCurrentLang($scope.lang);
  12885. $scope.gridOptions = {};
  12886. $scope.gridOptions.data = "myData";
  12887. $scope.gridOptions.enableColumnResizing = true;
  12888. // $scope.gridOptions.enableFiltering = true;
  12889. $scope.gridOptions.enableGridMenu = false;
  12890. $scope.gridOptions.enableRowSelection = true;
  12891. $scope.gridOptions.showGridFooter = true;
  12892. $scope.gridOptions.showColumnFooter = false;
  12893. $scope.gridOptions.fastWatch = true;
  12894. $scope.gridOptions.useExternalFiltering = true;
  12895. $scope.gridOptions.useExternalPagination = true;
  12896. $scope.gridOptions.paginationPageSizes = [10];
  12897. $scope.gridOptions.paginationPageSize = 10;
  12898. $scope.gridOptions.multiSelect = true;
  12899. $scope.gridOptions.rowIdentity = function (row) {
  12900. return row.id;
  12901. };
  12902. $scope.gridOptions.getRowIdentity = function (row) {
  12903. return row.id;
  12904. };
  12905. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12906. $scope.gridOptions.columnDefs = [
  12907. // { name:'id', width:80, enableFiltering:false},
  12908. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12909. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12910. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12911. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12912. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12913. {
  12914. name: "inspection.title",
  12915. displayName: "计划主题",
  12916. width: 120,
  12917. enableFiltering: false,
  12918. },
  12919. {
  12920. name: "sign",
  12921. displayName: "单号",
  12922. width: 140,
  12923. enableFiltering: false,
  12924. },
  12925. {
  12926. name: "inspectionType.type",
  12927. displayName: "巡检分类",
  12928. width: 200,
  12929. enableFiltering: false,
  12930. cellTemplate: '<div>' +
  12931. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  12932. '</div>'
  12933. },
  12934. {
  12935. name: "stateName",
  12936. displayName: "状态",
  12937. width: 80,
  12938. enableFiltering: false,
  12939. },
  12940. {
  12941. name: "processUser.name",
  12942. displayName: "处理人/组",
  12943. width: 120,
  12944. enableFiltering: false,
  12945. cellTemplate: '<div>' +
  12946. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  12947. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  12948. '</div>'
  12949. },
  12950. {
  12951. name: "startDate",
  12952. displayName: "开始时间",
  12953. width: 160,
  12954. enableFiltering: false,
  12955. },
  12956. {
  12957. name: "endTime",
  12958. displayName: "结束时间",
  12959. width: 160,
  12960. enableFiltering: false,
  12961. cellTemplate: '<div>' +
  12962. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  12963. '</div>'
  12964. },
  12965. // {
  12966. // name: "batchNo",
  12967. // displayName: "批次号",
  12968. // width: 160,
  12969. // enableFiltering: false,
  12970. // },
  12971. ];
  12972. var defaultFilterData = {
  12973. idx: 0,
  12974. sum: 10,
  12975. };
  12976. $scope.transferTime = function (time) {
  12977. return moment(time).format("YYYY-MM-DD HH:mm");
  12978. };
  12979. //分页控制
  12980. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12981. gridApi.pagination.on.paginationChanged(
  12982. $scope,
  12983. function (newPage, pageSize) {
  12984. var filtersData = $scope.memoryfilterData;
  12985. filtersData.idx = newPage - 1;
  12986. filtersData.sum = pageSize;
  12987. $scope.refreshData("expand-right", filtersData);
  12988. }
  12989. );
  12990. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12991. data.grid.appScope.selected.items = data.entity;
  12992. });
  12993. };
  12994. //页面获取数据
  12995. $scope.refreshData = function (style, filterData) {
  12996. // $scope.ldloading[style.replace('-', '_')] = true;
  12997. console.log(angular.isUndefined(filterData))
  12998. if (angular.isUndefined(filterData)) {
  12999. filterData = defaultFilterData;
  13000. }
  13001. $scope.myData = [];
  13002. console.log(filterData)
  13003. if(filterData.inspectionProcessActual && filterData.inspectionProcessActual.batchNo){
  13004. filterData.inspectionProcessActual = {
  13005. inspectionid: $scope.model.id,
  13006. batchNo:filterData.inspectionProcessActual.batchNo
  13007. }
  13008. }else{
  13009. filterData.inspectionProcessActual = {
  13010. inspectionid: $scope.model.id
  13011. }
  13012. }
  13013. // angular.extend(filterData, {
  13014. // inspectionProcessActual: {
  13015. // inspectionid: $scope.model.id,
  13016. // },
  13017. // });
  13018. console.log(filterData)
  13019. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  13020. function (data) {
  13021. var myData = Restangular.stripRestangular(data);
  13022. $scope.gridOptions.totalItems = myData.totalNum;
  13023. $scope.myData = myData.list;
  13024. for (var i = 0; i < $scope.myData.length; i++) {
  13025. //添加序号
  13026. $scope.myData[i]["item"] =
  13027. i + 1 + filterData.idx * filterData.sum;
  13028. }
  13029. // $scope.ldloading[style.replace('-', '_')] = false;
  13030. },
  13031. function () {
  13032. // $scope.ldloading[style.replace('-', '_')] = false;
  13033. }
  13034. );
  13035. };
  13036. $scope.refreshData("expand-right", defaultFilterData);
  13037. },
  13038. });
  13039. //文本框自定义选择面板组件
  13040. formlyConfigProvider.setType({
  13041. name: "ui-input-selectmodal",
  13042. extends: "input",
  13043. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  13044. defaultOptions: function (options) {
  13045. return {
  13046. templateOptions: {
  13047. openModal: function (size, options, modal) {
  13048. var modalInstance = modal.open({
  13049. templateUrl: "assets/views/customform/tpl/modal-content.html",
  13050. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  13051. size: size,
  13052. resolve: options.templateOptions.modalParam,
  13053. });
  13054. modalInstance.result.then(
  13055. function (selectedItem) {
  13056. options.value(selectedItem);
  13057. },
  13058. function () {
  13059. //console.log('Modal dismissed at: ' + new Date());
  13060. }
  13061. );
  13062. },
  13063. },
  13064. };
  13065. },
  13066. });
  13067. //日期控件
  13068. var datepicker_attr = [
  13069. "date-disabled",
  13070. "custom-class",
  13071. "show-weeks",
  13072. "starting-day",
  13073. "init-date",
  13074. "min-mode",
  13075. "max-mode",
  13076. "format-day",
  13077. "format-month",
  13078. "format-year",
  13079. "format-day-header",
  13080. "format-day-title",
  13081. "format-month-title",
  13082. "year-range",
  13083. "shortcut-propagation",
  13084. "datepicker-popup",
  13085. "show-button-bar",
  13086. "current-text",
  13087. "clear-text",
  13088. "close-text",
  13089. "close-on-date-selection",
  13090. "datepicker-append-to-body",
  13091. ];
  13092. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  13093. formlyConfigProvider.setType({
  13094. name: "ui-datetime",
  13095. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  13096. extends: "input",
  13097. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13098. defaultOptions: {
  13099. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13100. templateOptions: {
  13101. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13102. },
  13103. },
  13104. controller: [
  13105. "$scope",
  13106. "$filter",
  13107. function ($scope, $filter) {
  13108. $scope.model[$scope.options.key] = $filter("date")(
  13109. new Date(),
  13110. $scope.options.templateOptions.datepickerPopup
  13111. );
  13112. $scope.options.initialValue = $scope.model[$scope.options.key];
  13113. },
  13114. ],
  13115. });
  13116. //日期控件
  13117. formlyConfigProvider.setType({
  13118. name: "ui-datepicker",
  13119. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  13120. extends: "input",
  13121. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13122. defaultOptions: {
  13123. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13124. templateOptions: {
  13125. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13126. },
  13127. },
  13128. controller: [
  13129. "$scope",
  13130. "$filter",
  13131. function ($scope, $filter) {
  13132. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  13133. if ($scope.model[$scope.options.key]) {
  13134. } else {
  13135. $scope.model[$scope.options.key] = $filter("date")(
  13136. new Date(),
  13137. $scope.options.templateOptions.datepickerPopup
  13138. );
  13139. }
  13140. $scope.options.initialValue = $scope.model[$scope.options.key];
  13141. $scope.endOpen = true;
  13142. $scope.datepicker = {};
  13143. $scope.datepicker.opened = false;
  13144. $scope.datepicker.open = function ($event) {
  13145. $scope.datepicker.opened = true;
  13146. };
  13147. },
  13148. ],
  13149. });
  13150. //时分控件
  13151. formlyConfigProvider.setType({
  13152. name: "ui-datehourtime",
  13153. extends: "input",
  13154. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  13155. defaultOptions: function (options) {
  13156. return {
  13157. noFormControl: true,
  13158. // validators:{
  13159. // required:{
  13160. // expression:function(viewValue, modelValue){
  13161. // console.log(options)
  13162. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  13163. // // var value = modelValue.getHours() || viewValue.getHours();
  13164. // return value.length>=1;
  13165. // }
  13166. // }
  13167. // }
  13168. };
  13169. },
  13170. controller: [
  13171. "$scope",
  13172. "$log",
  13173. function ($scope, $log) {
  13174. $scope.hstep = new Date(
  13175. Date.parse($scope.model[$scope.options.key])
  13176. ).getHours();
  13177. $scope.minutes = new Date(
  13178. Date.parse($scope.model[$scope.options.key])
  13179. ).getMinutes();
  13180. $scope.model[$scope.options.key] = new Date(
  13181. Date.parse($scope.model[$scope.options.key])
  13182. );
  13183. },
  13184. ],
  13185. });
  13186. //状态追踪
  13187. formlyConfigProvider.setType({
  13188. name: "ui-followStatus",
  13189. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  13190. controller: [
  13191. "$scope",
  13192. "api_bpm_data",
  13193. "Restangular",
  13194. function ($scope, api_bpm_data, Restangular) {
  13195. setTimeout(function () {
  13196. var pkey = $scope.options.templateOptions.pkey;
  13197. var dataId = $scope.model.id;
  13198. if (dataId) {
  13199. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13200. if (response) {
  13201. var myData = Restangular.stripRestangular(response);
  13202. var processInstanceId = myData.data.processInstanceId;
  13203. $scope.options.templateOptions
  13204. .getData(
  13205. $scope.model,
  13206. $scope.options.templateOptions.ApiService,
  13207. processInstanceId
  13208. )
  13209. .then(function (result) {
  13210. if (result.status == 200) {
  13211. var newData = Restangular.stripRestangular(result);
  13212. $scope.followData = newData.data;
  13213. }
  13214. });
  13215. }
  13216. });
  13217. }
  13218. }, 10);
  13219. },
  13220. ],
  13221. });
  13222. //状态追踪2-事件id
  13223. formlyConfigProvider.setType({
  13224. name: "ui-followStatus2",
  13225. templateUrl: "assets/views/customform/tpl/ui-followStatus2.html",
  13226. controller: [
  13227. "$scope",
  13228. "api_bpm_data",
  13229. "Restangular",
  13230. function ($scope, api_bpm_data, Restangular) {
  13231. setTimeout(function () {
  13232. var pkey = $scope.options.templateOptions.pkey;
  13233. var dataId = $scope.model.id;
  13234. if (dataId) {
  13235. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13236. if (response) {
  13237. var myData = Restangular.stripRestangular(response);
  13238. var incidentId = myData.data.id;
  13239. $scope.options.templateOptions
  13240. .getData(
  13241. $scope.model,
  13242. $scope.options.templateOptions.ApiService,
  13243. incidentId
  13244. )
  13245. .then(function (result) {
  13246. if (result.status == 200) {
  13247. var newData = Restangular.stripRestangular(result);
  13248. $scope.followData = newData.list || [];
  13249. }
  13250. });
  13251. }
  13252. });
  13253. }
  13254. }, 10);
  13255. },
  13256. ],
  13257. });
  13258. //维修记录
  13259. formlyConfigProvider.setType({
  13260. name: "ui-handlerLog",
  13261. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  13262. controller: [
  13263. "$scope",
  13264. "api_bpm_data",
  13265. "Restangular",
  13266. function ($scope, api_bpm_data, Restangular) {
  13267. console.log($scope, 'ui-handlerLog')
  13268. },
  13269. ],
  13270. });
  13271. //资产
  13272. formlyConfigProvider.setType({
  13273. name: "ui-zc",
  13274. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  13275. controller: [
  13276. "$scope",
  13277. "api_bpm_data",
  13278. "Restangular",
  13279. function ($scope, api_bpm_data, Restangular) {
  13280. console.log($scope, 'ui-zc');
  13281. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13282. },
  13283. ],
  13284. });
  13285. //绑定的耗材
  13286. formlyConfigProvider.setType({
  13287. name: "ui-hc",
  13288. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  13289. controller: [
  13290. "$scope",
  13291. "api_cmdb2",
  13292. "Restangular",
  13293. function ($scope, api_cmdb2, Restangular) {
  13294. console.log($scope, 'ui-hc')
  13295. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  13296. $scope.list = [];
  13297. var sjId = $scope.model.incident.id;
  13298. api_cmdb2.getHc(sjId).then(function (response) {
  13299. console.log(response)
  13300. if (response.status == 200) {
  13301. $scope.list = response.data;
  13302. }
  13303. })
  13304. },
  13305. ],
  13306. });
  13307. //历史记录
  13308. formlyConfigProvider.setType({
  13309. name: "ui-history",
  13310. templateUrl: "assets/views/customform/tpl/ui-history.html",
  13311. controller: [
  13312. "$scope",
  13313. "api_bpm_data",
  13314. "Restangular",
  13315. function ($scope, api_bpm_data, Restangular) {
  13316. setTimeout(function () {
  13317. var pkey = $scope.options.templateOptions.pkey;
  13318. var dataId = $scope.model.id;
  13319. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13320. if (response) {
  13321. var myData = Restangular.stripRestangular(response);
  13322. var processInstanceId = myData.data.processInstanceId;
  13323. $scope.options.templateOptions
  13324. .getData(
  13325. $scope.model,
  13326. $scope.options.templateOptions.ApiService,
  13327. processInstanceId
  13328. )
  13329. .then(function (result) {
  13330. if (result.status == 200) {
  13331. var newData = Restangular.stripRestangular(result);
  13332. var long = newData.data.length - 1;
  13333. $scope.followData = newData.data[long];
  13334. }
  13335. });
  13336. }
  13337. });
  13338. }, 10);
  13339. },
  13340. ],
  13341. });
  13342. // //请求人信息显示
  13343. // formlyConfigProvider.setType({
  13344. // name: "ui-disrequester",
  13345. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  13346. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13347. // defaultOptions: function(options) {
  13348. // return {
  13349. // templateOptions: {}
  13350. // };
  13351. // },
  13352. // controller: ['$scope', function($scope) {
  13353. // $scope.options.templateOptions.that = $scope;
  13354. // }]
  13355. // });
  13356. //退回人信息显示
  13357. formlyConfigProvider.setType({
  13358. name: "ui-returnperson",
  13359. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  13360. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13361. defaultOptions: function (options) {
  13362. return {
  13363. templateOptions: {},
  13364. };
  13365. },
  13366. controller: [
  13367. "$scope",
  13368. function ($scope) {
  13369. $scope.group = "";
  13370. $scope.role = "";
  13371. if (
  13372. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13373. $scope.model.handlingPersonnelUser.group.length == 1
  13374. ) {
  13375. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13376. } else {
  13377. for (
  13378. var i = 0;
  13379. i < $scope.model.handlingPersonnelUser.group.length;
  13380. i++
  13381. ) {
  13382. $scope.group +=
  13383. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13384. }
  13385. }
  13386. if (
  13387. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13388. $scope.model.handlingPersonnelUser.role.length == 1
  13389. ) {
  13390. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13391. } else {
  13392. for (
  13393. var i = 0;
  13394. i < $scope.model.handlingPersonnelUser.role.length;
  13395. i++
  13396. ) {
  13397. $scope.role +=
  13398. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13399. }
  13400. }
  13401. $scope.options.templateOptions.that = $scope;
  13402. $scope.options.templateOptions.that = $scope;
  13403. },
  13404. ],
  13405. });
  13406. //退回人信息显示(去掉工作组&角色)
  13407. formlyConfigProvider.setType({
  13408. name: "ui-returnpersonNoGroup",
  13409. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  13410. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13411. defaultOptions: function (options) {
  13412. return {
  13413. templateOptions: {},
  13414. };
  13415. },
  13416. controller: [
  13417. "$scope",
  13418. function ($scope) {
  13419. $scope.group = "";
  13420. $scope.role = "";
  13421. if (
  13422. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13423. $scope.model.handlingPersonnelUser.group.length == 1
  13424. ) {
  13425. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13426. } else {
  13427. for (
  13428. var i = 0;
  13429. i < $scope.model.handlingPersonnelUser.group.length;
  13430. i++
  13431. ) {
  13432. $scope.group +=
  13433. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13434. }
  13435. }
  13436. if (
  13437. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13438. $scope.model.handlingPersonnelUser.role.length == 1
  13439. ) {
  13440. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13441. } else {
  13442. for (
  13443. var i = 0;
  13444. i < $scope.model.handlingPersonnelUser.role.length;
  13445. i++
  13446. ) {
  13447. $scope.role +=
  13448. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13449. }
  13450. }
  13451. $scope.options.templateOptions.that = $scope;
  13452. $scope.options.templateOptions.that = $scope;
  13453. },
  13454. ],
  13455. });
  13456. //指派技术人员
  13457. formlyConfigProvider.setType({
  13458. name: "ui-apiontperson",
  13459. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  13460. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13461. defaultOptions: function (options) {
  13462. return {
  13463. templateOptions: {
  13464. transtlara: function (value, $scope) { },
  13465. },
  13466. };
  13467. },
  13468. controller: [
  13469. "$scope",
  13470. "api_user_data",
  13471. "Restangular",
  13472. function ($scope, api_user_data, Restangular) {
  13473. var filterData = {
  13474. idx: 0,
  13475. sum: 1000,
  13476. };
  13477. api_user_data
  13478. .fetchDataList("group", filterData)
  13479. .then(function (response) {
  13480. if (response.status == 200) {
  13481. $scope.select = {};
  13482. $scope.multipleDemo = {};
  13483. $scope.userdata = {};
  13484. var data = response.list;
  13485. var item = [];
  13486. $scope.multipleDemo = data;
  13487. $scope.multipleDemo;
  13488. }
  13489. });
  13490. $scope.options.templateOptions.onChange = function (
  13491. id,
  13492. options,
  13493. groupdata,
  13494. $event,
  13495. model
  13496. ) {
  13497. if (groupdata.option) {
  13498. $scope.model[$scope.options.key] = {};
  13499. var fildate = {
  13500. idx: 0,
  13501. sum: 1000,
  13502. user: {
  13503. roledata: {
  13504. rolecode: model.currentRole,
  13505. },
  13506. selectType: "1",
  13507. groupdata: {
  13508. id: groupdata.option.id,
  13509. },
  13510. engineer: 1,
  13511. },
  13512. };
  13513. api_user_data
  13514. .fetchDataList("user", fildate)
  13515. .then(function (response) {
  13516. if (response.status == 200) {
  13517. $scope.userdata = {};
  13518. $scope.userdata = response.list;
  13519. }
  13520. });
  13521. } else {
  13522. $scope.model[$scope.options.key] = {
  13523. id: groupdata.id.id,
  13524. };
  13525. $scope.options.templateOptions.transtlara(
  13526. $scope.model[$scope.options.key],
  13527. $scope
  13528. );
  13529. }
  13530. };
  13531. // }
  13532. },
  13533. ],
  13534. });
  13535. //请求科室信息(小蓝框) lmm
  13536. formlyConfigProvider.setType({
  13537. name: "ui-deptinformation",
  13538. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13539. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13540. return {
  13541. templateOptions: {
  13542. checkform: function (options) { },
  13543. },
  13544. };
  13545. },
  13546. controller: [
  13547. "$scope",
  13548. "api_statistic",
  13549. function ($scope, api_statistic) {
  13550. // console.log($scope)
  13551. },
  13552. ],
  13553. });
  13554. //请求人信息
  13555. formlyConfigProvider.setType({
  13556. name: "ui-requesterinformation",
  13557. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13558. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13559. return {
  13560. templateOptions: {
  13561. checkform: function (options) {
  13562. if (options.model.requester) {
  13563. options.value(options.model.requester);
  13564. }
  13565. },
  13566. addRequeter: function (size, options, modal, e) {
  13567. if (e) {
  13568. if (e.clientX === 0) {
  13569. return;
  13570. }
  13571. e.preventDefault();
  13572. }
  13573. var modalInstance = modal.open({
  13574. templateUrl:
  13575. "assets/views/customform/tpl/modal-add-callrequester.html",
  13576. controller: function (
  13577. $scope,
  13578. sco,
  13579. $rootScope,
  13580. $modalInstance,
  13581. items,
  13582. SweetAlert,
  13583. title,
  13584. Restangular,
  13585. APIService,
  13586. UserService,
  13587. api_user_data,
  13588. api_statistic,
  13589. api_wechatfile,
  13590. $stateParams
  13591. ) {
  13592. $modalInstance.SweetAlert = SweetAlert;
  13593. $scope.title = "新增报修人";
  13594. $scope.requester = {};
  13595. $scope.searchData = {};
  13596. $scope.isRoom = sessionStorage.getItem('ifRoom') == 1;
  13597. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13598. var paramsModel = JSON.parse($stateParams.model)
  13599. //来电-添加报修人-回显电话
  13600. if (paramsModel.model.incident.requester.hjzxPhone) {
  13601. $scope.requester.phone = paramsModel.model.incident.requester.hjzxPhone;
  13602. }
  13603. }
  13604. $scope.onChangeadd = function (searchData) {
  13605. $scope.searchKey = searchData.account;
  13606. // $scope.searchDataadd = searchData;
  13607. var requesdata = angular.copy(searchData);
  13608. if (requesdata.phone) {
  13609. delete requesdata.phone;
  13610. }
  13611. $scope.requester = requesdata;
  13612. console.log($scope.requester);
  13613. };
  13614. $scope.refreshUseradd = function (searchKey) {
  13615. //请求人搜索
  13616. $scope.requester.account = searchKey;
  13617. $scope.searchData = searchKey;
  13618. serchdataadd(searchKey);
  13619. };
  13620. $scope.getMydata = function (x) {
  13621. $scope.searchField = JSON.parse(x[0]).account;
  13622. $scope.requester = JSON.parse(x[0]);
  13623. console.log($scope.requester);
  13624. };
  13625. $scope.getMydataone = function (x) {
  13626. $scope.searchField = x;
  13627. $scope.requester.account = x;
  13628. };
  13629. serchdataadd();
  13630. api_wechatfile
  13631. .getDictionary({
  13632. type: "list",
  13633. key: "male",
  13634. })
  13635. .then(function (data) {
  13636. if (data.status == 200) {
  13637. requester.gender = data.list;
  13638. }
  13639. });
  13640. function serchdataadd(searchKey) {
  13641. if (searchKey) {
  13642. var filterData = {
  13643. user: {
  13644. name: searchKey,
  13645. selectType: "pinyin_all",
  13646. engineer: 0,
  13647. },
  13648. idx: 0,
  13649. sum: 10,
  13650. };
  13651. } else {
  13652. var filterData = {
  13653. idx: 0,
  13654. sum: 10,
  13655. user: {
  13656. engineer: 0,
  13657. },
  13658. };
  13659. }
  13660. api_user_data
  13661. .fetchDataList("user", filterData)
  13662. .then(function (response) {
  13663. var myData = response;
  13664. $scope.myData = myData.list;
  13665. });
  13666. }
  13667. api_user_data
  13668. .fetchDataList("area", {
  13669. idx: 0,
  13670. sum: 1000,
  13671. })
  13672. .then(function (response) {
  13673. if (response.status == 200) {
  13674. $scope.areas = response.list;
  13675. }
  13676. });
  13677. api_wechatfile
  13678. .getDictionary(
  13679. {
  13680. key: "requester_type",
  13681. type: "list",
  13682. },
  13683. {
  13684. idx: 0,
  13685. sum: 100,
  13686. }
  13687. )
  13688. .then(function (response) {
  13689. if (response) {
  13690. $scope.networktypes = response;
  13691. }
  13692. });
  13693. $scope.requesterAreaid = "";
  13694. $scope.onChange = function (item) {
  13695. $scope.requesterAreaid = item.id;
  13696. api_user_data
  13697. .fetchDataList("place", {
  13698. place: {
  13699. area: {
  13700. id: item.id,
  13701. },
  13702. },
  13703. idx: 0,
  13704. sum: 1000,
  13705. })
  13706. .then(function (response) {
  13707. if (response.status == 200) {
  13708. $scope.places = response.list;
  13709. delete $scope.requester.placeDTO;
  13710. }
  13711. });
  13712. };
  13713. // 修改地点
  13714. $scope.requesterPlaceid = "";
  13715. $scope.onChangePlace = function (item) {
  13716. $scope.requesterPlaceid = item.id;
  13717. api_user_data
  13718. .fetchDataList("room", {
  13719. room: {
  13720. place: {
  13721. id: item.id,
  13722. },
  13723. },
  13724. idx: 0,
  13725. sum: 1000,
  13726. })
  13727. .then(function (response) {
  13728. if (response.status == 200) {
  13729. $scope.rooms = response.list;
  13730. }
  13731. });
  13732. };
  13733. $scope.refresh = function (searchVal) {
  13734. var faildata = {};
  13735. if ($scope.requesterAreaid) {
  13736. faildata = {
  13737. idx: 0,
  13738. sum: 1000,
  13739. place: {
  13740. areaId: $scope.requesterAreaid,
  13741. place: searchVal,
  13742. selectType: "pinyin_qs",
  13743. },
  13744. };
  13745. } else {
  13746. faildata = {
  13747. idx: 0,
  13748. sum: 1000,
  13749. place: {
  13750. place: searchVal,
  13751. selectType: "pinyin_qs",
  13752. },
  13753. };
  13754. }
  13755. api_user_data
  13756. .fetchDataList("place", faildata)
  13757. .then(function (response) {
  13758. $scope.places = response.list;
  13759. delete $scope.requester.placeDTO;
  13760. });
  13761. };
  13762. // 初始化房间号
  13763. $scope.refreshPlace = function () {
  13764. var faildata = {};
  13765. if ($scope.requesterPlaceid) {
  13766. faildata = {
  13767. idx: 0,
  13768. sum: 1000,
  13769. room: {
  13770. place: {id:$scope.requesterPlaceid},
  13771. },
  13772. };
  13773. } else {
  13774. faildata = {
  13775. idx: 0,
  13776. sum: 1000,
  13777. room: {
  13778. place: {id:$scope.requesterPlaceid},
  13779. },
  13780. };
  13781. }
  13782. api_user_data
  13783. .fetchDataList("room", faildata)
  13784. .then(function (response) {
  13785. $scope.rooms = response.list;
  13786. });
  13787. };
  13788. $scope.refreshDepts = function (key) {
  13789. var filterData = {
  13790. idx: 0,
  13791. sum: 5,
  13792. dept: {
  13793. name: key,
  13794. },
  13795. };
  13796. UserService.fetchDataList("department", filterData).then(
  13797. function (response) {
  13798. if (response.status == 200) {
  13799. $scope.depts = response.list;
  13800. }
  13801. }
  13802. );
  13803. };
  13804. $scope.ok = function () {
  13805. if (
  13806. angular.isUndefined($scope.requester.account) ||
  13807. $scope.requester.account == null ||
  13808. $scope.requester.account == ""
  13809. ) {
  13810. SweetAlert.swal(
  13811. "报修人员编号未填!",
  13812. "请填写报修人员编号",
  13813. "error"
  13814. );
  13815. } else if (
  13816. angular.isUndefined($scope.requester.name) ||
  13817. $scope.requester.name == null ||
  13818. $scope.requester.name == ""
  13819. ) {
  13820. SweetAlert.swal(
  13821. "报修人姓名未填!",
  13822. "请填写报修人姓名",
  13823. "error"
  13824. );
  13825. } else if (
  13826. angular.isUndefined($scope.requester.requesterType) ||
  13827. $scope.requester.requesterType == null ||
  13828. $scope.requester.requesterTypeDTO == ""
  13829. ) {
  13830. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13831. } else if (
  13832. angular.isUndefined($scope.requester.phone) ||
  13833. $scope.requester.phone == null ||
  13834. $scope.requester.phone == ""
  13835. ) {
  13836. SweetAlert.swal(
  13837. "报修人联系电话未填!",
  13838. "请填写报修人联系电话",
  13839. "error"
  13840. );
  13841. } else {
  13842. $scope.requesterId = $scope.requester.id;
  13843. var data = {
  13844. incident: {
  13845. requester: {
  13846. id: $scope.requesterId,
  13847. },
  13848. },
  13849. idx: 0,
  13850. sum: 3,
  13851. };
  13852. api_statistic
  13853. .tableData(data, "incident")
  13854. .then(function (data) {
  13855. sco.$parent.$parent.$parent.model.incident.tableList =
  13856. data.list;
  13857. });
  13858. $scope.$watch(
  13859. sco.$parent.$parent.$parent.model.incident.tableList,
  13860. function (oldObj, newObj) {
  13861. if (newObj != oldObj) {
  13862. sco.$parent.$parent.$parent.model.incident.tableList =
  13863. newObj;
  13864. }
  13865. }
  13866. );
  13867. console.log($scope.requester);
  13868. $modalInstance.close($scope.requester);
  13869. }
  13870. };
  13871. $scope.cancel = function () {
  13872. $modalInstance.dismiss("cancel");
  13873. };
  13874. },
  13875. resolve: {
  13876. items: function () {
  13877. return {
  13878. fetchItems: function (filterData, APIService) {
  13879. filterData = filterData || {};
  13880. if (!filterData.idx) {
  13881. filterData = {
  13882. idx: 0,
  13883. sum: 10,
  13884. };
  13885. }
  13886. return options.templateOptions.fetchItems(
  13887. filterData,
  13888. APIService
  13889. );
  13890. },
  13891. };
  13892. },
  13893. title: function () {
  13894. return options.templateOptions.modalTitle;
  13895. },
  13896. Restangular: function () {
  13897. return options.templateOptions.Restangular;
  13898. },
  13899. APIService: function () {
  13900. return options.templateOptions.ApiService;
  13901. },
  13902. UserService: function () {
  13903. return options.templateOptions.UserService;
  13904. },
  13905. sco: function () {
  13906. return $scope;
  13907. },
  13908. },
  13909. });
  13910. modalInstance.result.then(
  13911. function (selectedItem) {
  13912. console.log(selectedItem);
  13913. if (selectedItem) {
  13914. var data = {
  13915. requester: selectedItem,
  13916. };
  13917. $scope.searchKey = selectedItem.account;
  13918. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13919. // if (selectedItem.place && selectedItem.place.place) {
  13920. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13921. // }
  13922. options.templateOptions.UserService.addData(
  13923. "requester",
  13924. data
  13925. ).then(function (response) {
  13926. if (response.status == 200) {
  13927. if (options.model) {
  13928. options.model.requester = response.data;
  13929. $scope.$parent.$parent.$parent.model.incident.requester =
  13930. response.data;
  13931. $scope.$parent.$parent.$parent.model.requestershow =
  13932. response.data;
  13933. if (options.model.place) {
  13934. options.model.place.id = "";
  13935. }
  13936. if (options.model.area) {
  13937. options.model.area.id = "";
  13938. }
  13939. options.model.contacts = selectedItem.name;
  13940. if (
  13941. selectedItem.phone &&
  13942. selectedItem.phone != null &&
  13943. selectedItem.phone != ""
  13944. ) {
  13945. options.model.contactsInformation =
  13946. selectedItem.phone;
  13947. } else {
  13948. options.model.contactsInformation =
  13949. selectedItem.telephone;
  13950. }
  13951. if (
  13952. selectedItem.requesterTypeDTO &&
  13953. selectedItem.requesterTypeDTO.id == 2
  13954. ) {
  13955. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13956. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13957. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13958. }
  13959. }
  13960. if (!response.data.id) {
  13961. response.data.id = selectedItem.id;
  13962. }
  13963. options.value(response.data);
  13964. options.value(response.data);
  13965. console.log($scope, "0000000");
  13966. //新增报修人带入区域地点2020年4月23日19:48:15
  13967. $scope.model.selecthouseNumber = selectedItem.place
  13968. ? selectedItem.place
  13969. : {};
  13970. $scope.$root.selecthouseNumber = selectedItem.place
  13971. ? selectedItem.place
  13972. : {};
  13973. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13974. if (selectedItem.place && selectedItem.place.id) {
  13975. options.model.place.id = selectedItem.place.id;
  13976. options.model.place.area.id =
  13977. selectedItem.place.area.id;
  13978. }
  13979. } else {
  13980. if (selectedItem.place && selectedItem.place.id) {
  13981. options.model.place.id = selectedItem.place.id;
  13982. options.model.area.id = selectedItem.place.area.id;
  13983. }
  13984. }
  13985. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13986. // options.model.area.id = selectedItem.place.area.id
  13987. // }
  13988. if (selectedItem.houseNumber) {
  13989. options.model.houseNumber = selectedItem.houseNumber;
  13990. }
  13991. if (selectedItem.room) {
  13992. options.model.room.id = selectedItem.room.id;
  13993. }
  13994. // if (selectedItem.id) {
  13995. options.model.account = selectedItem.account;
  13996. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  13997. var baoxiuFields =
  13998. $scope.$parent.$parent.$parent.$parent.$parent.vm
  13999. .fields[1].fields;
  14000. var baoxiurenTo;
  14001. baoxiuFields.forEach((e, i) => {
  14002. if (e.key == "account") {
  14003. baoxiurenTo = e.templateOptions;
  14004. baoxiurenTo.APIService.fetchDataList("user", {
  14005. idx: 0,
  14006. sum: 20,
  14007. user: {
  14008. name: selectedItem.account,
  14009. selectType: "pinyin_all",
  14010. engineer: 0,
  14011. },
  14012. }).then((res) => {
  14013. baoxiurenTo.options = res.list;
  14014. options.model.account = selectedItem.account;
  14015. });
  14016. }
  14017. });
  14018. // }
  14019. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  14020. // 选择重复事件侧滑框
  14021. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  14022. $scope.$parent.$parent.$parent.model[
  14023. "repeatIncidentShow"
  14024. ] = false;
  14025. setTimeout(() => {
  14026. $scope.$parent.$parent.$parent.model[
  14027. "repeatIncidentShow"
  14028. ] = true;
  14029. }, 500);
  14030. // }
  14031. } else {
  14032. modalInstance.SweetAlert.swal({
  14033. title: "系统错误",
  14034. text: "账号重复!",
  14035. type: "error",
  14036. });
  14037. }
  14038. });
  14039. }
  14040. },
  14041. function () { }
  14042. );
  14043. },
  14044. changeRequeter: function (
  14045. size,
  14046. options,
  14047. modal,
  14048. modeldata,
  14049. $rootScope
  14050. ) {
  14051. var modalInstance = modal.open({
  14052. templateUrl:
  14053. "assets/views/customform/tpl/modal-change-requester.html",
  14054. controller: function (
  14055. $scope,
  14056. $modalInstance,
  14057. items,
  14058. SweetAlert,
  14059. title,
  14060. Restangular,
  14061. APIService,
  14062. UserService,
  14063. api_user_data,
  14064. $rootScope
  14065. ) {
  14066. $scope.title = "修改报修人";
  14067. $scope.requester = {
  14068. id: modeldata.requester.id,
  14069. account: modeldata.requester.account,
  14070. name: modeldata.requester.name,
  14071. gender: modeldata.requester.gender,
  14072. email: modeldata.requester.email,
  14073. deptName: modeldata.requester.deptName,
  14074. phone: modeldata.requester.phone,
  14075. telephone: modeldata.requester.telephone,
  14076. studentNo: modeldata.requester.studentNo,
  14077. areaDTO: modeldata.requester.areaDTO,
  14078. placeDTO: modeldata.requester.placeDTO,
  14079. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  14080. };
  14081. $scope.onChangeadd = function (searchData) {
  14082. console.log(searchData);
  14083. $scope.searchKey = searchData.account;
  14084. var requesdata = angular.copy(searchData);
  14085. if (requesdata.phone) {
  14086. delete requesdata.phone;
  14087. }
  14088. $scope.requester = requesdata;
  14089. };
  14090. $scope.refreshUseradd = function (searchKey) {
  14091. //请求人搜索
  14092. $scope.requester.account = searchKey;
  14093. $scope.searchData = searchKey;
  14094. serchdataadd(searchKey);
  14095. };
  14096. $scope.getMydata = function (x) {
  14097. $scope.searchField = JSON.parse(x[0]).account;
  14098. $scope.requester = JSON.parse(x[0]);
  14099. };
  14100. $scope.getMydataone = function (x) {
  14101. $scope.searchField = x;
  14102. $scope.requester.account = x;
  14103. };
  14104. serchdataadd();
  14105. function serchdataadd(searchKey) {
  14106. if (searchKey) {
  14107. var filterData = {
  14108. user: {
  14109. name: searchKey,
  14110. selectType: "pinyin_all",
  14111. engineer: 0,
  14112. },
  14113. idx: 0,
  14114. sum: 10,
  14115. };
  14116. } else {
  14117. var filterData = {
  14118. idx: 0,
  14119. sum: 10,
  14120. user:{
  14121. engineer: 0,
  14122. }
  14123. };
  14124. }
  14125. api_user_data
  14126. .fetchDataList("user", filterData)
  14127. .then(function (response) {
  14128. var myData = response;
  14129. $scope.myData = myData.list;
  14130. });
  14131. }
  14132. api_user_data
  14133. .fetchDataList("area", {
  14134. idx: 0,
  14135. sum: 1000,
  14136. })
  14137. .then(function (response) {
  14138. if (response.status == 200) {
  14139. $scope.areas = response.list;
  14140. }
  14141. });
  14142. api_user_data
  14143. .fetchDataList("requesterType", {
  14144. idx: 0,
  14145. sum: 100,
  14146. })
  14147. .then(function (response) {
  14148. if (response.status == 200) {
  14149. $scope.networktypes = response.list;
  14150. }
  14151. });
  14152. if (
  14153. $scope.requester.areaDTO &&
  14154. $scope.requester.areaDTO.id &&
  14155. $scope.requester.areaDTO.id != ""
  14156. ) {
  14157. api_user_data
  14158. .fetchDataList("place", {
  14159. place: {
  14160. areaId: $scope.requester.areaDTO.id,
  14161. },
  14162. idx: 0,
  14163. sum: 1000,
  14164. })
  14165. .then(function (response) {
  14166. if (response.status == 200) {
  14167. $scope.places = response.list;
  14168. }
  14169. });
  14170. }
  14171. $scope.onChange = function (item) {
  14172. $scope.requester.placeDTO = {};
  14173. api_user_data
  14174. .fetchDataList("place", {
  14175. place: {
  14176. areaId: item.id,
  14177. },
  14178. idx: 0,
  14179. sum: 1000,
  14180. })
  14181. .then(function (response) {
  14182. if (response.status == 200) {
  14183. $scope.places = response.list;
  14184. }
  14185. });
  14186. };
  14187. $scope.refreshDepts = function (key) {
  14188. var filterData = {
  14189. idx: 0,
  14190. sum: 5,
  14191. dept: {
  14192. name: key,
  14193. },
  14194. };
  14195. UserService.fetchDataList("department", filterData).then(
  14196. function (response) {
  14197. if (response.status == 200) {
  14198. $scope.depts = response.list;
  14199. }
  14200. }
  14201. );
  14202. };
  14203. $scope.ok = function () {
  14204. if (
  14205. $scope.requester.account == "" ||
  14206. $scope.requester.name == ""
  14207. ) {
  14208. SweetAlert.swal(
  14209. "报修人姓名或人员编号号未填!",
  14210. "请补全报修人信息",
  14211. "error"
  14212. );
  14213. } else {
  14214. $modalInstance.close($scope.requester);
  14215. }
  14216. };
  14217. $scope.cancel = function () {
  14218. $modalInstance.dismiss("cancel");
  14219. };
  14220. },
  14221. resolve: {
  14222. items: function () {
  14223. return {
  14224. fetchItems: function (filterData, APIService) {
  14225. filterData = filterData || {};
  14226. if (!filterData.idx) {
  14227. filterData = {
  14228. idx: 0,
  14229. sum: 10,
  14230. };
  14231. }
  14232. return options.templateOptions.fetchItems(
  14233. filterData,
  14234. APIService
  14235. );
  14236. },
  14237. };
  14238. },
  14239. title: function () {
  14240. return options.templateOptions.modalTitle;
  14241. },
  14242. Restangular: function () {
  14243. return options.templateOptions.Restangular;
  14244. },
  14245. APIService: function () {
  14246. return options.templateOptions.ApiService;
  14247. },
  14248. UserService: function () {
  14249. return options.templateOptions.UserService;
  14250. },
  14251. },
  14252. });
  14253. modalInstance.result.then(
  14254. function (selectedItem) {
  14255. console.log(selectedItem);
  14256. if (selectedItem) {
  14257. if (options.model) {
  14258. if (options.model.place) {
  14259. options.model.place.id = "";
  14260. }
  14261. if (options.model.area) {
  14262. options.model.area.id = "";
  14263. }
  14264. options.model.contacts = selectedItem.name;
  14265. if (
  14266. selectedItem.phone &&
  14267. selectedItem.phone != null &&
  14268. selectedItem.phone != ""
  14269. ) {
  14270. options.model.contactsInformation = selectedItem.phone;
  14271. } else {
  14272. options.model.contactsInformation =
  14273. selectedItem.telephone;
  14274. }
  14275. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14276. options.model.place.id = selectedItem.placeDTO.id;
  14277. }
  14278. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14279. options.model.area.id = selectedItem.areaDTO.id;
  14280. }
  14281. if (
  14282. selectedItem.requesterTypeDTO &&
  14283. selectedItem.requesterTypeDTO.id == 2
  14284. ) {
  14285. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14286. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14287. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14288. }
  14289. }
  14290. var data = {
  14291. requester: selectedItem,
  14292. };
  14293. options.templateOptions.UserService.addData(
  14294. "requester",
  14295. data
  14296. ).then(function (response) {
  14297. if (response.status == 200) {
  14298. $scope.$parent.$parent.$parent.model["requestershow"] =
  14299. selectedItem;
  14300. options.value(response.data);
  14301. } else {
  14302. }
  14303. });
  14304. }
  14305. },
  14306. function () { }
  14307. );
  14308. event.preventDefault();
  14309. },
  14310. },
  14311. };
  14312. },
  14313. controller: [
  14314. "$scope",
  14315. "api_user_data",
  14316. "api_statistic",
  14317. "$stateParams",
  14318. "api_bpm_data",
  14319. function ($scope, api_user_data, api_statistic, $stateParams,api_bpm_data) {
  14320. console.log($stateParams)
  14321. // 一键复制
  14322. $scope.quickCopy = function(model){
  14323. // 姓名,工号,来电电话,地点,详细地址,故障描述 liaomingming
  14324. console.log(model);
  14325. var text = '';
  14326. if(model.place.id){
  14327. api_bpm_data.fetchData("place", model.place.id)
  14328. .then(function (response) {
  14329. if (response.status == 200) {
  14330. 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||''}`;
  14331. var textarea = document.createElement('textarea');
  14332. document.body.appendChild(textarea);
  14333. // 隐藏此输入框
  14334. textarea.style.position = 'fixed';
  14335. textarea.style.clip = 'rect(0 0 0 0)';
  14336. textarea.style.top = '10px';
  14337. // 赋值
  14338. textarea.value = text;
  14339. // 选中
  14340. textarea.select();
  14341. // 复制
  14342. document.execCommand('copy', true);
  14343. // 移除输入框
  14344. document.body.removeChild(textarea);
  14345. }
  14346. });
  14347. }else{
  14348. text = `姓名:${model.contacts||''}\r\n工号:${model.account||''}\r\n来电电话:${model.contactsInformation||''}\r\n地点:${''}\r\n详细地址:${model.houseNumber||''}\r\n故障描述:${model.description||''}`;
  14349. var textarea = document.createElement('textarea');
  14350. document.body.appendChild(textarea);
  14351. // 隐藏此输入框
  14352. textarea.style.position = 'fixed';
  14353. textarea.style.clip = 'rect(0 0 0 0)';
  14354. textarea.style.top = '10px';
  14355. // 赋值
  14356. textarea.value = text;
  14357. // 选中
  14358. textarea.select();
  14359. // 复制
  14360. document.execCommand('copy', true);
  14361. // 移除输入框
  14362. document.body.removeChild(textarea);
  14363. }
  14364. event.preventDefault();
  14365. //提示
  14366. alert('复制成功');
  14367. }
  14368. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  14369. var paramsModel = JSON.parse($stateParams.model)
  14370. //来电-添加报修人
  14371. if (paramsModel.model.incident.requester.hjzxPhone) {
  14372. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  14373. }
  14374. }
  14375. $scope.options.initialValue = $scope.model[$scope.options.key];
  14376. $scope.saveReqPlace = false;
  14377. $scope.model.saveReqPlace = false;
  14378. $scope.selectGradeBox = function () {
  14379. $scope.saveReqPlace = !$scope.saveReqPlace;
  14380. console.log($scope);
  14381. $scope.model.saveReqPlace = $scope.saveReqPlace;
  14382. };
  14383. if (
  14384. $scope.model.requester &&
  14385. $scope.model.requester.requesterTypeDTO &&
  14386. $scope.model.requester.requesterTypeDTO.id == 2
  14387. ) {
  14388. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14389. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14390. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14391. }
  14392. },
  14393. ],
  14394. });
  14395. // 请求人选控件
  14396. formlyConfigProvider.setType({
  14397. name: "ui-requesterselect",
  14398. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  14399. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14400. defaultOptions: function (options, $scope) {
  14401. return {
  14402. templateOptions: {
  14403. // checkform: function(options) {
  14404. // if (options.model.requestershow) {
  14405. // options.value(options.model.requestershow);
  14406. // }
  14407. // },
  14408. validators: {
  14409. required: {
  14410. expression: function (viewValue, modelValue) {
  14411. var value = modelValue || viewValue;
  14412. return value.length >= 1;
  14413. },
  14414. },
  14415. },
  14416. openModal: function (size, options, modal) {
  14417. //查找弹出框
  14418. var modelObject = options.value();
  14419. var searchModal = function (filterSearchData) {
  14420. var modalInstance = modal.open({
  14421. templateUrl:
  14422. "assets/views/customform/tpl/checktable-modal-content.html",
  14423. controller: function (
  14424. $scope,
  14425. scope,
  14426. i18nService,
  14427. $modalInstance,
  14428. items,
  14429. title,
  14430. Restangular,
  14431. APIService,
  14432. language,
  14433. searchDatas,
  14434. api_bpm_data
  14435. ) {
  14436. $scope.langs = i18nService.getAllLangs();
  14437. $scope.lang = "zh-cn";
  14438. i18nService.setCurrentLang($scope.lang);
  14439. $scope.gridOptions = {};
  14440. $scope.gridOptions.data = "myData";
  14441. $scope.gridOptions.enableColumnResizing = true;
  14442. $scope.gridOptions.enableFiltering = true;
  14443. $scope.gridOptions.enableGridMenu = false;
  14444. $scope.gridOptions.enableRowSelection = true;
  14445. $scope.gridOptions.showGridFooter = true;
  14446. $scope.gridOptions.showColumnFooter = false;
  14447. $scope.gridOptions.fastWatch = true;
  14448. $scope.gridOptions.useExternalFiltering = true;
  14449. $scope.gridOptions.useExternalPagination = true;
  14450. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14451. $scope.gridOptions.paginationPageSize = 10;
  14452. $scope.gridOptions.multiSelect = false;
  14453. $scope.gridOptions.rowIdentity = function (row) {
  14454. return row.id;
  14455. };
  14456. $scope.gridOptions.getRowIdentity = function (row) {
  14457. return row.id;
  14458. };
  14459. $scope.gridOptions.columnDefs = [
  14460. {
  14461. name: "account",
  14462. displayName: "人员编号",
  14463. width: 140,
  14464. },
  14465. {
  14466. name: "name",
  14467. displayName: "姓名",
  14468. width: 100,
  14469. },
  14470. {
  14471. name: "gender.name",
  14472. displayName: "性别",
  14473. width: 80,
  14474. enableFiltering: false,
  14475. },
  14476. {
  14477. name: "phone",
  14478. displayName: "电话",
  14479. width: 100,
  14480. enableFiltering: false,
  14481. },
  14482. {
  14483. name: "email",
  14484. displayName: "邮件",
  14485. width: 100,
  14486. },
  14487. {
  14488. name: "areaDTO.area",
  14489. displayName: "区域",
  14490. width: 100,
  14491. enableFiltering: false,
  14492. },
  14493. {
  14494. name: "placeDTO.place",
  14495. displayName: "地点",
  14496. enableFiltering: false,
  14497. },
  14498. ];
  14499. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14500. $scope.gridApi = gridApi;
  14501. // var filtersData = $scope.memoryfilterData;
  14502. // filtersData.idx = newPage - 1;
  14503. // filtersData.sum = pageSize;
  14504. gridApi.pagination.on.paginationChanged(
  14505. $scope,
  14506. function (newPage, pageSize) {
  14507. var filtersData = $scope.memoryfilterData;
  14508. filtersData.idx = newPage - 1;
  14509. filtersData.sum = pageSize;
  14510. $scope.loadData(filtersData);
  14511. }
  14512. );
  14513. gridApi.selection.on.rowSelectionChanged(
  14514. $scope,
  14515. function (data) {
  14516. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  14517. $scope.selected.item = data.entity;
  14518. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  14519. }
  14520. );
  14521. gridApi.core.on.filterChanged($scope, function () {
  14522. var grid = this.grid;
  14523. var filtersData = {
  14524. idx: 0,
  14525. sum: 10,
  14526. // 'requester': { 'userType': 1 }
  14527. };
  14528. angular.forEach(grid.columns, function (item) {
  14529. if (item.enableFiltering) {
  14530. if (
  14531. angular.isDefined(item.filters[0].term) &&
  14532. item.filters[0].term != ""
  14533. ) {
  14534. if (angular.isUndefined(filtersData["requester"])) {
  14535. filtersData["requester"] = {};
  14536. }
  14537. filtersData["requester"][item.field] =
  14538. item.filters[0].term;
  14539. }
  14540. }
  14541. });
  14542. $scope.memoryfilterData = filtersData;
  14543. $scope.loadData(filtersData);
  14544. });
  14545. };
  14546. $scope.memoryfilterData = defaultFilterData = {
  14547. idx: 0,
  14548. sum: 10,
  14549. };
  14550. $scope.loadData = function (filterData) {
  14551. if (!filterData.requester) {
  14552. filterData.requester = {};
  14553. }
  14554. if (scope.roleidcode) {
  14555. angular.extend(filterData["requester"], {
  14556. userType: 1,
  14557. });
  14558. }
  14559. items
  14560. .fetchItems(filterData, APIService)
  14561. .then(function (data) {
  14562. var myData = Restangular.stripRestangular(data);
  14563. $scope.gridOptions.totalItems = myData.totalNum;
  14564. $scope.myData = myData.list;
  14565. });
  14566. };
  14567. // $scope.title = title;
  14568. if (searchDatas) {
  14569. $scope.loadData(searchDatas);
  14570. } else {
  14571. $scope.loadData({
  14572. idx: 0,
  14573. sum: 10,
  14574. });
  14575. }
  14576. $scope.selected = {
  14577. item: {},
  14578. };
  14579. $scope.ok = function () {
  14580. $modalInstance.close($scope.selected.item);
  14581. };
  14582. $scope.cancel = function () {
  14583. $modalInstance.dismiss("cancel");
  14584. };
  14585. },
  14586. size: size,
  14587. resolve: {
  14588. items: function () {
  14589. return {
  14590. fetchItems: function (filterData, APIService) {
  14591. filterData = filterData || {};
  14592. if (
  14593. angular.isUndefined(filterData.idx) ||
  14594. filterData.idx == null
  14595. ) {
  14596. filterData = {
  14597. idx: 0,
  14598. sum: 10,
  14599. };
  14600. }
  14601. return options.templateOptions.fetchItems(
  14602. filterData,
  14603. APIService
  14604. );
  14605. },
  14606. };
  14607. },
  14608. title: function () {
  14609. return options.templateOptions.modalTitle;
  14610. },
  14611. Restangular: function () {
  14612. return options.templateOptions.Restangular;
  14613. },
  14614. APIService: function () {
  14615. return options.templateOptions.ApiService;
  14616. },
  14617. language: function () {
  14618. return options.templateOptions.language;
  14619. },
  14620. searchDatas: function () {
  14621. return filterSearchData;
  14622. },
  14623. scope: function () {
  14624. return $scope;
  14625. },
  14626. },
  14627. });
  14628. modalInstance.result.then(
  14629. function (selectedItem) {
  14630. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14631. selectedItem.telephone =
  14632. $scope.model.incident.contactsInformation;
  14633. }
  14634. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14635. selectedItem;
  14636. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14637. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14638. if ($scope.model) {
  14639. if ($scope.model.incident.place) {
  14640. $scope.model.incident.place.id = "";
  14641. }
  14642. if ($scope.model.area) {
  14643. $scope.model.incident.area.id = "";
  14644. }
  14645. $scope.model.incident.contacts = selectedItem.name;
  14646. if (
  14647. selectedItem.phone &&
  14648. selectedItem.phone != null &&
  14649. selectedItem.phone != ""
  14650. ) {
  14651. $scope.model.incident.contactsInformation =
  14652. selectedItem.phone;
  14653. } else {
  14654. $scope.model.incident.contactsInformation =
  14655. selectedItem.telephone;
  14656. }
  14657. $scope.model.incident.houseNumber = "";
  14658. if (
  14659. selectedItem.requesterTypeDTO &&
  14660. selectedItem.requesterTypeDTO.id == 2
  14661. ) {
  14662. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14663. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14664. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14665. }
  14666. }
  14667. $scope.options.value(selectedItem);
  14668. $scope.searchData = selectedItem.account;
  14669. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14670. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14671. }
  14672. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14673. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14674. }
  14675. if (selectedItem.houseNumber) {
  14676. $scope.model.incident.houseNumber =
  14677. selectedItem.houseNumber;
  14678. }
  14679. if (
  14680. selectedItem.requesterTypeDTO &&
  14681. selectedItem.requesterTypeDTO.id == 2
  14682. ) {
  14683. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14684. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14685. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14686. }
  14687. if (
  14688. options.templateOptions.callback &&
  14689. angular.isFunction(options.templateOptions.callback)
  14690. ) {
  14691. options.templateOptions.callback(selectedItem, options);
  14692. }
  14693. if (!$scope.roleidcode) {
  14694. $scope.charging(selectedItem, modal);
  14695. }
  14696. $scope.recentlyincident(selectedItem);
  14697. },
  14698. function () {
  14699. //console.log('Modal dismissed at: ' + new Date());
  14700. }
  14701. );
  14702. };
  14703. searchModal();
  14704. // }
  14705. },
  14706. },
  14707. };
  14708. },
  14709. controller: [
  14710. "$rootScope",
  14711. "$scope",
  14712. "ngTableParams",
  14713. "$filter",
  14714. "SweetAlert",
  14715. "moment",
  14716. function (
  14717. $rootScope,
  14718. $scope,
  14719. ngTableParams,
  14720. $filter,
  14721. SweetAlert,
  14722. moment
  14723. ) {
  14724. $scope.isHk = $rootScope.isHk;
  14725. $scope.roleidcode = true;
  14726. // $scope.options.initialValue = undefined;
  14727. if ($rootScope.user && $rootScope.user.role) {
  14728. angular.forEach($rootScope.user.role, function (item) {
  14729. if (item.rolecode == "call center") {
  14730. $scope.roleidcode = false;
  14731. }
  14732. });
  14733. }
  14734. $scope.recently = false;
  14735. $scope.recentlyincident = function (key, model) {
  14736. //关联事件
  14737. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14738. idx: 0,
  14739. sum: 4,
  14740. incident: {
  14741. requester: {
  14742. id: key.id,
  14743. },
  14744. },
  14745. }).then(function (response) {
  14746. if (response.status == 200) {
  14747. $scope.recently = true;
  14748. $scope.recentincident = response.list;
  14749. } else {
  14750. $scope.recently = false;
  14751. }
  14752. });
  14753. $scope.bodyHeight = window.innerHeight - 100;
  14754. $(window).resize(function () {
  14755. $scope.bodyHeight = window.innerHeight - 100;
  14756. });
  14757. // $scope.shows = false;
  14758. $scope.tempData = {};
  14759. $scope.close = function () {
  14760. $scope.changes = !$scope.changes;
  14761. event.preventDefault();
  14762. };
  14763. };
  14764. $scope.charging = function (key, model) {
  14765. //计费弹出框
  14766. //用户信息
  14767. $scope.information = {};
  14768. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14769. userId: key.account,
  14770. }).then(function (response) {
  14771. // if (response.status == 200) {
  14772. if (response && response.data) {
  14773. angular.extend($scope.information, response.data[0]);
  14774. // $scope.information = response.data[0];
  14775. $scope.information.autologicDestroyTime = moment(
  14776. response.data[0].autologicDestroyTime
  14777. ).format("YYYY-MM-DD");
  14778. $scope.information.periodStartTime = moment(
  14779. response.data[0].periodStartTime
  14780. ).format("YYYY-MM-DD");
  14781. $scope.information.nextBillingTime = moment(
  14782. response.data[0].nextBillingTime
  14783. ).format("YYYY-MM-DD");
  14784. } else if (response.err) {
  14785. SweetAlert.swal(
  14786. "系统错误!",
  14787. "用户信息未取到,请刷新重试",
  14788. "error"
  14789. );
  14790. }
  14791. // }
  14792. });
  14793. //上网明细
  14794. $scope.options.templateOptions.ApiSer.fetchDataList(
  14795. "queryOnlineDetail",
  14796. {
  14797. userId: key.account,
  14798. limit: "10",
  14799. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  14800. "YYYY-MM-DD HH:mm:ss"
  14801. ),
  14802. toLogoutTime: moment(new Date().getTime()).format(
  14803. "YYYY-MM-DD HH:mm:ss"
  14804. ),
  14805. }
  14806. ).then(function (response) {
  14807. // if (response.status == 200) {
  14808. if (response && response.data) {
  14809. angular.forEach(response.data, function (item, index) {
  14810. if (item.logoutTime) {
  14811. response.data[index].logoutTime = moment(
  14812. item.logoutTime
  14813. ).format("YYYY-MM-DD HH:mm:ss");
  14814. }
  14815. if (item.loginTime) {
  14816. response.data[index].loginTime = moment(
  14817. item.loginTime
  14818. ).format("YYYY-MM-DD HH:mm:ss");
  14819. }
  14820. });
  14821. $scope.logininform = response.data;
  14822. } else if (response.err) {
  14823. SweetAlert.swal(
  14824. "系统错误!",
  14825. "上网明细未取到,请刷新重试",
  14826. "error"
  14827. );
  14828. }
  14829. });
  14830. //黑名单
  14831. // $scope.information.blacklist = "否"
  14832. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  14833. userId: key.account,
  14834. }).then(function (response) {
  14835. // if (response.status == 200) {
  14836. // $scope.logininformation = response.data;
  14837. if (response) {
  14838. if (response.data || response.data != null) {
  14839. $scope.information.blacklist = "是";
  14840. } else {
  14841. if (response.err) {
  14842. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  14843. } else {
  14844. $scope.information.blacklist = "否";
  14845. }
  14846. }
  14847. }
  14848. // }
  14849. });
  14850. $scope.bodyHeight = window.innerHeight - 100;
  14851. $(window).resize(function () {
  14852. $scope.bodyHeight = window.innerHeight - 100;
  14853. });
  14854. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  14855. // $scope.closepages = function(e) {
  14856. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  14857. // event.preventDefault();
  14858. // };
  14859. // $scope.shows = false;
  14860. $scope.tempData = {};
  14861. $scope.close = function () {
  14862. $scope.changes = !$scope.changes;
  14863. event.preventDefault();
  14864. };
  14865. };
  14866. $scope.options.templateOptions.ApiService.fetchDataList(
  14867. "requesterType",
  14868. {
  14869. idx: 0,
  14870. sum: 100,
  14871. }
  14872. ).then(function (response) {
  14873. if (response.status == 200) {
  14874. $scope.networktypes = response.list;
  14875. } else {
  14876. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  14877. }
  14878. });
  14879. function serchdata(searchKey) {
  14880. if (searchKey) {
  14881. var filterData = {
  14882. requester: {
  14883. searchKey: searchKey,
  14884. // 'userType': 1
  14885. },
  14886. idx: 0,
  14887. sum: 10,
  14888. };
  14889. } else {
  14890. var filterData = {
  14891. idx: 0,
  14892. requester: {},
  14893. sum: 10,
  14894. };
  14895. }
  14896. if (
  14897. $scope.model.requester &&
  14898. $scope.model.requester.requesterTypeDTO
  14899. ) {
  14900. angular.extend(filterData.requester, {
  14901. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  14902. });
  14903. if (!$scope.options.model.contactsInformation) {
  14904. $scope.options.model.contactsInformation =
  14905. $scope.model.requester.phone;
  14906. }
  14907. }
  14908. if ($scope.roleidcode) {
  14909. angular.extend(filterData["requester"], {
  14910. userType: 1,
  14911. });
  14912. }
  14913. $scope.options.templateOptions.ApiService.fetchDataList(
  14914. "requester",
  14915. filterData
  14916. ).then(function (response) {
  14917. var myData = response;
  14918. $scope.myData = myData.list;
  14919. });
  14920. }
  14921. $scope.searchData = {};
  14922. $scope.refreshUser = function (searchKey) {
  14923. //请求人搜索
  14924. if (searchKey && searchKey != "") {
  14925. serchdata(searchKey);
  14926. }
  14927. };
  14928. if (
  14929. $scope.$parent.$parent.$parent.model.incident.callID ||
  14930. $scope.$parent.$parent.$parent.model.requestershow
  14931. ) {
  14932. if (!$scope.roleidcode) {
  14933. $scope.charging(
  14934. $scope.$parent.$parent.$parent.model.incident.requester
  14935. );
  14936. }
  14937. $scope.recentlyincident(
  14938. $scope.$parent.$parent.$parent.model.incident.requester
  14939. );
  14940. }
  14941. $scope.onChange = function (searchData) {
  14942. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14943. searchData.telephone = $scope.model.incident.contactsInformation;
  14944. }
  14945. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14946. searchData;
  14947. if (!$scope.roleidcode) {
  14948. $scope.charging(searchData);
  14949. }
  14950. $scope.recentlyincident(searchData);
  14951. $scope.accountshow = false;
  14952. if ($scope.model.incident) {
  14953. if ($scope.model.incident.place) {
  14954. $scope.model.incident.place.id = "";
  14955. }
  14956. if ($scope.model.incident.area) {
  14957. $scope.model.incident.area.id = "";
  14958. }
  14959. $scope.model.incident.contacts = searchData.name;
  14960. if (
  14961. searchData.phone &&
  14962. searchData.phone != null &&
  14963. searchData.phone != ""
  14964. ) {
  14965. $scope.model.incident.contactsInformation = searchData.phone;
  14966. } else {
  14967. $scope.model.incident.contactsInformation = searchData.telephone;
  14968. }
  14969. $scope.model.incident.houseNumber = "";
  14970. if (
  14971. searchData.requesterTypeDTO &&
  14972. searchData.requesterTypeDTO.id == 2
  14973. ) {
  14974. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14975. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14976. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14977. }
  14978. }
  14979. $scope.options.value(searchData);
  14980. $scope.searchKey = searchData.account;
  14981. if (searchData.placeDTO && searchData.placeDTO.id) {
  14982. $scope.model.incident.place.id = searchData.placeDTO.id;
  14983. }
  14984. if (searchData.areaDTO && searchData.areaDTO.id) {
  14985. $scope.model.incident.area.id = searchData.areaDTO.id;
  14986. }
  14987. if (searchData.houseNumber) {
  14988. $scope.model.incident.houseNumber = searchData.houseNumber;
  14989. }
  14990. if (
  14991. searchData.requesterTypeDTO &&
  14992. searchData.requesterTypeDTO.id == 2
  14993. ) {
  14994. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14995. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14996. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14997. }
  14998. };
  14999. },
  15000. ],
  15001. });
  15002. //ui-grid-table展示控件
  15003. formlyConfigProvider.setType({
  15004. name: "ui-grid-table",
  15005. // extends: 'multiCheckbox',//去掉冒号
  15006. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  15007. defaultOptions: function (options) {
  15008. return {
  15009. templateOptions: {
  15010. linkage: function () { },
  15011. },
  15012. };
  15013. },
  15014. controller: function (
  15015. $scope,
  15016. $rootScope,
  15017. i18nService,
  15018. Restangular,
  15019. api_bpm_data,
  15020. api_statistic,
  15021. $rootScope
  15022. ) {
  15023. var loginUser = $rootScope.user;
  15024. $scope.langs = i18nService.getAllLangs();
  15025. $scope.lang = "zh-cn";
  15026. i18nService.setCurrentLang($scope.lang);
  15027. $scope.gridOptions = {};
  15028. $scope.gridOptions.data = "myData";
  15029. $scope.gridOptions.enableColumnResizing = true;
  15030. $scope.gridOptions.enableGridMenu = false;
  15031. $scope.gridOptions.enableRowSelection = true;
  15032. $scope.gridOptions.showGridFooter = false;
  15033. $scope.gridOptions.showColumnFooter = false;
  15034. $scope.gridOptions.fastWatch = true;
  15035. $scope.gridOptions.useExternalFiltering = true;
  15036. $scope.gridOptions.useExternalPagination = false;
  15037. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15038. $scope.gridOptions.paginationPageSize = 3;
  15039. $scope.gridOptions.multiSelect = false;
  15040. $scope.gridOptions.rowIdentity = function (row) {
  15041. return row.id;
  15042. };
  15043. $scope.gridOptions.getRowIdentity = function (row) {
  15044. return row.id;
  15045. };
  15046. $scope.gridOptions.columnDefs = [
  15047. {
  15048. name: "item",
  15049. displayName: "序号",
  15050. width: 80,
  15051. enableFiltering: false,
  15052. },
  15053. {
  15054. name: "incidentsign",
  15055. displayName: "单号",
  15056. width: 80,
  15057. enableFiltering: false,
  15058. },
  15059. {
  15060. name: "description",
  15061. displayName: "主题",
  15062. width: 80,
  15063. enableFiltering: false,
  15064. },
  15065. {
  15066. name: "state.name",
  15067. displayName: "状态",
  15068. width: 110,
  15069. enableFiltering: false,
  15070. },
  15071. {
  15072. name: "acceptDate",
  15073. displayName: "创建时间",
  15074. width: 160,
  15075. enableFiltering: false,
  15076. },
  15077. {
  15078. name: "requester.name",
  15079. displayName: "请求人",
  15080. width: 80,
  15081. enableFiltering: false,
  15082. },
  15083. {
  15084. name: "handlingPersonnelUser.name",
  15085. displayName: "处理人",
  15086. width: 160,
  15087. enableFiltering: false,
  15088. },
  15089. {
  15090. name: "place.place",
  15091. displayName: "区域地点",
  15092. width: 160,
  15093. enableFiltering: false,
  15094. },
  15095. ];
  15096. // var defaultFilterData = {
  15097. // "idx": 0,
  15098. // "sum": 3
  15099. // };
  15100. // // //分页控制
  15101. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15102. gridApi.pagination.on.paginationChanged(
  15103. $scope,
  15104. function (newPage, pageSize) {
  15105. var filtersData = $scope.memoryfilterData;
  15106. filtersData.idx = newPage - 1;
  15107. filtersData.sum = pageSize;
  15108. $scope.refreshData("expand-right", filtersData);
  15109. }
  15110. );
  15111. // 表格单选事件
  15112. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  15113. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  15114. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  15115. data.entity;
  15116. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  15117. data.entity.id;
  15118. var str =
  15119. data.grid.appScope.$parent.$parent.$parent.model.incident
  15120. .description || "";
  15121. str = str.split("").reverse().join("");
  15122. var del = addstr.split("").reverse().join("");
  15123. // console.log(del);
  15124. var reg = new RegExp(del);
  15125. str = str.replace(reg, "");
  15126. str = str.split("").reverse().join("");
  15127. if (
  15128. data.grid.appScope.$parent.$parent.$parent.model.incident
  15129. .associationType == "事件补充"
  15130. ) {
  15131. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  15132. null;
  15133. str += data.entity.description;
  15134. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15135. data.entity.description;
  15136. } else if (
  15137. data.grid.appScope.$parent.$parent.$parent.model.incident
  15138. .associationType == "事件已解决"
  15139. ) {
  15140. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  15141. "close";
  15142. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15143. "";
  15144. }
  15145. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  15146. str;
  15147. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  15148. data.entity.id;
  15149. });
  15150. };
  15151. // 刷新表格
  15152. setInterval(function () {
  15153. // console.log($scope.myData);
  15154. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  15155. // console.log($scope.myData);
  15156. if ($scope.myData != null) {
  15157. for (var i = 0; i < $scope.myData.length; i++) {
  15158. //添加序号
  15159. $scope.myData[i]["item"] = i + 1;
  15160. }
  15161. }
  15162. }, 1000);
  15163. },
  15164. });
  15165. //处理人信息
  15166. formlyConfigProvider.setType({
  15167. name: "ui-userinformation",
  15168. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  15169. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15170. defaultOptions: function (options) {
  15171. return {
  15172. templateOptions: {},
  15173. };
  15174. },
  15175. controller: [
  15176. "$scope",
  15177. function ($scope) {
  15178. $scope.group = "";
  15179. $scope.role = "";
  15180. if (
  15181. angular.isDefined($scope.model.handlingPersonnelUser) &&
  15182. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15183. $scope.model.handlingPersonnelUser.group.length == 1
  15184. ) {
  15185. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15186. } else {
  15187. for (
  15188. var i = 0;
  15189. i < $scope.model.handlingPersonnelUser.group.length;
  15190. i++
  15191. ) {
  15192. $scope.group +=
  15193. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15194. }
  15195. }
  15196. if (
  15197. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  15198. $scope.model.handlingPersonnelUser.role.length == 1
  15199. ) {
  15200. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  15201. } else {
  15202. for (
  15203. var i = 0;
  15204. i < $scope.model.handlingPersonnelUser.role.length;
  15205. i++
  15206. ) {
  15207. $scope.role +=
  15208. $scope.model.handlingPersonnelUser.role[i].role + ",";
  15209. }
  15210. }
  15211. $scope.options.templateOptions.that = $scope;
  15212. },
  15213. ],
  15214. });
  15215. //处理界面处理人信息
  15216. formlyConfigProvider.setType({
  15217. name: "ui-handler",
  15218. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  15219. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15220. defaultOptions: function (options) {
  15221. return {
  15222. templateOptions: {},
  15223. };
  15224. },
  15225. controller: [
  15226. "$scope",
  15227. function ($scope) {
  15228. $scope.group = "";
  15229. // $scope.role="";
  15230. if (
  15231. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15232. $scope.model.handlingPersonnelUser.group.length == 1
  15233. ) {
  15234. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15235. } else {
  15236. for (
  15237. var i = 0;
  15238. i < $scope.model.handlingPersonnelUser.group.length;
  15239. i++
  15240. ) {
  15241. $scope.group +=
  15242. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15243. }
  15244. }
  15245. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  15246. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  15247. // }else{
  15248. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  15249. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  15250. // }
  15251. // }
  15252. $scope.options.templateOptions.that = $scope;
  15253. },
  15254. ],
  15255. });
  15256. //微信事件流程
  15257. formlyConfigProvider.setType({
  15258. name: "ui-wxIncidentProcess",
  15259. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  15260. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15261. defaultOptions: function (options) {
  15262. return {
  15263. templateOptions: {},
  15264. };
  15265. },
  15266. controller: [
  15267. "$scope",
  15268. function ($scope) {
  15269. console.log($scope.model);
  15270. $scope.pingjia = false;
  15271. $scope.jiejue = false;
  15272. if ($scope.model.incidentState.value == "3") {
  15273. $scope.pingjia = true;
  15274. } else if ($scope.model.incidentState.value == "4") {
  15275. $scope.jiejue = true;
  15276. }
  15277. },
  15278. ],
  15279. });
  15280. //打电话
  15281. formlyConfigProvider.setType({
  15282. name: "ui-inputcall",
  15283. extends: "input",
  15284. templateUrl: "assets/views/customform/tpl/inputcall.html",
  15285. defaultOptions: function (options) {
  15286. return {
  15287. templateOptions: {
  15288. transform: function (value) { },
  15289. },
  15290. };
  15291. },
  15292. controller: [
  15293. "$scope",
  15294. "$rootScope",
  15295. "api_text",
  15296. "SweetAlert",
  15297. function ($scope, $rootScope, api_text, SweetAlert) {
  15298. $scope.dialout = function (teleno) {
  15299. // var gid = "@0";
  15300. // var telephone = "9" + teleno;
  15301. $rootScope.callout = 2;
  15302. // var agcount = tlwsa.tlaGetagentcount();
  15303. // var agcountFlag = false;
  15304. // console.log(teleno)
  15305. // // 查询当前话机是否签入
  15306. // for (var i = 0; i < agcount; i++) {
  15307. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  15308. // agcountFlag = true;
  15309. // }
  15310. // }
  15311. if (localStorage.getItem('fenjiNumber')) {
  15312. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  15313. // console.log(sessionStorage.getItem('phones'))
  15314. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  15315. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  15316. // console.log(isHuajihao)
  15317. // if(isHuajihao){
  15318. // tlwsa.tlaCallagc(teleno);
  15319. // }else{
  15320. // tlwsa.tlaCallout(teleno, caller, 0);
  15321. // }
  15322. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  15323. $rootScope.toggle('off-sidebar');
  15324. // tlwsa.tlaCallout(teleno, caller, 0);
  15325. }else if(localStorage.getItem('hk_phone')){
  15326. var gid = "@0"
  15327. var telephone = '9' + teleno
  15328. $rootScope.callout = 2;
  15329. if ($rootScope.takes) {
  15330. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  15331. if (data.errno == 0) {
  15332. $rootScope.status = 6;
  15333. }
  15334. })
  15335. } else {
  15336. SweetAlert.swal({
  15337. title: "呼叫失败",
  15338. text: "请先签入呼叫中心!",
  15339. type: "error",
  15340. confirmButtonColor: "#DD6B55"
  15341. });
  15342. }
  15343. } else {
  15344. SweetAlert.swal({
  15345. title: "呼叫失败",
  15346. text: "请先签入呼叫中心!",
  15347. type: "error",
  15348. confirmButtonColor: "#DD6B55",
  15349. });
  15350. }
  15351. };
  15352. $scope.options.templateOptions.that = $scope;
  15353. },
  15354. ],
  15355. });
  15356. //关闭界面处理人信息
  15357. formlyConfigProvider.setType({
  15358. name: "ui-closehandler",
  15359. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  15360. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15361. defaultOptions: function (options) {
  15362. return {
  15363. templateOptions: {},
  15364. };
  15365. },
  15366. controller: [
  15367. "$scope",
  15368. "$rootScope",
  15369. "api_text",
  15370. function ($scope, $rootScope, api_text) {
  15371. $scope.dialout = function (teleno) {
  15372. var gid = "@0";
  15373. var telephone = "9" + teleno;
  15374. api_text
  15375. .dialout($rootScope.takes, gid, telephone)
  15376. .then(function (data) {
  15377. if (data.errno == 0) {
  15378. $rootScope.status = 6;
  15379. }
  15380. });
  15381. };
  15382. $scope.options.templateOptions.that = $scope;
  15383. },
  15384. ],
  15385. });
  15386. //用户单选控件
  15387. formlyConfigProvider.setType({
  15388. name: "ui-userselect",
  15389. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  15390. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15391. defaultOptions: function (options) {
  15392. return {
  15393. templateOptions: {
  15394. openModal: function (size, options, modal) {
  15395. var modalInstance = modal.open({
  15396. templateUrl:
  15397. "assets/views/customform/tpl/checktable-modal-content.html",
  15398. controller: function (
  15399. $scope,
  15400. $rootScope,
  15401. i18nService,
  15402. $modalInstance,
  15403. items,
  15404. title,
  15405. Restangular,
  15406. APIService,
  15407. onDataCallback,
  15408. parentScope,
  15409. api_category,
  15410. api_user_data
  15411. ) {
  15412. $scope.isAssign = options.templateOptions.departmentDispatchesOrders;
  15413. $scope.langs = i18nService.getAllLangs();
  15414. $scope.lang = "zh-cn";
  15415. i18nService.setCurrentLang($scope.lang);
  15416. $scope.gridOptions = {};
  15417. $scope.gridOptions.data = "myData";
  15418. $scope.gridOptions.enableColumnResizing = true;
  15419. $scope.gridOptions.enableFiltering = true;
  15420. $scope.gridOptions.enableGridMenu = false;
  15421. $scope.gridOptions.showGridFooter = true;
  15422. $scope.gridOptions.showColumnFooter = false;
  15423. $scope.gridOptions.fastWatch = true;
  15424. $scope.gridOptions.useExternalFiltering = true;
  15425. $scope.gridOptions.useExternalPagination = true;
  15426. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15427. $scope.gridOptions.paginationPageSize = 10;
  15428. $scope.gridOptions.multiSelect = false;
  15429. $scope.searchModel = {
  15430. type:1,//默认科室内转派
  15431. }
  15432. $scope.hospitalList = [];
  15433. $scope.dutyDeptList = [];
  15434. // 修改转派模式
  15435. $scope.changeType = function(type){
  15436. console.log($scope.searchModel.type)
  15437. $scope.gridOptions.totalItems = 0;
  15438. $scope.myData = [];
  15439. $scope.searchModel.department = undefined;
  15440. $scope.searchModel.branch = undefined;
  15441. $scope.dutyDeptList = [];
  15442. if($scope.searchModel.type == 2){
  15443. //跨科室转派
  15444. api_user_data.fetchDataList('branch', {
  15445. "idx": 0,
  15446. "sum": 100
  15447. }).then(function (data) {
  15448. if(data.status == 200){
  15449. $scope.hospitalList = data.list;
  15450. if($rootScope.user.duty){
  15451. // 当前的所属责任科室
  15452. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  15453. // $scope.changeBranch();
  15454. }else if($rootScope.user.branch){
  15455. // 当前的所属院区
  15456. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  15457. // $scope.changeBranch();
  15458. }
  15459. }else{
  15460. SweetAlert.swal({
  15461. title: "系统错误!",
  15462. text: "请刷新重试!",
  15463. type: "error"
  15464. });
  15465. }
  15466. })
  15467. }else if($scope.searchModel.type == 1){
  15468. //科室内转派
  15469. var postData = {
  15470. idx: 0,
  15471. sum: 10,
  15472. user: {
  15473. roledata: {
  15474. rolecode: "first-line support",
  15475. },
  15476. selectType: "1",
  15477. },
  15478. }
  15479. // 判断当前是责任科室还是院区
  15480. if ($rootScope.user.duty) {
  15481. // 当前的所属责任科室
  15482. postData.user.currentDuty = $rootScope.user.duty.id;
  15483. } else if ($rootScope.user.branch) {
  15484. // 当前的所属院区
  15485. $scope.myData = [];
  15486. return;
  15487. }
  15488. $scope.loadData(postData);
  15489. }
  15490. }
  15491. // 修改院区
  15492. $scope.changeBranch = function(keyword=''){
  15493. if(!$scope.searchModel.branch){
  15494. return;
  15495. }
  15496. $scope.searchModel.department = undefined;
  15497. $scope.dutyDeptList = [];
  15498. api_user_data.fetchDataList('dutyDepartment', {
  15499. "idx": 0,
  15500. "sum": 100,
  15501. "dutyDepartment":{
  15502. branch:$scope.searchModel.branch.id,
  15503. dept:keyword,
  15504. selectType: "pinyin_qs"
  15505. }
  15506. }).then(function (data) {
  15507. if(data.status == 200){
  15508. $scope.dutyDeptList = data.list;
  15509. }else{
  15510. SweetAlert.swal({
  15511. title: "系统错误!",
  15512. text: "请刷新重试!",
  15513. type: "error"
  15514. });
  15515. }
  15516. })
  15517. }
  15518. // 修改责任科室
  15519. $scope.changeDutyDept = function(){
  15520. $scope.loadData({
  15521. idx: 0,
  15522. sum: 10,
  15523. user: {
  15524. duty:$scope.searchModel.department,
  15525. roledata: {
  15526. rolecode: "first-line support",
  15527. },
  15528. selectType: "1",
  15529. },
  15530. });
  15531. }
  15532. $scope.gridOptions.rowIdentity = function (row) {
  15533. return row.id;
  15534. };
  15535. $scope.gridOptions.getRowIdentity = function (row) {
  15536. return row.id;
  15537. };
  15538. $scope.gridOptions.rowTemplate =
  15539. '<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>';
  15540. $scope.gridOptions.columnDefs = [
  15541. {
  15542. name: "account",
  15543. displayName: "人员编号",
  15544. width: 120,
  15545. },
  15546. {
  15547. name: "name",
  15548. displayName: "姓名",
  15549. width: 100,
  15550. cellTemplate:
  15551. "<div>" +
  15552. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15553. "</div>",
  15554. },
  15555. // {
  15556. // name: 'gender.name',
  15557. // displayName: '性别',
  15558. // width: 80,
  15559. // enableFiltering: false
  15560. // },
  15561. {
  15562. name: "phone",
  15563. displayName: "电话",
  15564. width: 230,
  15565. enableFiltering: false,
  15566. },
  15567. {
  15568. name: "email",
  15569. displayName: "邮箱",
  15570. width: 180,
  15571. enableFiltering: false,
  15572. },
  15573. {
  15574. name: "dept.dept",
  15575. displayName: "科室",
  15576. width: 130,
  15577. enableFiltering: false,
  15578. },
  15579. {
  15580. name: "taskCount",
  15581. displayName: "处理中事件数",
  15582. enableFiltering: false,
  15583. },
  15584. ];
  15585. // $scope.selectButtonClick
  15586. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15587. $scope.gridApi = gridApi;
  15588. gridApi.pagination.on.paginationChanged(
  15589. $scope,
  15590. function (newPage, pageSize) {
  15591. var postData = {
  15592. idx: newPage - 1,
  15593. sum: pageSize,
  15594. user: {
  15595. roledata: {
  15596. rolecode: "first-line support",
  15597. },
  15598. selectType: "1",
  15599. },
  15600. }
  15601. if($scope.isAssign){
  15602. if($scope.searchModel.type == 1){
  15603. // 判断当前是责任科室还是院区
  15604. if ($rootScope.user.duty) {
  15605. // 当前的所属责任科室
  15606. postData.user.currentDuty = $rootScope.user.duty.id;
  15607. } else if ($rootScope.user.branch) {
  15608. // 当前的所属院区
  15609. $scope.myData = [];
  15610. return;
  15611. }
  15612. }else if($scope.searchModel.type == 2){
  15613. // 跨科室转派
  15614. postData.user.duty = $scope.searchModel.department;
  15615. }
  15616. }
  15617. $scope.loadData(postData);
  15618. }
  15619. );
  15620. gridApi.selection.on.rowSelectionChanged(
  15621. $scope,
  15622. function (data) {
  15623. $scope.selected.items = data.entity;
  15624. //console.log(data);
  15625. }
  15626. );
  15627. gridApi.selection.on.rowSelectionChangedBatch(
  15628. $scope,
  15629. function (data) {
  15630. $scope.selected.items = data.entity;
  15631. //console.log(data);
  15632. }
  15633. );
  15634. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15635. // // if (row.entity.age > 45) {
  15636. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15637. // // }
  15638. // };
  15639. gridApi.core.on.filterChanged($scope, function () {
  15640. var grid = this.grid;
  15641. var filtersData = {
  15642. idx: 0,
  15643. sum: 10,
  15644. user: {
  15645. roledata: {
  15646. rolecode: "roleset",
  15647. },
  15648. selectType: "1",
  15649. },
  15650. };
  15651. angular.forEach(grid.columns, function (item) {
  15652. if (item.enableFiltering) {
  15653. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15654. if (
  15655. angular.isDefined(item.filters[0].term) &&
  15656. item.filters[0].term != ""
  15657. ) {
  15658. if (angular.isUndefined(filtersData["user"])) {
  15659. filtersData["user"] = {};
  15660. }
  15661. filtersData["user"][item.field] =
  15662. item.filters[0].term;
  15663. }
  15664. }
  15665. });
  15666. if($scope.isAssign){
  15667. if($scope.searchModel.type == 1){
  15668. // 判断当前是责任科室还是院区
  15669. if ($rootScope.user.duty) {
  15670. // 当前的所属责任科室
  15671. filtersData.user.currentDuty = $rootScope.user.duty.id;
  15672. } else if ($rootScope.user.branch) {
  15673. // 当前的所属院区
  15674. $scope.myData = [];
  15675. return;
  15676. }
  15677. }else if($scope.searchModel.type == 2){
  15678. // 跨科室转派
  15679. filtersData.user.duty = $scope.searchModel.department;
  15680. }
  15681. }
  15682. // $scope.memoryfilterData = filtersData;
  15683. $scope.loadData(filtersData);
  15684. });
  15685. };
  15686. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15687. // if (row.entity.age > 45) {
  15688. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15689. // }
  15690. // },
  15691. $scope.onDblClick = function (data, event) {
  15692. // $scope.selected.items = data.entity;
  15693. $scope.selectButtonClick(data, event);
  15694. };
  15695. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15696. // $scope.selected.items = data.entity;
  15697. // })
  15698. // };
  15699. $scope.memoryfilterData = {
  15700. idx: 0,
  15701. sum: 10,
  15702. user: {
  15703. roledata: {
  15704. rolecode: "roleset",
  15705. },
  15706. selectType: "1",
  15707. },
  15708. };
  15709. $scope.loadData = function (filterData) {
  15710. // console.log("filtersData=111" + JSON.stringify(filterData))
  15711. items
  15712. .fetchItems(filterData, APIService)
  15713. .then(function (data) {
  15714. var myData = Restangular.stripRestangular(data);
  15715. $scope.gridOptions.totalItems = myData.totalNum;
  15716. $scope.myData = myData.list;
  15717. });
  15718. };
  15719. $scope.title = title;
  15720. $scope.selected = {
  15721. items: {},
  15722. };
  15723. $scope.ok = function () {
  15724. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15725. // onDataCallback($scope.selected.item, parentScope);
  15726. // }
  15727. $modalInstance.close($scope.selected.items);
  15728. };
  15729. $scope.cancel = function () {
  15730. $modalInstance.dismiss("cancel");
  15731. };
  15732. // 初始化
  15733. var postData = {
  15734. idx: 0,
  15735. sum: 10,
  15736. user: {
  15737. roledata: {
  15738. rolecode: "first-line support",
  15739. },
  15740. selectType: "1",
  15741. },
  15742. }
  15743. if($scope.isAssign){
  15744. if($scope.searchModel.type == 1){
  15745. // 判断当前是责任科室还是院区
  15746. if ($rootScope.user.duty) {
  15747. // 当前的所属责任科室
  15748. postData.user.currentDuty = $rootScope.user.duty.id;
  15749. } else if ($rootScope.user.branch) {
  15750. // 当前的所属院区
  15751. $scope.myData = [];
  15752. return;
  15753. }
  15754. }else if($scope.searchModel.type == 2){
  15755. // 跨科室转派
  15756. postData.user.duty = $scope.searchModel.department;
  15757. }
  15758. }
  15759. $scope.loadData(postData);
  15760. },
  15761. size: size,
  15762. resolve: {
  15763. items: function () {
  15764. return {
  15765. fetchItems: function (filterData, APIService) {
  15766. filterData = filterData || {};
  15767. if (
  15768. angular.isDefined(filterData.idx) &&
  15769. filterData.idx == null
  15770. ) {
  15771. filterData = {
  15772. idx: 0,
  15773. sum: 10,
  15774. user: {
  15775. roledata: {
  15776. rolecode: "roleset",
  15777. },
  15778. selectType: "1",
  15779. },
  15780. };
  15781. }
  15782. return options.templateOptions.fetchItems(
  15783. filterData,
  15784. APIService
  15785. );
  15786. },
  15787. };
  15788. },
  15789. title: function () {
  15790. return options.templateOptions.label;
  15791. },
  15792. Restangular: function () {
  15793. return options.templateOptions.Restangular;
  15794. },
  15795. APIService: function () {
  15796. return options.templateOptions.ApiService;
  15797. },
  15798. onDataCallback: function () {
  15799. return options.templateOptions.callback;
  15800. },
  15801. parentScope: function () {
  15802. return options.templateOptions.that;
  15803. },
  15804. },
  15805. });
  15806. modalInstance.result.then(
  15807. function (selectedItem) {
  15808. // console.log(selectedItem);
  15809. options.value(selectedItem);
  15810. if (
  15811. options.templateOptions.callback &&
  15812. angular.isFunction(options.templateOptions.callback)
  15813. ) {
  15814. options.templateOptions.callback(
  15815. selectedItem,
  15816. options.templateOptions.that
  15817. );
  15818. }
  15819. if (
  15820. options.templateOptions.linkData &&
  15821. angular.isFunction(options.templateOptions.linkData)
  15822. ) {
  15823. options.templateOptions.linkData(
  15824. selectedItem,
  15825. options.templateOptions.that
  15826. );
  15827. }
  15828. },
  15829. function () {
  15830. //console.log('Modal dismissed at: ' + new Date());
  15831. }
  15832. );
  15833. },
  15834. },
  15835. };
  15836. },
  15837. controller: [
  15838. "$scope",
  15839. function ($scope) {
  15840. $scope.options.templateOptions.that = $scope;
  15841. // $scope.options.model[$scope.options.key] = {}
  15842. },
  15843. ],
  15844. });
  15845. //用户单选控件(dd 单选input带搜索)liaomingming
  15846. formlyConfigProvider.setType({
  15847. name: "ui-userselectSearch",
  15848. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15849. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15850. defaultOptions: function (options) {
  15851. return {
  15852. templateOptions: {
  15853. openModal: function (size, options, modal) {
  15854. var modalInstance = modal.open({
  15855. templateUrl:
  15856. "assets/views/customform/tpl/checktable-modal-content.html",
  15857. controller: function (
  15858. $scope,
  15859. $rootScope,
  15860. i18nService,
  15861. $modalInstance,
  15862. items,
  15863. title,
  15864. Restangular,
  15865. APIService,
  15866. onDataCallback,
  15867. parentScope,
  15868. api_category,
  15869. api_user_data
  15870. ) {
  15871. $scope.isAssign = options.templateOptions.departmentDispatchesOrders;
  15872. $scope.langs = i18nService.getAllLangs();
  15873. $scope.lang = "zh-cn";
  15874. i18nService.setCurrentLang($scope.lang);
  15875. $scope.gridOptions = {};
  15876. $scope.gridOptions.data = "myData";
  15877. $scope.gridOptions.enableColumnResizing = true;
  15878. $scope.gridOptions.enableFiltering = true;
  15879. $scope.gridOptions.enableGridMenu = false;
  15880. $scope.gridOptions.showGridFooter = true;
  15881. $scope.gridOptions.showColumnFooter = false;
  15882. $scope.gridOptions.fastWatch = true;
  15883. $scope.gridOptions.useExternalFiltering = true;
  15884. $scope.gridOptions.useExternalPagination = true;
  15885. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15886. $scope.gridOptions.paginationPageSize = 10;
  15887. $scope.gridOptions.multiSelect = false;
  15888. $scope.searchModel = {
  15889. type:1,//默认科室内转派
  15890. }
  15891. $scope.hospitalList = [];
  15892. $scope.dutyDeptList = [];
  15893. // 修改转派模式
  15894. $scope.changeType = function(type){
  15895. console.log($scope.searchModel.type)
  15896. $scope.gridOptions.totalItems = 0;
  15897. $scope.myData = [];
  15898. $scope.searchModel.department = undefined;
  15899. $scope.searchModel.branch = undefined;
  15900. $scope.dutyDeptList = [];
  15901. if($scope.searchModel.type == 2){
  15902. //跨科室转派
  15903. api_user_data.fetchDataList('branch', {
  15904. "idx": 0,
  15905. "sum": 100
  15906. }).then(function (data) {
  15907. if(data.status == 200){
  15908. $scope.hospitalList = data.list;
  15909. if($rootScope.user.duty){
  15910. // 当前的所属责任科室
  15911. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.duty.branch);
  15912. // $scope.changeBranch();
  15913. }else if($rootScope.user.branch){
  15914. // 当前的所属院区
  15915. $scope.searchModel.branch = $scope.hospitalList.find(v=>v.id == $rootScope.user.branch.id);
  15916. // $scope.changeBranch();
  15917. }
  15918. }else{
  15919. SweetAlert.swal({
  15920. title: "系统错误!",
  15921. text: "请刷新重试!",
  15922. type: "error"
  15923. });
  15924. }
  15925. })
  15926. }else if($scope.searchModel.type == 1){
  15927. //科室内转派
  15928. var postData = {
  15929. idx: 0,
  15930. sum: 10,
  15931. user: {
  15932. roledata: {
  15933. rolecode: "first-line support",
  15934. },
  15935. selectType: "1",
  15936. },
  15937. }
  15938. // 判断当前是责任科室还是院区
  15939. if ($rootScope.user.duty) {
  15940. // 当前的所属责任科室
  15941. postData.user.currentDuty = $rootScope.user.duty.id;
  15942. } else if ($rootScope.user.branch) {
  15943. // 当前的所属院区
  15944. $scope.myData = [];
  15945. return;
  15946. }
  15947. $scope.loadData(postData);
  15948. }
  15949. }
  15950. // 修改院区
  15951. $scope.changeBranch = function(keyword=''){
  15952. if(!$scope.searchModel.branch){
  15953. return;
  15954. }
  15955. $scope.searchModel.department = undefined;
  15956. $scope.dutyDeptList = [];
  15957. api_user_data.fetchDataList('dutyDepartment', {
  15958. "idx": 0,
  15959. "sum": 100,
  15960. "dutyDepartment":{
  15961. branch:$scope.searchModel.branch.id,
  15962. dept:keyword,
  15963. selectType: "pinyin_qs"
  15964. }
  15965. }).then(function (data) {
  15966. if(data.status == 200){
  15967. $scope.dutyDeptList = data.list;
  15968. }else{
  15969. SweetAlert.swal({
  15970. title: "系统错误!",
  15971. text: "请刷新重试!",
  15972. type: "error"
  15973. });
  15974. }
  15975. })
  15976. }
  15977. // 修改责任科室
  15978. $scope.changeDutyDept = function(){
  15979. $scope.loadData({
  15980. idx: 0,
  15981. sum: 10,
  15982. user: {
  15983. duty:$scope.searchModel.department,
  15984. roledata: {
  15985. rolecode: "first-line support",
  15986. },
  15987. selectType: "1",
  15988. },
  15989. });
  15990. }
  15991. $scope.gridOptions.rowIdentity = function (row) {
  15992. return row.id;
  15993. };
  15994. $scope.gridOptions.getRowIdentity = function (row) {
  15995. return row.id;
  15996. };
  15997. $scope.gridOptions.rowTemplate =
  15998. '<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>';
  15999. $scope.gridOptions.columnDefs = [
  16000. {
  16001. name: "account",
  16002. displayName: "人员编号",
  16003. width: 120,
  16004. },
  16005. {
  16006. name: "name",
  16007. displayName: "姓名",
  16008. width: 100,
  16009. cellTemplate:
  16010. "<div>" +
  16011. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  16012. "</div>",
  16013. },
  16014. // {
  16015. // name: 'gender.name',
  16016. // displayName: '性别',
  16017. // width: 80,
  16018. // enableFiltering: false
  16019. // },
  16020. {
  16021. name: "phone",
  16022. displayName: "电话",
  16023. width: 230,
  16024. enableFiltering: false,
  16025. },
  16026. {
  16027. name: "email",
  16028. displayName: "邮箱",
  16029. width: 180,
  16030. enableFiltering: false,
  16031. },
  16032. {
  16033. name: "dept.dept",
  16034. displayName: "科室",
  16035. width: 130,
  16036. enableFiltering: false,
  16037. },
  16038. {
  16039. name: "taskCount",
  16040. displayName: "处理中事件数",
  16041. enableFiltering: false,
  16042. },
  16043. ];
  16044. // $scope.selectButtonClick
  16045. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16046. $scope.gridApi = gridApi;
  16047. gridApi.pagination.on.paginationChanged(
  16048. $scope,
  16049. function (newPage, pageSize) {
  16050. var postData = {
  16051. idx: newPage - 1,
  16052. sum: pageSize,
  16053. user: {
  16054. roledata: {
  16055. rolecode: "first-line support",
  16056. },
  16057. selectType: "1",
  16058. },
  16059. }
  16060. if($scope.isAssign){
  16061. if($scope.searchModel.type == 1){
  16062. // 判断当前是责任科室还是院区
  16063. if ($rootScope.user.duty) {
  16064. // 当前的所属责任科室
  16065. postData.user.currentDuty = $rootScope.user.duty.id;
  16066. } else if ($rootScope.user.branch) {
  16067. // 当前的所属院区
  16068. $scope.myData = [];
  16069. return;
  16070. }
  16071. }else if($scope.searchModel.type == 2){
  16072. // 跨科室转派
  16073. postData.user.duty = $scope.searchModel.department;
  16074. }
  16075. }
  16076. $scope.loadData(postData);
  16077. }
  16078. );
  16079. gridApi.selection.on.rowSelectionChanged(
  16080. $scope,
  16081. function (data) {
  16082. $scope.selected.items = data.entity;
  16083. //console.log(data);
  16084. }
  16085. );
  16086. gridApi.selection.on.rowSelectionChangedBatch(
  16087. $scope,
  16088. function (data) {
  16089. $scope.selected.items = data.entity;
  16090. //console.log(data);
  16091. }
  16092. );
  16093. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  16094. // // if (row.entity.age > 45) {
  16095. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16096. // // }
  16097. // };
  16098. gridApi.core.on.filterChanged($scope, function () {
  16099. var grid = this.grid;
  16100. var filtersData = {
  16101. idx: 0,
  16102. sum: 10,
  16103. user: {
  16104. roledata: {
  16105. rolecode: "first-line support",
  16106. },
  16107. selectType: "1",
  16108. },
  16109. };
  16110. angular.forEach(grid.columns, function (item) {
  16111. if (item.enableFiltering) {
  16112. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  16113. if (
  16114. angular.isDefined(item.filters[0].term) &&
  16115. item.filters[0].term != ""
  16116. ) {
  16117. if (angular.isUndefined(filtersData["user"])) {
  16118. filtersData["user"] = {};
  16119. }
  16120. filtersData["user"][item.field] =
  16121. item.filters[0].term;
  16122. }
  16123. }
  16124. });
  16125. if($scope.isAssign){
  16126. if($scope.searchModel.type == 1){
  16127. // 判断当前是责任科室还是院区
  16128. if ($rootScope.user.duty) {
  16129. // 当前的所属责任科室
  16130. filtersData.user.currentDuty = $rootScope.user.duty.id;
  16131. } else if ($rootScope.user.branch) {
  16132. // 当前的所属院区
  16133. $scope.myData = [];
  16134. return;
  16135. }
  16136. }else if($scope.searchModel.type == 2){
  16137. // 跨科室转派
  16138. filtersData.user.duty = $scope.searchModel.department;
  16139. }
  16140. }
  16141. // $scope.memoryfilterData = filtersData;
  16142. $scope.loadData(filtersData);
  16143. });
  16144. };
  16145. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  16146. // if (row.entity.age > 45) {
  16147. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16148. // }
  16149. // },
  16150. $scope.onDblClick = function (data, event) {
  16151. // $scope.selected.items = data.entity;
  16152. $scope.selectButtonClick(data, event);
  16153. };
  16154. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  16155. // $scope.selected.items = data.entity;
  16156. // })
  16157. // };
  16158. $scope.memoryfilterData = {
  16159. idx: 0,
  16160. sum: 10,
  16161. user: {
  16162. roledata: {
  16163. rolecode: "first-line support",
  16164. },
  16165. selectType: "1",
  16166. },
  16167. };
  16168. $scope.loadData = function (filterData) {
  16169. // console.log("filtersData=111" + JSON.stringify(filterData))
  16170. items
  16171. .fetchItems(filterData, APIService)
  16172. .then(function (data) {
  16173. if(($scope.searchModel.type == 1 && filterData.user.duty) || ($scope.searchModel.type == 2 && !filterData.user.duty)){
  16174. $scope.gridOptions.totalItems = 0;
  16175. $scope.myData = [];
  16176. }else{
  16177. var myData = Restangular.stripRestangular(data);
  16178. $scope.gridOptions.totalItems = myData.totalNum;
  16179. $scope.myData = myData.list;
  16180. }
  16181. });
  16182. };
  16183. $scope.title = title;
  16184. $scope.selected = {
  16185. items: {},
  16186. };
  16187. $scope.ok = function () {
  16188. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  16189. // onDataCallback($scope.selected.item, parentScope);
  16190. // }
  16191. $modalInstance.close($scope.selected.items);
  16192. };
  16193. $scope.cancel = function () {
  16194. $modalInstance.dismiss("cancel");
  16195. };
  16196. // 初始化
  16197. var postData = {
  16198. idx: 0,
  16199. sum: 10,
  16200. user: {
  16201. roledata: {
  16202. rolecode: "first-line support",
  16203. },
  16204. selectType: "1",
  16205. },
  16206. }
  16207. if($scope.isAssign){
  16208. if($scope.searchModel.type == 1){
  16209. // 判断当前是责任科室还是院区
  16210. if ($rootScope.user.duty) {
  16211. // 当前的所属责任科室
  16212. postData.user.currentDuty = $rootScope.user.duty.id;
  16213. } else if ($rootScope.user.branch) {
  16214. // 当前的所属院区
  16215. $scope.myData = [];
  16216. return;
  16217. }
  16218. }else if($scope.searchModel.type == 2){
  16219. // 跨科室转派
  16220. postData.user.duty = $scope.searchModel.department;
  16221. }
  16222. }
  16223. $scope.loadData(postData);
  16224. },
  16225. size: size,
  16226. resolve: {
  16227. items: function () {
  16228. return {
  16229. fetchItems: function (filterData, APIService) {
  16230. filterData = filterData || {};
  16231. if (
  16232. angular.isDefined(filterData.idx) &&
  16233. filterData.idx == null
  16234. ) {
  16235. filterData = {
  16236. idx: 0,
  16237. sum: 10,
  16238. user: {
  16239. roledata: {
  16240. rolecode: "first-line support",
  16241. },
  16242. selectType: "1",
  16243. },
  16244. };
  16245. }
  16246. return options.templateOptions.fetchItems(
  16247. filterData,
  16248. APIService
  16249. );
  16250. },
  16251. };
  16252. },
  16253. title: function () {
  16254. return options.templateOptions.label;
  16255. },
  16256. Restangular: function () {
  16257. return options.templateOptions.Restangular;
  16258. },
  16259. APIService: function () {
  16260. return options.templateOptions.ApiService;
  16261. },
  16262. onDataCallback: function () {
  16263. return options.templateOptions.callback;
  16264. },
  16265. parentScope: function () {
  16266. return options.templateOptions.that;
  16267. }
  16268. },
  16269. });
  16270. modalInstance.result.then(
  16271. function (selectedItem) {
  16272. // console.log(selectedItem);
  16273. options.value(selectedItem);
  16274. if (
  16275. options.templateOptions.callback &&
  16276. angular.isFunction(options.templateOptions.callback)
  16277. ) {
  16278. options.templateOptions.callback(
  16279. selectedItem,
  16280. options.templateOptions.that
  16281. );
  16282. }
  16283. if (
  16284. options.templateOptions.linkData &&
  16285. angular.isFunction(options.templateOptions.linkData)
  16286. ) {
  16287. options.templateOptions.linkData(
  16288. selectedItem,
  16289. options.templateOptions.that
  16290. );
  16291. }
  16292. },
  16293. function () {
  16294. //console.log('Modal dismissed at: ' + new Date());
  16295. }
  16296. );
  16297. },
  16298. },
  16299. };
  16300. },
  16301. controller: [
  16302. "$scope",
  16303. function ($scope) {
  16304. $scope.options.templateOptions.that = $scope;
  16305. },
  16306. ],
  16307. });
  16308. //用户多选控件
  16309. formlyConfigProvider.setType({
  16310. name: "ui-multiuserselect",
  16311. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  16312. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16313. defaultOptions: function (options) {
  16314. return {
  16315. templateOptions: {
  16316. openModal: function (size, options, modal, model) {
  16317. var modalInstance = modal.open({
  16318. templateUrl:
  16319. "assets/views/customform/tpl/checktable-modal-content.html",
  16320. controller: function (
  16321. $scope,
  16322. $modalInstance,
  16323. i18nService,
  16324. $timeout,
  16325. items,
  16326. title,
  16327. Restangular,
  16328. APIService,
  16329. selectItems
  16330. ) {
  16331. $scope.langs = i18nService.getAllLangs();
  16332. $scope.lang = "zh-cn";
  16333. i18nService.setCurrentLang($scope.lang);
  16334. $scope.gridOptions = {};
  16335. $scope.gridOptions.data = "myData";
  16336. $scope.gridOptions.enableColumnResizing = true;
  16337. $scope.gridOptions.enableFiltering = true;
  16338. $scope.gridOptions.enableGridMenu = true;
  16339. $scope.gridOptions.showGridFooter = true;
  16340. $scope.gridOptions.showColumnFooter = true;
  16341. $scope.gridOptions.fastWatch = true;
  16342. $scope.gridOptions.useExternalFiltering = true;
  16343. $scope.gridOptions.useExternalPagination = true;
  16344. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16345. $scope.gridOptions.paginationPageSize = 10;
  16346. $scope.gridOptions.multiSelect = true;
  16347. $scope.gridOptions.rowIdentity = function (row) {
  16348. return row.id;
  16349. };
  16350. $scope.gridOptions.getRowIdentity = function (row) {
  16351. return row.id;
  16352. };
  16353. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  16354. $scope.gridOptions.columnDefs = [
  16355. // { name:'id', width:80, enableFiltering:false},
  16356. {
  16357. name: "account",
  16358. displayName: "账号",
  16359. width: 140,
  16360. },
  16361. {
  16362. name: "name",
  16363. displayName: "名称",
  16364. width: 100,
  16365. },
  16366. {
  16367. name: "gender.name",
  16368. displayName: "性别",
  16369. width: 140,
  16370. enableFiltering: false,
  16371. },
  16372. {
  16373. name: "phone",
  16374. displayName: "电话",
  16375. width: 100,
  16376. enableFiltering: false,
  16377. },
  16378. {
  16379. name: "email",
  16380. displayName: "邮件",
  16381. width: 100,
  16382. enableFiltering: false,
  16383. },
  16384. {
  16385. name: "dept.dept",
  16386. displayName: "科室",
  16387. width: 100,
  16388. enableFiltering: false,
  16389. },
  16390. {
  16391. name: "group[0].groupName",
  16392. displayName: "职位",
  16393. width: 100,
  16394. enableFiltering: false,
  16395. },
  16396. ];
  16397. $scope.selected = {
  16398. items: selectItems,
  16399. };
  16400. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16401. $scope.gridApi = gridApi;
  16402. gridApi.pagination.on.paginationChanged(
  16403. $scope,
  16404. function (newPage, pageSize) {
  16405. var filtersData = $scope.memoryfilterData;
  16406. filtersData.idx = newPage - 1;
  16407. filtersData.sum = pageSize;
  16408. $scope.loadData(filtersData);
  16409. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  16410. }
  16411. );
  16412. gridApi.selection.on.rowSelectionChanged(
  16413. $scope,
  16414. function (scope) {
  16415. var j = 0;
  16416. for (
  16417. var i = 0;
  16418. i <= scope.grid.appScope.selected.items.length;
  16419. i++
  16420. ) {
  16421. if (
  16422. scope.grid.appScope.selected.items[i] == scope.entity
  16423. ) {
  16424. j++;
  16425. break;
  16426. }
  16427. }
  16428. if (j == 1) {
  16429. scope.grid.appScope.selected.items.splice(i, 1);
  16430. } else {
  16431. scope.grid.appScope.selected.items.push(scope.entity);
  16432. for (
  16433. var i = 0;
  16434. i < scope.grid.appScope.selected.items.length;
  16435. i++
  16436. ) {
  16437. for (
  16438. var z = 0;
  16439. z < scope.grid.appScope.selected.items.length;
  16440. z++
  16441. ) {
  16442. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  16443. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  16444. if (
  16445. angular.isDefined(
  16446. scope.grid.appScope.selected.items
  16447. ) &&
  16448. scope.grid.appScope.selected.items[i].id ==
  16449. scope.grid.appScope.selected.items[z].id &&
  16450. i != z
  16451. ) {
  16452. scope.grid.appScope.selected.items.splice(i, 1);
  16453. }
  16454. }
  16455. }
  16456. }
  16457. }
  16458. );
  16459. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  16460. // $scope.grid.appScope.selected.items.push($scope.entity);
  16461. // });
  16462. gridApi.core.on.filterChanged($scope, function () {
  16463. var grid = this.grid;
  16464. var filtersData = {
  16465. idx: 0,
  16466. sum: 10,
  16467. user: {
  16468. roledata: {
  16469. rolecode: options.model.currentRole,
  16470. },
  16471. selectType: "1",
  16472. },
  16473. };
  16474. angular.forEach(grid.columns, function (item) {
  16475. if (item.enableFiltering) {
  16476. //console.log("filtersData="+JSON.stringify(filtersData))
  16477. if (
  16478. angular.isDefined(item.filters[0].term) &&
  16479. item.filters[0].term != ""
  16480. ) {
  16481. if (angular.isUndefined(filtersData["user"])) {
  16482. filtersData["user"] = {};
  16483. }
  16484. filtersData["user"][item.field] =
  16485. item.filters[0].term;
  16486. }
  16487. }
  16488. });
  16489. $scope.memoryfilterData = filtersData;
  16490. $scope.loadData(filtersData);
  16491. });
  16492. };
  16493. if (!options.model) {
  16494. var mouse = {
  16495. model: {
  16496. currentRole: "",
  16497. },
  16498. };
  16499. angular.extend(options, mouse);
  16500. }
  16501. $scope.memoryfilterData = {
  16502. idx: 0,
  16503. sum: 10,
  16504. user: {
  16505. roledata: {
  16506. rolecode: options.model.currentRole,
  16507. },
  16508. selectType: "1",
  16509. },
  16510. };
  16511. $scope.loadData = function (filterData) {
  16512. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  16513. items
  16514. .fetchItems(filterData, APIService)
  16515. .then(function (data) {
  16516. var myData = Restangular.stripRestangular(data);
  16517. $scope.gridOptions.totalItems = myData.totalNum;
  16518. $scope.myData = myData.list;
  16519. //console.log($scope.gridOptions.pagination.getTotalPages());
  16520. // if($scope.selected.items){
  16521. // angular.forEach($scope.selected.items,function(selectItem){
  16522. // $scope.gridApi.selection.selectRow(selectItem);
  16523. // });
  16524. // }
  16525. });
  16526. };
  16527. // $scope.title = title;
  16528. $scope.loadData({
  16529. idx: 0,
  16530. sum: 10,
  16531. user: {
  16532. roledata: {
  16533. rolecode: options.model.currentRole,
  16534. },
  16535. selectType: "1",
  16536. },
  16537. });
  16538. // $timeout(function(){
  16539. // if($scope.selected.items){
  16540. // angular.forEach($scope.selected.items,function(selectItem){
  16541. // $scope.gridApi.selection.selectRow(selectItem);
  16542. // });
  16543. // }
  16544. // },2000)
  16545. $scope.ok = function () {
  16546. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  16547. $modalInstance.close($scope.selected.items);
  16548. };
  16549. $scope.cancel = function () {
  16550. $modalInstance.dismiss("cancel");
  16551. };
  16552. },
  16553. size: size,
  16554. resolve: {
  16555. items: function () {
  16556. return {
  16557. fetchItems: function (filterData, APIService) {
  16558. filterData = filterData || {};
  16559. if (
  16560. angular.isDefined(filterData.idx) &&
  16561. filterData.idx == null
  16562. ) {
  16563. filterData = {
  16564. idx: 0,
  16565. sum: 10,
  16566. user: {
  16567. roledata: {
  16568. rolecode: options.model.incident.currentRole,
  16569. },
  16570. selectType: "1",
  16571. },
  16572. };
  16573. }
  16574. return options.templateOptions.fetchItems(
  16575. filterData,
  16576. APIService
  16577. );
  16578. },
  16579. };
  16580. },
  16581. title: function () {
  16582. return options.templateOptions.modalTitle;
  16583. },
  16584. Restangular: function () {
  16585. return options.templateOptions.Restangular;
  16586. },
  16587. APIService: function () {
  16588. return options.templateOptions.ApiService;
  16589. },
  16590. selectItems: function () {
  16591. return model || [];
  16592. },
  16593. },
  16594. });
  16595. modalInstance.result.then(
  16596. function (selectedItem) {
  16597. options.value(selectedItem);
  16598. options.formControl.$validate();
  16599. },
  16600. function () {
  16601. //console.log('Modal dismissed at: ' + new Date());
  16602. }
  16603. );
  16604. },
  16605. },
  16606. validators: {
  16607. required: {
  16608. expression: function (viewValue, modelValue) {
  16609. var value = modelValue || viewValue;
  16610. return value.length >= 1;
  16611. },
  16612. },
  16613. },
  16614. };
  16615. },
  16616. controller: [
  16617. "$scope",
  16618. function ($scope) {
  16619. $scope.model[$scope.options.key] = [];
  16620. $scope.remove = function (itemId) {
  16621. angular.forEach(
  16622. $scope.model[$scope.options.key],
  16623. function (entry, index) {
  16624. if (entry.id == itemId) {
  16625. $scope.model[$scope.options.key].splice(index, 1);
  16626. // console.log($scope.options.formControl)
  16627. $scope.options.formControl.$validate();
  16628. } else {
  16629. }
  16630. }
  16631. );
  16632. };
  16633. },
  16634. ],
  16635. });
  16636. //用户多选控件-字符串展示
  16637. formlyConfigProvider.setType({
  16638. name: "ui-stringuserselect",
  16639. extends: "input",
  16640. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  16641. defaultOptions: function (options) {
  16642. return {
  16643. templateOptions: {
  16644. translate: "",
  16645. refreshDelay: 0,
  16646. },
  16647. };
  16648. },
  16649. controller: [
  16650. "$scope",
  16651. function ($scope) {
  16652. var keydata = "";
  16653. if (angular.isArray($scope.model)) {
  16654. angular.forEach($scope.model, function (item) {
  16655. keydata = keydata + "," + item.name;
  16656. });
  16657. }
  16658. // $scope.model[$scope.options.key] = [];
  16659. },
  16660. ],
  16661. });
  16662. //重复事件
  16663. formlyConfigProvider.setType({
  16664. name: "ui-incidentmodelselect",
  16665. extends: "input",
  16666. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16667. defaultOptions: function (options) {
  16668. return {
  16669. templateOptions: {
  16670. openModal: function (size, options, modal) {
  16671. var modalInstance = modal.open({
  16672. templateUrl:
  16673. "assets/views/customform/tpl/checktable-modal-content.html",
  16674. controller: function (
  16675. $scope,
  16676. $rootScope,
  16677. $modalInstance,
  16678. items,
  16679. title,
  16680. Restangular,
  16681. APIService,
  16682. i18nService,
  16683. api_configure_data,
  16684. api_user_data,
  16685. api_bpm_data
  16686. ) {
  16687. $scope.langs = i18nService.getAllLangs();
  16688. $scope.lang = "zh-cn";
  16689. i18nService.setCurrentLang($scope.lang);
  16690. $scope.gridOptions = {};
  16691. $scope.gridOptions.data = "myData";
  16692. $scope.gridOptions.enableColumnResizing = true;
  16693. $scope.gridOptions.enableFiltering = true;
  16694. $scope.gridOptions.enableGridMenu = false;
  16695. $scope.gridOptions.enableRowSelection = true;
  16696. $scope.gridOptions.showGridFooter = true;
  16697. $scope.gridOptions.showColumnFooter = false;
  16698. $scope.gridOptions.fastWatch = true;
  16699. $scope.gridOptions.useExternalFiltering = true;
  16700. $scope.gridOptions.useExternalPagination = true;
  16701. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16702. $scope.gridOptions.paginationPageSize = 10;
  16703. $scope.gridOptions.multiSelect = false;
  16704. var mun = $scope.gridOptions.paginationPageSize;
  16705. $scope.gridOptions.rowIdentity = function (row) {
  16706. return row.id;
  16707. };
  16708. $scope.gridOptions.getRowIdentity = function (row) {
  16709. return row.id;
  16710. };
  16711. $scope.gridOptions.columnDefs = items.columnDefs();
  16712. $scope.transferTime = function (time) {
  16713. return moment(time).format("YYYY-MM-DD HH:mm");
  16714. };
  16715. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16716. $scope.gridApi = gridApi;
  16717. gridApi.pagination.on.paginationChanged(
  16718. $scope,
  16719. function (newPage, pageSize) {
  16720. // console.log(newPage);
  16721. // console.log(pageSize);
  16722. $scope.loadData({
  16723. idx: newPage - 1,
  16724. sum: pageSize,
  16725. });
  16726. }
  16727. );
  16728. gridApi.core.on.filterChanged($scope, function () {
  16729. var grid = this.grid;
  16730. var filtersData = {
  16731. idx: 0,
  16732. sum: 100,
  16733. };
  16734. angular.forEach(grid.columns, function (item) {
  16735. if (item.enableFiltering) {
  16736. if (
  16737. angular.isDefined(item.filters[0].term) &&
  16738. item.filters[0].term != ""
  16739. ) {
  16740. // console.log("filtersData="+JSON.stringify(filtersData))
  16741. if (angular.isUndefined(filtersData["incident"])) {
  16742. filtersData["incident"] = {};
  16743. }
  16744. filtersData["incident"][item.field] =
  16745. item.filters[0].term;
  16746. if (angular.isUndefined(filtersData["problem"])) {
  16747. filtersData["problem"] = {};
  16748. }
  16749. filtersData["problem"][item.field] =
  16750. item.filters[0].term;
  16751. if (angular.isUndefined(filtersData["change"])) {
  16752. filtersData["change"] = {};
  16753. }
  16754. filtersData["change"][item.field] =
  16755. item.filters[0].term;
  16756. if (angular.isUndefined(filtersData["release"])) {
  16757. filtersData["release"] = {};
  16758. }
  16759. filtersData["release"][item.field] =
  16760. item.filters[0].term;
  16761. }
  16762. }
  16763. });
  16764. $scope.loadData(filtersData);
  16765. });
  16766. gridApi.selection.on.rowSelectionChanged(
  16767. $scope,
  16768. function (data) {
  16769. $scope.selected.item = data.entity;
  16770. //console.log(data);
  16771. }
  16772. );
  16773. };
  16774. //资产
  16775. $scope.cmdb = {};
  16776. //资产状态
  16777. $scope.state_data = [
  16778. {
  16779. name: "全部状态",
  16780. value: "",
  16781. },
  16782. {
  16783. name: "在库",
  16784. value: "1",
  16785. },
  16786. {
  16787. name: "在线",
  16788. value: "2",
  16789. },
  16790. {
  16791. name: "借出",
  16792. value: "3",
  16793. },
  16794. {
  16795. name: "报修",
  16796. value: "4",
  16797. },
  16798. {
  16799. name: "报废",
  16800. value: "5",
  16801. },
  16802. {
  16803. name: "备用",
  16804. value: "6",
  16805. },
  16806. ];
  16807. //资产类型
  16808. $scope.wt_zcfl = function () {
  16809. api_configure_data
  16810. .fetchDataList("ciclassify", {
  16811. idx: 0,
  16812. sum: 100,
  16813. })
  16814. .then(function (data) {
  16815. console.log(data);
  16816. // $scope.wt_zclx = data.list;
  16817. console.log(data);
  16818. $scope.wtData = [];
  16819. if (data.status == 200) {
  16820. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  16821. var root = null; //Initially set our loop to null
  16822. var parentNode = null;
  16823. //loop over data
  16824. // $scope.wtData=data.list;
  16825. data = data.list;
  16826. //知识库分类数据三级处理
  16827. for (var i = 0; i < data.length; i++) {
  16828. // console.log(data[i])
  16829. var datum = data[i];
  16830. //each node will have children, so let's give it a "children" poperty
  16831. // console.log(datum);
  16832. datum.children = [];
  16833. if (!datum.parent) {
  16834. $scope.wtData.push(datum);
  16835. // console.log($scope.wtData)
  16836. } else {
  16837. if ($scope.wtData[0]) {
  16838. if ($scope.wtData[0].id == datum.parent.id) {
  16839. $scope.wtData[0].children.push(datum);
  16840. }
  16841. for (
  16842. var j = 0;
  16843. j < $scope.wtData[0].children.length;
  16844. j++
  16845. ) {
  16846. if (
  16847. $scope.wtData[0].children[j].id ==
  16848. datum.parent.id
  16849. ) {
  16850. $scope.wtData[0].children[j].children.push(
  16851. datum
  16852. );
  16853. }
  16854. }
  16855. }
  16856. if ($scope.wtData[1]) {
  16857. if ($scope.wtData[1].id == datum.parent.id) {
  16858. $scope.wtData[1].children.push(datum);
  16859. }
  16860. for (
  16861. var j = 0;
  16862. j < $scope.wtData[1].children.length;
  16863. j++
  16864. ) {
  16865. if (
  16866. $scope.wtData[1].children[j].id ==
  16867. datum.parent.id
  16868. ) {
  16869. $scope.wtData[1].children[j].children.push(
  16870. datum
  16871. );
  16872. }
  16873. }
  16874. }
  16875. if ($scope.wtData[2]) {
  16876. if ($scope.wtData[2].id == datum.parent.id) {
  16877. $scope.wtData[2].children.push(datum);
  16878. }
  16879. for (
  16880. var j = 0;
  16881. j < $scope.wtData[2].children.length;
  16882. j++
  16883. ) {
  16884. if (
  16885. $scope.wtData[2].children[j].id ==
  16886. datum.parent.id
  16887. ) {
  16888. $scope.wtData[2].children[j].children.push(
  16889. datum
  16890. );
  16891. }
  16892. }
  16893. }
  16894. }
  16895. // console.log($scope.wtData)
  16896. idToNodeMap[datum.id] = datum;
  16897. root = datum;
  16898. // treeMap[datum.id] = root;
  16899. }
  16900. }
  16901. });
  16902. };
  16903. $scope.wt_zcfl();
  16904. //事件
  16905. //受理人,处理人
  16906. $scope.searchkeys = {};
  16907. var fieldata = {
  16908. idx: 0,
  16909. sum: 100,
  16910. flag: -1,
  16911. user: {
  16912. engineer: 1,
  16913. }
  16914. };
  16915. getUser(fieldata, 3);
  16916. function getUser(fieldatas, it) {
  16917. api_user_data
  16918. .fetchDataList("user", fieldatas)
  16919. .then(function (data) {
  16920. if (it == 1) {
  16921. $scope.acceptUser = data.list;
  16922. } else if (it == 2) {
  16923. $scope.handlingPersonnelUser = data.list;
  16924. } else if (it == 3) {
  16925. $scope.acceptUser = data.list;
  16926. $scope.handlingPersonnelUser = data.list;
  16927. }
  16928. });
  16929. }
  16930. //状态
  16931. $scope.othcode = {};
  16932. api_bpm_data
  16933. .fetchDataList("incidentstatus", {
  16934. idx: 0,
  16935. sum: 100,
  16936. })
  16937. .then(function (response) {
  16938. if (response) {
  16939. if ((response.status = 200)) {
  16940. $scope.state = response.list;
  16941. }
  16942. }
  16943. });
  16944. var defaultFilterData = {
  16945. assignee: $rootScope.user.id,
  16946. searchType: "todo",
  16947. idx: 0,
  16948. sum: mun,
  16949. };
  16950. var defaultFilterData1 = {
  16951. // "searchType": "todo",
  16952. idx: 0,
  16953. sum: mun,
  16954. };
  16955. //搜索
  16956. $scope.chiceIncident = function (parameters, item, stateid) {
  16957. console.log(item, stateid);
  16958. console.log($scope);
  16959. if ($scope.title == "关联资产编号") {
  16960. // alert('222222222222');
  16961. var fildata = defaultFilterData1;
  16962. $scope.gridOptions.paginationCurrentPage = 1;
  16963. var transitiondata = angular.copy(item);
  16964. angular.extend(fildata, transitiondata);
  16965. if (fildata.hw_state) {
  16966. fildata.hw_state = fildata.hw_state.name;
  16967. }
  16968. if (fildata.sign) {
  16969. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  16970. fildata.sign = fildata.sign.split(";");
  16971. fildata.sign = fildata.sign.join("");
  16972. fildata.sign = fildata.sign.toLowerCase();
  16973. }
  16974. if (fildata.keys) {
  16975. fildata["searchCriteria"] = "uuid";
  16976. }
  16977. console.log(fildata);
  16978. $scope.loadData(fildata);
  16979. }
  16980. if ($scope.title == "关联事件工单") {
  16981. // alert('3333333333333333')
  16982. if (stateid && stateid.code) {
  16983. item.statusId = stateid.code;
  16984. }
  16985. var fildata = defaultFilterData;
  16986. // $scope.memoryfilterData = fildata;
  16987. if (!fildata.incident) {
  16988. fildata["incident"] = {};
  16989. }
  16990. $scope.gridOptions.paginationCurrentPage = 1;
  16991. var transitiondata = angular.copy(item);
  16992. angular.extend(fildata.incident, transitiondata);
  16993. console.log(fildata);
  16994. // $scope.loadData(fildata);
  16995. api_bpm_data
  16996. .fetchDataList("incident", fildata)
  16997. .then(function (data) {
  16998. console.log(data);
  16999. if (data) {
  17000. $scope.myData = data.list;
  17001. $scope.gridOptions.totalItems = data.totalNum;
  17002. }
  17003. });
  17004. }
  17005. };
  17006. //重置
  17007. $scope.replacement = function (
  17008. parameters,
  17009. searchkeys,
  17010. othcode
  17011. ) {
  17012. // console.log(parameters, searchkeys, othcode);
  17013. delete defaultFilterData.incident;
  17014. console.log(defaultFilterData);
  17015. $scope.parameters = null;
  17016. $scope.searchkeys = {};
  17017. $scope.othcode = {};
  17018. $scope.wt_zcfl();
  17019. };
  17020. $scope.loadData = function (filterData) {
  17021. items
  17022. .fetchItems(filterData, APIService, $rootScope)
  17023. .then(function (data) {
  17024. var myData = Restangular.stripRestangular(data);
  17025. if (myData.data && myData.data.node) {
  17026. $scope.gridOptions.totalItems = myData.total;
  17027. $scope.myData = myData.data.node;
  17028. } else {
  17029. if (myData.resultCount) {
  17030. $scope.gridOptions["totalItems"] = myData.resultCount;
  17031. } else {
  17032. $scope.gridOptions.totalItems = myData.totalNum;
  17033. }
  17034. if (myData.list) {
  17035. $scope.myData = myData.list;
  17036. } else {
  17037. $scope.myData = myData.data;
  17038. }
  17039. }
  17040. });
  17041. };
  17042. $scope.title = title;
  17043. $scope.loadData({
  17044. idx: 0,
  17045. sum: 10,
  17046. });
  17047. $scope.selected = {
  17048. item: {},
  17049. };
  17050. $scope.ok = function () {
  17051. //console.log($scope.selected.item);
  17052. $modalInstance.close($scope.selected.item);
  17053. };
  17054. $scope.cancel = function () {
  17055. $modalInstance.dismiss("cancel");
  17056. };
  17057. },
  17058. size: size,
  17059. resolve: {
  17060. items: function () {
  17061. return {
  17062. fetchItems: function (filterData, APIService, $rootScope) {
  17063. filterData = filterData || {};
  17064. // if(!filterData.idx){
  17065. if (
  17066. angular.isDefined(filterData.idx) &&
  17067. filterData.idx == null
  17068. ) {
  17069. filterData = {
  17070. idx: 0,
  17071. sum: 10,
  17072. };
  17073. }
  17074. return options.templateOptions.fetchItems(
  17075. filterData,
  17076. APIService,
  17077. $rootScope
  17078. );
  17079. },
  17080. columnDefs: function () {
  17081. return options.templateOptions.columnDefs;
  17082. },
  17083. };
  17084. },
  17085. title: function () {
  17086. return options.templateOptions.modalTitle;
  17087. },
  17088. Restangular: function () {
  17089. return options.templateOptions.Restangular;
  17090. },
  17091. APIService: function () {
  17092. return options.templateOptions.ApiService;
  17093. },
  17094. },
  17095. });
  17096. modalInstance.result.then(
  17097. function (selectedItem) {
  17098. var selectitem = {
  17099. title: selectedItem.title,
  17100. description: selectedItem.description,
  17101. };
  17102. if (options.key == "chuku") {
  17103. if (selectedItem.assets) {
  17104. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  17105. selectedItem.assets;
  17106. }
  17107. if (selectedItem.consumables) {
  17108. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  17109. selectedItem.consumables;
  17110. }
  17111. angular.extend(
  17112. $scope.$parent.$parent.$parent.model,
  17113. selectitem
  17114. );
  17115. options.value(selectedItem);
  17116. // options.model.consumables = JSON.parse(consumables);
  17117. } else if (options.templateOptions.pkey == "change") {
  17118. console.log(options);
  17119. angular.extend(options.model);
  17120. options.value(selectedItem);
  17121. } else if (options.key == "cmdbCode") {
  17122. var zc_selectitem = selectedItem.uuid;
  17123. // angular.extend(options.model,zc_selectitem);
  17124. options.model.cmdbCode = zc_selectitem;
  17125. // angular.extend(options.model,zc_selectitem);
  17126. // options.templateOptions.displayName=zc_selectitem;
  17127. options.value(selectedItem);
  17128. console.log(options.model);
  17129. } else {
  17130. angular.extend(options.model, selectitem);
  17131. options.value(selectedItem);
  17132. }
  17133. },
  17134. function () {
  17135. //console.log('Modal dismissed at: ' + new Date());
  17136. }
  17137. );
  17138. },
  17139. },
  17140. };
  17141. },
  17142. });
  17143. //选项选择控件
  17144. formlyConfigProvider.setType({
  17145. name: "ui-modelselect",
  17146. extends: "input",
  17147. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  17148. defaultOptions: function (options) {
  17149. return {
  17150. templateOptions: {
  17151. openModal: function (size, options, modal) {
  17152. var modalInstance = modal.open({
  17153. templateUrl:
  17154. "assets/views/customform/tpl/checktable-modal-content.html",
  17155. controller: function (
  17156. $scope,
  17157. $modalInstance,
  17158. items,
  17159. title,
  17160. Restangular,
  17161. APIService,
  17162. i18nService
  17163. ) {
  17164. $scope.langs = i18nService.getAllLangs();
  17165. $scope.lang = "zh-cn";
  17166. i18nService.setCurrentLang($scope.lang);
  17167. $scope.gridOptions = {};
  17168. $scope.gridOptions.data = "myData";
  17169. $scope.gridOptions.enableColumnResizing = true;
  17170. $scope.gridOptions.enableFiltering = true;
  17171. $scope.gridOptions.enableGridMenu = false;
  17172. $scope.gridOptions.enableRowSelection = true;
  17173. $scope.gridOptions.showGridFooter = true;
  17174. $scope.gridOptions.showColumnFooter = true;
  17175. $scope.gridOptions.fastWatch = true;
  17176. $scope.gridOptions.useExternalFiltering = true;
  17177. $scope.gridOptions.useExternalPagination = true;
  17178. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  17179. $scope.gridOptions.paginationPageSize = 10;
  17180. $scope.gridOptions.multiSelect = false;
  17181. $scope.gridOptions.rowIdentity = function (row) {
  17182. return row.id;
  17183. };
  17184. $scope.gridOptions.getRowIdentity = function (row) {
  17185. return row.id;
  17186. };
  17187. $scope.gridOptions.columnDefs = items.columnDefs();
  17188. $scope.gridOptions.onRegisterApi = function (gridApi) {
  17189. $scope.gridApi = gridApi;
  17190. gridApi.pagination.on.paginationChanged(
  17191. $scope,
  17192. function (newPage, pageSize) {
  17193. // console.log(newPage);
  17194. // console.log(pageSize);
  17195. $scope.loadData({
  17196. idx: newPage - 1,
  17197. sum: pageSize,
  17198. });
  17199. }
  17200. );
  17201. gridApi.core.on.filterChanged($scope, function () {
  17202. var grid = this.grid;
  17203. var filtersData = {
  17204. idx: 0,
  17205. sum: 10,
  17206. };
  17207. angular.forEach(grid.columns, function (item) {
  17208. if (item.enableFiltering) {
  17209. if (
  17210. angular.isDefined(item.filters[0].term) &&
  17211. item.filters[0].term != ""
  17212. ) {
  17213. // console.log("filtersData="+JSON.stringify(filtersData))
  17214. if (angular.isUndefined(filtersData["incident"])) {
  17215. filtersData["incident"] = {};
  17216. }
  17217. filtersData["incident"][item.field] =
  17218. item.filters[0].term;
  17219. if (angular.isUndefined(filtersData["problem"])) {
  17220. filtersData["problem"] = {};
  17221. }
  17222. filtersData["problem"][item.field] =
  17223. item.filters[0].term;
  17224. if (angular.isUndefined(filtersData["change"])) {
  17225. filtersData["change"] = {};
  17226. }
  17227. filtersData["change"][item.field] =
  17228. item.filters[0].term;
  17229. if (angular.isUndefined(filtersData["release"])) {
  17230. filtersData["release"] = {};
  17231. }
  17232. filtersData["release"][item.field] =
  17233. item.filters[0].term;
  17234. }
  17235. }
  17236. });
  17237. $scope.loadData(filtersData);
  17238. });
  17239. gridApi.selection.on.rowSelectionChanged(
  17240. $scope,
  17241. function (data) {
  17242. $scope.selected.item = data.entity;
  17243. //console.log(data);
  17244. }
  17245. );
  17246. };
  17247. $scope.loadData = function (filterData) {
  17248. items
  17249. .fetchItems(filterData, APIService)
  17250. .then(function (data) {
  17251. var myData = Restangular.stripRestangular(data);
  17252. $scope.gridOptions.totalItems = myData.totalNum;
  17253. $scope.myData = myData.list;
  17254. });
  17255. };
  17256. $scope.title = title;
  17257. $scope.loadData({
  17258. idx: 0,
  17259. sum: 10,
  17260. });
  17261. $scope.selected = {
  17262. item: {},
  17263. };
  17264. $scope.ok = function () {
  17265. if ($scope.selected.item.scheduleOrder) {
  17266. $scope.selected.item.descriptionData =
  17267. "日期:" +
  17268. $scope.selected.item.watchTime +
  17269. ";" +
  17270. "班次:" +
  17271. $scope.selected.item.scheduleOrder.description +
  17272. ";" +
  17273. "值班人:" +
  17274. $scope.selected.item.scheduleOrder.users[0].name;
  17275. }
  17276. //console.log($scope.selected.item);
  17277. $modalInstance.close($scope.selected.item);
  17278. };
  17279. $scope.cancel = function () {
  17280. $modalInstance.dismiss("cancel");
  17281. };
  17282. },
  17283. size: size,
  17284. resolve: {
  17285. items: function () {
  17286. return {
  17287. fetchItems: function (filterData, APIService) {
  17288. filterData = filterData || {};
  17289. // if(!filterData.idx){
  17290. if (
  17291. angular.isDefined(filterData.idx) &&
  17292. filterData.idx == null
  17293. ) {
  17294. filterData = {
  17295. idx: 0,
  17296. sum: 10,
  17297. };
  17298. }
  17299. return options.templateOptions.fetchItems(
  17300. filterData,
  17301. APIService,
  17302. options
  17303. );
  17304. },
  17305. columnDefs: function () {
  17306. return options.templateOptions.columnDefs;
  17307. },
  17308. };
  17309. },
  17310. title: function () {
  17311. return options.templateOptions.modalTitle;
  17312. },
  17313. Restangular: function () {
  17314. return options.templateOptions.Restangular;
  17315. },
  17316. APIService: function () {
  17317. return options.templateOptions.ApiService;
  17318. },
  17319. },
  17320. });
  17321. modalInstance.result.then(
  17322. function (selectedItem) {
  17323. options.value(selectedItem);
  17324. },
  17325. function () {
  17326. //console.log('Modal dismissed at: ' + new Date());
  17327. }
  17328. );
  17329. },
  17330. },
  17331. };
  17332. },
  17333. });
  17334. formlyConfigProvider.setType({
  17335. name: "ui-requestform",
  17336. extends: "input",
  17337. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  17338. controller: [
  17339. "$scope",
  17340. function ($scope) {
  17341. setTimeout(function () {
  17342. var filterData = {
  17343. idx: 0,
  17344. sum: 5,
  17345. incident: {
  17346. requester: {
  17347. id: "",
  17348. },
  17349. },
  17350. };
  17351. $scope.options.templateOptions
  17352. .getWorkernumber(
  17353. $scope.options.templateOptions.ApiService,
  17354. filterData
  17355. )
  17356. .then(function (result) {
  17357. var modelData =
  17358. $scope.options.templateOptions.Restangular.stripRestangular(
  17359. result
  17360. );
  17361. });
  17362. }, 1000);
  17363. },
  17364. ],
  17365. });
  17366. //报修图片展示
  17367. formlyConfigProvider.setType({
  17368. name: "ui-repair-photos",
  17369. // extends: 'label',
  17370. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  17371. controller: [
  17372. "$scope",
  17373. "$rootScope",
  17374. "$modal",
  17375. "api_wechatfile",
  17376. "$stateParams",
  17377. function ($scope, $rootScope, $modal, api_wechatfile, $stateParams) {
  17378. console.log($scope);
  17379. $scope.imgs = [];
  17380. $scope.attachmentAddressSplicing = $rootScope.attachmentAddressSplicing;
  17381. if ($scope.model.wxFile) {
  17382. api_wechatfile
  17383. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  17384. .then(function (res) {
  17385. $scope.imgs = res.data;
  17386. });
  17387. }
  17388. console.log($stateParams);
  17389. if (
  17390. $stateParams &&
  17391. $stateParams.model &&
  17392. JSON.parse($stateParams.model) &&
  17393. JSON.parse($stateParams.model).model &&
  17394. JSON.parse($stateParams.model).model.flow
  17395. ) {
  17396. api_wechatfile
  17397. .listAttachment(
  17398. "wechatRequesterIncident",
  17399. JSON.parse($stateParams.model).model.flow
  17400. )
  17401. .then(function (res) {
  17402. $scope.imgs = res.data;
  17403. });
  17404. }
  17405. if ($scope.model.incident && $scope.model.incident.wxIncidentId) {
  17406. api_wechatfile
  17407. .listAttachment(
  17408. "wechatRequesterIncident",
  17409. $scope.model.incident.wxIncidentId
  17410. )
  17411. .then(function (res) {
  17412. $scope.imgs = res.data;
  17413. });
  17414. }
  17415. // if ($scope.model.flow) {
  17416. // api_wechatfile
  17417. // .listAttachment("wechatRequesterIncident", $scope.model.flow)
  17418. // .then(function (res) {
  17419. // $scope.imgs = res.data;
  17420. // });
  17421. // }
  17422. // 加载事件图片
  17423. // if($scope.model.incident){
  17424. // api_wechatfile
  17425. // .listAttachment("incident", $scope.model.incident.processInstanceId)
  17426. // .then(function (res) {
  17427. // $scope.imgs = res.data;
  17428. // });
  17429. // }
  17430. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  17431. // // setTimeout(function () {
  17432. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  17433. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  17434. // // if (modelData.status == 200) {
  17435. // // $scope.model[$scope.options.key] = modelData.data;
  17436. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  17437. // // }
  17438. // // });
  17439. // // }, 1000);
  17440. // }
  17441. $scope.preview = function (url, idx) {
  17442. var title = $scope.imgs[idx].title;
  17443. $modal.open({
  17444. backdrop: false,
  17445. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17446. controller: function ($scope, $rootScope, scope, $modalInstance) {
  17447. $scope.title = title;
  17448. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  17449. $scope.cancel = function () {
  17450. $modalInstance.dismiss("cancel");
  17451. };
  17452. },
  17453. resolve: {
  17454. scope: function () {
  17455. return $scope;
  17456. },
  17457. },
  17458. });
  17459. };
  17460. },
  17461. ],
  17462. });
  17463. //图片展示
  17464. formlyConfigProvider.setType({
  17465. name: "ui-showImgs",
  17466. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  17467. defaultOptions: function (options) {
  17468. return {
  17469. templateOptions: {
  17470. refresh: function (APIService, processInstanceId, data) {
  17471. return APIService.listAttachments(processInstanceId);
  17472. },
  17473. downloadUri: function (APIService, contentId) {
  17474. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17475. },
  17476. view: function (APIService, contentId) {
  17477. return APIService.attachmentsPreviewUrl(contentId);
  17478. },
  17479. download: function (APIService, contentId, item) {
  17480. var item = {
  17481. url: APIService.download(contentId),
  17482. headers: headers,
  17483. };
  17484. return item;
  17485. },
  17486. refreshDelay: 0,
  17487. },
  17488. };
  17489. },
  17490. controller: [
  17491. "$scope",
  17492. "$timeout",
  17493. "$modal",
  17494. "$rootScope",
  17495. "$http",
  17496. "up_down_file",
  17497. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17498. $scope.attachmentAddressSplicing = $rootScope.attachmentAddressSplicing;
  17499. var _refreshDelayPromise;
  17500. /**
  17501. * refresh
  17502. */
  17503. $scope._refresh = function (refreshAttr) {
  17504. $scope.attachments = [];
  17505. if (refreshAttr !== undefined) {
  17506. if (_refreshDelayPromise) {
  17507. $timeout.cancel(_refreshDelayPromise);
  17508. }
  17509. _refreshDelayPromise = $timeout(function () {
  17510. // 暂存附件
  17511. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17512. $scope.options.templateOptions
  17513. .refresh(
  17514. $scope.options.templateOptions.ApiService,
  17515. $scope.options.templateOptions.processInstanceId,
  17516. {
  17517. idx: 0,
  17518. sum: 1000,
  17519. }
  17520. )
  17521. .then(function (response) {
  17522. var myData =
  17523. $scope.options.templateOptions.Restangular.stripRestangular(
  17524. response
  17525. );
  17526. if (myData) {
  17527. for (var i = 0; i < myData.data.length; i++) {
  17528. $scope.attachments.push(myData.data[i]);
  17529. }
  17530. }
  17531. $scope.options.templateOptions
  17532. .refresh(
  17533. $scope.options.templateOptions.ApiService,
  17534. $scope.$parent.$parent.$parent.model.save_fileId,
  17535. {
  17536. idx: 0,
  17537. sum: 1000,
  17538. }
  17539. )
  17540. .then(function (response2) {
  17541. var myData2 =
  17542. $scope.options.templateOptions.Restangular.stripRestangular(
  17543. response2
  17544. );
  17545. if (myData2) {
  17546. for (var i = 0; i < myData2.data.length; i++) {
  17547. $scope.attachments.push(myData2.data[i]);
  17548. }
  17549. }
  17550. console.log($scope.attachments);
  17551. });
  17552. });
  17553. // 正常附件
  17554. } else {
  17555. $scope.options.templateOptions
  17556. .refresh(
  17557. $scope.options.templateOptions.ApiService,
  17558. $scope.options.templateOptions.processInstanceId,
  17559. {
  17560. idx: 0,
  17561. sum: 1000,
  17562. }
  17563. )
  17564. .then(function (response) {
  17565. var myData =
  17566. $scope.options.templateOptions.Restangular.stripRestangular(
  17567. response
  17568. );
  17569. if (myData) {
  17570. $scope.attachments = [];
  17571. $scope.imgs = [];
  17572. myData.data.forEach((e) => {
  17573. // if (
  17574. // e.suffix == "jpeg" ||
  17575. // e.suffix == "jpg" ||
  17576. // e.suffix == "svg" ||
  17577. // e.suffix == "png" ||
  17578. // e.suffix == "bmp" ||
  17579. // e.suffix == "gif" ||
  17580. // e.suffix == "tif"
  17581. // ) {
  17582. // $scope.imgs.push(e);
  17583. // }
  17584. $scope.imgs.push(e);
  17585. });
  17586. $scope.imgs = $scope.imgs;
  17587. console.log($scope.imgs);
  17588. }
  17589. });
  17590. }
  17591. }, $scope.options.templateOptions.refreshDelay);
  17592. }
  17593. };
  17594. $scope._refresh({});
  17595. // $scope.attachments = $scope.model[$scope.options.key]
  17596. // 预览
  17597. $scope.preview = function (url, idx) {
  17598. var title = $scope.imgs[idx].title;
  17599. $modal.open({
  17600. backdrop: false,
  17601. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17602. controller: function ($scope, $rootScope, scope, $modalInstance) {
  17603. $scope.title = title;
  17604. $scope.imageurl = $rootScope.attachmentAddressSplicing(url);
  17605. $scope.cancel = function () {
  17606. $modalInstance.dismiss("cancel");
  17607. };
  17608. },
  17609. resolve: {
  17610. scope: function () {
  17611. return $scope;
  17612. },
  17613. },
  17614. });
  17615. };
  17616. },
  17617. ],
  17618. });
  17619. //工单/受理人控件
  17620. formlyConfigProvider.setType({
  17621. name: "ui-workernumbersign",
  17622. // extends: 'label',
  17623. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  17624. controller: [
  17625. "$scope",
  17626. function ($scope) {
  17627. // 2020年4月24日13:20:40
  17628. console.log($scope, "docu");
  17629. // 左侧事件工单区域地点填充
  17630. $scope.model.selecthouseNumber = $scope.model.place;
  17631. if (
  17632. angular.isUndefined($scope.model[$scope.options.key]) ||
  17633. $scope.model[$scope.options.key] == null
  17634. ) {
  17635. setTimeout(function () {
  17636. $scope.options.templateOptions
  17637. .getWorkernumber($scope.options.templateOptions.ApiService)
  17638. .then(function (result) {
  17639. var modelData =
  17640. $scope.options.templateOptions.Restangular.stripRestangular(
  17641. result
  17642. );
  17643. if (modelData.status == 200) {
  17644. $scope.model[$scope.options.key] = modelData.data;
  17645. $scope.options.initialValue =
  17646. $scope.model[$scope.options.key];
  17647. }
  17648. });
  17649. }, 1000);
  17650. }
  17651. if (
  17652. $scope.options.templateOptions.user &&
  17653. (angular.isUndefined($scope.model.acceptUser) ||
  17654. $scope.model.acceptUser == null)
  17655. ) {
  17656. if (angular.isFunction($scope.options.templateOptions.transform)) {
  17657. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  17658. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  17659. // }
  17660. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17661. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17662. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  17663. }
  17664. $scope.model.acceptUser = $scope.options.templateOptions.user;
  17665. // $scope.options.initialValue = $scope.model.acceptUser;
  17666. }
  17667. },
  17668. ],
  17669. });
  17670. //工单控件-only number
  17671. formlyConfigProvider.setType({
  17672. name: "ui-workernumber",
  17673. extends: "input",
  17674. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17675. controller: [
  17676. "$scope",
  17677. function ($scope) {
  17678. if (
  17679. angular.isUndefined($scope.model[$scope.options.key]) ||
  17680. $scope.model[$scope.options.key] == null
  17681. ) {
  17682. setTimeout(function () {
  17683. $scope.options.templateOptions
  17684. .getWorkernumber($scope.options.templateOptions.ApiService)
  17685. .then(function (result) {
  17686. var modelData =
  17687. $scope.options.templateOptions.Restangular.stripRestangular(
  17688. result
  17689. );
  17690. if (modelData.status == 200) {
  17691. $scope.model[$scope.options.key] = modelData.data;
  17692. $scope.options.initialValue =
  17693. $scope.model[$scope.options.key];
  17694. }
  17695. });
  17696. }, 1000);
  17697. }
  17698. },
  17699. ],
  17700. });
  17701. //cmdb工单
  17702. formlyConfigProvider.setType({
  17703. name: "ui-cmdbworkernumber",
  17704. extends: "input",
  17705. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17706. controller: [
  17707. "$scope",
  17708. function ($scope) {
  17709. if (
  17710. angular.isUndefined($scope.model[$scope.options.key]) ||
  17711. $scope.model[$scope.options.key] == null
  17712. ) {
  17713. setTimeout(function () {
  17714. $scope.options.templateOptions
  17715. .getWorkernumber(
  17716. $scope.options.templateOptions.ApiService,
  17717. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  17718. .cifilter_classics.id
  17719. )
  17720. .then(function (result) {
  17721. var modelData =
  17722. $scope.options.templateOptions.Restangular.stripRestangular(
  17723. result
  17724. );
  17725. // if(modelData.status==200){
  17726. $scope.model[$scope.options.key] =
  17727. modelData[$scope.options.key];
  17728. $scope.options.initialValue = $scope.model[$scope.options.key];
  17729. // }
  17730. });
  17731. }, 1000);
  17732. }
  17733. },
  17734. ],
  17735. });
  17736. //简易上传图片组件
  17737. formlyConfigProvider.setType({
  17738. name: "ui-uploadImgs",
  17739. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  17740. wrapper: ["bootstrapHasError"],
  17741. controller: [
  17742. "$scope",
  17743. "fileReader",
  17744. "$parse",
  17745. "$modal",
  17746. function ($scope, fileReader, $parse, $modal) {
  17747. $scope.imgshows = [];
  17748. $scope.uploadimgs = [];
  17749. var model = $parse("upload_img");
  17750. var modelSetter = model.assign;
  17751. var uploader = ($scope.uploader =
  17752. $scope.options.templateOptions.fileUploader);
  17753. uploader.filters.push({
  17754. name: "customFilter",
  17755. fn: function (item /*{File|FileLikeObject}*/, options) {
  17756. return this.queue.length < 10;
  17757. },
  17758. });
  17759. // 添加
  17760. $scope.change = function (event) {
  17761. var element = $(".upinp");
  17762. modelSetter($scope, element[0].files[0]);
  17763. //附件预览
  17764. $scope.imgupload = event.files[0];
  17765. getFile($scope.imgupload, $scope);
  17766. //获得预览图地址并且把file对象放入上传合集内
  17767. function getFile(imgupload, $scope) {
  17768. if (!imgupload) {
  17769. return;
  17770. }
  17771. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  17772. $scope.imgshows.push(result);
  17773. var file = document.querySelector("input[type=file]").files[0];
  17774. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  17775. console.log($scope.imgshows, $scope.uploadimgs);
  17776. if ($scope.imgshows.length < 3) {
  17777. $("#upup").show();
  17778. } else {
  17779. $("#upup").hide();
  17780. }
  17781. });
  17782. }
  17783. };
  17784. // 删除
  17785. $scope.uploadimg_del = function (index, imgs) {
  17786. console.log(index, imgs);
  17787. $scope.imgshows.splice(index, 1);
  17788. $scope.uploadimgs.splice(index, 1);
  17789. if ($scope.imgshows.length < 3) {
  17790. $("#upup").show();
  17791. } else {
  17792. $("#upup").hide();
  17793. }
  17794. };
  17795. // 预览
  17796. $scope.preview = function (url, idx) {
  17797. var name = $scope.uploadimgs[idx].name;
  17798. $modal.open({
  17799. backdrop: false,
  17800. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17801. controller: function ($scope, scope, $modalInstance) {
  17802. $scope.title = name;
  17803. $scope.imageurl = url;
  17804. $scope.cancel = function () {
  17805. $modalInstance.dismiss("cancel");
  17806. };
  17807. },
  17808. resolve: {
  17809. scope: function () {
  17810. return $scope;
  17811. },
  17812. },
  17813. });
  17814. };
  17815. if (uploader) {
  17816. uploader.onWhenAddingFileFailed = function (
  17817. item /*{File|FileLikeObject}*/,
  17818. filter,
  17819. options
  17820. ) {
  17821. console.info("onWhenAddingFileFailed", item, filter, options);
  17822. };
  17823. uploader.onAfterAddingFile = function (fileItem) {
  17824. console.info("onAfterAddingFile", fileItem);
  17825. };
  17826. uploader.onAfterAddingAll = function (addedFileItems) {
  17827. console.info("onAfterAddingAll", addedFileItems);
  17828. };
  17829. uploader.onBeforeUploadItem = function (item) {
  17830. console.info("onBeforeUploadItem", item);
  17831. };
  17832. uploader.onProgressItem = function (fileItem, progress) {
  17833. console.info("onProgressItem", fileItem, progress);
  17834. };
  17835. uploader.onProgressAll = function (progress) {
  17836. console.info("onProgressAll", progress);
  17837. };
  17838. uploader.onSuccessItem = function (
  17839. fileItem,
  17840. response,
  17841. status,
  17842. headers
  17843. ) {
  17844. console.info("onSuccessItem", fileItem, response, status, headers);
  17845. };
  17846. uploader.onErrorItem = function (
  17847. fileItem,
  17848. response,
  17849. status,
  17850. headers
  17851. ) {
  17852. console.info("onErrorItem", fileItem, response, status, headers);
  17853. };
  17854. uploader.onCancelItem = function (
  17855. fileItem,
  17856. response,
  17857. status,
  17858. headers
  17859. ) {
  17860. console.info("onCancelItem", fileItem, response, status, headers);
  17861. };
  17862. uploader.onCompleteItem = function (
  17863. fileItem,
  17864. response,
  17865. status,
  17866. headers
  17867. ) {
  17868. console.info("onCompleteItem", fileItem, response, status, headers);
  17869. };
  17870. uploader.onCompleteAll = function () {
  17871. console.info("onCompleteAll");
  17872. };
  17873. }
  17874. // console.log(modelSetter)
  17875. },
  17876. ],
  17877. });
  17878. //jry-上传下载一体
  17879. formlyConfigProvider.setType({
  17880. name: "ui-upDropFile",
  17881. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  17882. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17883. defaultOptions: function (options) {
  17884. return {
  17885. templateOptions: {
  17886. view: function (APIService, contentId) {
  17887. return APIService.downloadAttachment(contentId);
  17888. },
  17889. // ApiService: 'api_wechatfile',
  17890. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  17891. // upUrl: 'common/common/uploadAttachment',
  17892. // listAttachmentUrl: 'common/common/listAttachment',
  17893. // downUrl: 'common/common/downloadAttachment',
  17894. // bindType: 'incident',
  17895. // bindId: 2323
  17896. },
  17897. // validators: {
  17898. // required: {
  17899. // expression: function(viewValue, modelValue) {
  17900. // var value = modelValue || viewValue;
  17901. // return value.length >= 1;
  17902. // }
  17903. // }
  17904. // }
  17905. };
  17906. },
  17907. controller: [
  17908. "$scope",
  17909. "$rootScope",
  17910. "Restangular",
  17911. "up_down_file",
  17912. "$http",
  17913. "api_bpm",
  17914. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  17915. console.log($scope);
  17916. $scope.showFileUp = true;
  17917. if ($scope.model.isKnowledge_detail) {
  17918. $scope.showFileUp = false;
  17919. }
  17920. if (angular.isUndefined($scope.form.dropState)) {
  17921. $scope.form.dropState = false;
  17922. }
  17923. if ($scope.model.incident) {
  17924. if ($scope.model.incident.alarm) {
  17925. console.log($scope);
  17926. if ($scope.model.incident.alarm) {
  17927. if ($scope.model.incident.alarm.alarmExtension) {
  17928. $scope.model.incident.alarm.alarmExtension =
  17929. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  17930. $scope.model.incident.alarm.alarmExtension =
  17931. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  17932. $scope.model.incident.description =
  17933. $scope.model.incident.alarm.alarmExtension;
  17934. console.log($scope.model.incident.description);
  17935. $scope.model.incident.description =
  17936. '"' +
  17937. "告警名称" +
  17938. '":' +
  17939. '"' +
  17940. $scope.model.incident.alarm.alarmSystem +
  17941. '",' +
  17942. '"' +
  17943. "告警状态" +
  17944. '":' +
  17945. '"' +
  17946. $scope.model.incident.alarm.alarmStatus +
  17947. '",' +
  17948. '"' +
  17949. "告警内容" +
  17950. '":' +
  17951. '"' +
  17952. $scope.model.incident.alarm.alarmContent +
  17953. '",' +
  17954. $scope.model.incident.description;
  17955. } else {
  17956. $scope.model.incident.description =
  17957. '"' +
  17958. "告警名称" +
  17959. '":' +
  17960. '"' +
  17961. $scope.model.incident.alarm.alarmSystem +
  17962. '",' +
  17963. '"' +
  17964. "告警状态" +
  17965. '":' +
  17966. '"' +
  17967. $scope.model.incident.alarm.alarmStatus +
  17968. '",' +
  17969. '"' +
  17970. "告警内容" +
  17971. '":' +
  17972. '"' +
  17973. $scope.model.incident.alarm.alarmContent +
  17974. '",';
  17975. }
  17976. $scope.model.incident.description =
  17977. $scope.model.incident.description.replace(/,/g, "\n");
  17978. console.log($scope.model.incident.description);
  17979. }
  17980. }
  17981. api_bpm
  17982. .tellCategory($scope.model.incident.category.id)
  17983. .then(function (wt_data) {
  17984. console.log(wt_data);
  17985. if (wt_data) {
  17986. $rootScope.wt_category = wt_data.data;
  17987. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  17988. $rootScope.wt_child = wt_data.child;
  17989. }
  17990. });
  17991. if ($scope.model.titleName == "接单") {
  17992. $scope.model.receive_code = "handler";
  17993. if (
  17994. $scope.model.incident.groupLeader &&
  17995. !$scope.model.incident.repeat
  17996. ) {
  17997. $scope.model.isHandlerUser = true;
  17998. }
  17999. }
  18000. if ($scope.model.titleName == "事件处理") {
  18001. console.log($scope.model.cmdbCode);
  18002. if ($scope.model.cmdbCode) {
  18003. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  18004. }
  18005. }
  18006. } else {
  18007. $rootScope.wt_category = "";
  18008. }
  18009. //附件上传数据
  18010. if ($scope.options.templateOptions.fileUploader) {
  18011. var uploader = ($scope.uploader =
  18012. $scope.options.templateOptions.fileUploader);
  18013. //$scope.options.templateOptions.uploader();
  18014. console.log(uploader);
  18015. // FILTERS
  18016. uploader.filters.push({
  18017. name: "customFilter",
  18018. fn: function (item /*{File|FileLikeObject}*/, options) {
  18019. return this.queue.length < 10;
  18020. },
  18021. });
  18022. }
  18023. var to = $scope.options.templateOptions;
  18024. // var bindType = $scope.model.bindType;
  18025. if (to.bindType == "incident") {
  18026. var bindId = $scope.model[to.bindType].processInstanceId;
  18027. } else if (to.bindType == "change") {
  18028. var bindId = $scope.model[to.bindType].processInstanceId;
  18029. } else {
  18030. var bindId = $scope.model[to.bindType].id;
  18031. }
  18032. //获取附件列表
  18033. $scope.listAttachmen = function () {
  18034. to.ApiService.listAttachment(
  18035. to.listAttachmentUrl,
  18036. to.bindType,
  18037. bindId
  18038. ).then(function (result) {
  18039. var myData = Restangular.stripRestangular(result);
  18040. // $scope.listAttachmens = myData;
  18041. $scope.attachments = myData.data;
  18042. });
  18043. };
  18044. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  18045. $scope.listAttachmen();
  18046. } else if (to.bindType && $scope.model[to.bindType].id) {
  18047. $scope.listAttachmen();
  18048. }
  18049. //附件上传
  18050. $scope.isUpfload = to.isUpfload;
  18051. $scope.dropfile = function (
  18052. APIService,
  18053. processInstanceId,
  18054. taskId,
  18055. userId
  18056. ) {
  18057. uploader.onBeforeUploadItem = function (item) {
  18058. angular.extend(item.headers, $rootScope.getSession());
  18059. item.url = to.ApiService.saveAttachments(
  18060. to.uploadUrl,
  18061. to.bindType,
  18062. bindId
  18063. ).getRequestedUrl();
  18064. item.formData.push({
  18065. filename: item.file.name,
  18066. });
  18067. };
  18068. uploader.uploadAll();
  18069. };
  18070. //附件下载
  18071. $scope.download = function (token, filename) {
  18072. var downUrl = to.ApiService.downloadAttachment(
  18073. to.downUrl,
  18074. token
  18075. ).getRequestedUrl();
  18076. // window.open(downUrl);
  18077. var a = document.createElement("a");
  18078. a.href = downUrl;
  18079. a.target = "_blank";
  18080. a.download = filename;
  18081. document.body.appendChild(a);
  18082. a.click();
  18083. };
  18084. //附件预览
  18085. $scope.view = function (id, previewUrl) {
  18086. if (previewUrl) {
  18087. window.open(previewUrl);
  18088. }
  18089. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  18090. // if (response.state == 200) {
  18091. // window.open(response.previewUrl);
  18092. // }
  18093. // })
  18094. };
  18095. // CALLBACKS
  18096. if (uploader) {
  18097. uploader.onWhenAddingFileFailed = function (
  18098. item /*{File|FileLikeObject}*/,
  18099. filter,
  18100. options
  18101. ) {
  18102. console.info("onWhenAddingFileFailed", item, filter, options);
  18103. };
  18104. uploader.onAfterAddingFile = function (fileItem) {
  18105. console.info("onAfterAddingFile", fileItem);
  18106. };
  18107. uploader.onAfterAddingAll = function (addedFileItems) {
  18108. console.info("onAfterAddingAll", addedFileItems);
  18109. };
  18110. uploader.onBeforeUploadItem = function (item) {
  18111. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18112. // // $scope.uploader.options.url();
  18113. // $scope.uploader.onBeforeUploadItem = function(item) {
  18114. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18115. // console.info('onBeforeUploadItem', item);
  18116. // };
  18117. // $scope.uploader.uploadAll();
  18118. // }
  18119. console.info("onBeforeUploadItem", item);
  18120. };
  18121. uploader.onProgressItem = function (fileItem, progress) {
  18122. console.info("onProgressItem", fileItem, progress);
  18123. };
  18124. uploader.onProgressAll = function (progress) {
  18125. console.info("onProgressAll", progress);
  18126. };
  18127. uploader.onSuccessItem = function (
  18128. fileItem,
  18129. response,
  18130. status,
  18131. headers
  18132. ) {
  18133. console.info("onSuccessItem", fileItem, response, status, headers);
  18134. if (response.status == 200) {
  18135. $scope.listAttachmen();
  18136. }
  18137. };
  18138. uploader.onErrorItem = function (
  18139. fileItem,
  18140. response,
  18141. status,
  18142. headers
  18143. ) {
  18144. console.info("onErrorItem", fileItem, response, status, headers);
  18145. };
  18146. uploader.onCancelItem = function (
  18147. fileItem,
  18148. response,
  18149. status,
  18150. headers
  18151. ) {
  18152. console.info("onCancelItem", fileItem, response, status, headers);
  18153. };
  18154. uploader.onCompleteItem = function (
  18155. fileItem,
  18156. response,
  18157. status,
  18158. headers
  18159. ) {
  18160. console.info("onCompleteItem", fileItem, response, status, headers);
  18161. };
  18162. uploader.onCompleteAll = function () {
  18163. console.info("onCompleteAll");
  18164. };
  18165. }
  18166. },
  18167. ],
  18168. });
  18169. //简易上传下载附件组件
  18170. formlyConfigProvider.setType({
  18171. name: "ui-upDownFiles",
  18172. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  18173. wrapper: ["bootstrapHasError"],
  18174. defaultOptions: function (options) {
  18175. return {
  18176. templateOptions: {
  18177. refresh: function (APIService, processInstanceId, data) {
  18178. return APIService.listAttachments(processInstanceId);
  18179. },
  18180. downloadUri: function (APIService, contentId) {
  18181. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18182. },
  18183. view: function (APIService, contentId) {
  18184. return APIService.attachmentsPreviewUrl(contentId);
  18185. },
  18186. download: function (APIService, contentId, item) {
  18187. var item = {
  18188. url: APIService.download(contentId),
  18189. headers: headers,
  18190. };
  18191. return item;
  18192. },
  18193. refreshDelay: 0,
  18194. },
  18195. };
  18196. },
  18197. controller: [
  18198. "$scope",
  18199. "$timeout",
  18200. "$modal",
  18201. "$rootScope",
  18202. "$http",
  18203. "up_down_file",
  18204. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18205. if (angular.isUndefined($scope.form.dropState)) {
  18206. $scope.form.dropState = false;
  18207. }
  18208. //附件上传数据
  18209. var uploader = ($scope.uploader =
  18210. $scope.options.templateOptions.fileUploader);
  18211. //$scope.options.templateOptions.uploader();
  18212. // FILTERS
  18213. uploader.filters.push({
  18214. name: "customFilter",
  18215. fn: function (item /*{File|FileLikeObject}*/, options) {
  18216. return this.queue.length < 10;
  18217. },
  18218. });
  18219. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  18220. // uploader.onBeforeUploadItem = function (item) {
  18221. // angular.extend(item.headers, $rootScope.getSession());
  18222. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  18223. // item.formData.push({
  18224. // 'fileName': item.file.name
  18225. // });
  18226. // console.info('onBeforeUploadItem', item);
  18227. // };
  18228. // }
  18229. // CALLBACKS
  18230. uploader.onWhenAddingFileFailed = function (
  18231. item /*{File|FileLikeObject}*/,
  18232. filter,
  18233. options
  18234. ) {
  18235. console.info("onWhenAddingFileFailed", item, filter, options);
  18236. };
  18237. uploader.onAfterAddingFile = function (fileItem) {
  18238. console.info("onAfterAddingFile", fileItem);
  18239. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18240. alert("文件过大");
  18241. fileItem.uploader.queue.pop();
  18242. console.log($scope);
  18243. }
  18244. };
  18245. uploader.onAfterAddingAll = function (addedFileItems) {
  18246. // console.info('onAfterAddingAll', addedFileItems);
  18247. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18248. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18249. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18250. // console.log(123)
  18251. };
  18252. uploader.onBeforeUploadItem = function (item) {
  18253. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18254. // // $scope.uploader.options.url();
  18255. // $scope.uploader.onBeforeUploadItem = function(item) {
  18256. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18257. // console.info('onBeforeUploadItem', item);
  18258. // };
  18259. // $scope.uploader.uploadAll();
  18260. // }
  18261. console.info("onBeforeUploadItem", item);
  18262. };
  18263. uploader.onProgressItem = function (fileItem, progress) {
  18264. console.info("onProgressItem", fileItem, progress);
  18265. };
  18266. uploader.onProgressAll = function (progress) {
  18267. console.info("onProgressAll", progress);
  18268. };
  18269. uploader.onSuccessItem = function (
  18270. fileItem,
  18271. response,
  18272. status,
  18273. headers
  18274. ) {
  18275. console.info("onSuccessItem", fileItem, response, status, headers);
  18276. };
  18277. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18278. console.info("onErrorItem", fileItem, response, status, headers);
  18279. };
  18280. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18281. console.info("onCancelItem", fileItem, response, status, headers);
  18282. };
  18283. uploader.onCompleteItem = function (
  18284. fileItem,
  18285. response,
  18286. status,
  18287. headers
  18288. ) {
  18289. console.info("onCompleteItem", fileItem, response, status, headers);
  18290. };
  18291. uploader.onCompleteAll = function () {
  18292. console.info("onCompleteAll");
  18293. };
  18294. var _refreshDelayPromise;
  18295. // 下载
  18296. $scope.download = function (contentId, filename, token) {
  18297. // console.log(contentId, filename, token)
  18298. //附件下载
  18299. var downUrl = up_down_file
  18300. .downloadAttachment("common/common/downloadAttachment", token)
  18301. .getRequestedUrl();
  18302. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18303. // console.log(downUrl)
  18304. var a = document.createElement("a");
  18305. a.href = downUrl;
  18306. a.target = "_blank";
  18307. a.download = filename;
  18308. document.body.appendChild(a);
  18309. a.click();
  18310. };
  18311. $scope._refresh = function (refreshAttr) {
  18312. $scope.attachments = [];
  18313. if (refreshAttr !== undefined) {
  18314. if (_refreshDelayPromise) {
  18315. $timeout.cancel(_refreshDelayPromise);
  18316. }
  18317. _refreshDelayPromise = $timeout(function () {
  18318. // 暂存附件
  18319. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18320. $scope.options.templateOptions
  18321. .refresh(
  18322. $scope.options.templateOptions.ApiService,
  18323. $scope.options.templateOptions.processInstanceId,
  18324. {
  18325. idx: 0,
  18326. sum: 1000,
  18327. }
  18328. )
  18329. .then(function (response) {
  18330. var myData =
  18331. $scope.options.templateOptions.Restangular.stripRestangular(
  18332. response
  18333. );
  18334. if (myData) {
  18335. for (var i = 0; i < myData.data.length; i++) {
  18336. $scope.attachments.push(myData.data[i]);
  18337. }
  18338. }
  18339. $scope.options.templateOptions
  18340. .refresh(
  18341. $scope.options.templateOptions.ApiService,
  18342. $scope.$parent.$parent.$parent.model.save_fileId,
  18343. {
  18344. idx: 0,
  18345. sum: 1000,
  18346. }
  18347. )
  18348. .then(function (response2) {
  18349. var myData2 =
  18350. $scope.options.templateOptions.Restangular.stripRestangular(
  18351. response2
  18352. );
  18353. if (myData2) {
  18354. for (var i = 0; i < myData2.data.length; i++) {
  18355. $scope.attachments.push(myData2.data[i]);
  18356. }
  18357. // 只展示除图片以外的附件
  18358. var a = [];
  18359. $scope.attachments.forEach((e) => {
  18360. if (
  18361. e.suffix == "jpeg" ||
  18362. e.suffix == "jpg" ||
  18363. e.suffix == "svg" ||
  18364. e.suffix == "png" ||
  18365. e.suffix == "bmp" ||
  18366. e.suffix == "gif" ||
  18367. e.suffix == "tif"
  18368. ) {
  18369. // $scope.imgs.push(e)
  18370. } else {
  18371. a.push(e);
  18372. }
  18373. });
  18374. $scope.attachments = a;
  18375. }
  18376. console.log($scope.attachments);
  18377. });
  18378. });
  18379. // 正常附件
  18380. } else {
  18381. $scope.options.templateOptions
  18382. .refresh(
  18383. $scope.options.templateOptions.ApiService,
  18384. $scope.options.templateOptions.processInstanceId,
  18385. {
  18386. idx: 0,
  18387. sum: 1000,
  18388. }
  18389. )
  18390. .then(function (response) {
  18391. var myData =
  18392. $scope.options.templateOptions.Restangular.stripRestangular(
  18393. response
  18394. );
  18395. if (myData) {
  18396. $scope.attachments = myData.data;
  18397. // 只展示除图片以外的附件
  18398. var a = [];
  18399. $scope.attachments.forEach((e) => {
  18400. if (
  18401. e.suffix == "jpeg" ||
  18402. e.suffix == "jpg" ||
  18403. e.suffix == "svg" ||
  18404. e.suffix == "png" ||
  18405. e.suffix == "bmp" ||
  18406. e.suffix == "gif" ||
  18407. e.suffix == "tif"
  18408. ) {
  18409. // $scope.imgs.push(e)
  18410. } else {
  18411. a.push(e);
  18412. }
  18413. });
  18414. $scope.attachments = a;
  18415. }
  18416. });
  18417. }
  18418. }, $scope.options.templateOptions.refreshDelay);
  18419. }
  18420. };
  18421. $scope._refresh({});
  18422. },
  18423. ],
  18424. });
  18425. //简易上传附件组件
  18426. formlyConfigProvider.setType({
  18427. name: "ui-uploadFiles",
  18428. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  18429. wrapper: ["bootstrapHasError"],
  18430. controller: [
  18431. "$scope",
  18432. function ($scope) {
  18433. if (angular.isUndefined($scope.form.dropState)) {
  18434. $scope.form.dropState = false;
  18435. }
  18436. //附件上传数据
  18437. var uploader = ($scope.uploader =
  18438. $scope.options.templateOptions.fileUploader);
  18439. //$scope.options.templateOptions.uploader();
  18440. // FILTERS
  18441. uploader.filters.push({
  18442. name: "customFilter",
  18443. fn: function (item /*{File|FileLikeObject}*/, options) {
  18444. return this.queue.length < 10;
  18445. },
  18446. });
  18447. $scope.dropfile = function (
  18448. APIService,
  18449. processInstanceId,
  18450. taskId,
  18451. userId
  18452. ) {
  18453. uploader.onBeforeUploadItem = function (item) {
  18454. angular.extend(item.headers, $rootScope.getSession());
  18455. item.url = APIService.saveAttachments(
  18456. processInstanceId,
  18457. taskId,
  18458. userId
  18459. ).getRequestedUrl();
  18460. item.formData.push({
  18461. fileName: item.file.name,
  18462. });
  18463. console.info("onBeforeUploadItem", item);
  18464. };
  18465. };
  18466. // CALLBACKS
  18467. uploader.onWhenAddingFileFailed = function (
  18468. item /*{File|FileLikeObject}*/,
  18469. filter,
  18470. options
  18471. ) {
  18472. console.info("onWhenAddingFileFailed", item, filter, options);
  18473. };
  18474. uploader.onAfterAddingFile = function (fileItem) {
  18475. console.info("onAfterAddingFile", fileItem);
  18476. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18477. alert("文件过大");
  18478. fileItem.uploader.queue.pop();
  18479. console.log($scope);
  18480. }
  18481. };
  18482. uploader.onAfterAddingAll = function (addedFileItems) {
  18483. // console.info('onAfterAddingAll', addedFileItems);
  18484. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18485. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18486. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18487. // console.log(123)
  18488. };
  18489. uploader.onBeforeUploadItem = function (item) {
  18490. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18491. // // $scope.uploader.options.url();
  18492. // $scope.uploader.onBeforeUploadItem = function(item) {
  18493. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18494. // console.info('onBeforeUploadItem', item);
  18495. // };
  18496. // $scope.uploader.uploadAll();
  18497. // }
  18498. console.info("onBeforeUploadItem", item);
  18499. };
  18500. uploader.onProgressItem = function (fileItem, progress) {
  18501. console.info("onProgressItem", fileItem, progress);
  18502. };
  18503. uploader.onProgressAll = function (progress) {
  18504. console.info("onProgressAll", progress);
  18505. };
  18506. uploader.onSuccessItem = function (
  18507. fileItem,
  18508. response,
  18509. status,
  18510. headers
  18511. ) {
  18512. console.info("onSuccessItem", fileItem, response, status, headers);
  18513. };
  18514. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18515. console.info("onErrorItem", fileItem, response, status, headers);
  18516. };
  18517. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18518. console.info("onCancelItem", fileItem, response, status, headers);
  18519. };
  18520. uploader.onCompleteItem = function (
  18521. fileItem,
  18522. response,
  18523. status,
  18524. headers
  18525. ) {
  18526. console.info("onCompleteItem", fileItem, response, status, headers);
  18527. };
  18528. uploader.onCompleteAll = function () {
  18529. console.info("onCompleteAll");
  18530. };
  18531. },
  18532. ],
  18533. });
  18534. //无上传按钮附件上传组件
  18535. formlyConfigProvider.setType({
  18536. name: "ui-dropfilenotup",
  18537. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18538. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18539. controller: [
  18540. "$scope",
  18541. function ($scope) {
  18542. if (angular.isUndefined($scope.form.dropState)) {
  18543. $scope.form.dropState = false;
  18544. }
  18545. //附件上传数据
  18546. var uploader = ($scope.uploader =
  18547. $scope.options.templateOptions.fileUploader);
  18548. //$scope.options.templateOptions.uploader();
  18549. // FILTERS
  18550. uploader.filters.push({
  18551. name: "customFilter",
  18552. fn: function (item /*{File|FileLikeObject}*/, options) {
  18553. return this.queue.length < 10;
  18554. },
  18555. });
  18556. $scope.dropfile = function (
  18557. APIService,
  18558. processInstanceId,
  18559. taskId,
  18560. userId
  18561. ) {
  18562. uploader.onBeforeUploadItem = function (item) {
  18563. angular.extend(item.headers, $rootScope.getSession());
  18564. item.url = APIService.saveAttachments(
  18565. processInstanceId,
  18566. taskId,
  18567. userId
  18568. ).getRequestedUrl();
  18569. item.formData.push({
  18570. fileName: item.file.name,
  18571. });
  18572. console.info("onBeforeUploadItem", item);
  18573. };
  18574. uploader.uploadAll();
  18575. };
  18576. // CALLBACKS
  18577. uploader.onWhenAddingFileFailed = function (
  18578. item /*{File|FileLikeObject}*/,
  18579. filter,
  18580. options
  18581. ) {
  18582. console.info("onWhenAddingFileFailed", item, filter, options);
  18583. };
  18584. uploader.onAfterAddingFile = function (fileItem) {
  18585. console.info("onAfterAddingFile", fileItem);
  18586. };
  18587. uploader.onAfterAddingAll = function (addedFileItems) {
  18588. console.info("onAfterAddingAll", addedFileItems);
  18589. };
  18590. uploader.onBeforeUploadItem = function (item) {
  18591. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18592. // // $scope.uploader.options.url();
  18593. // $scope.uploader.onBeforeUploadItem = function(item) {
  18594. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18595. // console.info('onBeforeUploadItem', item);
  18596. // };
  18597. // $scope.uploader.uploadAll();
  18598. // }
  18599. console.info("onBeforeUploadItem", item);
  18600. };
  18601. uploader.onProgressItem = function (fileItem, progress) {
  18602. console.info("onProgressItem", fileItem, progress);
  18603. };
  18604. uploader.onProgressAll = function (progress) {
  18605. console.info("onProgressAll", progress);
  18606. };
  18607. uploader.onSuccessItem = function (
  18608. fileItem,
  18609. response,
  18610. status,
  18611. headers
  18612. ) {
  18613. console.info("onSuccessItem", fileItem, response, status, headers);
  18614. };
  18615. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18616. console.info("onErrorItem", fileItem, response, status, headers);
  18617. };
  18618. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18619. console.info("onCancelItem", fileItem, response, status, headers);
  18620. };
  18621. uploader.onCompleteItem = function (
  18622. fileItem,
  18623. response,
  18624. status,
  18625. headers
  18626. ) {
  18627. console.info("onCompleteItem", fileItem, response, status, headers);
  18628. };
  18629. uploader.onCompleteAll = function () {
  18630. console.info("onCompleteAll");
  18631. };
  18632. },
  18633. ],
  18634. });
  18635. //无按钮知识库上传
  18636. formlyConfigProvider.setType({
  18637. name: "ui-dropfielkn",
  18638. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18639. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18640. controller: [
  18641. "$scope",
  18642. function ($scope) {
  18643. if (angular.isUndefined($scope.form.dropState)) {
  18644. $scope.form.dropState = false;
  18645. }
  18646. //附件上传数据
  18647. var uploader = ($scope.uploader =
  18648. $scope.options.templateOptions.fileUploader);
  18649. //$scope.options.templateOptions.uploader();
  18650. // FILTERS
  18651. uploader.filters.push({
  18652. name: "customFilter",
  18653. fn: function (item /*{File|FileLikeObject}*/, options) {
  18654. return this.queue.length < 10;
  18655. },
  18656. });
  18657. $scope.dropfile = function (
  18658. APIService,
  18659. processInstanceId,
  18660. taskId,
  18661. userId
  18662. ) {
  18663. uploader.onBeforeUploadItem = function (item) {
  18664. angular.extend(item.headers, $rootScope.getSession());
  18665. item.url = APIService.addFile(
  18666. processInstanceId,
  18667. taskId,
  18668. userId
  18669. ).getRequestedUrl();
  18670. item.formData.push({
  18671. fileName: item.file.name,
  18672. });
  18673. console.info("onBeforeUploadItem", item);
  18674. };
  18675. uploader.uploadAll();
  18676. };
  18677. // CALLBACKS
  18678. uploader.onWhenAddingFileFailed = function (
  18679. item /*{File|FileLikeObject}*/,
  18680. filter,
  18681. options
  18682. ) {
  18683. console.info("onWhenAddingFileFailed", item, filter, options);
  18684. };
  18685. uploader.onAfterAddingFile = function (fileItem) {
  18686. console.info("onAfterAddingFile", fileItem);
  18687. };
  18688. uploader.onAfterAddingAll = function (addedFileItems) {
  18689. console.info("onAfterAddingAll", addedFileItems);
  18690. };
  18691. uploader.onBeforeUploadItem = function (item) {
  18692. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18693. // // $scope.uploader.options.url();
  18694. // $scope.uploader.onBeforeUploadItem = function(item) {
  18695. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18696. // console.info('onBeforeUploadItem', item);
  18697. // };
  18698. // $scope.uploader.uploadAll();
  18699. // }
  18700. console.info("onBeforeUploadItem", item);
  18701. };
  18702. uploader.onProgressItem = function (fileItem, progress) {
  18703. console.info("onProgressItem", fileItem, progress);
  18704. };
  18705. uploader.onProgressAll = function (progress) {
  18706. console.info("onProgressAll", progress);
  18707. };
  18708. uploader.onSuccessItem = function (
  18709. fileItem,
  18710. response,
  18711. status,
  18712. headers
  18713. ) {
  18714. console.info("onSuccessItem", fileItem, response, status, headers);
  18715. };
  18716. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18717. console.info("onErrorItem", fileItem, response, status, headers);
  18718. };
  18719. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18720. console.info("onCancelItem", fileItem, response, status, headers);
  18721. };
  18722. uploader.onCompleteItem = function (
  18723. fileItem,
  18724. response,
  18725. status,
  18726. headers
  18727. ) {
  18728. console.info("onCompleteItem", fileItem, response, status, headers);
  18729. };
  18730. uploader.onCompleteAll = function () {
  18731. console.info("onCompleteAll");
  18732. };
  18733. },
  18734. ],
  18735. });
  18736. //附件上传列表组件
  18737. formlyConfigProvider.setType({
  18738. name: "ui-dropfile",
  18739. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18740. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18741. controller: [
  18742. "$scope",
  18743. "$rootScope",
  18744. function ($scope, $rootScope) {
  18745. if (angular.isUndefined($scope.form.dropState)) {
  18746. $scope.form.dropState = false;
  18747. }
  18748. //附件上传数据
  18749. var uploader = ($scope.uploader =
  18750. $scope.options.templateOptions.fileUploader);
  18751. //$scope.options.templateOptions.uploader();
  18752. // FILTERS
  18753. uploader.filters.push({
  18754. name: "customFilter",
  18755. fn: function (item /*{File|FileLikeObject}*/, options) {
  18756. return this.queue.length < 10;
  18757. },
  18758. });
  18759. $scope.dropfile = function (
  18760. APIService,
  18761. processInstanceId,
  18762. taskId,
  18763. userId
  18764. ) {
  18765. uploader.onBeforeUploadItem = function (item) {
  18766. angular.extend(item.headers, $rootScope.getSession());
  18767. if (
  18768. $scope.options.templateOptions.upservice &&
  18769. $scope.options.templateOptions.formname
  18770. ) {
  18771. // if ($scope.options.templateOptions.formket) {
  18772. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  18773. // } else {
  18774. item.url = APIService[$scope.options.templateOptions.upservice](
  18775. $scope.model[$scope.options.templateOptions.formname].id,
  18776. taskId,
  18777. userId
  18778. ).getRequestedUrl();
  18779. // }
  18780. } else {
  18781. item.url = APIService.saveAttachments(
  18782. processInstanceId,
  18783. taskId,
  18784. userId
  18785. ).getRequestedUrl();
  18786. }
  18787. item.formData.push({
  18788. filename: item.file.name,
  18789. });
  18790. console.info("onBeforeUploadItem", item);
  18791. };
  18792. uploader.uploadAll();
  18793. };
  18794. // CALLBACKS
  18795. uploader.onWhenAddingFileFailed = function (
  18796. item /*{File|FileLikeObject}*/,
  18797. filter,
  18798. options
  18799. ) {
  18800. console.info("onWhenAddingFileFailed", item, filter, options);
  18801. };
  18802. uploader.onAfterAddingFile = function (fileItem) {
  18803. console.info("onAfterAddingFile", fileItem);
  18804. };
  18805. uploader.onAfterAddingAll = function (addedFileItems) {
  18806. console.info("onAfterAddingAll", addedFileItems);
  18807. };
  18808. uploader.onBeforeUploadItem = function (item) {
  18809. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18810. // // $scope.uploader.options.url();
  18811. // $scope.uploader.onBeforeUploadItem = function(item) {
  18812. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18813. // console.info('onBeforeUploadItem', item);
  18814. // };
  18815. // $scope.uploader.uploadAll();
  18816. // }
  18817. console.info("onBeforeUploadItem", item);
  18818. };
  18819. uploader.onProgressItem = function (fileItem, progress) {
  18820. console.info("onProgressItem", fileItem, progress);
  18821. };
  18822. uploader.onProgressAll = function (progress) {
  18823. console.info("onProgressAll", progress);
  18824. };
  18825. uploader.onSuccessItem = function (
  18826. fileItem,
  18827. response,
  18828. status,
  18829. headers
  18830. ) {
  18831. console.info("onSuccessItem", fileItem, response, status, headers);
  18832. };
  18833. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18834. console.info("onErrorItem", fileItem, response, status, headers);
  18835. };
  18836. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18837. console.info("onCancelItem", fileItem, response, status, headers);
  18838. };
  18839. uploader.onCompleteItem = function (
  18840. fileItem,
  18841. response,
  18842. status,
  18843. headers
  18844. ) {
  18845. console.info("onCompleteItem", fileItem, response, status, headers);
  18846. };
  18847. uploader.onCompleteAll = function () {
  18848. console.info("onCompleteAll");
  18849. };
  18850. },
  18851. ],
  18852. });
  18853. //简易附件展示下载列表组件
  18854. formlyConfigProvider.setType({
  18855. name: "ui-dropFiles",
  18856. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  18857. defaultOptions: function (options) {
  18858. return {
  18859. templateOptions: {
  18860. refresh: function (APIService, processInstanceId, data) {
  18861. return APIService.listAttachments(processInstanceId);
  18862. },
  18863. downloadUri: function (APIService, contentId) {
  18864. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18865. },
  18866. view: function (APIService, contentId) {
  18867. return APIService.attachmentsPreviewUrl(contentId);
  18868. },
  18869. download: function (APIService, contentId, item) {
  18870. var item = {
  18871. url: APIService.download(contentId),
  18872. headers: headers,
  18873. };
  18874. return item;
  18875. },
  18876. refreshDelay: 0,
  18877. },
  18878. };
  18879. },
  18880. controller: [
  18881. "$scope",
  18882. "$timeout",
  18883. "$modal",
  18884. "$rootScope",
  18885. "$http",
  18886. "up_down_file",
  18887. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18888. var _refreshDelayPromise;
  18889. // $scope.downloadUrl = function(contentId){
  18890. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18891. // };
  18892. $scope.download = function (contentId, filename, token) {
  18893. // console.log(contentId, filename, token)
  18894. //附件下载
  18895. var downUrl = up_down_file
  18896. .downloadAttachment("common/common/downloadAttachment", token)
  18897. .getRequestedUrl();
  18898. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18899. // console.log(downUrl)
  18900. var a = document.createElement("a");
  18901. a.href = downUrl;
  18902. a.target = "_blank";
  18903. a.download = filename;
  18904. document.body.appendChild(a);
  18905. a.click();
  18906. };
  18907. $scope.view = function (contentId, token, filename, type) {
  18908. $scope.options.templateOptions
  18909. .view($scope.options.templateOptions.ApiService, contentId)
  18910. .then(function (response) {
  18911. if (response.state == 200) {
  18912. window.open(response.previewUrl);
  18913. }
  18914. });
  18915. };
  18916. /**
  18917. * refresh
  18918. */
  18919. $scope._refresh = function (refreshAttr) {
  18920. $scope.attachments = [];
  18921. if (refreshAttr !== undefined) {
  18922. if (_refreshDelayPromise) {
  18923. $timeout.cancel(_refreshDelayPromise);
  18924. }
  18925. _refreshDelayPromise = $timeout(function () {
  18926. // 暂存附件
  18927. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18928. $scope.options.templateOptions
  18929. .refresh(
  18930. $scope.options.templateOptions.ApiService,
  18931. $scope.options.templateOptions.processInstanceId,
  18932. {
  18933. idx: 0,
  18934. sum: 1000,
  18935. }
  18936. )
  18937. .then(function (response) {
  18938. var myData =
  18939. $scope.options.templateOptions.Restangular.stripRestangular(
  18940. response
  18941. );
  18942. if (myData) {
  18943. for (var i = 0; i < myData.data.length; i++) {
  18944. $scope.attachments.push(myData.data[i]);
  18945. }
  18946. }
  18947. $scope.options.templateOptions
  18948. .refresh(
  18949. $scope.options.templateOptions.ApiService,
  18950. $scope.$parent.$parent.$parent.model.save_fileId,
  18951. {
  18952. idx: 0,
  18953. sum: 1000,
  18954. }
  18955. )
  18956. .then(function (response2) {
  18957. var myData2 =
  18958. $scope.options.templateOptions.Restangular.stripRestangular(
  18959. response2
  18960. );
  18961. if (myData2) {
  18962. for (var i = 0; i < myData2.data.length; i++) {
  18963. $scope.attachments.push(myData2.data[i]);
  18964. }
  18965. // 只展示除图片以外的附件
  18966. var a = [];
  18967. $scope.attachments.forEach((e) => {
  18968. if (
  18969. e.suffix == "jpeg" ||
  18970. e.suffix == "jpg" ||
  18971. e.suffix == "svg" ||
  18972. e.suffix == "png" ||
  18973. e.suffix == "bmp" ||
  18974. e.suffix == "gif" ||
  18975. e.suffix == "tif"
  18976. ) {
  18977. // $scope.imgs.push(e)
  18978. } else {
  18979. a.push(e);
  18980. }
  18981. });
  18982. $scope.attachments = a;
  18983. }
  18984. console.log($scope.attachments);
  18985. });
  18986. });
  18987. // 正常附件
  18988. } else {
  18989. $scope.options.templateOptions
  18990. .refresh(
  18991. $scope.options.templateOptions.ApiService,
  18992. $scope.options.templateOptions.processInstanceId,
  18993. {
  18994. idx: 0,
  18995. sum: 1000,
  18996. }
  18997. )
  18998. .then(function (response) {
  18999. var myData =
  19000. $scope.options.templateOptions.Restangular.stripRestangular(
  19001. response
  19002. );
  19003. if (myData) {
  19004. $scope.attachments = myData.data;
  19005. // 只展示除图片以外的附件
  19006. var a = [];
  19007. $scope.attachments.forEach((e) => {
  19008. if (
  19009. e.suffix == "jpeg" ||
  19010. e.suffix == "jpg" ||
  19011. e.suffix == "svg" ||
  19012. e.suffix == "png" ||
  19013. e.suffix == "bmp" ||
  19014. e.suffix == "gif" ||
  19015. e.suffix == "tif"
  19016. ) {
  19017. // $scope.imgs.push(e)
  19018. } else {
  19019. a.push(e);
  19020. }
  19021. });
  19022. $scope.attachments = a;
  19023. console.log($scope.attachments);
  19024. }
  19025. });
  19026. }
  19027. }, $scope.options.templateOptions.refreshDelay);
  19028. }
  19029. };
  19030. $scope._refresh({});
  19031. // $scope.attachments = $scope.model[$scope.options.key]
  19032. },
  19033. ],
  19034. });
  19035. //知识库附件上传
  19036. formlyConfigProvider.setType({
  19037. name: "ui-dropfielknow",
  19038. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  19039. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  19040. controller: [
  19041. "$scope",
  19042. "$rootScope",
  19043. function ($scope, $rootScope) {
  19044. if (angular.isUndefined($scope.form.dropState)) {
  19045. $scope.form.dropState = false;
  19046. }
  19047. //附件上传数据
  19048. var uploader = ($scope.uploader =
  19049. $scope.options.templateOptions.fileUploader);
  19050. //$scope.options.templateOptions.uploader();
  19051. // FILTERS
  19052. uploader.filters.push({
  19053. name: "customFilter",
  19054. fn: function (item /*{File|FileLikeObject}*/, options) {
  19055. return this.queue.length < 10;
  19056. },
  19057. });
  19058. $scope.dropfile = function (
  19059. APIService,
  19060. processInstanceId,
  19061. taskId,
  19062. userId
  19063. ) {
  19064. uploader.onBeforeUploadItem = function (item) {
  19065. angular.extend(item.headers, $rootScope.getSession());
  19066. item.url = APIService.upload(
  19067. processInstanceId,
  19068. taskId,
  19069. userId
  19070. ).getRequestedUrl();
  19071. item.formData.push({
  19072. fileName: item.file.name,
  19073. type: "solution",
  19074. solutionId: $scope.model.knowledge.id,
  19075. });
  19076. console.info("onBeforeUploadItem", item);
  19077. };
  19078. uploader.uploadAll();
  19079. };
  19080. // CALLBACKS
  19081. uploader.onWhenAddingFileFailed = function (
  19082. item /*{File|FileLikeObject}*/,
  19083. filter,
  19084. options
  19085. ) {
  19086. console.info("onWhenAddingFileFailed", item, filter, options);
  19087. };
  19088. uploader.onAfterAddingFile = function (fileItem) {
  19089. console.info("onAfterAddingFile", fileItem);
  19090. };
  19091. uploader.onAfterAddingAll = function (addedFileItems) {
  19092. console.info("onAfterAddingAll", addedFileItems);
  19093. };
  19094. uploader.onBeforeUploadItem = function (item) {
  19095. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  19096. // // $scope.uploader.options.url();
  19097. // $scope.uploader.onBeforeUploadItem = function(item) {
  19098. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  19099. // console.info('onBeforeUploadItem', item);
  19100. // };
  19101. // $scope.uploader.uploadAll();
  19102. // }
  19103. console.info("onBeforeUploadItem", item);
  19104. };
  19105. uploader.onProgressItem = function (fileItem, progress) {
  19106. console.info("onProgressItem", fileItem, progress);
  19107. };
  19108. uploader.onProgressAll = function (progress) {
  19109. console.info("onProgressAll", progress);
  19110. };
  19111. uploader.onSuccessItem = function (
  19112. fileItem,
  19113. response,
  19114. status,
  19115. headers
  19116. ) {
  19117. console.info("onSuccessItem", fileItem, response, status, headers);
  19118. };
  19119. uploader.onErrorItem = function (fileItem, response, status, headers) {
  19120. console.info("onErrorItem", fileItem, response, status, headers);
  19121. };
  19122. uploader.onCancelItem = function (fileItem, response, status, headers) {
  19123. console.info("onCancelItem", fileItem, response, status, headers);
  19124. };
  19125. uploader.onCompleteItem = function (
  19126. fileItem,
  19127. response,
  19128. status,
  19129. headers
  19130. ) {
  19131. console.info("onCompleteItem", fileItem, response, status, headers);
  19132. };
  19133. uploader.onCompleteAll = function () {
  19134. console.info("onCompleteAll");
  19135. };
  19136. },
  19137. ],
  19138. });
  19139. //知识库附件下载列表
  19140. formlyConfigProvider.setType({
  19141. name: "ui-dropfileknowledge",
  19142. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  19143. defaultOptions: function (options) {
  19144. return {
  19145. templateOptions: {
  19146. refresh: function (APIService, contentId, data) {
  19147. return APIService.fetchDataList(contentId, data);
  19148. },
  19149. downloadUri: function (APIService, contentId) {
  19150. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19151. },
  19152. download: function (APIService, contentId) {
  19153. return APIService.getSolutionDowpath(contentId);
  19154. },
  19155. view: function (attachmentId) {
  19156. // return APIService.attachmentsPreviewUrl(contentId);
  19157. },
  19158. refreshDelay: 0,
  19159. },
  19160. };
  19161. },
  19162. controller: [
  19163. "$scope",
  19164. "$timeout",
  19165. "$modal",
  19166. "$rootScope",
  19167. "api_solution",
  19168. "$http",
  19169. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  19170. var _refreshDelayPromise;
  19171. $scope.attachments = [];
  19172. $scope.downloadUrl = function (contentId) {
  19173. return (
  19174. $scope.options.templateOptions.downloadUri(
  19175. $scope.options.templateOptions.ApiService,
  19176. contentId
  19177. ) || "#"
  19178. );
  19179. };
  19180. $scope.download = function (contentId, filename) {
  19181. $http({
  19182. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  19183. contentId
  19184. ).getRequestedUrl(),
  19185. method: "GET",
  19186. headers: {
  19187. //'Content-type' : 'application/xls',
  19188. Accept: "*/*",
  19189. },
  19190. responseType: "arraybuffer",
  19191. })
  19192. .success(function (data, status, headers, config) {
  19193. var file = new Blob([data], {
  19194. type: "application/octet-stream",
  19195. });
  19196. //trick to download store a file having its URL
  19197. var fileURL = URL.createObjectURL(file);
  19198. var a = document.createElement("a");
  19199. a.href = fileURL;
  19200. a.target = "_blank";
  19201. a.download = filename;
  19202. document.body.appendChild(a);
  19203. a.click();
  19204. })
  19205. .error(function (data, status, headers, config) {
  19206. // console.log(data);
  19207. });
  19208. };
  19209. $scope.view = function (contentId, filename, attachment) {
  19210. var index = filename.indexOf(".");
  19211. var type = filename.substring(index + 1);
  19212. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19213. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  19214. // var modalInstance = $modal.open({
  19215. // backdrop: false,
  19216. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19217. // controller: function($scope, scope, $modalInstance, filename) {
  19218. // $scope.title = filename;
  19219. // $scope.imageurl = scope.imageurl;
  19220. // $scope.cancel = function() {
  19221. // $modalInstance.dismiss('cancel');
  19222. // }
  19223. // },
  19224. // resolve: {
  19225. // scope: function() {
  19226. // return $scope;
  19227. // },
  19228. // filename: function() {
  19229. // return filename;
  19230. // }
  19231. // }
  19232. // });
  19233. // event.preventDefault();
  19234. // } else {
  19235. // for (var i = 0; i < $scope.attachments.length; i++) {
  19236. // if ($scope.attachments[i].id == attachmentId) {
  19237. window.open(attachment.previewUrl);
  19238. // }
  19239. // }
  19240. // }
  19241. };
  19242. $scope._refresh = function (refreshAttr) {
  19243. if (refreshAttr !== undefined) {
  19244. if (_refreshDelayPromise) {
  19245. $timeout.cancel(_refreshDelayPromise);
  19246. }
  19247. _refreshDelayPromise = $timeout(function () {
  19248. $scope.options.templateOptions
  19249. .refresh($scope.options.templateOptions.ApiService, "file", {
  19250. file: {
  19251. solutionId: $scope.model.knowledge.id,
  19252. },
  19253. idx: "0",
  19254. sum: "1000",
  19255. })
  19256. .then(function (response) {
  19257. var myData =
  19258. $scope.options.templateOptions.Restangular.stripRestangular(
  19259. response
  19260. );
  19261. if (myData) {
  19262. $scope.attachments = myData.list;
  19263. // $scope.view = function(attachmentId) {
  19264. // for (var i = 0; i < $scope.attachments.length; i++) {
  19265. // if ($scope.attachments[i].id == attachmentId) {
  19266. // window.open($scope.attachments[i].previewUrl);
  19267. // // var modalInstance = $modal.open({
  19268. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  19269. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  19270. // // }
  19271. // // });
  19272. // }
  19273. // }
  19274. // };
  19275. }
  19276. });
  19277. }, $scope.options.templateOptions.refreshDelay);
  19278. }
  19279. };
  19280. $scope._refresh({});
  19281. // $scope.attachments = $scope.model[$scope.options.key]
  19282. },
  19283. ],
  19284. });
  19285. //附件图片下载
  19286. formlyConfigProvider.setType({
  19287. name: "ui-downimage",
  19288. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  19289. defaultOptions: function (options) {
  19290. return {
  19291. templateOptions: {
  19292. refresh: function (APIService, processInstanceId, data) {
  19293. return APIService.listAttachments(processInstanceId, data);
  19294. },
  19295. downloadUri: function (APIService, contentId) {
  19296. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19297. },
  19298. view: function (APIService, contentId) {
  19299. return APIService.attachmentsPreviewUrl(contentId);
  19300. },
  19301. download: function (APIService, contentId, item) {
  19302. var item = {
  19303. url: APIService.download(contentId),
  19304. headers: headers,
  19305. };
  19306. return item;
  19307. },
  19308. refreshDelay: 0,
  19309. },
  19310. };
  19311. },
  19312. controller: [
  19313. "$scope",
  19314. "$timeout",
  19315. "$rootScope",
  19316. "$http",
  19317. function ($scope, $timeout, $rootScope, $http) {
  19318. var _refreshDelayPromise;
  19319. // $scope.downloadUrl = function(contentId){
  19320. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19321. // };
  19322. $scope.download = function (contentId, filename) {
  19323. // var headers=
  19324. $http({
  19325. url: $scope.options.templateOptions.ApiService.download(
  19326. contentId
  19327. ).getRequestedUrl(),
  19328. method: "GET",
  19329. headers: {
  19330. //'Content-type' : 'application/xls',
  19331. Accept: "*/*",
  19332. },
  19333. responseType: "arraybuffer",
  19334. })
  19335. .success(function (data, status, headers, config) {
  19336. var file = new Blob([data], {
  19337. type: "application/octet-stream",
  19338. });
  19339. //trick to download store a file having its URL
  19340. var fileURL = URL.createObjectURL(file);
  19341. var a = document.createElement("a");
  19342. a.href = fileURL;
  19343. a.target = "_blank";
  19344. a.download = filename;
  19345. document.body.appendChild(a);
  19346. a.click();
  19347. })
  19348. .error(function (data, status, headers, config) {
  19349. // console.log(data);
  19350. });
  19351. };
  19352. $scope.view = function (contentId) {
  19353. $scope.imageurl =
  19354. $scope.options.templateOptions.ApiService.download(
  19355. contentId
  19356. ).getRequestedUrl();
  19357. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  19358. // if (response.state == 200) {
  19359. // window.open(response.previewUrl);
  19360. // }
  19361. // })
  19362. };
  19363. /**
  19364. * refresh
  19365. */
  19366. $scope._refresh = function (refreshAttr) {
  19367. if (refreshAttr !== undefined) {
  19368. if (_refreshDelayPromise) {
  19369. $timeout.cancel(_refreshDelayPromise);
  19370. }
  19371. _refreshDelayPromise = $timeout(function () {
  19372. $scope.options.templateOptions
  19373. .refresh(
  19374. $scope.options.templateOptions.ApiService,
  19375. $scope.options.templateOptions.processInstanceId,
  19376. {
  19377. idx: 0,
  19378. sum: 1000,
  19379. }
  19380. )
  19381. .then(function (response) {
  19382. var myData =
  19383. $scope.options.templateOptions.Restangular.stripRestangular(
  19384. response
  19385. );
  19386. if (myData) {
  19387. $scope.attachments = myData.data;
  19388. }
  19389. });
  19390. }, $scope.options.templateOptions.refreshDelay);
  19391. }
  19392. };
  19393. $scope._refresh({});
  19394. // $scope.attachments = $scope.model[$scope.options.key]
  19395. },
  19396. ],
  19397. });
  19398. //附件下载列表组件
  19399. formlyConfigProvider.setType({
  19400. name: "ui-dropfiletable",
  19401. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  19402. defaultOptions: function (options) {
  19403. return {
  19404. templateOptions: {
  19405. refresh: function (APIService, processInstanceId, data) {
  19406. return APIService.listAttachments(processInstanceId, data);
  19407. },
  19408. downloadUri: function (APIService, contentId) {
  19409. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19410. },
  19411. view: function (APIService, contentId) {
  19412. return APIService.attachmentsPreviewUrl(contentId);
  19413. },
  19414. download: function (APIService, contentId, item) {
  19415. var item = {
  19416. url: APIService.download(contentId),
  19417. headers: headers,
  19418. };
  19419. return item;
  19420. },
  19421. refreshDelay: 0,
  19422. },
  19423. };
  19424. },
  19425. controller: [
  19426. "$scope",
  19427. "$timeout",
  19428. "$modal",
  19429. "$rootScope",
  19430. "$http",
  19431. function ($scope, $timeout, $modal, $rootScope, $http) {
  19432. var _refreshDelayPromise;
  19433. // $scope.downloadUrl = function(contentId){
  19434. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19435. // };
  19436. $scope.download = function (contentId, filename) {
  19437. // var headers=
  19438. $http({
  19439. url: $scope.options.templateOptions.ApiService.download(
  19440. contentId
  19441. ).getRequestedUrl(),
  19442. method: "GET",
  19443. headers: {
  19444. //'Content-type' : 'application/xls',
  19445. Accept: "*/*",
  19446. },
  19447. responseType: "arraybuffer",
  19448. })
  19449. .success(function (data, status, headers, config) {
  19450. var file = new Blob([data], {
  19451. type: "application/octet-stream",
  19452. });
  19453. //trick to download store a file having its URL
  19454. var fileURL = URL.createObjectURL(file);
  19455. var a = document.createElement("a");
  19456. a.href = fileURL;
  19457. a.target = "_blank";
  19458. a.download = filename;
  19459. document.body.appendChild(a);
  19460. a.click();
  19461. })
  19462. .error(function (data, status, headers, config) {
  19463. // console.log(data);
  19464. });
  19465. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  19466. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  19467. // var file = new Blob([response], {
  19468. // type : 'application/octet-stream'
  19469. // });
  19470. // // var filename = filename;
  19471. // //var file = new Blob([response], {type: 'application/pdf'});
  19472. // var fileURL = URL.createObjectURL(file);
  19473. // var a = document.createElement('a');
  19474. // a.href = fileURL;
  19475. // a.target = '_blank';
  19476. // a.download = filename ;
  19477. // document.body.appendChild(a);
  19478. // a.click();
  19479. // })
  19480. };
  19481. $scope.view = function (contentId, token, filename, type) {
  19482. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19483. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  19484. // var modalInstance = $modal.open({
  19485. // backdrop: false,
  19486. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19487. // controller: function($scope, scope, $modalInstance, filename) {
  19488. // $scope.title = filename;
  19489. // $scope.imageurl = scope.imageurl;
  19490. // $scope.cancel = function() {
  19491. // $modalInstance.dismiss('cancel');
  19492. // }
  19493. // },
  19494. // resolve: {
  19495. // scope: function() {
  19496. // return $scope;
  19497. // },
  19498. // filename: function() {
  19499. // return filename;
  19500. // }
  19501. // }
  19502. // });
  19503. // event.preventDefault();
  19504. // } else {
  19505. $scope.options.templateOptions
  19506. .view($scope.options.templateOptions.ApiService, contentId)
  19507. .then(function (response) {
  19508. if (response.state == 200) {
  19509. window.open(response.previewUrl);
  19510. }
  19511. });
  19512. // }
  19513. };
  19514. /**
  19515. * refresh
  19516. */
  19517. $scope._refresh = function (refreshAttr) {
  19518. if (refreshAttr !== undefined) {
  19519. if (_refreshDelayPromise) {
  19520. $timeout.cancel(_refreshDelayPromise);
  19521. }
  19522. _refreshDelayPromise = $timeout(function () {
  19523. $scope.options.templateOptions
  19524. .refresh(
  19525. $scope.options.templateOptions.ApiService,
  19526. $scope.options.templateOptions.processInstanceId,
  19527. {
  19528. idx: 0,
  19529. sum: 1000,
  19530. }
  19531. )
  19532. .then(function (response) {
  19533. var myData =
  19534. $scope.options.templateOptions.Restangular.stripRestangular(
  19535. response
  19536. );
  19537. if (myData) {
  19538. $scope.attachments = myData.data;
  19539. }
  19540. });
  19541. }, $scope.options.templateOptions.refreshDelay);
  19542. }
  19543. };
  19544. $scope._refresh({});
  19545. // $scope.attachments = $scope.model[$scope.options.key]
  19546. },
  19547. ],
  19548. });
  19549. //微信附件下载列表组件
  19550. formlyConfigProvider.setType({
  19551. name: "ui-dropfilewechat",
  19552. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  19553. defaultOptions: function (options) {
  19554. return {
  19555. templateOptions: {
  19556. // refresh: function(APIService, processInstanceId, data) {
  19557. // return APIService.listAttachments(processInstanceId, data);
  19558. // },
  19559. // downloadUri: function(APIService, contentId) {
  19560. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  19561. // },
  19562. view: function (APIService, contentId) {
  19563. // return APIService.attachmentsPreviewUrl(contentId);
  19564. return APIService.attachmentsPreviewUrl(contentId);
  19565. },
  19566. download: function (APIService, contentId, item) {
  19567. var item = {
  19568. url: APIService.download(contentId),
  19569. headers: headers,
  19570. };
  19571. return item;
  19572. },
  19573. // download: function(APIService, contentId, item) {
  19574. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  19575. // return item;
  19576. // },
  19577. refreshDelay: 0,
  19578. },
  19579. };
  19580. },
  19581. controller: [
  19582. "$scope",
  19583. "$timeout",
  19584. "$modal",
  19585. "$stateParams",
  19586. "$rootScope",
  19587. "$http",
  19588. "api_wechatfile",
  19589. function (
  19590. $scope,
  19591. $timeout,
  19592. $modal,
  19593. $stateParams,
  19594. $rootScope,
  19595. $http,
  19596. api_wechatfile
  19597. ) {
  19598. var _refreshDelayPromise;
  19599. // $scope.downloadUrl = function(contentId){
  19600. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19601. // };
  19602. $scope.attachments = {};
  19603. $scope.previewUrl = "";
  19604. $scope.download = function (token, filename) {
  19605. // var headers=
  19606. console.log($scope);
  19607. $http({
  19608. url: $scope.options.templateOptions.ApiService.jry_download(
  19609. token
  19610. ).getRequestedUrl(),
  19611. method: "GET",
  19612. headers: {
  19613. //'Content-type' : 'application/xls',
  19614. Accept: "*/*",
  19615. },
  19616. responseType: "arraybuffer",
  19617. })
  19618. .success(function (data, status, headers, config) {
  19619. var file = new Blob([data], {
  19620. type: "application/octet-stream",
  19621. });
  19622. //trick to download store a file having its URL
  19623. var fileURL = URL.createObjectURL(file);
  19624. var a = document.createElement("a");
  19625. a.href = fileURL;
  19626. a.target = "_blank";
  19627. a.download = filename;
  19628. document.body.appendChild(a);
  19629. a.click();
  19630. })
  19631. .error(function (data, status, headers, config) {
  19632. // console.log(data);
  19633. });
  19634. };
  19635. $scope.view = function (contentId, token, filename, type, previewUrl) {
  19636. // if (type) {
  19637. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  19638. // var modalInstance = $modal.open({
  19639. // backdrop: false,
  19640. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19641. // controller: function($scope, scope, $modalInstance, filename) {
  19642. // $scope.title = filename;
  19643. // $scope.imageurl = scope.imageurl;
  19644. // $scope.cancel = function() {
  19645. // $modalInstance.dismiss('cancel');
  19646. // }
  19647. // },
  19648. // resolve: {
  19649. // scope: function() {
  19650. // return $scope;
  19651. // },
  19652. // filename: function() {
  19653. // return filename;
  19654. // }
  19655. // }
  19656. // });
  19657. // event.preventDefault();
  19658. // } else {
  19659. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  19660. // if (response.state == 200) {
  19661. // window.open(response.previewUrl);
  19662. // }
  19663. // })
  19664. window.open(previewUrl);
  19665. // }
  19666. };
  19667. /**
  19668. * refresh
  19669. */
  19670. $scope._refresh = function (refreshAttr) {
  19671. if (refreshAttr !== undefined) {
  19672. if (_refreshDelayPromise) {
  19673. $timeout.cancel(_refreshDelayPromise);
  19674. }
  19675. _refreshDelayPromise = $timeout(function () {
  19676. // console.log(JSON.parse($stateParams.model))
  19677. var incidentChart = {};
  19678. if ($stateParams.model) {
  19679. incidentChart = JSON.parse($stateParams.model).model;
  19680. }
  19681. $scope.options.templateOptions
  19682. .refresh(
  19683. $scope.options.templateOptions.ApiService,
  19684. $scope.model
  19685. )
  19686. .then(function (response) {
  19687. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  19688. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  19689. var myData =
  19690. $scope.options.templateOptions.Restangular.stripRestangular(
  19691. response
  19692. );
  19693. if (myData) {
  19694. $scope.attachments = myData.data;
  19695. }
  19696. });
  19697. }, $scope.options.templateOptions.refreshDelay);
  19698. }
  19699. };
  19700. $scope._refresh({});
  19701. // $scope.attachments = $scope.model[$scope.options.key]
  19702. },
  19703. ],
  19704. });
  19705. formlyConfigProvider.setType({
  19706. name: "ui-paralleltask",
  19707. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  19708. defaultOptions: function (options) {
  19709. return {
  19710. templateOptions: {
  19711. refresh: function (APIService, processInstanceId, data) {
  19712. //return APIService.listAttachments(processInstanceId, data);
  19713. },
  19714. refreshDelay: 0,
  19715. },
  19716. };
  19717. },
  19718. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  19719. });
  19720. //repeatSection
  19721. //
  19722. formlyConfigProvider.setType({
  19723. name: "ui-repeatSection",
  19724. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  19725. defaultOptions: function (options) {
  19726. return {
  19727. templateOptions: {
  19728. unique: 1,
  19729. initDisplay: false,
  19730. },
  19731. };
  19732. },
  19733. controller: function ($scope) {
  19734. //$scope.options.templateOptions.unique;
  19735. $scope.formOptions = {
  19736. formState: $scope.formState,
  19737. };
  19738. $scope.addNew = addNew;
  19739. $scope.copyFields = copyFields;
  19740. function copyFields(fields) {
  19741. fields = angular.copy(fields);
  19742. addRandomIds(fields);
  19743. return fields;
  19744. }
  19745. function addNew() {
  19746. $scope.model[$scope.options.key] =
  19747. $scope.model[$scope.options.key] || [];
  19748. var repeatsection = $scope.model[$scope.options.key];
  19749. var lastSection = repeatsection[repeatsection.length - 1];
  19750. var newsection = {};
  19751. repeatsection.push(newsection);
  19752. }
  19753. function addRandomIds(fields) {
  19754. $scope.options.templateOptions.unique++;
  19755. angular.forEach(fields, function (field, index) {
  19756. if (field.fieldGroup) {
  19757. addRandomIds(field.fieldGroup);
  19758. return; // fieldGroups don't need an ID
  19759. }
  19760. if (field.templateOptions && field.templateOptions.fields) {
  19761. addRandomIds(field.templateOptions.fields);
  19762. }
  19763. field.id =
  19764. field.id ||
  19765. field.key +
  19766. "_" +
  19767. index +
  19768. "_" +
  19769. $scope.options.templateOptions.unique +
  19770. getRandomInt(0, 9999);
  19771. });
  19772. }
  19773. function getRandomInt(min, max) {
  19774. return Math.floor(Math.random() * (max - min)) + min;
  19775. }
  19776. if ($scope.options.templateOptions.initDisplay) {
  19777. addNew();
  19778. }
  19779. },
  19780. });
  19781. //时间轴任务列表组件
  19782. //cmdb控件
  19783. formlyConfigProvider.setType({
  19784. name: "ui-cmdb",
  19785. extends: "input",
  19786. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  19787. defaultOptions: function (options) {
  19788. return {
  19789. templateOptions: {
  19790. onClick: function (size, options, modal, event, model) {
  19791. var modalInstance = modal.open({
  19792. templateUrl:
  19793. "assets/views/customform/tpl/cmdb-modal-content.html",
  19794. controller: function (
  19795. $scope,
  19796. $modalInstance,
  19797. title,
  19798. Restangular,
  19799. APIService,
  19800. ConfigDataService,
  19801. ConfigFormService,
  19802. SweetAlert,
  19803. Toaster,
  19804. api_wechatfile
  19805. ) {
  19806. var width = ($scope.width = 600);
  19807. var height = ($scope.height = 400);
  19808. var tree;
  19809. var d3 = window.d3;
  19810. $scope.my_tree_handler = function (branch) {
  19811. //var _ref;
  19812. var classify = ($scope.classify =
  19813. branch.prefix.toLowerCase() + branch.sign);
  19814. APIService.query({
  19815. sign: classify,
  19816. }).then(function (data) {
  19817. var myData = Restangular.stripRestangular(data);
  19818. // console.log(myData.data.node);
  19819. if (myData.data && myData.status == 200) {
  19820. var ret = myData.data;
  19821. redrawSvg(myData);
  19822. }
  19823. });
  19824. };
  19825. $scope.my_data = [];
  19826. function convertListToTree(data, treeMap) {
  19827. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  19828. var root = null; //Initially set our loop to null
  19829. var parentNode = null;
  19830. //loop over data
  19831. for (var i = 0; i < data.length; i++) {
  19832. var datum = data[i];
  19833. //each node will have children, so let's give it a "children" poperty
  19834. datum.children = [];
  19835. //add an entry for this node to the map so that any future children can
  19836. //lookup the parent
  19837. idToNodeMap[datum.id] = datum;
  19838. //Does this node have a parent?
  19839. if (
  19840. typeof datum.parent === "undefined" ||
  19841. datum.parent == null
  19842. ) {
  19843. //Doesn't look like it, so this node is the root of the tree
  19844. root = datum;
  19845. treeMap[datum.id] = root;
  19846. } else {
  19847. //This node has a parent, so let's look it up using the id
  19848. parentNode = idToNodeMap[datum.parent.id];
  19849. //We don't need this property, so let's delete it.
  19850. delete datum.parent;
  19851. //Let's add the current node as a child of the parent node.
  19852. parentNode.children.push(datum);
  19853. }
  19854. }
  19855. return root;
  19856. }
  19857. function convertParentToChildList(data) {
  19858. var treeMap = {};
  19859. var list = [];
  19860. convertListToTree(data, treeMap);
  19861. angular.forEach(treeMap, function (item) {
  19862. list.push(item);
  19863. });
  19864. return list;
  19865. }
  19866. $scope.my_tree = tree = {};
  19867. $scope.try_async_load = function () {
  19868. $scope.my_data = [];
  19869. $scope.select_treedata = [];
  19870. $scope.doing_async = true;
  19871. ConfigDataService.fetchDataList("ciclassify", {
  19872. idx: 0,
  19873. sum: 100,
  19874. }).then(function (result) {
  19875. $scope.select_treedata = $scope.my_data =
  19876. convertParentToChildList(result["list"]);
  19877. $scope.doing_async = false;
  19878. });
  19879. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  19880. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  19881. // $scope.doing_async = false;
  19882. // });
  19883. };
  19884. $scope.select_treedata = [];
  19885. $scope.propTypeOptions = [];
  19886. $scope.try_async_load();
  19887. $scope.onFilterCallback = function (item) {
  19888. //console.log(item);
  19889. if (
  19890. angular.isDefined(item.children) &&
  19891. item.children.length >= 1
  19892. ) {
  19893. //not valid
  19894. } else {
  19895. var tempclassify = item.prefix.toLowerCase() + item.sign;
  19896. $scope.cifilter_classic = tempclassify;
  19897. ConfigFormService.renderTabForm(tempclassify).then(
  19898. function (data) {
  19899. var myData = Restangular.stripRestangular(data);
  19900. $scope.propTypeOptions = myData;
  19901. }
  19902. );
  19903. }
  19904. };
  19905. $scope.onPropTypeChange = function (form) {
  19906. $scope.propOptions = form.fields;
  19907. };
  19908. $scope.onPropChange = function (prop) {
  19909. $scope.cifilter_prop = prop;
  19910. };
  19911. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  19912. //if(searchKey!=null&&searchKey.length>1){
  19913. var searchData = {};
  19914. if (angular.isUndefined(propObj)) {
  19915. propObj = $scope.cifilter_prop;
  19916. }
  19917. if (angular.isUndefined(ciclassify)) {
  19918. ciclassify = $scope.cifilter_classic;
  19919. }
  19920. searchData["sign"] = ciclassify;
  19921. if (angular.isDefined(propObj)) {
  19922. searchData[propObj.key] = searchKey;
  19923. }
  19924. APIService.query(searchData).then(function (response) {
  19925. var data = Restangular.stripRestangular(response);
  19926. //此处不清空nodes
  19927. var node = data.data.node;
  19928. var tempNode = [];
  19929. //nodes 或者links 要去重
  19930. for (var i = 0; i < node.length; i++) {
  19931. var tmp = 0;
  19932. for (var j = 0; j < nodes.length; j++) {
  19933. if (node[i].uuid == nodes[j].uuid) {
  19934. tmp++;
  19935. break;
  19936. }
  19937. }
  19938. if (tmp == 0) {
  19939. tempNode.push(node[i]);
  19940. }
  19941. }
  19942. for (var i = 0; i < tempNode.length; i++) {
  19943. //nodes 不清空
  19944. nodes.push(tempNode[i]);
  19945. }
  19946. restart();
  19947. });
  19948. };
  19949. $scope.refresh = function () {
  19950. nodes.length = 0;
  19951. links.length = 0;
  19952. restart();
  19953. };
  19954. $scope.traversal = function () {
  19955. if ($scope.selected_node == null) {
  19956. SweetAlert.swal({
  19957. title: "错误的操作!",
  19958. text: "没有配置项被选中!",
  19959. type: "error",
  19960. });
  19961. } else {
  19962. var uuid = $scope.selected_node.uuid;
  19963. APIService.traversal(uuid).then(function (response) {
  19964. var d = response.data;
  19965. var node = d.node;
  19966. var link = d.edge;
  19967. var tempNode = [];
  19968. var tempLink = [];
  19969. //nodes 或者links 要去重
  19970. for (var i = 0; i < node.length; i++) {
  19971. var tmp = 0;
  19972. for (var j = 0; j < nodes.length; j++) {
  19973. if (node[i].id == nodes[j].id) {
  19974. tmp++;
  19975. break;
  19976. }
  19977. }
  19978. if (tmp == 0) {
  19979. tempNode.push(node[i]);
  19980. }
  19981. }
  19982. for (var i = 0; i < link.length; i++) {
  19983. var tmp = 0;
  19984. for (var j = 0; j < links.length; j++) {
  19985. if (link[i].id == links[j].id) {
  19986. tmp++;
  19987. break;
  19988. }
  19989. }
  19990. if (tmp == 0) {
  19991. tempLink.push(link[i]);
  19992. }
  19993. }
  19994. //数据写入页面
  19995. for (var i = 0; i < tempNode.length; i++) {
  19996. //nodes 不清空
  19997. nodes.push(tempNode[i]);
  19998. }
  19999. for (var i = 0; i < tempLink.length; i++) {
  20000. //link 不清空
  20001. links.push(tempLink[i]);
  20002. }
  20003. //links转换
  20004. for (var i = 0; i < links.length; i++) {
  20005. for (var j = 0; j < nodes.length; j++) {
  20006. if (links[i].source == nodes[j].id) {
  20007. links[i].source = nodes[j];
  20008. }
  20009. if (links[i].target == nodes[j].id) {
  20010. links[i].target = nodes[j];
  20011. }
  20012. }
  20013. }
  20014. restart();
  20015. });
  20016. }
  20017. };
  20018. var svg;
  20019. var force;
  20020. var drag_line, path, circle;
  20021. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  20022. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  20023. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  20024. var nodes = [],
  20025. links = [];
  20026. var treeNodes = [];
  20027. //读取labels (node)
  20028. var labels = [];
  20029. function redrawSvg(json) {
  20030. nodes.length = 0; //先清空
  20031. links.length = 0;
  20032. var data = json.data;
  20033. for (var i = 0; i < data.node.length; i++) {
  20034. nodes.push(data.node[i]);
  20035. }
  20036. restart();
  20037. }
  20038. //读取status (节点 连线)
  20039. var statuses = [];
  20040. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  20041. // if (result && result.status == 200) {
  20042. // d3.select('#nodeStatus').selectAll('option')
  20043. // .data(statuses).enter()
  20044. // .append('option')
  20045. // .attr('value', function(d) { return d.code; })
  20046. // .html(function(d) { return d.desc; });
  20047. // } else {
  20048. // SweetAlert.swal({
  20049. // title: "提示!",
  20050. // text: "服务器请求异常!",
  20051. // type: "error"
  20052. // });
  20053. // }
  20054. // });
  20055. api_wechatfile
  20056. .getDictionary({
  20057. key: "cmdb_status",
  20058. type: "list",
  20059. })
  20060. .then(function (result) {
  20061. if (result) {
  20062. d3.select("#nodeStatus")
  20063. .selectAll("option")
  20064. .data(statuses)
  20065. .enter()
  20066. .append("option")
  20067. .attr("value", function (d) {
  20068. return d.code;
  20069. })
  20070. .html(function (d) {
  20071. return d.desc;
  20072. });
  20073. } else {
  20074. SweetAlert.swal({
  20075. title: "提示!",
  20076. text: "服务器请求异常!",
  20077. type: "error",
  20078. });
  20079. }
  20080. });
  20081. //查询relationship_type表 name 为表里的type,label为显示值
  20082. var linkType = [];
  20083. function fetchEdgeTypes() {
  20084. ConfigDataService.fetchDataList("ciedgetype", {
  20085. idx: 0,
  20086. sum: 100,
  20087. }).then(function (response) {
  20088. if (response) {
  20089. if (response["list"]) {
  20090. linkType = response["list"];
  20091. // d3.select('#linkName').selectAll('option')
  20092. // .data(linkType).enter()
  20093. // .append('option')
  20094. // .attr('value',function(d){return d.type;})
  20095. // .html(function(d){ return d.label;});
  20096. } else {
  20097. SweetAlert.swal({
  20098. title: "提示!",
  20099. text: "服务器请求异常!",
  20100. type: "error",
  20101. });
  20102. }
  20103. } else {
  20104. SweetAlert.swal({
  20105. title: "提示!",
  20106. text: "服务器请求异常!",
  20107. type: "error",
  20108. });
  20109. }
  20110. });
  20111. }
  20112. // fetchEdgeTypes();
  20113. /*
  20114. // init D3 force layout
  20115. var force = d3.layout.force()
  20116. .nodes(nodes)
  20117. .links(links)
  20118. .size([width, height])
  20119. .gravity(.05)
  20120. .linkDistance(150)
  20121. .linkStrength(2)
  20122. .charge(-500)
  20123. .on('tick', tick);
  20124. // define arrow markers for graph links
  20125. svg.append('svg:defs').append('svg:marker')
  20126. .attr('id', 'end-arrow')
  20127. .attr('viewBox', '0 -5 10 10')
  20128. .attr('refX', 6)
  20129. .attr('markerWidth', 3)
  20130. .attr('markerHeight', 3)
  20131. .attr('orient', 'auto')
  20132. .append('svg:path')
  20133. .attr('d', 'M0,-5L10,0L0,5')
  20134. .attr('fill', '#000');
  20135. svg.append('svg:defs').append('svg:marker')
  20136. .attr('id', 'start-arrow')
  20137. .attr('viewBox', '0 -5 10 10')
  20138. .attr('refX', 4)
  20139. .attr('markerWidth', 3)
  20140. .attr('markerHeight', 3)
  20141. .attr('orient', 'auto')
  20142. .append('svg:path')
  20143. .attr('d', 'M10,-5L0,0L10,5')
  20144. .attr('fill', '#000');
  20145. // line displayed when dragging new nodes
  20146. var drag_line = svg.append('svg:path')
  20147. .attr('class', 'link dragline hidden')
  20148. .attr('d', 'M0,0L0,0');
  20149. // handles to link and node element groups
  20150. //(1)var path = svg.append('svg:g').selectAll('g')
  20151. var path = svg.append('svg:g').selectAll('g'),
  20152. circle = svg.append('svg:g').selectAll('g');
  20153. */
  20154. // mouse event vars
  20155. var selected_node = null,
  20156. selected_link = null,
  20157. mousedown_link = null,
  20158. mousedown_node = null,
  20159. mouseup_node = null;
  20160. function resetMouseVars() {
  20161. mousedown_node = null;
  20162. mouseup_node = null;
  20163. mousedown_link = null;
  20164. }
  20165. // update force layout (called automatically each iteration)
  20166. function tick() {
  20167. // draw directed edges with proper padding from node centers
  20168. path.selectAll("path").attr("d", function (d) {
  20169. var deltaX = d.target.x - d.source.x,
  20170. deltaY = d.target.y - d.source.y,
  20171. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  20172. normX = deltaX / dist,
  20173. normY = deltaY / dist,
  20174. sourcePadding = d.left ? 27 : 22,
  20175. targetPadding = d.right ? 27 : 22,
  20176. sourceX = d.source.x + sourcePadding * normX,
  20177. sourceY = d.source.y + sourcePadding * normY,
  20178. targetX = d.target.x - targetPadding * normX,
  20179. targetY = d.target.y - targetPadding * normY;
  20180. return (
  20181. "M" +
  20182. sourceX +
  20183. "," +
  20184. sourceY +
  20185. "L" +
  20186. targetX +
  20187. "," +
  20188. targetY
  20189. );
  20190. });
  20191. circle.attr("transform", function (d) {
  20192. return "translate(" + d.x + "," + d.y + ")";
  20193. });
  20194. }
  20195. // update graph (called when needed)
  20196. function restart() {
  20197. //绑定link 数据
  20198. path.datum(links);
  20199. // path (link) group
  20200. path = path.data(links, function (d) {
  20201. return d.id;
  20202. });
  20203. var p = path.enter().append("svg:g");
  20204. //update existing links
  20205. path
  20206. .selectAll("path")
  20207. .classed("selected", function (d) {
  20208. return d === selected_link;
  20209. })
  20210. .style("marker-start", function (d) {
  20211. return d.left ? "url(#start-arrow)" : "";
  20212. })
  20213. .style("marker-end", function (d) {
  20214. return d.right ? "url(#end-arrow)" : "";
  20215. });
  20216. // add new links
  20217. p.append("svg:path")
  20218. .attr("class", "link")
  20219. .attr("id", function (d) {
  20220. return "path_" + d.id;
  20221. })
  20222. // .attr('startOffset', '0%')
  20223. .classed("selected", function (d) {
  20224. return d === selected_link;
  20225. })
  20226. .style("marker-start", function (d) {
  20227. return d.left ? "url(#start-arrow)" : "";
  20228. })
  20229. .style("marker-end", function (d) {
  20230. return d.right ? "url(#end-arrow)" : "";
  20231. })
  20232. .on("mousedown", function (d) {
  20233. if (d3.event.ctrlKey) return;
  20234. //去除没有提交的连线
  20235. for (var i = 0; i < links.length; i++) {
  20236. if (links[i].id == -1 && d.id != -1) {
  20237. links.splice(i, 1);
  20238. }
  20239. }
  20240. // select link
  20241. mousedown_link = d;
  20242. if (mousedown_link === selected_link) {
  20243. selected_link = $scope.selected_link = null;
  20244. selected_node = $scope.selected_node = null;
  20245. // d3.select("#linkDetail").attr('style','display:none');
  20246. //hideLinkForm(true);//return ;
  20247. } else {
  20248. selected_link = $scope.selected_link = mousedown_link;
  20249. selected_node = $scope.selected_node = null;
  20250. }
  20251. selected_node = $scope.selected_node = null;
  20252. restart();
  20253. });
  20254. p.append("svg:text")
  20255. .attr("x", 30)
  20256. .attr("y", 20)
  20257. .attr("class", "fontM")
  20258. .append("textPath")
  20259. .attr("xlink:xlink:href", function (d, i) {
  20260. return "#path_" + d.id;
  20261. })
  20262. .html(function (d) {
  20263. for (var i = 0; i < linkType.length; i++) {
  20264. if (linkType[i].type == d.name) {
  20265. return linkType[i].label;
  20266. }
  20267. }
  20268. });
  20269. // remove old links
  20270. path.exit().remove();
  20271. // circle (node) group
  20272. // NB: the function arg is crucial here! nodes are known by id, not by index!
  20273. circle.datum(nodes);
  20274. circle = circle.data(nodes, function (d) {
  20275. return d.id;
  20276. });
  20277. // update existing nodes (reflexive & selected visual states)
  20278. circle
  20279. .selectAll("circle")
  20280. .style("fill", function (d) {
  20281. return d === selected_node
  20282. ? d3.rgb(colors(d.label)).brighter().toString()
  20283. : colors(d.label);
  20284. })
  20285. .style("fill-opacity", 0.75) // add by xi
  20286. .classed("reflexive", function (d) {
  20287. return d.reflexive;
  20288. });
  20289. // add new nodes
  20290. var g = circle.enter().append("svg:g");
  20291. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  20292. //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');
  20293. g.append("svg:circle")
  20294. .attr("r", 24)
  20295. .style("fill", function (d) {
  20296. return d === selected_node
  20297. ? "rgb(153,153,153)"
  20298. : "rgb(255,255,255)";
  20299. })
  20300. .style("stroke", function (d) {
  20301. return d3.rgb(colors(d.label)).darker().toString();
  20302. })
  20303. .style("stroke-width", "2");
  20304. g.append("svg:circle")
  20305. .attr("class", "node")
  20306. .attr("r", 18)
  20307. .style("fill", function (d) {
  20308. return d === selected_node
  20309. ? d3.rgb(colors(d.label)).brighter().toString()
  20310. : colors(d.label);
  20311. })
  20312. .style("stroke", function (d) {
  20313. return d3.rgb(colors(d.label)).darker().toString();
  20314. })
  20315. .style("fill-opacity", 0.25) //add by xj
  20316. .style("stroke-opacity", 0.5) //add by xj
  20317. .classed("reflexive", function (d) {
  20318. return d.reflexive;
  20319. });
  20320. g.on("mouseover", function (d) {
  20321. //if(!mousedown_node || d === mousedown_node) return;
  20322. // enlarge target node
  20323. //d3.select(this).attr('transform', 'scale(1.1)');
  20324. })
  20325. .on("mouseout", function (d) {
  20326. //if(!mousedown_node || d === mousedown_node) return;
  20327. // unenlarge target node
  20328. //d3.select(this).attr('transform', '');
  20329. })
  20330. .on("mousedown", function (d) {
  20331. if (d3.event.ctrlKey) return;
  20332. //hideLinkForm(true);
  20333. //去除没有提交的连线
  20334. for (var i = 0; i < links.length; i++) {
  20335. if (links[i].id == -1) {
  20336. links.splice(i, 1);
  20337. }
  20338. }
  20339. // select node
  20340. mousedown_node = d;
  20341. if (mousedown_node === selected_node) {
  20342. selected_node = $scope.selected_node = null;
  20343. } else {
  20344. selected_node = $scope.selected_node = mousedown_node;
  20345. selected_link = $scope.selected_link = null;
  20346. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  20347. APIService.findRefById(selected_node.id).then(function (
  20348. result
  20349. ) {
  20350. var d = result.data;
  20351. var node = d.node;
  20352. var link = d.edge;
  20353. var tempNode = [];
  20354. var tempLink = [];
  20355. //nodes 或者links 要去重
  20356. for (var i = 0; i < node.length; i++) {
  20357. var tmp = 0;
  20358. for (var j = 0; j < nodes.length; j++) {
  20359. if (node[i].id == nodes[j].id) {
  20360. tmp++;
  20361. break;
  20362. }
  20363. }
  20364. if (tmp == 0) {
  20365. tempNode.push(node[i]);
  20366. }
  20367. }
  20368. for (var i = 0; i < link.length; i++) {
  20369. var tmp = 0;
  20370. for (var j = 0; j < links.length; j++) {
  20371. if (link[i].id == links[j].id) {
  20372. tmp++;
  20373. break;
  20374. }
  20375. }
  20376. if (tmp == 0) {
  20377. tempLink.push(link[i]);
  20378. }
  20379. }
  20380. //数据写入页面
  20381. for (var i = 0; i < tempNode.length; i++) {
  20382. //nodes 不清空
  20383. nodes.push(tempNode[i]);
  20384. }
  20385. for (var i = 0; i < tempLink.length; i++) {
  20386. //link 不清空
  20387. links.push(tempLink[i]);
  20388. }
  20389. //links转换
  20390. for (var i = 0; i < links.length; i++) {
  20391. for (var j = 0; j < nodes.length; j++) {
  20392. if (links[i].source == nodes[j].id) {
  20393. links[i].source = nodes[j];
  20394. }
  20395. if (links[i].target == nodes[j].id) {
  20396. links[i].target = nodes[j];
  20397. }
  20398. }
  20399. }
  20400. restart();
  20401. });
  20402. }
  20403. // reposition drag line
  20404. drag_line
  20405. .style("marker-end", "url(#end-arrow)")
  20406. .classed("hidden", false)
  20407. .attr(
  20408. "d",
  20409. "M" +
  20410. mousedown_node.x +
  20411. "," +
  20412. mousedown_node.y +
  20413. "L" +
  20414. mousedown_node.x +
  20415. "," +
  20416. mousedown_node.y
  20417. );
  20418. restart();
  20419. })
  20420. .on("mouseup", function (d) {
  20421. if (!mousedown_node) return;
  20422. });
  20423. // show node name
  20424. g.append("svg:text")
  20425. .attr("x", 0)
  20426. .attr("y", 34)
  20427. .attr("class", "id")
  20428. .text(function (d) {
  20429. return d.name;
  20430. }); //TODO 改为 d.name
  20431. //设置图片
  20432. g.append("svg:foreignObject")
  20433. .attr("width", 32)
  20434. .attr("height", 32)
  20435. .attr("x", "-16px")
  20436. .attr("y", "-11px")
  20437. .html(function (d) {
  20438. for (var i = 0; i < labels.length; i++) {
  20439. if (d.label == labels[i].sign) {
  20440. return (
  20441. '<i class="icon iconfont">' +
  20442. labels[i].iconname +
  20443. "</i>"
  20444. );
  20445. }
  20446. }
  20447. });
  20448. // remove old nodes
  20449. circle.exit().remove();
  20450. // set the graph in motion
  20451. force.start();
  20452. }
  20453. function mousedown() {
  20454. // prevent I-bar on drag
  20455. //d3.event.preventDefault();
  20456. // because :active only works in WebKit?
  20457. svg.classed("active", true);
  20458. if (mousedown_node) {
  20459. viewNode(mousedown_node);
  20460. }
  20461. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  20462. return;
  20463. restart();
  20464. }
  20465. function mousemove() {
  20466. if (!mousedown_node) return;
  20467. // update drag line
  20468. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  20469. //restart();
  20470. }
  20471. function mouseup() {
  20472. if (mousedown_node) {
  20473. // hide drag line
  20474. drag_line.classed("hidden", true).style("marker-end", "");
  20475. }
  20476. // because :active only works in WebKit?
  20477. svg.classed("active", false);
  20478. // clear mouse event vars
  20479. resetMouseVars();
  20480. }
  20481. function spliceLinksForNode(node) {
  20482. var toSplice = links.filter(function (l) {
  20483. return l.source === node || l.target === node;
  20484. });
  20485. toSplice.map(function (l) {
  20486. links.splice(links.indexOf(l), 1);
  20487. });
  20488. }
  20489. // only respond once per keydown
  20490. var lastKeyDown = -1;
  20491. function keydown() {
  20492. //d3.event.preventDefault();
  20493. if (lastKeyDown !== -1) return;
  20494. lastKeyDown = d3.event.keyCode;
  20495. // ctrl
  20496. if (d3.event.keyCode === 17) {
  20497. circle.call(force.drag);
  20498. svg.classed("ctrl", true);
  20499. }
  20500. if (!selected_node && !selected_link) return;
  20501. switch (d3.event.keyCode) {
  20502. case 8: // backspace
  20503. case 66: // B
  20504. if (selected_link) {
  20505. // set link direction to both left and right
  20506. selected_link.left = true;
  20507. selected_link.right = true;
  20508. }
  20509. restart();
  20510. break;
  20511. case 76: // L
  20512. if (selected_link) {
  20513. // set link direction to left only
  20514. selected_link.left = true;
  20515. selected_link.right = false;
  20516. }
  20517. restart();
  20518. break;
  20519. case 82: // R
  20520. if (selected_node) {
  20521. // toggle node reflexivity
  20522. selected_node.reflexive = !selected_node.reflexive;
  20523. } else if (selected_link) {
  20524. // set link direction to right only
  20525. selected_link.left = false;
  20526. selected_link.right = true;
  20527. }
  20528. restart();
  20529. break;
  20530. }
  20531. }
  20532. function keyup() {
  20533. lastKeyDown = -1;
  20534. // ctrl
  20535. if (d3.event.keyCode === 17) {
  20536. circle
  20537. .on("mousedown.drag", null)
  20538. .on("touchstart.drag", null);
  20539. svg.classed("ctrl", false);
  20540. }
  20541. }
  20542. function viewNode(node) {
  20543. // console.log(svg.attr('left'));
  20544. //var el = angular.element('div.modal-dialog')[0];
  20545. var title =
  20546. $scope.selected_node.name +
  20547. "-[" +
  20548. $scope.selected_node.uuid +
  20549. "]";
  20550. if (!$scope.selected_node.props.state) {
  20551. $scope.selected_node.props.state = "空";
  20552. } else if ($scope.selected_node.props.state) {
  20553. if ($scope.selected_node.props.state == "1") {
  20554. $scope.selected_node.props.state = "未审核";
  20555. } else if ($scope.selected_node.props.state == "2") {
  20556. $scope.selected_node.props.state = "已审核";
  20557. } else if ($scope.selected_node.props.state == "3") {
  20558. $scope.selected_node.props.state = "不匹配";
  20559. } else if ($scope.selected_node.props.state == "4") {
  20560. $scope.selected_node.props.state = "丢失";
  20561. }
  20562. }
  20563. if (!$scope.selected_node.name) {
  20564. $scope.selected_node.name = "空";
  20565. }
  20566. if (!$scope.selected_node.status) {
  20567. $scope.selected_node.statu = "空";
  20568. }
  20569. if (!$scope.selected_node.props.useradmin) {
  20570. $scope.selected_node.props.useradmin = "空";
  20571. }
  20572. Toaster.pop({
  20573. // type: 'info',
  20574. // title: title,
  20575. body:
  20576. "<br/><p>搜索代码:" +
  20577. $scope.selected_node.uuid +
  20578. "</p>" +
  20579. "<p>配置标题:" +
  20580. $scope.selected_node.name +
  20581. "</p>" +
  20582. "<p>状态:" +
  20583. $scope.selected_node.status +
  20584. "</p>" +
  20585. "<p>审核状态:" +
  20586. $scope.selected_node.props.state +
  20587. "</p>" +
  20588. "<p>维护人员:" +
  20589. $scope.selected_node.props.useradmin +
  20590. "</p>",
  20591. bodyOutputType: "trustedHtml",
  20592. timeout: 3000,
  20593. });
  20594. }
  20595. //GT 颜色与数值对照表
  20596. function colors(sign) {
  20597. //num=num>20?num%20:parseInt(num);
  20598. for (var i = 0; i < labels.length; i++) {
  20599. var entity = labels[i];
  20600. if (sign == entity.sign) {
  20601. return entity.color;
  20602. }
  20603. if (i == labels.length - 1 && sign != entity.sign) {
  20604. return "#ffeeee";
  20605. }
  20606. }
  20607. }
  20608. $scope.init = function () {
  20609. svg = d3
  20610. .select("#cmdbSVG")
  20611. .append("svg")
  20612. .attr("width", width)
  20613. .attr("height", height);
  20614. // init D3 force layout
  20615. force = d3.layout
  20616. .force()
  20617. .nodes(nodes)
  20618. .links(links)
  20619. .size([width, height])
  20620. .gravity(0.05)
  20621. .linkDistance(150)
  20622. .linkStrength(2)
  20623. .charge(-500)
  20624. .on("tick", tick);
  20625. // define arrow markers for graph links
  20626. svg
  20627. .append("svg:defs")
  20628. .append("svg:marker")
  20629. .attr("id", "end-arrow")
  20630. .attr("viewBox", "0 -5 10 10")
  20631. .attr("refX", 6)
  20632. .attr("markerWidth", 3)
  20633. .attr("markerHeight", 3)
  20634. .attr("orient", "auto")
  20635. .append("svg:path")
  20636. .attr("d", "M0,-5L10,0L0,5")
  20637. .attr("fill", "#000");
  20638. svg
  20639. .append("svg:defs")
  20640. .append("svg:marker")
  20641. .attr("id", "start-arrow")
  20642. .attr("viewBox", "0 -5 10 10")
  20643. .attr("refX", 4)
  20644. .attr("markerWidth", 3)
  20645. .attr("markerHeight", 3)
  20646. .attr("orient", "auto")
  20647. .append("svg:path")
  20648. .attr("d", "M10,-5L0,0L10,5")
  20649. .attr("fill", "#000");
  20650. // line displayed when dragging new nodes
  20651. drag_line = svg
  20652. .append("svg:path")
  20653. .attr("class", "link dragline hidden")
  20654. .attr("d", "M0,0L0,0");
  20655. // handles to link and node element groups
  20656. //(1)var path = svg.append('svg:g').selectAll('g')
  20657. path = svg.append("svg:g").selectAll("g");
  20658. circle = svg.append("svg:g").selectAll("g");
  20659. svg
  20660. .on("mousedown", mousedown)
  20661. .on("mousemove", mousemove)
  20662. .on("mouseup", mouseup);
  20663. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  20664. };
  20665. var CI = {};
  20666. window.CI = CI;
  20667. $scope.ok = function () {
  20668. $modalInstance.close($scope.selected_node);
  20669. };
  20670. $scope.cancel = function () {
  20671. $modalInstance.dismiss("cancel");
  20672. };
  20673. },
  20674. size: size,
  20675. resolve: {
  20676. title: function () {
  20677. return options.templateOptions.title;
  20678. },
  20679. Restangular: function () {
  20680. return options.templateOptions.Restangular;
  20681. },
  20682. APIService: function () {
  20683. return options.templateOptions.ApiService;
  20684. },
  20685. ConfigDataService: function () {
  20686. return options.templateOptions.ConfigDataService;
  20687. },
  20688. ConfigFormService: function () {
  20689. return options.templateOptions.ConfigFormService;
  20690. },
  20691. SweetAlert: function () {
  20692. return options.templateOptions.Alert;
  20693. },
  20694. Toaster: function () {
  20695. return options.templateOptions.toaster;
  20696. },
  20697. },
  20698. });
  20699. modalInstance.result.then(
  20700. function (selectedItem) {
  20701. options.value(selectedItem.name + "-" + selectedItem.uuid);
  20702. },
  20703. function () {
  20704. //console.log('Modal dismissed at: ' + new Date());
  20705. }
  20706. );
  20707. },
  20708. },
  20709. };
  20710. },
  20711. controller: [
  20712. "$scope",
  20713. function ($scope) {
  20714. // setTimeout(function(){
  20715. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  20716. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  20717. // if(modelData.status==200){
  20718. // $scope.model[$scope.options.key] = modelData.data;
  20719. // $scope.options.initialValue = $scope.model[$scope.options.key];
  20720. // }
  20721. // });
  20722. // },1000);
  20723. },
  20724. ],
  20725. });
  20726. });
  20727. appFormly.run(function (formlyConfig, $parse) {
  20728. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  20729. var removeOnHideTransformer = function (fields, model) {
  20730. return fields.map(function (field) {
  20731. if (
  20732. field.hideExpression &&
  20733. (!field.data || !field.data.dontRemoveOnHidden)
  20734. ) {
  20735. addFieldRemoveOnHideWatcher(field);
  20736. }
  20737. if (field.type == "ui-title") {
  20738. addFieldRemoveOnHideWatcher(field);
  20739. }
  20740. return field;
  20741. });
  20742. };
  20743. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  20744. function addFieldRemoveOnHideWatcher(field) {
  20745. var watcher = getWatcher();
  20746. if (field.watcher) {
  20747. if (!angular.isArray(field.watcher)) {
  20748. field.watcher = [field.watcher];
  20749. }
  20750. field.watcher.push(watcher);
  20751. } else {
  20752. field.watcher = watcher;
  20753. }
  20754. }
  20755. function getWatcher() {
  20756. return {
  20757. expression: function (field) {
  20758. return field.hide;
  20759. },
  20760. listener: function (field, newHide, oldHide, scope) {
  20761. if (field.hide) {
  20762. if (field.templateOptions.pkey) {
  20763. if (field.key == "transferuser") {
  20764. $parse(field.templateOptions.pkey + "." + field.key).assign(
  20765. scope.model,
  20766. undefined
  20767. );
  20768. }
  20769. } else if(typeof field.key =='string') {
  20770. $parse(field.key).assign(scope.model, undefined);
  20771. }
  20772. }
  20773. if (field.type == "ui-title") {
  20774. $parse(field.key).assign(scope.model, undefined);
  20775. }
  20776. },
  20777. };
  20778. }
  20779. });
  20780. appFormly.controller("CustomformCtrl", [
  20781. "$rootScope",
  20782. "$scope",
  20783. "$parse",
  20784. "$injector",
  20785. "$http",
  20786. "$q",
  20787. "$state",
  20788. "$stateParams",
  20789. "$modal",
  20790. "$timeout",
  20791. "$interval",
  20792. "SweetAlert",
  20793. "FileUploader",
  20794. "i18nService",
  20795. "Restangular",
  20796. "UserRestangular",
  20797. "BpmRestangular",
  20798. "SimpleRestangular",
  20799. "WechatRestangular",
  20800. "api_configure_form",
  20801. "api_bpm_domain",
  20802. "api_bpm_domain1",
  20803. "api_simple",
  20804. "api_bpm",
  20805. "api_bpm_data",
  20806. "api_user_data",
  20807. "api_statistic",
  20808. "up_down_file",
  20809. "fileReader",
  20810. "api_wechatfile",
  20811. "api_category",
  20812. function (
  20813. $rootScope,
  20814. $scope,
  20815. $parse,
  20816. $injector,
  20817. $http,
  20818. $q,
  20819. $state,
  20820. $stateParams,
  20821. $modal,
  20822. $timeout,
  20823. $interval,
  20824. SweetAlert,
  20825. FileUploader,
  20826. i18nService,
  20827. Restangular,
  20828. UserRestangular,
  20829. BpmRestangular,
  20830. SimpleRestangular,
  20831. WechatRestangular,
  20832. api_configure_form,
  20833. api_bpm_domain,
  20834. api_bpm_domain1,
  20835. api_simple,
  20836. api_bpm,
  20837. api_bpm_data,
  20838. api_user_data,
  20839. api_statistic,
  20840. up_down_file,
  20841. fileReader,
  20842. api_wechatfile,
  20843. api_category
  20844. ) {
  20845. //console.log($parse('Restangular')($scope));
  20846. //console.log($injector.get('Restangular'));
  20847. //console.log($stateParams);
  20848. //保存报修主体
  20849. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  20850. $scope.imgUrlList = [];
  20851. $scope.uploadimg_del = function () {
  20852. console.log(123);
  20853. };
  20854. var vm = this;
  20855. vm.options = {};
  20856. vm.exampleTitle = ["expressionProperties", "model property"];
  20857. vm.fields = [];
  20858. vm.model = {};
  20859. $scope.langs = i18nService.getAllLangs();
  20860. $scope.lang = "zh-cn";
  20861. i18nService.setCurrentLang($scope.lang);
  20862. //alert($rootScope.user.id,null,2);
  20863. vm.model["loginUser"] = $rootScope.user;
  20864. var loginUser = $rootScope.user;
  20865. // console.log(vm);
  20866. var that = $injector;
  20867. var parse = $parse;
  20868. var formKey = "";
  20869. var pdKey = "";
  20870. var modelWatch = "";
  20871. // 房间号是否显示
  20872. vm.model.isRoom = sessionStorage.getItem('ifRoom') == 1;
  20873. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20874. modelWatch = JSON.parse($stateParams.model);
  20875. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  20876. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  20877. console.log(modelWatch, $rootScope);
  20878. // if(modelWatch.model.incident){
  20879. // if(modelWatch.model.incident.place){
  20880. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  20881. // }else{
  20882. // $rootScope.selecthouseNumber = undefined;
  20883. // }
  20884. // }
  20885. // 初始化的时候判断是否是简单处理
  20886. if(modelWatch.model && modelWatch.model.incident && modelWatch.model.incident.category){
  20887. if (modelWatch.model.incident.category.hasSimple == 1) {
  20888. vm.model.isHasSimple = true;
  20889. }else{
  20890. vm.model.isHasSimple = false;
  20891. }
  20892. }
  20893. }
  20894. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  20895. pdKey = $state.current.pdKey;
  20896. } else if ($stateParams.pdKey) {
  20897. pdKey = $stateParams.pdKey;
  20898. }
  20899. // console.log("pdKey::" + JSON.stringify($state.current.title));
  20900. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  20901. formKey = $stateParams.formKey;
  20902. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  20903. }
  20904. if (angular.isDefined($stateParams.model)) {
  20905. var formModel = $stateParams.model;
  20906. }
  20907. //用户测试数据,后续从header的auth中获取
  20908. var userId = 2;
  20909. userId = $rootScope.user.id;
  20910. //==============处理表单设计数据 开始====================
  20911. //处理组件加载后台数据选项的方法
  20912. function refreshSelectOptions(searchVal, field) {
  20913. if (
  20914. field.templateOptions.optionsUrl &&
  20915. !field.templateOptions.isnosearch
  20916. ) {
  20917. var process = BpmRestangular.all("");
  20918. if (field.templateOptions.ApiService) {
  20919. process = UserRestangular.all("");
  20920. }
  20921. if (field.templateOptions.Apicommon) {
  20922. process = WechatRestangular.all("");
  20923. }
  20924. var datakey = {
  20925. idx: 0,
  20926. sum: 1000,
  20927. };
  20928. if (field.templateOptions.modelreasondata) {
  20929. datakey = field.templateOptions.modelreasondata;
  20930. }
  20931. process
  20932. .customPOST(datakey, field.templateOptions.optionsUrl)
  20933. .then(function (result) {
  20934. if (!field.templateOptions.options) {
  20935. field.templateOptions.options = [];
  20936. }
  20937. if (field.templateOptions.optionsDataKey) {
  20938. field.templateOptions.options =
  20939. result[field.templateOptions.optionsDataKey];
  20940. } else {
  20941. field.templateOptions.options = result;
  20942. }
  20943. });
  20944. }
  20945. }
  20946. //获取表单后数据处理
  20947. function formfield(field, result) {
  20948. // angular.forEach(fields.fields, function(field) {
  20949. if (field.key == "") {
  20950. delete field.key;
  20951. }
  20952. if (angular.isDefined(field.extjson)) {
  20953. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  20954. angular.extend(field.templateOptions, extObj.templateOptions);
  20955. delete extObj.templateOptions;
  20956. for (var prop in extObj) {
  20957. if (new RegExp("Expression").test(prop)) {
  20958. //var obj = $scope.$eval(extObj[prop]);
  20959. //extObj[prop] = $scope.$eval(extObj[prop]);
  20960. if (extObj[prop] != null) {
  20961. if (new RegExp("function").test(extObj[prop])) {
  20962. var propValue = eval(extObj[prop]);
  20963. extObj[prop] = propValue;
  20964. } else {
  20965. //console.log(extObj[prop]);
  20966. var obj = $scope.$eval(extObj[prop]);
  20967. extObj[prop] = obj;
  20968. //console.log(obj);
  20969. }
  20970. }
  20971. } else if (new RegExp("expressionProperties").test(prop)) {
  20972. for (var p in extObj[prop]) {
  20973. if (new RegExp("function").test(extObj[prop][p])) {
  20974. var propValue = eval(extObj[prop][p]);
  20975. extObj[prop][p] = propValue;
  20976. } else {
  20977. //if(p.indexOf("'")>=0){
  20978. // var obj = $scope.$eval(extObj[prop][p]);
  20979. // extObj[prop][$scope.$eval(p)]=obj;
  20980. //}
  20981. }
  20982. }
  20983. } else if ("watcher" == prop) {
  20984. if (angular.isArray(extObj[prop])) {
  20985. angular.forEach(extObj[prop], function (item, index) {
  20986. for (var p in item) {
  20987. if (new RegExp("function").test(item[p])) {
  20988. var propValue = eval(item[p]);
  20989. extObj[prop][index][p] = propValue;
  20990. }
  20991. }
  20992. });
  20993. } else if (angular.isObject(extObj[prop])) {
  20994. for (var p in extObj[prop]) {
  20995. if (new RegExp("function").test(extObj[prop][p])) {
  20996. var propValue = eval(extObj[prop][p]);
  20997. extObj[prop][p] = propValue;
  20998. }
  20999. }
  21000. }
  21001. }
  21002. }
  21003. angular.extend(field, extObj);
  21004. delete field.extjson;
  21005. }
  21006. if (angular.isDefined(field.templateOptions)) {
  21007. var templateOs = field.templateOptions;
  21008. // console.log(templateOs,'come')
  21009. for (var property in templateOs) {
  21010. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  21011. if (angular.isString(templateOs[property])) {
  21012. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  21013. if (new RegExp("function").test(templateOs[property])) {
  21014. var propValue = eval(templateOs[property]);
  21015. field.templateOptions[property] = propValue;
  21016. } else {
  21017. if (that.has(templateOs[property])) {
  21018. field.templateOptions[property] = that.get(
  21019. templateOs[property]
  21020. );
  21021. } else {
  21022. field.templateOptions[property] = templateOs[property];
  21023. }
  21024. }
  21025. } else if (templateOs[property] == null) {
  21026. //delete field.templateOptions[property];
  21027. } else {
  21028. }
  21029. }
  21030. }
  21031. if (
  21032. angular.isDefined(field.templateOptions) &&
  21033. angular.isDefined(field.templateOptions.extjson)
  21034. ) {
  21035. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  21036. angular.extend(field.templateOptions, extObj);
  21037. delete field.templateOptions.extjson;
  21038. }
  21039. // ...
  21040. if (field.templateOptions) {
  21041. //处理远程获取数据控件方法调用
  21042. if (
  21043. field.templateOptions.optionsUrl &&
  21044. !field.templateOptions.refresh
  21045. ) {
  21046. // if (!field.templateOptions.isnoreash) {
  21047. field.templateOptions.refresh = refreshSelectOptions;
  21048. // }
  21049. }
  21050. //处理嵌套属性数据绑定/
  21051. if (field.templateOptions.pkey) {
  21052. var pmodel,
  21053. i = 0;
  21054. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  21055. if (i == 0) {
  21056. if (result.model[p] == null) {
  21057. result.model[p] = {};
  21058. }
  21059. pmodel = result.model[p];
  21060. i++;
  21061. } else {
  21062. if (pmodel[p] == null) {
  21063. pmodel[p] = {};
  21064. }
  21065. pmodel = pmodel[p];
  21066. }
  21067. });
  21068. if (pmodel != null) {
  21069. field.model = pmodel;
  21070. if (pmodel[field.key] == null) {
  21071. pmodel[field.key] = null;
  21072. }
  21073. }
  21074. } else {
  21075. if (result.model[field.key] == null) {
  21076. result.model[field.key] = null;
  21077. }
  21078. }
  21079. //处理弹出框组件初始化
  21080. if (field.type == "ui-input-selectmodal") {
  21081. field.templateOptions.modal = $modal;
  21082. //field.templateOptions.Restangular = Restangular;
  21083. } else if (field.type == "ui-requesterselect") {
  21084. //field.templateOptions.language = $scope.lang;
  21085. field.templateOptions.modal = $modal;
  21086. field.templateOptions.UserService = api_user_data;
  21087. } else if (field.type == "ui-deptinformation") {
  21088. field.templateOptions.modal = $modal;
  21089. field.templateOptions.UserService = api_user_data;
  21090. } else if (field.type == "ui-requesterinformation") {
  21091. field.templateOptions.modal = $modal;
  21092. field.templateOptions.UserService = api_user_data;
  21093. } else if (field.type == "ui-userselect") {
  21094. field.templateOptions.modal = $modal;
  21095. //field.templateOptions.Restangular = Restangular;
  21096. } else if (field.type == "ui-userselectSearch") {
  21097. field.templateOptions.modal = $modal;
  21098. //field.templateOptions.Restangular = Restangular;
  21099. } else if (field.type == "ui-multiuserselect") {
  21100. field.templateOptions.modal = $modal;
  21101. } else if (field.type == "ui-stringuserselect") {
  21102. field.templateOptions.modal = $modal;
  21103. } else if (field.type == "ui-search") {
  21104. field.templateOptions.modal = $modal;
  21105. } else if (field.type == "ui-modelselect") {
  21106. field.templateOptions.modal = $modal;
  21107. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  21108. field.templateOptions.loginUser = $rootScope.user;
  21109. //field.templateOptions.Restangular = Restangular;
  21110. } else if (field.type == "ui-incidentmodelselect") {
  21111. field.templateOptions.modal = $modal;
  21112. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  21113. field.templateOptions.loginUser = $rootScope.user;
  21114. //field.templateOptions.Restangular = Restangular;
  21115. } else if (field.type == "ui-dropfile") {
  21116. $scope.fileUploader = field.templateOptions.fileUploader =
  21117. new FileUploader({
  21118. url: "/uploader",
  21119. });
  21120. field.templateOptions.taskId = $stateParams.taskId;
  21121. field.templateOptions.processInstanceId =
  21122. $stateParams.processInstanceId;
  21123. field.templateOptions.userId = $rootScope.user.id;
  21124. } else if (field.type == "ui-dropfielknow") {
  21125. $scope.fileUploader = field.templateOptions.fileUploader =
  21126. new FileUploader({
  21127. url: "/uploader",
  21128. });
  21129. field.templateOptions.taskId = $stateParams.taskId;
  21130. field.templateOptions.processInstanceId =
  21131. $stateParams.processInstanceId;
  21132. field.templateOptions.userId = $rootScope.user.id;
  21133. } else if (field.type == "ui-upDropFile") {
  21134. $scope.fileUploader = field.templateOptions.fileUploader =
  21135. new FileUploader({
  21136. url: "/uploader",
  21137. });
  21138. field.templateOptions.taskId = $stateParams.taskId;
  21139. field.templateOptions.processInstanceId =
  21140. $stateParams.processInstanceId;
  21141. field.templateOptions.userId = $rootScope.user.id;
  21142. } else if (field.type == "ui-dropfilenotup") {
  21143. $scope.fileUploader = field.templateOptions.fileUploader =
  21144. new FileUploader({
  21145. url: "/uploader",
  21146. });
  21147. field.templateOptions.taskId = $stateParams.taskId;
  21148. field.templateOptions.processInstanceId =
  21149. $stateParams.processInstanceId;
  21150. field.templateOptions.userId = $rootScope.user.id;
  21151. //field.ApiService=api_bpm_domain;
  21152. } else if (field.type == "ui-uploadFiles") {
  21153. $scope.fileUploader = field.templateOptions.fileUploader =
  21154. new FileUploader({
  21155. url: "/uploader",
  21156. });
  21157. field.templateOptions.taskId = $stateParams.taskId;
  21158. field.templateOptions.processInstanceId =
  21159. $stateParams.processInstanceId;
  21160. field.templateOptions.userId = $rootScope.user.id;
  21161. //field.ApiService=api_bpm_domain;
  21162. } else if (field.type == "ui-upDownFiles") {
  21163. $scope.fileUploader = field.templateOptions.fileUploader =
  21164. new FileUploader({
  21165. url: "/uploader",
  21166. });
  21167. field.templateOptions.taskId = $stateParams.taskId;
  21168. field.templateOptions.processInstanceId =
  21169. $stateParams.processInstanceId;
  21170. field.templateOptions.userId = $rootScope.user.id;
  21171. //field.ApiService=api_bpm_domain;
  21172. } else if (field.type == "ui-uploadImgs") {
  21173. $scope.fileUploader = field.templateOptions.fileUploader =
  21174. new FileUploader({
  21175. url: "/uploader",
  21176. });
  21177. field.templateOptions.taskId = $stateParams.taskId;
  21178. field.templateOptions.processInstanceId =
  21179. $stateParams.processInstanceId;
  21180. field.templateOptions.userId = $rootScope.user.id;
  21181. //field.ApiService=api_bpm_domain;
  21182. } else if (field.type == "ui-dropfiletable") {
  21183. if (field.templateOptions.processInstanceId) {
  21184. } else {
  21185. field.templateOptions.processInstanceId =
  21186. $stateParams.processInstanceId;
  21187. }
  21188. } else if (field.type == "ui-dropFiles") {
  21189. if (field.templateOptions.processInstanceId) {
  21190. } else {
  21191. field.templateOptions.processInstanceId =
  21192. $stateParams.processInstanceId;
  21193. }
  21194. } else if (field.type == "ui-showImgs") {
  21195. if (field.templateOptions.processInstanceId) {
  21196. } else {
  21197. field.templateOptions.processInstanceId =
  21198. $stateParams.processInstanceId;
  21199. }
  21200. } else if (field.type == "ui-repeatSection") {
  21201. var repeatForm = {
  21202. model: {},
  21203. fields: field.templateOptions.fields,
  21204. };
  21205. repeatForm.model[field.key] = [];
  21206. decodeVMForm(repeatForm);
  21207. } else if (field.type == "ui-currentuser") {
  21208. field.templateOptions.user = vm.model["loginUser"];
  21209. } else if (field.type == "ui-workernumbersign") {
  21210. field.templateOptions.user = vm.model["loginUser"];
  21211. } else if (field.type == "ui-repair-photos") {
  21212. field.templateOptions.user = vm.model["loginUser"];
  21213. }
  21214. }
  21215. }
  21216. //解析自定义表单设计数据
  21217. $scope.oldfromtype = true;
  21218. function decodeVMForm(vmForm) {
  21219. if (vmForm.formType == "1") {
  21220. $scope.oldfromtype = false;
  21221. } else {
  21222. $scope.oldfromtype = true;
  21223. }
  21224. var result = {
  21225. model: {},
  21226. fields: [],
  21227. };
  21228. //设置模型实体数据 begin
  21229. // var mdata = vmForm.model;
  21230. //解析数据实体
  21231. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  21232. angular.extend(result.model, mdata);
  21233. if (modelWatch != null && modelWatch != "") {
  21234. //angular.extend(result.model.incident,modelWatch.incident);
  21235. //result.model.alarmType = modelWatch.alarmType;
  21236. // vmForm.cancelUrl = modelWatch.cancelUrl;
  21237. // console.log(modelWatch.cancelUrl)
  21238. for (var index in modelWatch.model) {
  21239. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  21240. if (result.model[index] != null) {
  21241. angular.extend(result.model[index], modelWatch.model[index]);
  21242. } else {
  21243. result.model[index] = modelWatch.model[index];
  21244. }
  21245. }
  21246. }
  21247. //设置模型实体数据 end
  21248. //解析设计数据生成表单项 begin
  21249. var fields = [];
  21250. //处理修改设计数据中展示设置
  21251. angular.forEach(vmForm.fields, function (fields) {
  21252. if (vmForm.formType == "1") {
  21253. angular.forEach(fields.fields, function (field) {
  21254. formfield(field, result);
  21255. });
  21256. } else {
  21257. formfield(fields, result);
  21258. }
  21259. // console.log(field);
  21260. result.fields.push(fields);
  21261. });
  21262. angular.extend($scope.vm.fields, result.fields);
  21263. angular.extend($scope.vm.model, result.model);
  21264. vm.model["loginUser"] = $rootScope.user;
  21265. //增加识别报修主体seimin
  21266. vm.model.repairType = $scope.repairMain.valueconfig;
  21267. if (vm.model.incident) {
  21268. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  21269. }
  21270. console.log(vm, "repairType"); //lmm
  21271. if (
  21272. modelWatch != null &&
  21273. modelWatch != "" &&
  21274. modelWatch.cancelUrl != null &&
  21275. modelWatch.cancelUrl != ""
  21276. ) {
  21277. vmForm.cancelUrl = modelWatch.cancelUrl;
  21278. }
  21279. $scope.formData = vmForm;
  21280. console.log($scope.formData, 4444444);
  21281. // console.log($scope.formData.url);
  21282. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  21283. if ($scope.formData.url == "start") {
  21284. $scope.Reset = true;
  21285. $scope.close = true;
  21286. $rootScope.isMask = false;
  21287. } else if ($scope.formData.url == "complete") {
  21288. $scope.Reset = false;
  21289. $scope.close = true;
  21290. }
  21291. //解析设计数据生成表单项 end
  21292. return result;
  21293. }
  21294. //======================处理表单设计数据 结束========================
  21295. $scope.ldloading = {};
  21296. function filter(obj) {
  21297. angular.forEach(obj, function (key, value) {
  21298. if (value === "" || value === null) {
  21299. delete obj[key];
  21300. } else if (
  21301. Object.prototype.toString.call(value) === "[object Object]"
  21302. ) {
  21303. filter(value);
  21304. } else if (angular.isArray(value)) {
  21305. angular.forEach(value, function (item) {
  21306. filter(item);
  21307. });
  21308. }
  21309. });
  21310. }
  21311. $scope.closeModel = function () {
  21312. // console.log($stateParams);
  21313. $state.go($scope.formData.cancelUrl, {});
  21314. event.preventDefault();
  21315. };
  21316. // console.log(vm);
  21317. // 暂存
  21318. $scope.save = function (data) {
  21319. console.log(vm);
  21320. if (vm.model.startSave) {
  21321. vm.model["initUser"] = $rootScope.user.id;
  21322. vm.model.start_code = "temporary";
  21323. //处理请求数据0327
  21324. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21325. delete data0327.repairType;
  21326. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  21327. if (
  21328. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21329. .selecthouseNumber
  21330. ) {
  21331. data0327.incident.place = {
  21332. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21333. .selecthouseNumber.id,
  21334. };
  21335. }
  21336. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  21337. if (response) {
  21338. var resData = Restangular.stripRestangular(response);
  21339. if (resData) {
  21340. if (
  21341. $scope.fileUploader != null &&
  21342. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  21343. resData.id
  21344. ) {
  21345. $scope.fileUploader.onBeforeUploadItem = function (item) {
  21346. angular.extend(item.headers, $rootScope.getSession());
  21347. item.url = api_bpm_domain
  21348. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  21349. .getRequestedUrl();
  21350. item.formData.push({
  21351. fileName: item.file.name,
  21352. });
  21353. //console.log();
  21354. };
  21355. $scope.fileUploader.uploadAll();
  21356. }
  21357. }
  21358. SweetAlert.swal(
  21359. {
  21360. title: "提交成功!",
  21361. type: "success",
  21362. confirmButtonColor: "#007AFF",
  21363. },
  21364. function () {
  21365. $state.go($scope.formData.cancelUrl);
  21366. }
  21367. );
  21368. } else {
  21369. SweetAlert.swal({
  21370. title: "系统错误",
  21371. text: "系统错误,请稍后重试!",
  21372. type: "error",
  21373. confirmButtonColor: "#DD6B55",
  21374. });
  21375. }
  21376. $scope.ldloading[style.replace("-", "_")] = false;
  21377. });
  21378. event.preventDefault();
  21379. } else if (vm.model.saveAgain) {
  21380. var toData = {
  21381. incident: vm.model.incident,
  21382. };
  21383. api_user_data.updData("incident", toData).then(function (response) {
  21384. if (response) {
  21385. var resData = Restangular.stripRestangular(response);
  21386. SweetAlert.swal(
  21387. {
  21388. title: "提交成功!",
  21389. type: "success",
  21390. confirmButtonColor: "#007AFF",
  21391. },
  21392. function () {
  21393. $state.go($scope.formData.cancelUrl);
  21394. }
  21395. );
  21396. } else {
  21397. SweetAlert.swal({
  21398. title: "系统错误",
  21399. text: "系统错误,请稍后重试!",
  21400. type: "error",
  21401. confirmButtonColor: "#DD6B55",
  21402. });
  21403. }
  21404. $scope.ldloading[style.replace("-", "_")] = false;
  21405. });
  21406. event.preventDefault();
  21407. } else {
  21408. SweetAlert.swal({
  21409. title: "系统错误",
  21410. text: "系统错误,请稍后重试!",
  21411. type: "error",
  21412. confirmButtonColor: "#DD6B55",
  21413. });
  21414. }
  21415. };
  21416. // 巡检生成事件
  21417. $scope.inspectionToIncident = function () {
  21418. var userData = {
  21419. idx: 0,
  21420. sum: 10,
  21421. user: {
  21422. name: loginUser.name,
  21423. engineer: 0,
  21424. },
  21425. };
  21426. api_user_data.fetchDataList("user", userData).then(function (res) {
  21427. console.log(res);
  21428. var toUser = {};
  21429. if (res.list.length > 0) {
  21430. toUser = res.list[0];
  21431. } else {
  21432. toUser = loginUser;
  21433. }
  21434. console.log(vm);
  21435. var incidentDescription = "";
  21436. console.log($stateParams.formUiEdit);
  21437. if ($stateParams.formUiEdit == "inspection_LinHu_confirm") {
  21438. var fields = vm.fields
  21439. .filter((v) => {
  21440. v.key = (v.key || "").toString();
  21441. return v.key.indexOf("sdCheckEnable") > -1;
  21442. })
  21443. .map((v) => ({
  21444. key: v.key,
  21445. name: v.templateOptions.label,
  21446. value: vm.model[v.key],
  21447. }));
  21448. fields.forEach(v=>{
  21449. if (vm.model[v.key]) {
  21450. incidentDescription =
  21451. incidentDescription.concat(v.name);
  21452. }
  21453. })
  21454. if (vm.model.descriptionTextarea) {
  21455. incidentDescription = incidentDescription.concat(
  21456. " " + "整改意见:" + vm.model.descriptionTextarea
  21457. );
  21458. }
  21459. }
  21460. // console.log(incidentDescription)
  21461. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  21462. var formdata = {
  21463. model: {
  21464. // 'isInspection': true,
  21465. // 'start_code':'assignment',
  21466. // 'isHandlerUser':false,
  21467. incident: {
  21468. requester: bxr,
  21469. area: bxr.place.area,
  21470. place: bxr.place,
  21471. houseNumber: bxr.houseNumber,
  21472. contacts: bxr.name,
  21473. contactsInformation: bxr.phone,
  21474. // 'category': data.wxIncidentClassifyDTO.category,
  21475. description: incidentDescription,
  21476. source: {
  21477. id: 1552,
  21478. },
  21479. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  21480. // 'sourceType': data.incident.sourceType,
  21481. // 'fileUrl': data.incident.fileUrl
  21482. },
  21483. // 'requestershow': toUser,//2020年4月27日22:29:15
  21484. // 'flow': data.incident.id
  21485. // 'assignee': loginUser.id//2020年4月27日22:29:25
  21486. },
  21487. };
  21488. // console.log(formdata,toUser,'1111');
  21489. console.log(formdata, "1111");
  21490. // return;
  21491. $state.go("app.incident.chart", {
  21492. model: JSON.stringify(formdata),
  21493. });
  21494. });
  21495. // var formdata = {
  21496. // model:$rootScope.login_requester
  21497. // };
  21498. // console.log(formdata,'00000')
  21499. // return;
  21500. // $state.go("app.incident.chart", {
  21501. // 'model': JSON.stringify(formdata)
  21502. // });
  21503. event.preventDefault();
  21504. };
  21505. // console.log(vm);
  21506. // 创建事件seimin
  21507. vm.submit = function (data, style) {
  21508. console.log(vm, 22222);
  21509. // return;
  21510. if (vm.model.handler_code == undefined) {
  21511. vm.model.handler_code = "resolve";
  21512. }
  21513. if (
  21514. vm.model.change &&
  21515. vm.model.change.requestingPerson &&
  21516. vm.model.change.requestingPerson.menu
  21517. ) {
  21518. delete vm.model.change.requestingPerson.menu;
  21519. }
  21520. // var pdKey = $stateParams.pdKey;
  21521. if (vm.form.$valid) {
  21522. if (data.incident && data.incident.synergetic) {
  21523. console.log(data.incident.synergetic);
  21524. var synergetic = [];
  21525. for (var i = 0; i < data.incident.synergetic.length; i++) {
  21526. synergetic.push({
  21527. id: data.incident.synergetic[i],
  21528. });
  21529. }
  21530. data.incident.synergetic = synergetic;
  21531. vm.model.incident.synergetic = synergetic;
  21532. }
  21533. $scope.ldloading[style.replace("-", "_")] = true;
  21534. var startsub = true;
  21535. if (pdKey == "bpm_incident") {
  21536. angular.forEach(vm.fields, function (item) {
  21537. angular.forEach(item.fields, function (index) {
  21538. if (index.templateOptions.required && !index.hide) {
  21539. if (index.model) {
  21540. if(Object.prototype.toString.call(index.model[index.key]).slice(8, -1).toLowerCase() === 'object' && !index.model[index.key].id){
  21541. startsub = false;
  21542. $scope.ldloading.expand_right = false;
  21543. console.log(vm);
  21544. SweetAlert.swal({
  21545. title: index.templateOptions.label + "未填",
  21546. text: "请填写此项!",
  21547. type: "error",
  21548. confirmButtonColor: "#DD6B55",
  21549. });
  21550. }else if (
  21551. angular.isDefined(index.model[index.key]) &&
  21552. index.model[index.key] != null
  21553. ) {
  21554. if (
  21555. index.model[index.key].id &&
  21556. index.model[index.key].id == ""
  21557. ) {
  21558. startsub = false;
  21559. $scope.ldloading.expand_right = false;
  21560. SweetAlert.swal({
  21561. title: index.templateOptions.label + "未填",
  21562. text: "请填写此项!",
  21563. type: "error",
  21564. confirmButtonColor: "#DD6B55",
  21565. });
  21566. } else {
  21567. }
  21568. } else {
  21569. startsub = false;
  21570. $scope.ldloading.expand_right = false;
  21571. console.log(vm);
  21572. SweetAlert.swal({
  21573. title: index.templateOptions.label + "未填",
  21574. text: "请填写此项!",
  21575. type: "error",
  21576. confirmButtonColor: "#DD6B55",
  21577. });
  21578. }
  21579. } else {
  21580. if (
  21581. data[index.key] &&
  21582. data[index.key] != "" &&
  21583. data[index.key] != null
  21584. ) {
  21585. } else {
  21586. startsub = false;
  21587. $scope.ldloading.expand_right = false;
  21588. SweetAlert.swal({
  21589. title: index.templateOptions.label + "未填",
  21590. text: "请填写此项!",
  21591. type: "error",
  21592. confirmButtonColor: "#DD6B55",
  21593. });
  21594. }
  21595. }
  21596. }
  21597. });
  21598. });
  21599. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  21600. // startsub = false;
  21601. // $scope.ldloading.expand_right = false;
  21602. // SweetAlert.swal({
  21603. // title: '保修人未填',
  21604. // text: "请填写此项!",
  21605. // type: "error",
  21606. // confirmButtonColor: "#DD6B55"
  21607. // });
  21608. // }
  21609. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  21610. // } else {
  21611. // startsub = false;
  21612. // $scope.ldloading.expand_right = false;
  21613. // SweetAlert.swal({
  21614. // title: '故障现象未填',
  21615. // text: "请填写此项!",
  21616. // type: "error",
  21617. // confirmButtonColor: "#DD6B55"
  21618. // });
  21619. // }
  21620. }
  21621. if (startsub) {
  21622. $scope.ldloading[style.replace("-", "_")] = true;
  21623. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  21624. // console.log("vm.options:"+ JSON.stringify(vm.options));
  21625. vm.options.updateInitialValue();
  21626. // console.log("dfjkasdhfkhskjf ")
  21627. var _ = window._;
  21628. vm.model = (function filter(obj) {
  21629. var dateTransKeys = [];
  21630. var filtered = _.pick(obj, function (v, k, obj) {
  21631. if (_.isDate(v)) {
  21632. dateTransKeys.push(k);
  21633. }
  21634. return (
  21635. angular.isDefined(v) &&
  21636. v !== null &&
  21637. (angular.isArray(v) ? v.length > 0 : true) &&
  21638. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  21639. );
  21640. });
  21641. return _.cloneDeep(filtered, function (v, index, object) {
  21642. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  21643. angular.forEach(dateTransKeys, function (item) {
  21644. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  21645. });
  21646. dateTransKey = [];
  21647. return v;
  21648. }
  21649. return !_.isEmpty(filtered) &&
  21650. v !== filtered &&
  21651. _.isPlainObject(v)
  21652. ? filter(v)
  21653. : undefined;
  21654. });
  21655. })(vm.model);
  21656. if (pdKey != "") {
  21657. if ($scope.oprcode == "save") {
  21658. //保存
  21659. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  21660. if (response) {
  21661. var resData = Restangular.stripRestangular(response);
  21662. SweetAlert.swal(
  21663. {
  21664. title: "保存成功!",
  21665. confirmButtonColor: "#007AFF",
  21666. },
  21667. function () {
  21668. $state.go($scope.formData.cancelUri);
  21669. }
  21670. );
  21671. // if(resData.status){
  21672. // resData
  21673. // }
  21674. } else {
  21675. SweetAlert.swal({
  21676. title: "系统错误",
  21677. text: "系统错误,请稍后重试!",
  21678. type: "error",
  21679. confirmButtonColor: "#DD6B55",
  21680. });
  21681. }
  21682. $scope.ldloading[style.replace("-", "_")] = false;
  21683. });
  21684. } else {
  21685. console.log($scope.formData.url, "zzzz");
  21686. var integralMechanism = sessionStorage.getItem('integralMechanism');
  21687. switch ($scope.formData.url) {
  21688. case "start":
  21689. vm.model["initUser"] = $rootScope.user.id;
  21690. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  21691. } else {
  21692. vm.model["assignee"] = $rootScope.user.id;
  21693. }
  21694. if (
  21695. vm.model["candidateGroups"] &&
  21696. vm.model.candidateGroups.id
  21697. ) {
  21698. vm.model.candidateGroups = vm.model.candidateGroups.id;
  21699. }
  21700. if (pdKey == "bpm_service_request") {
  21701. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  21702. angular.extend(vm.model.serviceCatalogueProcessActual, {
  21703. category: {
  21704. id: $stateParams.userId,
  21705. },
  21706. });
  21707. }
  21708. if (vm.model.schedule && vm.model.schedule.initUser) {
  21709. delete vm.model.schedule.initUser.menu;
  21710. }
  21711. if (
  21712. vm.model.isHandlerUser == "true" ||
  21713. vm.model.isHandlerUser == true
  21714. ) {
  21715. delete vm.model.candidateGroups;
  21716. }
  21717. if (vm.model.start_code == "close") {
  21718. // 直接处理
  21719. vm.model.incident.handlingPersonnelUser =
  21720. vm.model.incident.acceptUser;
  21721. delete vm.model.incident.handlerUser;
  21722. delete vm.model.candidateGroups;
  21723. } else if (vm.model.start_code == "assignment") {
  21724. // 派单
  21725. delete vm.model.incident.handlingPersonnelUser;
  21726. }
  21727. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  21728. $scope.jry_processInstanceId =
  21729. $stateParams.processInstanceId;
  21730. }
  21731. if ($scope.jry_processInstanceId) {
  21732. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  21733. }
  21734. //事件暂存判断
  21735. if (vm.model.saveAgain) {
  21736. if (
  21737. vm.model.directClose == "1" ||
  21738. vm.model.directClose == true
  21739. ) {
  21740. vm.model.start_code = "assignment";
  21741. vm.model.temporary_code = "assignment";
  21742. } else {
  21743. vm.model.start_code = "close";
  21744. vm.model.temporary_code = "close";
  21745. }
  21746. if (
  21747. vm.model.isHandlerUser == "true" ||
  21748. vm.model.isHandlerUser == true
  21749. ) {
  21750. delete vm.model.candidateGroups;
  21751. }
  21752. }
  21753. //处理请求数据0327
  21754. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21755. delete data0327.repairType;
  21756. if (data0327.start_code == "close") {
  21757. data0327.incident.directProcess = 1;
  21758. }
  21759. console.log(vm);
  21760. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  21761. var paramsModel = JSON.parse($stateParams.model)
  21762. //来电-传话机id
  21763. if (paramsModel.model.incident.sockid) {
  21764. data0327.incident.callID = paramsModel.model.incident.sockid;
  21765. }
  21766. }
  21767. // --------------------------- start----------------------------------------
  21768. // 积分机制,直接处理
  21769. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21770. $modal.open({
  21771. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21772. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21773. console.log(incidentData,currentUserId);
  21774. $scope.flag = false;
  21775. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21776. $scope.complexityFn = function(category){
  21777. if(category.complexity){
  21778. return category.complexity.value;
  21779. }else if(category.parent){
  21780. return $scope.complexityFn(category.parent);
  21781. }else{
  21782. return $scope.list[0]?$scope.list[0].value:1;
  21783. }
  21784. }
  21785. $scope.list = [];
  21786. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21787. $scope.list = res;
  21788. if(incidentData.category && incidentData.category.id){
  21789. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21790. if(result.status == 200){
  21791. $scope.complexity = $scope.complexityFn(result.data);
  21792. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21793. }
  21794. })
  21795. }
  21796. })
  21797. $scope.onChangeComplexity = function(item){
  21798. }
  21799. $scope.ok = function () {
  21800. if (!$scope.complexityConfirm.complexity){
  21801. Alert.swal({
  21802. title: "操作失败",
  21803. text: "请选择工时!",
  21804. type: "error"
  21805. });
  21806. return;
  21807. }
  21808. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21809. Alert.swal({
  21810. title: "操作失败",
  21811. text: "请填写升级原因!",
  21812. type: "error"
  21813. });
  21814. return;
  21815. }
  21816. $modalInstance.close('success');
  21817. handlerStart();
  21818. scope.complexity = $scope.complexity;
  21819. scope.complexityConfirm = $scope.complexityConfirm;
  21820. // 暂存--后面直接处理后调用积分接口
  21821. }
  21822. $scope.cancel = function () {
  21823. scope.ldloading.expand_right = false;
  21824. $modalInstance.dismiss('cancel');
  21825. }
  21826. },
  21827. size: 'sm',
  21828. resolve: {
  21829. scope: function () {
  21830. return $scope;
  21831. },
  21832. api_bpm: function () {
  21833. return api_bpm;
  21834. },
  21835. incidentData: function () {
  21836. return data0327.incident;
  21837. },
  21838. currentUserId: function () {
  21839. return loginUser.id;
  21840. },
  21841. Alert: function () {
  21842. return SweetAlert;
  21843. },
  21844. api_user_data: function () {
  21845. return api_user_data;
  21846. },
  21847. api_wechatfile: function () {
  21848. return api_wechatfile;
  21849. }
  21850. }
  21851. });
  21852. }else{
  21853. handlerStart();
  21854. }
  21855. // -------------------------------end------------------------------------
  21856. function handlerStart(){
  21857. api_bpm_domain
  21858. .start(pdKey, data0327)
  21859. .then(function (response) {
  21860. if (response) {
  21861. var resData = Restangular.stripRestangular(response);
  21862. if (resData) {
  21863. if (resData) {
  21864. if (
  21865. $scope.fileUploader != null &&
  21866. $scope.fileUploader.getNotUploadedItems().length >
  21867. 0 &&
  21868. resData.id
  21869. ) {
  21870. $scope.fileUploader.onBeforeUploadItem =
  21871. function (item) {
  21872. angular.extend(
  21873. item.headers,
  21874. $rootScope.getSession()
  21875. );
  21876. item.url = api_bpm_domain
  21877. .uploadAttachment(
  21878. resData.id,
  21879. "00000",
  21880. $rootScope.user.id
  21881. )
  21882. .getRequestedUrl();
  21883. item.formData.push({
  21884. fileName: item.file.name,
  21885. });
  21886. //console.log();
  21887. };
  21888. $scope.fileUploader.uploadAll();
  21889. }
  21890. }
  21891. }
  21892. if(vm.model.start_code == "close"&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21893. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21894. var auditState = res.find(v=>v.value == 0);
  21895. var postData = {
  21896. incidentIntegral: {
  21897. incidentId:resData.bussId,
  21898. auditState:auditState,
  21899. handlerUser:$rootScope.user.id,
  21900. handlerUserName:$rootScope.user.name,
  21901. sourceScore:$scope.complexity,
  21902. currentScore:$scope.complexityConfirm.complexity.value,
  21903. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21904. }
  21905. }
  21906. console.log(postData)
  21907. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21908. console.log(response)
  21909. if (response.status == 200) {
  21910. SweetAlert.swal(
  21911. {
  21912. title: "提交成功!",
  21913. type: "success",
  21914. confirmButtonColor: "#007AFF",
  21915. },
  21916. function () {
  21917. if (
  21918. vm.model.incident &&
  21919. vm.model.incident.callID &&
  21920. vm.model.incident.callID != ""
  21921. ) {
  21922. $rootScope.app.layout.isSidebarClosed = false;
  21923. if ($scope.login && !$rootScope.busy) {
  21924. $rootScope.setidle();
  21925. }
  21926. }
  21927. $state.go($scope.formData.cancelUrl);
  21928. }
  21929. );
  21930. } else {
  21931. Alert.swal({
  21932. title: "操作失败",
  21933. text: "操作失败, 请稍后再试!",
  21934. type: "error"
  21935. });
  21936. }
  21937. });
  21938. })
  21939. }else{
  21940. SweetAlert.swal(
  21941. {
  21942. title: "提交成功!",
  21943. type: "success",
  21944. confirmButtonColor: "#007AFF",
  21945. },
  21946. function () {
  21947. if (
  21948. vm.model.incident &&
  21949. vm.model.incident.callID &&
  21950. vm.model.incident.callID != ""
  21951. ) {
  21952. $rootScope.app.layout.isSidebarClosed = false;
  21953. if ($scope.login && !$rootScope.busy) {
  21954. $rootScope.setidle();
  21955. }
  21956. }
  21957. $state.go($scope.formData.cancelUrl);
  21958. }
  21959. );
  21960. }
  21961. } else {
  21962. SweetAlert.swal({
  21963. title: "系统错误",
  21964. text: "系统错误,请稍后重试!",
  21965. type: "error",
  21966. confirmButtonColor: "#DD6B55",
  21967. });
  21968. }
  21969. $scope.ldloading[style.replace("-", "_")] = false;
  21970. });
  21971. }
  21972. break;
  21973. case "complete":
  21974. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  21975. //console.log("complete taskId::"+$stateParams.taskId);
  21976. if (
  21977. $scope.formData.name == "transferform" &&
  21978. vm.model.ishandlers &&
  21979. !vm.model.incident.handlerUser
  21980. ) {
  21981. SweetAlert.swal({
  21982. title: "处理人未填",
  21983. text: "请填写此项!",
  21984. type: "error",
  21985. confirmButtonColor: "#DD6B55",
  21986. });
  21987. return;
  21988. }
  21989. console.log(vm);
  21990. // 积分机制,事件状态是“处理中”
  21991. if($scope.formData.name === 'handlerform'&&(integralMechanism == 1 || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21992. $modal.open({
  21993. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21994. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21995. console.log(incidentData,currentUserId);
  21996. $scope.flag = true;
  21997. $scope.complexityConfirm = {complexity:null,updateReason:''};
  21998. $scope.complexityFn = function(category){
  21999. if(category.complexity){
  22000. return category.complexity.value;
  22001. }else if(category.parent){
  22002. return $scope.complexityFn(category.parent);
  22003. }else{
  22004. return $scope.list[0]?$scope.list[0].value:1;
  22005. }
  22006. }
  22007. $scope.list = [];
  22008. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  22009. $scope.list = res;
  22010. if(incidentData.category && incidentData.category.id){
  22011. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  22012. if(result.status == 200){
  22013. $scope.complexity = $scope.complexityFn(result.data);
  22014. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  22015. }
  22016. })
  22017. }
  22018. })
  22019. $scope.onChangeComplexity = function(item){
  22020. if($scope.complexityConfirm.complexity.value == $scope.complexity){
  22021. $scope.complexityConfirm.updateReason = '';
  22022. }
  22023. }
  22024. $scope.ok = function () {
  22025. if (!$scope.complexityConfirm.complexity){
  22026. Alert.swal({
  22027. title: "操作失败",
  22028. text: "请选择工时!",
  22029. type: "error"
  22030. });
  22031. return;
  22032. }
  22033. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  22034. Alert.swal({
  22035. title: "操作失败",
  22036. text: "请填写升级原因!",
  22037. type: "error"
  22038. });
  22039. return;
  22040. }
  22041. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  22042. // var auditState = $scope.complexityConfirm.complexity.value == $scope.complexity?res.find(v=>v.value == 1):res.find(v=>v.value == 0);
  22043. var auditState = res.find(v=>v.value == 0);
  22044. var postData = {
  22045. incidentIntegral: {
  22046. incidentId:incidentData.id,
  22047. auditState:auditState,
  22048. handlerUser:$rootScope.user.id,
  22049. handlerUserName:$rootScope.user.name,
  22050. sourceScore:$scope.complexity,
  22051. currentScore:$scope.complexityConfirm.complexity.value,
  22052. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  22053. }
  22054. }
  22055. console.log(postData)
  22056. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  22057. console.log(response)
  22058. if (response.status == 200) {
  22059. $modalInstance.close('success');
  22060. handlerLogFn();
  22061. } else {
  22062. Alert.swal({
  22063. title: "操作失败",
  22064. text: "操作失败, 请稍后再试!",
  22065. type: "error"
  22066. });
  22067. }
  22068. });
  22069. })
  22070. }
  22071. $scope.cancel = function () {
  22072. scope.ldloading.expand_right = false;
  22073. $modalInstance.dismiss('cancel');
  22074. }
  22075. },
  22076. size: 'sm',
  22077. resolve: {
  22078. scope: function () {
  22079. return $scope;
  22080. },
  22081. api_bpm: function () {
  22082. return api_bpm;
  22083. },
  22084. incidentData: function () {
  22085. return $scope.formData.model.incident;
  22086. },
  22087. currentUserId: function () {
  22088. return loginUser.id;
  22089. },
  22090. Alert: function () {
  22091. return SweetAlert;
  22092. },
  22093. api_user_data: function () {
  22094. return api_user_data;
  22095. },
  22096. api_wechatfile: function () {
  22097. return api_wechatfile;
  22098. }
  22099. }
  22100. });
  22101. }else{
  22102. handlerLogFn();
  22103. }
  22104. function handlerLogFn(){
  22105. //维修记录
  22106. // 维修记录不为空并且事件是处理中状态
  22107. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  22108. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  22109. baseHandler();
  22110. })
  22111. } else {
  22112. if($stateParams.formUiEdit === 'inspection_LinHu_confirm'){
  22113. //巡检计划
  22114. if(vm.model.inspectionProcessActual.group&&vm.model.inspectionProcessActual.group.id){
  22115. api_bpm.assign({ids:$stateParams.dataId.toString(),userId:$rootScope.user.id}).then(function (response) {
  22116. if (response.status == 200) {
  22117. baseHandler();
  22118. } else {
  22119. Alert.swal({
  22120. title: "操作失败",
  22121. text: "操作失败, 请稍后再试!",
  22122. type: "error"
  22123. });
  22124. }
  22125. });
  22126. }else{
  22127. baseHandler();
  22128. }
  22129. }else{
  22130. baseHandler();
  22131. }
  22132. }
  22133. }
  22134. // return;
  22135. function baseHandler() {
  22136. api_bpm_domain
  22137. .complete($stateParams.taskId, userId, vm.model)
  22138. .then(function (response) {
  22139. if (response) {
  22140. var resData = Restangular.stripRestangular(response);
  22141. SweetAlert.swal(
  22142. {
  22143. title: "提交成功!",
  22144. type: "success",
  22145. confirmButtonColor: "#007AFF",
  22146. },
  22147. function () {
  22148. if (
  22149. $scope.fileUploader != null &&
  22150. $scope.fileUploader.getNotUploadedItems().length >
  22151. 0
  22152. ) {
  22153. console.log(vm);
  22154. if (vm.model.incident) {
  22155. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  22156. // angular.extend(item.headers, $rootScope.getSession());
  22157. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  22158. // item.formData.push({
  22159. // 'fileName': item.file.name
  22160. // });
  22161. // };
  22162. // $scope.fileUploader.uploadAll();
  22163. $scope.fileUploader.onBeforeUploadItem =
  22164. function (item) {
  22165. angular.extend(
  22166. item.headers,
  22167. $rootScope.getSession()
  22168. );
  22169. item.url = api_bpm_domain
  22170. .uploadAttachment(
  22171. vm.model.incident.processInstanceId,
  22172. "00000",
  22173. $rootScope.user.id
  22174. )
  22175. .getRequestedUrl();
  22176. item.formData.push({
  22177. fileName: item.file.name,
  22178. });
  22179. //console.log();
  22180. };
  22181. $scope.fileUploader.uploadAll();
  22182. } else if (vm.model.problem) {
  22183. $scope.fileUploader.onBeforeUploadItem =
  22184. function (item) {
  22185. angular.extend(
  22186. item.headers,
  22187. $rootScope.getSession()
  22188. );
  22189. item.url = api_bpm_domain
  22190. .uploadAttachmentJryModel(
  22191. "problem",
  22192. vm.model.problem.id,
  22193. "00000",
  22194. $rootScope.user.id
  22195. )
  22196. .getRequestedUrl();
  22197. item.formData.push({
  22198. fileName: item.file.name,
  22199. });
  22200. };
  22201. $scope.fileUploader.uploadAll();
  22202. } else if (vm.model.change) {
  22203. }else if(vm.model.inspectionProcessActual){
  22204. //巡检图片上传yeye
  22205. $scope.fileUploader.onBeforeUploadItem =
  22206. function (item) {
  22207. angular.extend(
  22208. item.headers,
  22209. $rootScope.getSession()
  22210. );
  22211. item.url = api_bpm_domain1
  22212. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  22213. .getRequestedUrl();
  22214. item.formData.push({
  22215. fileName: item.file.name,
  22216. });
  22217. //console.log();
  22218. };
  22219. $scope.fileUploader.uploadAll();
  22220. }
  22221. }
  22222. $state.go($scope.formData.cancelUrl);
  22223. }
  22224. );
  22225. } else {
  22226. SweetAlert.swal({
  22227. title: "系统错误",
  22228. text: "系统错误,请稍后重试!",
  22229. type: "error",
  22230. confirmButtonColor: "#DD6B55",
  22231. });
  22232. }
  22233. $scope.ldloading[style.replace("-", "_")] = false;
  22234. });
  22235. }
  22236. break;
  22237. case "back":
  22238. $state.go($scope.formData.cancelUrl);
  22239. break;
  22240. default:
  22241. $scope.ldloading[style.replace("-", "_")] = false;
  22242. break;
  22243. }
  22244. }
  22245. // var submitFunc = api_bpm_domain[$scope.formData.url]
  22246. // if(anuglar.isFunction(submitFunc)){
  22247. // submitFunc.apply(null, pdKey)
  22248. // }
  22249. }
  22250. }
  22251. } else {
  22252. // console.log(data)
  22253. // angular.forEach(vm.form.$error.required, function(item){
  22254. // var i=(item.$name).substring(item.$name.length-2)
  22255. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  22256. // for(var i=0;i<vm.fields.length;i++){
  22257. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  22258. SweetAlert.swal({
  22259. title: vm.fields[i].templateOptions.label + "未填",
  22260. text: "请填写此项!",
  22261. type: "error",
  22262. confirmButtonColor: "#DD6B55",
  22263. });
  22264. }
  22265. // }
  22266. // angular.forEach(vm.fields,function(f){
  22267. // if(f.name == item.$name){
  22268. // f.validation.show = true;
  22269. // SweetAlert.swal({
  22270. // title: f.templateOptions.label+'未填',
  22271. // text: "请填写此项!",
  22272. // type: "error",
  22273. // confirmButtonColor: "#DD6B55"
  22274. // });
  22275. // }
  22276. // });
  22277. // })
  22278. }
  22279. };
  22280. $scope.vm = vm;
  22281. console.log($stateParams, pdKey, 88888);
  22282. console.log($scope.vm, "assdfsdf");
  22283. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  22284. var processInstanceId = $stateParams.processInstanceId;
  22285. var itemId = $stateParams.dataId;
  22286. console.log($stateParams);
  22287. if (
  22288. angular.isDefined($stateParams.pdKey) &&
  22289. $stateParams.pdKey == "bpm_inspection"
  22290. ) {
  22291. api_configure_form
  22292. .renderForm(
  22293. $stateParams.formUiEdit,
  22294. userId,
  22295. processInstanceId,
  22296. itemId
  22297. )
  22298. .then(function (responseData) {
  22299. if (responseData) {
  22300. //console.log("responseData>>>");//console.log(responseData);
  22301. var vmForm = Restangular.stripRestangular(responseData);
  22302. if (vmForm) {
  22303. //console.log("vmForm>>>");//console.log(vmForm);
  22304. decodeVMForm(vmForm);
  22305. }
  22306. }
  22307. });
  22308. } else if (
  22309. angular.isDefined($stateParams.pdKey) &&
  22310. $stateParams.pdKey == "bpm_service_request"
  22311. ) {
  22312. api_configure_form
  22313. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  22314. .then(function (responseData) {
  22315. if (responseData) {
  22316. //console.log("responseData>>>");//console.log(responseData);
  22317. var vmForm = Restangular.stripRestangular(responseData);
  22318. if (vmForm) {
  22319. //console.log("vmForm>>>");//console.log(vmForm);
  22320. decodeVMForm(vmForm);
  22321. }
  22322. }
  22323. });
  22324. } else {
  22325. api_bpm_domain
  22326. .taskformkey($stateParams.taskId)
  22327. .then(function (response) {
  22328. if (response) {
  22329. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  22330. api_configure_form
  22331. .renderForm(myData.data, userId, processInstanceId, itemId)
  22332. .then(function (responseData) {
  22333. if (responseData) {
  22334. //console.log("responseData>>>");//console.log(responseData);
  22335. var vmForm = Restangular.stripRestangular(responseData);
  22336. if (vmForm) {
  22337. //console.log("vmForm>>>");//console.log(vmForm);
  22338. decodeVMForm(vmForm);
  22339. console.log(vmForm, 111111);
  22340. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  22341. console.log($scope, "今天"); //2020年4月24日11:40:55
  22342. }
  22343. }
  22344. });
  22345. }
  22346. });
  22347. }
  22348. } else {
  22349. // create process instance
  22350. if (pdKey != "") {
  22351. //for process
  22352. if (pdKey == "bpm_service_request") {
  22353. api_configure_form
  22354. .renderForm($stateParams.formUiStart, userId)
  22355. .then(function (responseData) {
  22356. if (responseData) {
  22357. var vmForm = Restangular.stripRestangular(responseData);
  22358. if (vmForm) {
  22359. decodeVMForm(vmForm);
  22360. }
  22361. }
  22362. });
  22363. } else {
  22364. api_bpm_domain.startformkey(pdKey).then(function (response) {
  22365. if (response) {
  22366. var myData = Restangular.stripRestangular(response);
  22367. //myData.data = "arrangeform";
  22368. api_configure_form
  22369. .renderForm(myData.data, userId)
  22370. .then(function (responseData) {
  22371. if (responseData) {
  22372. var vmForm = Restangular.stripRestangular(responseData);
  22373. if (vmForm) {
  22374. decodeVMForm(vmForm);
  22375. }
  22376. }
  22377. });
  22378. }
  22379. });
  22380. }
  22381. } else {
  22382. //for form
  22383. //TODO
  22384. //测试数据 开始
  22385. var testJson = {
  22386. fields: [
  22387. {
  22388. fields: [
  22389. {
  22390. className: "col-xs-12",
  22391. noFormControl: true,
  22392. key: "formtitle",
  22393. templateOptions: {
  22394. readOnly: false,
  22395. placeholder: "新建事件单",
  22396. hidden: false,
  22397. label: "事件工单",
  22398. required: false,
  22399. },
  22400. type: "ui-title",
  22401. },
  22402. ],
  22403. },
  22404. {
  22405. fields: [
  22406. {
  22407. key: "selectUser",
  22408. type: "ui-deptinformation",
  22409. className: "col-xs-12",
  22410. templateOptions: {
  22411. label: "请求人信息",
  22412. modalTitle: "请求人列表",
  22413. fetchItems: function (filterData, APIService) {
  22414. return APIService.fetchDataList("requester", filterData);
  22415. },
  22416. Restangular: Restangular,
  22417. ApiService: api_user_data,
  22418. // onClick:function(val, options, field, event , model){
  22419. // console.log(options);
  22420. // }
  22421. },
  22422. },
  22423. ],
  22424. },
  22425. {
  22426. fields: [
  22427. {
  22428. key: "first",
  22429. type: "ui-workernumber",
  22430. className: "col-xs-12",
  22431. templateOptions: {
  22432. type: "input",
  22433. label: "事件单号",
  22434. pkey: "name",
  22435. },
  22436. },
  22437. ],
  22438. },
  22439. {
  22440. fields: [
  22441. {
  22442. type: "ui-header",
  22443. key: "title",
  22444. className: "col-xs-12",
  22445. templateOptions: {
  22446. label: "报修人",
  22447. pkey: "change",
  22448. },
  22449. },
  22450. {
  22451. type: "ui-input",
  22452. key: "title",
  22453. className: "col-xs-4",
  22454. templateOptions: {
  22455. label: "报修人",
  22456. pkey: "change",
  22457. },
  22458. },
  22459. {
  22460. type: "ui-input",
  22461. key: "title",
  22462. className: "col-xs-4",
  22463. templateOptions: {
  22464. label: "联系人",
  22465. pkey: "change",
  22466. },
  22467. },
  22468. {
  22469. type: "ui-input",
  22470. key: "title",
  22471. className: "col-xs-4",
  22472. templateOptions: {
  22473. label: "联系电话",
  22474. pkey: "change",
  22475. },
  22476. },
  22477. ],
  22478. },
  22479. {
  22480. fields: [
  22481. {
  22482. type: "ui-header",
  22483. key: "title1",
  22484. className: "col-xs-12",
  22485. templateOptions: {
  22486. label: "报修人",
  22487. pkey: "change",
  22488. },
  22489. },
  22490. {
  22491. type: "ui-input",
  22492. key: "title2",
  22493. className: "col-xs-4",
  22494. templateOptions: {
  22495. label: "报修人",
  22496. pkey: "change",
  22497. },
  22498. },
  22499. {
  22500. type: "ui-input",
  22501. key: "title3",
  22502. className: "col-xs-4",
  22503. templateOptions: {
  22504. label: "联系人",
  22505. pkey: "change",
  22506. },
  22507. },
  22508. {
  22509. type: "ui-input",
  22510. key: "title4",
  22511. className: "col-xs-4",
  22512. templateOptions: {
  22513. label: "联系电话",
  22514. pkey: "change",
  22515. },
  22516. },
  22517. ],
  22518. },
  22519. ],
  22520. model: [
  22521. {
  22522. username: "robin lau",
  22523. password: "123456",
  22524. chkme: false,
  22525. start_code: 0,
  22526. formtitle: "Hey!I am title value!",
  22527. name: {
  22528. first: "robin",
  22529. last: "lau",
  22530. },
  22531. multiselectItem: [],
  22532. //date:"2015-09-15 00:00:00"
  22533. },
  22534. ],
  22535. // }
  22536. };
  22537. setTimeout(function () {
  22538. decodeVMForm(testJson);
  22539. $scope.$apply();
  22540. }, 500);
  22541. //测试数据结束
  22542. }
  22543. }
  22544. //console.log("end decode");
  22545. },
  22546. ]);