customformCtrl.js 857 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051
  1. var appFormly = angular.module("formlyExample", [
  2. "formly",
  3. "formlyBootstrap",
  4. "ui.bootstrap",
  5. "ngSanitize",
  6. "ui.select",
  7. "ui.grid",
  8. ]);
  9. app.requires.push("formlyExample");
  10. // var appFormly = angular.module('formlyExample', [
  11. // 'formly', 'formlyBootstrap','ui.bootstrap',
  12. // 'ngSanitize','ui.select','ui.grid'],
  13. // 图片上传
  14. app.factory("fileReader", [
  15. "$q",
  16. "$log",
  17. function ($q, $log) {
  18. var onLoad = function (reader, deferred, scope) {
  19. return function () {
  20. scope.$apply(function () {
  21. deferred.resolve(reader.result);
  22. });
  23. };
  24. };
  25. var onError = function (reader, deferred, scope) {
  26. return function () {
  27. scope.$apply(function () {
  28. deferred.reject(reader.result);
  29. });
  30. };
  31. };
  32. var getReader = function (deferred, scope) {
  33. var reader = new FileReader(); //fileReader
  34. reader.onload = onLoad(reader, deferred, scope);
  35. reader.onerror = onError(reader, deferred, scope);
  36. return reader;
  37. };
  38. var readAsDataURL = function (file, scope) {
  39. var deferred = $q.defer();
  40. var reader = getReader(deferred, scope);
  41. reader.readAsDataURL(file);
  42. return deferred.promise;
  43. };
  44. return {
  45. readAsDataUrl: readAsDataURL,
  46. };
  47. },
  48. ]);
  49. appFormly.filter("minutesToHours", function () {
  50. //分钟转小时
  51. return function (num) {
  52. var hour = parseInt(num / 60);
  53. var minute = num % 60;
  54. return hour + "小时" + minute + "分钟";
  55. };
  56. });
  57. appFormly.config(function config(formlyConfigProvider) {
  58. //格式转换方法 XXX-XXX转驼峰命名
  59. function camelize(string) {
  60. string = string.replace(/[\-_\s]+(.)?/g, function (match, chr) {
  61. return chr ? chr.toUpperCase() : "";
  62. });
  63. // Ensure 1st char is always lowercase
  64. return string.replace(/^([A-Z])/, function (match, chr) {
  65. return chr ? chr.toLowerCase() : "";
  66. });
  67. }
  68. //获取ngModelAttr对象设置
  69. function getNgModelAttr(attrs, bindings) {
  70. var ngModelAttrs = {};
  71. angular.forEach(attrs, function (attr) {
  72. ngModelAttrs[camelize(attr)] = {
  73. attribute: attr,
  74. };
  75. });
  76. angular.forEach(bindings, function (binding) {
  77. ngModelAttrs[camelize(binding)] = {
  78. bound: binding,
  79. };
  80. });
  81. return ngModelAttrs;
  82. }
  83. formlyConfigProvider.setWrapper({
  84. overwriteOk: true,
  85. name: "bootstrapLabel",
  86. templateUrl: "assets/views/customform/tpl/normal-label.html",
  87. });
  88. //流程图
  89. formlyConfigProvider.setType({
  90. name: "ui-process",
  91. templateUrl: "assets/views/customform/tpl/cmdb/ui-process.html",
  92. defaultOptions: function (options) {
  93. return {
  94. templateOptions: {
  95. refresh: function () { },
  96. refreshDelay: 0,
  97. },
  98. };
  99. },
  100. controller: [
  101. "$scope",
  102. "$modal",
  103. "SweetAlert",
  104. "api_bpm_domain",
  105. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  106. $scope.processdata = [];
  107. api_bpm_domain
  108. .flowTracing($scope.model.applicationForm.processInstanceId)
  109. .then(function (data) {
  110. console.log(data);
  111. $scope.processdata = data.data;
  112. });
  113. },
  114. ],
  115. });
  116. //出库单详情
  117. formlyConfigProvider.setType({
  118. name: "ui-getoutinform",
  119. extends: "radio",
  120. templateUrl: "assets/views/customform/tpl/cmdb/ui-getoutinform.html",
  121. defaultOptions: function (options) {
  122. return {
  123. templateOptions: {
  124. refresh: function () { },
  125. refreshDelay: 0,
  126. },
  127. };
  128. },
  129. controller: [
  130. "$scope",
  131. "$modal",
  132. "SweetAlert",
  133. "api_bpm_domain",
  134. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  135. if (
  136. angular.isDefined($scope.model.type.id) &&
  137. !$scope.model.type.name
  138. ) {
  139. if (($scope.model.type.id = 0)) {
  140. $scope.model.type.name = "新资产入库";
  141. } else if (($scope.model.type.id = 1)) {
  142. $scope.model.type.name = "新设备领用出库";
  143. } else if (($scope.model.type.id = 2)) {
  144. $scope.model.type.name = "资产归还";
  145. } else if (($scope.model.type.id = 4)) {
  146. $scope.model.type.name = "设备更换";
  147. }
  148. }
  149. },
  150. ],
  151. });
  152. //多选框组件
  153. formlyConfigProvider.setType({
  154. name: "ui-checkboxmore",
  155. extends: "radio",
  156. templateUrl: "assets/views/customform/tpl/cmdb/ui-checkboxmore.html",
  157. defaultOptions: function (options) {
  158. return {
  159. templateOptions: {
  160. refresh: function () { },
  161. refreshDelay: 0,
  162. },
  163. };
  164. },
  165. controller: [
  166. "$scope",
  167. "$modal",
  168. "SweetAlert",
  169. "api_bpm_domain",
  170. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  171. $scope.options.initialValue = $scope.model[$scope.options.key];
  172. },
  173. ],
  174. });
  175. //入库单详情
  176. formlyConfigProvider.setType({
  177. name: "ui-getininform",
  178. extends: "radio",
  179. templateUrl: "assets/views/customform/tpl/cmdb/ui-getininform.html",
  180. defaultOptions: function (options) {
  181. return {
  182. templateOptions: {
  183. refresh: function () { },
  184. refreshDelay: 0,
  185. },
  186. };
  187. },
  188. controller: [
  189. "$scope",
  190. "$modal",
  191. "SweetAlert",
  192. "api_bpm_domain",
  193. function ($scope, $modal, SweetAlert, api_bpm_domain) {
  194. if (
  195. angular.isDefined($scope.model.type.id) &&
  196. !$scope.model.type.name
  197. ) {
  198. if (($scope.model.type.id = 0)) {
  199. $scope.model.type.name = "新资产入库";
  200. } else if (($scope.model.type.id = 1)) {
  201. $scope.model.type.name = "新设备领用出库";
  202. } else if (($scope.model.type.id = 2)) {
  203. $scope.model.type.name = "资产归还";
  204. } else if (($scope.model.type.id = 4)) {
  205. $scope.model.type.name = "设备更换";
  206. }
  207. }
  208. },
  209. ],
  210. });
  211. //申请人详情
  212. formlyConfigProvider.setType({
  213. name: "ui-requsterinfom",
  214. extends: "radio",
  215. templateUrl: "assets/views/customform/tpl/cmdb/requsterinfom.html",
  216. defaultOptions: function (options) {
  217. return {
  218. templateOptions: {
  219. refresh: function () { },
  220. refreshDelay: 0,
  221. },
  222. };
  223. },
  224. });
  225. //设备耗材list组件
  226. formlyConfigProvider.setType({
  227. name: "ui-uplodchange",
  228. templateUrl: "assets/views/customform/tpl/cmdb/uplodchange.html",
  229. defaultOptions: function (options) {
  230. return {
  231. templateOptions: {
  232. refresh: function () { },
  233. refreshDelay: 0,
  234. view: function (APIService, contentId) {
  235. return APIService.downloadAttachment(contentId);
  236. },
  237. },
  238. };
  239. },
  240. controller: [
  241. "$scope",
  242. "$filter",
  243. "ngTableParams",
  244. "$rootScope",
  245. "Restangular",
  246. function ($scope, $filter, ngTableParams, $rootScope, Restangular) {
  247. // var data = { "haodata": [], "shedata": [] };
  248. var haodata = [];
  249. var shedata = [];
  250. if ($scope.model.consumables) {
  251. if (angular.isArray($scope.model.consumables)) {
  252. haodata = $scope.model.consumables;
  253. } else {
  254. haodata = JSON.parse($scope.model.consumables);
  255. }
  256. $scope.model.consumables = haodata;
  257. angular.forEach(haodata, function (item, index) {
  258. haodata[index].item = index + 1;
  259. });
  260. }
  261. if ($scope.model.assets) {
  262. if (angular.isArray($scope.model.assets)) {
  263. shedata = $scope.model.assets;
  264. } else {
  265. shedata = JSON.parse($scope.model.assets);
  266. }
  267. $scope.model.assets = shedata;
  268. angular.forEach(shedata, function (item, index) {
  269. shedata[index].item = index + 1;
  270. });
  271. }
  272. $scope.tableParamshao = new ngTableParams(
  273. {
  274. page: 1,
  275. count: 5,
  276. },
  277. {
  278. total: haodata.length,
  279. getData: function ($defer, params) {
  280. var orderedData = params.sorting()
  281. ? $filter("orderBy")(haodata, params.orderBy())
  282. : haodata;
  283. $defer.resolve(
  284. orderedData.slice(
  285. (params.page() - 1) * params.count(),
  286. params.page() * params.count()
  287. )
  288. );
  289. },
  290. }
  291. );
  292. $scope.tableParamsshe = new ngTableParams(
  293. {
  294. page: 1,
  295. count: 5,
  296. },
  297. {
  298. total: shedata.length,
  299. getData: function ($defer, params) {
  300. var orderedData = params.sorting()
  301. ? $filter("orderBy")(shedata, params.orderBy())
  302. : shedata;
  303. $defer.resolve(
  304. orderedData.slice(
  305. (params.page() - 1) * params.count(),
  306. params.page() * params.count()
  307. )
  308. );
  309. },
  310. }
  311. );
  312. $scope.editId = -1;
  313. $scope.setEditId = function (pid) {
  314. $scope.editId = pid;
  315. };
  316. if (angular.isUndefined($scope.form.dropState)) {
  317. $scope.form.dropState = false;
  318. }
  319. var to = $scope.options.templateOptions;
  320. var bindId = $scope.model.processInstanceId;
  321. //获取附件列表
  322. $scope.listAttachmen = function () {
  323. to.ApiService.listAttachment(
  324. to.listAttachmentUrl,
  325. to.bindType,
  326. bindId
  327. ).then(function (result) {
  328. var myData = Restangular.stripRestangular(result);
  329. // $scope.listAttachmens = myData;
  330. $scope.attachments = myData.data;
  331. });
  332. };
  333. $scope.listAttachmen();
  334. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  335. // $scope.listAttachmen();
  336. // } else if (to.bindType && $scope.model[to.bindType].id) {
  337. // $scope.listAttachmen();
  338. // }
  339. //附件下载
  340. $scope.download = function (token, filename) {
  341. var downUrl = to.ApiService.downloadAttachment(
  342. to.downUrl,
  343. token
  344. ).getRequestedUrl();
  345. // window.open(downUrl);
  346. var a = document.createElement("a");
  347. a.href = downUrl;
  348. a.target = "_blank";
  349. a.download = filename;
  350. document.body.appendChild(a);
  351. a.click();
  352. };
  353. //附件预览
  354. $scope.view = function (id, previewUrl) {
  355. if (previewUrl) {
  356. window.open(previewUrl);
  357. }
  358. };
  359. },
  360. ],
  361. });
  362. //多选框组件
  363. formlyConfigProvider.setType({
  364. name: "ui-nodataimage",
  365. templateUrl: "assets/views/customform/tpl/cmdb/ui-nodataimage.html",
  366. defaultOptions: function (options) {
  367. return {
  368. templateOptions: {
  369. refresh: function () { },
  370. refreshDelay: 0,
  371. },
  372. };
  373. },
  374. });
  375. //ui-grid list
  376. formlyConfigProvider.setType({
  377. name: "ui-gridtwolist",
  378. // extends: 'input',
  379. templateUrl: "assets/views/customform/tpl/cmdb/gridtwolist.html",
  380. defaultOptions: function (options, $scope) {
  381. return {
  382. templateOptions: {},
  383. };
  384. },
  385. controller: [
  386. "$scope",
  387. "$modal",
  388. "i18nService",
  389. "SweetAlert",
  390. function ($scope, $modal, i18nService, SweetAlert) {
  391. //gridone
  392. $scope.langs = i18nService.getAllLangs();
  393. $scope.lang = "zh-cn";
  394. i18nService.setCurrentLang($scope.lang);
  395. $scope.gridOptions = {};
  396. $scope.gridOptions.data = "myDatagrid";
  397. $scope.gridOptions.enableColumnResizing = true;
  398. $scope.gridOptions.enableFiltering = true;
  399. $scope.gridOptions.enableGridMenu = false;
  400. $scope.gridOptions.enableRowSelection = true;
  401. $scope.gridOptions.showGridFooter = true;
  402. $scope.gridOptions.showColumnFooter = false;
  403. $scope.gridOptions.fastWatch = true;
  404. $scope.gridOptions.useExternalFiltering = false;
  405. $scope.gridOptions.useExternalPagination = true;
  406. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  407. $scope.gridOptions.paginationPageSize = 10;
  408. $scope.gridOptions.multiSelect = false;
  409. $scope.myDatagrid = [];
  410. $scope.myDatagridall = [];
  411. $scope.selected = {
  412. item: {},
  413. };
  414. $scope.memoryfilterDatagrid = {
  415. idx: 0,
  416. sum: 10,
  417. };
  418. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  419. filterData = {
  420. idx: 0,
  421. sum: 10,
  422. };
  423. $scope.gridOptions.columnDefs =
  424. $scope.options.templateOptions.columnDefs;
  425. }
  426. $scope.gridOptions.rowIdentity = function (row) {
  427. return row.id;
  428. };
  429. $scope.gridOptions.getRowIdentity = function (row) {
  430. return row.id;
  431. };
  432. // $scope.gridOptions.columnDefs = items.columnDefs();
  433. $scope.interceptMydata = function (mydate, idx, sum) {
  434. return mydate.slice(idx * sum, (idx + 1) * sum);
  435. };
  436. $scope.gridOptions.onRegisterApi = function (gridApi) {
  437. $scope.gridApi = gridApi;
  438. gridApi.pagination.on.paginationChanged(
  439. $scope,
  440. function (newPage, pageSize) {
  441. $scope.memoryfilterDatagrid.idx = newPage - 1;
  442. $scope.memoryfilterDatagrid.sum = pageSize;
  443. $scope.myDatagrid = $scope.interceptMydata(
  444. $scope.myDatagridall,
  445. $scope.memoryfilterDatagrid.idx,
  446. 10
  447. );
  448. $scope.loadData({
  449. idx: newPage - 1,
  450. sum: pageSize,
  451. });
  452. }
  453. );
  454. gridApi.core.on.filterChanged($scope, function () { });
  455. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  456. $scope.selected.item = data.entity;
  457. //console.log(data);
  458. });
  459. };
  460. $scope.loadData = function (mydate, idx, sum) {
  461. angular.forEach($scope.myDatagrid, function (item, index) {
  462. $scope.myDatagrid[index].item = index;
  463. });
  464. $scope.gridOptions.totalItems = mydate.length;
  465. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  466. };
  467. if ($scope.model.assets) {
  468. $scope.myDatagridall = $scope.model.assets;
  469. $scope.loadData($scope.model.assets, 0, 10);
  470. }
  471. $scope.saveData = function (itemin) {
  472. event.preventDefault();
  473. var modalInstance = $modal.open({
  474. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  475. controller: function ($scope, $modalInstance, SweetAlert) {
  476. // $scope.consumptive = {};
  477. $scope.title = "填写领用设备信息";
  478. // if (items.name) {
  479. // $scope.consumptive.name = items.name.name;
  480. // }
  481. $scope.placechange = angular.copy(itemin);
  482. $scope.ok = function (item) {
  483. if (
  484. item.props &&
  485. item.props.hwnw_area &&
  486. item.props.hwnw_place &&
  487. item.props.hwnw_room &&
  488. item.props.hwnwswt_jiguihao &&
  489. item.props.hwnwswt_Ushu &&
  490. item.props.snnum
  491. ) {
  492. $modalInstance.close(item);
  493. } else {
  494. SweetAlert.swal({
  495. title: "数据填写不完整!",
  496. text: "请检查数据然后提交!",
  497. type: "error",
  498. });
  499. }
  500. };
  501. $scope.cancel = function () {
  502. $modalInstance.dismiss("cancel");
  503. };
  504. },
  505. resolve: {
  506. SweetAlert: function () {
  507. return SweetAlert;
  508. },
  509. },
  510. });
  511. modalInstance.result.then(function (selectedItem) {
  512. angular.forEach($scope.myDatagrid, function (item, index) {
  513. // $scope.myDatagrid[index].props.hw_state = "在线";
  514. if (item.id == selectedItem.id) {
  515. // $scope.myDatagrid[index] = selectedItem;
  516. angular.extend($scope.myDatagrid[index], selectedItem);
  517. }
  518. });
  519. // $scope.myData3.push(selectedItem);
  520. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  521. $scope.myDatagrid[i]["item"] =
  522. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  523. }
  524. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  525. $scope.myDatagridall;
  526. });
  527. };
  528. //gridtwo
  529. $scope.langs = i18nService.getAllLangs();
  530. $scope.lang = "zh-cn";
  531. i18nService.setCurrentLang($scope.lang);
  532. $scope.gridOptions2 = {};
  533. $scope.gridOptions2.data = "myDatagridold";
  534. $scope.gridOptions2.enableColumnResizing = true;
  535. $scope.gridOptions2.enableFiltering = true;
  536. $scope.gridOptions2.enableGridMenu = false;
  537. $scope.gridOptions2.enableRowSelection = true;
  538. $scope.gridOptions2.showGridFooter = true;
  539. $scope.gridOptions2.showColumnFooter = false;
  540. $scope.gridOptions2.fastWatch = true;
  541. $scope.gridOptions2.useExternalFiltering = false;
  542. $scope.gridOptions.useExternalPagination = true;
  543. $scope.gridOptions2.paginationPageSizes = [10];
  544. $scope.gridOptions2.paginationPageSize = 10;
  545. $scope.gridOptions2.multiSelect = false;
  546. $scope.myDatagridold = [];
  547. $scope.myDatagridoldall = [];
  548. $scope.selected = {
  549. item: {},
  550. };
  551. $scope.memoryfilterDatagridold = {
  552. idx: 0,
  553. sum: 10,
  554. };
  555. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  556. filterData = {
  557. idx: 0,
  558. sum: 10,
  559. };
  560. $scope.gridOptions2.columnDefs =
  561. $scope.options.templateOptions.columnDefstwo;
  562. }
  563. $scope.gridOptions2.rowIdentity = function (row) {
  564. return row.id;
  565. };
  566. $scope.gridOptions2.getRowIdentity = function (row) {
  567. return row.id;
  568. };
  569. // $scope.gridOptions.columnDefs = items.columnDefs();
  570. $scope.interceptMydata = function (mydate, idx, sum) {
  571. return mydate.slice(idx * sum, (idx + 1) * sum);
  572. };
  573. if ($scope.model.oldAssets) {
  574. $scope.myDatagridallold = JSON.parse($scope.model.oldAssets);
  575. $scope.myDatagridold = $scope.interceptMydata(
  576. $scope.myDatagridallold,
  577. $scope.memoryfilterDatagridold.idx,
  578. 10
  579. );
  580. }
  581. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  582. $scope.gridApi = gridApi;
  583. gridApi.pagination.on.paginationChanged(
  584. $scope,
  585. function (newPage, pageSize) {
  586. $scope.memoryfilterDatagridold.idx = newPage - 1;
  587. $scope.memoryfilterDatagridold.sum = pageSize;
  588. $scope.myDatagridold = $scope.interceptMydata(
  589. $scope.myDatagridallold,
  590. $scope.memoryfilterDatagridold.idx,
  591. 10
  592. );
  593. // $scope.loadData({ "idx": newPage - 1, "sum": pageSize });
  594. }
  595. );
  596. gridApi.core.on.filterChanged($scope, function () { });
  597. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  598. $scope.selected.item = data.entity;
  599. //console.log(data);
  600. });
  601. };
  602. // $scope.loadData = function(mydate, idx, sum) {
  603. // angular.forEach($scope.myDatagridold, function(item, index) {
  604. // $scope.myDatagridold[index].item = index;
  605. // })
  606. // $scope.myDatagridold = mydate.slice(idx * sum, (idx + 1) * sum)
  607. // }
  608. // if ($scope.model.assets) {
  609. // $scope.myDatagridallold = $scope.model.assets;
  610. // $scope.loadData($scope.model.assets, 0, 10)
  611. // }
  612. // $scope.addoldassets = function(itemin) {
  613. // event.preventDefault();
  614. // var modalInstance = $modal.open({
  615. // templateUrl: 'assets/views/customform/tpl/cmdb/lingyonglist.html',
  616. // controller: function($scope, $modalInstance, SweetAlert) {
  617. // // $scope.consumptive = {};
  618. // $scope.title = "填写领用设备信息";
  619. // // if (items.name) {
  620. // // $scope.consumptive.name = items.name.name;
  621. // // }
  622. // $scope.placechange = itemin;
  623. // $scope.ok = function(item) {
  624. // if (item.hwnw_area && item.hwnw_place && item.hwnw_room && item.hwnwswt_jiguihao && item.hwnwswt_Ushu && item.snnum) {
  625. // $modalInstance.close(item);
  626. // } else {
  627. // SweetAlert.swal({
  628. // title: "数据填写不完整!",
  629. // text: "请检查数据然后提交!",
  630. // type: "error"
  631. // });
  632. // }
  633. // };
  634. // $scope.cancel = function() {
  635. // $modalInstance.dismiss('cancel');
  636. // };
  637. // },
  638. // resolve: {
  639. // SweetAlert: function() {
  640. // return SweetAlert;
  641. // }
  642. // }
  643. // });
  644. $scope.interceptMydata = function (mydate, idx, sum) {
  645. return mydate.slice(idx * sum, (idx + 1) * sum);
  646. };
  647. $scope.addshebei = function () {
  648. event.preventDefault();
  649. var modalInstance = $modal.open({
  650. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  651. controller: function (
  652. $scope,
  653. i18nService,
  654. $modalInstance,
  655. items,
  656. title,
  657. Restangular,
  658. APIService,
  659. onDataCallback,
  660. parentScope,
  661. api_configure_data,
  662. api_configure_form,
  663. api_cmdb
  664. ) {
  665. $scope.langs = i18nService.getAllLangs();
  666. $scope.lang = "zh-cn";
  667. i18nService.setCurrentLang($scope.lang);
  668. $scope.gridOptions = {};
  669. $scope.gridOptions.data = "myDatatwo";
  670. $scope.gridOptions.enableColumnResizing = true;
  671. $scope.gridOptions.enableFiltering = false;
  672. $scope.gridOptions.enableGridMenu = false;
  673. $scope.gridOptions.showGridFooter = true;
  674. $scope.gridOptions.showColumnFooter = false;
  675. $scope.gridOptions.fastWatch = true;
  676. $scope.gridOptions.useExternalFiltering = true;
  677. $scope.gridOptions.useExternalPagination = true;
  678. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  679. $scope.gridOptions.paginationPageSize = 10;
  680. $scope.gridOptions.multiSelect = true;
  681. $scope.gridOptions.rowIdentity = function (row) {
  682. return row.id;
  683. };
  684. $scope.gridOptions.getRowIdentity = function (row) {
  685. return row.id;
  686. };
  687. $scope.gridOptions.columnDefs = [
  688. {
  689. name: "item",
  690. displayName: "序号",
  691. width: 80,
  692. enableFiltering: false,
  693. },
  694. {
  695. name: "uuid",
  696. displayName: "内部编号",
  697. width: 150,
  698. },
  699. {
  700. name: "props.hw_mingcheng",
  701. displayName: "资产名称",
  702. width: 100,
  703. },
  704. {
  705. name: "props.hw_cifilterClassic",
  706. displayName: "资产类型",
  707. width: 120,
  708. enableFiltering: false,
  709. },
  710. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  711. {
  712. name: "props.hw_state",
  713. displayName: "资产状态",
  714. width: 150,
  715. enableFiltering: false,
  716. },
  717. {
  718. name: "props.hwnw_area",
  719. displayName: "资产地点",
  720. width: 130,
  721. enableFiltering: false,
  722. },
  723. {
  724. name: "createtime",
  725. displayName: "申请时间",
  726. enableFiltering: false,
  727. },
  728. ];
  729. // $scope.selectButtonClick
  730. var defaultFilterData = {
  731. // "assignee":2,
  732. // "applicationForm": { "hw_state": "在线" },
  733. hw_state: "在线",
  734. idx: 0,
  735. sum: 10,
  736. };
  737. $scope.memoryfilterData = {
  738. // "assignee":2,
  739. // "applicationForm": { "hw_state": "在线" },
  740. hw_state: "在线",
  741. idx: 0,
  742. sum: 10,
  743. };
  744. $scope.refreshData = function (style, filterData) {
  745. if (angular.isUndefined(filterData)) {
  746. filterData = defaultFilterData;
  747. }
  748. $scope.myDatatwo = [];
  749. // $scope.gridOptions['sum']=filterData.sum;
  750. api_cmdb.query(filterData).then(
  751. function (data) {
  752. // $scope.callsPending--;
  753. var myDatatwo = Restangular.stripRestangular(data);
  754. $scope.gridOptions["totalItems"] = data.total;
  755. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  756. myDatatwo.data.node[i].createtime = moment(
  757. myDatatwo.data.node[i].createtime
  758. ).format("YYYY-MM-DD");
  759. }
  760. $scope.myDatatwo = myDatatwo.data.node;
  761. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  762. $scope.myDatatwo[i]["item"] =
  763. i + 1 + filterData.idx * filterData.sum;
  764. }
  765. },
  766. function () { }
  767. );
  768. };
  769. $scope.refreshData("expand-right", defaultFilterData);
  770. $scope.gridOptions.onRegisterApi = function (gridApi) {
  771. $scope.gridApi = gridApi;
  772. gridApi.pagination.on.paginationChanged(
  773. $scope,
  774. function (newPage, pageSize) {
  775. var filtersData = $scope.memoryfilterData;
  776. filtersData.idx = newPage - 1;
  777. filtersData.sum = pageSize;
  778. // $scope.loadData(filtersData);
  779. $scope.refreshData("expand-right", filtersData);
  780. //console.log(pageSize);
  781. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  782. }
  783. );
  784. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  785. // $scope.selected.items.push(data.entity);
  786. //console.log(data);
  787. gridApi.selection.on.rowSelectionChanged(
  788. $scope,
  789. function (scope, ect) {
  790. if (scope.isSelected) {
  791. scope.grid.appScope.selected.items.push(scope.entity);
  792. } else {
  793. for (
  794. var i = 0;
  795. i <= scope.grid.appScope.selected.items.length;
  796. i++
  797. ) {
  798. if (
  799. scope.grid.appScope.selected.items[i].id ==
  800. scope.entity.id
  801. ) {
  802. scope.grid.appScope.selected.items.splice(i, 1);
  803. break;
  804. }
  805. }
  806. }
  807. $scope.mySelectedRows =
  808. $scope.gridApi.selection.getSelectedRows();
  809. }
  810. );
  811. // });
  812. gridApi.selection.on.rowSelectionChangedBatch(
  813. $scope,
  814. function (rows) {
  815. // $scope.selected.items = data.entity;
  816. //console.log(data);
  817. var selectitem = [];
  818. selectitem = angular.copy($scope.selected.items);
  819. for (var j = 0; j < rows.length; j++) {
  820. if (rows[j].isSelected == true) {
  821. selectitem.push(rows[j].entity);
  822. } else {
  823. delete selectitem[j];
  824. // rows.splice(j, 1);
  825. }
  826. }
  827. $scope.selected.items = [];
  828. for (var i = 0; i < selectitem.length; i++) {
  829. if (selectitem[i]) {
  830. $scope.selected.items.push(selectitem[i]);
  831. }
  832. }
  833. }
  834. );
  835. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  836. // // if (row.entity.age > 45) {
  837. // row.grid.api.selection.selectRow(row.entity); // 选中行
  838. // // }
  839. // };
  840. gridApi.core.on.filterChanged($scope, function () {
  841. var grid = this.grid;
  842. var filtersData = {
  843. idx: 0,
  844. sum: 10,
  845. user: {
  846. roledata: {
  847. rolecode: "roleset",
  848. },
  849. selectType: "1",
  850. },
  851. };
  852. angular.forEach(grid.columns, function (item) {
  853. if (item.enableFiltering) {
  854. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  855. if (
  856. angular.isDefined(item.filters[0].term) &&
  857. item.filters[0].term != ""
  858. ) {
  859. if (angular.isUndefined(filtersData["user"])) {
  860. filtersData["user"] = {};
  861. }
  862. filtersData["user"][item.field] = item.filters[0].term;
  863. }
  864. }
  865. });
  866. $scope.memoryfilterData = filtersData;
  867. // $scope.loadData(filtersData);
  868. });
  869. };
  870. $scope.onDblClick = function (data, event) {
  871. // $scope.selected.items = data.entity;
  872. $scope.selectButtonClick(data, event);
  873. };
  874. $scope.title = title;
  875. //树形图
  876. var apple_selected, tree, treedata_avm, treedata_geography;
  877. $scope.my_tree_handler = function (branch) {
  878. //var _ref;
  879. var classify = ($scope.classify =
  880. branch.prefix.toLowerCase() + branch.sign);
  881. api_cmdb
  882. .query({
  883. sign: classify,
  884. })
  885. .then(function (data) {
  886. var myDatalingbei = Restangular.stripRestangular(data);
  887. // console.log(myData.data.node);
  888. if (myDatalingbei.data && myDatalingbei.status == 200) {
  889. var ret = myDatalingbei.data;
  890. redrawSvg(myDatalingbei);
  891. }
  892. });
  893. };
  894. $scope.my_data = [];
  895. function convertListToTree(data, treeMap) {
  896. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  897. var root = null; //Initially set our loop to null
  898. var parentNode = null;
  899. //loop over data
  900. for (var i = 0; i < data.length; i++) {
  901. var datum = data[i];
  902. //each node will have children, so let's give it a "children" poperty
  903. datum.children = [];
  904. //add an entry for this node to the map so that any future children can
  905. //lookup the parent
  906. idToNodeMap[datum.id] = datum;
  907. //Does this node have a parent?
  908. if (
  909. typeof datum.parent === "undefined" ||
  910. datum.parent == null
  911. ) {
  912. //Doesn't look like it, so this node is the root of the tree
  913. root = datum;
  914. treeMap[datum.id] = root;
  915. } else {
  916. //This node has a parent, so let's look it up using the id
  917. parentNode = idToNodeMap[datum.parent.id];
  918. //We don't need this property, so let's delete it.
  919. delete datum.parent;
  920. //Let's add the current node as a child of the parent node.
  921. parentNode.children.push(datum);
  922. }
  923. }
  924. return root;
  925. }
  926. function convertParentToChildList(data) {
  927. var treeMap = {};
  928. var list = [];
  929. convertListToTree(data, treeMap);
  930. angular.forEach(treeMap, function (item) {
  931. list.push(item);
  932. });
  933. return list;
  934. }
  935. $scope.my_tree = tree = {};
  936. $scope.try_async_load = function () {
  937. $scope.my_data = [];
  938. $scope.select_treedata = [];
  939. $scope.doing_async = true;
  940. api_configure_data
  941. .fetchDataList("ciclassify", {
  942. idx: 0,
  943. sum: 100,
  944. })
  945. .then(function (result) {
  946. //console.log(result['list']);
  947. $scope.select_treedata = $scope.my_data =
  948. convertParentToChildList(result["list"]);
  949. $scope.doing_async = false;
  950. // tree.expand_all();
  951. //console.log(treelist);
  952. });
  953. };
  954. $scope.select_treedata = [];
  955. $scope.propTypeOptions = [];
  956. $scope.try_async_load();
  957. $scope.onFilterremove = function (item) {
  958. console.log(item);
  959. };
  960. $scope.searchdata = {};
  961. $scope.clear = function () {
  962. $scope.searchdata = {};
  963. $scope.cifilter_classic = {};
  964. $scope.try_async_load();
  965. var fildata = {
  966. idx: 0,
  967. sum: 10,
  968. hw_state: "在线",
  969. };
  970. $scope.memoryfilterData = fildata;
  971. $scope.refreshData("expand-right", fildata);
  972. };
  973. $scope.chiceIncident = function (item) {
  974. var fildata = $scope.memoryfilterData;
  975. // fildata.applicationForm = {};
  976. // if (item.alltitle && item.alldata) {
  977. // fildata.applicationForm[item.alltitle.key] = item.alldata
  978. // }
  979. if (item && item.id) {
  980. var classify = item.prefix.toLowerCase() + item.sign;
  981. fildata.sign = classify;
  982. }
  983. $scope.gridOptions.paginationCurrentPage = 1;
  984. var transitiondata = angular.copy(item);
  985. $scope.refreshData("expand-right", fildata);
  986. };
  987. $scope.applicadata = [];
  988. $scope.onFilterCallback = function (item) {
  989. var tempclassify = item.prefix.toLowerCase() + item.sign;
  990. api_configure_form
  991. .renderTabForm(tempclassify)
  992. .then(function (data) {
  993. var myData = Restangular.stripRestangular(data);
  994. $scope.applicadata = myData[0].form.fields;
  995. });
  996. // }
  997. };
  998. // $scope.loadData({
  999. // idx: 0,
  1000. // sum: 10,
  1001. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1002. // });
  1003. $scope.selected = {
  1004. items: [],
  1005. };
  1006. $scope.ok = function () {
  1007. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  1008. // onDataCallback($scope.selected.item, parentScope);
  1009. // }
  1010. $modalInstance.close($scope.selected.items);
  1011. };
  1012. $scope.cancel = function () {
  1013. $modalInstance.dismiss("cancel");
  1014. };
  1015. },
  1016. size: "lg",
  1017. resolve: {
  1018. items: function () {
  1019. return {
  1020. fetchItems: function (filterData, APIService) {
  1021. filterData = filterData || {};
  1022. if (
  1023. angular.isDefined(filterData.idx) &&
  1024. filterData.idx == null
  1025. ) {
  1026. filterData = {
  1027. idx: 0,
  1028. sum: 10,
  1029. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  1030. };
  1031. }
  1032. return $scope.options.templateOptions.fetchItems(
  1033. filterData,
  1034. APIService
  1035. );
  1036. },
  1037. };
  1038. },
  1039. title: function () {
  1040. return $scope.options.templateOptions.label;
  1041. },
  1042. Restangular: function () {
  1043. return $scope.options.templateOptions.Restangular;
  1044. },
  1045. APIService: function () {
  1046. return $scope.options.templateOptions.ApiService;
  1047. },
  1048. onDataCallback: function () {
  1049. return $scope.options.templateOptions.callback;
  1050. },
  1051. parentScope: function () {
  1052. return $scope.options.templateOptions.that;
  1053. },
  1054. },
  1055. });
  1056. modalInstance.result.then(function (selectedItem) {
  1057. $scope.myDatagridoldall = selectedItem;
  1058. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1059. $scope.myDatagridoldall[i]["item"] =
  1060. i +
  1061. 1 +
  1062. $scope.memoryfilterDatagridold.idx *
  1063. $scope.memoryfilterDatagridold.sum;
  1064. }
  1065. $scope.gridOptions2["totalItems"] = $scope.myDatagridoldall.length;
  1066. $scope.myDatagridold = $scope.interceptMydata(
  1067. $scope.myDatagridoldall,
  1068. 0,
  1069. 10
  1070. );
  1071. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1072. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1073. $scope.myDatagridoldall;
  1074. $scope.options.initialValue = $scope.model.oldAssets;
  1075. });
  1076. // }
  1077. };
  1078. $scope.changestate = function (itemin) {
  1079. event.preventDefault();
  1080. var modalInstance = $modal.open({
  1081. templateUrl: "assets/views/customform/tpl/cmdb/changeoldstate.html",
  1082. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1083. $scope.title = "旧设备状态修改";
  1084. $scope.stateshe = [
  1085. {
  1086. id: 2,
  1087. name: "在库",
  1088. },
  1089. {
  1090. id: 4,
  1091. name: "报修",
  1092. },
  1093. {
  1094. id: 3,
  1095. name: "报废",
  1096. },
  1097. ];
  1098. $scope.hw_state = {};
  1099. $scope.ok = function (item) {
  1100. $modalInstance.close(item.id);
  1101. };
  1102. $scope.cancel = function () {
  1103. $modalInstance.dismiss("cancel");
  1104. };
  1105. },
  1106. size: "sm",
  1107. resolve: {
  1108. scope: function () {
  1109. return $scope;
  1110. },
  1111. },
  1112. });
  1113. modalInstance.result.then(function (selectedItem) {
  1114. if (selectedItem) {
  1115. angular.forEach($scope.myDatagridallold, function (item, index) {
  1116. if (item.id == itemin.id) {
  1117. $scope.myDatagridallold[index].props.hw_state =
  1118. selectedItem.name;
  1119. }
  1120. });
  1121. for (var i = 0; i < $scope.myDatagridallold.length; i++) {
  1122. $scope.myDatagridallold[i]["item"] =
  1123. i +
  1124. 1 +
  1125. $scope.memoryfilterDatagridold.idx *
  1126. $scope.memoryfilterDatagridold.sum;
  1127. }
  1128. $scope.gridOptions2["totalItems"] =
  1129. $scope.myDatagridallold.length;
  1130. $scope.myDatagridold = $scope.interceptMydata(
  1131. $scope.myDatagridallold,
  1132. $scope.memoryfilterDatagridold.idx,
  1133. $scope.memoryfilterDatagridold.sum
  1134. );
  1135. // $scope.model.oldAssets = $scope.myDatagridallold;
  1136. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1137. $scope.myDatagridallold;
  1138. $scope.options.initialValue = $scope.model.oldAssets;
  1139. }
  1140. });
  1141. };
  1142. $scope.savedata = function (data) {
  1143. event.preventDefault();
  1144. var modalInstance = $modal.open({
  1145. templateUrl: "assets/views/customform/tpl/cmdb/changeoldshe.html",
  1146. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1147. $scope.title = "设备编辑";
  1148. // $scope.connect = '删除的数据不可恢复,请确认继续操作!';
  1149. $scope.ok = function (item) {
  1150. $modalInstance.close(item);
  1151. };
  1152. $scope.cancel = function () {
  1153. $modalInstance.dismiss("cancel");
  1154. };
  1155. },
  1156. size: "sm",
  1157. resolve: {
  1158. scope: function () {
  1159. return $scope;
  1160. },
  1161. },
  1162. });
  1163. modalInstance.result.then(function (selectedItem) {
  1164. if (selectedItem) {
  1165. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1166. if (item.id == data.id) {
  1167. $scope.myDatagridoldall[index].olddecription =
  1168. selectedItem.olddecription;
  1169. }
  1170. });
  1171. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1172. $scope.myDatagridoldall[i]["item"] =
  1173. i +
  1174. 1 +
  1175. $scope.memoryfilterDatagridold.idx *
  1176. $scope.memoryfilterDatagridold.sum;
  1177. }
  1178. $scope.gridOptions2["totalItems"] =
  1179. $scope.myDatagridoldall.length;
  1180. $scope.myDatagridold = $scope.interceptMydata(
  1181. $scope.myDatagridoldall,
  1182. 0,
  1183. 10
  1184. );
  1185. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1186. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1187. $scope.myDatagridoldall;
  1188. $scope.options.initialValue = $scope.model.oldAssets;
  1189. }
  1190. });
  1191. };
  1192. $scope.removeold = function (data) {
  1193. event.preventDefault();
  1194. var modalInstance = $modal.open({
  1195. templateUrl: "assets/views/delete.html",
  1196. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  1197. $scope.title = "设备删除";
  1198. $scope.connect = "删除的数据不可恢复,请确认继续操作!";
  1199. $scope.ok = function () {
  1200. $modalInstance.close(data);
  1201. };
  1202. $scope.cancel = function () {
  1203. $modalInstance.dismiss("cancel");
  1204. };
  1205. },
  1206. size: "sm",
  1207. resolve: {
  1208. scope: function () {
  1209. return $scope;
  1210. },
  1211. },
  1212. });
  1213. modalInstance.result.then(function (selectedItem) {
  1214. if (selectedItem) {
  1215. angular.forEach($scope.myDatagridoldall, function (item, index) {
  1216. if (item.id == selectedItem.id) {
  1217. $scope.myDatagridoldall.splice(index, 1);
  1218. }
  1219. });
  1220. for (var i = 0; i < $scope.myDatagridoldall.length; i++) {
  1221. $scope.myDatagridoldall[i]["item"] =
  1222. i +
  1223. 1 +
  1224. $scope.memoryfilterDatagridold.idx *
  1225. $scope.memoryfilterDatagridold.sum;
  1226. }
  1227. $scope.gridOptions2["totalItems"] =
  1228. $scope.myDatagridoldall.length;
  1229. $scope.myDatagridold = $scope.interceptMydata(
  1230. $scope.myDatagridoldall,
  1231. 0,
  1232. 10
  1233. );
  1234. // $scope.model.oldAssets = $scope.myDatagridoldall;
  1235. $scope.$parent.$parent.$parent.model.applicationForm.oldAssets =
  1236. $scope.myDatagridoldall;
  1237. $scope.options.initialValue = $scope.model.oldAssets;
  1238. }
  1239. });
  1240. };
  1241. },
  1242. ],
  1243. });
  1244. //ui-grid list
  1245. formlyConfigProvider.setType({
  1246. name: "ui-gridlist",
  1247. extends: "input",
  1248. templateUrl: "assets/views/customform/tpl/cmdb/gridlist.html",
  1249. defaultOptions: function (options, $scope) {
  1250. return {
  1251. templateOptions: {},
  1252. };
  1253. },
  1254. controller: [
  1255. "$scope",
  1256. "$modal",
  1257. "i18nService",
  1258. "SweetAlert",
  1259. function ($scope, $modal, i18nService, SweetAlert) {
  1260. //gridone
  1261. $scope.langs = i18nService.getAllLangs();
  1262. $scope.lang = "zh-cn";
  1263. i18nService.setCurrentLang($scope.lang);
  1264. $scope.gridOptions = {};
  1265. $scope.gridOptions.data = "myDatagrid";
  1266. $scope.gridOptions.enableColumnResizing = true;
  1267. $scope.gridOptions.enableFiltering = true;
  1268. $scope.gridOptions.enableGridMenu = false;
  1269. $scope.gridOptions.enableRowSelection = true;
  1270. $scope.gridOptions.showGridFooter = true;
  1271. $scope.gridOptions.showColumnFooter = false;
  1272. $scope.gridOptions.fastWatch = true;
  1273. $scope.gridOptions.useExternalFiltering = false;
  1274. // $scope.gridOptions.useExternalPagination = true;
  1275. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1276. $scope.gridOptions.paginationPageSize = 10;
  1277. $scope.gridOptions.multiSelect = false;
  1278. $scope.myDatagrid = [];
  1279. $scope.myDatagridall = [];
  1280. $scope.selected = {
  1281. item: {},
  1282. };
  1283. $scope.memoryfilterDatagrid = {
  1284. idx: 0,
  1285. sum: 10,
  1286. };
  1287. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  1288. filterData = {
  1289. idx: 0,
  1290. sum: 10,
  1291. };
  1292. $scope.gridOptions.columnDefs =
  1293. $scope.options.templateOptions.columnDefs;
  1294. }
  1295. $scope.gridOptions.rowIdentity = function (row) {
  1296. return row.id;
  1297. };
  1298. $scope.gridOptions.getRowIdentity = function (row) {
  1299. return row.id;
  1300. };
  1301. // $scope.gridOptions.columnDefs = items.columnDefs();
  1302. $scope.interceptMydata = function (mydate, idx, sum) {
  1303. return mydate.slice(idx * sum, (idx + 1) * sum);
  1304. };
  1305. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1306. $scope.gridApi = gridApi;
  1307. gridApi.pagination.on.paginationChanged(
  1308. $scope,
  1309. function (newPage, pageSize) {
  1310. $scope.memoryfilterDatagrid.idx = newPage - 1;
  1311. $scope.memoryfilterDatagrid.sum = pageSize;
  1312. $scope.myDatagrid = $scope.interceptMydata(
  1313. $scope.myDatagridall,
  1314. $scope.memoryfilterDatagrid.idx,
  1315. 10
  1316. );
  1317. $scope.loadData({
  1318. idx: newPage - 1,
  1319. sum: pageSize,
  1320. });
  1321. }
  1322. );
  1323. gridApi.core.on.filterChanged($scope, function () { });
  1324. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  1325. $scope.selected.item = data.entity;
  1326. //console.log(data);
  1327. });
  1328. };
  1329. $scope.loadData = function (mydate, idx, sum) {
  1330. angular.forEach($scope.myDatagrid, function (item, index) {
  1331. $scope.myDatagrid[index].item = index;
  1332. });
  1333. $scope.myDatagrid = mydate.slice(idx * sum, (idx + 1) * sum);
  1334. };
  1335. if ($scope.model.assets) {
  1336. $scope.myDatagridall = $scope.model.assets;
  1337. $scope.loadData($scope.model.assets, 0, 10);
  1338. }
  1339. $scope.saveData = function (itemin) {
  1340. event.preventDefault();
  1341. var modalInstance = $modal.open({
  1342. templateUrl: "assets/views/customform/tpl/cmdb/lingyonglist.html",
  1343. controller: function ($scope, $modalInstance, SweetAlert) {
  1344. // $scope.consumptive = {};
  1345. $scope.title = "填写领用设备信息";
  1346. // if (items.name) {
  1347. // $scope.consumptive.name = items.name.name;
  1348. // }
  1349. $scope.placechange = angular.copy(itemin);
  1350. $scope.ok = function (item) {
  1351. if (
  1352. item.props &&
  1353. item.props.hwnw_area &&
  1354. item.props.hwnw_place &&
  1355. item.props.hwnw_room &&
  1356. item.props.hwnwswt_jiguihao &&
  1357. item.props.hwnwswt_Ushu &&
  1358. item.props.snnum
  1359. ) {
  1360. $modalInstance.close(item);
  1361. } else {
  1362. SweetAlert.swal({
  1363. title: "数据填写不完整!",
  1364. text: "请检查数据然后提交!",
  1365. type: "error",
  1366. });
  1367. }
  1368. };
  1369. $scope.cancel = function () {
  1370. $modalInstance.dismiss("cancel");
  1371. };
  1372. },
  1373. resolve: {
  1374. SweetAlert: function () {
  1375. return SweetAlert;
  1376. },
  1377. },
  1378. });
  1379. modalInstance.result.then(function (selectedItem) {
  1380. angular.forEach($scope.myDatagrid, function (item, index) {
  1381. if (item.id == selectedItem.id) {
  1382. angular.extend($scope.myDatagrid[index], selectedItem);
  1383. }
  1384. });
  1385. // $scope.myData3.push(selectedItem);
  1386. for (var i = 0; i < $scope.myDatagrid.length; i++) {
  1387. $scope.myDatagrid[i]["item"] =
  1388. i + 1 + $scope.memoryfilterDatagrid.idx * 10;
  1389. }
  1390. // $scope.model.assets = $scope.myDatagridall;
  1391. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1392. $scope.myDatagridall;
  1393. });
  1394. };
  1395. },
  1396. ],
  1397. });
  1398. //设备耗材list组件
  1399. formlyConfigProvider.setType({
  1400. name: "ui-shehaolist",
  1401. // extends: 'radio',
  1402. templateUrl: "assets/views/customform/tpl/cmdb/shehaolist.html",
  1403. defaultOptions: function (options) {
  1404. return {
  1405. templateOptions: {
  1406. refresh: function () { },
  1407. refreshDelay: 0,
  1408. },
  1409. };
  1410. },
  1411. controller: [
  1412. "$scope",
  1413. "$filter",
  1414. "ngTableParams",
  1415. function ($scope, $filter, ngTableParams) {
  1416. // var data = { "haodata": [], "shedata": [] };
  1417. var haodata = [];
  1418. var shedata = [];
  1419. if ($scope.model.consumables) {
  1420. if (angular.isArray($scope.model.consumables)) {
  1421. haodata = $scope.model.consumables;
  1422. } else {
  1423. haodata = JSON.parse($scope.model.consumables);
  1424. }
  1425. $scope.model.consumables = haodata;
  1426. angular.forEach(haodata, function (item, index) {
  1427. haodata[index].item = index + 1;
  1428. });
  1429. }
  1430. if ($scope.model.assets) {
  1431. if (angular.isArray($scope.model.assets)) {
  1432. shedata = $scope.model.assets;
  1433. } else {
  1434. shedata = JSON.parse($scope.model.assets);
  1435. }
  1436. $scope.model.assets = shedata;
  1437. angular.forEach(shedata, function (item, index) {
  1438. shedata[index].item = index + 1;
  1439. });
  1440. }
  1441. $scope.tableParamshao = new ngTableParams(
  1442. {
  1443. page: 1,
  1444. count: 5,
  1445. },
  1446. {
  1447. total: haodata.length,
  1448. getData: function ($defer, params) {
  1449. var orderedData = params.sorting()
  1450. ? $filter("orderBy")(haodata, params.orderBy())
  1451. : haodata;
  1452. $defer.resolve(
  1453. orderedData.slice(
  1454. (params.page() - 1) * params.count(),
  1455. params.page() * params.count()
  1456. )
  1457. );
  1458. },
  1459. }
  1460. );
  1461. $scope.tableParamsshe = new ngTableParams(
  1462. {
  1463. page: 1,
  1464. count: 5,
  1465. },
  1466. {
  1467. total: shedata.length,
  1468. getData: function ($defer, params) {
  1469. var orderedData = params.sorting()
  1470. ? $filter("orderBy")(shedata, params.orderBy())
  1471. : shedata;
  1472. $defer.resolve(
  1473. orderedData.slice(
  1474. (params.page() - 1) * params.count(),
  1475. params.page() * params.count()
  1476. )
  1477. );
  1478. },
  1479. }
  1480. );
  1481. $scope.editId = -1;
  1482. $scope.setEditId = function (pid) {
  1483. $scope.editId = pid;
  1484. };
  1485. if (
  1486. $scope.$parent.$parent.$parent.model.isAgree &&
  1487. $scope.$parent.$parent.$parent.model.isAgree == "2"
  1488. ) {
  1489. $scope.isAgree = "同意";
  1490. } else if (
  1491. $scope.$parent.$parent.$parent.model.isAgree &&
  1492. $scope.$parent.$parent.$parent.model.isAgree == "1"
  1493. ) {
  1494. $scope.isAgree = "同意";
  1495. } else if (
  1496. $scope.$parent.$parent.$parent.model.isAgree &&
  1497. $scope.$parent.$parent.$parent.model.isAgree == "3"
  1498. ) {
  1499. $scope.isAgree = "返回修改";
  1500. }
  1501. },
  1502. ],
  1503. });
  1504. //关联资产出库
  1505. formlyConfigProvider.setType({
  1506. name: "ui-meansmodelselect",
  1507. extends: "input",
  1508. templateUrl: "assets/views/customform/tpl/cmdb/inputguanlina.html",
  1509. defaultOptions: function (options) {
  1510. return {
  1511. templateOptions: {},
  1512. };
  1513. },
  1514. controller: [
  1515. "$scope",
  1516. "$modal",
  1517. function ($scope, $modal) {
  1518. $scope.openModal = function (size, options, modal) {
  1519. var modalInstance = $modal.open({
  1520. templateUrl: "assets/views/customform/tpl/cmdb/guanlian.html",
  1521. controller: function (
  1522. $scope,
  1523. $rootScope,
  1524. $modalInstance,
  1525. items,
  1526. title,
  1527. Restangular,
  1528. APIService,
  1529. api_user_data,
  1530. i18nService,
  1531. api_wechatfile
  1532. ) {
  1533. $scope.langs = i18nService.getAllLangs();
  1534. $scope.lang = "zh-cn";
  1535. i18nService.setCurrentLang($scope.lang);
  1536. $scope.gridOptions = {};
  1537. $scope.gridOptions.data = "myData";
  1538. $scope.gridOptions.enableColumnResizing = true;
  1539. $scope.gridOptions.enableFiltering = false;
  1540. $scope.gridOptions.enableGridMenu = false;
  1541. $scope.gridOptions.showGridFooter = true;
  1542. $scope.gridOptions.showColumnFooter = false;
  1543. $scope.gridOptions.fastWatch = true;
  1544. $scope.gridOptions.useExternalFiltering = true;
  1545. $scope.gridOptions.useExternalPagination = true;
  1546. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  1547. $scope.gridOptions.paginationPageSize = 10;
  1548. $scope.gridOptions.multiSelect = false;
  1549. $scope.gridOptions.rowIdentity = function (row) {
  1550. return row.id;
  1551. };
  1552. $scope.gridOptions.getRowIdentity = function (row) {
  1553. return row.id;
  1554. };
  1555. // $scope.states = [{
  1556. // id: 0,
  1557. // name: '待批准'
  1558. // },
  1559. // {
  1560. // id: 1,
  1561. // name: '已驳回'
  1562. // },
  1563. // {
  1564. // id: 2,
  1565. // name: '待出库'
  1566. // },
  1567. // {
  1568. // id: 3,
  1569. // name: '信息更新'
  1570. // },
  1571. // {
  1572. // id: 4,
  1573. // name: '信息确认'
  1574. // },
  1575. // {
  1576. // id: 5,
  1577. // name: '已关闭'
  1578. // }
  1579. // ];
  1580. $scope.getStatesDictionary = function () {
  1581. var data = {
  1582. key: "applicationForm_status",
  1583. type: "list",
  1584. };
  1585. api_wechatfile.getDictionary(data).then(function (res) {
  1586. $scope.states = res;
  1587. });
  1588. };
  1589. $scope.getStatesDictionary();
  1590. $scope.type = [
  1591. {
  1592. id: 1,
  1593. name: "资产入库",
  1594. },
  1595. {
  1596. id: 2,
  1597. name: "资产归还",
  1598. },
  1599. {
  1600. id: 3,
  1601. name: "资产领用",
  1602. },
  1603. {
  1604. id: 4,
  1605. name: "资产更换",
  1606. },
  1607. ];
  1608. $scope.typedata = function (row) {
  1609. if (row.type == 0) {
  1610. return "资产入库";
  1611. } else if (row.type == 2) {
  1612. return "资产归还";
  1613. } else if (row.type == 1) {
  1614. return "资产领用";
  1615. } else if (row.type == 4) {
  1616. return "资产更换";
  1617. }
  1618. };
  1619. $scope.statedata = function (row) {
  1620. if (row.status == 0) {
  1621. return "待批准";
  1622. } else if (row.status == 1) {
  1623. return "已驳回";
  1624. } else if (row.status == 2) {
  1625. return "待出库";
  1626. } else if (row.status == 3) {
  1627. return "信息更新";
  1628. } else if (row.status == 4) {
  1629. return "信息确认";
  1630. } else if (row.status == 5) {
  1631. return "已关闭";
  1632. }
  1633. };
  1634. $scope.transferTime = function (time) {
  1635. return moment(time).format("YYYY-MM-DD HH:mm");
  1636. };
  1637. $scope.application = [
  1638. {
  1639. value: "serialNumbe",
  1640. name: "申请单编号",
  1641. },
  1642. // { value: "proposer", name: '申请人' },
  1643. {
  1644. value: "purpose",
  1645. name: "领用用途",
  1646. },
  1647. // { value: "cmdbsign", name: '设备编号' }
  1648. ];
  1649. $scope.parameters = null;
  1650. $scope.open = function ($event) {
  1651. $event.preventDefault();
  1652. $event.stopPropagation();
  1653. $scope.opened = !$scope.opened;
  1654. };
  1655. $scope.endOpen = function ($event) {
  1656. $event.preventDefault();
  1657. $event.stopPropagation();
  1658. $scope.startOpened = false;
  1659. $scope.endOpened = !$scope.endOpened;
  1660. };
  1661. $scope.startOpen = function ($event) {
  1662. $event.preventDefault();
  1663. $event.stopPropagation();
  1664. $scope.endOpened = false;
  1665. $scope.startOpened = !$scope.startOpened;
  1666. };
  1667. $scope.othcode = {};
  1668. $scope.searchkeys = {};
  1669. $scope.parameters = {};
  1670. $scope.memoryfilterData = {
  1671. assignee: $rootScope.user.id,
  1672. candidateGroups: $rootScope.user.group[0].id,
  1673. searchType: "todo",
  1674. idx: 0,
  1675. sum: 10,
  1676. };
  1677. $scope.clear = function () {
  1678. $scope.searchkeys = {};
  1679. // $scope.searchstate = JSON.parse(sessionStorage.getItem("searchincident")).searchType;
  1680. // $scope.othcode = {};
  1681. $scope.parameters = {};
  1682. var fildata = {
  1683. assignee: $rootScope.user.id,
  1684. candidateGroups: $rootScope.user.group[0].id,
  1685. searchType: "todo",
  1686. idx: 0,
  1687. sum: 10,
  1688. };
  1689. // sessionStorage.removeItem("searchincident");
  1690. $scope.memoryfilterData = fildata;
  1691. $scope.loadData(fildata);
  1692. };
  1693. $scope.chiceIncident = function (parameters, item, stateid) {
  1694. var fildata = {
  1695. assignee: $rootScope.user.id,
  1696. candidateGroups: 1,
  1697. searchType: "todo",
  1698. idx: 0,
  1699. sum: 10,
  1700. };
  1701. if (item) {
  1702. fildata.applicationForm = {};
  1703. if (item.alltitle && item.alldata) {
  1704. fildata.applicationForm[item.alltitle.value] = item.alldata;
  1705. }
  1706. if (item.linkProposer) {
  1707. fildata.applicationForm.linkProposer = item.linkProposer;
  1708. }
  1709. if (item.proposer) {
  1710. fildata.applicationForm.proposer = item.proposer;
  1711. }
  1712. if (item.status) {
  1713. fildata.applicationForm["status"] = {
  1714. id: item.status.id,
  1715. };
  1716. }
  1717. if (item.type) {
  1718. fildata.applicationForm["type"] = {
  1719. id: item.type.id,
  1720. };
  1721. }
  1722. }
  1723. $scope.gridOptions.paginationCurrentPage = 1;
  1724. if (
  1725. parameters &&
  1726. parameters.paramDateFrom &&
  1727. parameters.paramDateTo
  1728. ) {
  1729. angular.extend(fildata, {
  1730. idx: 0,
  1731. sum: $scope.gridOptions.paginationPageSize,
  1732. });
  1733. angular.extend(fildata.applicationForm, {
  1734. startDate: moment(parameters.paramDateFrom).format(
  1735. "YYYY-MM-DD HH:mm:ss"
  1736. ),
  1737. endDate: moment(parameters.paramDateTo).format(
  1738. "YYYY-MM-DD 23:59:59"
  1739. ),
  1740. });
  1741. }
  1742. var transitiondata = angular.copy(item);
  1743. // angular.extend(fildata.applicationForm, transitiondata)
  1744. $scope.loadData(fildata);
  1745. };
  1746. $scope.key = {};
  1747. api_user_data
  1748. .fetchDataList("user", {
  1749. idx: 0,
  1750. sum: 1000,
  1751. flag: -1,
  1752. })
  1753. .then(function (data) {
  1754. $scope.handlingPersonnelUser = data.list;
  1755. });
  1756. $scope.gridOptions.columnDefs = items.columnDefs();
  1757. $scope.gridOptions.onRegisterApi = function (gridApi) {
  1758. $scope.gridApi = gridApi;
  1759. gridApi.pagination.on.paginationChanged(
  1760. $scope,
  1761. function (newPage, pageSize) {
  1762. // console.log(newPage);
  1763. // console.log(pageSize);
  1764. $scope.loadData({
  1765. idx: newPage - 1,
  1766. sum: pageSize,
  1767. });
  1768. }
  1769. );
  1770. gridApi.core.on.filterChanged($scope, function () { });
  1771. gridApi.selection.on.rowSelectionChanged(
  1772. $scope,
  1773. function (data) {
  1774. $scope.selected.item = data.entity;
  1775. //console.log(data);
  1776. }
  1777. );
  1778. };
  1779. $scope.loadData = function (filterData) {
  1780. items.fetchItems(filterData, APIService).then(function (data) {
  1781. var myData = Restangular.stripRestangular(data);
  1782. $scope.gridOptions.totalItems = myData.totalNum;
  1783. $scope.myData = myData.list;
  1784. for (var i = 0; i < $scope.myData.length; i++) {
  1785. $scope.myData[i]["item"] =
  1786. i + 1 + filterData.idx * filterData.sum;
  1787. }
  1788. });
  1789. };
  1790. $scope.title = title;
  1791. $scope.loadData({
  1792. idx: 0,
  1793. sum: 10,
  1794. assignee: $rootScope.user.id,
  1795. candidateGroups: $rootScope.user.group[0].id,
  1796. searchType: "todo",
  1797. });
  1798. $scope.selected = {
  1799. item: {},
  1800. };
  1801. $scope.ok = function () {
  1802. //console.log($scope.selected.item);
  1803. $modalInstance.close($scope.selected.item);
  1804. };
  1805. $scope.cancel = function () {
  1806. $modalInstance.dismiss("cancel");
  1807. };
  1808. },
  1809. size: "lg",
  1810. resolve: {
  1811. items: function () {
  1812. return {
  1813. fetchItems: function (filterData, APIService) {
  1814. filterData = filterData || {};
  1815. // if(!filterData.idx){
  1816. if (
  1817. angular.isDefined(filterData.idx) &&
  1818. filterData.idx == null
  1819. ) {
  1820. filterData = {
  1821. idx: 0,
  1822. sum: 10,
  1823. };
  1824. }
  1825. return options.templateOptions.fetchItems(
  1826. filterData,
  1827. APIService,
  1828. options
  1829. );
  1830. },
  1831. columnDefs: function () {
  1832. return options.templateOptions.columnDefs;
  1833. },
  1834. };
  1835. },
  1836. title: function () {
  1837. return options.templateOptions.modalTitle;
  1838. },
  1839. Restangular: function () {
  1840. return options.templateOptions.Restangular;
  1841. },
  1842. APIService: function () {
  1843. return options.templateOptions.ApiService;
  1844. },
  1845. },
  1846. });
  1847. modalInstance.result.then(
  1848. function (selectedItem) {
  1849. var selectitem = {
  1850. title: selectedItem.title,
  1851. description: selectedItem.description,
  1852. };
  1853. if (options.key == "chuku") {
  1854. if (selectedItem.assets) {
  1855. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  1856. selectedItem.assets;
  1857. }
  1858. if (selectedItem.consumables) {
  1859. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  1860. selectedItem.consumables;
  1861. }
  1862. angular.extend(
  1863. $scope.$parent.$parent.$parent.model,
  1864. selectitem
  1865. );
  1866. options.value(selectedItem);
  1867. // options.model.consumables = JSON.parse(selectedItem.consumables);
  1868. } else {
  1869. angular.extend(options.model, selectitem);
  1870. options.value(selectedItem);
  1871. }
  1872. },
  1873. function () {
  1874. //console.log('Modal dismissed at: ' + new Date());
  1875. }
  1876. );
  1877. };
  1878. },
  1879. ],
  1880. });
  1881. //文本框
  1882. formlyConfigProvider.setType({
  1883. name: "ui-textcmdb",
  1884. extends: "",
  1885. templateUrl: "assets/views/customform/tpl/cmdb/ui-textcmdb.html",
  1886. defaultOptions: function (options) {
  1887. return {
  1888. templateOptions: {
  1889. transform: function (model, value) {
  1890. return value;
  1891. },
  1892. },
  1893. validation: {
  1894. messages: {
  1895. maxlength: function (viewValue, modelValue, scope) {
  1896. if (viewValue != null) {
  1897. if (viewValue.length > scope.to.maxlength) {
  1898. return (
  1899. scope.to.label +
  1900. " 字数(" +
  1901. viewValue.length +
  1902. ")超限(" +
  1903. scope.to.maxlength +
  1904. ")"
  1905. );
  1906. } else {
  1907. return "";
  1908. }
  1909. }
  1910. },
  1911. },
  1912. },
  1913. };
  1914. },
  1915. controller: [
  1916. "$scope",
  1917. function ($scope) {
  1918. var value = $scope.model[$scope.options.key];
  1919. if (angular.isFunction($scope.options.templateOptions.transform)) {
  1920. $scope.model[$scope.options.key] =
  1921. $scope.options.templateOptions.transform(
  1922. $scope.originalModel,
  1923. value
  1924. );
  1925. }
  1926. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  1927. $scope.options.templateOptions.felditem($scope);
  1928. }
  1929. },
  1930. ],
  1931. });
  1932. //设备组件
  1933. formlyConfigProvider.setType({
  1934. name: "ui-applist",
  1935. extends: "radio",
  1936. templateUrl: "assets/views/customform/tpl/cmdb/applist.html",
  1937. defaultOptions: function (options) {
  1938. return {
  1939. templateOptions: {
  1940. refresh: function () { },
  1941. refreshDelay: 0,
  1942. },
  1943. };
  1944. },
  1945. controller: [
  1946. "$scope",
  1947. "$filter",
  1948. "ngTableParams",
  1949. function ($scope, $filter, ngTableParams) {
  1950. var data = [];
  1951. if ($scope.model.consumables && $scope.options.key == "consumables") {
  1952. // data = JSON.parse($scope.model.consumables);
  1953. if (angular.isArray($scope.model.consumables)) {
  1954. data = $scope.model.consumables;
  1955. } else {
  1956. data = JSON.parse($scope.model.consumables);
  1957. }
  1958. $scope.model.consumables = data;
  1959. angular.forEach(data, function (item, index) {
  1960. data[index].item = index + 1;
  1961. });
  1962. }
  1963. if ($scope.model.assets && $scope.options.key == "assets") {
  1964. if (angular.isArray($scope.model.assets)) {
  1965. data = $scope.model.assets;
  1966. } else {
  1967. data = JSON.parse($scope.model.assets);
  1968. }
  1969. // data = JSON.parse($scope.model.assets);
  1970. $scope.model.assets = data;
  1971. angular.forEach(data, function (item, index) {
  1972. data[index].item = index + 1;
  1973. });
  1974. }
  1975. $scope.tableParams = new ngTableParams(
  1976. {
  1977. page: 1,
  1978. count: 5,
  1979. },
  1980. {
  1981. total: data.length,
  1982. getData: function ($defer, params) {
  1983. var orderedData = params.sorting()
  1984. ? $filter("orderBy")(data, params.orderBy())
  1985. : data;
  1986. $defer.resolve(
  1987. orderedData.slice(
  1988. (params.page() - 1) * params.count(),
  1989. params.page() * params.count()
  1990. )
  1991. );
  1992. },
  1993. }
  1994. );
  1995. $scope.editId = -1;
  1996. $scope.setEditId = function (pid) {
  1997. $scope.editId = pid;
  1998. };
  1999. },
  2000. ],
  2001. });
  2002. //list组件
  2003. formlyConfigProvider.setType({
  2004. name: "ui-gudinglist",
  2005. extends: "radio",
  2006. templateUrl: "assets/views/customform/tpl/cmdb/gudinglist.html",
  2007. defaultOptions: function (options) {
  2008. return {
  2009. templateOptions: {
  2010. refresh: function () { },
  2011. refreshDelay: 0,
  2012. },
  2013. };
  2014. },
  2015. controller: [
  2016. "$scope",
  2017. "$filter",
  2018. "ngTableParams",
  2019. function ($scope, $filter, ngTableParams) {
  2020. var data = [];
  2021. if ($scope.model.consumables && $scope.options.key == "consumables") {
  2022. // data = JSON.parse($scope.model.consumables);
  2023. if (angular.isArray($scope.model.consumables)) {
  2024. data = $scope.model.consumables;
  2025. } else {
  2026. data = JSON.parse($scope.model.consumables);
  2027. }
  2028. $scope.model.consumables = data;
  2029. angular.forEach(data, function (item, index) {
  2030. data[index].item = index + 1;
  2031. });
  2032. }
  2033. if ($scope.model.assets && $scope.options.key == "assets") {
  2034. if (angular.isArray($scope.model.assets)) {
  2035. data = $scope.model.assets;
  2036. } else {
  2037. data = JSON.parse($scope.model.assets);
  2038. }
  2039. // data = JSON.parse($scope.model.assets);
  2040. $scope.model.assets = data;
  2041. angular.forEach(data, function (item, index) {
  2042. data[index].item = index + 1;
  2043. });
  2044. }
  2045. $scope.tableParams = new ngTableParams(
  2046. {
  2047. page: 1,
  2048. count: 5,
  2049. },
  2050. {
  2051. total: data.length,
  2052. getData: function ($defer, params) {
  2053. var orderedData = params.sorting()
  2054. ? $filter("orderBy")(data, params.orderBy())
  2055. : data;
  2056. $defer.resolve(
  2057. orderedData.slice(
  2058. (params.page() - 1) * params.count(),
  2059. params.page() * params.count()
  2060. )
  2061. );
  2062. },
  2063. }
  2064. );
  2065. $scope.editId = -1;
  2066. $scope.setEditId = function (pid) {
  2067. $scope.editId = pid;
  2068. };
  2069. },
  2070. ],
  2071. });
  2072. //other list tab组件
  2073. formlyConfigProvider.setType({
  2074. name: "ui-otherlisttab",
  2075. extends: "",
  2076. templateUrl: "assets/views/customform/tpl/cmdb/otherlisttab.html",
  2077. defaultOptions: function (options) {
  2078. return {
  2079. templateOptions: {
  2080. refresh: function () { },
  2081. refreshDelay: 0,
  2082. },
  2083. };
  2084. },
  2085. controller: [
  2086. "$scope",
  2087. "$filter",
  2088. "ngTableParams",
  2089. function ($scope, $filter, ngTableParams) { },
  2090. ],
  2091. });
  2092. //审核查看组件
  2093. formlyConfigProvider.setType({
  2094. name: "ui-aprovelist",
  2095. extends: "",
  2096. templateUrl: "assets/views/customform/tpl/cmdb/aprovelist.html",
  2097. defaultOptions: function (options) {
  2098. return {
  2099. templateOptions: {
  2100. refresh: function () { },
  2101. refreshDelay: 0,
  2102. },
  2103. };
  2104. },
  2105. controller: [
  2106. "$scope",
  2107. "$filter",
  2108. "ngTableParams",
  2109. function ($scope, $filter, ngTableParams) {
  2110. if ($scope.model.isAgree && $scope.model.isAgree == "2") {
  2111. $scope.isAgree = "同意";
  2112. } else if ($scope.model.isAgree && $scope.model.isAgree == "1") {
  2113. $scope.isAgree = "同意";
  2114. } else if ($scope.model.isAgree && $scope.model.isAgree == "3") {
  2115. $scope.isAgree = "返回修改";
  2116. }
  2117. },
  2118. ],
  2119. });
  2120. //other list组件
  2121. formlyConfigProvider.setType({
  2122. name: "ui-otherlist",
  2123. extends: "",
  2124. templateUrl: "assets/views/customform/tpl/cmdb/otherlist.html",
  2125. defaultOptions: function (options) {
  2126. return {
  2127. templateOptions: {
  2128. refresh: function () { },
  2129. refreshDelay: 0,
  2130. },
  2131. };
  2132. },
  2133. controller: [
  2134. "$rootScope",
  2135. "$scope",
  2136. "$parse",
  2137. "$injector",
  2138. "$http",
  2139. "$q",
  2140. "$state",
  2141. "$stateParams",
  2142. "$modal",
  2143. "$timeout",
  2144. "$interval",
  2145. "i18nService",
  2146. "SweetAlert",
  2147. "FileUploader",
  2148. "Restangular",
  2149. "UserRestangular",
  2150. "BpmRestangular",
  2151. "api_configure_form",
  2152. "api_configure_data",
  2153. "api_bpm_domain",
  2154. "api_bpm_data",
  2155. "api_user_data",
  2156. "api_cmdb",
  2157. "api_sysinfo",
  2158. function (
  2159. $rootScope,
  2160. $scope,
  2161. $parse,
  2162. $injector,
  2163. $http,
  2164. $q,
  2165. $state,
  2166. $stateParams,
  2167. $modal,
  2168. $timeout,
  2169. $interval,
  2170. i18nService,
  2171. SweetAlert,
  2172. FileUploader,
  2173. Restangular,
  2174. UserRestangular,
  2175. BpmRestangular,
  2176. api_configure_form,
  2177. api_configure_data,
  2178. api_bpm_domain,
  2179. api_bpm_data,
  2180. api_user_data,
  2181. api_cmdb,
  2182. api_sysinfo
  2183. ) {
  2184. console.log("哈哈");
  2185. console.log($scope);
  2186. $scope.langs = i18nService.getAllLangs();
  2187. $scope.lang = "zh-cn";
  2188. i18nService.setCurrentLang($scope.lang);
  2189. var vm = this;
  2190. vm.options = {};
  2191. vm.exampleTitle = ["expressionProperties", "model property"];
  2192. vm.fields = [];
  2193. vm.models = {};
  2194. // vm.models["loginUser"] = $rootScope.user;
  2195. var that = $injector;
  2196. var parse = $parse;
  2197. var formKey = "";
  2198. var pdKey = "";
  2199. if (
  2200. angular.isDefined($state.current.pdKey) &&
  2201. $state.current.pdKey != ""
  2202. ) {
  2203. pdKey = $state.current.pdKey;
  2204. //console.log("pdKey::"+$state.current.pdKey);
  2205. }
  2206. if (
  2207. angular.isDefined($stateParams.formKey) &&
  2208. $stateParams.formKey != ""
  2209. ) {
  2210. formKey = $stateParams.formKey;
  2211. //console.log("formKey::"+$stateParams.formKey);
  2212. }
  2213. //用户测试数据,后续从header的auth中获取
  2214. var userId = 2;
  2215. userId = $rootScope.user.id;
  2216. //==============处理表单设计数据 开始====================
  2217. //处理组件加载后台数据选项的方法
  2218. function refreshSelectOptions(searchVal, field) {
  2219. if (field.templateOptions.optionsUrl) {
  2220. var process = BpmRestangular.all("");
  2221. if (field.templateOptions.ApiService) {
  2222. process = UserRestangular.all("");
  2223. }
  2224. process
  2225. .customPOST(
  2226. {
  2227. idx: 0,
  2228. sum: 1000,
  2229. },
  2230. field.templateOptions.optionsUrl
  2231. )
  2232. .then(function (result) {
  2233. if (!field.templateOptions.options) {
  2234. field.templateOptions.options = [];
  2235. }
  2236. if (field.templateOptions.optionsDataKey) {
  2237. field.templateOptions.options =
  2238. result[field.templateOptions.optionsDataKey];
  2239. } else {
  2240. field.templateOptions.options = result;
  2241. }
  2242. });
  2243. }
  2244. }
  2245. function decodeVMTabForm(model, tabs) {
  2246. var result = {
  2247. model: {},
  2248. tabs: [],
  2249. };
  2250. var mdata = angular.fromJson(model);
  2251. angular.extend(result.model, mdata);
  2252. angular.forEach(tabs, function (tab) {
  2253. tab.form.model = vm.models;
  2254. angular.forEach(tab.form.fields, function (field) {
  2255. if (field.key == "") {
  2256. delete field.key;
  2257. }
  2258. field.type = "ui-otherlisttab";
  2259. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2260. var extObj = angular.fromJson(field.extjson);
  2261. angular.extend(field.templateOptions, extObj.templateOptions);
  2262. delete extObj.templateOptions;
  2263. for (var prop in extObj) {
  2264. if (new RegExp("Expression").test(prop)) {
  2265. //var obj = $scope.$eval(extObj[prop]);
  2266. //extObj[prop] = $scope.$eval(extObj[prop]);
  2267. if (extObj[prop] != null) {
  2268. if (new RegExp("function").test(extObj[prop])) {
  2269. var propValue = eval(extObj[prop]);
  2270. extObj[prop] = propValue;
  2271. } else {
  2272. //console.log(extObj[prop]);
  2273. var obj = $scope.$eval(extObj[prop]);
  2274. extObj[prop] = obj;
  2275. //console.log(obj);
  2276. }
  2277. }
  2278. } else if (new RegExp("expressionProperties").test(prop)) {
  2279. for (var p in extObj[prop]) {
  2280. if (new RegExp("function").test(extObj[prop][p])) {
  2281. var propValue = eval(extObj[prop][p]);
  2282. extObj[prop][p] = propValue;
  2283. } else {
  2284. //if(p.indexOf("'")>=0){
  2285. // var obj = $scope.$eval(extObj[prop][p]);
  2286. // extObj[prop][$scope.$eval(p)]=obj;
  2287. //}
  2288. }
  2289. }
  2290. } else if ("watcher" == prop) {
  2291. if (angular.isArray(extObj[prop])) {
  2292. angular.forEach(extObj[prop], function (item, index) {
  2293. for (var p in item) {
  2294. if (new RegExp("function").test(item[p])) {
  2295. var propValue = eval(item[p]);
  2296. extObj[prop][index][p] = propValue;
  2297. }
  2298. }
  2299. });
  2300. } else if (angular.isObject(extObj[prop])) {
  2301. for (var p in extObj[prop]) {
  2302. if (new RegExp("function").test(extObj[prop][p])) {
  2303. var propValue = eval(extObj[prop][p]);
  2304. extObj[prop][p] = propValue;
  2305. }
  2306. }
  2307. }
  2308. }
  2309. }
  2310. angular.extend(field, extObj);
  2311. delete field.extjson;
  2312. }
  2313. if (field.extjson == "") {
  2314. delete field.extjson;
  2315. }
  2316. if (angular.isDefined(field.templateOptions)) {
  2317. var templateOs = field.templateOptions;
  2318. for (var property in templateOs) {
  2319. //console.log(property);
  2320. if (
  2321. angular.isString(templateOs[property]) &&
  2322. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2323. ) {
  2324. if (new RegExp("function").test(templateOs[property])) {
  2325. var propValue = eval(templateOs[property]);
  2326. field.templateOptions[property] = propValue;
  2327. } else {
  2328. if (that.has(templateOs[property])) {
  2329. field.templateOptions[property] = that.get(
  2330. templateOs[property]
  2331. );
  2332. } else {
  2333. field.templateOptions[property] = templateOs[property];
  2334. }
  2335. }
  2336. } else if (templateOs[property] == null) {
  2337. //delete field.templateOptions[property];
  2338. } else {
  2339. }
  2340. }
  2341. }
  2342. if (
  2343. angular.isDefined(field.templateOptions) &&
  2344. angular.isDefined(field.templateOptions.extjson)
  2345. ) {
  2346. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2347. angular.extend(field.templateOptions, extObj);
  2348. delete field.templateOptions.extjson;
  2349. }
  2350. //...
  2351. if (field.templateOptions) {
  2352. //处理远程获取数据控件方法调用
  2353. if (field.templateOptions.optionsUrl) {
  2354. field.templateOptions.refresh = refreshSelectOptions;
  2355. }
  2356. //处理嵌套属性数据绑定/
  2357. if (field.templateOptions.pkey) {
  2358. var pmodel,
  2359. i = 0;
  2360. angular.forEach(
  2361. field.templateOptions.pkey.split("."),
  2362. function (p) {
  2363. if (i == 0) {
  2364. if (result.model[p] == null) {
  2365. result.model[p] = {};
  2366. }
  2367. pmodel = result.model[p];
  2368. i++;
  2369. } else {
  2370. if (pmodel[p] == null) {
  2371. pmodel[p] = {};
  2372. }
  2373. pmodel = pmodel[p];
  2374. }
  2375. }
  2376. );
  2377. if (pmodel != null) {
  2378. field.model = pmodel;
  2379. if (pmodel[field.key] == null) {
  2380. pmodel[field.key] = null;
  2381. }
  2382. }
  2383. } else {
  2384. if (result.model[field.key] == null) {
  2385. result.model[field.key] = null;
  2386. }
  2387. }
  2388. //处理弹出框组件初始化
  2389. if (field.type == "ui-input-selectmodal") {
  2390. field.templateOptions.modal = $modal;
  2391. //field.templateOptions.Restangular = Restangular;
  2392. } else if (field.type == "ui-userselect") {
  2393. field.templateOptions.modal = $modal;
  2394. //field.templateOptions.Restangular = Restangular;
  2395. } else if (field.type == "ui-multiuserselect") {
  2396. field.templateOptions.modal = $modal;
  2397. } else if (field.type == "ui-modelselect") {
  2398. field.templateOptions.modal = $modal;
  2399. //field.templateOptions.Restangular = Restangular;
  2400. } else if (field.type == "ui-cmdbuplode") {
  2401. $scope.fileUploader = field.templateOptions.fileUploader =
  2402. new FileUploader({
  2403. url: "/uploader",
  2404. queueLimit: 1, //文件个数
  2405. autoUpload: true,
  2406. });
  2407. // $scope.fileUploadermeans = field.templateOptions.fileUploadermeans;
  2408. } else if (field.type == "ui-dropfile") {
  2409. field.templateOptions.fileUploader = new FileUploader({
  2410. url: "/uploader",
  2411. });
  2412. field.templateOptions.taskId = $stateParams.taskId;
  2413. field.templateOptions.processInstanceId =
  2414. $stateParams.processInstanceId;
  2415. field.templateOptions.userId = $rootScope.user.id;
  2416. //field.ApiService=api_bpm_domain;
  2417. } else if (field.type == "ui-dropfiletable") {
  2418. if (field.templateOptions.processInstanceId) {
  2419. } else {
  2420. field.templateOptions.processInstanceId =
  2421. $stateParams.processInstanceId;
  2422. }
  2423. } else if (field.type == "ui-repeatSection") {
  2424. var repeatForm = {
  2425. model: {},
  2426. fields: field.templateOptions.fields,
  2427. };
  2428. repeatForm.model[field.key] = [];
  2429. decodeVMTabForm(repeatForm);
  2430. }
  2431. }
  2432. // console.log(field);
  2433. //field
  2434. //result.fields.push(field);
  2435. });
  2436. });
  2437. vm.originalTabs = angular.copy(vm.form);
  2438. }
  2439. //======================处理表单设计数据 结束========================
  2440. $scope.ldloading = {};
  2441. function filter(obj) {
  2442. angular.forEach(obj, function (key, value) {
  2443. if (value === "" || value === null) {
  2444. delete obj[key];
  2445. } else if (
  2446. Object.prototype.toString.call(value) === "[object Object]"
  2447. ) {
  2448. filter(value);
  2449. } else if (angular.isArray(value)) {
  2450. angular.forEach(value, function (item) {
  2451. filter(item);
  2452. });
  2453. }
  2454. });
  2455. }
  2456. function invokeOnAllFormOptions(fn) {
  2457. angular.forEach(vm.tabs, function (tab) {
  2458. if (tab.form.options && tab.form.options[fn]) {
  2459. tab.form.options[fn]();
  2460. }
  2461. });
  2462. }
  2463. function encodeCIData(data, ciId) {
  2464. /*
  2465. create/update state:未审核
  2466. create createtime:系统时间
  2467. create/update lastupdatetime : 系统时间
  2468. label:ci分类
  2469. */
  2470. if (ciId) {
  2471. var baseprop = [
  2472. "uuid",
  2473. "name",
  2474. "type",
  2475. "label",
  2476. "status",
  2477. "createtime",
  2478. "lastupdatetime",
  2479. "props",
  2480. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  2481. var extraprop = "props";
  2482. data[extraprop] = {};
  2483. for (var key in data) {
  2484. console.log(data[key]);
  2485. if (_.indexOf(baseprop, key) >= 0) {
  2486. continue;
  2487. } else {
  2488. data[extraprop][key] = data[key];
  2489. delete data[key];
  2490. }
  2491. }
  2492. if ($rootScope.user) {
  2493. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  2494. data[extraprop]["configperson"] = $rootScope.user.name;
  2495. var isCMAdminFlag = false;
  2496. angular.forEach($rootScope.user.role, function (roleItem) {
  2497. if (roleItem.rolecode == "cmdb charge") {
  2498. isCMAdminFlag = true;
  2499. }
  2500. });
  2501. if (!isCMAdminFlag) {
  2502. data[extraprop]["state"] = "1";
  2503. }
  2504. }
  2505. if (data.props.id) {
  2506. } else {
  2507. data.label = ciId;
  2508. }
  2509. return data;
  2510. }
  2511. return undefined;
  2512. }
  2513. function decodeCIModel(data) {
  2514. var extraprop = "props";
  2515. if (data[extraprop]) {
  2516. for (var key in data[extraprop]) {
  2517. data[key] = data[extraprop][key];
  2518. }
  2519. delete data[extraprop];
  2520. }
  2521. data["iscmadmin"] = false;
  2522. angular.forEach($rootScope.user.role, function (roleItem) {
  2523. if (roleItem.rolecode == "cmdb charge") {
  2524. data["iscmadmin"] = true;
  2525. }
  2526. });
  2527. return data;
  2528. }
  2529. function formValid() {
  2530. angular.forEach(vm.tabs, function (item) {
  2531. //item.
  2532. });
  2533. }
  2534. $scope.vm = vm;
  2535. $scope.refreshcmdbform = function (item) {
  2536. var tempclassify = item.prefix.toLowerCase() + item.sign;
  2537. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  2538. var myData = Restangular.stripRestangular(data);
  2539. $scope.propTypeOptions = myData;
  2540. $scope.templateProps = myData;
  2541. $scope.vm.tabs = myData;
  2542. if ($scope.model.assets) {
  2543. vm.models = JSON.parse($scope.model.assets);
  2544. }
  2545. if (angular.isDefined(vm.models.vtvmvtm_kaiji)) {
  2546. if (vm.models.vtvmvtm_kaiji) {
  2547. vm.models.vtvmvtm_kaiji = "是";
  2548. } else {
  2549. vm.models.vtvmvtm_kaiji = "否";
  2550. }
  2551. }
  2552. decodeVMTabForm(vm.models, vm.tabs);
  2553. });
  2554. // }
  2555. };
  2556. var cifilterClassic = {};
  2557. // if ($scope.$parent.$parent.$parent.model.cifilterClassic && cifilterClassic.id != $scope.$parent.$parent.$parent.model.cifilterClassic.id) {
  2558. // cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic;
  2559. $scope.refreshcmdbform(
  2560. $scope.$parent.$parent.$parent.model.cifilterClassic
  2561. );
  2562. // } else {}
  2563. },
  2564. ],
  2565. });
  2566. //固定资产下载
  2567. formlyConfigProvider.setType({
  2568. name: "ui-dropupload",
  2569. templateUrl: "assets/views/customform/tpl/cmdb/upload.html",
  2570. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  2571. defaultOptions: function (options) {
  2572. return {
  2573. templateOptions: {
  2574. view: function (APIService, contentId) {
  2575. return APIService.downloadAttachment(contentId);
  2576. },
  2577. },
  2578. };
  2579. },
  2580. controller: [
  2581. "$scope",
  2582. "$rootScope",
  2583. "Restangular",
  2584. function ($scope, $rootScope, Restangular) {
  2585. if (angular.isUndefined($scope.form.dropState)) {
  2586. $scope.form.dropState = false;
  2587. }
  2588. var to = $scope.options.templateOptions;
  2589. var bindId = $scope.model[to.bindType].processInstanceId;
  2590. //获取附件列表
  2591. $scope.listAttachmen = function () {
  2592. to.ApiService.listAttachment(
  2593. to.listAttachmentUrl,
  2594. to.bindType,
  2595. bindId
  2596. ).then(function (result) {
  2597. var myData = Restangular.stripRestangular(result);
  2598. // $scope.listAttachmens = myData;
  2599. $scope.attachments = myData.data;
  2600. });
  2601. };
  2602. $scope.listAttachmen();
  2603. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  2604. // $scope.listAttachmen();
  2605. // } else if (to.bindType && $scope.model[to.bindType].id) {
  2606. // $scope.listAttachmen();
  2607. // }
  2608. //附件下载
  2609. $scope.download = function (token, filename) {
  2610. var downUrl = to.ApiService.downloadAttachment(
  2611. to.downUrl,
  2612. token
  2613. ).getRequestedUrl();
  2614. var a = document.createElement("a");
  2615. a.href = downUrl;
  2616. a.target = "_blank";
  2617. a.download = filename;
  2618. document.body.appendChild(a);
  2619. a.click();
  2620. };
  2621. //附件预览
  2622. $scope.view = function (id, previewUrl) {
  2623. if (previewUrl) {
  2624. window.open(previewUrl);
  2625. }
  2626. };
  2627. },
  2628. ],
  2629. });
  2630. formlyConfigProvider.setType({
  2631. name: "ui-form",
  2632. templateUrl: "assets/views/customform/tpl/ui-cmdbform.html",
  2633. defaultOptions: function (options) {
  2634. return {
  2635. templateOptions: {
  2636. // link: function() {}
  2637. },
  2638. };
  2639. },
  2640. controller: [
  2641. "$rootScope",
  2642. "$scope",
  2643. "$parse",
  2644. "$injector",
  2645. "$http",
  2646. "$q",
  2647. "$state",
  2648. "$stateParams",
  2649. "$modal",
  2650. "$timeout",
  2651. "$interval",
  2652. "i18nService",
  2653. "SweetAlert",
  2654. "FileUploader",
  2655. "Restangular",
  2656. "UserRestangular",
  2657. "BpmRestangular",
  2658. "api_configure_form",
  2659. "api_configure_data",
  2660. "api_bpm_domain",
  2661. "api_bpm_data",
  2662. "api_user_data",
  2663. "api_cmdb",
  2664. "api_sysinfo",
  2665. function (
  2666. $rootScope,
  2667. $scope,
  2668. $parse,
  2669. $injector,
  2670. $http,
  2671. $q,
  2672. $state,
  2673. $stateParams,
  2674. $modal,
  2675. $timeout,
  2676. $interval,
  2677. i18nService,
  2678. SweetAlert,
  2679. FileUploader,
  2680. Restangular,
  2681. UserRestangular,
  2682. BpmRestangular,
  2683. api_configure_form,
  2684. api_configure_data,
  2685. api_bpm_domain,
  2686. api_bpm_data,
  2687. api_user_data,
  2688. api_cmdb,
  2689. api_sysinfo
  2690. ) {
  2691. $scope.langs = i18nService.getAllLangs();
  2692. $scope.lang = "zh-cn";
  2693. i18nService.setCurrentLang($scope.lang);
  2694. var vm = this;
  2695. vm.options = {};
  2696. vm.exampleTitle = ["expressionProperties", "model property"];
  2697. vm.fields = [];
  2698. vm.models = {};
  2699. // vm.models["loginUser"] = $rootScope.user;
  2700. var that = $injector;
  2701. var parse = $parse;
  2702. var formKey = "";
  2703. var pdKey = "";
  2704. if (
  2705. angular.isDefined($state.current.pdKey) &&
  2706. $state.current.pdKey != ""
  2707. ) {
  2708. pdKey = $state.current.pdKey;
  2709. //console.log("pdKey::"+$state.current.pdKey);
  2710. }
  2711. if (
  2712. angular.isDefined($stateParams.formKey) &&
  2713. $stateParams.formKey != ""
  2714. ) {
  2715. formKey = $stateParams.formKey;
  2716. //console.log("formKey::"+$stateParams.formKey);
  2717. }
  2718. //用户测试数据,后续从header的auth中获取
  2719. var userId = 2;
  2720. userId = $rootScope.user.id;
  2721. //==============处理表单设计数据 开始====================
  2722. //处理组件加载后台数据选项的方法
  2723. function refreshSelectOptions(searchVal, field) {
  2724. if (field.templateOptions.optionsUrl) {
  2725. var process = BpmRestangular.all("");
  2726. if (field.templateOptions.ApiService) {
  2727. process = UserRestangular.all("");
  2728. }
  2729. process
  2730. .customPOST(
  2731. {
  2732. idx: 0,
  2733. sum: 1000,
  2734. },
  2735. field.templateOptions.optionsUrl
  2736. )
  2737. .then(function (result) {
  2738. if (!field.templateOptions.options) {
  2739. field.templateOptions.options = [];
  2740. }
  2741. if (field.templateOptions.optionsDataKey) {
  2742. field.templateOptions.options =
  2743. result[field.templateOptions.optionsDataKey];
  2744. } else {
  2745. field.templateOptions.options = result;
  2746. }
  2747. });
  2748. }
  2749. }
  2750. function decodeVMTabForm(model, tabs) {
  2751. var result = {
  2752. model: {},
  2753. tabs: [],
  2754. };
  2755. var mdata = angular.fromJson(model);
  2756. angular.extend(result.model, mdata);
  2757. angular.forEach(tabs, function (tab) {
  2758. tab.form.model = vm.models;
  2759. angular.forEach(tab.form.fields, function (field) {
  2760. if (field.key == "") {
  2761. delete field.key;
  2762. }
  2763. if (angular.isDefined(field.extjson) && field.extjson != "") {
  2764. var extObj = angular.fromJson(field.extjson);
  2765. angular.extend(field.templateOptions, extObj.templateOptions);
  2766. delete extObj.templateOptions;
  2767. for (var prop in extObj) {
  2768. if (new RegExp("Expression").test(prop)) {
  2769. //var obj = $scope.$eval(extObj[prop]);
  2770. //extObj[prop] = $scope.$eval(extObj[prop]);
  2771. if (extObj[prop] != null) {
  2772. if (new RegExp("function").test(extObj[prop])) {
  2773. var propValue = eval(extObj[prop]);
  2774. extObj[prop] = propValue;
  2775. } else {
  2776. //console.log(extObj[prop]);
  2777. var obj = $scope.$eval(extObj[prop]);
  2778. extObj[prop] = obj;
  2779. //console.log(obj);
  2780. }
  2781. }
  2782. } else if (new RegExp("expressionProperties").test(prop)) {
  2783. for (var p in extObj[prop]) {
  2784. if (new RegExp("function").test(extObj[prop][p])) {
  2785. var propValue = eval(extObj[prop][p]);
  2786. extObj[prop][p] = propValue;
  2787. } else {
  2788. //if(p.indexOf("'")>=0){
  2789. // var obj = $scope.$eval(extObj[prop][p]);
  2790. // extObj[prop][$scope.$eval(p)]=obj;
  2791. //}
  2792. }
  2793. }
  2794. } else if ("watcher" == prop) {
  2795. if (angular.isArray(extObj[prop])) {
  2796. angular.forEach(extObj[prop], function (item, index) {
  2797. for (var p in item) {
  2798. if (new RegExp("function").test(item[p])) {
  2799. var propValue = eval(item[p]);
  2800. extObj[prop][index][p] = propValue;
  2801. }
  2802. }
  2803. });
  2804. } else if (angular.isObject(extObj[prop])) {
  2805. for (var p in extObj[prop]) {
  2806. if (new RegExp("function").test(extObj[prop][p])) {
  2807. var propValue = eval(extObj[prop][p]);
  2808. extObj[prop][p] = propValue;
  2809. }
  2810. }
  2811. }
  2812. }
  2813. }
  2814. angular.extend(field, extObj);
  2815. delete field.extjson;
  2816. }
  2817. if (field.extjson == "") {
  2818. delete field.extjson;
  2819. }
  2820. if (angular.isDefined(field.templateOptions)) {
  2821. var templateOs = field.templateOptions;
  2822. for (var property in templateOs) {
  2823. //console.log(property);
  2824. if (
  2825. angular.isString(templateOs[property]) &&
  2826. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  2827. ) {
  2828. if (new RegExp("function").test(templateOs[property])) {
  2829. var propValue = eval(templateOs[property]);
  2830. field.templateOptions[property] = propValue;
  2831. } else {
  2832. if (that.has(templateOs[property])) {
  2833. field.templateOptions[property] = that.get(
  2834. templateOs[property]
  2835. );
  2836. } else {
  2837. field.templateOptions[property] = templateOs[property];
  2838. }
  2839. }
  2840. } else if (templateOs[property] == null) {
  2841. //delete field.templateOptions[property];
  2842. } else {
  2843. }
  2844. }
  2845. }
  2846. if (
  2847. angular.isDefined(field.templateOptions) &&
  2848. angular.isDefined(field.templateOptions.extjson)
  2849. ) {
  2850. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  2851. angular.extend(field.templateOptions, extObj);
  2852. delete field.templateOptions.extjson;
  2853. }
  2854. //...
  2855. if (field.templateOptions) {
  2856. //处理远程获取数据控件方法调用
  2857. if (field.templateOptions.optionsUrl) {
  2858. field.templateOptions.refresh = refreshSelectOptions;
  2859. }
  2860. //处理嵌套属性数据绑定/
  2861. if (field.templateOptions.pkey) {
  2862. var pmodel,
  2863. i = 0;
  2864. angular.forEach(
  2865. field.templateOptions.pkey.split("."),
  2866. function (p) {
  2867. if (i == 0) {
  2868. if (result.model[p] == null) {
  2869. result.model[p] = {};
  2870. }
  2871. pmodel = result.model[p];
  2872. i++;
  2873. } else {
  2874. if (pmodel[p] == null) {
  2875. pmodel[p] = {};
  2876. }
  2877. pmodel = pmodel[p];
  2878. }
  2879. }
  2880. );
  2881. if (pmodel != null) {
  2882. field.model = pmodel;
  2883. if (pmodel[field.key] == null) {
  2884. pmodel[field.key] = null;
  2885. }
  2886. }
  2887. } else {
  2888. if (result.model[field.key] == null) {
  2889. result.model[field.key] = null;
  2890. }
  2891. }
  2892. //处理弹出框组件初始化
  2893. if (field.type == "ui-input-selectmodal") {
  2894. field.templateOptions.modal = $modal;
  2895. //field.templateOptions.Restangular = Restangular;
  2896. } else if (field.type == "ui-userselect") {
  2897. field.templateOptions.modal = $modal;
  2898. //field.templateOptions.Restangular = Restangular;
  2899. } else if (field.type == "ui-multiuserselect") {
  2900. field.templateOptions.modal = $modal;
  2901. } else if (field.type == "ui-modelselect") {
  2902. field.templateOptions.modal = $modal;
  2903. //field.templateOptions.Restangular = Restangular;
  2904. } else if (field.type == "ui-dropfile") {
  2905. field.templateOptions.fileUploader = new FileUploader({
  2906. url: "/uploader",
  2907. });
  2908. field.templateOptions.taskId = $stateParams.taskId;
  2909. field.templateOptions.processInstanceId =
  2910. $stateParams.processInstanceId;
  2911. field.templateOptions.userId = $rootScope.user.id;
  2912. //field.ApiService=api_bpm_domain;
  2913. // }else if (field.type == "ui-uploadFile") {
  2914. // field.templateOptions.fileUploader = new FileUploader({
  2915. // url: '/uploader'
  2916. // });
  2917. // field.templateOptions.taskId = $stateParams.taskId;
  2918. // field.templateOptions.processInstanceId = $stateParams.processInstanceId;
  2919. // field.templateOptions.userId = $rootScope.user.id;
  2920. //field.ApiService=api_bpm_domain;
  2921. } else if (field.type == "ui-dropfiletable") {
  2922. if (field.templateOptions.processInstanceId) {
  2923. } else {
  2924. field.templateOptions.processInstanceId =
  2925. $stateParams.processInstanceId;
  2926. }
  2927. } else if (field.type == "ui-dropFiles") {
  2928. if (field.templateOptions.processInstanceId) {
  2929. } else {
  2930. field.templateOptions.processInstanceId =
  2931. $stateParams.processInstanceId;
  2932. }
  2933. } else if (field.type == "ui-showImgs") {
  2934. if (field.templateOptions.processInstanceId) {
  2935. } else {
  2936. field.templateOptions.processInstanceId =
  2937. $stateParams.processInstanceId;
  2938. }
  2939. } else if (field.type == "ui-repeatSection") {
  2940. var repeatForm = {
  2941. model: {},
  2942. fields: field.templateOptions.fields,
  2943. };
  2944. repeatForm.model[field.key] = [];
  2945. decodeVMTabForm(repeatForm);
  2946. }
  2947. }
  2948. // console.log(field);
  2949. //field
  2950. //result.fields.push(field);
  2951. });
  2952. });
  2953. vm.originalTabs = angular.copy(vm.form);
  2954. }
  2955. //解析自定义表单设计数据
  2956. function decodeVMForm(vmForm) {
  2957. var result = {
  2958. model: {},
  2959. tabs: [],
  2960. };
  2961. //设置模型实体数据 begin
  2962. // var mdata = vmForm.model;
  2963. //解析数据实体
  2964. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  2965. angular.extend(result.model, mdata);
  2966. //设置模型实体数据 end
  2967. //解析设计数据生成表单项 begin
  2968. var fields = [];
  2969. //处理修改设计数据中展示设置
  2970. angular.forEach(vmForm.tabs, function (field) {
  2971. if (field.key == "") {
  2972. delete field.key;
  2973. }
  2974. if (angular.isDefined(field.extjson)) {
  2975. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  2976. angular.extend(field.templateOptions, extObj.templateOptions);
  2977. delete extObj.templateOptions;
  2978. for (var prop in extObj) {
  2979. if (new RegExp("Expression").test(prop)) {
  2980. //var obj = $scope.$eval(extObj[prop]);
  2981. //extObj[prop] = $scope.$eval(extObj[prop]);
  2982. if (extObj[prop] != null) {
  2983. if (new RegExp("function").test(extObj[prop])) {
  2984. var propValue = eval(extObj[prop]);
  2985. extObj[prop] = propValue;
  2986. } else {
  2987. //console.log(extObj[prop]);
  2988. var obj = $scope.$eval(extObj[prop]);
  2989. extObj[prop] = obj;
  2990. //console.log(obj);
  2991. }
  2992. }
  2993. } else if (new RegExp("expressionProperties").test(prop)) {
  2994. for (var p in extObj[prop]) {
  2995. if (new RegExp("function").test(extObj[prop][p])) {
  2996. var propValue = eval(extObj[prop][p]);
  2997. extObj[prop][p] = propValue;
  2998. } else {
  2999. //if(p.indexOf("'")>=0){
  3000. // var obj = $scope.$eval(extObj[prop][p]);
  3001. // extObj[prop][$scope.$eval(p)]=obj;
  3002. //}
  3003. }
  3004. }
  3005. } else if ("watcher" == prop) {
  3006. if (angular.isArray(extObj[prop])) {
  3007. angular.forEach(extObj[prop], function (item, index) {
  3008. for (var p in item) {
  3009. if (new RegExp("function").test(item[p])) {
  3010. var propValue = eval(item[p]);
  3011. extObj[prop][index][p] = propValue;
  3012. }
  3013. }
  3014. });
  3015. } else if (angular.isObject(extObj[prop])) {
  3016. for (var p in extObj[prop]) {
  3017. if (new RegExp("function").test(extObj[prop][p])) {
  3018. var propValue = eval(extObj[prop][p]);
  3019. extObj[prop][p] = propValue;
  3020. }
  3021. }
  3022. }
  3023. }
  3024. }
  3025. angular.extend(field, extObj);
  3026. delete field.extjson;
  3027. }
  3028. if (angular.isDefined(field.templateOptions)) {
  3029. var templateOs = field.templateOptions;
  3030. for (var property in templateOs) {
  3031. //console.log(property);
  3032. if (
  3033. angular.isString(templateOs[property]) &&
  3034. !new RegExp("[\u4e00-\u9fa5]").test(templateOs[property])
  3035. ) {
  3036. if (new RegExp("function").test(templateOs[property])) {
  3037. var propValue = eval(templateOs[property]);
  3038. field.templateOptions[property] = propValue;
  3039. } else {
  3040. if (that.has(templateOs[property])) {
  3041. field.templateOptions[property] = that.get(
  3042. templateOs[property]
  3043. );
  3044. } else {
  3045. field.templateOptions[property] = templateOs[property];
  3046. }
  3047. }
  3048. } else if (templateOs[property] == null) {
  3049. //delete field.templateOptions[property];
  3050. } else {
  3051. }
  3052. }
  3053. }
  3054. if (
  3055. angular.isDefined(field.templateOptions) &&
  3056. angular.isDefined(field.templateOptions.extjson)
  3057. ) {
  3058. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  3059. angular.extend(field.templateOptions, extObj);
  3060. delete field.templateOptions.extjson;
  3061. }
  3062. //...
  3063. if (field.templateOptions) {
  3064. //处理远程获取数据控件方法调用
  3065. if (field.templateOptions.optionsUrl) {
  3066. field.templateOptions.refresh = refreshSelectOptions;
  3067. }
  3068. //处理嵌套属性数据绑定/
  3069. if (field.templateOptions.pkey) {
  3070. var pmodel,
  3071. i = 0;
  3072. angular.forEach(
  3073. field.templateOptions.pkey.split("."),
  3074. function (p) {
  3075. if (i == 0) {
  3076. if (result.model[p] == null) {
  3077. result.model[p] = {};
  3078. }
  3079. pmodel = result.model[p];
  3080. i++;
  3081. } else {
  3082. if (pmodel[p] == null) {
  3083. pmodel[p] = {};
  3084. }
  3085. pmodel = pmodel[p];
  3086. }
  3087. }
  3088. );
  3089. if (pmodel != null) {
  3090. field.model = pmodel;
  3091. if (pmodel[field.key] == null) {
  3092. pmodel[field.key] = null;
  3093. }
  3094. }
  3095. } else {
  3096. if (result.model[field.key] == null) {
  3097. result.model[field.key] = null;
  3098. }
  3099. }
  3100. //处理弹出框组件初始化
  3101. if (field.type == "ui-input-selectmodal") {
  3102. field.templateOptions.modal = $modal;
  3103. //field.templateOptions.Restangular = Restangular;
  3104. } else if (field.type == "ui-userselect") {
  3105. field.templateOptions.modal = $modal;
  3106. //field.templateOptions.Restangular = Restangular;
  3107. } else if (field.type == "ui-multiuserselect") {
  3108. field.templateOptions.modal = $modal;
  3109. } else if (field.type == "ui-modelselect") {
  3110. field.templateOptions.modal = $modal;
  3111. //field.templateOptions.Restangular = Restangular;
  3112. } else if (field.type == "ui-dropfile") {
  3113. field.templateOptions.fileUploader = new FileUploader({
  3114. url: "/uploader",
  3115. });
  3116. field.templateOptions.taskId = $stateParams.taskId;
  3117. field.templateOptions.processInstanceId =
  3118. $stateParams.processInstanceId;
  3119. field.templateOptions.userId = $rootScope.user.id;
  3120. //field.ApiService=api_bpm_domain;
  3121. } else if (field.type == "ui-dropfiletable") {
  3122. if (field.templateOptions.processInstanceId) {
  3123. } else {
  3124. field.templateOptions.processInstanceId =
  3125. $stateParams.processInstanceId;
  3126. }
  3127. } else if (field.type == "ui-dropFiles") {
  3128. if (field.templateOptions.processInstanceId) {
  3129. } else {
  3130. field.templateOptions.processInstanceId =
  3131. $stateParams.processInstanceId;
  3132. }
  3133. } else if (field.type == "ui-showImgs") {
  3134. if (field.templateOptions.processInstanceId) {
  3135. } else {
  3136. field.templateOptions.processInstanceId =
  3137. $stateParams.processInstanceId;
  3138. }
  3139. } else if (field.type == "ui-repeatSection") {
  3140. var repeatForm = {
  3141. model: {},
  3142. fields: field.templateOptions.fields,
  3143. };
  3144. repeatForm.model[field.key] = [];
  3145. decodeVMForm(repeatForm);
  3146. }
  3147. }
  3148. // console.log(field);
  3149. result.fields.push(field);
  3150. });
  3151. angular.extend($scope.vm.fields, result.fields);
  3152. angular.extend($scope.vm.models, result.model);
  3153. $scope.formData = vmForm;
  3154. //console.log($scope.vm);
  3155. //解析设计数据生成表单项 end
  3156. return result;
  3157. }
  3158. //======================处理表单设计数据 结束========================
  3159. $scope.ldloading = {};
  3160. function filter(obj) {
  3161. angular.forEach(obj, function (key, value) {
  3162. if (value === "" || value === null) {
  3163. delete obj[key];
  3164. } else if (
  3165. Object.prototype.toString.call(value) === "[object Object]"
  3166. ) {
  3167. filter(value);
  3168. } else if (angular.isArray(value)) {
  3169. angular.forEach(value, function (item) {
  3170. filter(item);
  3171. });
  3172. }
  3173. });
  3174. }
  3175. function invokeOnAllFormOptions(fn) {
  3176. angular.forEach(vm.tabs, function (tab) {
  3177. if (tab.form.options && tab.form.options[fn]) {
  3178. tab.form.options[fn]();
  3179. }
  3180. });
  3181. }
  3182. function encodeCIData(data, ciId) {
  3183. /*
  3184. create/update state:未审核
  3185. create createtime:系统时间
  3186. create/update lastupdatetime : 系统时间
  3187. label:ci分类
  3188. */
  3189. if (ciId) {
  3190. var baseprop = [
  3191. "uuid",
  3192. "name",
  3193. "type",
  3194. "label",
  3195. "status",
  3196. "createtime",
  3197. "lastupdatetime",
  3198. "props",
  3199. ]; //state|audittime//createtime//removeflag|removetime//configperson//lastupdateperson//manager//useradmin
  3200. var extraprop = "props";
  3201. data[extraprop] = {};
  3202. for (var key in data) {
  3203. console.log(data[key]);
  3204. if (_.indexOf(baseprop, key) >= 0) {
  3205. continue;
  3206. } else {
  3207. data[extraprop][key] = data[key];
  3208. delete data[key];
  3209. }
  3210. }
  3211. if ($rootScope.user) {
  3212. data[extraprop]["lastupdateperson"] = $rootScope.user.name;
  3213. data[extraprop]["configperson"] = $rootScope.user.name;
  3214. var isCMAdminFlag = false;
  3215. angular.forEach($rootScope.user.role, function (roleItem) {
  3216. if (roleItem.rolecode == "cmdb charge") {
  3217. isCMAdminFlag = true;
  3218. }
  3219. });
  3220. if (!isCMAdminFlag) {
  3221. data[extraprop]["state"] = "1";
  3222. }
  3223. }
  3224. if (data.props.id) {
  3225. } else {
  3226. data.label = ciId;
  3227. }
  3228. return data;
  3229. }
  3230. return undefined;
  3231. }
  3232. function decodeCIModel(data) {
  3233. var extraprop = "props";
  3234. if (data[extraprop]) {
  3235. for (var key in data[extraprop]) {
  3236. data[key] = data[extraprop][key];
  3237. }
  3238. delete data[extraprop];
  3239. }
  3240. data["iscmadmin"] = false;
  3241. angular.forEach($rootScope.user.role, function (roleItem) {
  3242. if (roleItem.rolecode == "cmdb charge") {
  3243. data["iscmadmin"] = true;
  3244. }
  3245. });
  3246. return data;
  3247. }
  3248. vm.remove = function (data, style) {
  3249. $scope.ldloading[style.replace("-", "_")] = true;
  3250. var modalInstance = $modal.open({
  3251. templateUrl: "assets/views/delete.html",
  3252. controller: function ($scope, scope, $modalInstance, api_bpm_data) {
  3253. var cidata = {
  3254. label: data.label,
  3255. id: data.id,
  3256. uuid: data.uuid,
  3257. name: data.name,
  3258. props: {},
  3259. };
  3260. if (cidata.id) {
  3261. cidata.props["removeflag"] = true;
  3262. cidata.props["lastupdateperson"] = vm.models.loginUser;
  3263. $scope.ok = function () {
  3264. $modalInstance.close(cidata);
  3265. };
  3266. $scope.cancel = function () {
  3267. $modalInstance.dismiss("cancel");
  3268. };
  3269. }
  3270. },
  3271. size: "sm",
  3272. resolve: {
  3273. scope: function () {
  3274. return $scope;
  3275. },
  3276. },
  3277. });
  3278. modalInstance.result.then(function (selectedItem) {
  3279. if (selectedItem) {
  3280. // if (selectedItem.length > 0) {
  3281. api_cmdb
  3282. .put(selectedItem, selectedItem.id)
  3283. .then(function (response) {
  3284. if (response) {
  3285. var resData = Restangular.stripRestangular(response);
  3286. SweetAlert.swal(
  3287. {
  3288. title: "删除成功!",
  3289. confirmButtonColor: "#007AFF",
  3290. },
  3291. function () {
  3292. $state.go("app.means.list");
  3293. // $scope.refreshform();
  3294. // reinitTabForm($scope.classify);
  3295. }
  3296. );
  3297. } else {
  3298. SweetAlert.swal({
  3299. title: "系统错误",
  3300. text: "系统错误,请稍后重试!",
  3301. type: "error",
  3302. confirmButtonColor: "#DD6B55",
  3303. });
  3304. }
  3305. $scope.ldloading[style.replace("-", "_")] = false;
  3306. });
  3307. }
  3308. });
  3309. };
  3310. function formValid() {
  3311. angular.forEach(vm.tabs, function (item) {
  3312. //item.
  3313. });
  3314. }
  3315. $scope.closeModel = function () {
  3316. console.log($stateParams);
  3317. if (
  3318. angular.isDefined($stateParams.formKey) &&
  3319. $stateParams.formKey != ""
  3320. ) {
  3321. if (
  3322. $stateParams.formKey == "means_editor" ||
  3323. $stateParams.formKey == "means_edit"
  3324. ) {
  3325. $state.go("app.means.list", {});
  3326. }
  3327. event.preventDefault();
  3328. }
  3329. };
  3330. // setInterval(function() {
  3331. // if ($scope.model.cifilter_classic && cifilter_classic.id != $scope.model.cifilter_classic.id) {
  3332. // cifilter_classic = $scope.model.cifilter_classic;
  3333. // $scope.refreshcmdbform(cifilter_classic);
  3334. // } else {}
  3335. // }, 100);
  3336. vm.models = (function filter(obj) {
  3337. var filtered = _.pick(obj, function (v) {
  3338. return (
  3339. angular.isDefined(v) &&
  3340. v !== null &&
  3341. (angular.isArray(v) ? v.length > 0 : true) &&
  3342. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3343. );
  3344. });
  3345. return _.cloneDeep(filtered, function (v) {
  3346. return v !== filtered && _.isPlainObject(v) ? filter(v) : undefined;
  3347. });
  3348. })(vm.models);
  3349. // setInterval(function() {
  3350. // if ($scope.model.type == 0) {
  3351. // $scope.model[$scope.options.key] = vm.models;
  3352. // }
  3353. // }, 100);
  3354. setInterval(function () {
  3355. if (vm.form && vm.form.$$parentForm.$valid) {
  3356. if (
  3357. $scope.$parent &&
  3358. $scope.$parent.$parent &&
  3359. $scope.$parent.$parent.$parent &&
  3360. $scope.$parent.$parent.$parent.model
  3361. ) {
  3362. vm.models.hw_cifilterClassic =
  3363. $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3364. $scope.model[$scope.options.key] = vm.models;
  3365. }
  3366. // vm.models.hw_cifilterClassic = $scope.$parent.$parent.$parent.model.cifilterClassic.label;
  3367. // $scope.model[$scope.options.key] = vm.models;
  3368. }
  3369. }, 100);
  3370. vm.submit = function (data, ciId, templateitem, style) {
  3371. // $scope.ldloading[style.replace('-', '_')] = true;
  3372. console.log(vm.form.$$parentForm.$valid);
  3373. if (vm.form.$$parentForm.$valid) {
  3374. invokeOnAllFormOptions("updateInitialValue");
  3375. //alert(JSON.stringify(vm.model), null, 2);
  3376. //vm.options.updateInitialValue();
  3377. //console.log(vm.model);
  3378. var cidata = encodeCIData(vm.models, ciId);
  3379. if (cidata) {
  3380. //var cidata = ;
  3381. if (cidata.props.id) {
  3382. //修改
  3383. api_cmdb.put(cidata, ciId).then(function (response) {
  3384. if (response) {
  3385. var resData = Restangular.stripRestangular(response);
  3386. SweetAlert.swal(
  3387. {
  3388. title: "保存成功!",
  3389. confirmButtonColor: "#007AFF",
  3390. },
  3391. function () {
  3392. $scope.ldloading[style.replace("-", "_")] = false;
  3393. // $scope.refreshform();
  3394. $state.go("app.means.list");
  3395. }
  3396. );
  3397. } else {
  3398. SweetAlert.swal({
  3399. title: "系统错误",
  3400. text: "系统错误,请稍后重试!",
  3401. type: "error",
  3402. confirmButtonColor: "#DD6B55",
  3403. });
  3404. }
  3405. $scope.ldloading[style.replace("-", "_")] = false;
  3406. });
  3407. } else {
  3408. //新建
  3409. var type = 2;
  3410. api_sysinfo
  3411. .getSerialnumber(type, templateitem.id)
  3412. .then(function (data) {
  3413. if (data && data.status == 200) {
  3414. cidata.uuid = data.uuid;
  3415. api_cmdb.create(cidata).then(function (response) {
  3416. if (response) {
  3417. var resData = Restangular.stripRestangular(response);
  3418. SweetAlert.swal(
  3419. {
  3420. title: "保存成功!",
  3421. text: "内部编号:" + cidata.uuid,
  3422. confirmButtonColor: "#007AFF",
  3423. },
  3424. function () {
  3425. $state.go("app.means.list");
  3426. }
  3427. );
  3428. // if(resData.status){
  3429. // resData
  3430. // }
  3431. } else {
  3432. SweetAlert.swal({
  3433. title: "系统错误",
  3434. text: "系统错误,请稍后重试!",
  3435. type: "error",
  3436. confirmButtonColor: "#DD6B55",
  3437. });
  3438. }
  3439. $scope.ldloading[style.replace("-", "_")] = false;
  3440. });
  3441. } else {
  3442. SweetAlert.swal({
  3443. title: "系统错误",
  3444. text: "内部编号生成出错!",
  3445. type: "error",
  3446. confirmButtonColor: "#DD6B55",
  3447. });
  3448. }
  3449. });
  3450. }
  3451. } else {
  3452. SweetAlert.swal({
  3453. title: "错误",
  3454. text: "错误,请选择资产分类!",
  3455. type: "error",
  3456. confirmButtonColor: "#DD6B55",
  3457. });
  3458. }
  3459. //alert(JSON.stringify(cidata), null, 2);
  3460. $scope.ldloading[style.replace("-", "_")] = true;
  3461. return;
  3462. var _ = window._;
  3463. vm.models = (function filter(obj) {
  3464. var filtered = _.pick(obj, function (v) {
  3465. return (
  3466. angular.isDefined(v) &&
  3467. v !== null &&
  3468. (angular.isArray(v) ? v.length > 0 : true) &&
  3469. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  3470. );
  3471. });
  3472. return _.cloneDeep(filtered, function (v) {
  3473. return v !== filtered && _.isPlainObject(v)
  3474. ? filter(v)
  3475. : undefined;
  3476. });
  3477. })(vm.models);
  3478. } else {
  3479. if (vm.form.$$parentForm.$error) {
  3480. SweetAlert.swal({
  3481. title: "校验错误",
  3482. text: "请填写必填项!",
  3483. type: "error",
  3484. confirmButtonColor: "#DD6B55",
  3485. });
  3486. angular.forEach(
  3487. vm.form.$$parentForm.$error.required,
  3488. function (item) {
  3489. angular.forEach(vm.tabs, function (tab) {
  3490. angular.forEach(tab.form.fields, function (f) {
  3491. if (f.name == item.$name) {
  3492. f.validation.show = true;
  3493. tab.active = true;
  3494. }
  3495. });
  3496. });
  3497. }
  3498. );
  3499. $scope.ldloading[style.replace("-", "_")] = false;
  3500. }
  3501. }
  3502. };
  3503. $scope.vm = vm;
  3504. $scope.refreshcmdbform = function (item) {
  3505. // if ($stateParams.model) {
  3506. // var modeldata = JSON.parse($stateParams.model)
  3507. var tempclassify = item.prefix.toLowerCase() + item.sign;
  3508. api_configure_form.renderTabForm(tempclassify).then(function (data) {
  3509. var myData = Restangular.stripRestangular(data);
  3510. $scope.propTypeOptions = myData;
  3511. $scope.templateProps = myData;
  3512. $scope.vm.tabs = myData;
  3513. if ($scope.model.asset && $scope.model.asset.length != "") {
  3514. vm.models = JSON.parse($scope.model.asset);
  3515. }
  3516. decodeVMTabForm(vm.models, vm.tabs);
  3517. });
  3518. // }
  3519. };
  3520. var cifilterClassic = {};
  3521. setInterval(function () {
  3522. if (
  3523. $scope.$parent.$parent &&
  3524. $scope.$parent.$parent.$parent &&
  3525. $scope.$parent.$parent.$parent.model &&
  3526. $scope.$parent.$parent.$parent.model.cifilterClassic &&
  3527. cifilterClassic.id !=
  3528. $scope.$parent.$parent.$parent.model.cifilterClassic.id
  3529. ) {
  3530. // $scope.$parent.$parent.$parent.model.cifilterClassic = $scope.model.cifilterClassic;
  3531. cifilterClassic =
  3532. $scope.$parent.$parent.$parent.model.cifilterClassic;
  3533. $scope.refreshcmdbform(cifilterClassic);
  3534. } else {
  3535. }
  3536. }, 100);
  3537. },
  3538. ],
  3539. });
  3540. //请求人信息
  3541. formlyConfigProvider.setType({
  3542. name: "ui-cmdbinformation",
  3543. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbinformation.html",
  3544. wrapper: ["bootstrapHasError"],
  3545. defaultOptions: function (options, $scope) {
  3546. return {
  3547. templateOptions: {
  3548. // checkform: function(options) {
  3549. // if (options.model.requester) {
  3550. // options.value(options.model.requester);
  3551. // }
  3552. // },
  3553. },
  3554. };
  3555. },
  3556. controller: [
  3557. "$scope",
  3558. "api_user_data",
  3559. function ($scope, api_user_data) {
  3560. if ($scope.options.templateOptions.loginUser) {
  3561. if (
  3562. $scope.model[$scope.options.key] &&
  3563. $scope.model[$scope.options.key].id
  3564. ) {
  3565. } else {
  3566. $scope.model[$scope.options.key] =
  3567. $scope.options.templateOptions.loginUser;
  3568. }
  3569. $scope.options.initialValue = $scope.model[$scope.options.key];
  3570. }
  3571. },
  3572. ],
  3573. });
  3574. //资产属性
  3575. formlyConfigProvider.setType({
  3576. name: "ui-cmdbtype",
  3577. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtype.html",
  3578. wrapper: ["bootstrapHasError"],
  3579. defaultOptions: function (options, $scope) {
  3580. return {
  3581. templateOptions: {
  3582. // checkform: function(options) {
  3583. // if (options.model.requester) {
  3584. // options.value(options.model.requester);
  3585. // }
  3586. // },
  3587. },
  3588. };
  3589. },
  3590. controller: [
  3591. "$scope",
  3592. "api_user_data",
  3593. function ($scope, api_user_data) {
  3594. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3595. $scope.property = {
  3596. hw_change: $scope.to.loginUser,
  3597. hw_updata: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3598. hw_createtime: moment(new Date()).format("YYYY-MM-DD hh:mm:ss"),
  3599. };
  3600. if ($scope.$parent.$parent.$parent.model.assets) {
  3601. $scope.$parent.$parent.$parent.model.assets.extend($scope.property);
  3602. }
  3603. },
  3604. ],
  3605. });
  3606. //申请单信息
  3607. formlyConfigProvider.setType({
  3608. name: "ui-cmdbformimform",
  3609. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbformimform.html",
  3610. wrapper: ["bootstrapHasError"],
  3611. defaultOptions: function (options, $scope) {
  3612. return {
  3613. templateOptions: {
  3614. // checkform: function(options) {
  3615. // if (options.model.requester) {
  3616. // options.value(options.model.requester);
  3617. // }
  3618. // },
  3619. },
  3620. };
  3621. },
  3622. controller: [
  3623. "$scope",
  3624. "api_user_data",
  3625. function ($scope, api_user_data) {
  3626. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3627. $scope.getininform = {
  3628. serialNumbe:
  3629. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3630. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3631. };
  3632. if ($scope.$parent.$parent.$parent.model.applicationForm.type == 0) {
  3633. $scope.getininform.types = "新资产入库";
  3634. } else if (
  3635. $scope.$parent.$parent.$parent.model.applicationForm.type == 2
  3636. ) {
  3637. $scope.getininform.types = "资产归还";
  3638. }
  3639. },
  3640. ],
  3641. });
  3642. //出库单信息
  3643. formlyConfigProvider.setType({
  3644. name: "ui-outinformation",
  3645. templateUrl: "assets/views/customform/tpl/cmdb/outinformation.html",
  3646. wrapper: ["bootstrapHasError"],
  3647. defaultOptions: function (options, $scope) {
  3648. return {
  3649. templateOptions: {
  3650. // checkform: function(options) {
  3651. // if (options.model.requester) {
  3652. // options.value(options.model.requester);
  3653. // }
  3654. // },
  3655. },
  3656. };
  3657. },
  3658. controller: [
  3659. "$scope",
  3660. "api_user_data",
  3661. function ($scope, api_user_data) {
  3662. // $scope.options.initialValue = $scope.model[$scope.options.key];
  3663. $scope.getininform = {
  3664. serialNumbe:
  3665. $scope.$parent.$parent.$parent.model.applicationForm.serialNumbe,
  3666. time: $scope.$parent.$parent.$parent.model.applicationForm.time,
  3667. // source: $scope.$parent.$parent.$parent.model.applicationForm.source,
  3668. sourceId:
  3669. $scope.$parent.$parent.$parent.model.applicationForm.sourceId,
  3670. describe:
  3671. $scope.$parent.$parent.$parent.model.applicationForm.describe,
  3672. };
  3673. if ($scope.$parent.$parent.$parent.model.type.value == "1") {
  3674. $scope.getininform.types = "新设备领用出库";
  3675. } else if ($scope.$parent.$parent.$parent.model.type.value == "4") {
  3676. $scope.getininform.types = "设备更换";
  3677. }
  3678. $scope.getininform.source_id =
  3679. $scope.$parent.$parent.$parent.model.source.value;
  3680. if ($scope.$parent.$parent.$parent.model.source.value == "1") {
  3681. $scope.getininform.source = "事件";
  3682. } else if ($scope.$parent.$parent.$parent.model.source.value == "2") {
  3683. $scope.getininform.source = "变更";
  3684. // $scope.getininform.sourceId=$scope.$parent.$parent.$parent.model.source
  3685. } else if ($scope.$parent.$parent.$parent.model.source.value == "3") {
  3686. $scope.getininform.source = "其它";
  3687. }
  3688. },
  3689. ],
  3690. });
  3691. //资产附件上传
  3692. formlyConfigProvider.setType({
  3693. name: "ui-cmdbuplode",
  3694. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbuplode.html",
  3695. wrapper: ["bootstrapHasError"],
  3696. defaultOptions: function (options, $scope) {
  3697. return {
  3698. templateOptions: {
  3699. // checkform: function(options) {
  3700. // if (options.model.requester) {
  3701. // options.value(options.model.requester);
  3702. // }
  3703. // },
  3704. },
  3705. };
  3706. },
  3707. controller: [
  3708. "$scope",
  3709. "$rootScope",
  3710. "$http",
  3711. "SweetAlert",
  3712. "FileUploader",
  3713. "api_user_data",
  3714. "i18nService",
  3715. "$modal",
  3716. "Restangular",
  3717. "api_configure_data",
  3718. "api_cmdb",
  3719. "api_cmdb_new",
  3720. "api_wechatfile",
  3721. "api_sysinfo",
  3722. function (
  3723. $scope,
  3724. $rootScope,
  3725. $http,
  3726. SweetAlert,
  3727. FileUploader,
  3728. api_user_data,
  3729. i18nService,
  3730. $modal,
  3731. Restangular,
  3732. api_configure_data,
  3733. api_cmdb,
  3734. api_cmdb_new,
  3735. api_wechatfile,
  3736. api_sysinfo
  3737. ) {
  3738. $scope.state = 1;
  3739. $scope.myData3all = [];
  3740. $scope.myData3 = [];
  3741. $scope.memoryfilterDatahao = {
  3742. idx: 0,
  3743. sum: 10,
  3744. };
  3745. $scope.selected = {
  3746. items: [],
  3747. };
  3748. $scope.interceptMydata = function (mydate, idx, sum) {
  3749. return mydate.slice(idx * sum, (idx + 1) * sum);
  3750. };
  3751. // $scope.importnext = function() {
  3752. // $scope.state = 2;
  3753. // event.preventDefault();
  3754. // }
  3755. $scope.workspaces = [];
  3756. $scope.options.templateOptions.getpush = function (item) {
  3757. $scope.workspaces = [];
  3758. if (item.gu) {
  3759. $scope.workspaces.push({
  3760. id: 1,
  3761. name: "固定资产",
  3762. active: true,
  3763. contentUrl: "assets/views/customform/tpl/cmdb/gudingzichan.html",
  3764. });
  3765. }
  3766. if (item.hao) {
  3767. $scope.workspaces.push({
  3768. id: 2,
  3769. name: "耗材资产",
  3770. active: true,
  3771. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  3772. });
  3773. }
  3774. };
  3775. //获取附件列表
  3776. $scope.listAttachmen = function () {
  3777. to.ApiService.listAttachment(
  3778. to.listAttachmentUrl,
  3779. to.bindType,
  3780. bindId
  3781. ).then(function (result) {
  3782. var myData = Restangular.stripRestangular(result);
  3783. // $scope.listAttachmens = myData;
  3784. $scope.attachments = myData.data;
  3785. });
  3786. };
  3787. //附件列表
  3788. if ($scope.options.templateOptions.bindType) {
  3789. if (angular.isUndefined($scope.form.dropState)) {
  3790. $scope.form.dropState = false;
  3791. }
  3792. var to = $scope.options.templateOptions;
  3793. var bindId = $scope.model[to.bindType].processInstanceId;
  3794. $scope.listAttachmen();
  3795. }
  3796. // if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  3797. // $scope.listAttachmen();
  3798. // } else if (to.bindType && $scope.model[to.bindType].id) {
  3799. // $scope.listAttachmen();
  3800. // }
  3801. //附件下载
  3802. $scope.download = function (token, filename) {
  3803. var downUrl = to.ApiService.downloadAttachment(
  3804. to.downUrl,
  3805. token
  3806. ).getRequestedUrl();
  3807. // window.open(downUrl);
  3808. var a = document.createElement("a");
  3809. a.href = downUrl;
  3810. a.target = "_blank";
  3811. a.download = filename;
  3812. document.body.appendChild(a);
  3813. a.click();
  3814. };
  3815. //附件预览
  3816. $scope.view = function (id, previewUrl) {
  3817. if (previewUrl) {
  3818. window.open(previewUrl);
  3819. }
  3820. };
  3821. //下载资产模版
  3822. $scope.filenum = 0;
  3823. $scope.openmeans = function () {
  3824. var modalInstance = $modal.open({
  3825. templateUrl: "assets/views/means/tpl/meansdown.html",
  3826. controller: function ($scope, scope, $modalInstance) {
  3827. $scope.item = {};
  3828. $scope.title = "选择下载模版";
  3829. $scope.lable = "资产模版下载";
  3830. function foreachdata(my_datas) {
  3831. // angular.forEach(my_datas, function(item, index) {
  3832. // if (item.children && item.children.length > 0) {
  3833. // foreachdata(item.children);
  3834. // } else {
  3835. // my_datas[index].checks = true;
  3836. // }
  3837. // })
  3838. for (var i = 0; i < my_datas.length; i++) {
  3839. if (my_datas[i].children && my_datas[i].children.length > 0) {
  3840. foreachdata(my_datas[i].children);
  3841. console.log($scope);
  3842. } else {
  3843. my_datas[i].checks = true;
  3844. }
  3845. }
  3846. }
  3847. function foreachtree(data) {
  3848. angular.forEach(data, function (item) {
  3849. // if (item.checks != true) {
  3850. item.checks = true;
  3851. item.expanded = true;
  3852. if (item.children && item.children.length > 0) {
  3853. foreachtree(item.children);
  3854. } else {
  3855. $scope.getslowtree.push(item);
  3856. }
  3857. // }
  3858. });
  3859. }
  3860. $scope.getslowtree = [];
  3861. $scope.slowtree = function (tree) {
  3862. foreachtree(tree);
  3863. return $scope.getslowtree;
  3864. };
  3865. $scope.all = function (c, v) {
  3866. //全选
  3867. if (c == true) {
  3868. $scope.formdashboard($scope.slowtree(v));
  3869. } else {
  3870. $scope.my_data_after = [];
  3871. angular.forEach($scope.my_data, function (item, index) {
  3872. $scope.my_data[index].checks = false;
  3873. $scope.my_data[index].expanded = false;
  3874. if (item.children && item.children.length > 0) {
  3875. angular.forEach(
  3876. item.children,
  3877. function (itemone, indexone) {
  3878. $scope.my_data[index].children[
  3879. indexone
  3880. ].checks = false;
  3881. $scope.my_data[index].children[
  3882. indexone
  3883. ].expanded = false;
  3884. if (itemone.children && itemone.children.length > 0) {
  3885. angular.forEach(
  3886. itemone.children,
  3887. function (itemtwo, indextwo) {
  3888. $scope.my_data[index].children[
  3889. indexone
  3890. ].children[indextwo].checks = false;
  3891. }
  3892. );
  3893. } else {
  3894. }
  3895. }
  3896. );
  3897. } else {
  3898. }
  3899. });
  3900. $scope.mydatacate = [];
  3901. $scope.getslowtree = [];
  3902. // }
  3903. }
  3904. };
  3905. // $scope.searchone = function(search) {
  3906. // angular.forEach($scope.my_data, function(item) {
  3907. // if (item.indexOf(search) > 0) {
  3908. // }
  3909. // })
  3910. // }
  3911. $scope.checkall = function () {
  3912. angular.forEach($scope.my_data, function (item, index) {
  3913. scope.my_data[index].checks = true;
  3914. });
  3915. };
  3916. $scope.selectitem = [];
  3917. $scope.choiceitem = function (item) {
  3918. // if (item.checkeds) {
  3919. // item.checkeds = false;
  3920. // // for (var i = 0; i < $scope.selectitem.length; i++) {
  3921. // // if ($scope.selectitem[i].id == item.id) {
  3922. // // $scope.selectitem.splice(i, 1)
  3923. // // }
  3924. // // }
  3925. // for (var i = 0; i < $scope.my_data_after; i++) {
  3926. // if ($scope.my_data_after[i].id == item.id) {
  3927. // $scope.my_data_after[i].checkeds ? $scope.my_data_after[i].checkeds = false : $scope.my_data_after[i].checkeds = true;
  3928. // // $scope.selectitem.splice(i, 1)
  3929. // }
  3930. // }
  3931. // } else {
  3932. // item.checkeds = true;
  3933. // $scope.selectitem.push(item)
  3934. // }
  3935. for (var i = 0; i < $scope.my_data_after.length; i++) {
  3936. if ($scope.my_data_after[i].id == item.id) {
  3937. $scope.my_data_after[i].checkeds
  3938. ? ($scope.my_data_after[i].checkeds = false)
  3939. : ($scope.my_data_after[i].checkeds = true);
  3940. }
  3941. }
  3942. };
  3943. $scope.remove = function (removeitem) {
  3944. var realdat = angular.copy($scope.my_data_after);
  3945. // angular.extend(realdat, $scope.selectitem);
  3946. $scope.my_data_after = [];
  3947. angular.forEach(realdat, function (item) {
  3948. if (!item.checkeds) {
  3949. $scope.my_data_after.push(item);
  3950. }
  3951. });
  3952. $scope.mydatacate = angular.copy($scope.my_data_after);
  3953. };
  3954. $scope.try_async_loads = function (item, search) {
  3955. var fildatas = {
  3956. idx: 0,
  3957. sum: 1000,
  3958. };
  3959. $scope.my_data = [];
  3960. // $scope.try_async_load = true;
  3961. if (item) {
  3962. angular.extend(fildatas, item);
  3963. }
  3964. api_configure_data
  3965. .fetchDataList("ciclassify", fildatas)
  3966. .then(function (response) {
  3967. if (response.status == 200) {
  3968. var data = response.list;
  3969. var objects = [];
  3970. for (var i = 0; i < data.length; i++) {
  3971. var object = {};
  3972. object.id = data[i].id;
  3973. if (search) {
  3974. delete data[i].parent;
  3975. } else {
  3976. if (data[i].parent && data[i].parent.id != 0) {
  3977. object.parent = data[i].parent.id;
  3978. }
  3979. }
  3980. angular.extend(object, data[i]);
  3981. objects.push(object);
  3982. }
  3983. $scope.my_data = convertParentToChildList(objects);
  3984. $scope.tree_data = angular.copy($scope.my_data);
  3985. if ($scope.my_data.length > 0) {
  3986. $scope.try_async_load = false;
  3987. }
  3988. } else {
  3989. SweetAlert.swal({
  3990. title: "系统错误!",
  3991. text: "请刷新重试!",
  3992. type: "error",
  3993. });
  3994. }
  3995. });
  3996. };
  3997. function convertListToTree(data, treeMap) {
  3998. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  3999. var root = null; //Initially set our loop to null
  4000. //loop over data
  4001. for (var i = 0; i < data.length; i++) {
  4002. var datum = data[i];
  4003. //each node will have children, so let's give it a "children" poperty
  4004. datum.children = [];
  4005. //add an entry for this node to the map so that any future children can
  4006. //lookup the parent
  4007. idToNodeMap[datum.id] = datum;
  4008. //Does this node have a parent?
  4009. // console.log("datum="+JSON.stringify(datum))
  4010. if (
  4011. typeof datum.parent === "undefined" ||
  4012. datum.parent === null
  4013. ) {
  4014. //Doesn't look like it, so this node is the root of the tree
  4015. root = datum;
  4016. treeMap[datum.id] = root;
  4017. } else {
  4018. //This node has a parent, so let's look it up using the id
  4019. parentNode = idToNodeMap[datum.parent.id];
  4020. //We don't need this property, so let's delete it.
  4021. // delete datum.parent;
  4022. //Let's add the current node as a child of the parent node.
  4023. parentNode.children.push(datum);
  4024. }
  4025. }
  4026. return root;
  4027. }
  4028. function convertParentToChildList(data) {
  4029. var treeMap = {};
  4030. var list = [];
  4031. convertListToTree(data, treeMap);
  4032. angular.forEach(treeMap, function (item) {
  4033. list.push(item);
  4034. });
  4035. return list;
  4036. }
  4037. function convertParentToChild(datato) {
  4038. var treeMapto = {};
  4039. var listto = [];
  4040. convertListToTree(datato, treeMapto);
  4041. angular.forEach(treeMapto, function (items) {
  4042. listto.push(items);
  4043. });
  4044. return listto;
  4045. }
  4046. $scope.try_async_loads();
  4047. $scope.searchdown = function (key) {
  4048. if (key && key != "") {
  4049. $scope.try_async_loads(
  4050. {
  4051. ciclassify: {
  4052. label: key,
  4053. },
  4054. },
  4055. "search"
  4056. );
  4057. } else {
  4058. $scope.try_async_loads();
  4059. }
  4060. // var mydatacatedown = angular.copy($scope.my_data);
  4061. // $scope.my_data = [];
  4062. // var objects = [];
  4063. // angular.forEach(mydatacatedown, function(item) {
  4064. // if (item.label.match(key)) {
  4065. // objects.push(item)
  4066. // } else {
  4067. // // $scope.my_data_after.push(item)
  4068. // }
  4069. // })
  4070. // $scope.my_data = convertParentToChildList(objects);
  4071. // $scope.tree_data = angular.copy($scope.my_data);
  4072. };
  4073. $scope.mydatacate = [];
  4074. $scope.searchup = function (key) {
  4075. // var mydatacate = angular.copy($scope.my_data_after);
  4076. $scope.my_data_after = [];
  4077. angular.forEach($scope.mydatacate, function (item) {
  4078. if (item.label.match(key)) {
  4079. $scope.my_data_after.push(item);
  4080. } else {
  4081. }
  4082. });
  4083. };
  4084. //角色树
  4085. $scope.my_tree = [];
  4086. $scope.tree_data_after = [];
  4087. $scope.my_data = [];
  4088. $scope.my_data_after = [];
  4089. $scope.formdashboard = function (item) {
  4090. $scope.my_data_after = [];
  4091. angular.forEach(item, function (infox) {
  4092. if (infox.children.length == 0) {
  4093. $scope.my_data_after.push(infox);
  4094. }
  4095. });
  4096. $scope.mydatacate = angular.copy($scope.my_data_after);
  4097. };
  4098. $scope.ok = function (item) {
  4099. $modalInstance.close(item);
  4100. };
  4101. $scope.cancel = function () {
  4102. $modalInstance.dismiss("cancel");
  4103. };
  4104. },
  4105. // size: 'sm',
  4106. resolve: {
  4107. scope: function () {
  4108. return $scope;
  4109. },
  4110. },
  4111. });
  4112. modalInstance.result.then(function (selectedItem) {
  4113. // $rootScope.isMask = true;
  4114. if (selectedItem) {
  4115. var type = 1;
  4116. var fildat = {
  4117. configure: selectedItem,
  4118. };
  4119. // api_configure_data.downModeldata('cmdb', fildat).then(function(data) {
  4120. // // if (data.errno == 0) {
  4121. // var file = new Blob([data], {
  4122. // // 'Accept': '*/*'
  4123. // type: 'application/octet-stream'
  4124. // // type: 'application/vnd.ms-excel'
  4125. // });
  4126. // //trick to download store a file having its URL
  4127. // var fileURL = URL.createObjectURL(file);
  4128. // var a = document.createElement('a');
  4129. // a.href = fileURL;
  4130. // a.target = '_blank';
  4131. // a.download = "资产导入模版.xlsx";
  4132. // document.body.appendChild(a);
  4133. // a.click();
  4134. // // }
  4135. // })
  4136. $http({
  4137. url: api_configure_data
  4138. .downModels("export/cmdb", fildat)
  4139. .getRequestedUrl(),
  4140. method: "POST",
  4141. data: JSON.stringify(fildat),
  4142. headers: {
  4143. // 'Content-type': 'application/xls',
  4144. Accept: "*/*",
  4145. },
  4146. responseType: "arraybuffer",
  4147. })
  4148. .success(function (data, status, headers, config) {
  4149. $rootScope.isMask = false;
  4150. var file = new Blob([data], {
  4151. type: "application/octet-stream",
  4152. // type : 'application/vnd.ms-excel'
  4153. });
  4154. //trick to download store a file having its URL
  4155. var fileURL = URL.createObjectURL(file);
  4156. var a = document.createElement("a");
  4157. a.href = fileURL;
  4158. a.target = "_blank";
  4159. a.download = "资产导入模版.xlsx";
  4160. document.body.appendChild(a);
  4161. a.click();
  4162. })
  4163. .error(function (data, status, headers, config) {
  4164. // console.log(data);
  4165. $rootScope.isMask = false;
  4166. });
  4167. // break;
  4168. // }
  4169. // }
  4170. // }
  4171. // })
  4172. } else {
  4173. SweetAlert.swal(
  4174. {
  4175. title: "未选择资产分类!",
  4176. text: "请选择资产分类",
  4177. type: "error",
  4178. },
  4179. function () {
  4180. $rootScope.isMask = false;
  4181. }
  4182. );
  4183. }
  4184. // }
  4185. });
  4186. };
  4187. $scope.wrongdata = [];
  4188. var uploader = ($scope.uploader =
  4189. $scope.options.templateOptions.fileUploader);
  4190. var uploadermeans = ($scope.uploadermeans =
  4191. $scope.options.templateOptions.fileUploadermeans);
  4192. $scope.importopen = function () {
  4193. //导入触发事件
  4194. if (angular.isUndefined($scope.form.dropState)) {
  4195. $scope.form.dropState = false;
  4196. }
  4197. //附件上传数据
  4198. //$scope.options.templateOptions.uploader();
  4199. // FILTERS
  4200. uploader.filters.push({
  4201. name: "customFilter",
  4202. fn: function (item /*{File|FileLikeObject}*/, options) {
  4203. return this.queue.length < 2;
  4204. },
  4205. });
  4206. // CALLBACKS
  4207. uploader.onWhenAddingFileFailed = function (
  4208. item /*{File|FileLikeObject}*/,
  4209. filter,
  4210. options
  4211. ) {
  4212. console.info("onWhenAddingFileFailed", item, filter, options);
  4213. };
  4214. uploader.onAfterAddingFile = function (fileItem) {
  4215. console.info("onAfterAddingFile", fileItem);
  4216. };
  4217. uploader.onAfterAddingAll = function (addedFileItems) {
  4218. console.info("onAfterAddingAll", addedFileItems);
  4219. };
  4220. uploader.onBeforeUploadItem = function (item) {
  4221. console.info("onBeforeUploadItem", item);
  4222. };
  4223. uploader.onProgressItem = function (fileItem, progress) {
  4224. console.info("onProgressItem", fileItem, progress);
  4225. };
  4226. uploader.onProgressAll = function (progress) {
  4227. console.info("onProgressAll", progress);
  4228. };
  4229. // uploader.onSuccessItem = function(fileItem, response, status, headers) {
  4230. // console.info('onSuccessItem', fileItem, response, status, headers);
  4231. // };
  4232. uploader.onErrorItem = function (
  4233. fileItem,
  4234. response,
  4235. status,
  4236. headers
  4237. ) {
  4238. console.info("onErrorItem", fileItem, response, status, headers);
  4239. };
  4240. uploader.onCancelItem = function (
  4241. fileItem,
  4242. response,
  4243. status,
  4244. headers
  4245. ) {
  4246. console.info("onCancelItem", fileItem, response, status, headers);
  4247. };
  4248. uploader.onCompleteItem = function (
  4249. fileItem,
  4250. response,
  4251. status,
  4252. headers
  4253. ) {
  4254. console.info("onCompleteItem", fileItem, response, status, headers);
  4255. };
  4256. uploader.onCompleteAll = function () {
  4257. console.info("onCompleteAll");
  4258. };
  4259. };
  4260. // $scope.importnext = function() {
  4261. // $scope.state = 2;
  4262. // event.preventDefault();
  4263. // }
  4264. $scope.importnext = function () {
  4265. event.preventDefault();
  4266. // $rootScope.isMask = true;
  4267. $rootScope.loading = true;
  4268. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4269. uploader.onBeforeUploadItem = function (item) {
  4270. angular.extend(item.headers, $rootScope.getSession());
  4271. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4272. // if (item.index > 1) {
  4273. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4274. // }
  4275. // item.index = 1;
  4276. item.formData = [
  4277. {
  4278. filename: item.file.name,
  4279. },
  4280. ];
  4281. console.info("onBeforeUploadItem", item);
  4282. };
  4283. uploader.uploadAll();
  4284. uploader.onSuccessItem = function (
  4285. fileItem,
  4286. response,
  4287. status,
  4288. headers
  4289. ) {
  4290. if (response.status == 200) {
  4291. $scope.wrongdata = [];
  4292. $rootScope.loading = false;
  4293. if (response.abnormal) {
  4294. $scope.state = 2;
  4295. angular.forEach(response.msg, function (item) {
  4296. $scope.wrongdata.push({
  4297. name: item.assetName,
  4298. line: item.row,
  4299. cmdbname: item.name,
  4300. errotip: [
  4301. {
  4302. label: item.msg,
  4303. },
  4304. ],
  4305. });
  4306. });
  4307. } else {
  4308. $scope.state = 3;
  4309. }
  4310. } else {
  4311. $rootScope.loading = false;
  4312. $scope.state = 2;
  4313. }
  4314. };
  4315. };
  4316. $scope.clearItems = function () {
  4317. //重新选择文件时,清空队列,达到覆盖文件的效果
  4318. uploader.clearQueue();
  4319. // uploader.remove();
  4320. // uploader.cancel();
  4321. // uploader.onChange();
  4322. };
  4323. uploader.onAfterAddingFile = function (fileItem) {
  4324. $scope.fileItem = fileItem._file;
  4325. // $scope.$apply();
  4326. // $scope.fileItem = filenum;
  4327. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + "."); //添加文件之后,把文件信息赋给scope
  4328. // $scope.fileItem.name = fileItem._file.name.replace(".", "_" + filenum + ".");
  4329. $scope.filenum++;
  4330. };
  4331. uploader.onSuccessItem = function (
  4332. fileItem,
  4333. response,
  4334. status,
  4335. headers
  4336. ) {
  4337. $scope.uploadStatus = true; //上传成功则把状态改为true
  4338. // alert(response.path);
  4339. };
  4340. $scope.importnext = function () {
  4341. event.preventDefault();
  4342. // uploader.onChange();
  4343. $rootScope.loading = true;
  4344. // $scope.loadingtext = "正在导入中,请暂时不要离开此界面..."
  4345. uploader.onBeforeUploadItem = function (item) {
  4346. angular.extend(item.headers, $rootScope.getSession());
  4347. item.url = api_cmdb_new.checkFile(1).getRequestedUrl();
  4348. // if (item.index > 1) {
  4349. // item.formData = [{ 'filename': item.file.name + '_' + (item.index - 1) }];
  4350. // }
  4351. // item.index = 1;
  4352. item.formData = [
  4353. {
  4354. filename: item.file.name,
  4355. },
  4356. ];
  4357. console.info("onBeforeUploadItem", item);
  4358. };
  4359. uploader.uploadAll();
  4360. uploader.onSuccessItem = function (
  4361. fileItem,
  4362. response,
  4363. status,
  4364. headers
  4365. ) {
  4366. if (response.status == 200) {
  4367. $scope.wrongdata = [];
  4368. // uploader.queue = [];
  4369. $rootScope.loading = false;
  4370. if (response.abnormal) {
  4371. $scope.state = 2;
  4372. uploader.clearQueue();
  4373. angular.forEach(response.msg, function (item) {
  4374. $scope.wrongdata.push({
  4375. name: item.assetName,
  4376. line: item.row,
  4377. cmdbname: item.name,
  4378. errotip: [
  4379. {
  4380. label: item.msg,
  4381. },
  4382. ],
  4383. });
  4384. });
  4385. } else {
  4386. $scope.state = 3;
  4387. }
  4388. } else {
  4389. uploader.clearQueue();
  4390. $rootScope.loading = false;
  4391. $scope.state = 2;
  4392. }
  4393. };
  4394. };
  4395. var setAllInactive = function () {
  4396. angular.forEach($scope.workspaces, function (workspace) {
  4397. workspace.active = false;
  4398. });
  4399. };
  4400. //添加
  4401. var addNewWorkspace = function (name, contentUrl) {
  4402. var id = $scope.workspaces.length + 1;
  4403. $scope.workspaces.push({
  4404. id: id,
  4405. name: name,
  4406. active: true,
  4407. contentUrl: "main/html/content.html",
  4408. });
  4409. };
  4410. //关闭
  4411. $scope.closeopen = function (closedata) {
  4412. event.preventDefault();
  4413. angular.forEach($scope.workspaces, function (item, index) {
  4414. if (closedata.id == item.id) {
  4415. if (closedata.id == 1) {
  4416. $scope.$parent.$parent.$parent.model.uplodtype.gu = false;
  4417. } else {
  4418. $scope.$parent.$parent.$parent.model.uplodtype.hao = false;
  4419. }
  4420. $scope.workspaces.splice(index, 1);
  4421. }
  4422. });
  4423. };
  4424. // $scope.workspaces = [
  4425. // { id: 1, name: "固定资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/gudingzichan.html' },
  4426. // { id: 2, name: "耗材资产", active: true, contentUrl: 'assets/views/customform/tpl/cmdb/haocai.html' }
  4427. // ];
  4428. $scope.addWorkspace = function (contentUrl, name) {
  4429. setAllInactive();
  4430. addNewWorkspace(name, contentUrl);
  4431. };
  4432. // $rootScope.addWorkspace = $scope.addWorkspace;
  4433. $scope.close = function (idNumber) {
  4434. var index = 0; //记录当前元素下标
  4435. angular.forEach($scope.workspaces, function (workspace) {
  4436. if (workspace.id === idNumber) {
  4437. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4438. }
  4439. index++;
  4440. });
  4441. };
  4442. //grid2
  4443. $scope.langs = i18nService.getAllLangs();
  4444. $scope.lang = "zh-cn";
  4445. i18nService.setCurrentLang($scope.lang);
  4446. $scope.gridOptions2 = {};
  4447. $scope.gridOptions2.data = "myData3";
  4448. $scope.gridOptions2.enableColumnResizing = true;
  4449. $scope.gridOptions2.enableFiltering = false;
  4450. $scope.gridOptions2.enableGridMenu = false;
  4451. $scope.gridOptions2.showGridFooter = true;
  4452. $scope.gridOptions2.showColumnFooter = false;
  4453. $scope.gridOptions2.fastWatch = true;
  4454. $scope.gridOptions2.useExternalFiltering = true;
  4455. $scope.gridOptions2.useExternalPagination = true;
  4456. $scope.gridOptions2.paginationPageSizes = [10];
  4457. $scope.gridOptions2.paginationPageSize = 10;
  4458. $scope.gridOptions2.multiSelect = false;
  4459. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  4460. $scope.gridOptions2.columnDefs = [
  4461. {
  4462. name: "item",
  4463. displayName: "序号",
  4464. width: 120,
  4465. },
  4466. {
  4467. name: "name",
  4468. displayName: "耗材名称",
  4469. width: 80,
  4470. enableFiltering: false,
  4471. },
  4472. {
  4473. name: "model",
  4474. displayName: "品牌/型号",
  4475. width: 100,
  4476. enableFiltering: false,
  4477. },
  4478. {
  4479. name: "Specifications",
  4480. displayName: "规格",
  4481. width: 150,
  4482. enableFiltering: false,
  4483. },
  4484. {
  4485. name: "sum",
  4486. displayName: "数量",
  4487. enableFiltering: false,
  4488. },
  4489. {
  4490. name: "操作",
  4491. cellTemplate:
  4492. '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  4493. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  4494. "</div></div>",
  4495. enableFiltering: false,
  4496. },
  4497. ];
  4498. if ($scope.$parent.$parent.$parent.model.uplodtype) {
  4499. if ($scope.$parent.$parent.$parent.model.uplodtype.hao == "true") {
  4500. $scope.myData3all = JSON.parse(
  4501. $scope.$parent.$parent.$parent.model.applicationForm.consumables
  4502. );
  4503. for (var i = 0; i < $scope.myData3all.length; i++) {
  4504. $scope.myData3all[i]["item"] =
  4505. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  4506. }
  4507. // $scope.model.consumables = $scope.myDataone;
  4508. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4509. $scope.myData3 = $scope.interceptMydata($scope.myData3all, 0, 10);
  4510. $scope.model.applicationForm.consumables = $scope.myData3all;
  4511. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4512. $scope.options.templateOptions.getpush({
  4513. hao: true,
  4514. gu: true,
  4515. });
  4516. } else {
  4517. $scope.options.templateOptions.getpush({
  4518. hao: true,
  4519. });
  4520. }
  4521. } else {
  4522. if ($scope.$parent.$parent.$parent.model.uplodtype.gu == "true") {
  4523. $scope.options.templateOptions.getpush({
  4524. gu: true,
  4525. });
  4526. }
  4527. }
  4528. }
  4529. $scope.options.templateOptions.workspaces = $scope.workspaces;
  4530. $scope.changecai = function (item) {
  4531. event.preventDefault();
  4532. var modalInstance = $modal.open({
  4533. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  4534. controller: function ($scope, $modalInstance) {
  4535. $scope.title = "修改耗材数量";
  4536. $scope.consumptive = angular.copy(item);
  4537. $scope.ok = function () {
  4538. $modalInstance.close($scope.consumptive);
  4539. };
  4540. $scope.cancel = function () {
  4541. $modalInstance.dismiss("cancel");
  4542. };
  4543. },
  4544. size: "sm",
  4545. });
  4546. modalInstance.result.then(function (selectedItem) {
  4547. // angular.forEach($scope.myData3, function(items, index) {
  4548. // if (items.id == selectedItem.id) {
  4549. // $scope.myData3[index] = selectedItem;
  4550. // }
  4551. // })
  4552. // // $scope.myData3.push(selectedItem);
  4553. // $scope.model.applicationForm.consumables = $scope.myData3;
  4554. angular.forEach($scope.myData3all, function (items, index) {
  4555. if (
  4556. items.modelid == selectedItem.modelid &&
  4557. items.nameid == selectedItem.nameid &&
  4558. items.Specificationsid == selectedItem.Specificationsid
  4559. ) {
  4560. // item.model.id == itemsdata.modelid && item.name.id == itemsdata.nameid && item.Specifications.id == itemsdata.Specificationsid
  4561. angular.extend($scope.myData3all[index], selectedItem);
  4562. }
  4563. });
  4564. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4565. $scope.myData3 = $scope.interceptMydata(
  4566. $scope.myData3all,
  4567. $scope.memoryfilterDatahao.idx,
  4568. 10
  4569. );
  4570. $scope.model.applicationForm.consumables = $scope.myData3all;
  4571. });
  4572. };
  4573. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  4574. $scope.gridApi = gridApi;
  4575. gridApi.pagination.on.paginationChanged(
  4576. $scope,
  4577. function (newPage, pageSize) {
  4578. // var filtersData = $scope.memoryfilterDatahao;
  4579. // filtersData.idx = newPage - 1;
  4580. // filtersData.sum = pageSize;
  4581. // $scope.loadData(filtersData);
  4582. $scope.memoryfilterDatahao.idx = newPage - 1;
  4583. $scope.memoryfilterDatahao.sum = pageSize;
  4584. $scope.myData3 = $scope.interceptMydata(
  4585. $scope.myData3all,
  4586. $scope.memoryfilterDatahao.idx,
  4587. 10
  4588. );
  4589. }
  4590. );
  4591. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  4592. $scope.selected.items = data.entity;
  4593. //console.log(data);
  4594. });
  4595. gridApi.selection.on.rowSelectionChangedBatch(
  4596. $scope,
  4597. function (data) {
  4598. $scope.selected.items = data.entity;
  4599. //console.log(data);
  4600. }
  4601. );
  4602. gridApi.core.on.filterChanged($scope, function () {
  4603. var grid = this.grid;
  4604. var filtersData = {
  4605. idx: 0,
  4606. sum: 10,
  4607. };
  4608. $scope.memoryfilterDatahao = filtersData;
  4609. // $scope.loadData(filtersData);
  4610. // $scope.memoryfilterDatahao.idx = newPage - 1;
  4611. // $scope.memoryfilterDatahao.sum = pageSize;
  4612. $scope.myData3 = $scope.interceptMydata(
  4613. $scope.myData3all,
  4614. $scope.memoryfilterDatahao.idx,
  4615. 10
  4616. );
  4617. });
  4618. };
  4619. $scope.haocaiopen = function (items) {
  4620. event.preventDefault();
  4621. var modalInstance = $modal.open({
  4622. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  4623. controller: function ($scope, $modalInstance, SweetAlert) {
  4624. $scope.consumptive = {};
  4625. $scope.title = "新增耗材";
  4626. if (items.name) {
  4627. $scope.consumptive.name = items.name.name;
  4628. }
  4629. $scope.clearNoNum = function (obj, attr) {
  4630. //先把非数字的都替换掉,除了数字和.
  4631. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4632. //必须保证第一个为数字而不是.
  4633. obj[attr] = obj[attr].replace(/^\./g, "");
  4634. //保证只有出现一个.而没有多个.
  4635. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4636. //保证.只出现一次,而不能出现两次以上
  4637. obj[attr] = obj[attr]
  4638. .replace(".", "$#$")
  4639. .replace(/\./g, "")
  4640. .replace("$#$", ".");
  4641. //小于最大值
  4642. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4643. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4644. // obj[attr] = '';
  4645. // }
  4646. };
  4647. $scope.ok = function (item) {
  4648. // if (item.name && item.model && item.Specifications && item.sum) {
  4649. if (
  4650. item.name &&
  4651. item.model &&
  4652. JSON.stringify(item.model) != "{}" &&
  4653. item.Specifications &&
  4654. JSON.stringify(item.Specifications) != "{}" &&
  4655. item.sum
  4656. ) {
  4657. $modalInstance.close(item);
  4658. } else {
  4659. SweetAlert.swal({
  4660. title: "数据填写不完整!",
  4661. text: "请检查数据然后提交!",
  4662. type: "error",
  4663. });
  4664. }
  4665. };
  4666. $scope.cancel = function () {
  4667. $modalInstance.dismiss("cancel");
  4668. };
  4669. },
  4670. size: "sm",
  4671. resolve: {
  4672. SweetAlert: function () {
  4673. return SweetAlert;
  4674. },
  4675. },
  4676. });
  4677. modalInstance.result.then(function (selectedItem) {
  4678. api_sysinfo
  4679. .addData("dictionaryTree", {
  4680. // "type": "list",
  4681. key: "haocaifenlei",
  4682. name: selectedItem.name,
  4683. parent: selectedItem.id,
  4684. value: selectedItem.name,
  4685. deleted: false,
  4686. level: 1,
  4687. })
  4688. .then(function (data) {
  4689. // $scope.haocainame.name = data.list;
  4690. api_sysinfo
  4691. .addData("dictionaryTree", {
  4692. // "type": "list",
  4693. key: "pinpai",
  4694. name: selectedItem.model,
  4695. parent: data.id,
  4696. value: selectedItem.model,
  4697. deleted: false,
  4698. level: 2,
  4699. })
  4700. .then(function (data) {
  4701. // $scope.haocainame = data.list;
  4702. });
  4703. api_sysinfo
  4704. .addData({
  4705. // "type": "list",
  4706. key: "guige",
  4707. name: selectedItem.Specifications,
  4708. parent: data.id,
  4709. value: selectedItem.Specifications,
  4710. deleted: false,
  4711. level: 2,
  4712. })
  4713. .then(function (data) {
  4714. // $scope.haocainame = data.list;
  4715. });
  4716. });
  4717. // $scope.myData3.push(selectedItem);
  4718. // for (var i = 0; i < $scope.myData3.length; i++) {
  4719. // $scope.myData3[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  4720. // }
  4721. // $scope.model.applicationForm.consumables = $scope.myData3;
  4722. $scope.myData3all.push(selectedItem);
  4723. for (var i = 0; i < $scope.myData3all.length; i++) {
  4724. $scope.myData3all[i]["item"] = i + 1;
  4725. }
  4726. // $scope.model.consumables = $scope.myDataone;
  4727. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4728. $scope.myData3 = $scope.interceptMydata(
  4729. $scope.myData3all,
  4730. $scope.memoryfilterDatahao.idx,
  4731. 10
  4732. );
  4733. $scope.model.applicationForm.consumables = $scope.myData3all;
  4734. });
  4735. };
  4736. $scope.haocaiadd = function () {
  4737. event.preventDefault();
  4738. var modalInstance = $modal.open({
  4739. templateUrl:
  4740. "assets/views/customform/tpl/cmdb/addchangehaocai.html",
  4741. controller: function (
  4742. $scope,
  4743. scope,
  4744. $modalInstance,
  4745. api_wechatfile,
  4746. SweetAlert,
  4747. api_cmdb3
  4748. ) {
  4749. $scope.haocainame = [];
  4750. $scope.pinpai = [];
  4751. $scope.guige = [];
  4752. $scope.consumptive = {};
  4753. $scope.consumpall = {};
  4754. $scope.title = "添加耗材";
  4755. api_wechatfile
  4756. .getDictionary({
  4757. key: "haocaifenlei",
  4758. type: "tree",
  4759. })
  4760. .then(function (data) {
  4761. $scope.haocainame = data;
  4762. });
  4763. $scope.clearNoNum = function (obj, attr) {
  4764. //先把非数字的都替换掉,除了数字和.
  4765. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  4766. //必须保证第一个为数字而不是.
  4767. obj[attr] = obj[attr].replace(/^\./g, "");
  4768. //保证只有出现一个.而没有多个.
  4769. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  4770. //保证.只出现一次,而不能出现两次以上
  4771. obj[attr] = obj[attr]
  4772. .replace(".", "$#$")
  4773. .replace(/\./g, "")
  4774. .replace("$#$", ".");
  4775. //小于最大值
  4776. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  4777. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  4778. // obj[attr] = '';
  4779. // }
  4780. };
  4781. $scope.onChange = function (parent) {
  4782. $scope.consumptive.model = {};
  4783. $scope.consumptive.Specifications = {};
  4784. api_wechatfile
  4785. .getDictionaryForList({
  4786. key: "pinpai",
  4787. parent: parent.id,
  4788. })
  4789. .then(function (data) {
  4790. $scope.pinpai = data;
  4791. });
  4792. api_wechatfile
  4793. .getDictionaryForList({
  4794. key: "guige",
  4795. parent: parent.id,
  4796. })
  4797. .then(function (data) {
  4798. $scope.guige = data;
  4799. });
  4800. };
  4801. $scope.addhaocai = function () {
  4802. $modalInstance.dismiss("cancel");
  4803. scope.haocaiopen($scope.consumptive);
  4804. };
  4805. $scope.ok = function (item) {
  4806. var items = {};
  4807. var submittrue = true;
  4808. if (
  4809. item.name &&
  4810. item.model &&
  4811. JSON.stringify(item.model) != "{}" &&
  4812. item.Specifications &&
  4813. JSON.stringify(item.Specifications) != "{}" &&
  4814. item.sum
  4815. ) {
  4816. items = {
  4817. modelid: item.model.id,
  4818. nameid: item.name.id,
  4819. Specificationsid: item.Specifications.id,
  4820. name: item.name.name,
  4821. model: item.model.name,
  4822. Specifications: item.Specifications.name,
  4823. sum: item.sum,
  4824. };
  4825. angular.forEach(scope.myData3all, function (itemsdata) {
  4826. if (
  4827. item.model.id == itemsdata.modelid &&
  4828. item.name.id == itemsdata.nameid &&
  4829. item.Specifications.id == itemsdata.Specificationsid
  4830. ) {
  4831. submittrue = false;
  4832. }
  4833. });
  4834. if (submittrue) {
  4835. $modalInstance.close(items);
  4836. } else {
  4837. SweetAlert.swal({
  4838. title: "该耗材已有添加",
  4839. text: "请检查数据然后提交!",
  4840. type: "error",
  4841. });
  4842. }
  4843. } else {
  4844. SweetAlert.swal({
  4845. title: "数据填写不完整!",
  4846. text: "请检查数据然后提交!",
  4847. type: "error",
  4848. });
  4849. }
  4850. // var isold = false;
  4851. // if (item.name && item.model && item.Specifications && item.sum) {
  4852. // for (var i = 0; i < scope.myData3all.length; i++) {
  4853. // if (scope.myData3all[i].id == $scope.consumpall.id) {
  4854. // isold = true;
  4855. // }
  4856. // }
  4857. // if (isold) {
  4858. // SweetAlert.swal({
  4859. // title: "该耗材已添加!",
  4860. // text: "请不要重复添加耗材!",
  4861. // type: "error"
  4862. // });
  4863. // } else {
  4864. // $scope.consumpall.model = $scope.consumpall.brandModel;
  4865. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  4866. // $scope.consumpall.sum = item.sum;
  4867. // delete $scope.consumpall.brandModel;
  4868. // delete $scope.consumpall.specification;
  4869. // $modalInstance.close($scope.consumpall);
  4870. // }
  4871. // } else {
  4872. // SweetAlert.swal({
  4873. // title: "数据填写不完整!",
  4874. // text: "请检查数据然后提交!",
  4875. // type: "error"
  4876. // });
  4877. // }
  4878. };
  4879. $scope.cancel = function () {
  4880. $modalInstance.dismiss("cancel");
  4881. };
  4882. },
  4883. size: "sm",
  4884. resolve: {
  4885. scope: function () {
  4886. return $scope;
  4887. },
  4888. },
  4889. });
  4890. modalInstance.result.then(function (selectedItem) {
  4891. $scope.myData3all.push(selectedItem);
  4892. for (var i = 0; i < $scope.myData3all.length; i++) {
  4893. $scope.myData3all[i]["item"] = i + 1;
  4894. }
  4895. // $scope.model.consumables = $scope.myDataone;
  4896. $scope.gridOptions2["totalItems"] = $scope.myData3all.length;
  4897. $scope.myData3 = $scope.interceptMydata(
  4898. $scope.myData3all,
  4899. $scope.memoryfilterDatahao.idx,
  4900. 10
  4901. );
  4902. $scope.model.applicationForm.consumables = $scope.myData3all;
  4903. });
  4904. };
  4905. $scope.onDblClick = function (data, event) {
  4906. $scope.selectButtonClick(data, event);
  4907. };
  4908. // $scope.memoryfilterDatahao = {
  4909. // "idx": 0,
  4910. // "sum": 10,
  4911. // }
  4912. // $scope.loadData = function(filterData) {};
  4913. // $scope.title = title;
  4914. if (angular.isFunction($scope.options.templateOptions.transform)) {
  4915. $scope.options.templateOptions.transform(
  4916. $scope.options,
  4917. $rootScope,
  4918. $scope
  4919. );
  4920. }
  4921. },
  4922. ],
  4923. });
  4924. //归还设备耗材tab
  4925. formlyConfigProvider.setType({
  4926. name: "ui-cmdbreturntab",
  4927. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbreturntab.html",
  4928. wrapper: ["bootstrapHasError"],
  4929. defaultOptions: function (options, $scope) {
  4930. return {
  4931. templateOptions: {
  4932. // checkform: function(options) {
  4933. // if (options.model.requester) {
  4934. // options.value(options.model.requester);
  4935. // }
  4936. // },
  4937. },
  4938. };
  4939. },
  4940. controller: [
  4941. "$scope",
  4942. "$modal",
  4943. "api_user_data",
  4944. "i18nService",
  4945. "api_wechatfile",
  4946. "api_cmdb3",
  4947. function (
  4948. $scope,
  4949. $modal,
  4950. api_user_data,
  4951. i18nService,
  4952. api_wechatfile,
  4953. api_cmdb3
  4954. ) {
  4955. var setAllInactive = function () {
  4956. angular.forEach($scope.workspaces, function (workspace) {
  4957. workspace.active = false;
  4958. });
  4959. };
  4960. $scope.memoryfilterData = {
  4961. idx: 0,
  4962. sum: 10,
  4963. };
  4964. //添加
  4965. var addNewWorkspace = function (name, contentUrl) {
  4966. var id = $scope.workspaces.length + 1;
  4967. $scope.workspaces.push({
  4968. id: id,
  4969. name: name,
  4970. active: true,
  4971. contentUrl: "main/html/content.html",
  4972. });
  4973. };
  4974. $scope.workspaces = [
  4975. {
  4976. id: 1,
  4977. name: "归还设备",
  4978. active: true,
  4979. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  4980. },
  4981. {
  4982. id: 2,
  4983. name: "归还耗材",
  4984. active: true,
  4985. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  4986. },
  4987. ];
  4988. $scope.addWorkspace = function (contentUrl, name) {
  4989. setAllInactive();
  4990. addNewWorkspace(name, contentUrl);
  4991. };
  4992. // $rootScope.addWorkspace = $scope.addWorkspace;
  4993. $scope.close = function (idNumber) {
  4994. var index = 0; //记录当前元素下标
  4995. angular.forEach($scope.workspaces, function (workspace) {
  4996. if (workspace.id === idNumber) {
  4997. $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  4998. }
  4999. index++;
  5000. });
  5001. };
  5002. $scope.memoryfilterDataguishe = {
  5003. idx: 0,
  5004. sum: 10,
  5005. };
  5006. //grid1
  5007. $scope.langs = i18nService.getAllLangs();
  5008. $scope.lang = "zh-cn";
  5009. i18nService.setCurrentLang($scope.lang);
  5010. $scope.gridOptions1 = {};
  5011. $scope.gridOptions1.data = "myData1";
  5012. $scope.gridOptions1.enableColumnResizing = true;
  5013. $scope.gridOptions1.enableFiltering = false;
  5014. $scope.gridOptions1.enableGridMenu = false;
  5015. $scope.gridOptions1.showGridFooter = true;
  5016. $scope.gridOptions1.showColumnFooter = false;
  5017. $scope.gridOptions1.fastWatch = true;
  5018. $scope.gridOptions1.useExternalFiltering = true;
  5019. $scope.gridOptions1.useExternalPagination = true;
  5020. $scope.gridOptions1.paginationPageSizes = [10];
  5021. $scope.gridOptions1.paginationPageSize = 10;
  5022. $scope.gridOptions1.multiSelect = false;
  5023. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5024. $scope.gridOptions1.columnDefs = [
  5025. {
  5026. name: "item",
  5027. displayName: "序号",
  5028. width: 120,
  5029. },
  5030. {
  5031. name: "props.hw_cifilterClassic",
  5032. displayName: "设备类型",
  5033. width: 150,
  5034. enableFiltering: false,
  5035. },
  5036. {
  5037. name: "props.hw_mingcheng",
  5038. displayName: "设备名称",
  5039. width: 180,
  5040. enableFiltering: false,
  5041. },
  5042. {
  5043. name: "uuid",
  5044. displayName: "设备编号",
  5045. width: 180,
  5046. enableFiltering: false,
  5047. },
  5048. {
  5049. name: "props.hw_state",
  5050. width: 150,
  5051. displayName: "状态",
  5052. enableFiltering: false,
  5053. },
  5054. {
  5055. name: "操作",
  5056. cellTemplate:
  5057. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5058. '<a ng-click="grid.appScope.changegu(row.entity)" class="bianjifont">修改状态</a>' +
  5059. "</div></div>",
  5060. enableFiltering: false,
  5061. },
  5062. ];
  5063. // $scope.selectButtonClick
  5064. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5065. $scope.gridApi = gridApi;
  5066. gridApi.pagination.on.paginationChanged(
  5067. $scope,
  5068. function (newPage, pageSize) {
  5069. // var filtersData = $scope.memoryfilterData;
  5070. // filtersData.idx = newPage - 1;
  5071. // filtersData.sum = pageSize;
  5072. // $scope.loadData(filtersData);
  5073. $scope.memoryfilterDataguishe.idx = newPage - 1;
  5074. $scope.memoryfilterDataguishe.sum = pageSize;
  5075. $scope.myData1 = $scope.interceptMydata(
  5076. $scope.myData2all,
  5077. $scope.memoryfilterDataguishe.idx,
  5078. 10
  5079. );
  5080. }
  5081. );
  5082. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5083. $scope.selected.items = data.entity;
  5084. //console.log(data);
  5085. });
  5086. gridApi.selection.on.rowSelectionChangedBatch(
  5087. $scope,
  5088. function (data) {
  5089. $scope.selected.items = data.entity;
  5090. //console.log(data);
  5091. }
  5092. );
  5093. gridApi.core.on.filterChanged($scope, function () {
  5094. // var grid = this.grid;
  5095. // var filtersData = {
  5096. // idx: 0,
  5097. // sum: 20,
  5098. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5099. // };
  5100. // angular.forEach(grid.columns, function(item) {
  5101. // if (item.enableFiltering) {
  5102. // // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5103. // if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  5104. // if (angular.isUndefined(filtersData['user'])) {
  5105. // filtersData['user'] = {};
  5106. // }
  5107. // filtersData['user'][item.field] = item.filters[0].term;
  5108. // }
  5109. // }
  5110. // });
  5111. // $scope.memoryfilterData = filtersData;
  5112. // $scope.loadData(filtersData);
  5113. });
  5114. };
  5115. $scope.changegu = function (item) {
  5116. event.preventDefault();
  5117. var modalInstance = $modal.open({
  5118. templateUrl: "assets/views/customform/tpl/cmdb/changestate.html",
  5119. controller: function ($scope, $modalInstance) {
  5120. $scope.title = "修改设备状态";
  5121. $scope.hw_state = {};
  5122. if (item.status) {
  5123. $scope.hw_state.name = item.hw_state;
  5124. }
  5125. // $scope.consumptive = item;
  5126. $scope.stateshe = [
  5127. {
  5128. id: 2,
  5129. name: "在库",
  5130. },
  5131. {
  5132. id: 4,
  5133. name: "报修",
  5134. },
  5135. {
  5136. id: 3,
  5137. name: "报废",
  5138. },
  5139. ];
  5140. $scope.ok = function (item) {
  5141. $modalInstance.close($scope.hw_state);
  5142. };
  5143. $scope.cancel = function () {
  5144. $modalInstance.dismiss("cancel");
  5145. };
  5146. },
  5147. size: "sm",
  5148. });
  5149. modalInstance.result.then(function (selectedItem) {
  5150. angular.forEach($scope.myData1, function (items, index) {
  5151. if (items.id == item.id) {
  5152. $scope.myData1[index].props.hw_state = selectedItem.id.name;
  5153. }
  5154. });
  5155. $scope.model.assets = $scope.myData1;
  5156. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  5157. $scope.model.assets;
  5158. });
  5159. };
  5160. $scope.onDblClick = function (data, event) {
  5161. $scope.selectButtonClick(data, event);
  5162. };
  5163. $scope.memoryfilterData = {
  5164. idx: 0,
  5165. sum: 10,
  5166. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5167. };
  5168. // $scope.myData = {};
  5169. $scope.loadData = function (filterData) { };
  5170. // $scope.title = title;
  5171. $scope.loadData({
  5172. idx: 0,
  5173. sum: 10,
  5174. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  5175. });
  5176. $scope.selected = {
  5177. items: [],
  5178. };
  5179. $scope.myData2 = [];
  5180. $scope.consumptive = {};
  5181. $scope.myDataguibeiall = [];
  5182. $scope.haocaiopen = function (items) {
  5183. event.preventDefault();
  5184. var modalInstance = $modal.open({
  5185. templateUrl: "assets/views/customform/tpl/cmdb/addhaocai.html",
  5186. controller: function (
  5187. $scope,
  5188. $modalInstance,
  5189. SweetAlert,
  5190. api_wechatfile,
  5191. api_sysinfo
  5192. ) {
  5193. $scope.consumptive = {};
  5194. $scope.title = "新增耗材";
  5195. if (items.name) {
  5196. $scope.consumptive.name = items.name.name;
  5197. }
  5198. $scope.ok = function (item) {
  5199. if (
  5200. item.name &&
  5201. item.model &&
  5202. JSON.stringify(item.model) != "{}" &&
  5203. item.Specifications &&
  5204. JSON.stringify(item.Specifications) != "{}" &&
  5205. item.sum
  5206. ) {
  5207. $modalInstance.close(item);
  5208. } else {
  5209. SweetAlert.swal({
  5210. title: "数据填写不完整!",
  5211. text: "请检查数据然后提交!",
  5212. type: "error",
  5213. });
  5214. }
  5215. };
  5216. $scope.cancel = function () {
  5217. $modalInstance.dismiss("cancel");
  5218. };
  5219. },
  5220. size: "sm",
  5221. });
  5222. modalInstance.result.then(function (selectedItem) {
  5223. api_sysinfo
  5224. .addData({
  5225. type: "list",
  5226. key: "haocaifenlei",
  5227. name: selectedItem.name,
  5228. parent: selectedItem.id,
  5229. value: "1",
  5230. })
  5231. .then(function (data) {
  5232. // $scope.haocainame.name = data.list;
  5233. api_wechatfile
  5234. .addDictionary({
  5235. type: "list",
  5236. key: "pinpai",
  5237. name: selectedItem.model,
  5238. parent: data.id,
  5239. value: "1",
  5240. })
  5241. .then(function (data) {
  5242. // $scope.haocainame = data.list;
  5243. });
  5244. api_wechatfile
  5245. .addDictionary({
  5246. type: "list",
  5247. key: "guige",
  5248. name: selectedItem.Specifications,
  5249. parent: data.id,
  5250. value: "1",
  5251. })
  5252. .then(function (data) {
  5253. // $scope.haocainame = data.list;
  5254. });
  5255. });
  5256. $scope.myData2.push(selectedItem);
  5257. for (var i = 0; i < $scope.myData2.length; i++) {
  5258. $scope.myData2[i]["item"] =
  5259. i + 1 + $scope.memoryfilterData.idx * 10;
  5260. }
  5261. // $scope.model.applicationForm.consumables = $scope.myData2;
  5262. angular.forEach($scope.myDataguibeiall, function (items, index) {
  5263. if (items.id == selectedItem.id) {
  5264. $scope.myDataguibeiall.splice(index, 1);
  5265. }
  5266. });
  5267. $scope.myData2 = $scope.interceptMydata($scope.myDataguibei, 0, 10);
  5268. $scope.model.consumables = $scope.myDataguibeiall;
  5269. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5270. $scope.model.consumables;
  5271. $scope.gridOptions1["totalItems"] = $scope.myDataguibeiall.length;
  5272. });
  5273. };
  5274. //grid2
  5275. $scope.langs = i18nService.getAllLangs();
  5276. $scope.lang = "zh-cn";
  5277. i18nService.setCurrentLang($scope.lang);
  5278. $scope.gridOptions2 = {};
  5279. $scope.gridOptions2.data = "myData2";
  5280. $scope.gridOptions2.enableColumnResizing = true;
  5281. $scope.gridOptions2.enableFiltering = false;
  5282. $scope.gridOptions2.enableGridMenu = false;
  5283. $scope.gridOptions2.showGridFooter = true;
  5284. $scope.gridOptions2.showColumnFooter = false;
  5285. $scope.gridOptions2.fastWatch = true;
  5286. $scope.gridOptions2.useExternalFiltering = true;
  5287. $scope.gridOptions2.useExternalPagination = true;
  5288. $scope.gridOptions2.paginationPageSizes = [10];
  5289. $scope.gridOptions2.paginationPageSize = 10;
  5290. $scope.gridOptions2.multiSelect = false;
  5291. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5292. $scope.modelcons = {};
  5293. $scope.modelass = {};
  5294. $scope.myData2all = [];
  5295. $scope.myData1all = [];
  5296. $scope.memoryfilterDatagui = {
  5297. idx: 0,
  5298. sum: 10,
  5299. };
  5300. setInterval(function () {
  5301. if ($scope.model.assets) {
  5302. if (
  5303. $scope.model.assets != $scope.modelass &&
  5304. typeof $scope.model.assets == "string"
  5305. ) {
  5306. $scope.modelass = $scope.model.assets;
  5307. if (JSON.stringify($scope.model.assets) == "{}") {
  5308. $scope.model.assets = [];
  5309. } else {
  5310. $scope.model.assets = JSON.parse($scope.model.assets);
  5311. }
  5312. // $scope.myData1 = $scope.model.assets;
  5313. // for (var i = 0; i < $scope.myData1.length; i++) {
  5314. // $scope.myData1[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5315. // }
  5316. $scope.myData1all = $scope.model.assets;
  5317. for (var i = 0; i < $scope.myData1all.length; i++) {
  5318. $scope.myData1all[i]["item"] =
  5319. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5320. }
  5321. $scope.gridOptions1["totalItems"] = $scope.myData1all.length;
  5322. $scope.myData1 = $scope.interceptMydata($scope.myData1all, 0, 10);
  5323. }
  5324. }
  5325. if ($scope.model.consumables) {
  5326. if (
  5327. $scope.model.consumables != $scope.modelcons &&
  5328. typeof $scope.model.consumables == "string"
  5329. ) {
  5330. $scope.modelass = $scope.model.consumables;
  5331. if (JSON.stringify($scope.model.consumables) == "{}") {
  5332. $scope.model.consumables = [];
  5333. } else {
  5334. $scope.model.consumables = JSON.parse($scope.model.consumables);
  5335. }
  5336. // $scope.myData2 = $scope.model.consumables;
  5337. // for (var i = 0; i < $scope.myData2.length; i++) {
  5338. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5339. // }
  5340. $scope.myData2all = $scope.model.consumables;
  5341. for (var i = 0; i < $scope.myData2all.length; i++) {
  5342. $scope.myData2all[i]["item"] =
  5343. i + 1 + $scope.memoryfilterDatagui.idx * 10;
  5344. }
  5345. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5346. $scope.myData2 = $scope.interceptMydata($scope.myData2all, 0, 10);
  5347. // $scope.model.consumables = $scope.myData2all;
  5348. }
  5349. }
  5350. }, 100);
  5351. $scope.gridOptions2.columnDefs = [
  5352. {
  5353. name: "item",
  5354. displayName: "序号",
  5355. width: 120,
  5356. },
  5357. {
  5358. name: "name",
  5359. displayName: "耗材名称",
  5360. width: 180,
  5361. enableFiltering: false,
  5362. },
  5363. {
  5364. name: "model",
  5365. displayName: "品牌/型号",
  5366. width: 180,
  5367. enableFiltering: false,
  5368. },
  5369. {
  5370. name: "Specifications",
  5371. displayName: "规格",
  5372. width: 150,
  5373. enableFiltering: false,
  5374. },
  5375. {
  5376. name: "sum",
  5377. width: 150,
  5378. displayName: "数量",
  5379. enableFiltering: false,
  5380. },
  5381. {
  5382. name: "操作",
  5383. cellTemplate:
  5384. '<div><div class="cl-effect-1 ui-grid-cell-contents" >' +
  5385. '<a ng-click="grid.appScope.changecai(row.entity)" class="bianjifont">修改数量</a>' +
  5386. "</div></div>",
  5387. enableFiltering: false,
  5388. },
  5389. ];
  5390. // $scope.selectButtonClick
  5391. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  5392. $scope.gridApi = gridApi;
  5393. gridApi.pagination.on.paginationChanged(
  5394. $scope,
  5395. function (newPage, pageSize) {
  5396. // var filtersData = $scope.memoryfilterDatagui;
  5397. // filtersData.idx = newPage - 1;
  5398. // filtersData.sum = pageSize;
  5399. $scope.memoryfilterDatagui.idx = newPage - 1;
  5400. $scope.memoryfilterDatagui.sum = pageSize;
  5401. $scope.myData2 = $scope.interceptMydata(
  5402. $scope.myData2all,
  5403. $scope.memoryfilterDatagui.idx,
  5404. 10
  5405. );
  5406. }
  5407. );
  5408. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5409. $scope.selected.items = data.entity;
  5410. //console.log(data);
  5411. });
  5412. gridApi.selection.on.rowSelectionChangedBatch(
  5413. $scope,
  5414. function (data) {
  5415. $scope.selected.items = data.entity;
  5416. //console.log(data);
  5417. }
  5418. );
  5419. gridApi.core.on.filterChanged($scope, function () {
  5420. var grid = this.grid;
  5421. var filtersData = {
  5422. idx: 0,
  5423. sum: 10,
  5424. };
  5425. angular.forEach(grid.columns, function (item) {
  5426. if (item.enableFiltering) {
  5427. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5428. if (
  5429. angular.isDefined(item.filters[0].term) &&
  5430. item.filters[0].term != ""
  5431. ) {
  5432. if (angular.isUndefined(filtersData["user"])) {
  5433. filtersData["user"] = {};
  5434. }
  5435. filtersData["user"][item.field] = item.filters[0].term;
  5436. }
  5437. }
  5438. });
  5439. $scope.memoryfilterData = filtersData;
  5440. $scope.loadData(filtersData);
  5441. });
  5442. };
  5443. $scope.changecai = function (item) {
  5444. event.preventDefault();
  5445. var modalInstance = $modal.open({
  5446. templateUrl: "assets/views/customform/tpl/cmdb/changehaocai.html",
  5447. controller: function ($scope, $modalInstance) {
  5448. $scope.title = "修改耗材数量";
  5449. $scope.consumptive = angular.copy(item);
  5450. // $scope.consumptive = item;
  5451. $scope.maxsum = item.inventoryNum;
  5452. $scope.clearNoNum = function (obj, attr) {
  5453. //先把非数字的都替换掉,除了数字和.
  5454. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5455. //必须保证第一个为数字而不是.
  5456. obj[attr] = obj[attr].replace(/^\./g, "");
  5457. //保证只有出现一个.而没有多个.
  5458. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5459. //保证.只出现一次,而不能出现两次以上
  5460. obj[attr] = obj[attr]
  5461. .replace(".", "$#$")
  5462. .replace(/\./g, "")
  5463. .replace("$#$", ".");
  5464. //小于最大值
  5465. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5466. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  5467. // obj[attr] = '';
  5468. // }
  5469. };
  5470. $scope.ok = function () {
  5471. $modalInstance.close($scope.consumptive);
  5472. };
  5473. $scope.cancel = function () {
  5474. $modalInstance.dismiss("cancel");
  5475. };
  5476. },
  5477. size: "sm",
  5478. });
  5479. modalInstance.result.then(function (selectedItem) {
  5480. angular.forEach($scope.myData2all, function (items, index) {
  5481. // if (items.id == selectedItem.id) {
  5482. if (
  5483. items.modelid == selectedItem.modelid &&
  5484. items.nameid == selectedItem.nameid &&
  5485. items.Specificationsid == selectedItem.Specificationsid
  5486. ) {
  5487. angular.extend($scope.myData2all[index], selectedItem);
  5488. }
  5489. });
  5490. // $scope.model.consumables = $scope.myData2;
  5491. // $scope.myData2 = $scope.model.consumables;
  5492. // $scope.myData2all.push(selectedItem);
  5493. // for (var i = 0; i < $scope.myData2all.length; i++) {
  5494. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5495. // }
  5496. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5497. $scope.myData2 = $scope.interceptMydata(
  5498. $scope.myData2all,
  5499. $scope.memoryfilterDatagui.idx,
  5500. 10
  5501. );
  5502. $scope.model.consumables = $scope.myData2all;
  5503. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5504. $scope.model.consumables;
  5505. });
  5506. };
  5507. $scope.interceptMydata = function (mydate, idx, sum) {
  5508. return mydate.slice(idx * sum, (idx + 1) * sum);
  5509. };
  5510. $scope.haocaiadd = function () {
  5511. event.preventDefault();
  5512. var modalInstance = $modal.open({
  5513. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  5514. controller: function (
  5515. $scope,
  5516. scope,
  5517. $modalInstance,
  5518. api_wechatfile,
  5519. SweetAlert
  5520. ) {
  5521. $scope.haocainame = [];
  5522. $scope.pinpai = [];
  5523. $scope.guige = [];
  5524. $scope.consumptive = {};
  5525. $scope.consumptiveall = {};
  5526. $scope.title = "添加耗材";
  5527. api_wechatfile
  5528. .getDictionaryForList({
  5529. key: "haocaifenlei",
  5530. })
  5531. .then(function (data) {
  5532. $scope.haocainame = data;
  5533. });
  5534. $scope.clearNoNum = function (obj, attr) {
  5535. //先把非数字的都替换掉,除了数字和.
  5536. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  5537. //必须保证第一个为数字而不是.
  5538. obj[attr] = obj[attr].replace(/^\./g, "");
  5539. //保证只有出现一个.而没有多个.
  5540. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  5541. //保证.只出现一次,而不能出现两次以上
  5542. obj[attr] = obj[attr]
  5543. .replace(".", "$#$")
  5544. .replace(/\./g, "")
  5545. .replace("$#$", ".");
  5546. //小于最大值
  5547. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  5548. alert(
  5549. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  5550. );
  5551. obj[attr] = "";
  5552. }
  5553. };
  5554. $scope.onChange = function (parent) {
  5555. $scope.consumptive.model = {};
  5556. $scope.consumptive.Specifications = {};
  5557. api_wechatfile
  5558. .getDictionaryForList({
  5559. key: "pinpai",
  5560. parent: parent.id,
  5561. })
  5562. .then(function (data) {
  5563. $scope.pinpai = data;
  5564. });
  5565. api_wechatfile
  5566. .getDictionaryForList({
  5567. key: "guige",
  5568. parent: parent.id,
  5569. })
  5570. .then(function (data) {
  5571. $scope.guige = data;
  5572. });
  5573. };
  5574. // $scope.onChangesum = function(item) {
  5575. // if (item.name && item.model && item.model.id && item.Specifications && item.Specifications.id) {
  5576. // var data1 = { "idx": 0, "sum": 10, "consumable": { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name } }
  5577. // $scope.consumptiveall = data1;
  5578. // // api_cmdb3.fetchDataList('consumable', data1).then(function(data) {
  5579. // // if (data.list && data.list.length != 0) {
  5580. // // var myData = data.list;
  5581. // // $scope.consumptiveall = myData[0];
  5582. // // $scope.maxsum = myData[0].inventoryNum;
  5583. // // } else if (data.list && data.list.length == 0) {
  5584. // // SweetAlert.swal({
  5585. // // title: "库存数据存在问题!",
  5586. // // text: "请检查库存数据!",
  5587. // // type: "error"
  5588. // // });
  5589. // // }
  5590. // // });
  5591. // }
  5592. // }
  5593. $scope.addhaocai = function () {
  5594. $modalInstance.dismiss("cancel");
  5595. scope.haocaiopen($scope.consumptive);
  5596. };
  5597. $scope.ok = function (item) {
  5598. var submittrue = true;
  5599. // var data = { "id": item.model.id, "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  5600. var data = {
  5601. modelid: item.model.id,
  5602. nameid: item.name.id,
  5603. Specificationsid: item.Specifications.id,
  5604. name: item.name.name,
  5605. model: item.model.name,
  5606. Specifications: item.Specifications.name,
  5607. sum: item.sum,
  5608. };
  5609. if (
  5610. item.name &&
  5611. item.model &&
  5612. JSON.stringify(item.model) != "{}" &&
  5613. item.Specifications &&
  5614. JSON.stringify(item.Specifications) != "{}" &&
  5615. item.sum
  5616. ) {
  5617. // $modalInstance.close(data);
  5618. angular.forEach(scope.myData2all, function (itemsdata) {
  5619. // if (item.model.id == itemsdata.id) {
  5620. if (
  5621. item.model.id == itemsdata.modelid &&
  5622. item.name.id == itemsdata.nameid &&
  5623. item.Specifications.id == itemsdata.Specificationsid
  5624. ) {
  5625. submittrue = false;
  5626. }
  5627. });
  5628. if (submittrue) {
  5629. $modalInstance.close(data);
  5630. } else {
  5631. SweetAlert.swal({
  5632. title: "该耗材已有添加",
  5633. text: "请检查数据然后提交!",
  5634. type: "error",
  5635. });
  5636. }
  5637. } else {
  5638. SweetAlert.swal({
  5639. title: "数据填写不完整!",
  5640. text: "请检查数据然后提交!",
  5641. type: "error",
  5642. });
  5643. }
  5644. };
  5645. $scope.cancel = function () {
  5646. $modalInstance.dismiss("cancel");
  5647. };
  5648. },
  5649. size: "sm",
  5650. resolve: {
  5651. scope: function () {
  5652. return $scope;
  5653. },
  5654. },
  5655. });
  5656. modalInstance.result.then(function (selectedItem) {
  5657. // $scope.myData2.push(selectedItem);
  5658. // for (var i = 0; i < $scope.myData2.length; i++) {
  5659. // $scope.myData2[i]['item'] = i + 1 + $scope.memoryfilterData.idx * 10
  5660. // }
  5661. // $scope.model.consumables = $scope.myData2;
  5662. $scope.myData2all.push(selectedItem);
  5663. for (var i = 0; i < $scope.myData2all.length; i++) {
  5664. // $scope.myData2all[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5665. $scope.myData2all[i]["item"] = i + 1;
  5666. }
  5667. $scope.gridOptions2["totalItems"] = $scope.myData2all.length;
  5668. $scope.myData2 = $scope.interceptMydata(
  5669. $scope.myData2all,
  5670. $scope.memoryfilterDatagui.idx,
  5671. 10
  5672. );
  5673. $scope.model.consumables = $scope.myData2all;
  5674. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5675. $scope.model.consumables;
  5676. });
  5677. };
  5678. $scope.onDblClick = function (data, event) {
  5679. $scope.selectButtonClick(data, event);
  5680. };
  5681. $scope.memoryfilterData = {
  5682. idx: 0,
  5683. sum: 20,
  5684. user: {
  5685. roledata: {
  5686. rolecode: "roleset",
  5687. },
  5688. selectType: "1",
  5689. },
  5690. };
  5691. $scope.myData = {};
  5692. $scope.loadData = function (filterData) { };
  5693. // $scope.title = title;
  5694. $scope.loadData({
  5695. idx: 0,
  5696. sum: 20,
  5697. user: {
  5698. roledata: {
  5699. rolecode: "roleset",
  5700. },
  5701. selectType: "1",
  5702. },
  5703. });
  5704. $scope.selected = {
  5705. items: {},
  5706. };
  5707. },
  5708. ],
  5709. });
  5710. //tab 列表
  5711. formlyConfigProvider.setType({
  5712. name: "ui-cmdbtab",
  5713. templateUrl: "assets/views/customform/tpl/cmdb/ui-cmdbtab.html",
  5714. wrapper: ["bootstrapHasError"],
  5715. defaultOptions: function (options, $scope) {
  5716. return {
  5717. templateOptions: {},
  5718. };
  5719. },
  5720. controller: [
  5721. "$scope",
  5722. "api_user_data",
  5723. "i18nService",
  5724. "$modal",
  5725. "api_cmdb",
  5726. function ($scope, api_user_data, i18nService, $modal, api_cmdb) {
  5727. $scope.memoryfilterDatashe = {
  5728. idx: 0,
  5729. sum: 10,
  5730. };
  5731. $scope.myDataoneall = [];
  5732. var setAllInactive = function () {
  5733. angular.forEach($scope.workspaces, function (workspace) {
  5734. workspace.active = false;
  5735. });
  5736. };
  5737. //添加
  5738. var addNewWorkspace = function (name, contentUrl) {
  5739. var id = $scope.workspaces.length + 1;
  5740. $scope.workspaces.push({
  5741. id: id,
  5742. name: name,
  5743. active: true,
  5744. contentUrl: "main/html/content.html",
  5745. });
  5746. };
  5747. //关闭
  5748. $scope.remove = function (closedata) {
  5749. event.preventDefault();
  5750. angular.forEach($scope.workspaces, function (item, index) {
  5751. if (closedata.id == item.id) {
  5752. if (closedata.id == 1) {
  5753. $scope.$parent.$parent.$parent.model.gettype.gu = false;
  5754. } else {
  5755. $scope.$parent.$parent.$parent.model.gettype.hao = false;
  5756. }
  5757. $scope.workspaces.splice(index, 1);
  5758. }
  5759. });
  5760. };
  5761. $scope.workspaces = [];
  5762. $scope.options.templateOptions.getpush = function (item) {
  5763. $scope.workspaces = [];
  5764. if (item.gu) {
  5765. $scope.workspaces.push({
  5766. id: 1,
  5767. name: "领用设备",
  5768. active: true,
  5769. contentUrl: "assets/views/customform/tpl/cmdb/shebei.html",
  5770. });
  5771. }
  5772. if (item.hao) {
  5773. $scope.workspaces.push({
  5774. id: 2,
  5775. name: "领用耗材",
  5776. active: true,
  5777. contentUrl: "assets/views/customform/tpl/cmdb/haocai.html",
  5778. });
  5779. }
  5780. $scope.options.templateOptions.workspaces = $scope.workspaces;
  5781. };
  5782. $scope.addWorkspace = function (contentUrl, name) {
  5783. setAllInactive();
  5784. addNewWorkspace(name, contentUrl);
  5785. };
  5786. // $rootScope.addWorkspace = $scope.addWorkspace;
  5787. // $scope.remove = function(idNumber) {
  5788. // var index = 0; //记录当前元素下标
  5789. // angular.forEach($scope.workspaces, function(workspace) {
  5790. // if (workspace.id === idNumber.id) {
  5791. // $scope.workspaces.splice(index, 1); //删除当前下标的选项卡元素
  5792. // }
  5793. // index++;
  5794. // });
  5795. // };
  5796. // setInterval(function() {
  5797. // if ($scope.model.assets) {
  5798. // if ($scope.model.assets != $scope.modelass && typeof($scope.model.assets) == 'string') {
  5799. // $scope.modelass = $scope.model.assets;
  5800. // if (JSON.stringify($scope.model.assets) == "{}") {
  5801. // $scope.model.assets = []
  5802. // } else {
  5803. // $scope.model.assets = JSON.parse($scope.model.assets);
  5804. // }
  5805. // $scope.myDatalingbeiall = $scope.model.assets;
  5806. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5807. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5808. // }
  5809. // $scope.gridOptions1['totalItems'] = $scope.myDatalingbeiall.length;
  5810. // $scope.myDatalingbei = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5811. // }
  5812. // }
  5813. // if ($scope.model.consumables) {
  5814. // if ($scope.model.consumables != $scope.modelcons && typeof($scope.model.consumables) == 'string') {
  5815. // $scope.modelass = $scope.model.consumables;
  5816. // if (JSON.stringify($scope.model.consumables) == "{}") {
  5817. // $scope.model.consumables = [];
  5818. // } else {
  5819. // $scope.model.consumables = JSON.parse($scope.model.consumables);
  5820. // }
  5821. // $scope.myDatalingbeiall = $scope.model.consumables;
  5822. // for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5823. // $scope.myDatalingbeiall[i]['item'] = i + 1 + $scope.memoryfilterDatagui.idx * 10
  5824. // }
  5825. // $scope.gridOptions2['totalItems'] = $scope.myDatalingbeiall.length;
  5826. // $scope.myDatatwo = $scope.interceptMydata($scope.myDatalingbeiall, 0, 10)
  5827. // // $scope.model.consumables = $scope.myData2all;
  5828. // }
  5829. // }
  5830. // }, 100);
  5831. //grid1
  5832. $scope.langs = i18nService.getAllLangs();
  5833. $scope.lang = "zh-cn";
  5834. i18nService.setCurrentLang($scope.lang);
  5835. $scope.gridOptions1 = {};
  5836. $scope.gridOptions1.data = "myDatalingbei";
  5837. $scope.gridOptions1.enableColumnResizing = true;
  5838. $scope.gridOptions1.enableFiltering = false;
  5839. $scope.gridOptions1.enableGridMenu = false;
  5840. $scope.gridOptions1.showGridFooter = true;
  5841. $scope.gridOptions1.showColumnFooter = false;
  5842. $scope.gridOptions1.fastWatch = true;
  5843. $scope.gridOptions1.useExternalFiltering = true;
  5844. $scope.gridOptions1.useExternalPagination = true;
  5845. $scope.gridOptions1.paginationPageSizes = [10];
  5846. $scope.gridOptions1.paginationPageSize = 10;
  5847. $scope.gridOptions1.multiSelect = false;
  5848. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  5849. $scope.gridOptions1.columnDefs = [
  5850. {
  5851. name: "item",
  5852. displayName: "序号",
  5853. width: 120,
  5854. },
  5855. {
  5856. name: "props.hw_cifilterClassic",
  5857. displayName: "设备类型",
  5858. width: 150,
  5859. enableFiltering: false,
  5860. },
  5861. {
  5862. name: "props.hw_mingcheng",
  5863. displayName: "设备名称",
  5864. width: 100,
  5865. enableFiltering: false,
  5866. },
  5867. {
  5868. name: "uuid",
  5869. displayName: "设备编号",
  5870. enableFiltering: false,
  5871. },
  5872. ];
  5873. $scope.myDatalingbeiall = [];
  5874. $scope.gridOptions1.onRegisterApi = function (gridApi) {
  5875. $scope.gridApi = gridApi;
  5876. gridApi.pagination.on.paginationChanged(
  5877. $scope,
  5878. function (newPage, pageSize) {
  5879. // var filtersData = $scope.memoryfilterData;
  5880. // filtersData.idx = newPage - 1;
  5881. // filtersData.sum = pageSize;
  5882. // $scope.loadData(filtersData);
  5883. $scope.memoryfilterDatashe.idx = newPage - 1;
  5884. $scope.memoryfilterDatashe.sum = pageSize;
  5885. $scope.myDatalingbei = $scope.interceptMydata(
  5886. $scope.myDatalingbeiall,
  5887. $scope.memoryfilterDatashe.idx,
  5888. 10
  5889. );
  5890. }
  5891. );
  5892. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  5893. $scope.selected.items = data.entity;
  5894. //console.log(data);
  5895. });
  5896. gridApi.selection.on.rowSelectionChangedBatch(
  5897. $scope,
  5898. function (data) {
  5899. $scope.selected.items = data.entity;
  5900. //console.log(data);
  5901. }
  5902. );
  5903. gridApi.core.on.filterChanged($scope, function () {
  5904. var grid = this.grid;
  5905. var filtersData = {
  5906. idx: 0,
  5907. sum: 20,
  5908. user: {
  5909. roledata: {
  5910. rolecode: "roleset",
  5911. },
  5912. selectType: "1",
  5913. },
  5914. };
  5915. angular.forEach(grid.columns, function (item) {
  5916. if (item.enableFiltering) {
  5917. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  5918. if (
  5919. angular.isDefined(item.filters[0].term) &&
  5920. item.filters[0].term != ""
  5921. ) {
  5922. if (angular.isUndefined(filtersData["user"])) {
  5923. filtersData["user"] = {};
  5924. }
  5925. filtersData["user"][item.field] = item.filters[0].term;
  5926. }
  5927. }
  5928. });
  5929. $scope.memoryfilterDatashe = filtersData;
  5930. // $scope.loadData(filtersData);
  5931. });
  5932. };
  5933. $scope.interceptMydata = function (mydate, idx, sum) {
  5934. return mydate.slice(idx * sum, (idx + 1) * sum);
  5935. };
  5936. $scope.removeshebei = function (item) {
  5937. event.preventDefault();
  5938. var modalInstance = $modal.open({
  5939. templateUrl: "assets/views/delete.html",
  5940. controller: function ($scope, $modalInstance, scope) {
  5941. $scope.title = "设备移除";
  5942. $scope.connect = "确定要移除此设备?";
  5943. $scope.consumptive = scope.selected.items;
  5944. $scope.ok = function () {
  5945. $modalInstance.close($scope.consumptive);
  5946. };
  5947. $scope.cancel = function () {
  5948. $modalInstance.dismiss("cancel");
  5949. };
  5950. },
  5951. size: "sm",
  5952. resolve: {
  5953. scope: function () {
  5954. return $scope;
  5955. },
  5956. },
  5957. });
  5958. modalInstance.result.then(function (selectedItem) {
  5959. angular.forEach($scope.myDatalingbeiall, function (items, index) {
  5960. if (items.id == selectedItem.id) {
  5961. $scope.myDatalingbeiall.splice(index, 1);
  5962. }
  5963. });
  5964. // $scope.myData3.push(selectedItem);
  5965. $scope.model.consumables = $scope.myDatalingbeiall;
  5966. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  5967. $scope.myDatalingbeiall;
  5968. $scope.gridOptions1["totalItems"] = $scope.myDatalingbeiall.length;
  5969. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  5970. $scope.myDatalingbeiall[i]["item"] =
  5971. i +
  5972. 1 +
  5973. $scope.memoryfilterDatashe.idx * $scope.memoryfilterDatashe.sum;
  5974. }
  5975. $scope.myDatalingbei = $scope.interceptMydata(
  5976. $scope.myDatalingbeiall,
  5977. 0,
  5978. 10
  5979. );
  5980. });
  5981. };
  5982. $scope.addshebei = function () {
  5983. event.preventDefault();
  5984. var modalInstance = $modal.open({
  5985. templateUrl: "assets/views/customform/tpl/cmdb/add_shebei.html",
  5986. controller: function (
  5987. $scope,
  5988. i18nService,
  5989. $modalInstance,
  5990. items,
  5991. title,
  5992. Restangular,
  5993. APIService,
  5994. onDataCallback,
  5995. parentScope,
  5996. api_configure_data,
  5997. api_configure_form
  5998. ) {
  5999. $scope.langs = i18nService.getAllLangs();
  6000. $scope.lang = "zh-cn";
  6001. i18nService.setCurrentLang($scope.lang);
  6002. $scope.gridOptions = {};
  6003. $scope.gridOptions.data = "myDatatwo";
  6004. $scope.gridOptions.enableColumnResizing = true;
  6005. $scope.gridOptions.enableFiltering = false;
  6006. $scope.gridOptions.enableGridMenu = false;
  6007. $scope.gridOptions.showGridFooter = true;
  6008. $scope.gridOptions.showColumnFooter = false;
  6009. $scope.gridOptions.fastWatch = true;
  6010. $scope.gridOptions.useExternalFiltering = true;
  6011. $scope.gridOptions.useExternalPagination = true;
  6012. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  6013. $scope.gridOptions.paginationPageSize = 10;
  6014. $scope.gridOptions.multiSelect = true;
  6015. $scope.gridOptions.rowIdentity = function (row) {
  6016. return row.id;
  6017. };
  6018. $scope.gridOptions.getRowIdentity = function (row) {
  6019. return row.id;
  6020. };
  6021. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6022. $scope.gridOptions.columnDefs = [
  6023. {
  6024. name: "item",
  6025. displayName: "序号",
  6026. width: 80,
  6027. enableFiltering: false,
  6028. },
  6029. {
  6030. name: "uuid",
  6031. displayName: "内部编号",
  6032. width: 175,
  6033. },
  6034. {
  6035. name: "props.hw_mingcheng",
  6036. displayName: "资产名称",
  6037. width: 120,
  6038. },
  6039. {
  6040. name: "props.hw_cifilterClassic",
  6041. displayName: "资产类型",
  6042. width: 80,
  6043. enableFiltering: false,
  6044. },
  6045. // { name: 'type', displayName: '资产型号', width: 100, enableFiltering: false },
  6046. {
  6047. name: "props.hw_state",
  6048. displayName: "资产状态",
  6049. width: 150,
  6050. enableFiltering: false,
  6051. },
  6052. {
  6053. name: "props.hwnw_area",
  6054. displayName: "资产地点",
  6055. width: 130,
  6056. enableFiltering: false,
  6057. },
  6058. {
  6059. name: "createtime",
  6060. displayName: "申请时间",
  6061. enableFiltering: false,
  6062. },
  6063. ];
  6064. // $scope.selectButtonClick
  6065. var defaultFilterData = {
  6066. // "assignee":2,
  6067. // "sign":"basehwitndl",
  6068. // "applicationForm": { "hw_state": "在线" },
  6069. hw_state: "在库",
  6070. idx: 0,
  6071. sum: 10,
  6072. };
  6073. $scope.memoryfilterData = {
  6074. // "assignee":2,
  6075. // "sign":"basehwitndl",
  6076. // "applicationForm": { "hw_state": "在线" },
  6077. hw_state: "在库",
  6078. idx: 0,
  6079. sum: 10,
  6080. };
  6081. $scope.refreshData = function (style, filterData) {
  6082. if (angular.isUndefined(filterData)) {
  6083. filterData = defaultFilterData;
  6084. }
  6085. $scope.myDatatwo = [];
  6086. // $scope.gridOptions['sum']=filterData.sum;
  6087. api_cmdb.query(filterData).then(
  6088. function (data) {
  6089. // $scope.callsPending--;
  6090. var filterData = $scope.memoryfilterData;
  6091. var myDatatwo = Restangular.stripRestangular(data);
  6092. $scope.gridOptions["totalItems"] = data.total;
  6093. for (var i = 0; i < myDatatwo.data.node.length; i++) {
  6094. myDatatwo.data.node[i].createtime = moment(
  6095. myDatatwo.data.node[i].createtime
  6096. ).format("YYYY-MM-DD");
  6097. }
  6098. $scope.myDatatwo = myDatatwo.data.node;
  6099. for (var i = 0; i < $scope.myDatatwo.length; i++) {
  6100. $scope.myDatatwo[i]["item"] =
  6101. i + 1 + filterData.idx * filterData.sum;
  6102. }
  6103. },
  6104. function () { }
  6105. );
  6106. };
  6107. $scope.refreshData("expand-right", defaultFilterData);
  6108. $scope.gridOptions.onRegisterApi = function (gridApi) {
  6109. $scope.gridApi = gridApi;
  6110. gridApi.pagination.on.paginationChanged(
  6111. $scope,
  6112. function (newPage, pageSize) {
  6113. var filtersData = $scope.memoryfilterData;
  6114. filtersData.idx = newPage - 1;
  6115. filtersData.sum = pageSize;
  6116. // $scope.loadData(filtersData);
  6117. $scope.refreshData("expand-right", filtersData);
  6118. //console.log(pageSize);
  6119. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  6120. }
  6121. );
  6122. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  6123. // $scope.selected.items.push(data.entity);
  6124. //console.log(data);
  6125. gridApi.selection.on.rowSelectionChanged(
  6126. $scope,
  6127. function (scope, ect) {
  6128. if (scope.isSelected) {
  6129. scope.grid.appScope.selected.items.push(scope.entity);
  6130. } else {
  6131. for (
  6132. var i = 0;
  6133. i <= scope.grid.appScope.selected.items.length;
  6134. i++
  6135. ) {
  6136. if (
  6137. scope.grid.appScope.selected.items[i].id ==
  6138. scope.entity.id
  6139. ) {
  6140. scope.grid.appScope.selected.items.splice(i, 1);
  6141. break;
  6142. }
  6143. }
  6144. }
  6145. $scope.mySelectedRows =
  6146. $scope.gridApi.selection.getSelectedRows();
  6147. }
  6148. );
  6149. // });
  6150. gridApi.selection.on.rowSelectionChangedBatch(
  6151. $scope,
  6152. function (rows) {
  6153. // $scope.selected.items = data.entity;
  6154. //console.log(data);
  6155. var selectitem = [];
  6156. selectitem = angular.copy($scope.selected.items);
  6157. for (var j = 0; j < rows.length; j++) {
  6158. if (rows[j].isSelected == true) {
  6159. selectitem.push(rows[j].entity);
  6160. } else {
  6161. delete selectitem[j];
  6162. // rows.splice(j, 1);
  6163. }
  6164. }
  6165. $scope.selected.items = [];
  6166. for (var i = 0; i < selectitem.length; i++) {
  6167. if (selectitem[i]) {
  6168. $scope.selected.items.push(selectitem[i]);
  6169. }
  6170. }
  6171. }
  6172. );
  6173. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  6174. // // if (row.entity.age > 45) {
  6175. // row.grid.api.selection.selectRow(row.entity); // 选中行
  6176. // // }
  6177. // };
  6178. gridApi.core.on.filterChanged($scope, function () {
  6179. var grid = this.grid;
  6180. var filtersData = {
  6181. idx: 0,
  6182. sum: 10,
  6183. user: {
  6184. roledata: {
  6185. rolecode: "roleset",
  6186. },
  6187. selectType: "1",
  6188. },
  6189. };
  6190. angular.forEach(grid.columns, function (item) {
  6191. if (item.enableFiltering) {
  6192. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6193. if (
  6194. angular.isDefined(item.filters[0].term) &&
  6195. item.filters[0].term != ""
  6196. ) {
  6197. if (angular.isUndefined(filtersData["user"])) {
  6198. filtersData["user"] = {};
  6199. }
  6200. filtersData["user"][item.field] = item.filters[0].term;
  6201. }
  6202. }
  6203. });
  6204. $scope.memoryfilterData = filtersData;
  6205. // $scope.loadData(filtersData);
  6206. });
  6207. };
  6208. $scope.onDblClick = function (data, event) {
  6209. // $scope.selected.items = data.entity;
  6210. $scope.selectButtonClick(data, event);
  6211. };
  6212. // $scope.loadData = function(filterData) {
  6213. // // console.log("filtersData=111" + JSON.stringify(filterData))
  6214. // items.fetchItems(filterData, APIService).then(function(data) {
  6215. // var myDatatwo = Restangular.stripRestangular(data);
  6216. // $scope.gridOptions.totalItems = myDatatwo.totalNum;
  6217. // $scope.myDatatwo = myDatatwo.list;
  6218. // });
  6219. // };
  6220. $scope.title = title;
  6221. //树形图
  6222. var apple_selected, tree, treedata_avm, treedata_geography;
  6223. $scope.my_tree_handler = function (branch) {
  6224. //var _ref;
  6225. var classify = ($scope.classify =
  6226. branch.prefix.toLowerCase() + branch.sign);
  6227. api_cmdb
  6228. .query({
  6229. sign: classify,
  6230. })
  6231. .then(function (data) {
  6232. var myDatalingbei = Restangular.stripRestangular(data);
  6233. // console.log(myData.data.node);
  6234. if (myDatalingbei.data && myDatalingbei.status == 200) {
  6235. var ret = myDatalingbei.data;
  6236. redrawSvg(myDatalingbei);
  6237. }
  6238. });
  6239. };
  6240. $scope.my_data = [];
  6241. function convertListToTree(data, treeMap) {
  6242. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  6243. var root = null; //Initially set our loop to null
  6244. var parentNode = null;
  6245. //loop over data
  6246. for (var i = 0; i < data.length; i++) {
  6247. var datum = data[i];
  6248. //each node will have children, so let's give it a "children" poperty
  6249. datum.children = [];
  6250. //add an entry for this node to the map so that any future children can
  6251. //lookup the parent
  6252. idToNodeMap[datum.id] = datum;
  6253. //Does this node have a parent?
  6254. if (
  6255. typeof datum.parent === "undefined" ||
  6256. datum.parent == null
  6257. ) {
  6258. //Doesn't look like it, so this node is the root of the tree
  6259. root = datum;
  6260. treeMap[datum.id] = root;
  6261. } else {
  6262. //This node has a parent, so let's look it up using the id
  6263. parentNode = idToNodeMap[datum.parent.id];
  6264. //We don't need this property, so let's delete it.
  6265. delete datum.parent;
  6266. //Let's add the current node as a child of the parent node.
  6267. parentNode.children.push(datum);
  6268. }
  6269. }
  6270. return root;
  6271. }
  6272. function convertParentToChildList(data) {
  6273. var treeMap = {};
  6274. var list = [];
  6275. convertListToTree(data, treeMap);
  6276. angular.forEach(treeMap, function (item) {
  6277. list.push(item);
  6278. });
  6279. return list;
  6280. }
  6281. $scope.my_tree = tree = {};
  6282. $scope.try_async_load = function () {
  6283. $scope.my_data = [];
  6284. $scope.select_treedata = [];
  6285. $scope.doing_async = true;
  6286. api_configure_data
  6287. .fetchDataList("ciclassify", {
  6288. idx: 0,
  6289. sum: 100,
  6290. })
  6291. .then(function (result) {
  6292. //console.log(result['list']);
  6293. $scope.select_treedata = $scope.my_data =
  6294. convertParentToChildList(result["list"]);
  6295. $scope.doing_async = false;
  6296. // tree.expand_all();
  6297. //console.log(treelist);
  6298. });
  6299. };
  6300. $scope.select_treedata = [];
  6301. $scope.propTypeOptions = [];
  6302. $scope.try_async_load();
  6303. $scope.onFilterremove = function (item) {
  6304. console.log(item);
  6305. };
  6306. $scope.searchdata = {};
  6307. $scope.clear = function () {
  6308. $scope.searchdata = {};
  6309. $scope.cifilter_classic = {};
  6310. $scope.try_async_load();
  6311. var fildata = {
  6312. idx: 0,
  6313. sum: 10,
  6314. hw_state: "在库",
  6315. };
  6316. $scope.memoryfilterData = fildata;
  6317. $scope.refreshData("expand-right", fildata);
  6318. };
  6319. $scope.cifilter_classic = {};
  6320. $scope.chiceIncident = function (item) {
  6321. var fildata = defaultFilterData;
  6322. // fildata.applicationForm = {};
  6323. // sign: basehwnwswt
  6324. if (item && item.id) {
  6325. var classify = item.prefix.toLowerCase() + item.sign;
  6326. fildata.sign = classify;
  6327. } else {
  6328. delete fildata.sign;
  6329. }
  6330. $scope.gridOptions.paginationCurrentPage = 1;
  6331. var transitiondata = angular.copy(item);
  6332. $scope.refreshData("expand-right", fildata);
  6333. };
  6334. $scope.applicadata = [];
  6335. $scope.onFilterCallback = function (item) {
  6336. var tempclassify = item.prefix.toLowerCase() + item.sign;
  6337. api_configure_form
  6338. .renderTabForm(tempclassify)
  6339. .then(function (data) {
  6340. var myData = Restangular.stripRestangular(data);
  6341. $scope.applicadata = myData[0].form.fields;
  6342. });
  6343. // }
  6344. };
  6345. // $scope.loadData({
  6346. // idx: 0,
  6347. // sum: 10,
  6348. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6349. // });
  6350. $scope.selected = {
  6351. items: [],
  6352. };
  6353. $scope.ok = function () {
  6354. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  6355. // onDataCallback($scope.selected.item, parentScope);
  6356. // }
  6357. $modalInstance.close($scope.selected.items);
  6358. };
  6359. $scope.cancel = function () {
  6360. $modalInstance.dismiss("cancel");
  6361. };
  6362. },
  6363. size: "lg",
  6364. resolve: {
  6365. items: function () {
  6366. return {
  6367. fetchItems: function (filterData, APIService) {
  6368. filterData = filterData || {};
  6369. if (
  6370. angular.isDefined(filterData.idx) &&
  6371. filterData.idx == null
  6372. ) {
  6373. filterData = {
  6374. idx: 0,
  6375. sum: 10,
  6376. user: {
  6377. roledata: {
  6378. rolecode: "roleset",
  6379. },
  6380. selectType: "1",
  6381. },
  6382. };
  6383. }
  6384. return $scope.options.templateOptions.fetchItems(
  6385. filterData,
  6386. APIService
  6387. );
  6388. },
  6389. };
  6390. },
  6391. title: function () {
  6392. return $scope.options.templateOptions.label;
  6393. },
  6394. Restangular: function () {
  6395. return $scope.options.templateOptions.Restangular;
  6396. },
  6397. APIService: function () {
  6398. return $scope.options.templateOptions.ApiService;
  6399. },
  6400. onDataCallback: function () {
  6401. return $scope.options.templateOptions.callback;
  6402. },
  6403. parentScope: function () {
  6404. return $scope.options.templateOptions.that;
  6405. },
  6406. },
  6407. });
  6408. modalInstance.result.then(
  6409. function (selectedItem) {
  6410. // console.log(selectedItem);
  6411. // options.value(selectedItem);
  6412. var filterData = $scope.memoryfilterDatashe;
  6413. $scope.myDatalingbeiall = selectedItem;
  6414. $scope.gridOptions1["totalItems"] =
  6415. $scope.myDatalingbeiall.length;
  6416. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6417. $scope.myDatalingbeiall[i]["item"] =
  6418. i + 1 + filterData.idx * filterData.sum;
  6419. }
  6420. $scope.myDatalingbei = $scope.interceptMydata(
  6421. $scope.myDatalingbeiall,
  6422. 0,
  6423. 10
  6424. );
  6425. $scope.model.assets = $scope.myDatalingbeiall;
  6426. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  6427. $scope.myDatalingbeiall;
  6428. // if (options.templateOptions.callback && angular.isFunction(options.templateOptions.callback)) {
  6429. // options.templateOptions.callback(selectedItem, options.templateOptions.that);
  6430. // }
  6431. // if (options.templateOptions.linkData && angular.isFunction(options.templateOptions.linkData)) {
  6432. // options.templateOptions.linkData(selectedItem, options.templateOptions.that);
  6433. // }
  6434. },
  6435. function () {
  6436. //console.log('Modal dismissed at: ' + new Date());
  6437. }
  6438. );
  6439. };
  6440. $scope.onDblClick = function (data, event) {
  6441. $scope.selectButtonClick(data, event);
  6442. };
  6443. // $scope.loadData = function(filterData) {};
  6444. // $scope.title = title;
  6445. // $scope.loadData({
  6446. // idx: 0,
  6447. // sum: 20,
  6448. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6449. // });
  6450. $scope.selected = {
  6451. items: [],
  6452. };
  6453. //grid2
  6454. $scope.langs = i18nService.getAllLangs();
  6455. $scope.lang = "zh-cn";
  6456. i18nService.setCurrentLang($scope.lang);
  6457. $scope.gridOptions2 = {};
  6458. $scope.gridOptions2.data = "myDataone";
  6459. $scope.gridOptions2.enableColumnResizing = true;
  6460. $scope.gridOptions2.enableFiltering = false;
  6461. $scope.gridOptions2.enableGridMenu = false;
  6462. $scope.gridOptions2.showGridFooter = true;
  6463. $scope.gridOptions2.showColumnFooter = false;
  6464. $scope.gridOptions2.fastWatch = true;
  6465. $scope.gridOptions2.useExternalFiltering = true;
  6466. $scope.gridOptions2.useExternalPagination = true;
  6467. $scope.gridOptions2.paginationPageSizes = [10];
  6468. $scope.gridOptions2.paginationPageSize = 10;
  6469. $scope.gridOptions2.multiSelect = false;
  6470. // $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row,$event)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  6471. $scope.gridOptions2.columnDefs = [
  6472. {
  6473. name: "item",
  6474. displayName: "序号",
  6475. width: 120,
  6476. },
  6477. {
  6478. name: "name",
  6479. displayName: "耗材名称",
  6480. width: 150,
  6481. enableFiltering: false,
  6482. },
  6483. {
  6484. name: "model",
  6485. displayName: "品牌/型号",
  6486. width: 100,
  6487. enableFiltering: false,
  6488. },
  6489. {
  6490. name: "Specifications",
  6491. displayName: "规格",
  6492. width: 150,
  6493. enableFiltering: false,
  6494. },
  6495. {
  6496. name: "sum",
  6497. displayName: "领用数量",
  6498. enableFiltering: false,
  6499. },
  6500. ];
  6501. // $scope.selectButtonClick
  6502. $scope.gridOptions2.onRegisterApi = function (gridApi) {
  6503. $scope.gridApi = gridApi;
  6504. gridApi.pagination.on.paginationChanged(
  6505. $scope,
  6506. function (newPage, pageSize) {
  6507. // var filtersData = $scope.memoryfilterData;
  6508. // filtersData.idx = newPage - 1;
  6509. // filtersData.sum = pageSize;
  6510. // $scope.loadData(filtersData);
  6511. $scope.memoryfilterDatahao.idx = newPage - 1;
  6512. $scope.memoryfilterDatahao.sum = pageSize;
  6513. $scope.myDataone = $scope.interceptMydata(
  6514. $scope.myDataoneall,
  6515. $scope.memoryfilterDatahao.idx,
  6516. 10
  6517. );
  6518. }
  6519. );
  6520. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  6521. $scope.selected.items.push(data.entity);
  6522. //console.log(data);
  6523. });
  6524. gridApi.selection.on.rowSelectionChangedBatch(
  6525. $scope,
  6526. function (data) {
  6527. $scope.selected.items.push(data.entity);
  6528. //console.log(data);
  6529. }
  6530. );
  6531. gridApi.core.on.filterChanged($scope, function () {
  6532. var grid = this.grid;
  6533. var filtersData = {
  6534. idx: 0,
  6535. sum: 10,
  6536. user: {
  6537. roledata: {
  6538. rolecode: "roleset",
  6539. },
  6540. selectType: "1",
  6541. },
  6542. };
  6543. angular.forEach(grid.columns, function (item) {
  6544. if (item.enableFiltering) {
  6545. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  6546. if (
  6547. angular.isDefined(item.filters[0].term) &&
  6548. item.filters[0].term != ""
  6549. ) {
  6550. if (angular.isUndefined(filtersData["user"])) {
  6551. filtersData["user"] = {};
  6552. }
  6553. filtersData["user"][item.field] = item.filters[0].term;
  6554. }
  6555. }
  6556. });
  6557. $scope.memoryfilterDatahao = filtersData;
  6558. $scope.loadData(filtersData);
  6559. });
  6560. };
  6561. $scope.removehaocai = function (item) {
  6562. event.preventDefault();
  6563. // var modalInstance = $modal.open({
  6564. // templateUrl: 'assets/views/customform/tpl/cmdb/changehaocai.html',
  6565. // controller: function($scope, $modalInstance) {
  6566. // $scope.title = "修改耗材数量";
  6567. // $scope.consumptive = item;
  6568. // $scope.ok = function() {
  6569. // $modalInstance.close($scope.consumptive);
  6570. // };
  6571. // $scope.cancel = function() {
  6572. // $modalInstance.dismiss('cancel');
  6573. // };
  6574. // },
  6575. // size: 'sm'
  6576. // });
  6577. var modalInstance = $modal.open({
  6578. templateUrl: "assets/views/delete.html",
  6579. controller: function ($scope, $modalInstance, scope) {
  6580. $scope.title = "耗材移除";
  6581. $scope.connect = "确定要移除此设备?";
  6582. $scope.consumptive = scope.selected.items[0];
  6583. $scope.ok = function () {
  6584. $modalInstance.close($scope.consumptive);
  6585. };
  6586. $scope.cancel = function () {
  6587. $modalInstance.dismiss("cancel");
  6588. };
  6589. },
  6590. size: "sm",
  6591. resolve: {
  6592. scope: function () {
  6593. return $scope;
  6594. },
  6595. },
  6596. });
  6597. modalInstance.result.then(function (selectedItem) {
  6598. // angular.forEach($scope.myData3, function(items, index) {
  6599. // if (items.id == selectedItem.id) {
  6600. // $scope.myData3[index] = selectedItem;
  6601. // }
  6602. // })
  6603. // $scope.model.applicationForm.consumables = $scope.myData3;
  6604. angular.forEach($scope.myDataoneall, function (items, index) {
  6605. if (items.id == selectedItem.id) {
  6606. $scope.myDataoneall.splice(index, 1);
  6607. }
  6608. });
  6609. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6610. $scope.myDataoneall[i]["item"] =
  6611. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6612. }
  6613. $scope.myDataone = $scope.interceptMydata(
  6614. $scope.myDataoneall,
  6615. 0,
  6616. 10
  6617. );
  6618. $scope.model.consumables = $scope.myDataoneall;
  6619. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6620. $scope.myDataoneall;
  6621. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6622. $scope.selected = {
  6623. items: [],
  6624. };
  6625. });
  6626. };
  6627. $scope.haocaiadd = function () {
  6628. event.preventDefault();
  6629. var modalInstance = $modal.open({
  6630. templateUrl: "assets/views/customform/tpl/cmdb/add_haocai.html",
  6631. controller: function (
  6632. $scope,
  6633. scope,
  6634. $modalInstance,
  6635. api_wechatfile,
  6636. SweetAlert,
  6637. api_cmdb3
  6638. ) {
  6639. $scope.haocainame = [];
  6640. $scope.pinpai = [];
  6641. $scope.guige = [];
  6642. $scope.consumptive = {};
  6643. $scope.consumpall = {};
  6644. $scope.title = "添加耗材";
  6645. api_wechatfile
  6646. .getDictionaryForList({
  6647. key: "haocaifenlei",
  6648. })
  6649. .then(function (data) {
  6650. $scope.haocainame = data;
  6651. });
  6652. $scope.clearNoNum = function (obj, attr) {
  6653. //先把非数字的都替换掉,除了数字和.
  6654. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  6655. //必须保证第一个为数字而不是.
  6656. obj[attr] = obj[attr].replace(/^\./g, "");
  6657. //保证只有出现一个.而没有多个.
  6658. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  6659. //保证.只出现一次,而不能出现两次以上
  6660. obj[attr] = obj[attr]
  6661. .replace(".", "$#$")
  6662. .replace(/\./g, "")
  6663. .replace("$#$", ".");
  6664. //小于最大值
  6665. if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  6666. alert(
  6667. "输入数据超过库存数量" + $scope.maxsum + ",请重新输入!"
  6668. );
  6669. obj[attr] = "";
  6670. }
  6671. };
  6672. $scope.onChange = function (parent) {
  6673. $scope.consumptive.model = {};
  6674. $scope.consumptive.Specifications = {};
  6675. api_wechatfile
  6676. .getDictionaryForList({
  6677. key: "pinpai",
  6678. parent: parent.id,
  6679. })
  6680. .then(function (data) {
  6681. $scope.pinpai = data;
  6682. });
  6683. api_wechatfile
  6684. .getDictionaryForList({
  6685. key: "guige",
  6686. parent: parent.id,
  6687. })
  6688. .then(function (data) {
  6689. $scope.guige = data;
  6690. });
  6691. };
  6692. $scope.onChangesum = function (item) {
  6693. if (item.name && item.model.id && item.Specifications.id) {
  6694. $scope.consumptive.sum = "";
  6695. var data1 = {
  6696. idx: 0,
  6697. sum: 10,
  6698. consumable: {
  6699. name: item.name.name,
  6700. brandModel: item.model.name,
  6701. specification: item.Specifications.name,
  6702. },
  6703. };
  6704. api_cmdb3
  6705. .fetchDataList("consumable", data1)
  6706. .then(function (data) {
  6707. if (data.status == 200 && data.list.length > 0) {
  6708. var myData = data.list;
  6709. $scope.consumpall = myData[0];
  6710. $scope.maxsum = myData[0].inventoryNum;
  6711. } else {
  6712. SweetAlert.swal({
  6713. title: "不存在该耗材",
  6714. text: "请检查库存后重新填写!",
  6715. type: "error",
  6716. });
  6717. }
  6718. });
  6719. }
  6720. };
  6721. $scope.addhaocai = function () {
  6722. $modalInstance.dismiss("cancel");
  6723. scope.haocaiopen($scope.consumptive);
  6724. };
  6725. $scope.ok = function (item) {
  6726. var items = {};
  6727. // if (item.name && item.model && item.Specifications && item.sum) {
  6728. // // items = { "name": item.name.name, "model": item.model.name, "Specifications": item.Specifications.name, "sum": item.sum }
  6729. // $scope.consumpall.model = $scope.consumpall.brandModel;
  6730. // $scope.consumpall.Specifications = $scope.consumpall.specification;
  6731. // $scope.consumpall.sum = item.sum;
  6732. // delete $scope.consumpall.brandModel;
  6733. // delete $scope.consumpall.specification;
  6734. // $modalInstance.close($scope.consumpall);
  6735. // } else {
  6736. // SweetAlert.swal({
  6737. // title: "数据填写不完整!",
  6738. // text: "请检查数据然后提交!",
  6739. // type: "error"
  6740. // });
  6741. // }
  6742. var isold = false;
  6743. if (
  6744. item.name &&
  6745. item.model &&
  6746. JSON.stringify(item.model) != "{}" &&
  6747. item.Specifications &&
  6748. JSON.stringify(item.Specifications) != "{}" &&
  6749. item.sum
  6750. ) {
  6751. for (var i = 0; i < scope.myDataoneall.length; i++) {
  6752. if (scope.myDataoneall[i].id == $scope.consumpall.id) {
  6753. isold = true;
  6754. }
  6755. }
  6756. if (isold) {
  6757. SweetAlert.swal({
  6758. title: "该耗材已添加!",
  6759. text: "请不要重复添加耗材!",
  6760. type: "error",
  6761. });
  6762. } else {
  6763. $scope.consumpall.model = $scope.consumpall.brandModel;
  6764. $scope.consumpall.Specifications =
  6765. $scope.consumpall.specification;
  6766. $scope.consumpall.sum = item.sum;
  6767. delete $scope.consumpall.brandModel;
  6768. delete $scope.consumpall.specification;
  6769. $modalInstance.close($scope.consumpall);
  6770. }
  6771. } else {
  6772. SweetAlert.swal({
  6773. title: "数据填写不完整!",
  6774. text: "请检查数据然后提交!",
  6775. type: "error",
  6776. });
  6777. }
  6778. // $modalInstance.close(item);
  6779. };
  6780. $scope.cancel = function () {
  6781. $modalInstance.dismiss("cancel");
  6782. };
  6783. },
  6784. size: "sm",
  6785. resolve: {
  6786. scope: function () {
  6787. return $scope;
  6788. },
  6789. },
  6790. });
  6791. modalInstance.result.then(function (selectedItem) {
  6792. $scope.myDataoneall.push(selectedItem);
  6793. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6794. $scope.myDataoneall[i]["item"] =
  6795. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6796. }
  6797. // $scope.model.consumables = $scope.myDataone;
  6798. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6799. $scope.myDataone = $scope.interceptMydata(
  6800. $scope.myDataoneall,
  6801. 0,
  6802. 10
  6803. );
  6804. $scope.model.consumables = $scope.myDataoneall;
  6805. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  6806. $scope.myDataoneall;
  6807. });
  6808. };
  6809. $scope.onDblClick = function (data, event) {
  6810. $scope.selectButtonClick(data, event);
  6811. };
  6812. $scope.memoryfilterDatahao = {
  6813. idx: 0,
  6814. sum: 10,
  6815. // "user": { "roledata": { "rolecode": "roleset" }, "selectType": "1" }
  6816. };
  6817. $scope.myDataone = [];
  6818. $scope.loadData = function (filterData) { };
  6819. // $scope.title = title;
  6820. $scope.ldloading = {};
  6821. $scope.selected = {
  6822. items: [],
  6823. };
  6824. if ($scope.$parent.$parent.$parent.model.gettype) {
  6825. if ($scope.$parent.$parent.$parent.model.gettype.hao == "true") {
  6826. if ($scope.model.assets) {
  6827. if (JSON.stringify($scope.model.assets) == "{}") {
  6828. $scope.model.assets = [];
  6829. } else {
  6830. $scope.model.assets = JSON.parse($scope.model.assets);
  6831. }
  6832. $scope.myDatalingbeiall = $scope.model.assets;
  6833. for (var i = 0; i < $scope.myDatalingbeiall.length; i++) {
  6834. $scope.myDatalingbeiall[i]["item"] =
  6835. i + 1 + $scope.memoryfilterDatashe.idx * 10;
  6836. }
  6837. $scope.gridOptions1["totalItems"] =
  6838. $scope.myDatalingbeiall.length;
  6839. $scope.myDatalingbei = $scope.interceptMydata(
  6840. $scope.myDatalingbeiall,
  6841. 0,
  6842. 10
  6843. );
  6844. }
  6845. if ($scope.model.consumables) {
  6846. if (JSON.stringify($scope.model.consumables) == "{}") {
  6847. $scope.model.consumables = [];
  6848. } else {
  6849. $scope.model.consumables = JSON.parse($scope.model.consumables);
  6850. }
  6851. $scope.myDataoneall = $scope.model.consumables;
  6852. for (var i = 0; i < $scope.myDataoneall.length; i++) {
  6853. $scope.myDataoneall[i]["item"] =
  6854. i + 1 + $scope.memoryfilterDatahao.idx * 10;
  6855. }
  6856. $scope.gridOptions2["totalItems"] = $scope.myDataoneall.length;
  6857. $scope.myDataone = $scope.interceptMydata(
  6858. $scope.myDataoneall,
  6859. 0,
  6860. 10
  6861. );
  6862. }
  6863. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6864. $scope.options.templateOptions.getpush({
  6865. hao: true,
  6866. gu: true,
  6867. });
  6868. } else {
  6869. $scope.options.templateOptions.getpush({
  6870. hao: true,
  6871. });
  6872. }
  6873. } else {
  6874. if ($scope.$parent.$parent.$parent.model.gettype.gu == "true") {
  6875. $scope.options.templateOptions.getpush({
  6876. gu: true,
  6877. });
  6878. }
  6879. }
  6880. }
  6881. },
  6882. ],
  6883. });
  6884. formlyConfigProvider.setType({
  6885. name: "ui-panel",
  6886. templateUrl: "assets/views/customform/tpl/ui-panel.html",
  6887. });
  6888. formlyConfigProvider.setType({
  6889. name: "ui-currentuser",
  6890. extends: "input",
  6891. templateUrl: "assets/views/customform/tpl/ui-username.html",
  6892. defaultOptions: function (options) {
  6893. return {
  6894. templateOptions: {
  6895. // link: function() {}
  6896. },
  6897. };
  6898. },
  6899. controller: [
  6900. "$scope",
  6901. function ($scope) {
  6902. if ($scope.options.templateOptions.user) {
  6903. if (angular.isFunction($scope.options.templateOptions.transform)) {
  6904. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  6905. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  6906. // }
  6907. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6908. $scope.$parent.$parent.$parent.model["directClose"] = false;
  6909. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  6910. }
  6911. $scope.model[$scope.options.key] =
  6912. $scope.options.templateOptions.user;
  6913. $scope.options.initialValue = $scope.model[$scope.options.key];
  6914. }
  6915. },
  6916. ],
  6917. });
  6918. //仪表盘
  6919. //待处理变更列表
  6920. formlyConfigProvider.setType({
  6921. name: "ui-ngpchangetable",
  6922. templateUrl: "assets/views/customform/tpl/ui-ngpchangetable.html",
  6923. defaultOptions: function (options) {
  6924. return {
  6925. templateOptions: {
  6926. // relationAction: function() {
  6927. // options.hideExpression = true
  6928. // }
  6929. },
  6930. };
  6931. },
  6932. controller: [
  6933. "$scope",
  6934. "$modal",
  6935. "$timeout",
  6936. "SweetAlert",
  6937. "api_bpm_domain",
  6938. "$rootScope",
  6939. "ngTableParams",
  6940. "$filter",
  6941. "$state",
  6942. function (
  6943. $scope,
  6944. $modal,
  6945. $timeout,
  6946. SweetAlert,
  6947. api_bpm_domain,
  6948. $rootScope,
  6949. ngTableParams,
  6950. $filter,
  6951. $state
  6952. ) {
  6953. // var filterData = {
  6954. // "assignee": $rootScope.user.id,
  6955. // "searchtype": "all",
  6956. // "idx": "0",
  6957. // "sum": "10"
  6958. // };
  6959. var filterData = {
  6960. idx: "0",
  6961. sum: "10",
  6962. assignee: 2,
  6963. searchType: "todo",
  6964. };
  6965. $scope.incidentprocess = function (item) {
  6966. $state.go("app.wt_change.add", {
  6967. taskId: item.taskId,
  6968. processInstanceId: item.processInstanceId,
  6969. });
  6970. };
  6971. $scope.more = function () {
  6972. $state.go("app.wt_change.list", {});
  6973. };
  6974. api_bpm_domain
  6975. .fetchtask("bpm_change", filterData)
  6976. .then(function (data) {
  6977. if (data.data) {
  6978. $scope.myData = data.data;
  6979. } else {
  6980. SweetAlert.swal({
  6981. title: "操作异常!",
  6982. text: "系统异常,请稍后重试,或者联系管理员!",
  6983. type: "error",
  6984. });
  6985. }
  6986. });
  6987. $scope.removes = function () {
  6988. var modalInstance = $modal.open({
  6989. templateUrl: "assets/views/delete.html",
  6990. controller: function ($scope, $modalInstance) {
  6991. $scope.ok = function () {
  6992. $modalInstance.close();
  6993. };
  6994. $scope.cancel = function () {
  6995. $modalInstance.dismiss("cancel");
  6996. };
  6997. },
  6998. size: "sm",
  6999. });
  7000. modalInstance.result.then(function () {
  7001. console.log($scope.$parent.$parent.$parent.$parent);
  7002. for (
  7003. var i = 0;
  7004. i <
  7005. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7006. i++
  7007. ) {
  7008. if (
  7009. $scope.fields.type ==
  7010. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7011. .type
  7012. ) {
  7013. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7014. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7015. i,
  7016. 1
  7017. );
  7018. break;
  7019. }
  7020. }
  7021. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7022. if (vmForm) {
  7023. //console.log("vmForm>>>");//console.log(vmForm);
  7024. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7025. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7026. }
  7027. });
  7028. };
  7029. },
  7030. ],
  7031. });
  7032. //待处理问题列表
  7033. formlyConfigProvider.setType({
  7034. name: "ui-ngproblemtable",
  7035. templateUrl: "assets/views/customform/tpl/ui-ngproblemtable.html",
  7036. defaultOptions: function (options) {
  7037. return {
  7038. templateOptions: {
  7039. // relationAction: function() {
  7040. // options.hideExpression = true
  7041. // }
  7042. },
  7043. };
  7044. },
  7045. controller: [
  7046. "$scope",
  7047. "$modal",
  7048. "$timeout",
  7049. "SweetAlert",
  7050. "api_bpm_data",
  7051. "$rootScope",
  7052. "ngTableParams",
  7053. "$filter",
  7054. "$state",
  7055. function (
  7056. $scope,
  7057. $modal,
  7058. $timeout,
  7059. SweetAlert,
  7060. api_bpm_data,
  7061. $rootScope,
  7062. ngTableParams,
  7063. $filter,
  7064. $state
  7065. ) {
  7066. var filterData = {
  7067. assignee: $rootScope.user.id,
  7068. candidateGroups: $rootScope.user.group[0].id,
  7069. searchtype: "todo",
  7070. idx: 0,
  7071. sum: 10,
  7072. };
  7073. $scope.incidentprocess = function (item) {
  7074. $state.go("app.wt_change.add", {
  7075. taskId: item.taskId,
  7076. processInstanceId: item.processInstanceId,
  7077. });
  7078. };
  7079. $scope.more = function () {
  7080. $state.go("app.wt_change.list", {});
  7081. };
  7082. api_bpm_data
  7083. .fetchDataList("changeclassify", filterData)
  7084. .then(function (data) {
  7085. if (data.data) {
  7086. $scope.myData = data.data;
  7087. } else {
  7088. SweetAlert.swal({
  7089. title: "操作异常!",
  7090. text: "系统异常,请稍后重试,或者联系管理员!",
  7091. type: "error",
  7092. });
  7093. }
  7094. });
  7095. $scope.removes = function () {
  7096. var modalInstance = $modal.open({
  7097. templateUrl: "assets/views/delete.html",
  7098. controller: function ($scope, $modalInstance) {
  7099. $scope.ok = function () {
  7100. $modalInstance.close();
  7101. };
  7102. $scope.cancel = function () {
  7103. $modalInstance.dismiss("cancel");
  7104. };
  7105. },
  7106. size: "sm",
  7107. });
  7108. modalInstance.result.then(function () {
  7109. console.log($scope.$parent.$parent.$parent.$parent);
  7110. for (
  7111. var i = 0;
  7112. i <
  7113. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7114. i++
  7115. ) {
  7116. if (
  7117. $scope.fields.type ==
  7118. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7119. .type
  7120. ) {
  7121. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7122. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7123. i,
  7124. 1
  7125. );
  7126. break;
  7127. }
  7128. }
  7129. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7130. if (vmForm) {
  7131. //console.log("vmForm>>>");//console.log(vmForm);
  7132. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7133. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7134. }
  7135. });
  7136. };
  7137. },
  7138. ],
  7139. });
  7140. //待处理事件列表
  7141. formlyConfigProvider.setType({
  7142. name: "ui-ngtable",
  7143. templateUrl: "assets/views/customform/tpl/ui-ngtable.html",
  7144. defaultOptions: function (options) {
  7145. return {
  7146. templateOptions: {
  7147. // relationAction: function() {
  7148. // options.hideExpression = true
  7149. // }
  7150. },
  7151. };
  7152. },
  7153. controller: [
  7154. "$scope",
  7155. "$modal",
  7156. "$timeout",
  7157. "SweetAlert",
  7158. "api_bpm_domain",
  7159. "$rootScope",
  7160. "ngTableParams",
  7161. "$filter",
  7162. "$state",
  7163. function (
  7164. $scope,
  7165. $modal,
  7166. $timeout,
  7167. SweetAlert,
  7168. api_bpm_domain,
  7169. $rootScope,
  7170. ngTableParams,
  7171. $filter,
  7172. $state
  7173. ) {
  7174. var filterData = {
  7175. assignee: $rootScope.user.id,
  7176. candidateGroups: $rootScope.user.group[0].id,
  7177. searchtype: "done",
  7178. idx: 0,
  7179. sum: 10,
  7180. };
  7181. $scope.incidentprocess = function (item) {
  7182. $state.go("app.incident.editor", {
  7183. taskId: item.taskId,
  7184. processInstanceId: item.processInstanceId,
  7185. });
  7186. };
  7187. $scope.more = function () {
  7188. $state.go("app.incident.list", {});
  7189. };
  7190. api_bpm_domain
  7191. .fetchtask("bpm_incident", filterData)
  7192. .then(function (data) {
  7193. if (data.data) {
  7194. $scope.myData = data.data;
  7195. } else {
  7196. SweetAlert.swal({
  7197. title: "操作异常!",
  7198. text: "系统异常,请稍后重试,或者联系管理员!",
  7199. type: "error",
  7200. });
  7201. }
  7202. });
  7203. $scope.removes = function () {
  7204. var modalInstance = $modal.open({
  7205. templateUrl: "assets/views/delete.html",
  7206. controller: function ($scope, $modalInstance) {
  7207. $scope.ok = function () {
  7208. $modalInstance.close();
  7209. };
  7210. $scope.cancel = function () {
  7211. $modalInstance.dismiss("cancel");
  7212. };
  7213. },
  7214. size: "sm",
  7215. });
  7216. modalInstance.result.then(function () {
  7217. console.log($scope.$parent.$parent.$parent.$parent);
  7218. for (
  7219. var i = 0;
  7220. i <
  7221. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7222. i++
  7223. ) {
  7224. if (
  7225. $scope.fields.type ==
  7226. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7227. .type
  7228. ) {
  7229. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7230. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7231. i,
  7232. 1
  7233. );
  7234. break;
  7235. }
  7236. }
  7237. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7238. if (vmForm) {
  7239. //console.log("vmForm>>>");//console.log(vmForm);
  7240. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7241. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7242. }
  7243. });
  7244. };
  7245. },
  7246. ],
  7247. });
  7248. //知识库列表
  7249. formlyConfigProvider.setType({
  7250. name: "ui-knowledge",
  7251. templateUrl: "assets/views/customform/tpl/ui-knowledgelist.html",
  7252. defaultOptions: function (options) {
  7253. return {
  7254. templateOptions: {
  7255. // relationAction: function() {
  7256. // options.hideExpression = true
  7257. // }
  7258. },
  7259. };
  7260. },
  7261. controller: [
  7262. "$scope",
  7263. "$modal",
  7264. "$timeout",
  7265. "api_solution",
  7266. "$rootScope",
  7267. "ngTableParams",
  7268. "$filter",
  7269. "$state",
  7270. function (
  7271. $scope,
  7272. $modal,
  7273. $timeout,
  7274. api_solution,
  7275. $rootScope,
  7276. ngTableParams,
  7277. $filter,
  7278. $state
  7279. ) {
  7280. var filterData = {
  7281. key: "null",
  7282. pageIndex: 0,
  7283. pageSum: 6,
  7284. status: 0,
  7285. userId: $rootScope.user.id,
  7286. };
  7287. $scope.model.removereport = false;
  7288. $scope.removes = function () {
  7289. $scope.model.removereport = true;
  7290. };
  7291. $scope.more = function () {
  7292. $state.go("app.knowledge.manager", {});
  7293. };
  7294. api_solution.findSolutionByKeys(filterData).then(function (data) {
  7295. if (data.status == 200) {
  7296. $scope.myData = data.list;
  7297. }
  7298. });
  7299. $scope.removes = function () {
  7300. var modalInstance = $modal.open({
  7301. templateUrl: "assets/views/delete.html",
  7302. controller: function ($scope, $modalInstance) {
  7303. $scope.ok = function () {
  7304. $modalInstance.close();
  7305. };
  7306. $scope.cancel = function () {
  7307. $modalInstance.dismiss("cancel");
  7308. };
  7309. },
  7310. size: "sm",
  7311. });
  7312. modalInstance.result.then(function () {
  7313. for (
  7314. var i = 0;
  7315. i <
  7316. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7317. i++
  7318. ) {
  7319. if (
  7320. $scope.fields.type ==
  7321. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7322. .type
  7323. ) {
  7324. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7325. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7326. i,
  7327. 1
  7328. );
  7329. break;
  7330. }
  7331. }
  7332. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7333. if (vmForm) {
  7334. //console.log("vmForm>>>");//console.log(vmForm);
  7335. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7336. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7337. }
  7338. });
  7339. };
  7340. },
  7341. ],
  7342. });
  7343. //公告列表
  7344. formlyConfigProvider.setType({
  7345. name: "ui-ngnotice",
  7346. templateUrl: "assets/views/customform/tpl/ui-ngnotice.html",
  7347. defaultOptions: function (options) {
  7348. return {
  7349. templateOptions: {
  7350. // relationAction: function() {
  7351. // options.hideExpression = true
  7352. // }
  7353. },
  7354. };
  7355. },
  7356. controller: [
  7357. "$scope",
  7358. "$modal",
  7359. "$timeout",
  7360. "SweetAlert",
  7361. "api_user_data",
  7362. "$rootScope",
  7363. "ngTableParams",
  7364. "$filter",
  7365. "$state",
  7366. function (
  7367. $scope,
  7368. $modal,
  7369. $timeout,
  7370. SweetAlert,
  7371. api_user_data,
  7372. $rootScope,
  7373. ngTableParams,
  7374. $filter,
  7375. $state
  7376. ) {
  7377. var filterData = {
  7378. idx: 0,
  7379. sum: 10,
  7380. };
  7381. // $scope.$scope.model.className = "col-xs-12";
  7382. api_user_data.fetchDataList("notice", filterData).then(function (data) {
  7383. if (data) {
  7384. $scope.myData = data.data;
  7385. } else {
  7386. SweetAlert.swal({
  7387. title: "操作异常!",
  7388. text: "系统异常,请稍后重试,或者联系管理员!",
  7389. type: "error",
  7390. });
  7391. }
  7392. });
  7393. $scope.more = function () {
  7394. $state.go("app.system.notice.list", {});
  7395. };
  7396. $scope.removes = function () {
  7397. var modalInstance = $modal.open({
  7398. templateUrl: "assets/views/delete.html",
  7399. controller: function ($scope, $modalInstance) {
  7400. $scope.ok = function () {
  7401. $modalInstance.close();
  7402. };
  7403. $scope.cancel = function () {
  7404. $modalInstance.dismiss("cancel");
  7405. };
  7406. },
  7407. size: "sm",
  7408. });
  7409. modalInstance.result.then(function () {
  7410. for (
  7411. var i = 0;
  7412. i <
  7413. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7414. i++
  7415. ) {
  7416. if (
  7417. $scope.fields.type ==
  7418. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7419. .type
  7420. ) {
  7421. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7422. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7423. i,
  7424. 1
  7425. );
  7426. break;
  7427. }
  7428. }
  7429. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7430. if (vmForm) {
  7431. //console.log("vmForm>>>");//console.log(vmForm);
  7432. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7433. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7434. }
  7435. });
  7436. };
  7437. },
  7438. ],
  7439. });
  7440. //事件统计图
  7441. formlyConfigProvider.setType({
  7442. name: "ui-incidentreport",
  7443. templateUrl: "assets/views/customform/tpl/ui-incidentreport.html",
  7444. defaultOptions: function (options) {
  7445. return {
  7446. templateOptions: {
  7447. // relationAction: function() {
  7448. // options.hideExpression = true
  7449. // }
  7450. },
  7451. };
  7452. },
  7453. controller: [
  7454. "$scope",
  7455. "$modal",
  7456. "moment",
  7457. "api_report",
  7458. "$cookieStore",
  7459. function ($scope, $modal, moment, api_report, $cookieStore) {
  7460. api_report.getLicenseKey().then(function (response) {
  7461. $cookieStore.put("Auth-Token", response.token);
  7462. $scope.try_async_load();
  7463. });
  7464. $scope.try_async_load = function () {
  7465. $scope.my_data = [];
  7466. api_report.list().then(function (response) {
  7467. var dataList = response;
  7468. getRepoRoot(dataList, "/homes/home:admin/ITSM报表");
  7469. $scope.repoRoot.name = "事件报表";
  7470. convertRepoObject($scope.repoRoot);
  7471. $scope.my_data.push($scope.repoRoot);
  7472. });
  7473. };
  7474. var workspace = {};
  7475. $scope.repoRoot = null;
  7476. function getRepoRoot(repo, path) {
  7477. angular.forEach(repo, function (value, key) {
  7478. if (value.path == path) {
  7479. $scope.repoRoot = value;
  7480. } else {
  7481. if (
  7482. $scope.repoRoot == null &&
  7483. angular.isDefined(value.repoObjects)
  7484. ) {
  7485. getRepoRoot(value.repoObjects, path);
  7486. } else {
  7487. }
  7488. }
  7489. });
  7490. }
  7491. function convertRepoObject(repo) {
  7492. if (angular.isArray(repo)) {
  7493. angular.forEach(repo, function (value, key) {
  7494. convertRepoObject(value);
  7495. });
  7496. } else {
  7497. if (angular.isDefined(repo.name)) {
  7498. if (repo.name.indexOf(".") >= 0) {
  7499. repo.label = repo.name.substr(0, repo.name.lastIndexOf("."));
  7500. } else {
  7501. repo.label = repo.name;
  7502. }
  7503. //delete repo.name;
  7504. }
  7505. if (angular.isDefined(repo.repoObjects)) {
  7506. repo.children = [];
  7507. repo.children = repo.repoObjects;
  7508. delete repo.repoObjects;
  7509. convertRepoObject(repo.children);
  7510. }
  7511. }
  7512. }
  7513. function parseDateParameter(parameters) {
  7514. var result = undefined;
  7515. if (angular.isArray(parameters)) {
  7516. // angular.forEach(parmeters,function(param){
  7517. // param.
  7518. // })
  7519. } else {
  7520. result = {};
  7521. for (var k in parameters) {
  7522. if (k.indexOf("Date") > 0) {
  7523. if (angular.isString(parameters[k])) {
  7524. result[k] = moment(parameters[k], "YYYYMMDD").format(
  7525. "YYYY-MM-DD"
  7526. );
  7527. //result[k] = ''+parameters[k]+'';//= moment(parameters[k], "YYYYMMDD").toDate();
  7528. }
  7529. }
  7530. }
  7531. }
  7532. return result;
  7533. }
  7534. function ConvertDateParameter(parameters) {
  7535. var result = undefined;
  7536. if (angular.isArray(parameters)) {
  7537. //
  7538. } else {
  7539. result = {};
  7540. for (var k in parameters) {
  7541. if (k.indexOf("Date") > 0) {
  7542. if (angular.isDate(parameters[k])) {
  7543. result[k] = moment(parameters[k]).format("YYYYMMDD");
  7544. } else if (angular.isString(parameters[k])) {
  7545. result[k] = parameters[k];
  7546. }
  7547. }
  7548. }
  7549. }
  7550. return result;
  7551. }
  7552. var incidentchart =
  7553. "/homes/home:admin/ITSM报表/事件报表/日统计报表.saiku";
  7554. var queryUUID;
  7555. function genUUID() {
  7556. var uuid = "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx"
  7557. .replace(/[xy]/g, function (c) {
  7558. var r = (Math.random() * 16) | 0,
  7559. v = c == "x" ? r : (r & 0x3) | 0x8;
  7560. return v.toString(16);
  7561. })
  7562. .toUpperCase();
  7563. return uuid;
  7564. }
  7565. queryUUID = genUUID();
  7566. var pathincidenttimekey = [];
  7567. var incidenttime = {
  7568. starttimes: moment(new Date().getTime() - 86400000 * 14).format(
  7569. "YYYYMMDD"
  7570. ),
  7571. endtimes: moment(new Date()).format("YYYYMMDD"),
  7572. };
  7573. var thisday = moment(new Date().getTime() + 86400000).format(
  7574. "YYYYMMDD"
  7575. );
  7576. var thisdaymine = Date.parse(
  7577. thisday.substr(4, 2) +
  7578. "/" +
  7579. thisday.substr(6, 2) +
  7580. "/" +
  7581. thisday.substr(0, 4)
  7582. );
  7583. var averages = [
  7584. [thisdaymine - 86400000 * 14, 0],
  7585. [thisdaymine - 86400000 * 13, 0],
  7586. [thisdaymine - 86400000 * 12, 0],
  7587. [thisdaymine - 86400000 * 11, 0],
  7588. [thisdaymine - 86400000 * 10, 0],
  7589. [thisdaymine - 86400000 * 9, 0],
  7590. [thisdaymine - 86400000 * 8, 0],
  7591. [thisdaymine - 86400000 * 7, 0],
  7592. [thisdaymine - 86400000 * 6, 0],
  7593. [thisdaymine - 86400000 * 5, 0],
  7594. [thisdaymine - 86400000 * 4, 0],
  7595. [thisdaymine - 86400000 * 3, 0],
  7596. [thisdaymine - 86400000 * 2, 0],
  7597. [thisdaymine - 86400000 * 1, 0],
  7598. [thisdaymine, 0],
  7599. ];
  7600. var getreportdata = function (incidenttime, path) {
  7601. api_report.getMdx(path, queryUUID).then(function (response) {
  7602. var mdxquery = response;
  7603. workspace.query = mdxquery;
  7604. workspace.query.parameters.paramDateFrom = incidenttime.starttimes;
  7605. workspace.query.parameters.paramDateTo = incidenttime.endtimes;
  7606. $scope.parameters = parseDateParameter(workspace.query.parameters);
  7607. weekuser(mdxquery);
  7608. });
  7609. };
  7610. getreportdata(incidenttime, incidentchart);
  7611. var weekuser = function (mdxquery) {
  7612. var key = [];
  7613. api_report.execute(mdxquery).then(function (data) {
  7614. $scope.rheaders = [];
  7615. $scope.rRows = [];
  7616. var reportData = data;
  7617. if (reportData.cellset == null || reportData.cellset.length == 0) {
  7618. $scope.shows = true;
  7619. $scope.empty = "数据为空!";
  7620. } else {
  7621. angular.forEach(reportData.cellset, function (item, i) {
  7622. angular.forEach(averages, function (index, j) {
  7623. // angular.forEach(averages, function(item, index) {
  7624. if (item.length > 1 && i > 0 && item[1].value != "") {
  7625. if (
  7626. index[0] ==
  7627. Date.parse(
  7628. item[0].value.substr(4, 2) +
  7629. "/" +
  7630. item[0].value.substr(6, 2) +
  7631. "/" +
  7632. item[0].value.substr(0, 4)
  7633. ) +
  7634. 86400000
  7635. ) {
  7636. index[1] = Number(item[1].value);
  7637. }
  7638. // key.push([Date.parse(item[0].value.substr(4, 2) + "/" + item[0].value.substr(6, 2) + "/" + item[0].value.substr(0, 4)), Number(item[1].value)]);
  7639. }
  7640. // })
  7641. });
  7642. });
  7643. incidentchartfun(averages);
  7644. }
  7645. });
  7646. };
  7647. var incidentchartfun = function (incidentchartkey) {
  7648. // $scope.isMaskincident = false;
  7649. Highcharts.chart("incidentchart", {
  7650. title: {
  7651. text: "事件近15天趋势图",
  7652. },
  7653. xAxis: {
  7654. type: "datetime",
  7655. labels: {
  7656. align: "left",
  7657. step: 1,
  7658. },
  7659. },
  7660. yAxis: {
  7661. title: {
  7662. text: null,
  7663. },
  7664. },
  7665. tooltip: {
  7666. crosshairs: true,
  7667. shared: true,
  7668. valueSuffix: "条",
  7669. },
  7670. legend: {},
  7671. series: [
  7672. {
  7673. name: "生成事件",
  7674. data: incidentchartkey,
  7675. zIndex: 1,
  7676. marker: {
  7677. fillColor: "white",
  7678. lineWidth: 2,
  7679. lineColor: Highcharts.getOptions().colors[0],
  7680. },
  7681. },
  7682. ],
  7683. });
  7684. };
  7685. $scope.data = {
  7686. labels: [
  7687. "1号",
  7688. "2号",
  7689. "3号",
  7690. "4号",
  7691. "5号",
  7692. "6号",
  7693. "7号",
  7694. "8号",
  7695. "9号",
  7696. "10号",
  7697. "11号",
  7698. "12号",
  7699. "13号",
  7700. "14号",
  7701. "15号",
  7702. ],
  7703. datasets: [
  7704. {
  7705. label: "新增事件数量",
  7706. fillColor: "rgba(220,220,220,0.2)",
  7707. strokeColor: "rgba(220,220,220,1)",
  7708. pointColor: "rgba(220,220,220,1)",
  7709. pointStrokeColor: "#fff",
  7710. pointHighlightFill: "#fff",
  7711. pointHighlightStroke: "rgba(220,220,220,1)",
  7712. data: [
  7713. 65, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87, 78, 23, 34,
  7714. ],
  7715. },
  7716. {
  7717. label: "已解决事件数量",
  7718. fillColor: "rgba(151,187,205,0.2)",
  7719. strokeColor: "rgba(151,187,205,1)",
  7720. pointColor: "rgba(151,187,205,1)",
  7721. pointStrokeColor: "#fff",
  7722. pointHighlightFill: "#fff",
  7723. pointHighlightStroke: "rgba(151,187,205,1)",
  7724. data: [
  7725. 48, 48, 78, 80, 86, 27, 90, 60, 60, 120, 60, 80, 83, 44, 20,
  7726. ],
  7727. },
  7728. ],
  7729. };
  7730. $scope.removes = function () {
  7731. var modalInstance = $modal.open({
  7732. templateUrl: "assets/views/delete.html",
  7733. controller: function ($scope, $modalInstance) {
  7734. $scope.ok = function () {
  7735. $modalInstance.close();
  7736. };
  7737. $scope.cancel = function () {
  7738. $modalInstance.dismiss("cancel");
  7739. };
  7740. },
  7741. size: "sm",
  7742. });
  7743. modalInstance.result.then(function () {
  7744. for (
  7745. var i = 0;
  7746. i <
  7747. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  7748. i++
  7749. ) {
  7750. if (
  7751. $scope.fields.type ==
  7752. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  7753. .type
  7754. ) {
  7755. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  7756. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  7757. i,
  7758. 1
  7759. );
  7760. break;
  7761. }
  7762. }
  7763. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  7764. if (vmForm) {
  7765. //console.log("vmForm>>>");//console.log(vmForm);
  7766. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  7767. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  7768. }
  7769. });
  7770. };
  7771. var addDatas = 0;
  7772. var resolve = 0;
  7773. for (var i = 0; i < $scope.data.datasets[0].data.length; i++) {
  7774. addDatas = addDatas + $scope.data.datasets[0].data[i];
  7775. }
  7776. for (var i = 0; i < $scope.data.datasets[1].data.length; i++) {
  7777. resolve = resolve + $scope.data.datasets[1].data[i];
  7778. }
  7779. $scope.resolution = ((resolve / addDatas) * 100).toFixed(2);
  7780. $scope.opt = {
  7781. maintainAspectRatio: false,
  7782. // Sets the chart to be responsive
  7783. responsive: true,
  7784. ///Boolean - Whether grid lines are shown across the chart
  7785. scaleShowGridLines: true,
  7786. //String - Colour of the grid lines
  7787. scaleGridLineColor: "rgba(0,0,0,.05)",
  7788. //Number - Width of the grid lines
  7789. scaleGridLineWidth: 1,
  7790. //Boolean - Whether the line is curved between points
  7791. bezierCurve: false,
  7792. //Number - Tension of the bezier curve between points
  7793. bezierCurveTension: 0.4,
  7794. //Boolean - Whether to show a dot for each point
  7795. pointDot: true,
  7796. //Number - Radius of each point dot in pixels
  7797. pointDotRadius: 4,
  7798. //Number - Pixel width of point dot stroke
  7799. pointDotStrokeWidth: 1,
  7800. //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
  7801. pointHitDetectionRadius: 20,
  7802. //Boolean - Whether to show a stroke for datasets
  7803. datasetStroke: true,
  7804. //Number - Pixel width of dataset stroke
  7805. datasetStrokeWidth: 2,
  7806. //Boolean - Whether to fill the dataset with a colour
  7807. datasetFill: true,
  7808. // Function - on animation progress
  7809. onAnimationProgress: function () { },
  7810. // Function - on animation complete
  7811. onAnimationComplete: function () { },
  7812. //String - A legend template
  7813. legendTemplate:
  7814. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7815. };
  7816. angular.extend($scope.options, $scope.opt);
  7817. $scope.datamonth = {
  7818. labels: ["一月", "二月", "三月", "四月", "五月", "六月"],
  7819. datasets: [
  7820. {
  7821. label: "新增事件数量",
  7822. fillColor: "rgba(220,220,220,0.5)",
  7823. strokeColor: "rgba(220,220,220,0.8)",
  7824. highlightFill: "rgba(220,220,220,0.75)",
  7825. highlightStroke: "rgba(220,220,220,1)",
  7826. data: [65, 59, 80, 81, 56, 55],
  7827. },
  7828. {
  7829. label: "已解决事件数量",
  7830. fillColor: "rgba(151,187,205,0.5)",
  7831. strokeColor: "rgba(151,187,205,0.8)",
  7832. highlightFill: "rgba(151,187,205,0.75)",
  7833. highlightStroke: "rgba(151,187,205,1)",
  7834. data: [28, 48, 40, 19, 86, 27],
  7835. },
  7836. ],
  7837. };
  7838. // Chart.js Options
  7839. $scope.taption = {
  7840. maintainAspectRatio: false,
  7841. // Sets the chart to be responsive
  7842. responsive: true,
  7843. //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
  7844. scaleBeginAtZero: true,
  7845. //Boolean - Whether grid lines are shown across the chart
  7846. scaleShowGridLines: true,
  7847. //String - Colour of the grid lines
  7848. scaleGridLineColor: "rgba(0,0,0,.05)",
  7849. //Number - Width of the grid lines
  7850. scaleGridLineWidth: 1,
  7851. //Boolean - If there is a stroke on each bar
  7852. barShowStroke: true,
  7853. //Number - Pixel width of the bar stroke
  7854. barStrokeWidth: 2,
  7855. //Number - Spacing between each of the X value sets
  7856. barValueSpacing: 5,
  7857. //Number - Spacing between data sets within X values
  7858. barDatasetSpacing: 1,
  7859. //String - A legend template
  7860. legendTemplate:
  7861. '<ul class="tc-chart-js-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
  7862. };
  7863. },
  7864. ],
  7865. });
  7866. //排版日历
  7867. formlyConfigProvider.setType({
  7868. name: "ui-dashcalendar",
  7869. templateUrl: "assets/views/customform/tpl/ui-dashcalendar.html",
  7870. defaultOptions: function (options) {
  7871. return {
  7872. templateOptions: {
  7873. // relationAction: function() {
  7874. // options.hideExpression = true
  7875. // }
  7876. },
  7877. };
  7878. },
  7879. controller: [
  7880. "$rootScope",
  7881. "$scope",
  7882. "$modal",
  7883. "$aside",
  7884. "calendarConfig",
  7885. "moment",
  7886. "SweetAlert",
  7887. "Restangular",
  7888. "api_bpm_schedule",
  7889. "api_user_data",
  7890. "$state",
  7891. function (
  7892. $rootScope,
  7893. $scope,
  7894. $modal,
  7895. $aside,
  7896. calendarConfig,
  7897. moment,
  7898. SweetAlert,
  7899. Restangular,
  7900. api_bpm_schedule,
  7901. api_user_data,
  7902. $state
  7903. ) {
  7904. var loginUser = $rootScope.user;
  7905. calendarConfig.dateFormatter = "moment";
  7906. calendarConfig.i18nStrings.eventsLabel = "排班描述";
  7907. calendarConfig.i18nStrings.timeLabel = "时间";
  7908. calendarConfig.i18nStrings.weekNumber = "{week}周";
  7909. calendarConfig.allDateFormats = {
  7910. angular: {
  7911. date: {
  7912. hour: "ha",
  7913. day: "d MMM",
  7914. month: "MMMM",
  7915. weekDay: "EEEE",
  7916. time: "HH:mm",
  7917. datetime: "MMM d, h:mm a",
  7918. },
  7919. title: {
  7920. day: "yyyy MMMM EEEE d",
  7921. week: "{year}年第{week}周",
  7922. month: "yyyy MMMM",
  7923. year: "yyyy",
  7924. },
  7925. },
  7926. moment: {
  7927. date: {
  7928. hour: "ha",
  7929. day: "MMMDD日",
  7930. month: "MMMM",
  7931. weekDay: "dddd",
  7932. time: "HH:mm",
  7933. datetime: "MMM D, h:mm a",
  7934. },
  7935. title: {
  7936. day: "YYYY年MMMMDD日, dddd ",
  7937. week: "{year}年第{week}周",
  7938. month: "YYYY年MMMM",
  7939. year: "YYYY",
  7940. },
  7941. },
  7942. };
  7943. moment.locale("zh_cn", {
  7944. months:
  7945. "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split(
  7946. "_"
  7947. ),
  7948. monthsShort:
  7949. "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),
  7950. weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split(
  7951. "_"
  7952. ),
  7953. weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"),
  7954. weekdaysMin: "日_一_二_三_四_五_六".split("_"),
  7955. longDateFormat: {
  7956. LT: "Ah点mm分",
  7957. LTS: "Ah点m分s秒",
  7958. L: "YYYY-MM-DD",
  7959. LL: "YYYY年MMMD日",
  7960. LLL: "YYYY年MMMD日Ah点mm分",
  7961. LLLL: "YYYY年MMMD日ddddAh点mm分",
  7962. l: "YYYY-MM-DD",
  7963. ll: "YYYY年MMMD日",
  7964. lll: "YYYY年MMMD日Ah点mm分",
  7965. llll: "YYYY年MMMD日ddddAh点mm分",
  7966. },
  7967. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  7968. meridiemHour: function (hour, meridiem) {
  7969. if (hour === 12) {
  7970. hour = 0;
  7971. }
  7972. if (
  7973. meridiem === "凌晨" ||
  7974. meridiem === "早上" ||
  7975. meridiem === "上午"
  7976. ) {
  7977. return hour;
  7978. } else if (meridiem === "下午" || meridiem === "晚上") {
  7979. return hour + 12;
  7980. } else {
  7981. // '中午'
  7982. return hour >= 11 ? hour : hour + 12;
  7983. }
  7984. },
  7985. meridiem: function (hour, minute, isLower) {
  7986. var hm = hour * 100 + minute;
  7987. if (hm < 600) {
  7988. return "凌晨";
  7989. } else if (hm < 900) {
  7990. return "早上";
  7991. } else if (hm < 1130) {
  7992. return "上午";
  7993. } else if (hm < 1230) {
  7994. return "中午";
  7995. } else if (hm < 1800) {
  7996. return "下午";
  7997. } else {
  7998. return "晚上";
  7999. }
  8000. },
  8001. calendar: {
  8002. sameDay: function () {
  8003. return this.minutes() === 0 ? "[今天]Ah[点整]" : "[今天]LT";
  8004. },
  8005. nextDay: function () {
  8006. return this.minutes() === 0 ? "[明天]Ah[点整]" : "[明天]LT";
  8007. },
  8008. lastDay: function () {
  8009. return this.minutes() === 0 ? "[昨天]Ah[点整]" : "[昨天]LT";
  8010. },
  8011. nextWeek: function () {
  8012. var startOfWeek, prefix;
  8013. startOfWeek = moment().startOf("week");
  8014. prefix =
  8015. this.unix() - startOfWeek.unix() >= 7 * 24 * 3600
  8016. ? "[下]"
  8017. : "[本]";
  8018. return this.minutes() === 0
  8019. ? prefix + "dddAh点整"
  8020. : prefix + "dddAh点mm";
  8021. },
  8022. lastWeek: function () {
  8023. var startOfWeek, prefix;
  8024. startOfWeek = moment().startOf("week");
  8025. prefix = this.unix() < startOfWeek.unix() ? "[上]" : "[本]";
  8026. return this.minutes() === 0
  8027. ? prefix + "dddAh点整"
  8028. : prefix + "dddAh点mm";
  8029. },
  8030. sameElse: "LL",
  8031. },
  8032. ordinalParse: /\d{1,2}(日|月|周)/,
  8033. ordinal: function (number, period) {
  8034. switch (period) {
  8035. case "d":
  8036. case "D":
  8037. case "DDD":
  8038. return number + "日";
  8039. case "M":
  8040. return number + "月";
  8041. case "w":
  8042. case "W":
  8043. return number + "周";
  8044. default:
  8045. return number;
  8046. }
  8047. },
  8048. relativeTime: {
  8049. future: "%s内",
  8050. past: "%s前",
  8051. s: "几秒",
  8052. m: "1 分钟",
  8053. mm: "%d 分钟",
  8054. h: "1 小时",
  8055. hh: "%d 小时",
  8056. d: "1 天",
  8057. dd: "%d 天",
  8058. M: "1 个月",
  8059. MM: "%d 个月",
  8060. y: "1 年",
  8061. yy: "%d 年",
  8062. },
  8063. week: {
  8064. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  8065. dow: 1, // Monday is the first day of the week.
  8066. doy: 4, // The week that contains Jan 4th is the first week of the year.
  8067. },
  8068. });
  8069. var date = new Date();
  8070. var d = date.getDate();
  8071. var m = date.getMonth();
  8072. var y = date.getFullYear();
  8073. var filterData = {
  8074. userId: loginUser.id,
  8075. startTime: moment(new Date(y, m, 1, 0, 0)).format(
  8076. "YYYY-MM-DD HH:mm:ss"
  8077. ),
  8078. endTime: moment(new Date(y, m + 1, 1, 0, 0)).format(
  8079. "YYYY-MM-DD HH:mm:ss"
  8080. ),
  8081. };
  8082. var load = ($scope.load = function (filterData) {
  8083. api_bpm_schedule
  8084. .fetchSchedule(
  8085. filterData.userId,
  8086. filterData.startTime,
  8087. filterData.endTime
  8088. )
  8089. .then(function (response) {
  8090. if (response.status == 200) {
  8091. $scope.events = [];
  8092. var myData = response.list;
  8093. angular.forEach(myData, function (item) {
  8094. var eventTemp = {};
  8095. eventTemp.title = item.description;
  8096. eventTemp.type = item.scheduleClass.code;
  8097. eventTemp.startsAt = moment(
  8098. item["scheduleOrderDTO"].startTime
  8099. ).toDate();
  8100. eventTemp.endsAtTime = moment(
  8101. item["scheduleOrderDTO"].endTime
  8102. ).toDate();
  8103. eventTemp.startTime = item["scheduleOrderDTO"].startTime;
  8104. eventTemp.endTime = item["scheduleOrderDTO"].endTime;
  8105. //eventTemp.ends_at = moment(item.endTime).toDate();
  8106. eventTemp.id = item.id;
  8107. eventTemp.deletable = false;
  8108. eventTemp.user = item.user;
  8109. $scope.events.push(eventTemp);
  8110. });
  8111. }
  8112. });
  8113. });
  8114. // var load = $scope.load = function(filterData){
  8115. // api_bpm_schedule.fetchSchedule(filterData.userId, filterData.startTime, filterData.endTime).then(function(response){
  8116. // console.log("response="+JSON.stringify(response));
  8117. // if(response.status==200){
  8118. // $scope.events = [];
  8119. // console.log(response.list);
  8120. // var myData = response.list;
  8121. // angular.forEach(myData,function(item){
  8122. // var eventTemp = {};
  8123. // eventTemp.title = item.description;
  8124. // eventTemp.type = item.scheduleClass.code;
  8125. // eventTemp.startsAt = moment(item.startTime).toDate();
  8126. // eventTemp.endsAtTime = moment(item.endTime).toDate();
  8127. // eventTemp.startTime = item.startTime;
  8128. // eventTemp.endTime = item.endTime;
  8129. // //eventTemp.ends_at = moment(item.endTime).toDate();
  8130. // eventTemp.id = item.id;
  8131. // eventTemp.deletable = false;
  8132. // eventTemp.users = item.users;
  8133. // $scope.events.push(eventTemp);
  8134. // // console.log("eventTemp="+JSON.stringify(eventTemp));
  8135. // })
  8136. // }
  8137. // });
  8138. // }
  8139. $scope.scheduleClass = {};
  8140. var convertEvent = function (scheduleorder) {
  8141. var eventTemp = {};
  8142. eventTemp.title = scheduleorder.description;
  8143. eventTemp.type = scheduleorder.scheduleClass.code;
  8144. eventTemp.startsAt = moment(scheduleorder.startTime).toDate();
  8145. //eventTemp.ends_at = moment(scheduleorder.endTime).toDate();
  8146. eventTemp.id = scheduleorder.id;
  8147. eventTemp.user = scheduleorder.user;
  8148. eventTemp.deletable = false;
  8149. return eventTemp;
  8150. };
  8151. // var convertEvent = function(scheduleorder){
  8152. // var eventTemp = {};
  8153. // eventTemp.title = scheduleorder.description;
  8154. // eventTemp.type = scheduleorder.scheduleClass.code;
  8155. // eventTemp.starts_at = moment(scheduleorder.scheduleClass.startTime).toDate();
  8156. // eventTemp.ends_at = moment(scheduleorder.scheduleClass.endTime).toDate();
  8157. // eventTemp.id = scheduleorder.id;
  8158. // eventTemp.users = scheduleorder.users;
  8159. // eventTemp.deletable = false;
  8160. // return eventTemp;
  8161. // }
  8162. api_bpm_schedule.getScheduleClass().then(function (response) {
  8163. if (response.status == 200) {
  8164. var scheduleClassList = response.list;
  8165. angular.forEach(scheduleClassList, function (item) {
  8166. item.startsAt = moment(item.startTime).format("HH:mm:ss");
  8167. item.endsAt = moment(item.endTime).format("HH:mm:ss");
  8168. // console.log("item.startsAt="+JSON.stringify(item.startsAt))
  8169. // console.log("item.endsAt="+JSON.stringify(item.endsAt))
  8170. $scope.scheduleClass[item["code"]] = item;
  8171. });
  8172. }
  8173. });
  8174. $scope.events = [];
  8175. $scope.calendarView = "month";
  8176. //$scope.calendarDay = new Date();
  8177. $scope.calendarDate = moment().startOf("month").toDate();
  8178. $scope.timeLabel = "时间";
  8179. $scope.eventLabel = "描述";
  8180. function showModal(action, event) {
  8181. // console.log("action="+JSON.stringify(action))
  8182. var modalInstance = $aside.open({
  8183. templateUrl: "scheduleEvent.html",
  8184. placement: "right",
  8185. size: "sm",
  8186. backdrop: true,
  8187. controller: function (
  8188. $scope,
  8189. $modalInstance,
  8190. scheduleClass,
  8191. APIService,
  8192. MementFormat
  8193. ) {
  8194. $scope.$modalInstance = $modalInstance;
  8195. $scope.action = action;
  8196. $scope.event = event;
  8197. $scope.scheduleClassic = scheduleClass;
  8198. $scope.$watch("event.type", function (newvalue, oldvalue) {
  8199. // if(oldvalue == newvalue) return;
  8200. // if(scheduleClass[newvalue]){
  8201. var sm = MementFormat(scheduleClass[newvalue].startTime);
  8202. var em = MementFormat(scheduleClass[newvalue].endTime);
  8203. console.log("sm=" + JSON.stringify(sm));
  8204. event.starts_at = MementFormat(event.startTime)
  8205. .startOf("day")
  8206. .add(sm.hour(), "hour")
  8207. .add(sm.minute(), "minute")
  8208. .add(sm.second(), "second")
  8209. .toDate();
  8210. console.log(
  8211. "event.starts_at=" + JSON.stringify(event.starts_at)
  8212. );
  8213. if (sm.hour() > em.hour()) {
  8214. event.ends_at = MementFormat(event.startTime)
  8215. .startOf("day")
  8216. .add(1, "day")
  8217. .add(em.hour(), "hour")
  8218. .add(em.minute(), "minute")
  8219. .add(em.second(), "second")
  8220. .toDate();
  8221. console.log(
  8222. "event.ends_at=" + JSON.stringify(event.starts_at)
  8223. );
  8224. } else {
  8225. event.ends_at = MementFormat(event.startTime)
  8226. .startOf("day")
  8227. .add(em.hour(), "hour")
  8228. .add(em.minute(), "minute")
  8229. .add(em.second(), "second")
  8230. .toDate();
  8231. console.log("event.ends_at=" + JSON.stringify(event.ends_at));
  8232. }
  8233. // }
  8234. });
  8235. // $scope.ok = function (event) {
  8236. // console.log("event="+JSON.stringify(event))
  8237. // event.action = action;
  8238. // $modalInstance.close(event);
  8239. // };
  8240. $scope.cancel = function (event) {
  8241. $modalInstance.dismiss();
  8242. };
  8243. var acUserSelect = ($scope.refreshUser = function (key) {
  8244. //for test
  8245. // $scope.users=[{"id":1,"phone":"13971293737","orgId":1,"name":"李静","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0}],"gender":"女","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005292","nickname":"lijing","group":[{"id":3,"groupName":"运行监控科"}]},{"id":2,"phone":"15807199490","orgId":1,"name":"李进","role":[{"id":1,"rolecode":"admin","role":"主行管理员","flag":0},{"id":7,"rolecode":"change manager","role":"变更流程经理","flag":1},{"id":8,"rolecode":"change coordinator","role":"协调员","flag":0},{"id":9,"rolecode":"configure manager","role":"配置管理员","flag":0},{"id":10,"rolecode":"release manager","role":"发布经理","flag":0}],"gender":"男","dept":{"id":3,"dept":"运行监控科"},"flag":0,"email":"","account":"005298","nickname":"lijin","group":[{"id":3,"groupName":"运行监控科"}]},{"id":3,"phone":"13507195958","orgId":1,"name":"杨代华","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005241","group":[{"id":9,"groupName":"管理层"}]},{"id":4,"phone":"18717107255","orgId":1,"name":"朱红艳","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"女","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005242","group":[{"id":9,"groupName":"管理层"}]},{"id":5,"phone":"13667282828","orgId":1,"name":"李喆","role":[{"id":2,"rolecode":"user","role":"主行员工","flag":1}],"gender":"男","dept":{"id":9,"dept":"管理层"},"flag":0,"email":"","account":"005243","group":[{"id":9,"groupName":"管理层"}]}];
  8246. // return;
  8247. var data = {
  8248. idx: "0",
  8249. sum: "5",
  8250. };
  8251. if (key) {
  8252. data["user"] = {
  8253. name: key,
  8254. };
  8255. }
  8256. APIService.fetchDataList("user", data).then(function (
  8257. response
  8258. ) {
  8259. if (response) {
  8260. if ((response.status = 200)) {
  8261. $scope.users = response.list;
  8262. console.log($scope.users);
  8263. }
  8264. }
  8265. });
  8266. });
  8267. if (angular.isDefined(event.users) && event.users.length > 0) {
  8268. }
  8269. $scope.users = [event.user];
  8270. acUserSelect();
  8271. },
  8272. resolve: {
  8273. scheduleClass: function () {
  8274. return $scope.scheduleClass;
  8275. },
  8276. APIService: function () {
  8277. return api_user_data;
  8278. },
  8279. MementFormat: function () {
  8280. return moment;
  8281. },
  8282. },
  8283. });
  8284. modalInstance.result.then(function (selectedEvent) {
  8285. if (selectedEvent.action == "Clicked") {
  8286. // var data = {
  8287. // "scheduleorder":{
  8288. // "id":selectedEvent.id,
  8289. // "description":selectedEvent.title,
  8290. // "startTime":moment(selectedEvent.starts_at).format('YYYY-MM-DD HH:mm:ss'),
  8291. // "endTime":moment(selectedEvent.ends_at).format('YYYY-MM-DD HH:mm:ss'),
  8292. // "users":selectedEvent.users,
  8293. // "scheduleClass":{"id":$scope.scheduleClass[selectedEvent.type].id}
  8294. // }
  8295. // };
  8296. // api_bpm_schedule.update(data).then(function(response){
  8297. // if(response.status==200){
  8298. // SweetAlert.swal({
  8299. // title: "操作成功!",
  8300. // text: "排班更新成功!",
  8301. // type: "succes"
  8302. // });
  8303. // angular.forEach($scope.events,function(item){
  8304. // if(item.id==selectedEvent.id){
  8305. // item = selectedEvent;
  8306. // }
  8307. // })
  8308. // }else{
  8309. // SweetAlert.swal({
  8310. // title: "操作失败",
  8311. // text: "排班更新失败,请稍后重试!",
  8312. // type: "error"
  8313. // })
  8314. // }
  8315. // })
  8316. } else {
  8317. //
  8318. }
  8319. });
  8320. }
  8321. $scope.moment = function (string) {
  8322. return moment(string);
  8323. };
  8324. $scope.eventClicked = function (event) {
  8325. // console.log("event="+JSON.stringify(event))
  8326. showModal("Clicked", event);
  8327. };
  8328. $scope.eventEdited = function (event) {
  8329. showModal("Edited", event);
  8330. };
  8331. var updateView = function (newvalue, oldvalue) {
  8332. if (oldvalue == newvalue) return;
  8333. var timeStart, timeEnd, timeStartSpan, timeEndSpan;
  8334. if ($scope.calendarView == "year") {
  8335. } else if ($scope.calendarView == "month") {
  8336. timeStart = moment(newvalue).startOf("month");
  8337. timeEnd = moment(newvalue).endOf("month");
  8338. } else if ($scope.calendarView == "week") {
  8339. timeStart = moment(newvalue).startOf("week");
  8340. timeEnd = moment(newvalue).endOf("week");
  8341. } else if ($scope.calendarView == "Day") {
  8342. timeStart = moment(newvalue).startOf("day");
  8343. timeEnd = moment(newvalue).endOf("day");
  8344. }
  8345. timeStartSpan = timeStart.format("YYYY-MM-DD HH:mm:ss");
  8346. timeEndSpan = timeEnd.format("YYYY-MM-DD HH:mm:ss");
  8347. filterData["startTime"] = timeStartSpan;
  8348. filterData["endTime"] = timeEndSpan;
  8349. load(filterData);
  8350. };
  8351. $scope.$watch("calendarDate", updateView);
  8352. $scope.next = function () {
  8353. $scope.calendarControl.next();
  8354. };
  8355. $scope.prev = function () {
  8356. $scope.calendarControl.prev();
  8357. };
  8358. $scope.setCalendarToToday = function () {
  8359. $scope.calendarDay = new Date();
  8360. };
  8361. $scope.toggle = function ($event, field, event) {
  8362. $event.preventDefault();
  8363. $event.stopPropagation();
  8364. event[field] = !event[field];
  8365. };
  8366. $scope.load(filterData);
  8367. $scope.more = function () {
  8368. $state.go("app.scheduling.myscheduling", {});
  8369. };
  8370. $scope.removes = function () {
  8371. var modalInstance = $modal.open({
  8372. templateUrl: "assets/views/delete.html",
  8373. controller: function ($scope, $modalInstance) {
  8374. $scope.ok = function () {
  8375. $modalInstance.close();
  8376. };
  8377. $scope.cancel = function () {
  8378. $modalInstance.dismiss("cancel");
  8379. };
  8380. },
  8381. size: "sm",
  8382. });
  8383. modalInstance.result.then(function () {
  8384. for (
  8385. var i = 0;
  8386. i <
  8387. $scope.$parent.$parent.$parent.$parent.resonseform.fields.length;
  8388. i++
  8389. ) {
  8390. if (
  8391. $scope.fields.type ==
  8392. $scope.$parent.$parent.$parent.$parent.resonseform.fields[i]
  8393. .type
  8394. ) {
  8395. // $scope.resonseform.fields.push($scope.responseData.fields[i]);
  8396. $scope.$parent.$parent.$parent.$parent.resonseform.fields.splice(
  8397. i,
  8398. 1
  8399. );
  8400. break;
  8401. }
  8402. }
  8403. var vmForm = $scope.$parent.$parent.$parent.$parent.resonseform;
  8404. if (vmForm) {
  8405. //console.log("vmForm>>>");//console.log(vmForm);
  8406. $scope.$parent.$parent.$parent.$parent.decodeVMForm(vmForm);
  8407. $scope.$parent.$parent.$parent.$parent.vm.fields = vmForm.fields;
  8408. }
  8409. });
  8410. };
  8411. },
  8412. ],
  8413. });
  8414. //空格组件
  8415. formlyConfigProvider.setType({
  8416. name: "ui-black",
  8417. /*extends: 'input',*/
  8418. template: '<div class="input-group col-xs-12" style="height:80px"></div>',
  8419. });
  8420. //请求人最近事件
  8421. formlyConfigProvider.setType({
  8422. name: "ui-recentIncident",
  8423. templateUrl: "assets/views/customform/tpl/ui-recentincident.html",
  8424. controller: [
  8425. "$scope",
  8426. "$modal",
  8427. "api_solution",
  8428. function ($scope, $modal, api_solution) {
  8429. var filterData = {
  8430. incident: {
  8431. requester: {
  8432. id: "",
  8433. },
  8434. },
  8435. idx: 0,
  8436. sum: 3,
  8437. };
  8438. setInterval(function () {
  8439. if (
  8440. filterData.incident.requester.id == "" ||
  8441. filterData.incident.requester.id != $scope.model.requester.id
  8442. ) {
  8443. var requester = $scope.model.requester;
  8444. if (requester != null && angular.isDefined(requester.id)) {
  8445. filterData.incident.requester.id = $scope.model.requester.id;
  8446. $scope.options.templateOptions
  8447. .getWorkernumber(
  8448. $scope.options.templateOptions.ApiService,
  8449. filterData
  8450. )
  8451. .then(function (result) {
  8452. var modelData =
  8453. $scope.options.templateOptions.Restangular.stripRestangular(
  8454. result
  8455. );
  8456. if (modelData.status == 200) {
  8457. $scope.lastrequst = modelData.list;
  8458. }
  8459. });
  8460. requester = null;
  8461. } else {
  8462. }
  8463. } else {
  8464. }
  8465. }, 1000);
  8466. $scope.detail = function (data) {
  8467. var modalInstance = $modal.open({
  8468. templateUrl: "assets/views/incident/tpl/detailincident.html",
  8469. controller: function ($scope, $modalInstance) {
  8470. $scope.entity = {};
  8471. $scope.entity = data;
  8472. $scope.cancel = function () {
  8473. $modalInstance.dismiss("cancel");
  8474. };
  8475. },
  8476. size: "lg",
  8477. });
  8478. };
  8479. },
  8480. ],
  8481. });
  8482. //参数列表
  8483. formlyConfigProvider.setType({
  8484. name: "ui-listinput",
  8485. templateUrl: "assets/views/customform/tpl/ui-listinput.html",
  8486. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  8487. defaultOptions: function (options) {
  8488. return {
  8489. templateOptions: {},
  8490. };
  8491. },
  8492. controller: ["$scope", function ($scope) { }],
  8493. });
  8494. //时间段控件(分)
  8495. formlyConfigProvider.setType({
  8496. name: "ui-timeslot",
  8497. extends: "input",
  8498. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8499. controller: ["$scope", function ($scope) { }],
  8500. });
  8501. //优先级级联-逾期时间
  8502. formlyConfigProvider.setType({
  8503. name: "ui-overtime",
  8504. extends: "input",
  8505. templateUrl: "assets/views/customform/tpl/ui-overtime.html",
  8506. controller: [
  8507. "$scope",
  8508. "api_bpm_domain",
  8509. function ($scope, api_bpm_domain) {
  8510. var filteData = {};
  8511. var datas = {};
  8512. setInterval(function () {
  8513. if (
  8514. $scope.model.priority &&
  8515. $scope.model.priority.id != null &&
  8516. filteData &&
  8517. datas != $scope.model.priority.id
  8518. ) {
  8519. filteData = "L" + $scope.model.priority.id;
  8520. datas = $scope.model.priority.id;
  8521. // console.log($scope.options.templateOptions)
  8522. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8523. // var overtime=requester.date;
  8524. if (requester.state == 200) {
  8525. // if($scope.options.key=="date"){
  8526. $scope.model[$scope.options.key] = requester.date;
  8527. // }
  8528. }
  8529. });
  8530. }
  8531. }, 1000);
  8532. },
  8533. ],
  8534. });
  8535. formlyConfigProvider.setType({
  8536. name: "ui-responsetime",
  8537. extends: "input",
  8538. templateUrl: "assets/views/customform/tpl/ui-responsetime.html",
  8539. controller: [
  8540. "$scope",
  8541. "api_bpm_domain",
  8542. function ($scope, api_bpm_domain) {
  8543. var filteData = {};
  8544. var datas = {};
  8545. setInterval(function () {
  8546. if (
  8547. $scope.model.priority &&
  8548. $scope.model.priority.id != null &&
  8549. filteData &&
  8550. datas != $scope.model.priority.id
  8551. ) {
  8552. filteData = "L" + $scope.model.priority.id;
  8553. datas = $scope.model.priority.id;
  8554. // console.log($scope.options.templateOptions)
  8555. api_bpm_domain.expectedTime(filteData).then(function (requester) {
  8556. // var overtime=requester.date;
  8557. if (requester.state == 200) {
  8558. var keyName = {};
  8559. // $scope.model.overdueTime = requester.date;
  8560. if ($scope.options.key == "expectIntroTime") {
  8561. keyName = "resolveTime";
  8562. } else if ($scope.options.key == "expectResponseTime") {
  8563. keyName = "responseTime";
  8564. }
  8565. $scope.model[$scope.options.key] =
  8566. requester.serviceLevelAgreement[keyName];
  8567. // }
  8568. console.log($scope.$parent.$parent.$parent.model);
  8569. }
  8570. if (requester.date1) {
  8571. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  8572. requester.date;
  8573. $scope.$parent.$parent.$parent.model.incident.overdueResponseDate =
  8574. requester.date1;
  8575. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  8576. requester.serviceLevelAgreement.resolveTime;
  8577. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  8578. requester.serviceLevelAgreement.responseTime;
  8579. }
  8580. });
  8581. }
  8582. }, 1000);
  8583. },
  8584. ],
  8585. });
  8586. //知识库按钮组件
  8587. formlyConfigProvider.setType({
  8588. name: "ui-discasecade",
  8589. extends: "input",
  8590. templateUrl: "assets/views/customform/tpl/ui-discasecade.html",
  8591. defaultOptions: function (options) {
  8592. return {
  8593. templateOptions: {
  8594. relationAction: function (fields, modelscope, item) { },
  8595. },
  8596. validators: {
  8597. required: {
  8598. expression: function (viewValue, modelValue) {
  8599. var value = modelValue || viewValue;
  8600. // return value = "true";
  8601. },
  8602. },
  8603. },
  8604. };
  8605. },
  8606. controller: [
  8607. "$scope",
  8608. "$rootScope",
  8609. "$modal",
  8610. "SweetAlert",
  8611. "api_bpm_data",
  8612. "api_solution",
  8613. "$aside",
  8614. "api_zsk",
  8615. "api_bpm_domain",
  8616. function (
  8617. $scope,
  8618. $rootScope,
  8619. $modal,
  8620. SweetAlert,
  8621. api_bpm_data,
  8622. api_solution,
  8623. $aside,
  8624. api_zsk,
  8625. api_bpm_domain
  8626. ) {
  8627. // $scope.options.initialValue = $scope.model[$scope.options.key];
  8628. $scope.searchField = $scope.options.model[$scope.options.key];
  8629. $scope.searchData = "";
  8630. $scope.onChangeadd = function (searchData) {
  8631. $scope.searchKey = searchData.account;
  8632. // $scope.searchDataadd = searchData;
  8633. var requesdata = angular.copy(searchData);
  8634. $scope.requester = requesdata;
  8635. };
  8636. $scope.refreshUseradd = function (searchKey) {
  8637. //主题搜索
  8638. $scope.searchData = searchKey;
  8639. reashdata($scope.searchData);
  8640. };
  8641. $scope.getMydata = function (x) {
  8642. $scope.model[$scope.options.key] = JSON.parse(x).title;
  8643. $scope.searchField = $scope.model[$scope.options.key];
  8644. };
  8645. $scope.getMydataone = function (x) {
  8646. $scope.model[$scope.options.key] = x;
  8647. $scope.searchField = $scope.model[$scope.options.key];
  8648. };
  8649. $scope.fildata = {
  8650. idx: 0,
  8651. sum: 10,
  8652. // 'incident': { 'tilte': item }
  8653. };
  8654. function reashdata(item) {
  8655. if (item && item != "") {
  8656. angular.extend($scope.fildata, {
  8657. incident: {
  8658. title: item,
  8659. },
  8660. });
  8661. } else {
  8662. delete $scope.fildata.incident;
  8663. }
  8664. api_bpm_data
  8665. .fetchDataList("incident", $scope.fildata)
  8666. .then(function (response) {
  8667. if (response) {
  8668. if ((response.status = 200)) {
  8669. var myData = response;
  8670. $scope.myData = myData.list;
  8671. }
  8672. }
  8673. });
  8674. }
  8675. function delHtmlTag(str) {
  8676. return str.replace(/<[^>]+>/g, "");
  8677. }
  8678. // reashdata();
  8679. var changedata = {};
  8680. setInterval(function () {
  8681. if (
  8682. $scope.model.category != null &&
  8683. $scope.model.category.id != changedata.id &&
  8684. $scope.model.titles != $scope.model.category
  8685. ) {
  8686. $scope.searchData = {};
  8687. changedata = angular.copy($scope.model.category);
  8688. if ($scope.options.key == "title") {
  8689. var filterData = {
  8690. idx: 0,
  8691. sum: 1000,
  8692. };
  8693. api_bpm_data
  8694. .fetchDataList("incidentcategory", filterData)
  8695. .then(function (data) {
  8696. var datalist = data.list;
  8697. angular.forEach(datalist, function (item) {
  8698. if (item.id == $scope.model.category.id) {
  8699. $scope.model[$scope.options.key] = item.category;
  8700. $scope.searchField =
  8701. $scope.options.model[$scope.options.key];
  8702. $scope.titles = item.category;
  8703. titles = $scope.model.category;
  8704. }
  8705. });
  8706. });
  8707. }
  8708. }
  8709. }, 1000);
  8710. $scope.open = function (key, options, fildata, $event, model) {
  8711. if (key && key.length > 1) {
  8712. api_zsk
  8713. .solutionData(
  8714. {
  8715. solution: {
  8716. searchWord: key,
  8717. },
  8718. idx: "0",
  8719. sum: "1000",
  8720. },
  8721. "solution"
  8722. )
  8723. .then(function (response) {
  8724. if (response && response.list.length > 0) {
  8725. $scope.dlideboxslide = true;
  8726. angular.forEach(response, function (item) {
  8727. console.log(response);
  8728. // api_solution.fetchDataList('solutionQuote', { "solutionQuote": { "solutionId": item.id }, "idx": "0", "sum": "1000" }).then(function (data) {
  8729. // if (response.status == 200) {
  8730. // var quote = { 'totalNum': response.totalNum }
  8731. // item = angular.extend(item, quote)
  8732. // }
  8733. // })
  8734. $scope.searchData = response.list;
  8735. console.log($scope.searchData);
  8736. });
  8737. $scope.changes = false;
  8738. // $('#navigation .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  8739. // $scope.closepages = function(e) {
  8740. // $('#navigation .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  8741. // event.preventDefault();
  8742. // };
  8743. $scope.shows = false;
  8744. $scope.tempData = {};
  8745. $scope.showpage = function (item) {
  8746. item.content = delHtmlTag(item.content);
  8747. $scope.shows = true;
  8748. $scope.tempData = item;
  8749. if (item.content != null) {
  8750. $scope.tempData.content = $scope.tempData.content
  8751. .replace("<p>", "")
  8752. .replace("</p>", "");
  8753. }
  8754. $scope.knowledgedata = item;
  8755. $scope.pageid = item.id;
  8756. $scope.changes = !$scope.changes;
  8757. api_bpm_domain
  8758. .listAttachments(item.id)
  8759. // api_solution.fetchDataList('file', {
  8760. // "file": {
  8761. // "solutionId": item.id
  8762. // },
  8763. // "idx": "0",
  8764. // "sum": "1000"
  8765. // })
  8766. .then(function (data) {
  8767. if (data) {
  8768. $scope.attachments = data.list;
  8769. $scope.view = function (attachmentId) {
  8770. for (
  8771. var i = 0;
  8772. i < $scope.attachments.length;
  8773. i++
  8774. ) {
  8775. if ($scope.attachments[i].id == attachmentId) {
  8776. window.open($scope.attachments[i].previewUrl);
  8777. }
  8778. }
  8779. };
  8780. $scope.download = function (contentId, filename) {
  8781. api_solution
  8782. .getSolutionDowpath(contentId)
  8783. .then(function (response) {
  8784. var file = new Blob([response], {
  8785. type: "application/octet-stream",
  8786. });
  8787. // var filename = filename;
  8788. var fileURL = URL.createObjectURL(file);
  8789. var a = document.createElement("a");
  8790. a.href = fileURL;
  8791. a.target = "_blank";
  8792. a.download = filename;
  8793. document.body.appendChild(a);
  8794. a.click();
  8795. });
  8796. };
  8797. }
  8798. });
  8799. };
  8800. $scope.related = function (item) {
  8801. if (item.content != null) {
  8802. item.content = item.content
  8803. .replace("<p>", "")
  8804. .replace("</p>", "");
  8805. }
  8806. // fildata.$parent.$parent.$parent.model.directClose = 0;
  8807. options.model.handleDescription = item.content;
  8808. var data = {
  8809. solutionQuote: {
  8810. solutionId: item.id,
  8811. incidentsign: options.model.incidentsign,
  8812. },
  8813. };
  8814. api_zsk.solutionQuote(item.id).then(function (response) {
  8815. if (response.status == 200) {
  8816. SweetAlert.swal("引用成功", "知识库已引用", "success");
  8817. fildata.$parent.$parent.$parent.$parent.model.start_code =
  8818. "close";
  8819. fildata.$parent.$parent.$parent.$parent.model.directClose = 0;
  8820. } else {
  8821. SweetAlert.swal("引用失败", "知识库未引用", "error");
  8822. }
  8823. });
  8824. };
  8825. $scope.close = function () {
  8826. $scope.changes = !$scope.changes;
  8827. event.preventDefault();
  8828. };
  8829. }
  8830. });
  8831. }
  8832. };
  8833. },
  8834. ],
  8835. });
  8836. //侧滑选择重复事件
  8837. formlyConfigProvider.setType({
  8838. name: "ui-repeatIncidentbtn",
  8839. templateUrl: "assets/views/customform/tpl/ui-repeatIncidentbtn.html",
  8840. defaultOptions: function (options) {
  8841. return {
  8842. templateOptions: {
  8843. relationAction: function (fields, modelscope, item) { },
  8844. },
  8845. validators: {
  8846. required: {
  8847. expression: function (viewValue, modelValue) {
  8848. // var value = modelValue || viewValue;
  8849. },
  8850. },
  8851. },
  8852. };
  8853. },
  8854. controller: [
  8855. "$scope",
  8856. "$rootScope",
  8857. "$modal",
  8858. "SweetAlert",
  8859. "api_bpm_data",
  8860. "api_solution",
  8861. "$aside",
  8862. "api_zsk",
  8863. "api_bpm_domain",
  8864. "api_webservice1",
  8865. function (
  8866. $scope,
  8867. $rootScope,
  8868. $modal,
  8869. SweetAlert,
  8870. api_bpm_data,
  8871. api_solution,
  8872. $aside,
  8873. api_zsk,
  8874. api_bpm_domain,
  8875. api_webservice1
  8876. ) {
  8877. console.log($scope);
  8878. $scope.selection = {
  8879. id: "",
  8880. };
  8881. //认证计费数据获取
  8882. $scope.sumInfo = {};
  8883. function getSumInfo() {
  8884. // $scope.isHk = $rootScope.isHk;
  8885. $scope.isHk = true;
  8886. if($rootScope.isHk){
  8887. //用户信息
  8888. api_webservice1.fetchDataList("queryUser", { "userId": $scope.model.incident.account }).then(function(response) {
  8889. // if (response.status == 200) {
  8890. if (response && response.data) {
  8891. angular.extend($scope.sumInfo, response.data[0]);
  8892. // $scope.sumInfo = response.data[0];
  8893. $scope.sumInfo.autologicDestroyTime = moment(response.data[0].autologicDestroyTime).format('YYYY-MM-DD');
  8894. $scope.sumInfo.periodStartTime = moment(response.data[0].periodStartTime).format('YYYY-MM-DD');
  8895. $scope.sumInfo.nextBillingTime = moment(response.data[0].nextBillingTime).format('YYYY-MM-DD');
  8896. } else if (response.err) {
  8897. SweetAlert.swal("系统错误!", "用户信息未取到,请刷新重试", "error");
  8898. }
  8899. // }
  8900. })
  8901. //上网明细
  8902. 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) {
  8903. // if (response.status == 200) {
  8904. if (response && response.data) {
  8905. angular.forEach(response.data, function(item, index) {
  8906. if (item.logoutTime) {
  8907. response.data[index].logoutTime = moment(item.logoutTime).format('YYYY-MM-DD HH:mm:ss');
  8908. }
  8909. if (item.loginTime) {
  8910. response.data[index].loginTime = moment(item.loginTime).format('YYYY-MM-DD HH:mm:ss');
  8911. }
  8912. })
  8913. $scope.logininform_sumInfo = response.data;
  8914. } else if (response.err) {
  8915. SweetAlert.swal("上网明细未取到", "该用户暂无上网明细", "error");
  8916. }
  8917. })
  8918. //黑名单
  8919. // $scope.sumInfo.blacklist = "否"
  8920. api_webservice1.fetchDataList("queryInhibit", { "userId": $scope.model.incident.account }).then(function(response) {
  8921. // if (response.status == 200) {
  8922. // $scope.loginsumInfo = response.data;
  8923. if (response) {
  8924. if (response.data || response.data != null) {
  8925. $scope.sumInfo.blacklist = "是"
  8926. } else {
  8927. if (response.err) {
  8928. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  8929. } else {
  8930. $scope.sumInfo.blacklist = "否"
  8931. }
  8932. }
  8933. }
  8934. // }
  8935. })
  8936. }else{
  8937. api_bpm_data
  8938. .sumInfo($scope.model.incident.account)
  8939. .then(function (data) {
  8940. console.log(data);
  8941. if (data) {
  8942. $scope.sumInfo = data.data || {};
  8943. }
  8944. });
  8945. }
  8946. }
  8947. getSumInfo();
  8948. // 收起重复事件侧滑框
  8949. function reashdata(item) {
  8950. var fildata = {
  8951. idx: 0,
  8952. incident: {
  8953. requester: {
  8954. id: $scope.model.incident.requester.id,
  8955. },
  8956. },
  8957. sum: 3,
  8958. };
  8959. api_bpm_data.fetchDataList("incident", fildata).then(function (data) {
  8960. console.log(data);
  8961. if (data) {
  8962. for (let i = 0; i < data.list.length; i++) {
  8963. var element = data.list[i];
  8964. if(element.handleDescription){
  8965. element.handleDescription = element.handleDescription.replace(/<[^>]+>/g, '');
  8966. }
  8967. }
  8968. $scope.repeatData = data.list;
  8969. }
  8970. });
  8971. }
  8972. reashdata();
  8973. // 确认选中的重复事件
  8974. $scope.repeatIncidentOk = function () {
  8975. if ($scope.selection.id) {
  8976. $scope.model.incident.repeat = $scope.selection;
  8977. $scope.model.isRepeat = true; //隐藏处理信息
  8978. console.log($scope.model);
  8979. }
  8980. angular.element("#repeatIncident").removeClass("active");
  8981. };
  8982. // 取消选中的重复事件
  8983. $scope.repeatIncidentCancle = function () {
  8984. angular.element("#repeatIncident").removeClass("active");
  8985. return;
  8986. };
  8987. },
  8988. ],
  8989. });
  8990. //侧滑选择知识库查询
  8991. formlyConfigProvider.setType({
  8992. name: "ui-knowledgebtn",
  8993. templateUrl: "assets/views/customform/tpl/ui-knowledgebtn.html",
  8994. defaultOptions: function (options) {
  8995. return {
  8996. templateOptions: {
  8997. relationAction: function (fields, modelscope, item) { },
  8998. },
  8999. validators: {
  9000. required: {
  9001. expression: function (viewValue, modelValue) {
  9002. // var value = modelValue || viewValue;
  9003. },
  9004. },
  9005. },
  9006. };
  9007. },
  9008. controller: [
  9009. "$scope",
  9010. "$rootScope",
  9011. "$modal",
  9012. "SweetAlert",
  9013. "api_bpm_data",
  9014. "api_solution",
  9015. "$aside",
  9016. "api_zsk",
  9017. "api_bpm_domain",
  9018. "api_wechatfile",
  9019. "up_down_file",
  9020. function (
  9021. $scope,
  9022. $rootScope,
  9023. $modal,
  9024. SweetAlert,
  9025. api_bpm_data,
  9026. api_solution,
  9027. $aside,
  9028. api_zsk,
  9029. api_bpm_domain,
  9030. api_wechatfile,
  9031. up_down_file
  9032. ) {
  9033. $scope.keypressModel = function (e, key) {
  9034. if (e.keyCode === 13) {
  9035. $scope.openModel(key);
  9036. }
  9037. };
  9038. // 引用知识库点击
  9039. $scope.searchKeyWord = "";
  9040. $scope.openModel = function (key) {
  9041. // alert(1)//重点
  9042. $scope.searchKeyWord = key;
  9043. if (key) {
  9044. api_zsk
  9045. .solutionData(
  9046. {
  9047. solution: {
  9048. threeSearch: key,
  9049. status: { id: 72 }, //已发布
  9050. selectType: "keySearch",
  9051. },
  9052. idx: "0",
  9053. sum: "1000",
  9054. },
  9055. "solution"
  9056. )
  9057. .then(function (response) {
  9058. $scope.searchData = response.list;
  9059. });
  9060. }
  9061. };
  9062. $scope.openModel($scope.model.incident.description);
  9063. // 展开/收起
  9064. $scope.showId = "";
  9065. $scope.ifshow = false;
  9066. $scope.showAll = function (id) {
  9067. $scope.attachments = [];
  9068. if ($scope.showId == id) {
  9069. $scope.ifshow = !$scope.ifshow;
  9070. } else {
  9071. $scope.ifshow = true;
  9072. }
  9073. $scope.showId = id;
  9074. // 获取附件
  9075. api_wechatfile
  9076. .listAttachments("knowledge", $scope.showId)
  9077. .then(function (data) {
  9078. $scope.attachments = data.data;
  9079. $scope.download = function (token, filename) {
  9080. var downUrl = up_down_file
  9081. .downloadAttachment("common/common/downloadAttachment", token)
  9082. .getRequestedUrl();
  9083. // window.open(downUrl);
  9084. var a = document.createElement("a");
  9085. a.href = downUrl;
  9086. a.target = "_blank";
  9087. a.download = filename;
  9088. document.body.appendChild(a);
  9089. a.click();
  9090. };
  9091. });
  9092. };
  9093. // 引用
  9094. $scope.related = function (item) {
  9095. console.log(item, "引用名");
  9096. if (item.content) {
  9097. item.content = item.content
  9098. .replace(/<p>/g, "")
  9099. .replace(/<\/p>/g, "")
  9100. .replace(/&nbsp;/g, "");
  9101. }
  9102. $scope.model.incident.handleDescription = item.content;
  9103. $scope.model.incident.title = $scope.model.incident.description =
  9104. item.title;
  9105. $scope.model.incident.category = item.category;
  9106. if (item.category) {
  9107. $scope.model.incident.priority.id = item.category.priority.id;
  9108. item.category.label = item.category.category;
  9109. }
  9110. var categoryId = item.category ? item.category.id : "";
  9111. // 引用知识库事件分类后,修改事件分类选中状态,事件分类列表重载
  9112. function getres(nodes) {
  9113. if (!nodes || nodes.length == 0) {
  9114. return;
  9115. }
  9116. nodes.forEach((e) => {
  9117. e.selected = false;
  9118. if (e.id == categoryId) {
  9119. e.selected = true;
  9120. return false;
  9121. }
  9122. getres(e.children);
  9123. });
  9124. }
  9125. var categorys = [];
  9126. $scope.fields.forEach((e, i) => {
  9127. if (e.key == "category") {
  9128. categorys = e.templateOptions.options;
  9129. if (categorys.length) {
  9130. getres(categorys);
  9131. $scope.fields[i].templateOptions.options = categorys;
  9132. $scope.$root.refreshSelectedItems();
  9133. }
  9134. return false;
  9135. }
  9136. });
  9137. // field.$parent.$parent.$parent.model.candidateGroups=item.category.group
  9138. $scope.model.candidateGroups = item.category
  9139. ? item.category.group
  9140. : {};
  9141. // 携带关联优先级,事件工单信息的时间
  9142. if (
  9143. $scope.model &&
  9144. $scope.model.incident &&
  9145. item.category &&
  9146. item.category.priority &&
  9147. item.category.priority.id
  9148. ) {
  9149. api_bpm_domain
  9150. .expectedTime("L" + (item.category.priority.id - 1559))
  9151. .then(function (res) {
  9152. $scope.model.incident.expectResponseTime =
  9153. $scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  9154. res.serviceLevelAgreement.responseTime;
  9155. $scope.model.incident.expectIntroTime =
  9156. $scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  9157. res.serviceLevelAgreement.resolveTime;
  9158. $scope.model.incident.overdueTime =
  9159. $scope.$parent.$parent.$parent.model.incident.overdueTime =
  9160. res.date;
  9161. });
  9162. }
  9163. api_zsk.solutionQuote(item.id).then(function (response) {
  9164. if (response.status == 200) {
  9165. $("#seachknowledge").removeClass("active");
  9166. SweetAlert.swal("引用成功", "知识库已引用", "success");
  9167. $scope.$parent.$parent.$parent.model.start_code = "close";
  9168. $scope.$parent.$parent.$parent.model.directClose = 0;
  9169. console.log($scope.model);
  9170. } else {
  9171. SweetAlert.swal("引用失败", "知识库未引用", "error");
  9172. }
  9173. });
  9174. };
  9175. },
  9176. ],
  9177. });
  9178. //下拉输入组件
  9179. formlyConfigProvider.setType({
  9180. name: "ui-selectinput",
  9181. extends: "input",
  9182. templateUrl: "assets/views/customform/tpl/selectinput.html",
  9183. defaultOptions: function (options) {
  9184. return {
  9185. templateOptions: {
  9186. refresh: function () { },
  9187. refreshDelay: 0,
  9188. linkage: function (modelName, data) { },
  9189. },
  9190. };
  9191. },
  9192. controller: [
  9193. "$scope",
  9194. "$rootScope",
  9195. "$modal",
  9196. "SweetAlert",
  9197. "api_bpm_data",
  9198. "api_solution",
  9199. "$aside",
  9200. function (
  9201. $scope,
  9202. $rootScope,
  9203. $modal,
  9204. SweetAlert,
  9205. api_bpm_data,
  9206. api_solution,
  9207. $aside
  9208. ) {
  9209. $scope.searchData = "";
  9210. $scope.onChangeadd = function (searchData) {
  9211. // $scope.searchKey = searchData.account;
  9212. // var requesdata = angular.copy(searchData)
  9213. // $scope.requester = requesdata;
  9214. };
  9215. $scope.refreshUseradd = function (searchKey) {
  9216. //主题搜索
  9217. // $scope.searchData = searchKey;
  9218. // reashdata($scope.searchData);
  9219. };
  9220. $scope.getMydata = function (x) {
  9221. $scope.model[$scope.options.key] =
  9222. JSON.parse(x)[$scope.options.templateOptions.labelProp];
  9223. $scope.searchField = $scope.model[$scope.options.key];
  9224. };
  9225. $scope.getMydataone = function (x) {
  9226. $scope.model[$scope.options.key] = x;
  9227. $scope.searchField = $scope.model[$scope.options.key];
  9228. if (
  9229. $scope.model[$scope.options.key] &&
  9230. $scope.model[$scope.options.key] != ""
  9231. ) {
  9232. $scope.hidden = false;
  9233. } else {
  9234. $scope.hidden = true;
  9235. }
  9236. };
  9237. function reashdata(item) {
  9238. $scope.myData = $scope.options.templateOptions.mydata;
  9239. }
  9240. reashdata();
  9241. if (angular.isFunction($scope.options.templateOptions.fetchItems)) {
  9242. $scope.options.templateOptions.fetchItems($scope);
  9243. }
  9244. },
  9245. ],
  9246. });
  9247. //重构组件模板
  9248. //获取当前人
  9249. formlyConfigProvider.setType({
  9250. name: "ui-users",
  9251. extends: "input",
  9252. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9253. defaultOptions: function (options) {
  9254. return {
  9255. templateOptions: {
  9256. translate: "",
  9257. refreshDelay: 0,
  9258. },
  9259. };
  9260. },
  9261. controller: [
  9262. "$scope",
  9263. function ($scope) {
  9264. // $scope.model[$scope.options.key]=$scope.$root.user.name;
  9265. $scope.options.templateOptions.translate = $scope.$root.user.name;
  9266. },
  9267. ],
  9268. });
  9269. //只读控件
  9270. formlyConfigProvider.setType({
  9271. name: "ui-label",
  9272. extends: "input",
  9273. templateUrl: "assets/views/customform/tpl/ui-label.html",
  9274. defaultOptions: function (options) {
  9275. return {
  9276. templateOptions: {
  9277. translate: "",
  9278. refreshDelay: 0,
  9279. },
  9280. };
  9281. },
  9282. controller: [
  9283. "$scope",
  9284. "$rootScope",
  9285. function ($scope, $rootScope) {
  9286. // console.log($scope.options.templateOptions)
  9287. // console.log($scope.options,'options1122');
  9288. $scope.isSolutionLabel = false;
  9289. $scope.solutionLabelStr = "";
  9290. // console.log($scope.options.templateOptions.solotinLabel);
  9291. if ($scope.options.templateOptions.solotinLabel) {
  9292. $scope.isSolutionLabel = true;
  9293. if ($scope.model[$scope.options.key]) {
  9294. var solutionArr = $scope.model[$scope.options.key].split("/");
  9295. $scope.solutionLabelStr = solutionArr.join(" ");
  9296. }
  9297. }
  9298. var value = $scope.model[$scope.options.key];
  9299. // ----------------
  9300. // ----------------
  9301. // console.log(value, 'pppp')
  9302. function treeDesc(children, key, label) {
  9303. if (label == "") {
  9304. label = children[key];
  9305. } else {
  9306. label = children[key] + "-" + label;
  9307. }
  9308. if (angular.isDefined(children.parent)) {
  9309. treeDesc(children.parent, key, label);
  9310. } else {
  9311. return label;
  9312. }
  9313. }
  9314. if (angular.isArray(value)) {
  9315. var tempValue = "";
  9316. angular.forEach(value, function (item) {
  9317. if (tempValue != "") {
  9318. tempValue = tempValue + ",";
  9319. }
  9320. tempValue =
  9321. tempValue + item[$scope.options.templateOptions.labelProp] ||
  9322. item;
  9323. });
  9324. $scope.options.templateOptions.translate = tempValue;
  9325. } else if (angular.isObject(value)) {
  9326. if (
  9327. angular.isDefined(value.children) ||
  9328. angular.isDefined(value.parent)
  9329. ) {
  9330. //tree
  9331. // console.log("value.parent="+JSON.stringify(value.parent))
  9332. var nameLabel = value[$scope.options.templateOptions.labelProp];
  9333. nameLabel = treeDesc(
  9334. value.parent,
  9335. $scope.options.templateOptions.labelProp,
  9336. nameLabel
  9337. );
  9338. $scope.options.templateOptions.translate = nameLabel;
  9339. } else {
  9340. $scope.options.templateOptions.translate = value;
  9341. }
  9342. } else if (
  9343. angular.isString(value) &&
  9344. value.indexOf("yyyy-MM-ddTHH:mm:sssZ") > 0
  9345. ) {
  9346. // console.log("value=" + value);
  9347. $scope.options.templateOptions.translate = value;
  9348. // }else if(angular.isString(value)&&value.indexOf('yyyy-MM-ddTHH:mm:sssZ')>0){
  9349. // console.log("value="+value);
  9350. // $scope.options.templateOptions.translate = value;
  9351. } else {
  9352. // var datasdf = JSON.parse(value);
  9353. // console.log("$scope.options.templateOptions.translate="+JSON.stringify($scope.options.templateOptions.translate))
  9354. $scope.options.templateOptions.translate = value;
  9355. }
  9356. if (angular.isFunction($scope.options.templateOptions.transform)) {
  9357. // console.log("$scope.options.templateOptions.transform22="+JSON.stringify($scope.options.templateOptions.transform))
  9358. $scope.options.templateOptions.translate =
  9359. $scope.options.templateOptions.transform(
  9360. $scope.originalModel,
  9361. value,
  9362. $rootScope,
  9363. $scope
  9364. );
  9365. }
  9366. // console.log($scope.options.templateOptions.translate,99999);
  9367. },
  9368. ],
  9369. });
  9370. //小标题组件
  9371. formlyConfigProvider.setType({
  9372. name: "ui-header",
  9373. template:
  9374. '<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>',
  9375. });
  9376. //标题组件
  9377. formlyConfigProvider.setType({
  9378. name: "ui-title",
  9379. template:
  9380. '<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>',
  9381. });
  9382. //标栏是否展示
  9383. formlyConfigProvider.setType({
  9384. name: "ui-orshow",
  9385. template:
  9386. '<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>',
  9387. controller: [
  9388. "$scope",
  9389. function ($scope) {
  9390. $scope.clickshow = function (key) {
  9391. // $scope.model[$scope.options.key] != key;
  9392. if (key == false) {
  9393. $scope.model[$scope.options.key] = true;
  9394. } else {
  9395. $scope.model[$scope.options.key] = false;
  9396. }
  9397. };
  9398. },
  9399. ],
  9400. });
  9401. //按钮组
  9402. formlyConfigProvider.setType({
  9403. name: "ui-button",
  9404. templateUrl: "assets/views/customform/tpl/ui-button.html",
  9405. defaultOptions: function (options) {
  9406. return {
  9407. noFormControl: true,
  9408. };
  9409. },
  9410. });
  9411. //3d组link
  9412. formlyConfigProvider.setType({
  9413. name: "ui-link",
  9414. templateUrl: "assets/views/customform/tpl/ui-link.html",
  9415. defaultOptions: function (options) {
  9416. return {
  9417. noFormControl: true,
  9418. };
  9419. },
  9420. });
  9421. //隐藏域组件
  9422. formlyConfigProvider.setType({
  9423. name: "ui-hidden",
  9424. extends: "input",
  9425. template:
  9426. '<input type="text" ng-model="model[options.key]" style="display: none;"/ >',
  9427. defaultOptions: function (options) {
  9428. return {
  9429. // noFormControl: true
  9430. };
  9431. },
  9432. });
  9433. //文本框组件
  9434. formlyConfigProvider.setType({
  9435. name: "ui-input",
  9436. extends: "input",
  9437. templateUrl: "assets/views/customform/tpl/ui-input.html",
  9438. defaultOptions: function (options) {
  9439. return {
  9440. templateOptions: {
  9441. transform: function (value) { },
  9442. },
  9443. };
  9444. },
  9445. controller: [
  9446. "$scope",
  9447. "$timeout",
  9448. function ($scope, $timeout) {
  9449. // console.log($scope.model[$scope.options.key]);
  9450. // console.log($scope.options)
  9451. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9452. $scope.model[$scope.options.key] =
  9453. $scope.options.templateOptions.linkData($scope.model);
  9454. }
  9455. },
  9456. ],
  9457. });
  9458. //搜索下拉框-故障地点seimin
  9459. formlyConfigProvider.setType({
  9460. name: "ui-select-search",
  9461. extends: "input",
  9462. templateUrl: "assets/views/customform/tpl/ui-select-search.html",
  9463. defaultOptions: function (options) {
  9464. return {
  9465. templateOptions: {
  9466. transform: function (value) { },
  9467. },
  9468. };
  9469. },
  9470. controller: [
  9471. "$scope",
  9472. "$rootScope",
  9473. "api_search_area",
  9474. function ($scope, $rootScope, api_search_area) {
  9475. // console.log($scope.options, $scope.model)
  9476. // ----------------分割线 start-----------------
  9477. // 故障地点下拉
  9478. $scope.address_arr = []; //故障地点所有数据
  9479. $scope.addressFlag = false; //默认下拉框列表隐藏
  9480. //点击文本框
  9481. $scope.AddressClickHandle = function () {
  9482. $scope.getDepartmentList();
  9483. angular.element("#bx_address_ul").scrollTop(0);
  9484. };
  9485. //修改文字,实时监听
  9486. $scope.ksChangeHandle = _.debounce(function () {
  9487. $scope.model[$scope.options.key] =
  9488. $scope.model[$scope.options.key] === undefined
  9489. ? ""
  9490. : $scope.model[$scope.options.key];
  9491. $scope.getDepartmentList();
  9492. angular.element("#bx_address_ul").scrollTop(0);
  9493. }, 500);
  9494. //获取故障地点seimin
  9495. $scope.getDepartmentList = function () {
  9496. $scope.model[$scope.options.key] =
  9497. $scope.model[$scope.options.key] === null
  9498. ? ""
  9499. : $scope.model[$scope.options.key];
  9500. api_search_area
  9501. .getAreaList({ searchKey: $scope.model[$scope.options.key] })
  9502. .then((res) => {
  9503. if (res.state == 200) {
  9504. $scope.address_arr = res.result;
  9505. $scope.addressFlag = true; //显示
  9506. }
  9507. })
  9508. .catch((err) => {
  9509. console.log(err);
  9510. });
  9511. };
  9512. // $scope.getDepartmentList();
  9513. // console.log($scope.model[$scope.options.key])
  9514. //下拉框列表选中
  9515. $scope.addressItemClick = function (obj) {
  9516. $scope.addressFlag = false; //隐藏
  9517. $scope.model[$scope.options.key] = obj.place
  9518. ? obj.area.area + obj.place
  9519. : obj.area;
  9520. //选择故障地点后带入区域地点2020年4月23日15:20:44
  9521. $scope.model.selecthouseNumber = obj;
  9522. console.log($scope, 77777);
  9523. $scope.$root.selecthouseNumber = obj;
  9524. };
  9525. //点击空白处隐藏
  9526. angular.element(document).on("click", function (e) {
  9527. if (e.target !== angular.element("#bx_address").get(0)) {
  9528. $scope.addressFlag = false; //隐藏
  9529. //模拟placeholder
  9530. // if ($('#bx_address').val() == '') {
  9531. // $('#bx_address').val('请选择报修科室');
  9532. // }
  9533. }
  9534. });
  9535. // -----------------分割线 end----------------
  9536. },
  9537. ],
  9538. });
  9539. //知识库关键字组件
  9540. formlyConfigProvider.setType({
  9541. name: "ui-knowledgeKeywords",
  9542. extends: "input",
  9543. templateUrl: "assets/views/customform/tpl/ui-knowledgeKeywords.html",
  9544. defaultOptions: function (options) {
  9545. return {
  9546. templateOptions: {
  9547. transform: function (value) { },
  9548. },
  9549. };
  9550. },
  9551. controller: [
  9552. "$scope",
  9553. "$timeout",
  9554. "SweetAlert",
  9555. function ($scope, $timeout, SweetAlert) {
  9556. $scope.valueLength = [
  9557. {
  9558. value: "",
  9559. },
  9560. ];
  9561. $scope.valueAll = [];
  9562. if ($scope.model[$scope.options.key]) {
  9563. var valueArr = $scope.model[$scope.options.key].split("/");
  9564. $scope.valueLength = [];
  9565. for (var i = 0; i < valueArr.length; i++) {
  9566. $scope.valueLength.push({
  9567. value: valueArr[i],
  9568. });
  9569. }
  9570. }
  9571. $scope.addIpt = function () {
  9572. if ($scope.valueLength.length < 5) {
  9573. $scope.valueLength.push({
  9574. value: "",
  9575. });
  9576. } else {
  9577. SweetAlert.swal({
  9578. title: "添加失败",
  9579. text: "关键字不能超过5个!",
  9580. type: "error",
  9581. confirmButtonColor: "#DD6B55",
  9582. });
  9583. }
  9584. };
  9585. $scope.closeIpt = function (data) {
  9586. $scope.valueLength.splice(data, 1);
  9587. };
  9588. $scope.toOption = function () {
  9589. $scope.valueAll = [];
  9590. for (var i = 0; i < $scope.valueLength.length; i++) {
  9591. if ($scope.valueLength[i].value != "") {
  9592. $scope.valueAll.push($scope.valueLength[i].value);
  9593. }
  9594. }
  9595. $scope.model.label = $scope.valueAll.join("/");
  9596. };
  9597. },
  9598. ],
  9599. });
  9600. //文本框组件
  9601. formlyConfigProvider.setType({
  9602. name: "ui-num",
  9603. extends: "input",
  9604. templateUrl: "assets/views/customform/tpl/ui-num.html",
  9605. defaultOptions: function (options) {
  9606. return {
  9607. templateOptions: {
  9608. transform: function (value) { },
  9609. },
  9610. };
  9611. },
  9612. controller: [
  9613. "$scope",
  9614. "$timeout",
  9615. function ($scope, $timeout) {
  9616. if (angular.isFunction($scope.options.templateOptions.linkData)) {
  9617. $scope.model[$scope.options.key] =
  9618. $scope.options.templateOptions.linkData($scope.model);
  9619. }
  9620. $scope.clearNoNum = function (obj, attr) {
  9621. //先把非数字的都替换掉,除了数字和.
  9622. obj[attr] = obj[attr].replace(/[^\d.]/g, "");
  9623. //必须保证第一个为数字而不是.
  9624. obj[attr] = obj[attr].replace(/^\./g, "");
  9625. //保证只有出现一个.而没有多个.
  9626. obj[attr] = obj[attr].replace(/\.{2,}/g, "");
  9627. //保证.只出现一次,而不能出现两次以上
  9628. obj[attr] = obj[attr]
  9629. .replace(".", "$#$")
  9630. .replace(/\./g, "")
  9631. .replace("$#$", ".");
  9632. //小于最大值
  9633. // if ($scope.maxsum && parseInt(obj[attr]) > $scope.maxsum) {
  9634. // alert('输入数据超过库存数量' + $scope.maxsum + ',请重新输入!');
  9635. // obj[attr] = '';
  9636. // }
  9637. };
  9638. },
  9639. ],
  9640. });
  9641. // //关联请求人文本框组件
  9642. // formlyConfigProvider.setType({
  9643. // name: 'ui-requestinput',
  9644. // extends: 'input',
  9645. // templateUrl: 'assets/views/customform/tpl/ui-input.html',
  9646. // defaultOptions: function(options) {
  9647. // return {
  9648. // templateOptions: {
  9649. // transform: function(value) {},
  9650. // linkData: function(options) {}
  9651. // }
  9652. // };
  9653. // }
  9654. // });
  9655. //只读文本
  9656. formlyConfigProvider.setType({
  9657. name: "ui-disableinput",
  9658. extends: "input",
  9659. templateUrl: "assets/views/customform/tpl/ui-disableinput.html",
  9660. defaultOptions: function (options) {
  9661. return {
  9662. templateOptions: {
  9663. transform: function (value) {
  9664. var ret = "";
  9665. if (value) {
  9666. ret = "已删除";
  9667. } else {
  9668. ret = "正常";
  9669. }
  9670. return ret;
  9671. },
  9672. },
  9673. };
  9674. },
  9675. });
  9676. formlyConfigProvider.setType({
  9677. name: "ui-disinput",
  9678. extends: "input",
  9679. templateUrl: "assets/views/customform/tpl/ui-disinput.html",
  9680. defaultOptions: function (options) {
  9681. return {
  9682. templateOptions: {},
  9683. };
  9684. },
  9685. });
  9686. //数字组件
  9687. formlyConfigProvider.setType({
  9688. name: "ui-number",
  9689. extends: "input",
  9690. templateUrl: "assets/views/customform/tpl/ui-number.html",
  9691. defaultOptions: function (options) {
  9692. return {
  9693. templateOptions: {},
  9694. };
  9695. },
  9696. controller: ["$scope", function ($scope) { }],
  9697. });
  9698. //含有周的日期
  9699. formlyConfigProvider.setType({
  9700. name: "ui-datepickerweek",
  9701. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  9702. extends: "input",
  9703. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  9704. defaultOptions: {
  9705. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  9706. templateOptions: {
  9707. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  9708. },
  9709. },
  9710. controller: [
  9711. "$scope",
  9712. "$filter",
  9713. function ($scope, $filter) {
  9714. $scope.mindata = new Date(
  9715. $scope.options.templateOptions.transform($scope.model).getTime() +
  9716. 5 * 60 * 1000
  9717. );
  9718. if ($scope.model[$scope.options.key]) {
  9719. } else {
  9720. $scope.model[$scope.options.key] = $filter("date")(
  9721. new Date(new Date().getTime()),
  9722. $scope.options.templateOptions.datepickerPopup
  9723. );
  9724. }
  9725. $scope.options.initialValue = $scope.model[$scope.options.key];
  9726. $scope.endOpen = true;
  9727. $scope.datepicker = {};
  9728. $scope.datepicker.opened = false;
  9729. $scope.datepicker.open = function ($event) {
  9730. $scope.datepicker.opened = true;
  9731. };
  9732. },
  9733. ],
  9734. });
  9735. //lmm
  9736. //分配任务列表
  9737. formlyConfigProvider.setType({
  9738. name: "jry_taskDistributionList",
  9739. templateUrl: "assets/views/customform/tpl/jry_taskDistributionList.html",
  9740. wrapper: ["bootstrapHasError"],
  9741. defaultOptions: function (options, $scope) {
  9742. return {
  9743. templateOptions: {},
  9744. };
  9745. },
  9746. controller: function (
  9747. $rootScope,
  9748. $scope,
  9749. api_user_data,
  9750. $modal,
  9751. api_doc_data,
  9752. i18nService,
  9753. SweetAlert,
  9754. api_wechatfile
  9755. ) {
  9756. // 获取状态
  9757. $scope.stateListData = {};
  9758. $scope.getStateData = function () {
  9759. //lyl
  9760. var data = {
  9761. key: "task_sub_state",
  9762. type: "list",
  9763. };
  9764. api_wechatfile.getDictionary(data).then(function (res) {
  9765. angular.forEach(res, function (v, i) {
  9766. $scope.stateListData[v.value] = v.id;
  9767. });
  9768. });
  9769. };
  9770. $scope.getStateData();
  9771. var loginUser = $rootScope.user;
  9772. $scope.langs = i18nService.getAllLangs();
  9773. $scope.lang = "zh-cn";
  9774. i18nService.setCurrentLang($scope.lang);
  9775. $scope.gridOptions = {};
  9776. $scope.gridOptions.data = "myData";
  9777. $scope.gridOptions.enableColumnResizing = true;
  9778. $scope.gridOptions.enableGridMenu = false;
  9779. $scope.gridOptions.enableRowSelection = true;
  9780. $scope.gridOptions.showGridFooter = true;
  9781. $scope.gridOptions.showColumnFooter = false;
  9782. $scope.gridOptions.fastWatch = true;
  9783. $scope.gridOptions.useExternalFiltering = true;
  9784. $scope.gridOptions.useExternalPagination = true;
  9785. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  9786. $scope.gridOptions.paginationPageSize = 10;
  9787. $scope.gridOptions.multiSelect = true;
  9788. $scope.gridOptions.rowIdentity = function (row) {
  9789. return row.id;
  9790. };
  9791. $scope.gridOptions.getRowIdentity = function (row) {
  9792. return row.id;
  9793. };
  9794. // console.log($scope.model);//lmmmm
  9795. $scope.gridOptions.columnDefs = [
  9796. {
  9797. name: "item",
  9798. displayName: "序号",
  9799. width: "10%",
  9800. cellTemplate:
  9801. "<div>" +
  9802. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  9803. "</div>",
  9804. },
  9805. {
  9806. name: "taskDescribe",
  9807. displayName: "任务说明",
  9808. width: "25%",
  9809. enableFiltering: false,
  9810. cellTemplate:
  9811. "<div>" +
  9812. '<div class="ui-grid-cell-contents">{{row.entity.taskDescribe}}</div>' +
  9813. "</div>",
  9814. },
  9815. {
  9816. name: "assign.name",
  9817. displayName: "指派人",
  9818. width: "5%",
  9819. enableFiltering: false,
  9820. cellTemplate:
  9821. "<div>" +
  9822. '<div class="ui-grid-cell-contents">{{row.entity.assign.name}}</div>' +
  9823. "</div>",
  9824. },
  9825. {
  9826. name: "startTime",
  9827. displayName: "开始时间",
  9828. width: "13%",
  9829. enableFiltering: false,
  9830. cellTemplate:
  9831. "<div>" +
  9832. '<div class="ui-grid-cell-contents">{{row.entity.startTime}}</div>' +
  9833. "</div>",
  9834. },
  9835. {
  9836. name: "endTime",
  9837. displayName: "结束时间",
  9838. width: "13%",
  9839. enableFiltering: false,
  9840. cellTemplate:
  9841. "<div>" +
  9842. '<div class="ui-grid-cell-contents">{{row.entity.endTime}}</div>' +
  9843. "</div>",
  9844. },
  9845. {
  9846. name: "priority.name",
  9847. displayName: "优先级",
  9848. width: "5%",
  9849. enableFiltering: false,
  9850. cellTemplate:
  9851. "<div>" +
  9852. '<div class="ui-grid-cell-contents">{{row.entity.priority.name}}</div>' +
  9853. "</div>",
  9854. },
  9855. {
  9856. name: "state.name",
  9857. displayName: "状态",
  9858. width: "5%",
  9859. enableFiltering: false,
  9860. cellTemplate:
  9861. "<div>" +
  9862. '<div class="ui-grid-cell-contents">{{row.entity.state.name}}</div>' +
  9863. "</div>",
  9864. },
  9865. {
  9866. name: "操作", //lmmm
  9867. cellTemplate:
  9868. '<div><div class="cl-effect-1 ui-grid-cell-contents caozuo">' +
  9869. '<a ng-click="grid.appScope.remove(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">删除</a>' +
  9870. '<a ng-click="grid.appScope.edit(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">编辑</a>' +
  9871. '<a ng-click="grid.appScope.release(row.entity)" ng-show="row.entity.state.id==grid.appScope.stateListData[1]&&grid.appScope.model.showOtherBtn">发布</a>' +
  9872. '<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>' +
  9873. "</div></div>",
  9874. enableFiltering: false,
  9875. },
  9876. ];
  9877. // 查看
  9878. $scope.see = function (data) {
  9879. $scope.seeData = data;
  9880. var modalInstance = $modal.open({
  9881. backdrop: false,
  9882. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9883. controller: function (
  9884. $scope,
  9885. scope,
  9886. $modalInstance,
  9887. api_doc_data,
  9888. SweetAlert,
  9889. api_user_data,
  9890. api_wechatfile
  9891. ) {
  9892. $scope.personData = {}; //指派人
  9893. $scope.priorityData = {}; //优先级
  9894. $scope.personListData = {}; //指派人下拉数据
  9895. $scope.priorityListData = {}; //优先级下拉数据
  9896. $scope.startTime = ""; //开始时间
  9897. $scope.releaseShow = "no";
  9898. $scope.subShow = "no";
  9899. $scope.onlySee = "ok";
  9900. $scope.endTime = ""; //结束时间
  9901. $scope.taskDescribe = ""; //任务描述
  9902. $scope.taskDescribe = scope.seeData.taskDescribe;
  9903. $scope.personData.data = scope.seeData.assign;
  9904. $scope.priorityData.data = scope.seeData.priority;
  9905. $scope.startTime = scope.seeData.startTime;
  9906. $scope.endTime = scope.seeData.endTime;
  9907. $scope.done = scope.seeData.done;
  9908. $scope.feedback = scope.seeData.feedback;
  9909. $scope.cancel = function () {
  9910. $modalInstance.dismiss("cancel");
  9911. };
  9912. },
  9913. size: "sm",
  9914. resolve: {
  9915. scope: function () {
  9916. return $scope;
  9917. },
  9918. },
  9919. backdrop: true,
  9920. });
  9921. };
  9922. // 编辑
  9923. $scope.edit = function (data) {
  9924. $scope.editData = data;
  9925. var modalInstance = $modal.open({
  9926. backdrop: false,
  9927. templateUrl: "assets/views/customform/tpl/newTaskDistribution.html",
  9928. controller: function (
  9929. $scope,
  9930. scope,
  9931. $modalInstance,
  9932. api_doc_data,
  9933. SweetAlert,
  9934. api_user_data,
  9935. api_wechatfile
  9936. ) {
  9937. console.log(scope.editData);
  9938. $scope.personData = {}; //指派人
  9939. $scope.priorityData = {}; //优先级
  9940. $scope.personListData = {}; //指派人下拉数据
  9941. $scope.priorityListData = {}; //优先级下拉数据
  9942. $scope.startTime = ""; //开始时间
  9943. $scope.releaseShow = "no";
  9944. $scope.endTime = ""; //结束时间
  9945. $scope.taskDescribe = ""; //任务描述
  9946. $scope.taskDescribe = scope.editData.taskDescribe;
  9947. $scope.personData.data = scope.editData.assign;
  9948. $scope.priorityData.data = scope.editData.priority;
  9949. $scope.startTime = scope.editData.startTime;
  9950. $scope.endTime = scope.editData.endTime;
  9951. // 指派人下拉框数据
  9952. $scope.getPersonData = function () {
  9953. var data = {
  9954. idx: 0,
  9955. sum: 1000,
  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. };
  10261. api_user_data.fetchDataList("user", data).then(function (res) {
  10262. $scope.personListData = res.list;
  10263. });
  10264. };
  10265. $scope.getPersonData();
  10266. //优先级下拉数据
  10267. $scope.getPriorityData = function () {
  10268. var data = {
  10269. key: "change_rick_level",
  10270. type: "list",
  10271. };
  10272. api_wechatfile.getDictionary(data).then(function (res) {
  10273. $scope.priorityListData = res;
  10274. });
  10275. };
  10276. // 控制结束时间的最大时间
  10277. $scope.jryEndMaxTime = scope.model.taskMonth.endTime;
  10278. // 控制结束时间的最小时间
  10279. $scope.jryEndMinTime = scope.model.taskMonth.startTime;
  10280. $scope.$watch("startTime", function (n, o) {
  10281. if (n) {
  10282. if (n > scope.model.taskMonth.startTime) {
  10283. $scope.jryEndMinTime = n;
  10284. }
  10285. }
  10286. });
  10287. // 控制开始时间的最小时间
  10288. $scope.jryStartMinTime = scope.model.taskMonth.startTime;
  10289. // 控制开始时间的最大时间
  10290. $scope.jryStartMaxTime = scope.model.taskMonth.endTime;
  10291. $scope.$watch("endTime", function (n, o) {
  10292. if (n) {
  10293. if (n < scope.model.taskMonth.endTime) {
  10294. $scope.jryStartMaxTime = n;
  10295. }
  10296. }
  10297. });
  10298. $scope.getPriorityData();
  10299. //时间控件
  10300. $scope.open = function ($event) {
  10301. $event.preventDefault();
  10302. $event.stopPropagation();
  10303. $scope.opened = !$scope.opened;
  10304. };
  10305. $scope.endOpen = function ($event) {
  10306. $event.preventDefault();
  10307. $event.stopPropagation();
  10308. $scope.startOpened = false;
  10309. $scope.endOpened = !$scope.endOpened;
  10310. };
  10311. $scope.startOpen = function ($event) {
  10312. $event.preventDefault();
  10313. $event.stopPropagation();
  10314. $scope.endOpened = false;
  10315. $scope.startOpened = !$scope.startOpened;
  10316. };
  10317. $scope.datepickerPopup = "yyyy-MM-dd HH:mm:ss";
  10318. // 获取状态-lmm
  10319. $scope.stateListData = {};
  10320. $scope.getStateData = function () {
  10321. //lyl
  10322. var data = {
  10323. key: "task_sub_state",
  10324. type: "list",
  10325. };
  10326. api_wechatfile.getDictionary(data).then(function (res) {
  10327. angular.forEach(res, function (v, i) {
  10328. $scope.stateListData[v.value] = v.id;
  10329. });
  10330. });
  10331. };
  10332. $scope.getStateData();
  10333. // 草稿保存
  10334. $scope.ok = function (item) {
  10335. if (
  10336. $scope.taskDescribe &&
  10337. $scope.personData.data &&
  10338. $scope.priorityData.data &&
  10339. $scope.startTime &&
  10340. $scope.endTime
  10341. ) {
  10342. $scope.startTime = moment(
  10343. new Date($scope.startTime).getTime()
  10344. ).format("YYYY-MM-DD HH:mm:ss");
  10345. $scope.endTime = moment(
  10346. new Date($scope.endTime).getTime()
  10347. ).format("YYYY-MM-DD HH:mm:ss");
  10348. $scope.addData = {
  10349. taskSub: {
  10350. taskDescribe: $scope.taskDescribe,
  10351. assign: $scope.personData.data,
  10352. priority: $scope.priorityData.data,
  10353. startTime: $scope.startTime,
  10354. endTime: $scope.endTime,
  10355. taskMonth: {
  10356. id: scope.model.taskMonth.id,
  10357. },
  10358. },
  10359. };
  10360. $scope.addData.taskSub["state"] = {
  10361. id: $scope.stateListData[1],
  10362. };
  10363. api_user_data
  10364. .addData("taskSub", $scope.addData)
  10365. .then(function (res) {
  10366. if (res.status == 200) {
  10367. SweetAlert.swal({
  10368. title: "保存成功!",
  10369. type: "success",
  10370. confirmButtonColor: "#007AFF",
  10371. });
  10372. scope.refreshData(scope.jry_filterdata);
  10373. $modalInstance.dismiss("cancel");
  10374. } else {
  10375. SweetAlert.swal({
  10376. title: "保存失败",
  10377. text: "系统错误,请重试!",
  10378. type: "error",
  10379. });
  10380. $modalInstance.dismiss("cancel");
  10381. }
  10382. });
  10383. } else {
  10384. SweetAlert.swal({
  10385. title: "保存失败",
  10386. text: "必填项不能为空!",
  10387. type: "error",
  10388. });
  10389. }
  10390. };
  10391. // 发布
  10392. $scope.release = function () {
  10393. if (
  10394. $scope.taskDescribe &&
  10395. $scope.personData.data &&
  10396. $scope.priorityData.data &&
  10397. $scope.startTime &&
  10398. $scope.endTime
  10399. ) {
  10400. $scope.startTime = moment(
  10401. new Date($scope.startTime).getTime()
  10402. ).format("YYYY-MM-DD HH:mm:ss");
  10403. $scope.endTime = moment(
  10404. new Date($scope.endTime).getTime()
  10405. ).format("YYYY-MM-DD HH:mm:ss");
  10406. $scope.addData = {
  10407. taskSub: {
  10408. taskDescribe: $scope.taskDescribe,
  10409. assign: $scope.personData.data,
  10410. priority: $scope.priorityData.data,
  10411. startTime: $scope.startTime,
  10412. endTime: $scope.endTime,
  10413. taskMonth: {
  10414. id: scope.model.taskMonth.id,
  10415. },
  10416. },
  10417. };
  10418. $scope.addData.taskSub["state"] = {
  10419. id: $scope.stateListData[1],
  10420. };
  10421. api_user_data
  10422. .addData("taskSub", $scope.addData)
  10423. .then(function (res) {
  10424. if (res.status == 200) {
  10425. SweetAlert.swal({
  10426. title: "保存成功!",
  10427. type: "success",
  10428. confirmButtonColor: "#007AFF",
  10429. });
  10430. scope.refreshData(scope.jry_filterdata);
  10431. $modalInstance.dismiss("cancel");
  10432. } else {
  10433. SweetAlert.swal({
  10434. title: "保存失败",
  10435. text: "系统错误,请重试!",
  10436. type: "error",
  10437. });
  10438. $modalInstance.dismiss("cancel");
  10439. }
  10440. });
  10441. } else {
  10442. SweetAlert.swal({
  10443. title: "保存失败",
  10444. text: "必填项不能为空!",
  10445. type: "error",
  10446. });
  10447. }
  10448. };
  10449. $scope.cancel = function () {
  10450. $modalInstance.dismiss("cancel");
  10451. };
  10452. },
  10453. size: "sm",
  10454. resolve: {
  10455. scope: function () {
  10456. return $scope;
  10457. },
  10458. },
  10459. backdrop: true,
  10460. });
  10461. };
  10462. },
  10463. });
  10464. // 多次反馈文本域组件--jry
  10465. formlyConfigProvider.setType({
  10466. name: "ui-feedbacktTextarea",
  10467. extends: "textarea",
  10468. templateUrl: "assets/views/customform/tpl/ui-feedbacktTextarea.html",
  10469. defaultOptions: function (options) {
  10470. return {
  10471. templateOptions: {
  10472. transform: function (model, value) {
  10473. return value;
  10474. },
  10475. },
  10476. validation: {
  10477. messages: {
  10478. maxlength: function (viewValue, modelValue, scope) {
  10479. if (viewValue != null) {
  10480. if (viewValue.length > scope.to.maxlength) {
  10481. return (
  10482. scope.to.label +
  10483. " 字数(" +
  10484. viewValue.length +
  10485. ")超限(" +
  10486. scope.to.maxlength +
  10487. ")"
  10488. );
  10489. } else {
  10490. return "";
  10491. }
  10492. }
  10493. },
  10494. },
  10495. },
  10496. };
  10497. },
  10498. controller: [
  10499. "$scope",
  10500. "moment",
  10501. function ($scope, moment) {
  10502. // console.log($scope);
  10503. var timeKey = $scope.options.templateOptions.time;
  10504. $scope.time = moment($scope.model[timeKey]).format(
  10505. "YYYY-MM-DD HH:mm:ss"
  10506. );
  10507. var value = $scope.model[$scope.options.key];
  10508. if (angular.isFunction($scope.options.templateOptions.transform)) {
  10509. $scope.model[$scope.options.key] =
  10510. $scope.options.templateOptions.transform(
  10511. $scope.originalModel,
  10512. value
  10513. );
  10514. }
  10515. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  10516. $scope.options.templateOptions.felditem($scope);
  10517. }
  10518. },
  10519. ],
  10520. });
  10521. //任务管理开始时间--jry
  10522. formlyConfigProvider.setType({
  10523. name: "ui-jryStartdatepicker",
  10524. templateUrl: "assets/views/customform/tpl/ui-jryStartdatepicker.html",
  10525. extends: "input",
  10526. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10527. defaultOptions: {
  10528. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10529. templateOptions: {
  10530. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10531. },
  10532. },
  10533. controller: [
  10534. "$scope",
  10535. "$filter",
  10536. function ($scope, $filter) {
  10537. // console.log($scope.model[$scope.options.key],'lmm');
  10538. $scope.mindata = new Date(
  10539. $scope.options.templateOptions.transform($scope.model).getTime() +
  10540. 5 * 60 * 1000
  10541. );
  10542. if ($scope.model[$scope.options.key]) {
  10543. $scope.model[$scope.options.key] = $filter("date")(
  10544. $scope.model[$scope.options.key],
  10545. $scope.options.templateOptions.datepickerPopup
  10546. );
  10547. }
  10548. // console.log($scope.model[$scope.options.key],'lmm');
  10549. // console.log($scope.model,'lmm',$scope.options.key);
  10550. $scope.options.initialValue = $scope.model[$scope.options.key];
  10551. $scope.endOpen = true;
  10552. $scope.datepicker = {};
  10553. $scope.datepicker.opened = false;
  10554. $scope.datepicker.open = function ($event) {
  10555. $scope.datepicker.opened = true;
  10556. };
  10557. },
  10558. ],
  10559. });
  10560. //任务管理结束时间--jry
  10561. formlyConfigProvider.setType({
  10562. name: "ui-jryEnddatepicker",
  10563. templateUrl: "assets/views/customform/tpl/ui-jryEnddatepicker.html",
  10564. extends: "input",
  10565. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  10566. defaultOptions: {
  10567. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  10568. templateOptions: {
  10569. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  10570. },
  10571. },
  10572. controller: [
  10573. "$scope",
  10574. "$filter",
  10575. function ($scope, $filter) {
  10576. $scope.mindata = new Date(
  10577. $scope.options.templateOptions.transform($scope.model).getTime() +
  10578. 5 * 60 * 1000
  10579. );
  10580. if ($scope.model[$scope.options.key]) {
  10581. $scope.model[$scope.options.key] = $filter("date")(
  10582. $scope.model[$scope.options.key],
  10583. $scope.options.templateOptions.datepickerPopup
  10584. );
  10585. }
  10586. $scope.options.initialValue = $scope.model[$scope.options.key];
  10587. $scope.endOpen = true;
  10588. $scope.datepicker = {};
  10589. $scope.datepicker.opened = false;
  10590. $scope.datepicker.open = function ($event) {
  10591. $scope.datepicker.opened = true;
  10592. };
  10593. },
  10594. ],
  10595. });
  10596. //下拉多选框灵活组件--jry
  10597. formlyConfigProvider.setType({
  10598. name: "ui-jry_multiselectplus",
  10599. extends: "multiCheckbox",
  10600. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  10601. defaultOptions: function (options) {
  10602. return {
  10603. templateOptions: {
  10604. refreshData: function (search, options, model, that) {
  10605. // var process = options.templateOptions.ApiService.all("");
  10606. if (search) {
  10607. } else {
  10608. }
  10609. var postData = options.templateOptions.optionsPostData;
  10610. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  10611. postData = options.templateOptions.optionsPostData(
  10612. options,
  10613. model,
  10614. that
  10615. );
  10616. }
  10617. options.templateOptions.ApiService.fetchDataList(
  10618. options.templateOptions.optionsUrl,
  10619. options.templateOptions.optionsPostData
  10620. ).then(function (result) {
  10621. // if (!options.templateOptions.options) {
  10622. // options.templateOptions.options = [];
  10623. // }
  10624. if (options.templateOptions.optionsDataKey) {
  10625. options.templateOptions.options =
  10626. result[options.templateOptions.optionsDataKey];
  10627. } else {
  10628. options.templateOptions.options = result;
  10629. }
  10630. if (options.templateOptions.optionsChecked) {
  10631. // return options.value = null;
  10632. options.value(options.model[options.key]);
  10633. }
  10634. });
  10635. },
  10636. refreshDelay: 0,
  10637. // },
  10638. validators: {
  10639. required: {
  10640. expression: function (viewValue, modelValue) {
  10641. var value = modelValue || viewValue;
  10642. return value != null;
  10643. // return value.length>=1;
  10644. // if (modelValue && viewValue) {
  10645. // return value != null;
  10646. // } else {
  10647. // var value = modelValue || viewValue;
  10648. // return value.length > 0;
  10649. // }
  10650. },
  10651. },
  10652. },
  10653. },
  10654. };
  10655. },
  10656. controller: [
  10657. "$scope",
  10658. function ($scope) {
  10659. console.log($scope.to);
  10660. if (angular.isArray($scope.model[$scope.options.key])) {
  10661. } else {
  10662. $scope.model[$scope.options.key] = [];
  10663. }
  10664. },
  10665. ],
  10666. });
  10667. //下拉框组件
  10668. formlyConfigProvider.setType({
  10669. name: "ui-select",
  10670. extends: "select",
  10671. templateUrl: "assets/views/customform/tpl/ui-select.html",
  10672. defaultOptions: function (options, scope) {
  10673. return {
  10674. templateOptions: {
  10675. // refresh: function() {},
  10676. getScope: function () {
  10677. return scope;
  10678. },
  10679. refreshDelay: 0,
  10680. linkage: function (modelName, data, model, modelKey, key, timekey) {
  10681. //POST
  10682. console.log(model, "model");
  10683. angular.extend(data, {
  10684. idx: 0,
  10685. sum: 1000,
  10686. });
  10687. options.templateOptions.APIService.fetchDataList(
  10688. modelName,
  10689. data
  10690. ).then(function (response) {
  10691. var myData =
  10692. options.templateOptions.Restangular.stripRestangular(response);
  10693. var list = myData.list;
  10694. console.log(myData);
  10695. // api_bpm_domain.expectedTime("L" + item).then(function(res){
  10696. // console.log('balabalabala');
  10697. // console.log(res);
  10698. // })
  10699. if (list.length == 1) {
  10700. if (options.templateOptions.APIport) {
  10701. options.templateOptions.APIport.expectedTime(
  10702. "L" + list[0][key].id
  10703. ).then(function (response) {
  10704. if (response.state == "200") {
  10705. // if (model.$parent.model && model.$parent.model.incident) {
  10706. // } else {
  10707. // model.$parent.model = { 'incident': {} };
  10708. // }
  10709. var myDatas = response.serviceLevelAgreement;
  10710. //逾期
  10711. scope.$parent.$parent.$parent.model.incident.overdueTime =
  10712. response.date;
  10713. //解决
  10714. scope.$parent.$parent.$parent.model.incident.expectIntroTime =
  10715. myDatas.resolveTime;
  10716. //响应
  10717. scope.$parent.$parent.$parent.model.incident.expectResponseTime =
  10718. myDatas.responseTime;
  10719. } else {
  10720. }
  10721. });
  10722. }
  10723. angular.forEach(model.fields, function (item) {
  10724. angular.forEach(model.fields, function (item) {
  10725. if (item.templateOptions.pkey == modelKey + "." + key) {
  10726. item.model.id = "";
  10727. if (key == "place") {
  10728. item.templateOptions.options = list;
  10729. } else if (key == "placeDTO") {
  10730. item.templateOptions.options = list;
  10731. } else if (key == "requester") {
  10732. } else if (key == "area") {
  10733. item.templateOptions.options = list;
  10734. } else {
  10735. item.value(list[0][key][item.key]);
  10736. }
  10737. }
  10738. });
  10739. });
  10740. } else {
  10741. if (model.fields) {
  10742. angular.forEach(model.fields, function (item) {
  10743. angular.forEach(model.fields, function (item) {
  10744. if (item.templateOptions.pkey == modelKey + "." + key) {
  10745. item.model.id = "";
  10746. if (key == "place") {
  10747. item.templateOptions.isnosearch = true;
  10748. item.templateOptions.options = list;
  10749. }
  10750. if (key == "placeDTO") {
  10751. item.templateOptions.options = list;
  10752. }
  10753. if (key == "requester") {
  10754. }
  10755. if (key == "room") {
  10756. item.templateOptions.options = list;
  10757. }
  10758. if (key == "area") {
  10759. item.templateOptions.options = list;
  10760. }
  10761. }
  10762. });
  10763. });
  10764. } else {
  10765. angular.forEach(
  10766. scope.$parent.$parent.$parent.fields,
  10767. function (item) {
  10768. angular.forEach(
  10769. scope.$parent.$parent.$parent.fields,
  10770. function (item) {
  10771. if (
  10772. item.templateOptions.pkey ==
  10773. modelKey + "." + key
  10774. ) {
  10775. if (key == "place") {
  10776. item.templateOptions.isnosearch = true;
  10777. item.templateOptions.options = list;
  10778. scope.$parent.$parent.$parent.model.incident.place =
  10779. model.incident.place;
  10780. }
  10781. if (key == "placeDTO") {
  10782. item.templateOptions.options = list;
  10783. }
  10784. if (key == "requester") {
  10785. }
  10786. }
  10787. }
  10788. );
  10789. }
  10790. );
  10791. }
  10792. }
  10793. console.log(key);
  10794. //报修科室
  10795. if (key == "dept") {
  10796. // 报修科室单选
  10797. scope.$parent.$parent.$parent.model.incident.department =
  10798. response.list[0];
  10799. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10800. response.list[0].phone;
  10801. // scope.$parent.$parent.$parent.model.incident.houseNumber = response.list[0].place.area.area + response.list[0].place.place;
  10802. // 选择重复事件侧滑框
  10803. scope.$parent.$parent.$parent.model[
  10804. "repeatIncidentShow"
  10805. ] = false;
  10806. setTimeout(() => {
  10807. scope.$parent.$parent.$parent.model[
  10808. "repeatIncidentShow"
  10809. ] = true;
  10810. }, 500);
  10811. }
  10812. // 报修人
  10813. if (key == "requester") {
  10814. // 报修人单选
  10815. scope.$parent.$parent.$parent.model.incident.requester =
  10816. response.list[0];
  10817. console.log(scope.$parent.$parent.$parent.model);
  10818. scope.$parent.$parent.$parent.model.incident.account =
  10819. response.list[0].account;
  10820. var selectedItem = response.list[0];
  10821. var data = {
  10822. requester: selectedItem,
  10823. };
  10824. scope.$parent.$parent.$parent.model["requestershow"] =
  10825. selectedItem;
  10826. console.log(selectedItem, "----------------------");
  10827. // if (selectedItem.dept.place.place) {
  10828. // scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.dept.place.area.area + selectedItem.dept.place.place
  10829. // }
  10830. scope.$parent.$parent.$parent.model.incident.houseNumber =
  10831. selectedItem.houseNumber ? selectedItem.houseNumber : "";
  10832. scope.$parent.$parent.$parent.model.incident.branch.id =
  10833. selectedItem.branch ? selectedItem.branch.id : null;
  10834. scope.$parent.$parent.$parent.model.incident.area.id =
  10835. selectedItem.place ? selectedItem.place.area.id : null;
  10836. scope.$parent.$parent.$parent.model.incident.place.id =
  10837. selectedItem.place ? selectedItem.place.id : null;
  10838. if(scope.$parent.$parent.$parent.model.incident.branch.id){
  10839. options.templateOptions.APIService.fetchDataList(
  10840. 'area',
  10841. {"area":{"branch":scope.$parent.$parent.$parent.model.incident.branch.id},"idx":0,"sum":1000}
  10842. ).then(function (response1) {
  10843. for (var i = 0; i < scope.fields.length; i++) {
  10844. if(scope.fields[i].templateOptions.onlyKey == 'area_start'){
  10845. scope.fields[i].templateOptions.options = response1.status == 200?response1.list:[];
  10846. }
  10847. }
  10848. })
  10849. }else{
  10850. for (var i = 0; i < scope.fields.length; i++) {
  10851. if(scope.fields[i].templateOptions.onlyKey == 'area_start'){
  10852. scope.fields[i].templateOptions.options = [];
  10853. }
  10854. }
  10855. }
  10856. if(scope.$parent.$parent.$parent.model.incident.area.id){
  10857. options.templateOptions.APIService.fetchDataList(
  10858. 'place',
  10859. {"place":{"areaId":scope.$parent.$parent.$parent.model.incident.area.id},"idx":0,"sum":1000}
  10860. ).then(function (response1) {
  10861. for (var i = 0; i < scope.fields.length; i++) {
  10862. if(scope.fields[i].templateOptions.onlyKey == 'place_start'){
  10863. scope.fields[i].templateOptions.options = response1.status == 200?response1.list:[];
  10864. }
  10865. }
  10866. })
  10867. }else{
  10868. for (var i = 0; i < scope.fields.length; i++) {
  10869. if(scope.fields[i].templateOptions.onlyKey == 'place_start'){
  10870. scope.fields[i].templateOptions.options = [];
  10871. }
  10872. }
  10873. }
  10874. console.log(scope, 89898998);
  10875. // console.log(scope.formData,'接单页面');
  10876. //1,选择报修人后带入区域地点2020年4月23日19:34:17
  10877. scope.model.selecthouseNumber = selectedItem.place
  10878. ? selectedItem.place
  10879. : {};
  10880. scope.$root.selecthouseNumber = selectedItem.place
  10881. ? selectedItem.place
  10882. : {};
  10883. // options.templateOptions.ApiService.addData(
  10884. // "requester",
  10885. // data
  10886. // ).then(function (response) {
  10887. // if (response.status == 200) {
  10888. if (scope.$parent.$parent.$parent) {
  10889. if (scope.$parent.$parent.$parent.place) {
  10890. scope.$parent.$parent.$parent.place.id = "";
  10891. }
  10892. if (scope.$parent.$parent.$parent.area) {
  10893. scope.$parent.$parent.$parent.area.id = "";
  10894. }
  10895. scope.$parent.$parent.$parent.model.incident.contacts =
  10896. selectedItem.name;
  10897. if (
  10898. selectedItem.mphone &&
  10899. selectedItem.mphone != null &&
  10900. selectedItem.mphone != ""
  10901. ) {
  10902. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10903. selectedItem.mphone;
  10904. } else {
  10905. scope.$parent.$parent.$parent.model.incident.contactsInformation =
  10906. selectedItem.telephone;
  10907. }
  10908. if (
  10909. selectedItem.requesterTypeDTO &&
  10910. selectedItem.requesterTypeDTO.id == 2
  10911. ) {
  10912. scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  10913. }
  10914. }
  10915. // if (!response.data.id) {
  10916. // response.data.id = selectedItem.id;
  10917. // }
  10918. console.log(scope);
  10919. // if (scope.$parent.$parent.$parent.model.saveAgain) {
  10920. // if (selectedItem.place && selectedItem.place.id) {
  10921. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10922. // scope.$parent.$parent.$parent.model.incident.place.area.id = selectedItem.place.area.id
  10923. // };
  10924. // } else {
  10925. // if (selectedItem.place && selectedItem.place.id) {
  10926. // scope.$parent.$parent.$parent.model.incident.place.id = selectedItem.place.id
  10927. // scope.$parent.$parent.$parent.model.incident.area.id = selectedItem.place.area.id
  10928. // };
  10929. // }
  10930. // if(scope.$parent.$parent.$parent.model.incident.area){
  10931. // scope.$parent.$parent.$parent.model.incident.area.id = 1;//teshu
  10932. // }
  10933. if (selectedItem.id) {
  10934. scope.$parent.$parent.$parent.model.incident.account =
  10935. selectedItem.account;
  10936. }
  10937. // 选择重复事件侧滑框
  10938. // if (scope.$parent.$parent.$parent.model.incident.category && scope.$parent.$parent.$parent.model.incident.category.id) {
  10939. scope.$parent.$parent.$parent.model[
  10940. "repeatIncidentShow"
  10941. ] = false;
  10942. setTimeout(() => {
  10943. scope.$parent.$parent.$parent.model[
  10944. "repeatIncidentShow"
  10945. ] = true;
  10946. }, 500);
  10947. // }
  10948. // }
  10949. // });
  10950. }
  10951. //新建事件,选择派单,选择工作组查找处理人baba
  10952. if (key == "handlerUser") {
  10953. model.fields.forEach(function (v) {
  10954. if (v.templateOptions.pkey == "incident.handlerUser") {
  10955. v.templateOptions.options = list;
  10956. if (model.model.incident.handlerUser) {
  10957. if (model.model.incident.handlerUser.id) {
  10958. var flag = list.some(function (v) {
  10959. return v.id == model.model.incident.handlerUser.id;
  10960. });
  10961. if (flag) {
  10962. v.model.id = model.model.incident.handlerUser.id;
  10963. }
  10964. }
  10965. }
  10966. }
  10967. });
  10968. }
  10969. });
  10970. },
  10971. validators: {
  10972. required: {
  10973. expression: function (viewValue, modelValue) {
  10974. var value = modelValue || viewValue;
  10975. return value != null;
  10976. // return value.length>=1;
  10977. // if (modelValue && viewValue) {
  10978. // return value != null;
  10979. // } else {
  10980. // var value = modelValue || viewValue;
  10981. // return value.length > 0;
  10982. // }
  10983. },
  10984. },
  10985. },
  10986. },
  10987. controller: [
  10988. "$scope",
  10989. "$rootScope",
  10990. "api_bpm_domain",
  10991. "$stateParams",
  10992. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  10993. // $scope.myFilter = function(item) {
  10994. // return !$scope.search || $select.selected[to.labelProp || 'name'] == $scope.search;
  10995. // }
  10996. console.log($scope, "风浪");
  10997. if($scope.to.onlyKey === 'inspection.dictionary'){
  10998. //巡检列表-新增-巡检类型baba
  10999. console.log(location)
  11000. var loc = location.href.split('api_bpm_data')[1] || '';
  11001. if(loc.length <= 2){
  11002. // 新增轮询计划的时候
  11003. $scope.model.id = 1715;//默认系统默认
  11004. }
  11005. }
  11006. //工作组添加全部选项
  11007. // if($scope.options.templateOptions.label == '工作组'){
  11008. // $scope.options.templateOptions.options.unshift({id:0,groupName:'全部'});
  11009. // $scope.model._group = 0;
  11010. // }
  11011. if (
  11012. $scope.options.templateOptions.pkey &&
  11013. $scope.options.templateOptions.pkey == "incident.place"
  11014. ) {
  11015. if (
  11016. $scope.$parent &&
  11017. $scope.$parent.$parent.$parent.model &&
  11018. $scope.$parent.$parent.$parent.model.incident.area &&
  11019. $scope.$parent.$parent.$parent.model.incident.area.id
  11020. ) {
  11021. $scope.options.templateOptions.linkage(
  11022. "place",
  11023. {
  11024. place: {
  11025. areaId:
  11026. $scope.$parent.$parent.$parent.model.incident.area.id,
  11027. // area:{
  11028. // id:$scope.$parent.$parent.$parent.model.incident.area.id
  11029. // }
  11030. },
  11031. },
  11032. $scope.$parent.$parent.$parent.model,
  11033. "incident",
  11034. "place"
  11035. );
  11036. }
  11037. }
  11038. $scope.myFilter = $scope;
  11039. // console.log($scope.options.templateOptions)
  11040. console.log($scope, 77777);
  11041. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  11042. var paramsModel = JSON.parse($stateParams.model)
  11043. if ($scope.options.templateOptions.onlyKey == "c_account" && paramsModel.model.incident.requester.account) {
  11044. $scope.$parent.$parent.$parent.model.repeatIncidentShow = true;
  11045. $scope.$parent.$parent.$parent.model.incident.account = paramsModel.model.incident.requester.account;
  11046. }
  11047. }
  11048. //处理人根据事件分类自动带入baba
  11049. if ($scope.options.templateOptions.onlyKey == "c_handlerUser") {
  11050. console.log($scope.options.templateOptions.pkey);
  11051. if ($scope.$parent.$parent.$parent.model.incident.handlerUser) {
  11052. if (
  11053. $scope.$parent.$parent.$parent.model.incident.handlerUser.id
  11054. ) {
  11055. $scope.$parent.$parent.$parent.model.assignee =
  11056. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11057. $scope.options.model.id =
  11058. $scope.$parent.$parent.$parent.model.incident.handlerUser.id;
  11059. }else{
  11060. $scope.$parent.$parent.$parent.model.assignee = null;
  11061. $scope.options.model.id = null;
  11062. }
  11063. }else{
  11064. $scope.$parent.$parent.$parent.model.assignee = null;
  11065. $scope.options.model.id = null;
  11066. }
  11067. }
  11068. // 关闭事件页面满意度评价下拉框处理
  11069. if ($scope.options.templateOptions.onlyKey == "close_degree") {
  11070. $scope.model.id =
  11071. $scope.$parent.$parent.$parent.$parent.$parent.$parent.formData.model.incident.wxdegree.id;
  11072. }
  11073. if ($scope.options.templateOptions.initData == 1) {
  11074. $scope.options.templateOptions.onChange(
  11075. $scope.model.id,
  11076. $scope.options,
  11077. $scope
  11078. );
  11079. }
  11080. if ($scope.options.templateOptions.transform) {
  11081. $scope.options.templateOptions.onChange(
  11082. $scope.model.id,
  11083. $scope.options,
  11084. $scope
  11085. );
  11086. }
  11087. if (angular.isFunction($scope.options.templateOptions.translate)) {
  11088. $scope.model[$scope.options.key] =
  11089. $scope.options.templateOptions.translate(
  11090. $scope.options,
  11091. $rootScope,
  11092. $scope
  11093. );
  11094. }
  11095. if (
  11096. angular.isFunction($scope.options.templateOptions.translatefunc)
  11097. ) {
  11098. $scope.model[$scope.options.key] =
  11099. $scope.options.templateOptions.translatefunc(
  11100. $scope.options,
  11101. $rootScope,
  11102. $scope
  11103. );
  11104. }
  11105. if (
  11106. angular.isFunction($scope.options.templateOptions.onlyfunction)
  11107. ) {
  11108. $scope.options.templateOptions.onlyfunction(
  11109. $scope.options,
  11110. $rootScope,
  11111. $scope
  11112. );
  11113. }
  11114. },
  11115. ],
  11116. };
  11117. },
  11118. });
  11119. //下拉框组件(巡检计划-查看)
  11120. formlyConfigProvider.setType({
  11121. name: "ui-select-xj",
  11122. extends: "select",
  11123. templateUrl: "assets/views/customform/tpl/ui-select-xj.html",
  11124. defaultOptions: function (options, scope) {
  11125. return {
  11126. templateOptions: {
  11127. getScope: function () {
  11128. return scope;
  11129. },
  11130. refreshDelay: 0,
  11131. validators: {
  11132. required: {
  11133. expression: function (viewValue, modelValue) {
  11134. var value = modelValue || viewValue;
  11135. return value != null;
  11136. },
  11137. },
  11138. },
  11139. },
  11140. controller: [
  11141. "$scope",
  11142. "$rootScope",
  11143. "api_bpm_domain",
  11144. "$stateParams",
  11145. function ($scope, $rootScope, api_bpm_domain, $stateParams) {
  11146. $scope.model[$scope.options.key] = '0';//默认全部
  11147. var arr = [];
  11148. if($scope.model.inspection.batchNos){
  11149. arr = $scope.model.inspection.batchNos.map(v=>({value:v,name:v}));
  11150. }
  11151. arr.unshift({value:'0',name:'全部'});
  11152. $scope.options.templateOptions.options = arr;
  11153. console.log($scope)
  11154. // ts.$parent.fields.forEach(v=>{
  11155. // if(v.templateOptions.onlyKey === "batchNos"){
  11156. // //巡检计划-批次号
  11157. // var batchNos = $scope.model.batchNos === "0"?"":$scope.model.batchNos;
  11158. // v.templateOptions.getScope().refreshData(batchNos)
  11159. // }
  11160. // })
  11161. // ts.$parent.fields.forEach(v=>{if(v.templateOptions.onlyKey === "batchNos"){var batchNos = item == "0"?"":item;v.templateOptions.getScope().refreshData(batchNos);}})
  11162. // console.log($scope.options)
  11163. // console.log($scope.model)
  11164. },
  11165. ],
  11166. };
  11167. },
  11168. });
  11169. //下拉多选框组件
  11170. formlyConfigProvider.setType({
  11171. name: "ui-multiselect",
  11172. extends: "select",
  11173. templateUrl: "assets/views/customform/tpl/ui-multiselect.html",
  11174. defaultOptions: function (options) {
  11175. return {
  11176. templateOptions: {
  11177. refresh: function () { },
  11178. refreshDelay: 1000,
  11179. },
  11180. };
  11181. },
  11182. controller: [
  11183. "$scope",
  11184. function ($scope) {
  11185. $scope.model[$scope.options.key] = [];
  11186. },
  11187. ],
  11188. });
  11189. //下拉多选全选组件
  11190. formlyConfigProvider.setType({
  11191. name: "ui-isteven",
  11192. extends: "select",
  11193. templateUrl: "assets/views/customform/tpl/ui-isteven.html",
  11194. defaultOptions: function (options,$scope) {
  11195. return {
  11196. templateOptions: {
  11197. refresh: function () {
  11198. console.log(options)
  11199. options.templateOptions
  11200. .refreshData(options.templateOptions.APIService)
  11201. .then(function (result) {
  11202. if(result.status == 200){
  11203. console.log(result.list)
  11204. //树形结构转换
  11205. function formatDataTree2(json){
  11206. var _json = JSON.parse(JSON.stringify(json));
  11207. return _json.filter(p=>{
  11208. var _arr = _json.filter(c=>(c.parent?c.parent.id === p.id:false));
  11209. _arr.length && (p.children = _arr);
  11210. return !p.parent;
  11211. })
  11212. }
  11213. console.log(result.list)
  11214. var list = formatDataTree2(result.list);
  11215. console.log(list)
  11216. // $scope.treeList = angular.copy(list);
  11217. var resultList = [];
  11218. //转换数据
  11219. function trasData(list,obj){
  11220. if(obj){
  11221. //有父级
  11222. list.forEach(v=>{
  11223. var type = "<strong>"+ v.parent.type +"</strong>";//父级type
  11224. var i = resultList.findIndex(c=>c.type == type);
  11225. if(v.children){
  11226. resultList.splice(i+1,0,{
  11227. type: "<strong>"+ v.type +"</strong>",
  11228. msId: v.id,
  11229. msGroup: true,
  11230. },{msGroup: false})
  11231. trasData(v.children,v);
  11232. }else{
  11233. resultList.splice(i+1,0,{...v,...{ticked:false}});
  11234. }
  11235. })
  11236. }else{
  11237. //顶级
  11238. list.forEach(v=>{
  11239. if(v.children){
  11240. resultList.push({
  11241. type: "<strong>"+ v.type +"</strong>",
  11242. msId: v.id,
  11243. msGroup: true,
  11244. },{msGroup: false})
  11245. trasData(v.children,v);
  11246. }else{
  11247. resultList.push(...v,...{ticked:false});
  11248. }
  11249. })
  11250. }
  11251. return resultList;
  11252. }
  11253. var __arr = trasData(list,null);
  11254. // console.log(__arr,options.model.typeIds.split(','))
  11255. if(options.model.typeIds){
  11256. //有巡检类型,则需要回显
  11257. __arr.forEach(w=>{
  11258. w.ticked = options.model.typeIds.split(',').includes(w.id+'');
  11259. })
  11260. }
  11261. $scope.webBrowsersGrouped = __arr;
  11262. console.log($scope.webBrowsersGrouped);
  11263. }
  11264. })
  11265. },
  11266. refreshDelay: 1000,
  11267. },
  11268. };
  11269. },
  11270. controller: [
  11271. "$scope",
  11272. function ($scope) {
  11273. console.log($scope)
  11274. $scope.to.refresh();//获取列表数据
  11275. // $scope.model[$scope.options.key] = [];
  11276. //单项点击或菜单
  11277. $scope.fClick = function(data){
  11278. console.log($scope.outputBrowsers)
  11279. $scope.$parent.$parent.$parent.model.inspection.typeIds = $scope.outputBrowsers.map(v=>v.id).join();
  11280. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11281. // if(data.id){
  11282. // //单项点击
  11283. // if($scope.$parent.$parent.$parent.model.inspection.typeIds){
  11284. // //有巡检类型
  11285. // var arr = $scope.$parent.$parent.$parent.model.inspection.typeIds.split(',');
  11286. // if(data.ticked){
  11287. // arr.push(data.id);
  11288. // }else{
  11289. // arr = arr.filter(v=>v != data.id);
  11290. // }
  11291. // $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11292. // }else{
  11293. // //无巡检类型
  11294. // $scope.$parent.$parent.$parent.model.inspection.typeIds = 1;
  11295. // if(data.ticked){
  11296. // $scope.$parent.$parent.$parent.model.inspection.typeIds = data.id + '';
  11297. // }else{
  11298. // $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11299. // }
  11300. // }
  11301. // }else{
  11302. // // 菜单点击
  11303. // console.log($scope.webBrowsersGrouped,data.msId);
  11304. // var treeResultArr = $scope.webBrowsersGrouped.filter(v=>{
  11305. // return v.parent?v.parent.id == data.msId:false;
  11306. // })
  11307. // if(treeResultArr.every(v=>v.ticked)){
  11308. // //全部都是true的情况下,需要移除,否则增加
  11309. // }
  11310. // console.log(treeResultArr)
  11311. // // --------------------------------------
  11312. // // var treeArr = [];
  11313. // // function findParent(treeList){
  11314. // // treeList.forEach(v=>{
  11315. // // if(v.id == data.msId){
  11316. // // treeArr = v.children;
  11317. // // }else{
  11318. // // if(v.children){
  11319. // // findParent(v.children);
  11320. // // }
  11321. // // }
  11322. // // })
  11323. // // return treeArr;
  11324. // // }
  11325. // // var treeResultArr = findParent($scope.treeList);
  11326. // // console.log(treeResultArr)
  11327. // // -----------------------------------
  11328. // }
  11329. }
  11330. // 全选
  11331. $scope.fSelectAll = function(){
  11332. // console.log($scope.webBrowsersGrouped)
  11333. var arr = $scope.webBrowsersGrouped.filter(v=>v.id).map(v=>v.id);
  11334. // console.log(arr);
  11335. $scope.$parent.$parent.$parent.model.inspection.typeIds = arr.join();
  11336. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11337. }
  11338. // 全不选
  11339. $scope.fSelectNone = function(){
  11340. $scope.$parent.$parent.$parent.model.inspection.typeIds = '';
  11341. console.log($scope.$parent.$parent.$parent.model.inspection.typeIds)
  11342. }
  11343. // 配置信息
  11344. $scope.outputBrowsers = [];
  11345. $scope.localLang = {
  11346. selectAll: "全选",
  11347. selectNone: "全不选",
  11348. nothingSelected: "请选择"
  11349. }
  11350. },
  11351. ],
  11352. });
  11353. //下拉多选框灵活组件
  11354. formlyConfigProvider.setType({
  11355. name: "ui-multiselectplus",
  11356. extends: "multiCheckbox",
  11357. templateUrl: "assets/views/customform/tpl/ui-multiselectplus.html",
  11358. defaultOptions: function (options, $scope) {
  11359. return {
  11360. templateOptions: {
  11361. refreshData: function (search, options, model, that) {
  11362. console.log(search, options, model, that)
  11363. var process = options.templateOptions.ApiService.all("");
  11364. if (search) {
  11365. } else {
  11366. }
  11367. var postData = options.templateOptions.optionsPostData;
  11368. if (angular.isFunction(options.templateOptions.optionsPostData)) {
  11369. postData = options.templateOptions.optionsPostData(
  11370. options,
  11371. model,
  11372. that
  11373. );
  11374. }
  11375. if (options.templateOptions.modelreasondata) {
  11376. postData = options.templateOptions.modelreasondata;
  11377. }
  11378. process
  11379. .customPOST(postData, options.templateOptions.optionsUrl)
  11380. .then(function (result) {
  11381. // if (!options.templateOptions.options) {
  11382. // options.templateOptions.options = [];
  11383. // }
  11384. // 过滤下拉列表已选择的值
  11385. var modelVal = $scope.model[$scope.options.key];
  11386. var ides = [];
  11387. var rList = result.list || result;
  11388. if ($scope.options.key == "serviceTypeIds") {
  11389. modelVal = modelVal.map(function (v) {
  11390. if (typeof v !== 'object') {
  11391. return { id: v };
  11392. } else {
  11393. return v;
  11394. }
  11395. })
  11396. }
  11397. for (var i = 0; i < modelVal.length; i++) {
  11398. for (var j = 0; j < rList.length; j++) {
  11399. if (rList[j].id == modelVal[i].id) {
  11400. ides.push(rList[j].id);
  11401. }
  11402. }
  11403. }
  11404. ides.forEach(function (v1) {
  11405. rList.forEach(function (v2) {
  11406. if (v1 == v2.id) {
  11407. rList = rList.filter(v => v.id != v2.id);
  11408. }
  11409. })
  11410. })
  11411. options.templateOptions.options = rList;
  11412. // if (options.templateOptions.optionsDataKey) {
  11413. // options.templateOptions.options =
  11414. // result[options.templateOptions.optionsDataKey];
  11415. // } else {
  11416. // options.templateOptions.options = result;
  11417. // }
  11418. if (options.templateOptions.optionsChecked) {
  11419. // return options.value = null;
  11420. options.value(options.model[options.key]);
  11421. }
  11422. });
  11423. },
  11424. refreshDelay: 0,
  11425. // },
  11426. // validators: {
  11427. // required: {
  11428. // expression: function(viewValue, modelValue) {
  11429. // var value = modelValue || viewValue;
  11430. // // return value.length>=1;
  11431. // // if (modelValue && viewValue) {
  11432. // // return value != null;
  11433. // // } else {
  11434. // // var value = modelValue || viewValue;
  11435. // // return value.length > 0;
  11436. // // }
  11437. // }
  11438. // }
  11439. },
  11440. };
  11441. },
  11442. controller: [
  11443. "$scope",
  11444. function ($scope) {
  11445. if (angular.isArray($scope.model[$scope.options.key])) {
  11446. } else {
  11447. $scope.model[$scope.options.key] = [];
  11448. }
  11449. },
  11450. ],
  11451. });
  11452. //下拉树形多选组件
  11453. formlyConfigProvider.setType({
  11454. name: "ui-multiselect-tree",
  11455. extends: "multiCheckbox",
  11456. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11457. defaultOptions: function (options) {
  11458. return {
  11459. templateOptions: {
  11460. linkage: function (modelName, data, model, modelKey, key) {
  11461. angular.extend(data, {
  11462. idx: 0,
  11463. sum: 10,
  11464. });
  11465. options.templateOptions.APIService.fetchDataList(
  11466. modelName,
  11467. data
  11468. ).then(function (response) {
  11469. var myData =
  11470. options.templateOptions.Restangular.stripRestangular(response);
  11471. var list = myData.list;
  11472. if (list.length == 1) {
  11473. angular.forEach(model.fields, function (item) {
  11474. angular.forEach(model.fields, function (item) {
  11475. if (item.templateOptions.pkey == modelKey + "." + key) {
  11476. item.model.id = "";
  11477. if (key == "place") {
  11478. item.templateOptions.options = list;
  11479. } else {
  11480. item.value(list[0][key][item.key]);
  11481. }
  11482. }
  11483. });
  11484. });
  11485. }
  11486. });
  11487. },
  11488. // my_tree_handler : function(items) {
  11489. // },
  11490. // onFilterCallback : function(items) {
  11491. // },
  11492. // onFilterCallback : function(items) {
  11493. // },
  11494. refresh: function (items) {
  11495. var treedata = [];
  11496. function convertListToTree(data, treeMap) {
  11497. treedata = data;
  11498. for (var i = 0; i < data.length; i++) {
  11499. for (var j = 0; j < data.length; j++) {
  11500. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11501. if (data[i].pid == data[j].id) {
  11502. data[i].parent = data[j];
  11503. }
  11504. }
  11505. }
  11506. }
  11507. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11508. var root = null; //Initially set our loop to null
  11509. //loop over data
  11510. for (var i = 0; i < data.length; i++) {
  11511. var datum = data[i];
  11512. //each node will have children, so let's give it a "children" poperty
  11513. datum.children = [];
  11514. //add an entry for this node to the map so that any future children can
  11515. //lookup the parent
  11516. idToNodeMap[datum.id] = datum;
  11517. //Does this node have a parent?
  11518. if (
  11519. typeof datum.parent === "undefined" ||
  11520. datum.parent === null
  11521. ) {
  11522. //Doesn't look like it, so this node is the root of the tree
  11523. root = datum;
  11524. treeMap[datum.id] = root;
  11525. } else {
  11526. //This node has a parent, so let's look it up using the id
  11527. parentNode = idToNodeMap[datum.parent.id];
  11528. //We don't need this property, so let's delete it.
  11529. delete datum.parent;
  11530. //Let's add the current node as a child of the parent node.
  11531. parentNode.children.push(datum);
  11532. }
  11533. }
  11534. return root;
  11535. }
  11536. function convertParentToChildList(data) {
  11537. // console.log("data="+JSON.stringify(data))
  11538. var treeMap = {};
  11539. var list = [];
  11540. convertListToTree(data, treeMap);
  11541. angular.forEach(treeMap, function (item) {
  11542. list.push(item);
  11543. });
  11544. return list;
  11545. }
  11546. function selectItem(pmodel, childrens) {
  11547. if (angular.isArray(pmodel)) {
  11548. angular.forEach(pmodel, function (index) {
  11549. if (index && index.id) {
  11550. angular.forEach(childrens, function (item) {
  11551. if (item.id == index.id) {
  11552. item.selected = true;
  11553. }
  11554. if (item && item.children) {
  11555. selectItem(pmodel, item.children);
  11556. }
  11557. });
  11558. }
  11559. });
  11560. } else {
  11561. if (pmodel && pmodel.id) {
  11562. angular.forEach(childrens, function (item) {
  11563. if (item.id == pmodel.id) {
  11564. item.selected = true;
  11565. }
  11566. if (item && item.children) {
  11567. selectItem(pmodel, item.children);
  11568. }
  11569. });
  11570. }
  11571. }
  11572. }
  11573. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11574. options.templateOptions
  11575. .refreshData(options.templateOptions.APIService)
  11576. .then(function (result) {
  11577. if (result.status == 200) {
  11578. if (!options.templateOptions.options) {
  11579. options.templateOptions.options = [];
  11580. }
  11581. if (options.templateOptions.optionsDataKey) {
  11582. options.templateOptions.options = convertParentToChildList(
  11583. result[options.templateOptions.optionsDataKey]
  11584. );
  11585. } else {
  11586. options.templateOptions.options =
  11587. convertParentToChildList(result);
  11588. }
  11589. //set default value
  11590. var pmodel,
  11591. i = 0;
  11592. if (options.templateOptions.pkey) {
  11593. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11594. angular.forEach(
  11595. options.templateOptions.pkey.split("."),
  11596. function (p) {
  11597. if (i == 0) {
  11598. if (options.model[p] == null) {
  11599. options.model[p] = {};
  11600. }
  11601. pmodel = options.model[p];
  11602. i++;
  11603. } else {
  11604. if (pmodel[p] == null) {
  11605. pmodel[p] = {};
  11606. }
  11607. pmodel = pmodel[p];
  11608. }
  11609. }
  11610. );
  11611. } else {
  11612. pmodel = options.model;
  11613. }
  11614. }
  11615. if (pmodel) {
  11616. pmodel = pmodel[options.key];
  11617. } else if (options.model) {
  11618. pmodel = options.model[options.key];
  11619. } else {
  11620. pmodel = options.templateOptions.options;
  11621. }
  11622. if (angular.isArray(pmodel)) {
  11623. if (pmodel) {
  11624. // if(options.templateOptions.isMultiSelect==true){
  11625. // options.templateOptions.refreshData(options.templateOptions.APIService).then(function(rep){
  11626. // selectParent(pmodel,rep[options.templateOptions.optionsDataKey]);
  11627. // })
  11628. // }else{
  11629. selectItem(pmodel, options.templateOptions.options);
  11630. // }
  11631. }
  11632. } else {
  11633. if (pmodel && pmodel.id) {
  11634. selectItem(pmodel, options.templateOptions.options);
  11635. }
  11636. }
  11637. items.inputModel = options.templateOptions.options;
  11638. }
  11639. });
  11640. },
  11641. },
  11642. validators: {
  11643. required: {
  11644. expression: function (viewValue, modelValue) {
  11645. var value = modelValue || viewValue;
  11646. if (angular.isArray(value)) {
  11647. for (var i = 0; i < value.length; i++) {
  11648. value[i] = {
  11649. id: value[i].id,
  11650. };
  11651. }
  11652. return value.length > 0;
  11653. } else {
  11654. // console.log(options)
  11655. // return value = "true";
  11656. return value != null;
  11657. }
  11658. },
  11659. },
  11660. },
  11661. };
  11662. },
  11663. controller: [
  11664. "$scope",
  11665. "api_configure_form",
  11666. function ($scope, api_configure_form) {
  11667. if ($scope.options.templateOptions.isMultiSelect) {
  11668. // console.log($scope);
  11669. } else {
  11670. if ($scope.model[$scope.options.key]) {
  11671. }
  11672. }
  11673. },
  11674. ],
  11675. });
  11676. //多选下拉框组件
  11677. formlyConfigProvider.setType({
  11678. name: "ui-multi-select-tree",
  11679. extends: "input",
  11680. templateUrl: "assets/views/customform/tpl/ui-multi-select-tree.html",
  11681. defaultOptions: function (options) {
  11682. return {
  11683. templateOptions: {
  11684. linkage: function (modelName, data, model, modelKey, key) {
  11685. angular.extend(data, {
  11686. idx: 0,
  11687. sum: 10,
  11688. });
  11689. options.templateOptions.APIService.fetchDataList(
  11690. modelName,
  11691. data
  11692. ).then(function (response) {
  11693. var myData =
  11694. options.templateOptions.Restangular.stripRestangular(response);
  11695. var list = myData.list;
  11696. if (list.length == 1) {
  11697. angular.forEach(model.fields, function (item) {
  11698. angular.forEach(model.fields, function (item) {
  11699. if (item.templateOptions.pkey == modelKey + "." + key) {
  11700. item.model.id = "";
  11701. if (key == "place") {
  11702. item.templateOptions.options = list;
  11703. } else {
  11704. item.value(list[0][key][item.key]);
  11705. }
  11706. }
  11707. });
  11708. });
  11709. }
  11710. });
  11711. },
  11712. getparentdata: function (items) {
  11713. // console.log(items)
  11714. },
  11715. refresh: function (items, search, fn) {
  11716. console.log(items, options);
  11717. var treedata = [];
  11718. function convertListToTree(data, treeMap) {
  11719. // console.log(data)
  11720. treedata = data;
  11721. for (var i = 0; i < data.length; i++) {
  11722. for (var j = 0; j < data.length; j++) {
  11723. if (data[i].pid && data[i].id && data[i].pid != 0) {
  11724. if (data[i].pid == data[j].id) {
  11725. data[i].parent = data[j];
  11726. }
  11727. }
  11728. // if (data[i].id) {
  11729. // if (data[i].id== data[j].id) {
  11730. // data[i].parent = data[j];
  11731. // }
  11732. // }
  11733. }
  11734. }
  11735. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  11736. var root = []; //Initially set our loop to null
  11737. if (search == "search" && items.filterKeyword) {
  11738. function transform(nodes) {
  11739. var treeConverter = {
  11740. result: null, //转化后的结果,是根节点,所有节点都是从根节点长出来的
  11741. attributeName: "id", //节点唯一标识符
  11742. needFind: true, //是否查询节点在result中已经存在,为了优化效率
  11743. transform: function (node) {
  11744. //转化递归函数,参数:一个待插入节点
  11745. if (node.parent != null) {
  11746. //该节点有父节点
  11747. var newNode = this.transform(node.parent); //递归进入,返回值为一个节点,用作父节点,该父节点必然存在于result中,这点由下面的算法可以控制
  11748. if (this.needFind) {
  11749. for (var i = 0; i < newNode.children.length; i++) {
  11750. //查找要插入的node子节点是否在newNode这个父节点中存在
  11751. if (
  11752. newNode.children[i][this.attributeName] ===
  11753. node[this.attributeName]
  11754. ) {
  11755. return newNode.children[i]; //存在的话直接返回newNode父节点内的该子节点,该子节点必然存在于result中,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11756. }
  11757. }
  11758. }
  11759. this.needFind = false; //不存在的话,关闭之后递归的循环判断,因为待插入node节点不存在于result中,故而它的子节点一定不存在于result中,不用再循环判断
  11760. // delete node.parent; //删除该节点的parent属性,如果有的话
  11761. node.children = []; //因为确定是要新插入的节点,没有children:[]属性,故给该节点增加children:[]属性
  11762. newNode.children.push(node); //将该node节点push进newNode的子节点数组中
  11763. return node; //return该新插入节点,作为递归返回值给上层,用作newNode父节点,node存在于result中故newNode存在于result中
  11764. } else if (node.parent == null) {
  11765. //该叶节点没有父节点,即为根节点
  11766. // delete node.parent; //删除该节点的parent属性,如果有的话
  11767. if (this.result == null) {
  11768. //根节点不存在
  11769. node.children = []; //给该节点增加children:[]属性
  11770. return (this.result = node); //该节点赋给result,并return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11771. } else {
  11772. node.children = [];
  11773. // 顶级去重
  11774. for (
  11775. var i = 0;
  11776. i < this.result.children.length;
  11777. i++
  11778. ) {
  11779. if (
  11780. this.result.children[i][this.attributeName] ===
  11781. node[this.attributeName]
  11782. ) {
  11783. return this.result.children[i];
  11784. }
  11785. }
  11786. this.result.children.push(node);
  11787. return node; // 直接return根节点,作为返回值它将被用作上级递归的newNode,因此newNode必然存在于result中
  11788. }
  11789. }
  11790. },
  11791. getWhole: function (nodes, attributeName) {
  11792. //传入整个叶子节点数组,attributeName作为节点唯一标识符属性,返回整个转化结果
  11793. var _node = {};
  11794. _node.children = [];
  11795. this.result = _node; //重置根节点
  11796. this.attributeName =
  11797. attributeName == null ? "id" : attributeName; //唯一标识符默认为“id”
  11798. nodes = JSON.parse(JSON.stringify(nodes)); //复制出一个新的节点对象作为参数,保证不改变原有数据
  11799. nodes.forEach((item) => {
  11800. //循环调用转化方法
  11801. this.needFind = true; //重置开启节点是否已存在判断,保证不插入重复节点
  11802. this.transform(item);
  11803. });
  11804. return this.result; //返回根节点
  11805. },
  11806. };
  11807. var result = treeConverter.getWhole(nodes); //调用
  11808. return result;
  11809. }
  11810. var li = transform(data).children;
  11811. // li=[...new Set(li)]
  11812. console.log(li);
  11813. treeMap = li;
  11814. fn(li);
  11815. return li;
  11816. } else {
  11817. //loop over data
  11818. for (var i = 0; i < data.length; i++) {
  11819. var datum = data[i];
  11820. //each node will have children, so let's give it a "children" poperty
  11821. datum.children = [];
  11822. //add an entry for this node to the map so that any future children can
  11823. //lookup the parent
  11824. idToNodeMap[datum.id] = datum;
  11825. //Does this node have a parent?
  11826. if (
  11827. typeof datum.parent === "undefined" ||
  11828. datum.parent === null
  11829. ) {
  11830. //Doesn't look like it, so this node is the root of the tree
  11831. root = datum;
  11832. treeMap[datum.id] = root;
  11833. } else {
  11834. //This node has a parent, so let's look it up using the id
  11835. parentNode = idToNodeMap[datum.parent.id];
  11836. //We don't need this property, so let's delete it.
  11837. // delete datum.parent;
  11838. //Let's add the current node as a child of the parent node.
  11839. parentNode.children.push(datum);
  11840. }
  11841. }
  11842. }
  11843. return root;
  11844. }
  11845. function convertParentToChildList(data) {
  11846. var treeMap = {};
  11847. var list = [];
  11848. if (search == "search" && items.filterKeyword) {
  11849. var lis = convertListToTree(data, treeMap);
  11850. return lis;
  11851. } else {
  11852. if (data[0] && data[0].orders) {
  11853. list = data;
  11854. } else {
  11855. convertListToTree(data, treeMap);
  11856. angular.forEach(treeMap, function (item) {
  11857. // console.log("item="+JSON.stringify(item))
  11858. list.push(item);
  11859. });
  11860. }
  11861. return list;
  11862. }
  11863. }
  11864. function selectItem(pmodel, childrens) {
  11865. if (angular.isArray(pmodel)) {
  11866. angular.forEach(pmodel, function (index) {
  11867. if (index && index.id) {
  11868. angular.forEach(childrens, function (item) {
  11869. if (item.id == index.id) {
  11870. item.selected = true;
  11871. }
  11872. if (item && item.children) {
  11873. selectItem(pmodel, item.children);
  11874. }
  11875. });
  11876. // angular.forEach(treedata,function(parentdata){
  11877. // if(parentdata.id == index.id){
  11878. // if(parentdata.parent&&parentdata.parent.id){
  11879. // parentdata.parent.$
  11880. // }
  11881. // item.selected = true;
  11882. // }
  11883. // if (item && item.children) {
  11884. // selectItem(pmodel ,item.children);
  11885. // }
  11886. // });
  11887. }
  11888. });
  11889. } else {
  11890. if (pmodel && pmodel.id) {
  11891. angular.forEach(childrens, function (item, index) {
  11892. if (item.id == pmodel.id) {
  11893. item.selected = true;
  11894. // delete item.children;
  11895. }
  11896. if (item && item.children) {
  11897. selectItem(pmodel, item.children);
  11898. }
  11899. });
  11900. }
  11901. }
  11902. }
  11903. function selectItemchild(pmodel, childrens) {
  11904. if (angular.isArray(pmodel)) {
  11905. angular.forEach(pmodel, function (index) {
  11906. if (index && index.id) {
  11907. angular.forEach(childrens, function (item) {
  11908. if (item.id == index.id) {
  11909. item.selected = true;
  11910. }
  11911. if (item && item.children) {
  11912. selectItem(pmodel, item.children);
  11913. }
  11914. });
  11915. }
  11916. });
  11917. } else {
  11918. if (pmodel && pmodel.id) {
  11919. angular.forEach(childrens, function (item, index) {
  11920. if (item.id == pmodel.id) {
  11921. item.selected = true;
  11922. childrens[index].selected = true;
  11923. }
  11924. if (item && item.children) {
  11925. selectItem(pmodel, item.children);
  11926. }
  11927. });
  11928. }
  11929. }
  11930. }
  11931. // if(angular.isUndefined(options.model[options.key])||options.model[options.key]==null){
  11932. if (search === "search" && items.filterKeyword) {
  11933. // bala:树形模糊搜索
  11934. options.templateOptions
  11935. .bala(options.templateOptions.APIService, items.filterKeyword)
  11936. .then(function (result) {
  11937. result.list = [...new Set(result.list)]; //去重
  11938. if (!options.templateOptions.options) {
  11939. options.templateOptions.options = [];
  11940. }
  11941. if (options.templateOptions.optionsDataKey) {
  11942. options.templateOptions.options = convertParentToChildList(
  11943. result[options.templateOptions.optionsDataKey]
  11944. );
  11945. } else {
  11946. options.templateOptions.options =
  11947. convertParentToChildList(result);
  11948. }
  11949. //set default value
  11950. var pmodel,
  11951. i = 0;
  11952. if (
  11953. options.templateOptions.pkey ||
  11954. options.templateOptions.pkey != ""
  11955. ) {
  11956. if (options.templateOptions.pkey.indexOf(".") > 0) {
  11957. angular.forEach(
  11958. options.templateOptions.pkey.split("."),
  11959. function (p) {
  11960. if (i == 0) {
  11961. if (options.model[p] == null) {
  11962. options.model[p] = {};
  11963. }
  11964. pmodel = options.model[p];
  11965. i++;
  11966. } else {
  11967. if (pmodel[p] == null) {
  11968. pmodel[p] = {};
  11969. }
  11970. pmodel = pmodel[p];
  11971. }
  11972. }
  11973. );
  11974. } else {
  11975. pmodel = options.model;
  11976. }
  11977. }
  11978. var topdata = angular.copy(options.templateOptions.options);
  11979. if (pmodel) {
  11980. pmodel = pmodel[options.key];
  11981. } else if (options.model) {
  11982. pmodel = options.model[options.key];
  11983. }
  11984. if (angular.isArray(pmodel)) {
  11985. if (pmodel) {
  11986. items.inputModel = angular.copy(
  11987. options.templateOptions.options
  11988. );
  11989. selectItem(pmodel, options.templateOptions.options);
  11990. }
  11991. } else {
  11992. if (pmodel && pmodel.id) {
  11993. items.inputModel = angular.copy(
  11994. options.templateOptions.options
  11995. );
  11996. selectItem(pmodel, options.templateOptions.options);
  11997. } else {
  11998. // items.inputModel = options.templateOptions.options;
  11999. }
  12000. }
  12001. // items.inputModel = options.templateOptions.options;
  12002. items.selectModel = options.templateOptions.options;
  12003. // 可在此展开
  12004. if (!items.inputModel) {
  12005. items.inputModel = items.selectModel;
  12006. } else {
  12007. selectItemchild(pmodel, items.inputModel);
  12008. // for (var i = 0; i < items.inputModel.length; i++) {
  12009. // items.inputModel[i].
  12010. // for (var j = 0; j < items.selectModel.length; j++) {
  12011. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12012. // items.inputModel[i].selected = true;
  12013. // }
  12014. // }
  12015. // }
  12016. }
  12017. return items.inputModel;
  12018. // options.templateOptions.options = angular.copy(topdata);
  12019. // console.log(model);
  12020. // console.log(options);
  12021. });
  12022. } else {
  12023. options.templateOptions
  12024. .refreshData(options.templateOptions.APIService)
  12025. .then(function (result) {
  12026. //回显事件分类,带出绑定的人或组start caocao
  12027. if (options.templateOptions.onlyKey == 'cate_start' && items.$parent.originalModel.incident && items.$parent.originalModel.incident.category) {
  12028. console.log(result[options.templateOptions.optionsDataKey], items.$parent.model.category.id)
  12029. var item = result[options.templateOptions.optionsDataKey].find(function (v) {
  12030. return v.id == items.$parent.originalModel.incident.category.id;
  12031. })
  12032. console.log(item)//11615
  12033. if (item) {
  12034. items.$parent.originalModel.incident.branchType = item.branchType;
  12035. if(item.branchType == 0){
  12036. if (item.userOrGroupType === 1) {
  12037. items.$parent.originalModel.start_code = 'assignment';
  12038. items.$parent.originalModel.incident.handlerUser = { id: item.handleUser ? item.handleUser.id : undefined };
  12039. items.$parent.originalModel.directClose = true;
  12040. items.$parent.originalModel.isHandlerUser = false;
  12041. setTimeout(function () { items.$parent.originalModel.isHandlerUser = true; }, 0)
  12042. } else if (item.userOrGroupType === 2) {
  12043. items.$parent.originalModel.start_code = 'assignment';
  12044. items.$parent.originalModel.candidateGroups = item.group;
  12045. items.$parent.originalModel.directClose = true;
  12046. items.$parent.originalModel.isHandlerUser = false;
  12047. } else {
  12048. items.$parent.originalModel.start_code = 'close';
  12049. items.$parent.originalModel.directClose = false;
  12050. items.$parent.originalModel.isHandlerUser = false;
  12051. delete items.$parent.originalModel.candidateGroups;
  12052. delete items.$parent.originalModel.incident.handlerUser
  12053. }
  12054. }else if(item.branchType == 1){
  12055. items.$parent.originalModel.incident.branchUserGroups = item.branchUserGroups;
  12056. // items.$parent.originalModel.incident.area.id
  12057. options.templateOptions.APIService.fetchData('area',items.$parent.originalModel.incident.area.id).then(res=>{
  12058. console.log(res)
  12059. if(res.status == 200){
  12060. items.$parent.originalModel.incident.branchId = res.data.branch;
  12061. // res.data.branch
  12062. var branchUserGroup=item.branchUserGroups.find(v=>v.branchId==res.data.branch)||{};
  12063. if(branchUserGroup.branchUserOrGroupType==1){
  12064. items.$parent.originalModel.start_code='assignment';
  12065. items.$parent.originalModel.incident.handlerUser={id:branchUserGroup.userId?branchUserGroup.userId:undefined};
  12066. items.$parent.originalModel.directClose=true;
  12067. items.$parent.originalModel.isHandlerUser=false;
  12068. setTimeout(function(){items.$parent.originalModel.isHandlerUser=true;},0)
  12069. }else if(branchUserGroup.branchUserOrGroupType===2){
  12070. items.$parent.originalModel.start_code='assignment';
  12071. items.$parent.originalModel.candidateGroups=branchUserGroup.groupId?branchUserGroup.groupId:undefined;
  12072. items.$parent.originalModel.directClose=true;
  12073. items.$parent.originalModel.isHandlerUser=false;
  12074. }else{
  12075. items.$parent.originalModel.start_code='close';
  12076. items.$parent.originalModel.directClose=false;
  12077. items.$parent.originalModel.isHandlerUser=false;
  12078. delete items.$parent.originalModel.candidateGroups;
  12079. delete items.$parent.originalModel.incident.handlerUser
  12080. }
  12081. }
  12082. })
  12083. }
  12084. }
  12085. }
  12086. //回显事件分类,带出绑定的人或组end
  12087. if (!options.templateOptions.options) {
  12088. options.templateOptions.options = [];
  12089. }
  12090. if (options.templateOptions.optionsDataKey) {
  12091. options.templateOptions.options = convertParentToChildList(
  12092. result[options.templateOptions.optionsDataKey]
  12093. );
  12094. } else {
  12095. options.templateOptions.options =
  12096. convertParentToChildList(result);
  12097. }
  12098. //set default value
  12099. var pmodel,
  12100. i = 0;
  12101. if (
  12102. options.templateOptions.pkey ||
  12103. options.templateOptions.pkey != ""
  12104. ) {
  12105. if (options.templateOptions.pkey.indexOf(".") > 0) {
  12106. angular.forEach(
  12107. options.templateOptions.pkey.split("."),
  12108. function (p) {
  12109. if (i == 0) {
  12110. if (options.model[p] == null) {
  12111. options.model[p] = {};
  12112. }
  12113. pmodel = options.model[p];
  12114. i++;
  12115. } else {
  12116. if (pmodel[p] == null) {
  12117. pmodel[p] = {};
  12118. }
  12119. pmodel = pmodel[p];
  12120. }
  12121. }
  12122. );
  12123. } else {
  12124. pmodel = options.model;
  12125. }
  12126. }
  12127. var topdata = angular.copy(options.templateOptions.options);
  12128. if (pmodel) {
  12129. pmodel = pmodel[options.key];
  12130. } else if (options.model) {
  12131. pmodel = options.model[options.key];
  12132. }
  12133. if (angular.isArray(pmodel)) {
  12134. if (pmodel) {
  12135. items.inputModel = angular.copy(
  12136. options.templateOptions.options
  12137. );
  12138. selectItem(pmodel, options.templateOptions.options);
  12139. }
  12140. } else {
  12141. if (pmodel && pmodel.id) {
  12142. items.inputModel = angular.copy(
  12143. options.templateOptions.options
  12144. );
  12145. selectItem(pmodel, options.templateOptions.options);//baba
  12146. } else {
  12147. // items.inputModel = options.templateOptions.options;
  12148. }
  12149. }
  12150. // items.inputModel = options.templateOptions.options;
  12151. items.selectModel = options.templateOptions.options;
  12152. if (!items.inputModel) {
  12153. items.inputModel = items.selectModel;
  12154. } else {
  12155. selectItemchild(pmodel, items.inputModel);
  12156. // for (var i = 0; i < items.inputModel.length; i++) {
  12157. // for (var j = 0; j < items.selectModel.length; j++) {
  12158. // if (items.selectModel[j].id == items.inputModel[i].id) {
  12159. // items.inputModel[i].selected = true;
  12160. // }
  12161. // }
  12162. // }
  12163. }
  12164. // options.templateOptions.options = angular.copy(topdata);
  12165. // console.log(model);
  12166. // console.log(options);
  12167. });
  12168. }
  12169. },
  12170. },
  12171. validators: {
  12172. required: {
  12173. expression: function (viewValue, modelValue) {
  12174. var value = modelValue || viewValue;
  12175. if (angular.isArray(value)) {
  12176. return value.length > 0;
  12177. } else {
  12178. // console.log(options)
  12179. if (options.templateOptions.required && !value) {
  12180. // return value != null;
  12181. } else {
  12182. return value;
  12183. }
  12184. // return value = "true";
  12185. }
  12186. },
  12187. },
  12188. },
  12189. };
  12190. },
  12191. controller: [
  12192. "$scope",
  12193. "$rootScope",
  12194. "api_configure_form",
  12195. "api_bpm_domain",
  12196. function ($scope, $rootScope, api_configure_form, api_bpm_domain) {
  12197. $rootScope.checkClicked = function (item) {
  12198. angular.forEach($scope.to.options, function (itemone) {
  12199. if (!item.parent) {
  12200. if (item.id == itemone.id) {
  12201. // itemone.isExpanded = true;
  12202. } else {
  12203. itemone.isExpanded = false;
  12204. }
  12205. } else {
  12206. if (item.parent.id == itemone.id) {
  12207. angular.forEach(itemone.children, function (itemtwo) {
  12208. if (item.id == itemtwo.id) {
  12209. } else {
  12210. itemtwo.isExpanded = false;
  12211. }
  12212. });
  12213. }
  12214. }
  12215. });
  12216. // 事件分类带出优先级对应的事件工单信息(预计响应时间,解决时间,逾期时间)
  12217. console.log($scope, "gsm");
  12218. if (
  12219. $scope.originalModel &&
  12220. $scope.originalModel.incident &&
  12221. item.category &&
  12222. (!item.children || !item.children.length) &&
  12223. item.priority &&
  12224. item.priority.id
  12225. ) {
  12226. api_bpm_domain
  12227. .expectedTime("L" + (item.priority.id - 1559))
  12228. .then(function (res) {
  12229. $scope.originalModel.incident.expectResponseTime =
  12230. res.serviceLevelAgreement.responseTime;
  12231. $scope.originalModel.incident.expectIntroTime =
  12232. res.serviceLevelAgreement.resolveTime;
  12233. $scope.originalModel.incident.overdueTime = res.date;
  12234. });
  12235. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = false;
  12236. // setTimeout(() => {
  12237. // $scope.$parent.$parent.$parent.model['knowledgeShow'] = true;
  12238. // }, 500);
  12239. // console.log($scope.$parent.$parent.$parent)
  12240. }
  12241. };
  12242. if ($scope.options.templateOptions.isMultiSelect) {
  12243. // console.log($scope);
  12244. } else {
  12245. if ($scope.model[$scope.options.key]) {
  12246. }
  12247. }
  12248. // $scope.options.templateOptions.onDataCallback=function(item,selectItems,options, field, model){
  12249. // console.log(item)
  12250. // // if(){
  12251. // // }
  12252. // // $scope.model[$scope.options.key]=item.id;
  12253. // api_configure_form.renderTabForm(item.prefix).then(function(data){
  12254. // $scope.propTypeOptions = data;
  12255. // });
  12256. // }
  12257. // $scope.model[$scope.options.key]=[];
  12258. // $scope.fn
  12259. $rootScope.bala1 = function (items, fn) {
  12260. // $scope.fn = fn;
  12261. console.log(items);
  12262. // console.log($scope.options.templateOptions.refresh(items, 'search', fn))
  12263. $scope.options.templateOptions.refresh(items, "search", fn);
  12264. // $scope.options.templateOptions.bala($scope.options.templateOptions.APIService,items.filterKeyword).then(function(res){
  12265. // // return res.list;
  12266. // console.log(666)
  12267. // fn(res.list)
  12268. // })
  12269. };
  12270. },
  12271. ],
  12272. });
  12273. //勾选组件
  12274. formlyConfigProvider.setType({
  12275. name: "ui-checkbox",
  12276. extends: "checkbox",
  12277. templateUrl: "assets/views/customform/tpl/ui-checkbox.html",
  12278. controller: [
  12279. "$scope",
  12280. function ($scope) {
  12281. console.log($scope)
  12282. if($scope.options.templateOptions.isTrue){
  12283. //是否默认打开
  12284. $scope.model[$scope.options.key] = true;
  12285. }
  12286. // 巡检生成事件,默认派单
  12287. if ($scope.model.isInspection) {
  12288. $scope.model[$scope.options.key] = true;
  12289. }
  12290. if ($scope.model[$scope.options.key] == "true") {
  12291. $scope.model[$scope.options.key] = true;
  12292. }
  12293. if ($scope.model[$scope.options.key] == "false") {
  12294. $scope.model[$scope.options.key] = false;
  12295. }
  12296. },
  12297. ],
  12298. });
  12299. //勾选组件(禁用)--yeye
  12300. formlyConfigProvider.setType({
  12301. name: "ui-checkbox-disabled",
  12302. extends: "checkbox",
  12303. templateUrl: "assets/views/customform/tpl/ui-checkbox-disabled.html",
  12304. controller: [
  12305. "$scope",
  12306. function ($scope) {
  12307. // 巡检生成事件,默认派单
  12308. // if ($scope.model.isInspection) {
  12309. // $scope.model[$scope.options.key] = true;
  12310. // }
  12311. // if ($scope.model[$scope.options.key] == "true") {
  12312. // $scope.model[$scope.options.key] = true;
  12313. // }
  12314. // if ($scope.model[$scope.options.key] == "false") {
  12315. // $scope.model[$scope.options.key] = false;
  12316. // }
  12317. },
  12318. ],
  12319. });
  12320. //换行组件
  12321. formlyConfigProvider.setType({
  12322. name: "ui-nextLine",
  12323. /*extends: 'input',*/
  12324. template: "<div></div>",
  12325. });
  12326. //多选框组件
  12327. formlyConfigProvider.setType({
  12328. name: "ui-checklist",
  12329. extends: "multiCheckbox",
  12330. templateUrl: "assets/views/customform/tpl/ui-checklist.html",
  12331. defaultOptions: function (options) {
  12332. return {
  12333. templateOptions: {
  12334. refresh: function () { },
  12335. refreshDelay: 0,
  12336. },
  12337. };
  12338. },
  12339. });
  12340. //单选框组件
  12341. formlyConfigProvider.setType({
  12342. name: "ui-radio",
  12343. extends: "radio",
  12344. templateUrl: "assets/views/customform/tpl/ui-radio.html",
  12345. defaultOptions: function (options) {
  12346. return {
  12347. templateOptions: {
  12348. refresh: function () {},
  12349. refreshDelay: 0,
  12350. },
  12351. };
  12352. },
  12353. controller: [
  12354. "$scope",
  12355. "api_wechatfile",
  12356. function ($scope,api_wechatfile) {
  12357. // 新增巡检计划-巡检方式baba
  12358. if($scope.to.onlyKey === 'onlineType'){
  12359. api_wechatfile.getDictionary($scope.to.modelreasondata).then(function (result) {
  12360. $scope.to.options = result;
  12361. if(!$scope.model[$scope.options.key]){
  12362. $scope.model[$scope.options.key] = result[0]?result[0].id:null;
  12363. }
  12364. });
  12365. }
  12366. // 巡检生成事件,默认派单
  12367. if ($scope.model.isInspection) {
  12368. $scope.model[$scope.options.key] = true;
  12369. // $scope.model.isHandlerUser=true;
  12370. $scope.model.start_code = "assignment";
  12371. console.log($scope.model);
  12372. }
  12373. //多次暂存配置
  12374. // console.log($scope);
  12375. if ($scope.model.saveAgain) {
  12376. if (
  12377. $scope.model.directClose == "1" ||
  12378. $scope.model.directClose == true
  12379. ) {
  12380. $scope.model[$scope.options.key] = true;
  12381. // if($scope.model.incident.handlingPersonnelUser){
  12382. // delete $scope.model.incident.handlingPersonnelUser;
  12383. // };
  12384. if ($scope.model.incident.handleDescription) {
  12385. delete $scope.model.incident.handleDescription;
  12386. }
  12387. if ($scope.model.incident.closecode) {
  12388. delete $scope.model.incident.closecode;
  12389. }
  12390. if ($scope.model.incident.degree) {
  12391. delete $scope.model.incident.degree;
  12392. }
  12393. } else {
  12394. $scope.model.incident.handlingPersonnelUser =
  12395. $scope.model.incident.acceptUser;
  12396. $scope.model[$scope.options.key] = false;
  12397. }
  12398. }
  12399. },
  12400. ],
  12401. });
  12402. //文本域组件
  12403. formlyConfigProvider.setWrapper({
  12404. name: "validation",
  12405. types: ["ui-textarea"],
  12406. template:
  12407. '<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>',
  12408. });
  12409. formlyConfigProvider.setType({
  12410. name: "ui-textarea",
  12411. extends: "textarea",
  12412. templateUrl: "assets/views/customform/tpl/ui-textarea.html",
  12413. defaultOptions: function (options) {
  12414. return {
  12415. templateOptions: {
  12416. transform: function (model, value) {
  12417. return value;
  12418. },
  12419. },
  12420. validation: {
  12421. messages: {
  12422. maxlength: function (viewValue, modelValue, scope) {
  12423. if (viewValue != null) {
  12424. if (viewValue.length > scope.to.maxlength) {
  12425. return (
  12426. scope.to.label +
  12427. " 字数(" +
  12428. viewValue.length +
  12429. ")超限(" +
  12430. scope.to.maxlength +
  12431. ")"
  12432. );
  12433. } else {
  12434. return "";
  12435. }
  12436. }
  12437. },
  12438. },
  12439. },
  12440. };
  12441. },
  12442. controller: [
  12443. "$scope",
  12444. function ($scope) {
  12445. var value = $scope.model[$scope.options.key];
  12446. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12447. $scope.model[$scope.options.key] =
  12448. $scope.options.templateOptions.transform(
  12449. $scope.originalModel,
  12450. value
  12451. );
  12452. }
  12453. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12454. $scope.options.templateOptions.felditem($scope);
  12455. }
  12456. },
  12457. ],
  12458. });
  12459. // div版的textarea(展示富文本框内容用)
  12460. formlyConfigProvider.setType({
  12461. name: "ui-divTextarea",
  12462. extends: "textarea",
  12463. templateUrl: "assets/views/customform/tpl/ui-divTextarea.html",
  12464. defaultOptions: function (options) {
  12465. return {
  12466. templateOptions: {
  12467. transform: function (model, value) {
  12468. return value;
  12469. },
  12470. },
  12471. validation: {
  12472. messages: {
  12473. // maxlength: function (viewValue, modelValue, scope) {
  12474. // if (viewValue != null) {
  12475. // if (viewValue.length > scope.to.maxlength) {
  12476. // return scope.to.label + ' 字数(' + viewValue.length + ')超限(' + scope.to.maxlength + ')'
  12477. // } else {
  12478. // return "";
  12479. // }
  12480. // }
  12481. // },
  12482. },
  12483. },
  12484. };
  12485. },
  12486. controller: [
  12487. "$scope",
  12488. function ($scope) {
  12489. var value = $scope.model[$scope.options.key];
  12490. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12491. $scope.model[$scope.options.key] =
  12492. $scope.options.templateOptions.transform(
  12493. $scope.originalModel,
  12494. value
  12495. );
  12496. }
  12497. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12498. $scope.options.templateOptions.felditem($scope);
  12499. }
  12500. },
  12501. ],
  12502. });
  12503. // 带有知识库引用的textarea
  12504. formlyConfigProvider.setType({
  12505. name: "ui-textAreaKnowledge",
  12506. // extends: 'textarea',
  12507. templateUrl: "assets/views/customform/tpl/ui-textAreaKnowledge.html",
  12508. defaultOptions: function (options) {
  12509. return {
  12510. templateOptions: {
  12511. transform: function (model, value) {
  12512. return value;
  12513. },
  12514. },
  12515. validation: {
  12516. messages: {
  12517. maxlength: function (viewValue, modelValue, scope) {
  12518. if (viewValue != null) {
  12519. if (viewValue.length > scope.to.maxlength) {
  12520. return (
  12521. scope.to.label +
  12522. " 字数(" +
  12523. viewValue.length +
  12524. ")超限(" +
  12525. scope.to.maxlength +
  12526. ")"
  12527. );
  12528. } else {
  12529. return "";
  12530. }
  12531. }
  12532. },
  12533. },
  12534. },
  12535. };
  12536. },
  12537. controller: [
  12538. "$scope",
  12539. "$rootScope",
  12540. "$modal",
  12541. "SweetAlert",
  12542. "api_bpm_data",
  12543. "api_bpm_domain",
  12544. "api_solution",
  12545. "$aside",
  12546. "api_zsk",
  12547. "up_down_file",
  12548. "api_wechatfile",
  12549. function (
  12550. $scope,
  12551. $rootScope,
  12552. $modal,
  12553. SweetAlert,
  12554. api_bpm_data,
  12555. api_bpm_domain,
  12556. api_solution,
  12557. $aside,
  12558. api_zsk,
  12559. up_down_file,
  12560. api_wechatfile
  12561. ) {
  12562. // console.log($scope);
  12563. var value = $scope.model[$scope.options.key];
  12564. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12565. $scope.model[$scope.options.key] =
  12566. $scope.options.templateOptions.transform(
  12567. $scope.originalModel,
  12568. value
  12569. );
  12570. }
  12571. if (angular.isFunction($scope.options.templateOptions.felditem)) {
  12572. $scope.options.templateOptions.felditem($scope);
  12573. }
  12574. // 引用知识库点击
  12575. $scope.openSolution = function () {
  12576. $scope.$parent.$parent.$parent.model["knowledgeShow"] = false;
  12577. setTimeout(() => {
  12578. $scope.$parent.$parent.$parent.model["knowledgeShow"] = true;
  12579. }, 100);
  12580. };
  12581. },
  12582. ],
  12583. });
  12584. //常用语句选择textarea
  12585. formlyConfigProvider.setType({
  12586. name: "ui-textselect",
  12587. extends: "textarea",
  12588. templateUrl: "assets/views/customform/tpl/ui-textselect.html",
  12589. defaultOptions: function (options) {
  12590. return {
  12591. templateOptions: {
  12592. transform: function (model, value) {
  12593. return value;
  12594. },
  12595. },
  12596. validation: {
  12597. messages: {
  12598. maxlength: function (viewValue, modelValue, scope) {
  12599. if (viewValue != null) {
  12600. if (viewValue.length > scope.to.maxlength) {
  12601. return (
  12602. scope.to.label +
  12603. " 字数(" +
  12604. viewValue.length +
  12605. ")超限(" +
  12606. scope.to.maxlength +
  12607. ")"
  12608. );
  12609. } else {
  12610. return "";
  12611. }
  12612. }
  12613. },
  12614. },
  12615. },
  12616. };
  12617. },
  12618. controller: [
  12619. "$scope",
  12620. function ($scope) {
  12621. var value = $scope.model[$scope.options.key];
  12622. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12623. $scope.model[$scope.options.key] =
  12624. $scope.options.templateOptions.transform(
  12625. $scope.originalModel,
  12626. value
  12627. );
  12628. }
  12629. },
  12630. ],
  12631. });
  12632. //改动的组件 ckeditor封装后的组件
  12633. formlyConfigProvider.setType({
  12634. name: "ui-text-check",
  12635. extends: "textarea",
  12636. templateUrl: "assets/views/customform/tpl/ui-text-check.html",
  12637. defaultOptions: function (options) {
  12638. return {
  12639. templateOptions: {
  12640. extraPlugins: "uploadimage",
  12641. uploadimageConfig: {
  12642. backend: "basic",
  12643. settings: {
  12644. uploadUrl:
  12645. options.templateOptions.APIService.upload().getRequestedUrl(),
  12646. headers: "",
  12647. downloadUrl:
  12648. options.templateOptions.APIService.uploadResponseUri().getRequestedUrl(),
  12649. },
  12650. },
  12651. refresh: function (APIService, contentId, data) {
  12652. return APIService.fetchDataList(contentId, data);
  12653. },
  12654. downloadUri: function (APIService, contentId) {
  12655. return APIService.downloadAttachment(contentId).getRequestedUrl();
  12656. },
  12657. upload: function (APIService, contentId) {
  12658. return APIService.getSolutionDowpath(contentId);
  12659. },
  12660. view: function (attachmentId) {
  12661. // return APIService.attachmentsPreviewUrl(contentId);
  12662. },
  12663. refreshDelay: 0,
  12664. transform: function (model, value) {
  12665. return value;
  12666. },
  12667. },
  12668. validation: {
  12669. messages: {
  12670. maxlength: function (viewValue, modelValue, scope) {
  12671. if (viewValue != null) {
  12672. if (viewValue.length > scope.to.maxlength) {
  12673. return (
  12674. scope.to.label +
  12675. " 字数(" +
  12676. viewValue.length +
  12677. ")超限(" +
  12678. scope.to.maxlength +
  12679. ")"
  12680. );
  12681. } else {
  12682. return "";
  12683. }
  12684. }
  12685. },
  12686. },
  12687. },
  12688. };
  12689. },
  12690. controller: [
  12691. "$scope",
  12692. "$rootScope",
  12693. function ($scope, $rootScope) {
  12694. var value = $scope.model[$scope.options.key];
  12695. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12696. $scope.model[$scope.options.key] =
  12697. $scope.options.templateOptions.transform(
  12698. $scope.originalModel,
  12699. value
  12700. );
  12701. }
  12702. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12703. $rootScope.getSession();
  12704. //var expiry={'expiry':14804244006};
  12705. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12706. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12707. $scope.upload = function (contentId, filename) {
  12708. var filename = filename;
  12709. $scope.options.templateOptions
  12710. .upload($scope.options.templateOptions.ApiService, contentId)
  12711. .then(function (response) {
  12712. var file = new Blob([response], {
  12713. type: "application/octet-stream",
  12714. });
  12715. // var filename = filename;
  12716. var fileURL = URL.createObjectURL(file);
  12717. var a = document.createElement("a");
  12718. a.href = fileURL;
  12719. a.target = "_blank";
  12720. a.download = filename;
  12721. document.body.appendChild(a);
  12722. a.click();
  12723. });
  12724. };
  12725. },
  12726. ],
  12727. });
  12728. //改动的组件 ckeditor封装后的附文本组件
  12729. formlyConfigProvider.setType({
  12730. name: "ui-fuwenben",
  12731. extends: "textarea",
  12732. templateUrl: "assets/views/customform/tpl/ui-fuwenben.html",
  12733. defaultOptions: function (options) {
  12734. return {
  12735. templateOptions: {
  12736. allowedContent: "img[!src]", //允许展示源码的标签,否则会被富文本框强制删除
  12737. extraPlugins: "uploadimage",
  12738. uploadimageConfig: {
  12739. backend: "basic",
  12740. settings: {
  12741. uploadUrl:
  12742. options.templateOptions.APIService.upload(
  12743. -110
  12744. ).getRequestedUrl(),
  12745. headers: "",
  12746. downloadUrl:
  12747. options.templateOptions.APIService.uploadResponseUri(),
  12748. },
  12749. },
  12750. refresh: function (APIService, contentId, data) {
  12751. return APIService.fetchDataList(-110, data);
  12752. },
  12753. downloadUri: function (APIService, contentId) {
  12754. return APIService.downloadAttachment(-110).getRequestedUrl();
  12755. },
  12756. upload: function (APIService, contentId) {
  12757. return APIService.getSolutionDowpath(-110);
  12758. },
  12759. view: function (attachmentId) {
  12760. // return APIService.attachmentsPreviewUrl(contentId);
  12761. },
  12762. refreshDelay: 0,
  12763. transform: function (model, value) {
  12764. return value;
  12765. },
  12766. },
  12767. validation: {
  12768. messages: {
  12769. maxlength: function (viewValue, modelValue, scope) {
  12770. if (viewValue != null) {
  12771. if (viewValue.length > scope.to.maxlength) {
  12772. return (
  12773. scope.to.label +
  12774. " 字数(" +
  12775. viewValue.length +
  12776. ")超限(" +
  12777. scope.to.maxlength +
  12778. ")"
  12779. );
  12780. } else {
  12781. return "";
  12782. }
  12783. }
  12784. },
  12785. },
  12786. },
  12787. };
  12788. },
  12789. controller: [
  12790. "$scope",
  12791. "$rootScope",
  12792. function ($scope, $rootScope) {
  12793. var value = $scope.model[$scope.options.key];
  12794. if (angular.isFunction($scope.options.templateOptions.transform)) {
  12795. $scope.model[$scope.options.key] =
  12796. $scope.options.templateOptions.transform(
  12797. $scope.originalModel,
  12798. value
  12799. );
  12800. }
  12801. $scope.options.templateOptions.uploadimageConfig.settings.headers =
  12802. $rootScope.getSession();
  12803. //var expiry={'expiry':14804244006};
  12804. //angular.extend($scope.options.templateOptions.uploadimageConfig.settings.headers,expiry)
  12805. //$scope.options.templateOptions.uploadimageConfig.settings.headers
  12806. $scope.upload = function (contentId, filename) {
  12807. var filename = filename;
  12808. $scope.options.templateOptions
  12809. .upload($scope.options.templateOptions.ApiService, -110)
  12810. .then(function (response) {
  12811. var file = new Blob([response], {
  12812. type: "application/octet-stream",
  12813. });
  12814. // var filename = filename;
  12815. var fileURL = URL.createObjectURL(file);
  12816. var a = document.createElement("a");
  12817. a.href = fileURL;
  12818. a.target = "_blank";
  12819. a.download = filename;
  12820. document.body.appendChild(a);
  12821. a.click();
  12822. });
  12823. };
  12824. },
  12825. ],
  12826. });
  12827. //ui-grid展示控件
  12828. formlyConfigProvider.setType({
  12829. name: "ui-grid-show",
  12830. extends: "multiCheckbox",
  12831. templateUrl: "assets/views/customform/tpl/ui-grid-show.html",
  12832. defaultOptions: function (options,scope) {
  12833. return {
  12834. templateOptions: {
  12835. linkage: function () { },
  12836. getScope: function () {
  12837. return scope;
  12838. },
  12839. },
  12840. };
  12841. },
  12842. controller: function (
  12843. $scope,
  12844. $rootScope,
  12845. i18nService,
  12846. Restangular,
  12847. api_bpm_data
  12848. ) {
  12849. var loginUser = $rootScope.user;
  12850. $scope.langs = i18nService.getAllLangs();
  12851. $scope.lang = "zh-cn";
  12852. i18nService.setCurrentLang($scope.lang);
  12853. $scope.gridOptions = {};
  12854. $scope.gridOptions.data = "myData";
  12855. $scope.gridOptions.enableColumnResizing = true;
  12856. // $scope.gridOptions.enableFiltering = true;
  12857. $scope.gridOptions.enableGridMenu = false;
  12858. $scope.gridOptions.enableRowSelection = true;
  12859. $scope.gridOptions.showGridFooter = true;
  12860. $scope.gridOptions.showColumnFooter = false;
  12861. $scope.gridOptions.fastWatch = true;
  12862. $scope.gridOptions.useExternalFiltering = true;
  12863. $scope.gridOptions.useExternalPagination = true;
  12864. $scope.gridOptions.paginationPageSizes = [10];
  12865. $scope.gridOptions.paginationPageSize = 10;
  12866. $scope.gridOptions.multiSelect = true;
  12867. $scope.gridOptions.rowIdentity = function (row) {
  12868. return row.id;
  12869. };
  12870. $scope.gridOptions.getRowIdentity = function (row) {
  12871. return row.id;
  12872. };
  12873. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  12874. $scope.gridOptions.columnDefs = [
  12875. // { name:'id', width:80, enableFiltering:false},
  12876. // { name: 'item', displayName: '序号', width: 50, enableFiltering: false },
  12877. // { name: 'inspectionDTO.title', displayName: '计划主题', width: 150, enableFiltering: false },
  12878. // { name: 'startDate', displayName: '巡检执行时间', width: 200, enableFiltering: false },
  12879. // { name: 'inspectionDTO.executeUser.name', displayName: '计划执行人', width: 100, enableFiltering: false },
  12880. // { name: 'inspectionDTO.createTime', displayName: '巡检创建时间', width: 200, enableFiltering: false },
  12881. {
  12882. name: "inspection.title",
  12883. displayName: "计划主题",
  12884. width: 120,
  12885. enableFiltering: false,
  12886. },
  12887. {
  12888. name: "sign",
  12889. displayName: "单号",
  12890. width: 140,
  12891. enableFiltering: false,
  12892. },
  12893. {
  12894. name: "inspectionType.type",
  12895. displayName: "巡检分类",
  12896. width: 200,
  12897. enableFiltering: false,
  12898. cellTemplate: '<div>' +
  12899. '<div class="ui-grid-cell-contents">{{row.entity.online?"线上巡检-":(row.entity.online===false?"线下巡检-":"")}}{{row.entity.inspectionType.type}}</div>' +
  12900. '</div>'
  12901. },
  12902. {
  12903. name: "stateName",
  12904. displayName: "状态",
  12905. width: 80,
  12906. enableFiltering: false,
  12907. },
  12908. {
  12909. name: "processUser.name",
  12910. displayName: "处理人/组",
  12911. width: 120,
  12912. enableFiltering: false,
  12913. cellTemplate: '<div>' +
  12914. '<div class="ui-grid-cell-contents" ng-if="!row.entity.group">{{row.entity.processUser.name}}</div>' +
  12915. '<div class="ui-grid-cell-contents" ng-if="row.entity.group">{{row.entity.group.groupName}}</div>' +
  12916. '</div>'
  12917. },
  12918. {
  12919. name: "startDate",
  12920. displayName: "开始时间",
  12921. width: 160,
  12922. enableFiltering: false,
  12923. },
  12924. {
  12925. name: "endTime",
  12926. displayName: "结束时间",
  12927. width: 160,
  12928. enableFiltering: false,
  12929. cellTemplate: '<div>' +
  12930. '<div class="ui-grid-cell-contents">{{row.entity.endTime?grid.appScope.transferTime(row.entity.endTime):""}}</div>' +
  12931. '</div>'
  12932. },
  12933. // {
  12934. // name: "batchNo",
  12935. // displayName: "批次号",
  12936. // width: 160,
  12937. // enableFiltering: false,
  12938. // },
  12939. ];
  12940. var defaultFilterData = {
  12941. idx: 0,
  12942. sum: 10,
  12943. };
  12944. $scope.transferTime = function (time) {
  12945. return moment(time).format("YYYY-MM-DD HH:mm");
  12946. };
  12947. //分页控制
  12948. $scope.gridOptions.onRegisterApi = function (gridApi) {
  12949. gridApi.pagination.on.paginationChanged(
  12950. $scope,
  12951. function (newPage, pageSize) {
  12952. var filtersData = $scope.memoryfilterData;
  12953. filtersData.idx = newPage - 1;
  12954. filtersData.sum = pageSize;
  12955. $scope.refreshData("expand-right", filtersData);
  12956. }
  12957. );
  12958. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  12959. data.grid.appScope.selected.items = data.entity;
  12960. });
  12961. };
  12962. //页面获取数据
  12963. $scope.refreshData = function (style, filterData) {
  12964. // $scope.ldloading[style.replace('-', '_')] = true;
  12965. console.log(angular.isUndefined(filterData))
  12966. if (angular.isUndefined(filterData)) {
  12967. filterData = defaultFilterData;
  12968. }
  12969. $scope.myData = [];
  12970. console.log(filterData)
  12971. if(filterData.inspectionProcessActual && filterData.inspectionProcessActual.batchNo){
  12972. filterData.inspectionProcessActual = {
  12973. inspectionid: $scope.model.id,
  12974. batchNo:filterData.inspectionProcessActual.batchNo
  12975. }
  12976. }else{
  12977. filterData.inspectionProcessActual = {
  12978. inspectionid: $scope.model.id
  12979. }
  12980. }
  12981. // angular.extend(filterData, {
  12982. // inspectionProcessActual: {
  12983. // inspectionid: $scope.model.id,
  12984. // },
  12985. // });
  12986. console.log(filterData)
  12987. api_bpm_data.fetchDataList("inspectionProcessActual", filterData).then(
  12988. function (data) {
  12989. var myData = Restangular.stripRestangular(data);
  12990. $scope.gridOptions.totalItems = myData.totalNum;
  12991. $scope.myData = myData.list;
  12992. for (var i = 0; i < $scope.myData.length; i++) {
  12993. //添加序号
  12994. $scope.myData[i]["item"] =
  12995. i + 1 + filterData.idx * filterData.sum;
  12996. }
  12997. // $scope.ldloading[style.replace('-', '_')] = false;
  12998. },
  12999. function () {
  13000. // $scope.ldloading[style.replace('-', '_')] = false;
  13001. }
  13002. );
  13003. };
  13004. $scope.refreshData("expand-right", defaultFilterData);
  13005. },
  13006. });
  13007. //文本框自定义选择面板组件
  13008. formlyConfigProvider.setType({
  13009. name: "ui-input-selectmodal",
  13010. extends: "input",
  13011. templateUrl: "assets/views/customform/tpl/ui-input-selectmodal.html",
  13012. defaultOptions: function (options) {
  13013. return {
  13014. templateOptions: {
  13015. openModal: function (size, options, modal) {
  13016. var modalInstance = modal.open({
  13017. templateUrl: "assets/views/customform/tpl/modal-content.html",
  13018. controller: "ModalInstanceCtrl", //'CustomformCtrl',//
  13019. size: size,
  13020. resolve: options.templateOptions.modalParam,
  13021. });
  13022. modalInstance.result.then(
  13023. function (selectedItem) {
  13024. options.value(selectedItem);
  13025. },
  13026. function () {
  13027. //console.log('Modal dismissed at: ' + new Date());
  13028. }
  13029. );
  13030. },
  13031. },
  13032. };
  13033. },
  13034. });
  13035. //日期控件
  13036. var datepicker_attr = [
  13037. "date-disabled",
  13038. "custom-class",
  13039. "show-weeks",
  13040. "starting-day",
  13041. "init-date",
  13042. "min-mode",
  13043. "max-mode",
  13044. "format-day",
  13045. "format-month",
  13046. "format-year",
  13047. "format-day-header",
  13048. "format-day-title",
  13049. "format-month-title",
  13050. "year-range",
  13051. "shortcut-propagation",
  13052. "datepicker-popup",
  13053. "show-button-bar",
  13054. "current-text",
  13055. "clear-text",
  13056. "close-text",
  13057. "close-on-date-selection",
  13058. "datepicker-append-to-body",
  13059. ];
  13060. var datepicker_bindings = ["datepicker-mode", "min-date", "max-date"];
  13061. formlyConfigProvider.setType({
  13062. name: "ui-datetime",
  13063. templateUrl: "assets/views/customform/tpl/ui-datetime.html",
  13064. extends: "input",
  13065. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13066. defaultOptions: {
  13067. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13068. templateOptions: {
  13069. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13070. },
  13071. },
  13072. controller: [
  13073. "$scope",
  13074. "$filter",
  13075. function ($scope, $filter) {
  13076. $scope.model[$scope.options.key] = $filter("date")(
  13077. new Date(),
  13078. $scope.options.templateOptions.datepickerPopup
  13079. );
  13080. $scope.options.initialValue = $scope.model[$scope.options.key];
  13081. },
  13082. ],
  13083. });
  13084. //日期控件
  13085. formlyConfigProvider.setType({
  13086. name: "ui-datepicker",
  13087. templateUrl: "assets/views/customform/tpl/ui-datepicker.html",
  13088. extends: "input",
  13089. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13090. defaultOptions: {
  13091. ngModelAttrs: getNgModelAttr(datepicker_attr, datepicker_bindings),
  13092. templateOptions: {
  13093. datepickerPopup: "yyyy-MM-dd HH:mm:ss",
  13094. },
  13095. },
  13096. controller: [
  13097. "$scope",
  13098. "$filter",
  13099. function ($scope, $filter) {
  13100. // $scope.mindata=new Date(new Date().getTime() + 24*60*60*1000);
  13101. if ($scope.model[$scope.options.key]) {
  13102. } else {
  13103. $scope.model[$scope.options.key] = $filter("date")(
  13104. new Date(),
  13105. $scope.options.templateOptions.datepickerPopup
  13106. );
  13107. }
  13108. $scope.options.initialValue = $scope.model[$scope.options.key];
  13109. $scope.endOpen = true;
  13110. $scope.datepicker = {};
  13111. $scope.datepicker.opened = false;
  13112. $scope.datepicker.open = function ($event) {
  13113. $scope.datepicker.opened = true;
  13114. };
  13115. },
  13116. ],
  13117. });
  13118. //时分控件
  13119. formlyConfigProvider.setType({
  13120. name: "ui-datehourtime",
  13121. extends: "input",
  13122. templateUrl: "assets/views/customform/tpl/ui-datehourtime.html",
  13123. defaultOptions: function (options) {
  13124. return {
  13125. noFormControl: true,
  13126. // validators:{
  13127. // required:{
  13128. // expression:function(viewValue, modelValue){
  13129. // console.log(options)
  13130. // var value = modelValue.getHours().toString()+":"+modelValue.getMinutes().toString()+":"+"59"||viewValue.getHours().toString()+":"+viewValue.getMinutes().toString()+":"+"59"
  13131. // // var value = modelValue.getHours() || viewValue.getHours();
  13132. // return value.length>=1;
  13133. // }
  13134. // }
  13135. // }
  13136. };
  13137. },
  13138. controller: [
  13139. "$scope",
  13140. "$log",
  13141. function ($scope, $log) {
  13142. $scope.hstep = new Date(
  13143. Date.parse($scope.model[$scope.options.key])
  13144. ).getHours();
  13145. $scope.minutes = new Date(
  13146. Date.parse($scope.model[$scope.options.key])
  13147. ).getMinutes();
  13148. $scope.model[$scope.options.key] = new Date(
  13149. Date.parse($scope.model[$scope.options.key])
  13150. );
  13151. },
  13152. ],
  13153. });
  13154. //状态追踪
  13155. formlyConfigProvider.setType({
  13156. name: "ui-followStatus",
  13157. templateUrl: "assets/views/customform/tpl/ui-followStatus.html",
  13158. controller: [
  13159. "$scope",
  13160. "api_bpm_data",
  13161. "Restangular",
  13162. function ($scope, api_bpm_data, Restangular) {
  13163. setTimeout(function () {
  13164. var pkey = $scope.options.templateOptions.pkey;
  13165. var dataId = $scope.model.id;
  13166. if (dataId) {
  13167. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13168. if (response) {
  13169. var myData = Restangular.stripRestangular(response);
  13170. var processInstanceId = myData.data.processInstanceId;
  13171. $scope.options.templateOptions
  13172. .getData(
  13173. $scope.model,
  13174. $scope.options.templateOptions.ApiService,
  13175. processInstanceId
  13176. )
  13177. .then(function (result) {
  13178. if (result.status == 200) {
  13179. var newData = Restangular.stripRestangular(result);
  13180. $scope.followData = newData.data;
  13181. }
  13182. });
  13183. }
  13184. });
  13185. }
  13186. }, 10);
  13187. },
  13188. ],
  13189. });
  13190. //沟通记录
  13191. formlyConfigProvider.setType({
  13192. name: "ui-handlerLog",
  13193. templateUrl: "assets/views/customform/tpl/ui-handlerLog.html",
  13194. controller: [
  13195. "$scope",
  13196. "$rootScope",
  13197. "$modal",
  13198. "api_bpm_data",
  13199. "Restangular",
  13200. function ($scope, $rootScope, $modal, api_bpm_data, Restangular) {
  13201. console.log($scope, 'ui-handlerLog');
  13202. //录音
  13203. $scope.recordcall = function(data) {
  13204. var modalInstance = $modal.open({
  13205. backdrop: "static",
  13206. templateUrl: 'assets/views/incident/tpl/audio.html',
  13207. controller: function($rootScope, $scope, $modalInstance, $sce, $http, api_playservice) {
  13208. $rootScope.setbusy();
  13209. $scope.audioUrl=$sce.trustAsResourceUrl(callIp+data.recordingFileName);
  13210. // $scope.audioUrl=$sce.trustAsResourceUrl('https://www.runoob.com/try/demo_source/horse.ogg');//暂时写死
  13211. $scope.cancel = function() {
  13212. $modalInstance.dismiss('cancel');
  13213. };
  13214. $modalInstance.close();
  13215. }
  13216. });
  13217. modalInstance.result.then(function(result) {}, function(reason) {
  13218. $rootScope.setidle();
  13219. });
  13220. };
  13221. },
  13222. ],
  13223. });
  13224. //资产
  13225. formlyConfigProvider.setType({
  13226. name: "ui-zc",
  13227. templateUrl: "assets/views/customform/tpl/ui-zc.html",
  13228. controller: [
  13229. "$scope",
  13230. "api_bpm_data",
  13231. "Restangular",
  13232. function ($scope, api_bpm_data, Restangular) {
  13233. console.log($scope, 'ui-zc');
  13234. $scope.wxIncidentWithCmdb = JSON.parse(sessionStorage.getItem("wxIncidentWithCmdb"));//资产
  13235. },
  13236. ],
  13237. });
  13238. //绑定的耗材
  13239. formlyConfigProvider.setType({
  13240. name: "ui-hc",
  13241. templateUrl: "assets/views/customform/tpl/ui-hc.html",
  13242. controller: [
  13243. "$scope",
  13244. "api_cmdb2",
  13245. "Restangular",
  13246. function ($scope, api_cmdb2, Restangular) {
  13247. console.log($scope, 'ui-hc')
  13248. $scope.incidentWithConsumable = JSON.parse(sessionStorage.getItem("incidentWithConsumable"));//耗材
  13249. $scope.list = [];
  13250. var sjId = $scope.model.incident.id;
  13251. api_cmdb2.getHc(sjId).then(function (response) {
  13252. console.log(response)
  13253. if (response.status == 200) {
  13254. $scope.list = response.data;
  13255. }
  13256. })
  13257. },
  13258. ],
  13259. });
  13260. //历史记录
  13261. formlyConfigProvider.setType({
  13262. name: "ui-history",
  13263. templateUrl: "assets/views/customform/tpl/ui-history.html",
  13264. controller: [
  13265. "$scope",
  13266. "api_bpm_data",
  13267. "Restangular",
  13268. function ($scope, api_bpm_data, Restangular) {
  13269. setTimeout(function () {
  13270. var pkey = $scope.options.templateOptions.pkey;
  13271. var dataId = $scope.model.id;
  13272. api_bpm_data.fetchData(pkey, dataId).then(function (response) {
  13273. if (response) {
  13274. var myData = Restangular.stripRestangular(response);
  13275. var processInstanceId = myData.data.processInstanceId;
  13276. $scope.options.templateOptions
  13277. .getData(
  13278. $scope.model,
  13279. $scope.options.templateOptions.ApiService,
  13280. processInstanceId
  13281. )
  13282. .then(function (result) {
  13283. if (result.status == 200) {
  13284. var newData = Restangular.stripRestangular(result);
  13285. var long = newData.data.length - 1;
  13286. $scope.followData = newData.data[long];
  13287. }
  13288. });
  13289. }
  13290. });
  13291. }, 10);
  13292. },
  13293. ],
  13294. });
  13295. // //请求人信息显示
  13296. // formlyConfigProvider.setType({
  13297. // name: "ui-disrequester",
  13298. // templateUrl: 'assets/views/customform/tpl/ui-disrequester.html',
  13299. // wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  13300. // defaultOptions: function(options) {
  13301. // return {
  13302. // templateOptions: {}
  13303. // };
  13304. // },
  13305. // controller: ['$scope', function($scope) {
  13306. // $scope.options.templateOptions.that = $scope;
  13307. // }]
  13308. // });
  13309. //退回人信息显示
  13310. formlyConfigProvider.setType({
  13311. name: "ui-returnperson",
  13312. templateUrl: "assets/views/customform/tpl/ui-returnperson.html",
  13313. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13314. defaultOptions: function (options) {
  13315. return {
  13316. templateOptions: {},
  13317. };
  13318. },
  13319. controller: [
  13320. "$scope",
  13321. function ($scope) {
  13322. $scope.group = "";
  13323. $scope.role = "";
  13324. if (
  13325. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13326. $scope.model.handlingPersonnelUser.group.length == 1
  13327. ) {
  13328. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13329. } else {
  13330. for (
  13331. var i = 0;
  13332. i < $scope.model.handlingPersonnelUser.group.length;
  13333. i++
  13334. ) {
  13335. $scope.group +=
  13336. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13337. }
  13338. }
  13339. if (
  13340. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13341. $scope.model.handlingPersonnelUser.role.length == 1
  13342. ) {
  13343. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13344. } else {
  13345. for (
  13346. var i = 0;
  13347. i < $scope.model.handlingPersonnelUser.role.length;
  13348. i++
  13349. ) {
  13350. $scope.role +=
  13351. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13352. }
  13353. }
  13354. $scope.options.templateOptions.that = $scope;
  13355. $scope.options.templateOptions.that = $scope;
  13356. },
  13357. ],
  13358. });
  13359. //退回人信息显示(去掉工作组&角色)
  13360. formlyConfigProvider.setType({
  13361. name: "ui-returnpersonNoGroup",
  13362. templateUrl: "assets/views/customform/tpl/ui-returnpersonNoGroup.html",
  13363. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13364. defaultOptions: function (options) {
  13365. return {
  13366. templateOptions: {},
  13367. };
  13368. },
  13369. controller: [
  13370. "$scope",
  13371. function ($scope) {
  13372. $scope.group = "";
  13373. $scope.role = "";
  13374. if (
  13375. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  13376. $scope.model.handlingPersonnelUser.group.length == 1
  13377. ) {
  13378. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  13379. } else {
  13380. for (
  13381. var i = 0;
  13382. i < $scope.model.handlingPersonnelUser.group.length;
  13383. i++
  13384. ) {
  13385. $scope.group +=
  13386. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  13387. }
  13388. }
  13389. if (
  13390. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  13391. $scope.model.handlingPersonnelUser.role.length == 1
  13392. ) {
  13393. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  13394. } else {
  13395. for (
  13396. var i = 0;
  13397. i < $scope.model.handlingPersonnelUser.role.length;
  13398. i++
  13399. ) {
  13400. $scope.role +=
  13401. $scope.model.handlingPersonnelUser.role[i].role + ",";
  13402. }
  13403. }
  13404. $scope.options.templateOptions.that = $scope;
  13405. $scope.options.templateOptions.that = $scope;
  13406. },
  13407. ],
  13408. });
  13409. //指派技术人员
  13410. formlyConfigProvider.setType({
  13411. name: "ui-apiontperson",
  13412. templateUrl: "assets/views/customform/tpl/ui-apiontperson.html",
  13413. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  13414. defaultOptions: function (options) {
  13415. return {
  13416. templateOptions: {
  13417. transtlara: function (value, $scope) { },
  13418. },
  13419. };
  13420. },
  13421. controller: [
  13422. "$scope",
  13423. "api_user_data",
  13424. "Restangular",
  13425. function ($scope, api_user_data, Restangular) {
  13426. var filterData = {
  13427. idx: 0,
  13428. sum: 1000,
  13429. };
  13430. api_user_data
  13431. .fetchDataList("group", filterData)
  13432. .then(function (response) {
  13433. if (response.status == 200) {
  13434. $scope.select = {};
  13435. $scope.multipleDemo = {};
  13436. $scope.userdata = {};
  13437. var data = response.list;
  13438. var item = [];
  13439. $scope.multipleDemo = data;
  13440. $scope.multipleDemo;
  13441. }
  13442. });
  13443. $scope.options.templateOptions.onChange = function (
  13444. id,
  13445. options,
  13446. groupdata,
  13447. $event,
  13448. model
  13449. ) {
  13450. if (groupdata.option) {
  13451. $scope.model[$scope.options.key] = {};
  13452. var fildate = {
  13453. idx: 0,
  13454. sum: 1000,
  13455. user: {
  13456. roledata: {
  13457. rolecode: model.currentRole,
  13458. },
  13459. selectType: "1",
  13460. groupdata: {
  13461. id: groupdata.option.id,
  13462. },
  13463. },
  13464. };
  13465. api_user_data
  13466. .fetchDataList("user", fildate)
  13467. .then(function (response) {
  13468. if (response.status == 200) {
  13469. $scope.userdata = {};
  13470. $scope.userdata = response.list;
  13471. }
  13472. });
  13473. } else {
  13474. $scope.model[$scope.options.key] = {
  13475. id: groupdata.id.id,
  13476. };
  13477. $scope.options.templateOptions.transtlara(
  13478. $scope.model[$scope.options.key],
  13479. $scope
  13480. );
  13481. }
  13482. };
  13483. // }
  13484. },
  13485. ],
  13486. });
  13487. //请求科室信息(小蓝框) lmm
  13488. formlyConfigProvider.setType({
  13489. name: "ui-deptinformation",
  13490. templateUrl: "assets/views/customform/tpl/ui-deptinformation.html",
  13491. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13492. return {
  13493. templateOptions: {
  13494. checkform: function (options) { },
  13495. },
  13496. };
  13497. },
  13498. controller: [
  13499. "$scope",
  13500. "api_statistic",
  13501. function ($scope, api_statistic) {
  13502. // console.log($scope)
  13503. },
  13504. ],
  13505. });
  13506. //请求人信息
  13507. formlyConfigProvider.setType({
  13508. name: "ui-requesterinformation",
  13509. templateUrl: "assets/views/customform/tpl/ui-requesterinformation.html",
  13510. defaultOptions: function (options, $scope, $rootScope, api_statistic) {
  13511. return {
  13512. templateOptions: {
  13513. checkform: function (options) {
  13514. if (options.model.requester) {
  13515. options.value(options.model.requester);
  13516. }
  13517. },
  13518. addRequeter: function (size, options, modal, e) {
  13519. if (e) {
  13520. if (e.clientX === 0) {
  13521. return;
  13522. }
  13523. e.preventDefault();
  13524. }
  13525. var modalInstance = modal.open({
  13526. templateUrl:
  13527. "assets/views/customform/tpl/modal-add-callrequester.html",
  13528. controller: function (
  13529. $scope,
  13530. sco,
  13531. $rootScope,
  13532. $modalInstance,
  13533. items,
  13534. SweetAlert,
  13535. title,
  13536. Restangular,
  13537. APIService,
  13538. UserService,
  13539. api_user_data,
  13540. api_statistic,
  13541. api_wechatfile,
  13542. $stateParams
  13543. ) {
  13544. $modalInstance.SweetAlert = SweetAlert;
  13545. $scope.title = "新增报修人";
  13546. $scope.requester = {};
  13547. $scope.searchData = {};
  13548. $scope.isRoom = sessionStorage.getItem('ifRoom') == 1;
  13549. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  13550. var paramsModel = JSON.parse($stateParams.model)
  13551. //来电-添加报修人-回显电话
  13552. if (paramsModel.model.incident.requester.hjzxPhone) {
  13553. $scope.requester.mphone = paramsModel.model.incident.requester.hjzxPhone;
  13554. }
  13555. }
  13556. $scope.onChangeadd = function (searchData) {
  13557. $scope.searchKey = searchData.account;
  13558. // $scope.searchDataadd = searchData;
  13559. var requesdata = angular.copy(searchData);
  13560. if (requesdata.mphone) {
  13561. delete requesdata.mphone;
  13562. }
  13563. $scope.requester = requesdata;
  13564. console.log($scope.requester);
  13565. };
  13566. $scope.refreshUseradd = function (searchKey) {
  13567. //请求人搜索
  13568. $scope.requester.account = searchKey;
  13569. $scope.searchData = searchKey;
  13570. serchdataadd(searchKey);
  13571. };
  13572. $scope.getMydata = function (x) {
  13573. // $scope.searchField = JSON.parse(x[0]).account;
  13574. // $scope.requester = JSON.parse(x[0]);
  13575. // console.log($scope.requester);
  13576. // $scope.refreshArea('');
  13577. // $scope.refresh('');
  13578. var reqestdatap = JSON.parse(x[0]);
  13579. if ($scope.requester.telephone) {
  13580. delete reqestdatap.telephone;
  13581. }
  13582. $scope.searchField = JSON.parse(x[0]).account;
  13583. angular.extend($scope.requester, reqestdatap);
  13584. // $scope.searchField = JSON.parse(x[0]).account;
  13585. // $scope.requester = JSON.parse(x[0]);
  13586. console.log($scope.requester);
  13587. $scope.refreshArea('');
  13588. $scope.refresh('');
  13589. };
  13590. $scope.getMydataone = function (x) {
  13591. $scope.searchField = x;
  13592. $scope.requester.account = x;
  13593. };
  13594. serchdataadd();
  13595. api_wechatfile
  13596. .getDictionary({
  13597. type: "list",
  13598. key: "male",
  13599. })
  13600. .then(function (data) {
  13601. if (data.status == 200) {
  13602. requester.gender = data.list;
  13603. }
  13604. });
  13605. function serchdataadd(searchKey) {
  13606. if (searchKey) {
  13607. var filterData = {
  13608. requester: {
  13609. searchKey: searchKey,
  13610. },
  13611. idx: 0,
  13612. sum: 10,
  13613. };
  13614. } else {
  13615. var filterData = {
  13616. idx: 0,
  13617. sum: 10,
  13618. };
  13619. }
  13620. api_user_data
  13621. .fetchDataList("requester", filterData)
  13622. .then(function (response) {
  13623. var myData = response;
  13624. $scope.myData = myData.list;
  13625. });
  13626. }
  13627. api_user_data
  13628. .fetchDataList("branch", {
  13629. idx: 0,
  13630. sum: 1000,
  13631. })
  13632. .then(function (response) {
  13633. if (response.status == 200) {
  13634. $scope.branchs = response.list;
  13635. }
  13636. });
  13637. // api_user_data
  13638. // .fetchDataList("area", {
  13639. // idx: 0,
  13640. // sum: 1000,
  13641. // })
  13642. // .then(function (response) {
  13643. // if (response.status == 200) {
  13644. // $scope.areas = response.list;
  13645. // }
  13646. // });
  13647. api_wechatfile
  13648. .getDictionary(
  13649. {
  13650. key: "requester_type",
  13651. type: "list",
  13652. },
  13653. {
  13654. idx: 0,
  13655. sum: 100,
  13656. }
  13657. )
  13658. .then(function (response) {
  13659. if (response) {
  13660. $scope.networktypes = response;
  13661. }
  13662. });
  13663. $scope.onChangeBranch = function (item) {
  13664. delete $scope.requester.place;
  13665. console.log($scope.requester, 'changeArea');
  13666. api_user_data
  13667. .fetchDataList("area", {
  13668. area: {
  13669. branch: item.id,
  13670. },
  13671. idx: 0,
  13672. sum: 1000,
  13673. })
  13674. .then(function (response) {
  13675. if (response.status == 200) {
  13676. $scope.areas = response.list;
  13677. }
  13678. });
  13679. };
  13680. $scope.onChange = function (item) {
  13681. $scope.requester.place = {area: $scope.requester.place.area};
  13682. console.log($scope.requester, 'changeArea');
  13683. api_user_data
  13684. .fetchDataList("place", {
  13685. place: {
  13686. area: {
  13687. id: item.id,
  13688. },
  13689. },
  13690. idx: 0,
  13691. sum: 1000,
  13692. })
  13693. .then(function (response) {
  13694. if (response.status == 200) {
  13695. $scope.places = response.list;
  13696. delete $scope.requester.placeDTO;
  13697. }
  13698. });
  13699. };
  13700. // 修改地点
  13701. $scope.requesterPlaceid = "";
  13702. $scope.onChangePlace = function (item) {
  13703. $scope.requesterPlaceid = item.id;
  13704. console.log($scope.requester, 'changePlace');
  13705. api_user_data
  13706. .fetchDataList("room", {
  13707. room: {
  13708. place: {
  13709. id: item.id,
  13710. },
  13711. },
  13712. idx: 0,
  13713. sum: 1000,
  13714. })
  13715. .then(function (response) {
  13716. if (response.status == 200) {
  13717. $scope.rooms = response.list;
  13718. }
  13719. });
  13720. };
  13721. $scope.refreshArea = function (searchVal) {
  13722. console.log($scope.requester, 'area');
  13723. var faildata = {};
  13724. if ($scope.requester.branch) {
  13725. faildata = {
  13726. idx: 0,
  13727. sum: 1000,
  13728. area: {
  13729. branch: $scope.requester.branch.id,
  13730. area: searchVal,
  13731. selectType: "pinyin_qs",
  13732. },
  13733. };
  13734. } else {
  13735. return;
  13736. }
  13737. api_user_data
  13738. .fetchDataList("area", faildata)
  13739. .then(function (response) {
  13740. $scope.areas = response.list;
  13741. delete $scope.requester.areaDTO;
  13742. });
  13743. };
  13744. $scope.refresh = function (searchVal) {
  13745. console.log($scope.requester, 'place');
  13746. var faildata = {};
  13747. if ($scope.requester.place && $scope.requester.place.area) {
  13748. faildata = {
  13749. idx: 0,
  13750. sum: 1000,
  13751. place: {
  13752. areaId: $scope.requester.place.area.id,
  13753. place: searchVal,
  13754. selectType: "pinyin_qs",
  13755. },
  13756. };
  13757. } else {
  13758. return;
  13759. }
  13760. api_user_data
  13761. .fetchDataList("place", faildata)
  13762. .then(function (response) {
  13763. $scope.places = response.list;
  13764. delete $scope.requester.placeDTO;
  13765. });
  13766. };
  13767. // 初始化房间号
  13768. $scope.refreshRoom = function () {
  13769. var faildata = {};
  13770. if ($scope.requesterPlaceid) {
  13771. faildata = {
  13772. idx: 0,
  13773. sum: 1000,
  13774. room: {
  13775. place: {id:$scope.requesterPlaceid},
  13776. },
  13777. };
  13778. } else {
  13779. faildata = {
  13780. idx: 0,
  13781. sum: 1000,
  13782. room: {
  13783. place: {id:$scope.requesterPlaceid},
  13784. },
  13785. };
  13786. }
  13787. api_user_data
  13788. .fetchDataList("room", faildata)
  13789. .then(function (response) {
  13790. $scope.rooms = response.list;
  13791. });
  13792. };
  13793. $scope.refreshDepts = function (key) {
  13794. var filterData = {
  13795. idx: 0,
  13796. sum: 5,
  13797. dept: {
  13798. name: key,
  13799. },
  13800. };
  13801. UserService.fetchDataList("department", filterData).then(
  13802. function (response) {
  13803. if (response.status == 200) {
  13804. $scope.depts = response.list;
  13805. }
  13806. }
  13807. );
  13808. };
  13809. $scope.ok = function () {
  13810. if (
  13811. angular.isUndefined($scope.requester.account) ||
  13812. $scope.requester.account == null ||
  13813. $scope.requester.account == ""
  13814. ) {
  13815. SweetAlert.swal(
  13816. "报修人员编号未填!",
  13817. "请填写报修人员编号",
  13818. "error"
  13819. );
  13820. } else if (
  13821. angular.isUndefined($scope.requester.name) ||
  13822. $scope.requester.name == null ||
  13823. $scope.requester.name == ""
  13824. ) {
  13825. SweetAlert.swal(
  13826. "报修人姓名未填!",
  13827. "请填写报修人姓名",
  13828. "error"
  13829. );
  13830. } else if (
  13831. angular.isUndefined($scope.requester.requesterType) ||
  13832. $scope.requester.requesterType == null ||
  13833. $scope.requester.requesterTypeDTO == ""
  13834. ) {
  13835. SweetAlert.swal("人员类型未填!", "请填写人员类型", "error");
  13836. } else if (
  13837. angular.isUndefined($scope.requester.mphone) ||
  13838. $scope.requester.mphone == null ||
  13839. $scope.requester.mphone == ""
  13840. ) {
  13841. SweetAlert.swal(
  13842. "报修人联系电话未填!",
  13843. "请填写报修人联系电话",
  13844. "error"
  13845. );
  13846. } else {
  13847. $scope.requesterId = $scope.requester.id;
  13848. var data = {
  13849. incident: {
  13850. requester: {
  13851. id: $scope.requesterId,
  13852. },
  13853. },
  13854. idx: 0,
  13855. sum: 3,
  13856. };
  13857. api_statistic
  13858. .tableData(data, "incident")
  13859. .then(function (data) {
  13860. sco.$parent.$parent.$parent.model.incident.tableList =
  13861. data.list;
  13862. });
  13863. $scope.$watch(
  13864. sco.$parent.$parent.$parent.model.incident.tableList,
  13865. function (oldObj, newObj) {
  13866. if (newObj != oldObj) {
  13867. sco.$parent.$parent.$parent.model.incident.tableList =
  13868. newObj;
  13869. }
  13870. }
  13871. );
  13872. console.log($scope.requester);
  13873. // $modalInstance.close($scope.requester);
  13874. $scope.selectedItemTodo(sco, $scope.requester)
  13875. }
  13876. };
  13877. $scope.selectedItemTodo = function($scope, selectedItem){
  13878. if (selectedItem) {
  13879. var data = {
  13880. requester: selectedItem,
  13881. };
  13882. $scope.searchKey = selectedItem.account;
  13883. // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  13884. // if (selectedItem.place && selectedItem.place.place) {
  13885. // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  13886. // }
  13887. options.templateOptions.UserService.addData(
  13888. "requester",
  13889. data
  13890. ).then(function (response) {
  13891. if (response.status == 200) {
  13892. $modalInstance.dismiss("ok");
  13893. if (options.model) {
  13894. options.model.requester = response.data;
  13895. $scope.$parent.$parent.$parent.model.incident.requester =
  13896. response.data;
  13897. $scope.$parent.$parent.$parent.model.requestershow =
  13898. response.data;
  13899. if (options.model.place) {
  13900. options.model.place.id = "";
  13901. }
  13902. if (options.model.area) {
  13903. options.model.area.id = "";
  13904. }
  13905. options.model.contacts = selectedItem.name;
  13906. if (
  13907. selectedItem.mphone &&
  13908. selectedItem.mphone != null &&
  13909. selectedItem.mphone != ""
  13910. ) {
  13911. options.model.contactsInformation =
  13912. selectedItem.mphone;
  13913. } else {
  13914. options.model.contactsInformation =
  13915. selectedItem.telephone;
  13916. }
  13917. if (
  13918. selectedItem.requesterTypeDTO &&
  13919. selectedItem.requesterTypeDTO.id == 2
  13920. ) {
  13921. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  13922. // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  13923. // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  13924. }
  13925. }
  13926. if (!response.data.id) {
  13927. response.data.id = selectedItem.id;
  13928. }
  13929. options.value(response.data);
  13930. options.value(response.data);
  13931. console.log($scope, "0000000");
  13932. //新增报修人带入区域地点2020年4月23日19:48:15
  13933. $scope.model.selecthouseNumber = selectedItem.place
  13934. ? selectedItem.place
  13935. : {};
  13936. $scope.$root.selecthouseNumber = selectedItem.place
  13937. ? selectedItem.place
  13938. : {};
  13939. if ($scope.$parent.$parent.$parent.model.saveAgain) {
  13940. if (selectedItem.place && selectedItem.place.id) {
  13941. options.model.place.id = selectedItem.place.id;
  13942. options.model.place.area.id = selectedItem.place.area.id;
  13943. if(selectedItem.branch && selectedItem.branch.id){
  13944. options.model.branch.id = selectedItem.branch.id;
  13945. console.log($scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields);
  13946. let fields = $scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields;
  13947. for (let i = 0; i < fields.length; i++) {
  13948. if(fields[i].templateOptions.onlyKey == 'area_start'){
  13949. // 如果是区域
  13950. options.templateOptions.UserService.fetchDataList('area', { idx: 0, sum: 1000, area:{branch:options.model.branch.id} }).then(function(response) {
  13951. if (response.status == 200) {
  13952. fields[i].templateOptions.options = response.list;
  13953. }
  13954. })
  13955. }else if(fields[i].templateOptions.onlyKey == 'place_start'){
  13956. // 如果是地点
  13957. options.templateOptions.UserService.fetchDataList('place', { idx: 0, sum: 1000, place:{area:{id:options.model.area.id}} }).then(function(response) {
  13958. if (response.status == 200) {
  13959. fields[i].templateOptions.options = response.list;
  13960. }
  13961. })
  13962. }
  13963. }
  13964. }
  13965. }
  13966. } else {
  13967. if (selectedItem.place && selectedItem.place.id) {
  13968. options.model.place.id = selectedItem.place.id;
  13969. options.model.area.id = selectedItem.place.area.id;
  13970. if(selectedItem.branch && selectedItem.branch.id){
  13971. options.model.branch.id = selectedItem.branch.id;
  13972. console.log($scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields);
  13973. let fields = $scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields;
  13974. for (let i = 0; i < fields.length; i++) {
  13975. if(fields[i].templateOptions.onlyKey == 'area_start'){
  13976. // 如果是区域
  13977. options.templateOptions.UserService.fetchDataList('area', { idx: 0, sum: 1000, area:{branch:options.model.branch.id} }).then(function(response) {
  13978. if (response.status == 200) {
  13979. fields[i].templateOptions.options = response.list;
  13980. }
  13981. })
  13982. }else if(fields[i].templateOptions.onlyKey == 'place_start'){
  13983. // 如果是地点
  13984. options.templateOptions.UserService.fetchDataList('place', { idx: 0, sum: 1000, place:{area:{id:options.model.area.id}} }).then(function(response) {
  13985. if (response.status == 200) {
  13986. fields[i].templateOptions.options = response.list;
  13987. }
  13988. })
  13989. }
  13990. }
  13991. }
  13992. }
  13993. }
  13994. // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  13995. // options.model.area.id = selectedItem.place.area.id
  13996. // }
  13997. if (selectedItem.houseNumber) {
  13998. options.model.houseNumber = selectedItem.houseNumber;
  13999. }
  14000. if (selectedItem.room) {
  14001. options.model.room.id = selectedItem.room.id;
  14002. }
  14003. // if (selectedItem.id) {
  14004. options.model.account = selectedItem.account;
  14005. // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  14006. var baoxiuFields =
  14007. $scope.$parent.$parent.$parent.$parent.$parent.vm
  14008. .fields[1].fields;
  14009. var baoxiurenTo;
  14010. baoxiuFields.forEach((e, i) => {
  14011. if (e.key == "account") {
  14012. baoxiurenTo = e.templateOptions;
  14013. baoxiurenTo.APIService.fetchDataList("requester", {
  14014. idx: 0,
  14015. sum: 20,
  14016. requester: {
  14017. searchKey: selectedItem.account,
  14018. },
  14019. }).then((res) => {
  14020. baoxiurenTo.options = res.list;
  14021. options.model.account = selectedItem.account;
  14022. });
  14023. }
  14024. });
  14025. // }
  14026. // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  14027. // 选择重复事件侧滑框
  14028. // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  14029. $scope.$parent.$parent.$parent.model[
  14030. "repeatIncidentShow"
  14031. ] = false;
  14032. setTimeout(() => {
  14033. $scope.$parent.$parent.$parent.model[
  14034. "repeatIncidentShow"
  14035. ] = true;
  14036. }, 500);
  14037. // }
  14038. } else {
  14039. modalInstance.SweetAlert.swal({
  14040. title: "系统错误",
  14041. text: "账号重复!",
  14042. type: "error",
  14043. });
  14044. }
  14045. });
  14046. }
  14047. }
  14048. $scope.cancel = function () {
  14049. $modalInstance.dismiss("cancel");
  14050. };
  14051. },
  14052. resolve: {
  14053. items: function () {
  14054. return {
  14055. fetchItems: function (filterData, APIService) {
  14056. filterData = filterData || {};
  14057. if (!filterData.idx) {
  14058. filterData = {
  14059. idx: 0,
  14060. sum: 10,
  14061. };
  14062. }
  14063. return options.templateOptions.fetchItems(
  14064. filterData,
  14065. APIService
  14066. );
  14067. },
  14068. };
  14069. },
  14070. title: function () {
  14071. return options.templateOptions.modalTitle;
  14072. },
  14073. Restangular: function () {
  14074. return options.templateOptions.Restangular;
  14075. },
  14076. APIService: function () {
  14077. return options.templateOptions.ApiService;
  14078. },
  14079. UserService: function () {
  14080. return options.templateOptions.UserService;
  14081. },
  14082. sco: function () {
  14083. return $scope;
  14084. },
  14085. },
  14086. });
  14087. // modalInstance.result.then(
  14088. // function (selectedItem) {
  14089. // console.log(selectedItem);
  14090. // if (selectedItem) {
  14091. // var data = {
  14092. // requester: selectedItem,
  14093. // };
  14094. // $scope.searchKey = selectedItem.account;
  14095. // // $scope.$parent.$parent.$parent.model['requestershow'] = selectedItem;
  14096. // // if (selectedItem.place && selectedItem.place.place) {
  14097. // // $scope.$parent.$parent.$parent.model.incident.houseNumber = selectedItem.place.area.area + selectedItem.place.place
  14098. // // }
  14099. // options.templateOptions.UserService.addData(
  14100. // "requester",
  14101. // data
  14102. // ).then(function (response) {
  14103. // if (response.status == 200) {
  14104. // if (options.model) {
  14105. // options.model.requester = response.data;
  14106. // $scope.$parent.$parent.$parent.model.incident.requester =
  14107. // response.data;
  14108. // $scope.$parent.$parent.$parent.model.requestershow =
  14109. // response.data;
  14110. // if (options.model.place) {
  14111. // options.model.place.id = "";
  14112. // }
  14113. // if (options.model.area) {
  14114. // options.model.area.id = "";
  14115. // }
  14116. // options.model.contacts = selectedItem.name;
  14117. // if (
  14118. // selectedItem.mphone &&
  14119. // selectedItem.mphone != null &&
  14120. // selectedItem.mphone != ""
  14121. // ) {
  14122. // options.model.contactsInformation =
  14123. // selectedItem.mphone;
  14124. // } else {
  14125. // options.model.contactsInformation =
  14126. // selectedItem.telephone;
  14127. // }
  14128. // if (
  14129. // selectedItem.requesterTypeDTO &&
  14130. // selectedItem.requesterTypeDTO.id == 2
  14131. // ) {
  14132. // $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14133. // // $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14134. // // $scope.$parent.$parent.$parent.model.incident.influence.id = 1
  14135. // }
  14136. // }
  14137. // if (!response.data.id) {
  14138. // response.data.id = selectedItem.id;
  14139. // }
  14140. // options.value(response.data);
  14141. // options.value(response.data);
  14142. // console.log($scope, "0000000");
  14143. // //新增报修人带入区域地点2020年4月23日19:48:15
  14144. // $scope.model.selecthouseNumber = selectedItem.place
  14145. // ? selectedItem.place
  14146. // : {};
  14147. // $scope.$root.selecthouseNumber = selectedItem.place
  14148. // ? selectedItem.place
  14149. // : {};
  14150. // if ($scope.$parent.$parent.$parent.model.saveAgain) {
  14151. // if (selectedItem.place && selectedItem.place.id) {
  14152. // options.model.place.id = selectedItem.place.id;
  14153. // options.model.place.area.id = selectedItem.place.area.id;
  14154. // if(selectedItem.branch && selectedItem.branch.id){
  14155. // options.model.branch.id = selectedItem.branch.id;
  14156. // console.log($scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields);
  14157. // let fields = $scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields;
  14158. // for (let i = 0; i < fields.length; i++) {
  14159. // if(fields[i].templateOptions.onlyKey == 'area_start'){
  14160. // // 如果是区域
  14161. // options.templateOptions.UserService.fetchDataList('area', { idx: 0, sum: 1000, area:{branch:options.model.branch.id} }).then(function(response) {
  14162. // if (response.status == 200) {
  14163. // fields[i].templateOptions.options = response.list;
  14164. // }
  14165. // })
  14166. // }else if(fields[i].templateOptions.onlyKey == 'place_start'){
  14167. // // 如果是地点
  14168. // options.templateOptions.UserService.fetchDataList('place', { idx: 0, sum: 1000, place:{area:{id:options.model.area.id}} }).then(function(response) {
  14169. // if (response.status == 200) {
  14170. // fields[i].templateOptions.options = response.list;
  14171. // }
  14172. // })
  14173. // }
  14174. // }
  14175. // }
  14176. // }
  14177. // } else {
  14178. // if (selectedItem.place && selectedItem.place.id) {
  14179. // options.model.place.id = selectedItem.place.id;
  14180. // options.model.area.id = selectedItem.place.area.id;
  14181. // if(selectedItem.branch && selectedItem.branch.id){
  14182. // options.model.branch.id = selectedItem.branch.id;
  14183. // console.log($scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields);
  14184. // let fields = $scope.$parent.$parent.$parent.$parent.$parent.formData.fields[1].fields;
  14185. // for (let i = 0; i < fields.length; i++) {
  14186. // if(fields[i].templateOptions.onlyKey == 'area_start'){
  14187. // // 如果是区域
  14188. // options.templateOptions.UserService.fetchDataList('area', { idx: 0, sum: 1000, area:{branch:options.model.branch.id} }).then(function(response) {
  14189. // if (response.status == 200) {
  14190. // fields[i].templateOptions.options = response.list;
  14191. // }
  14192. // })
  14193. // }else if(fields[i].templateOptions.onlyKey == 'place_start'){
  14194. // // 如果是地点
  14195. // options.templateOptions.UserService.fetchDataList('place', { idx: 0, sum: 1000, place:{area:{id:options.model.area.id}} }).then(function(response) {
  14196. // if (response.status == 200) {
  14197. // fields[i].templateOptions.options = response.list;
  14198. // }
  14199. // })
  14200. // }
  14201. // }
  14202. // }
  14203. // }
  14204. // }
  14205. // // if (selectedItem.areaDTO && selectedItem.place.area.id) {
  14206. // // options.model.area.id = selectedItem.place.area.id
  14207. // // }
  14208. // if (selectedItem.houseNumber) {
  14209. // options.model.houseNumber = selectedItem.houseNumber;
  14210. // }
  14211. // if (selectedItem.room) {
  14212. // options.model.room.id = selectedItem.room.id;
  14213. // }
  14214. // // if (selectedItem.id) {
  14215. // options.model.account = selectedItem.account;
  14216. // // 找到表单报修人组件,并使用组件内部方法重新获取增加报修人后的报修人下拉选项
  14217. // var baoxiuFields =
  14218. // $scope.$parent.$parent.$parent.$parent.$parent.vm
  14219. // .fields[1].fields;
  14220. // var baoxiurenTo;
  14221. // baoxiuFields.forEach((e, i) => {
  14222. // if (e.key == "account") {
  14223. // baoxiurenTo = e.templateOptions;
  14224. // baoxiurenTo.APIService.fetchDataList("requester", {
  14225. // idx: 0,
  14226. // sum: 20,
  14227. // requester: {
  14228. // searchKey: selectedItem.account,
  14229. // },
  14230. // }).then((res) => {
  14231. // baoxiurenTo.options = res.list;
  14232. // options.model.account = selectedItem.account;
  14233. // });
  14234. // }
  14235. // });
  14236. // // }
  14237. // // $scope.$parent.$parent.$parent.model.incident.requester = selectedItem
  14238. // // 选择重复事件侧滑框
  14239. // // if ($scope.$parent.$parent.$parent.model.incident.category && $scope.$parent.$parent.$parent.model.incident.category.id) {
  14240. // $scope.$parent.$parent.$parent.model[
  14241. // "repeatIncidentShow"
  14242. // ] = false;
  14243. // setTimeout(() => {
  14244. // $scope.$parent.$parent.$parent.model[
  14245. // "repeatIncidentShow"
  14246. // ] = true;
  14247. // }, 500);
  14248. // // }
  14249. // } else {
  14250. // modalInstance.SweetAlert.swal({
  14251. // title: "系统错误",
  14252. // text: "账号重复!",
  14253. // type: "error",
  14254. // });
  14255. // }
  14256. // });
  14257. // }
  14258. // },
  14259. // function () { }
  14260. // );
  14261. },
  14262. changeRequeter: function (
  14263. size,
  14264. options,
  14265. modal,
  14266. modeldata,
  14267. $rootScope
  14268. ) {
  14269. var modalInstance = modal.open({
  14270. templateUrl:
  14271. "assets/views/customform/tpl/modal-change-requester.html",
  14272. controller: function (
  14273. $scope,
  14274. $modalInstance,
  14275. items,
  14276. SweetAlert,
  14277. title,
  14278. Restangular,
  14279. APIService,
  14280. UserService,
  14281. api_user_data,
  14282. $rootScope
  14283. ) {
  14284. $scope.title = "修改报修人";
  14285. $scope.requester = {
  14286. id: modeldata.requester.id,
  14287. account: modeldata.requester.account,
  14288. name: modeldata.requester.name,
  14289. gender: modeldata.requester.gender,
  14290. email: modeldata.requester.email,
  14291. deptName: modeldata.requester.deptName,
  14292. mphone: modeldata.requester.mphone,
  14293. telephone: modeldata.requester.telephone,
  14294. studentNo: modeldata.requester.studentNo,
  14295. areaDTO: modeldata.requester.areaDTO,
  14296. placeDTO: modeldata.requester.placeDTO,
  14297. requesterTypeDTO: modeldata.requester.requesterTypeDTO,
  14298. };
  14299. $scope.onChangeadd = function (searchData) {
  14300. console.log(searchData);
  14301. $scope.searchKey = searchData.account;
  14302. var requesdata = angular.copy(searchData);
  14303. if (requesdata.mphone) {
  14304. delete requesdata.mphone;
  14305. }
  14306. $scope.requester = requesdata;
  14307. };
  14308. $scope.refreshUseradd = function (searchKey) {
  14309. //请求人搜索
  14310. $scope.requester.account = searchKey;
  14311. $scope.searchData = searchKey;
  14312. serchdataadd(searchKey);
  14313. };
  14314. $scope.getMydata = function (x) {
  14315. $scope.searchField = JSON.parse(x[0]).account;
  14316. $scope.requester = JSON.parse(x[0]);
  14317. };
  14318. $scope.getMydataone = function (x) {
  14319. $scope.searchField = x;
  14320. $scope.requester.account = x;
  14321. };
  14322. serchdataadd();
  14323. function serchdataadd(searchKey) {
  14324. if (searchKey) {
  14325. var filterData = {
  14326. requester: {
  14327. searchKey: searchKey,
  14328. },
  14329. idx: 0,
  14330. sum: 10,
  14331. };
  14332. } else {
  14333. var filterData = {
  14334. idx: 0,
  14335. sum: 10,
  14336. };
  14337. }
  14338. api_user_data
  14339. .fetchDataList("requester", filterData)
  14340. .then(function (response) {
  14341. var myData = response;
  14342. $scope.myData = myData.list;
  14343. });
  14344. }
  14345. api_user_data
  14346. .fetchDataList("area", {
  14347. idx: 0,
  14348. sum: 1000,
  14349. })
  14350. .then(function (response) {
  14351. if (response.status == 200) {
  14352. $scope.areas = response.list;
  14353. }
  14354. });
  14355. api_user_data
  14356. .fetchDataList("requesterType", {
  14357. idx: 0,
  14358. sum: 100,
  14359. })
  14360. .then(function (response) {
  14361. if (response.status == 200) {
  14362. $scope.networktypes = response.list;
  14363. }
  14364. });
  14365. if (
  14366. $scope.requester.areaDTO &&
  14367. $scope.requester.areaDTO.id &&
  14368. $scope.requester.areaDTO.id != ""
  14369. ) {
  14370. api_user_data
  14371. .fetchDataList("place", {
  14372. place: {
  14373. areaId: $scope.requester.areaDTO.id,
  14374. },
  14375. idx: 0,
  14376. sum: 1000,
  14377. })
  14378. .then(function (response) {
  14379. if (response.status == 200) {
  14380. $scope.places = response.list;
  14381. }
  14382. });
  14383. }
  14384. $scope.onChange = function (item) {
  14385. $scope.requester.placeDTO = {};
  14386. api_user_data
  14387. .fetchDataList("place", {
  14388. place: {
  14389. areaId: item.id,
  14390. },
  14391. idx: 0,
  14392. sum: 1000,
  14393. })
  14394. .then(function (response) {
  14395. if (response.status == 200) {
  14396. $scope.places = response.list;
  14397. }
  14398. });
  14399. };
  14400. $scope.refreshDepts = function (key) {
  14401. var filterData = {
  14402. idx: 0,
  14403. sum: 5,
  14404. dept: {
  14405. name: key,
  14406. },
  14407. };
  14408. UserService.fetchDataList("department", filterData).then(
  14409. function (response) {
  14410. if (response.status == 200) {
  14411. $scope.depts = response.list;
  14412. }
  14413. }
  14414. );
  14415. };
  14416. $scope.ok = function () {
  14417. if (
  14418. $scope.requester.account == "" ||
  14419. $scope.requester.name == ""
  14420. ) {
  14421. SweetAlert.swal(
  14422. "报修人姓名或人员编号号未填!",
  14423. "请补全报修人信息",
  14424. "error"
  14425. );
  14426. } else {
  14427. $modalInstance.close($scope.requester);
  14428. }
  14429. };
  14430. $scope.cancel = function () {
  14431. $modalInstance.dismiss("cancel");
  14432. };
  14433. },
  14434. resolve: {
  14435. items: function () {
  14436. return {
  14437. fetchItems: function (filterData, APIService) {
  14438. filterData = filterData || {};
  14439. if (!filterData.idx) {
  14440. filterData = {
  14441. idx: 0,
  14442. sum: 10,
  14443. };
  14444. }
  14445. return options.templateOptions.fetchItems(
  14446. filterData,
  14447. APIService
  14448. );
  14449. },
  14450. };
  14451. },
  14452. title: function () {
  14453. return options.templateOptions.modalTitle;
  14454. },
  14455. Restangular: function () {
  14456. return options.templateOptions.Restangular;
  14457. },
  14458. APIService: function () {
  14459. return options.templateOptions.ApiService;
  14460. },
  14461. UserService: function () {
  14462. return options.templateOptions.UserService;
  14463. },
  14464. },
  14465. });
  14466. modalInstance.result.then(
  14467. function (selectedItem) {
  14468. console.log(selectedItem);
  14469. if (selectedItem) {
  14470. if (options.model) {
  14471. if (options.model.place) {
  14472. options.model.place.id = "";
  14473. }
  14474. if (options.model.area) {
  14475. options.model.area.id = "";
  14476. }
  14477. options.model.contacts = selectedItem.name;
  14478. if (
  14479. selectedItem.mphone &&
  14480. selectedItem.mphone != null &&
  14481. selectedItem.mphone != ""
  14482. ) {
  14483. options.model.contactsInformation = selectedItem.mphone;
  14484. } else {
  14485. options.model.contactsInformation =
  14486. selectedItem.telephone;
  14487. }
  14488. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14489. options.model.place.id = selectedItem.placeDTO.id;
  14490. }
  14491. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14492. options.model.area.id = selectedItem.areaDTO.id;
  14493. }
  14494. if (
  14495. selectedItem.requesterTypeDTO &&
  14496. selectedItem.requesterTypeDTO.id == 2
  14497. ) {
  14498. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14499. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14500. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14501. }
  14502. }
  14503. var data = {
  14504. requester: selectedItem,
  14505. };
  14506. options.templateOptions.UserService.addData(
  14507. "requester",
  14508. data
  14509. ).then(function (response) {
  14510. if (response.status == 200) {
  14511. $scope.$parent.$parent.$parent.model["requestershow"] =
  14512. selectedItem;
  14513. options.value(response.data);
  14514. } else {
  14515. }
  14516. });
  14517. }
  14518. },
  14519. function () { }
  14520. );
  14521. event.preventDefault();
  14522. },
  14523. },
  14524. };
  14525. },
  14526. controller: [
  14527. "$scope",
  14528. "api_user_data",
  14529. "api_statistic",
  14530. "$stateParams",
  14531. "api_bpm_data",
  14532. function ($scope, api_user_data, api_statistic, $stateParams,api_bpm_data) {
  14533. console.log($stateParams)
  14534. // 一键复制
  14535. $scope.quickCopy = function(model){
  14536. // 姓名,工号,来电电话,地点,详细地址,事件描述 liaomingming
  14537. console.log(model);
  14538. var text = '';
  14539. if(model.place.id){
  14540. api_bpm_data.fetchData("place", model.place.id)
  14541. .then(function (response) {
  14542. if (response.status == 200) {
  14543. text = `姓名:${model.requester?(model.requester.name||''):''}\r\n工号:${model.requester?(model.requester.account||''):''}\r\n来电电话:${model.requester?(model.requester.telephone||''):''}\r\n地点:${response.data.place||''}\r\n详细地址:${model.houseNumber||''}\r\n事件描述:${model.description||''}`;
  14544. var textarea = document.createElement('textarea');
  14545. document.body.appendChild(textarea);
  14546. // 隐藏此输入框
  14547. textarea.style.position = 'fixed';
  14548. textarea.style.clip = 'rect(0 0 0 0)';
  14549. textarea.style.top = '10px';
  14550. // 赋值
  14551. textarea.value = text;
  14552. // 选中
  14553. textarea.select();
  14554. // 复制
  14555. document.execCommand('copy', true);
  14556. // 移除输入框
  14557. document.body.removeChild(textarea);
  14558. }
  14559. });
  14560. }else{
  14561. text = `姓名:${model.requester?(model.requester.name||''):''}\r\n工号:${model.requester?(model.requester.account||''):''}\r\n来电电话:${model.requester?(model.requester.telephone||''):''}\r\n地点:${''}\r\n详细地址:${model.houseNumber||''}\r\n事件描述:${model.description||''}`;
  14562. var textarea = document.createElement('textarea');
  14563. document.body.appendChild(textarea);
  14564. // 隐藏此输入框
  14565. textarea.style.position = 'fixed';
  14566. textarea.style.clip = 'rect(0 0 0 0)';
  14567. textarea.style.top = '10px';
  14568. // 赋值
  14569. textarea.value = text;
  14570. // 选中
  14571. textarea.select();
  14572. // 复制
  14573. document.execCommand('copy', true);
  14574. // 移除输入框
  14575. document.body.removeChild(textarea);
  14576. }
  14577. event.preventDefault();
  14578. //提示
  14579. // alert('复制成功');
  14580. }
  14581. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  14582. var paramsModel = JSON.parse($stateParams.model)
  14583. //来电-添加报修人
  14584. if (paramsModel.model.incident.requester.hjzxPhone) {
  14585. $scope.options.templateOptions['addRequeter']('lg', $scope.options, $scope.to.modal);
  14586. }
  14587. }
  14588. $scope.options.initialValue = $scope.model[$scope.options.key];
  14589. $scope.saveReqPlace = false;
  14590. $scope.model.saveReqPlace = false;
  14591. $scope.selectGradeBox = function () {
  14592. $scope.saveReqPlace = !$scope.saveReqPlace;
  14593. console.log($scope);
  14594. $scope.model.saveReqPlace = $scope.saveReqPlace;
  14595. };
  14596. if (
  14597. $scope.model.requester &&
  14598. $scope.model.requester.requesterTypeDTO &&
  14599. $scope.model.requester.requesterTypeDTO.id == 2
  14600. ) {
  14601. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14602. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14603. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14604. }
  14605. },
  14606. ],
  14607. });
  14608. // 请求人选控件
  14609. formlyConfigProvider.setType({
  14610. name: "ui-requesterselect",
  14611. templateUrl: "assets/views/customform/tpl/ui-requester.html",
  14612. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  14613. defaultOptions: function (options, $scope) {
  14614. return {
  14615. templateOptions: {
  14616. // checkform: function(options) {
  14617. // if (options.model.requestershow) {
  14618. // options.value(options.model.requestershow);
  14619. // }
  14620. // },
  14621. validators: {
  14622. required: {
  14623. expression: function (viewValue, modelValue) {
  14624. var value = modelValue || viewValue;
  14625. return value.length >= 1;
  14626. },
  14627. },
  14628. },
  14629. openModal: function (size, options, modal) {
  14630. //查找弹出框
  14631. var modelObject = options.value();
  14632. var searchModal = function (filterSearchData) {
  14633. var modalInstance = modal.open({
  14634. templateUrl:
  14635. "assets/views/customform/tpl/checktable-modal-content.html",
  14636. controller: function (
  14637. $scope,
  14638. scope,
  14639. i18nService,
  14640. $modalInstance,
  14641. items,
  14642. title,
  14643. Restangular,
  14644. APIService,
  14645. language,
  14646. searchDatas,
  14647. api_bpm_data
  14648. ) {
  14649. $scope.langs = i18nService.getAllLangs();
  14650. $scope.lang = "zh-cn";
  14651. i18nService.setCurrentLang($scope.lang);
  14652. $scope.gridOptions = {};
  14653. $scope.gridOptions.data = "myData";
  14654. $scope.gridOptions.enableColumnResizing = true;
  14655. $scope.gridOptions.enableFiltering = true;
  14656. $scope.gridOptions.enableGridMenu = false;
  14657. $scope.gridOptions.enableRowSelection = true;
  14658. $scope.gridOptions.showGridFooter = true;
  14659. $scope.gridOptions.showColumnFooter = false;
  14660. $scope.gridOptions.fastWatch = true;
  14661. $scope.gridOptions.useExternalFiltering = true;
  14662. $scope.gridOptions.useExternalPagination = true;
  14663. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  14664. $scope.gridOptions.paginationPageSize = 10;
  14665. $scope.gridOptions.multiSelect = false;
  14666. $scope.gridOptions.rowIdentity = function (row) {
  14667. return row.id;
  14668. };
  14669. $scope.gridOptions.getRowIdentity = function (row) {
  14670. return row.id;
  14671. };
  14672. $scope.gridOptions.columnDefs = [
  14673. {
  14674. name: "account",
  14675. displayName: "人员编号",
  14676. width: 140,
  14677. },
  14678. {
  14679. name: "name",
  14680. displayName: "姓名",
  14681. width: 100,
  14682. },
  14683. {
  14684. name: "gender.name",
  14685. displayName: "性别",
  14686. width: 80,
  14687. enableFiltering: false,
  14688. },
  14689. {
  14690. name: "mphone",
  14691. displayName: "电话",
  14692. width: 100,
  14693. enableFiltering: false,
  14694. },
  14695. {
  14696. name: "email",
  14697. displayName: "邮件",
  14698. width: 100,
  14699. },
  14700. {
  14701. name: "areaDTO.area",
  14702. displayName: "区域",
  14703. width: 100,
  14704. enableFiltering: false,
  14705. },
  14706. {
  14707. name: "placeDTO.place",
  14708. displayName: "地点",
  14709. enableFiltering: false,
  14710. },
  14711. ];
  14712. $scope.gridOptions.onRegisterApi = function (gridApi) {
  14713. $scope.gridApi = gridApi;
  14714. // var filtersData = $scope.memoryfilterData;
  14715. // filtersData.idx = newPage - 1;
  14716. // filtersData.sum = pageSize;
  14717. gridApi.pagination.on.paginationChanged(
  14718. $scope,
  14719. function (newPage, pageSize) {
  14720. var filtersData = $scope.memoryfilterData;
  14721. filtersData.idx = newPage - 1;
  14722. filtersData.sum = pageSize;
  14723. $scope.loadData(filtersData);
  14724. }
  14725. );
  14726. gridApi.selection.on.rowSelectionChanged(
  14727. $scope,
  14728. function (data) {
  14729. // if(angular.isDefined(data.entity.account)&&data.entity.account.length==6){
  14730. $scope.selected.item = data.entity;
  14731. // }else{alert ("工号格式不对,账号应为6位数,请重新填写!")}
  14732. }
  14733. );
  14734. gridApi.core.on.filterChanged($scope, function () {
  14735. var grid = this.grid;
  14736. var filtersData = {
  14737. idx: 0,
  14738. sum: 10,
  14739. // 'requester': { 'userType': 1 }
  14740. };
  14741. angular.forEach(grid.columns, function (item) {
  14742. if (item.enableFiltering) {
  14743. if (
  14744. angular.isDefined(item.filters[0].term) &&
  14745. item.filters[0].term != ""
  14746. ) {
  14747. if (angular.isUndefined(filtersData["requester"])) {
  14748. filtersData["requester"] = {};
  14749. }
  14750. filtersData["requester"][item.field] =
  14751. item.filters[0].term;
  14752. }
  14753. }
  14754. });
  14755. $scope.memoryfilterData = filtersData;
  14756. $scope.loadData(filtersData);
  14757. });
  14758. };
  14759. $scope.memoryfilterData = defaultFilterData = {
  14760. idx: 0,
  14761. sum: 10,
  14762. };
  14763. $scope.loadData = function (filterData) {
  14764. if (!filterData.requester) {
  14765. filterData.requester = {};
  14766. }
  14767. if (scope.roleidcode) {
  14768. angular.extend(filterData["requester"], {
  14769. userType: 1,
  14770. });
  14771. }
  14772. items
  14773. .fetchItems(filterData, APIService)
  14774. .then(function (data) {
  14775. var myData = Restangular.stripRestangular(data);
  14776. $scope.gridOptions.totalItems = myData.totalNum;
  14777. $scope.myData = myData.list;
  14778. });
  14779. };
  14780. // $scope.title = title;
  14781. if (searchDatas) {
  14782. $scope.loadData(searchDatas);
  14783. } else {
  14784. $scope.loadData({
  14785. idx: 0,
  14786. sum: 10,
  14787. });
  14788. }
  14789. $scope.selected = {
  14790. item: {},
  14791. };
  14792. $scope.ok = function () {
  14793. $modalInstance.close($scope.selected.item);
  14794. };
  14795. $scope.cancel = function () {
  14796. $modalInstance.dismiss("cancel");
  14797. };
  14798. },
  14799. size: size,
  14800. resolve: {
  14801. items: function () {
  14802. return {
  14803. fetchItems: function (filterData, APIService) {
  14804. filterData = filterData || {};
  14805. if (
  14806. angular.isUndefined(filterData.idx) ||
  14807. filterData.idx == null
  14808. ) {
  14809. filterData = {
  14810. idx: 0,
  14811. sum: 10,
  14812. };
  14813. }
  14814. return options.templateOptions.fetchItems(
  14815. filterData,
  14816. APIService
  14817. );
  14818. },
  14819. };
  14820. },
  14821. title: function () {
  14822. return options.templateOptions.modalTitle;
  14823. },
  14824. Restangular: function () {
  14825. return options.templateOptions.Restangular;
  14826. },
  14827. APIService: function () {
  14828. return options.templateOptions.ApiService;
  14829. },
  14830. language: function () {
  14831. return options.templateOptions.language;
  14832. },
  14833. searchDatas: function () {
  14834. return filterSearchData;
  14835. },
  14836. scope: function () {
  14837. return $scope;
  14838. },
  14839. },
  14840. });
  14841. modalInstance.result.then(
  14842. function (selectedItem) {
  14843. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  14844. selectedItem.telephone =
  14845. $scope.model.incident.contactsInformation;
  14846. }
  14847. $scope.$parent.$parent.$parent.model.incident["requester"] =
  14848. selectedItem;
  14849. // $scope.$parent.$parent.$parent.model.incident['requester'] = angular.copy(selectedItem)
  14850. // delete $scope.$parent.$parent.$parent.model.incident.requester.telephone;
  14851. if ($scope.model) {
  14852. if ($scope.model.incident.place) {
  14853. $scope.model.incident.place.id = "";
  14854. }
  14855. if ($scope.model.area) {
  14856. $scope.model.incident.area.id = "";
  14857. }
  14858. $scope.model.incident.contacts = selectedItem.name;
  14859. if (
  14860. selectedItem.mphone &&
  14861. selectedItem.mphone != null &&
  14862. selectedItem.mphone != ""
  14863. ) {
  14864. $scope.model.incident.contactsInformation =
  14865. selectedItem.mphone;
  14866. } else {
  14867. $scope.model.incident.contactsInformation =
  14868. selectedItem.telephone;
  14869. }
  14870. $scope.model.incident.houseNumber = "";
  14871. if (
  14872. selectedItem.requesterTypeDTO &&
  14873. selectedItem.requesterTypeDTO.id == 2
  14874. ) {
  14875. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14876. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14877. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14878. }
  14879. }
  14880. $scope.options.value(selectedItem);
  14881. $scope.searchData = selectedItem.account;
  14882. if (selectedItem.placeDTO && selectedItem.placeDTO.id) {
  14883. $scope.model.incident.place.id = selectedItem.placeDTO.id;
  14884. }
  14885. if (selectedItem.areaDTO && selectedItem.areaDTO.id) {
  14886. $scope.model.incident.area.id = selectedItem.areaDTO.id;
  14887. }
  14888. if (selectedItem.houseNumber) {
  14889. $scope.model.incident.houseNumber =
  14890. selectedItem.houseNumber;
  14891. }
  14892. if (
  14893. selectedItem.requesterTypeDTO &&
  14894. selectedItem.requesterTypeDTO.id == 2
  14895. ) {
  14896. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  14897. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  14898. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  14899. }
  14900. if (
  14901. options.templateOptions.callback &&
  14902. angular.isFunction(options.templateOptions.callback)
  14903. ) {
  14904. options.templateOptions.callback(selectedItem, options);
  14905. }
  14906. if (!$scope.roleidcode) {
  14907. $scope.charging(selectedItem, modal);
  14908. }
  14909. $scope.recentlyincident(selectedItem);
  14910. },
  14911. function () {
  14912. //console.log('Modal dismissed at: ' + new Date());
  14913. }
  14914. );
  14915. };
  14916. searchModal();
  14917. // }
  14918. },
  14919. },
  14920. };
  14921. },
  14922. controller: [
  14923. "$rootScope",
  14924. "$scope",
  14925. "ngTableParams",
  14926. "$filter",
  14927. "SweetAlert",
  14928. "moment",
  14929. function (
  14930. $rootScope,
  14931. $scope,
  14932. ngTableParams,
  14933. $filter,
  14934. SweetAlert,
  14935. moment
  14936. ) {
  14937. // $scope.isHk = $rootScope.isHk;
  14938. $scope.isHk = true;
  14939. $scope.roleidcode = true;
  14940. // $scope.options.initialValue = undefined;
  14941. if ($rootScope.user && $rootScope.user.role) {
  14942. angular.forEach($rootScope.user.role, function (item) {
  14943. if (item.rolecode == "call center") {
  14944. $scope.roleidcode = false;
  14945. }
  14946. });
  14947. }
  14948. $scope.recently = false;
  14949. $scope.recentlyincident = function (key, model) {
  14950. //关联事件
  14951. $scope.options.templateOptions.ApiRecently.fetchDataList("incident", {
  14952. idx: 0,
  14953. sum: 4,
  14954. incident: {
  14955. requester: {
  14956. id: key.id,
  14957. },
  14958. },
  14959. }).then(function (response) {
  14960. if (response.status == 200) {
  14961. $scope.recently = true;
  14962. $scope.recentincident = response.list;
  14963. } else {
  14964. $scope.recently = false;
  14965. }
  14966. });
  14967. $scope.bodyHeight = window.innerHeight - 100;
  14968. $(window).resize(function () {
  14969. $scope.bodyHeight = window.innerHeight - 100;
  14970. });
  14971. // $scope.shows = false;
  14972. $scope.tempData = {};
  14973. $scope.close = function () {
  14974. $scope.changes = !$scope.changes;
  14975. event.preventDefault();
  14976. };
  14977. };
  14978. $scope.charging = function (key, model) {
  14979. //计费弹出框
  14980. //用户信息
  14981. $scope.information = {};
  14982. $scope.options.templateOptions.ApiSer.fetchDataList("queryUser", {
  14983. userId: key.account,
  14984. }).then(function (response) {
  14985. // if (response.status == 200) {
  14986. if (response && response.data) {
  14987. angular.extend($scope.information, response.data[0]);
  14988. // $scope.information = response.data[0];
  14989. $scope.information.autologicDestroyTime = moment(
  14990. response.data[0].autologicDestroyTime
  14991. ).format("YYYY-MM-DD");
  14992. $scope.information.periodStartTime = moment(
  14993. response.data[0].periodStartTime
  14994. ).format("YYYY-MM-DD");
  14995. $scope.information.nextBillingTime = moment(
  14996. response.data[0].nextBillingTime
  14997. ).format("YYYY-MM-DD");
  14998. } else if (response.err) {
  14999. SweetAlert.swal(
  15000. "系统错误!",
  15001. "用户信息未取到,请刷新重试",
  15002. "error"
  15003. );
  15004. }
  15005. // }
  15006. });
  15007. //上网明细
  15008. $scope.options.templateOptions.ApiSer.fetchDataList(
  15009. "queryOnlineDetail",
  15010. {
  15011. userId: key.account,
  15012. limit: "10",
  15013. fromLoginTime: moment(new Date().getTime() - 86400000 * 6).format(
  15014. "YYYY-MM-DD HH:mm:ss"
  15015. ),
  15016. toLogoutTime: moment(new Date().getTime()).format(
  15017. "YYYY-MM-DD HH:mm:ss"
  15018. ),
  15019. }
  15020. ).then(function (response) {
  15021. // if (response.status == 200) {
  15022. if (response && response.data) {
  15023. angular.forEach(response.data, function (item, index) {
  15024. if (item.logoutTime) {
  15025. response.data[index].logoutTime = moment(
  15026. item.logoutTime
  15027. ).format("YYYY-MM-DD HH:mm:ss");
  15028. }
  15029. if (item.loginTime) {
  15030. response.data[index].loginTime = moment(
  15031. item.loginTime
  15032. ).format("YYYY-MM-DD HH:mm:ss");
  15033. }
  15034. });
  15035. $scope.logininform = response.data;
  15036. } else if (response.err) {
  15037. SweetAlert.swal(
  15038. "系统错误!",
  15039. "上网明细未取到,请刷新重试",
  15040. "error"
  15041. );
  15042. }
  15043. });
  15044. //黑名单
  15045. // $scope.information.blacklist = "否"
  15046. $scope.options.templateOptions.ApiSer.fetchDataList("queryInhibit", {
  15047. userId: key.account,
  15048. }).then(function (response) {
  15049. // if (response.status == 200) {
  15050. // $scope.logininformation = response.data;
  15051. if (response) {
  15052. if (response.data || response.data != null) {
  15053. $scope.information.blacklist = "是";
  15054. } else {
  15055. if (response.err) {
  15056. // SweetAlert.swal("系统错误!", "黑名单未取到,请刷新重试", "error");
  15057. } else {
  15058. $scope.information.blacklist = "否";
  15059. }
  15060. }
  15061. }
  15062. // }
  15063. });
  15064. $scope.bodyHeight = window.innerHeight - 100;
  15065. $(window).resize(function () {
  15066. $scope.bodyHeight = window.innerHeight - 100;
  15067. });
  15068. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '-500px' }, 1000);
  15069. // $scope.closepages = function(e) {
  15070. // $('#navigationcharging .pages').stop().animate({ 'marginLeft': '500px' }, 1000);
  15071. // event.preventDefault();
  15072. // };
  15073. // $scope.shows = false;
  15074. $scope.tempData = {};
  15075. $scope.close = function () {
  15076. $scope.changes = !$scope.changes;
  15077. event.preventDefault();
  15078. };
  15079. };
  15080. $scope.options.templateOptions.ApiService.fetchDataList(
  15081. "requesterType",
  15082. {
  15083. idx: 0,
  15084. sum: 100,
  15085. }
  15086. ).then(function (response) {
  15087. if (response.status == 200) {
  15088. $scope.networktypes = response.list;
  15089. } else {
  15090. SweetAlert.swal("系统错误!", "请刷新重试", "error");
  15091. }
  15092. });
  15093. function serchdata(searchKey) {
  15094. if (searchKey) {
  15095. var filterData = {
  15096. requester: {
  15097. searchKey: searchKey,
  15098. // 'userType': 1
  15099. },
  15100. idx: 0,
  15101. sum: 10,
  15102. };
  15103. } else {
  15104. var filterData = {
  15105. idx: 0,
  15106. requester: {},
  15107. sum: 10,
  15108. };
  15109. }
  15110. if (
  15111. $scope.model.requester &&
  15112. $scope.model.requester.requesterTypeDTO
  15113. ) {
  15114. angular.extend(filterData.requester, {
  15115. requesterTypeDTO: $scope.model.requester.requesterTypeDTO,
  15116. });
  15117. if (!$scope.options.model.contactsInformation) {
  15118. $scope.options.model.contactsInformation =
  15119. $scope.model.requester.mphone;
  15120. }
  15121. }
  15122. if ($scope.roleidcode) {
  15123. angular.extend(filterData["requester"], {
  15124. userType: 1,
  15125. });
  15126. }
  15127. $scope.options.templateOptions.ApiService.fetchDataList(
  15128. "requester",
  15129. filterData
  15130. ).then(function (response) {
  15131. var myData = response;
  15132. $scope.myData = myData.list;
  15133. });
  15134. }
  15135. $scope.searchData = {};
  15136. $scope.refreshUser = function (searchKey) {
  15137. //请求人搜索
  15138. if (searchKey && searchKey != "") {
  15139. serchdata(searchKey);
  15140. }
  15141. };
  15142. if (
  15143. $scope.$parent.$parent.$parent.model.incident.callID ||
  15144. $scope.$parent.$parent.$parent.model.requestershow
  15145. ) {
  15146. if (!$scope.roleidcode) {
  15147. $scope.charging(
  15148. $scope.$parent.$parent.$parent.model.incident.requester
  15149. );
  15150. }
  15151. $scope.recentlyincident(
  15152. $scope.$parent.$parent.$parent.model.incident.requester
  15153. );
  15154. }
  15155. $scope.onChange = function (searchData) {
  15156. if ($scope.$parent.$parent.$parent.model.incident.callID) {
  15157. searchData.telephone = $scope.model.incident.contactsInformation;
  15158. }
  15159. $scope.$parent.$parent.$parent.model.incident["requester"] =
  15160. searchData;
  15161. if (!$scope.roleidcode) {
  15162. $scope.charging(searchData);
  15163. }
  15164. $scope.recentlyincident(searchData);
  15165. $scope.accountshow = false;
  15166. if ($scope.model.incident) {
  15167. if ($scope.model.incident.place) {
  15168. $scope.model.incident.place.id = "";
  15169. }
  15170. if ($scope.model.incident.area) {
  15171. $scope.model.incident.area.id = "";
  15172. }
  15173. $scope.model.incident.contacts = searchData.name;
  15174. if (
  15175. searchData.mphone &&
  15176. searchData.mphone != null &&
  15177. searchData.mphone != ""
  15178. ) {
  15179. $scope.model.incident.contactsInformation = searchData.mphone;
  15180. } else {
  15181. $scope.model.incident.contactsInformation = searchData.telephone;
  15182. }
  15183. $scope.model.incident.houseNumber = "";
  15184. if (
  15185. searchData.requesterTypeDTO &&
  15186. searchData.requesterTypeDTO.id == 2
  15187. ) {
  15188. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  15189. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  15190. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  15191. }
  15192. }
  15193. $scope.options.value(searchData);
  15194. $scope.searchKey = searchData.account;
  15195. if (searchData.placeDTO && searchData.placeDTO.id) {
  15196. $scope.model.incident.place.id = searchData.placeDTO.id;
  15197. }
  15198. if (searchData.areaDTO && searchData.areaDTO.id) {
  15199. $scope.model.incident.area.id = searchData.areaDTO.id;
  15200. }
  15201. if (searchData.houseNumber) {
  15202. $scope.model.incident.houseNumber = searchData.houseNumber;
  15203. }
  15204. if (
  15205. searchData.requesterTypeDTO &&
  15206. searchData.requesterTypeDTO.id == 2
  15207. ) {
  15208. $scope.$parent.$parent.$parent.model.incident.priority.id = 2;
  15209. $scope.$parent.$parent.$parent.model.incident.emergency.id = 2;
  15210. $scope.$parent.$parent.$parent.model.incident.influence.id = 1;
  15211. }
  15212. };
  15213. },
  15214. ],
  15215. });
  15216. //ui-grid-table展示控件
  15217. formlyConfigProvider.setType({
  15218. name: "ui-grid-table",
  15219. // extends: 'multiCheckbox',//去掉冒号
  15220. templateUrl: "assets/views/customform/tpl/ui-grid-show-nofooter.html",
  15221. defaultOptions: function (options) {
  15222. return {
  15223. templateOptions: {
  15224. linkage: function () { },
  15225. },
  15226. };
  15227. },
  15228. controller: function (
  15229. $scope,
  15230. $rootScope,
  15231. i18nService,
  15232. Restangular,
  15233. api_bpm_data,
  15234. api_statistic,
  15235. $rootScope
  15236. ) {
  15237. var loginUser = $rootScope.user;
  15238. $scope.langs = i18nService.getAllLangs();
  15239. $scope.lang = "zh-cn";
  15240. i18nService.setCurrentLang($scope.lang);
  15241. $scope.gridOptions = {};
  15242. $scope.gridOptions.data = "myData";
  15243. $scope.gridOptions.enableColumnResizing = true;
  15244. $scope.gridOptions.enableGridMenu = false;
  15245. $scope.gridOptions.enableRowSelection = true;
  15246. $scope.gridOptions.showGridFooter = false;
  15247. $scope.gridOptions.showColumnFooter = false;
  15248. $scope.gridOptions.fastWatch = true;
  15249. $scope.gridOptions.useExternalFiltering = true;
  15250. $scope.gridOptions.useExternalPagination = false;
  15251. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15252. $scope.gridOptions.paginationPageSize = 3;
  15253. $scope.gridOptions.multiSelect = false;
  15254. $scope.gridOptions.rowIdentity = function (row) {
  15255. return row.id;
  15256. };
  15257. $scope.gridOptions.getRowIdentity = function (row) {
  15258. return row.id;
  15259. };
  15260. $scope.gridOptions.columnDefs = [
  15261. {
  15262. name: "item",
  15263. displayName: "序号",
  15264. width: 80,
  15265. enableFiltering: false,
  15266. },
  15267. {
  15268. name: "incidentsign",
  15269. displayName: "单号",
  15270. width: 80,
  15271. enableFiltering: false,
  15272. },
  15273. {
  15274. name: "description",
  15275. displayName: "主题",
  15276. width: 80,
  15277. enableFiltering: false,
  15278. },
  15279. {
  15280. name: "state.name",
  15281. displayName: "状态",
  15282. width: 110,
  15283. enableFiltering: false,
  15284. },
  15285. {
  15286. name: "acceptDate",
  15287. displayName: "创建时间",
  15288. width: 160,
  15289. enableFiltering: false,
  15290. },
  15291. {
  15292. name: "requester.name",
  15293. displayName: "请求人",
  15294. width: 80,
  15295. enableFiltering: false,
  15296. },
  15297. {
  15298. name: "handlingPersonnelUser.name",
  15299. displayName: "处理人",
  15300. width: 160,
  15301. enableFiltering: false,
  15302. },
  15303. {
  15304. name: "place.place",
  15305. displayName: "区域地点",
  15306. width: 160,
  15307. enableFiltering: false,
  15308. },
  15309. ];
  15310. // var defaultFilterData = {
  15311. // "idx": 0,
  15312. // "sum": 3
  15313. // };
  15314. // // //分页控制
  15315. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15316. gridApi.pagination.on.paginationChanged(
  15317. $scope,
  15318. function (newPage, pageSize) {
  15319. var filtersData = $scope.memoryfilterData;
  15320. filtersData.idx = newPage - 1;
  15321. filtersData.sum = pageSize;
  15322. $scope.refreshData("expand-right", filtersData);
  15323. }
  15324. );
  15325. // 表格单选事件
  15326. gridApi.selection.on.rowSelectionChanged($scope, function (data) {
  15327. var addstr = data.grid.appScope.$parent.$parent.$parent.model.addstr;
  15328. data.grid.appScope.$parent.$parent.$parent.model.incident.table =
  15329. data.entity;
  15330. data.grid.appScope.$parent.$parent.$parent.model.associationType =
  15331. data.entity.id;
  15332. var str =
  15333. data.grid.appScope.$parent.$parent.$parent.model.incident
  15334. .description || "";
  15335. str = str.split("").reverse().join("");
  15336. var del = addstr.split("").reverse().join("");
  15337. // console.log(del);
  15338. var reg = new RegExp(del);
  15339. str = str.replace(reg, "");
  15340. str = str.split("").reverse().join("");
  15341. if (
  15342. data.grid.appScope.$parent.$parent.$parent.model.incident
  15343. .associationType == "事件补充"
  15344. ) {
  15345. data.grid.appScope.$parent.$parent.$parent.model.relationType =
  15346. null;
  15347. str += data.entity.description;
  15348. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15349. data.entity.description;
  15350. } else if (
  15351. data.grid.appScope.$parent.$parent.$parent.model.incident
  15352. .associationType == "事件已解决"
  15353. ) {
  15354. data.grid.appScope.$parent.$parent.$parent.model.incident.relationType =
  15355. "close";
  15356. data.grid.appScope.$parent.$parent.$parent.model.addstr = addstr =
  15357. "";
  15358. }
  15359. data.grid.appScope.$parent.$parent.$parent.model.incident.description =
  15360. str;
  15361. data.grid.appScope.$parent.$parent.$parent.model.incident.relationIncidentId =
  15362. data.entity.id;
  15363. });
  15364. };
  15365. // 刷新表格
  15366. setInterval(function () {
  15367. // console.log($scope.myData);
  15368. $scope.myData = $scope.$parent.$parent.$parent.model.incident.tableList;
  15369. // console.log($scope.myData);
  15370. if ($scope.myData != null) {
  15371. for (var i = 0; i < $scope.myData.length; i++) {
  15372. //添加序号
  15373. $scope.myData[i]["item"] = i + 1;
  15374. }
  15375. }
  15376. }, 1000);
  15377. },
  15378. });
  15379. //处理人信息
  15380. formlyConfigProvider.setType({
  15381. name: "ui-userinformation",
  15382. templateUrl: "assets/views/customform/tpl/ui-userinformation.html",
  15383. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15384. defaultOptions: function (options) {
  15385. return {
  15386. templateOptions: {},
  15387. };
  15388. },
  15389. controller: [
  15390. "$scope",
  15391. function ($scope) {
  15392. $scope.group = "";
  15393. $scope.role = "";
  15394. if (
  15395. angular.isDefined($scope.model.handlingPersonnelUser) &&
  15396. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15397. $scope.model.handlingPersonnelUser.group.length == 1
  15398. ) {
  15399. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15400. } else {
  15401. for (
  15402. var i = 0;
  15403. i < $scope.model.handlingPersonnelUser.group.length;
  15404. i++
  15405. ) {
  15406. $scope.group +=
  15407. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15408. }
  15409. }
  15410. if (
  15411. angular.isDefined($scope.model.handlingPersonnelUser.role) &&
  15412. $scope.model.handlingPersonnelUser.role.length == 1
  15413. ) {
  15414. $scope.role = $scope.model.handlingPersonnelUser.role[0].role;
  15415. } else {
  15416. for (
  15417. var i = 0;
  15418. i < $scope.model.handlingPersonnelUser.role.length;
  15419. i++
  15420. ) {
  15421. $scope.role +=
  15422. $scope.model.handlingPersonnelUser.role[i].role + ",";
  15423. }
  15424. }
  15425. $scope.options.templateOptions.that = $scope;
  15426. },
  15427. ],
  15428. });
  15429. //处理界面处理人信息
  15430. formlyConfigProvider.setType({
  15431. name: "ui-handler",
  15432. templateUrl: "assets/views/customform/tpl/ui-handler.html",
  15433. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15434. defaultOptions: function (options) {
  15435. return {
  15436. templateOptions: {},
  15437. };
  15438. },
  15439. controller: [
  15440. "$scope",
  15441. function ($scope) {
  15442. $scope.group = "";
  15443. // $scope.role="";
  15444. if (
  15445. angular.isDefined($scope.model.handlingPersonnelUser.group) &&
  15446. $scope.model.handlingPersonnelUser.group.length == 1
  15447. ) {
  15448. $scope.group = $scope.model.handlingPersonnelUser.group[0].groupName;
  15449. } else {
  15450. for (
  15451. var i = 0;
  15452. i < $scope.model.handlingPersonnelUser.group.length;
  15453. i++
  15454. ) {
  15455. $scope.group +=
  15456. $scope.model.handlingPersonnelUser.group[i].groupName + ",";
  15457. }
  15458. }
  15459. // if(angular.isDefined($scope.model.handlingPersonnelUser.role) &&$scope.model.handlingPersonnelUser.role.length==1){
  15460. // $scope.role=$scope.model.handlingPersonnelUser.role[0].role;
  15461. // }else{
  15462. // for(var i=0;i<$scope.model.handlingPersonnelUser.role.length;i++){
  15463. // $scope.role += $scope.model.handlingPersonnelUser.role[i].role +",";
  15464. // }
  15465. // }
  15466. $scope.options.templateOptions.that = $scope;
  15467. },
  15468. ],
  15469. });
  15470. //微信事件流程
  15471. formlyConfigProvider.setType({
  15472. name: "ui-wxIncidentProcess",
  15473. templateUrl: "assets/views/customform/tpl/wxIncidentProcess.html",
  15474. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15475. defaultOptions: function (options) {
  15476. return {
  15477. templateOptions: {},
  15478. };
  15479. },
  15480. controller: [
  15481. "$scope",
  15482. function ($scope) {
  15483. console.log($scope.model);
  15484. $scope.pingjia = false;
  15485. $scope.jiejue = false;
  15486. if ($scope.model.incidentState.value == "3") {
  15487. $scope.pingjia = true;
  15488. } else if ($scope.model.incidentState.value == "4") {
  15489. $scope.jiejue = true;
  15490. }
  15491. },
  15492. ],
  15493. });
  15494. //打电话
  15495. formlyConfigProvider.setType({
  15496. name: "ui-inputcall",
  15497. extends: "input",
  15498. templateUrl: "assets/views/customform/tpl/inputcall.html",
  15499. defaultOptions: function (options) {
  15500. return {
  15501. templateOptions: {
  15502. transform: function (value) { },
  15503. },
  15504. };
  15505. },
  15506. controller: [
  15507. "$scope",
  15508. "$rootScope",
  15509. "api_text",
  15510. "SweetAlert",
  15511. function ($scope, $rootScope, api_text, SweetAlert) {
  15512. $scope.dialout = function (teleno) {
  15513. // var gid = "@0";
  15514. // var telephone = "9" + teleno;
  15515. $rootScope.callout = 2;
  15516. // var agcount = tlwsa.tlaGetagentcount();
  15517. // var agcountFlag = false;
  15518. // console.log(teleno)
  15519. // // 查询当前话机是否签入
  15520. // for (var i = 0; i < agcount; i++) {
  15521. // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
  15522. // agcountFlag = true;
  15523. // }
  15524. // }
  15525. if (localStorage.getItem('fenjiNumber')) {
  15526. // var caller = localStorage.getItem('phoneNumber');//呼叫人
  15527. // console.log(sessionStorage.getItem('phones'))
  15528. // var phones = JSON.parse(sessionStorage.getItem('phones'));
  15529. // var isHuajihao = phones.length?phones.some(v=>v == teleno):false;
  15530. // console.log(isHuajihao)
  15531. // if(isHuajihao){
  15532. // tlwsa.tlaCallagc(teleno);
  15533. // }else{
  15534. // tlwsa.tlaCallout(teleno, caller, 0);
  15535. // }
  15536. // var caller = localStorage.getItem('fenjiNumber');//呼叫人
  15537. $rootScope.toggle('off-sidebar');
  15538. // tlwsa.tlaCallout(teleno, caller, 0);
  15539. }else if(localStorage.getItem('hk_phone')){
  15540. var gid = "@0"
  15541. var telephone = '9' + teleno
  15542. $rootScope.callout = 2;
  15543. if ($rootScope.takes) {
  15544. api_text.dialout($rootScope.takes, gid, telephone).then(function (data) {
  15545. if (data.errno == 0) {
  15546. $rootScope.status = 6;
  15547. }
  15548. })
  15549. } else {
  15550. SweetAlert.swal({
  15551. title: "呼叫失败",
  15552. text: "请先签入呼叫中心!",
  15553. type: "error",
  15554. confirmButtonColor: "#DD6B55"
  15555. });
  15556. }
  15557. } else {
  15558. SweetAlert.swal({
  15559. title: "呼叫失败",
  15560. text: "请先签入呼叫中心!",
  15561. type: "error",
  15562. confirmButtonColor: "#DD6B55",
  15563. });
  15564. }
  15565. };
  15566. $scope.options.templateOptions.that = $scope;
  15567. },
  15568. ],
  15569. });
  15570. //关闭界面处理人信息
  15571. formlyConfigProvider.setType({
  15572. name: "ui-closehandler",
  15573. templateUrl: "assets/views/customform/tpl/ui-closehandler.html",
  15574. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15575. defaultOptions: function (options) {
  15576. return {
  15577. templateOptions: {},
  15578. };
  15579. },
  15580. controller: [
  15581. "$scope",
  15582. "$rootScope",
  15583. "api_text",
  15584. function ($scope, $rootScope, api_text) {
  15585. $scope.dialout = function (teleno) {
  15586. var gid = "@0";
  15587. var telephone = "9" + teleno;
  15588. api_text
  15589. .dialout($rootScope.takes, gid, telephone)
  15590. .then(function (data) {
  15591. if (data.errno == 0) {
  15592. $rootScope.status = 6;
  15593. }
  15594. });
  15595. };
  15596. $scope.options.templateOptions.that = $scope;
  15597. },
  15598. ],
  15599. });
  15600. //用户单选控件
  15601. formlyConfigProvider.setType({
  15602. name: "ui-userselect",
  15603. templateUrl: "assets/views/customform/tpl/ui-userselect.html",
  15604. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15605. defaultOptions: function (options) {
  15606. return {
  15607. templateOptions: {
  15608. openModal: function (size, options, modal) {
  15609. var modalInstance = modal.open({
  15610. templateUrl:
  15611. "assets/views/customform/tpl/checktable-modal-content.html",
  15612. controller: function (
  15613. $scope,
  15614. i18nService,
  15615. $modalInstance,
  15616. items,
  15617. title,
  15618. Restangular,
  15619. APIService,
  15620. onDataCallback,
  15621. parentScope
  15622. ) {
  15623. $scope.langs = i18nService.getAllLangs();
  15624. $scope.lang = "zh-cn";
  15625. i18nService.setCurrentLang($scope.lang);
  15626. $scope.gridOptions = {};
  15627. $scope.gridOptions.data = "myData";
  15628. $scope.gridOptions.enableColumnResizing = true;
  15629. $scope.gridOptions.enableFiltering = true;
  15630. $scope.gridOptions.enableGridMenu = false;
  15631. $scope.gridOptions.showGridFooter = true;
  15632. $scope.gridOptions.showColumnFooter = false;
  15633. $scope.gridOptions.fastWatch = true;
  15634. $scope.gridOptions.useExternalFiltering = true;
  15635. $scope.gridOptions.useExternalPagination = true;
  15636. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15637. $scope.gridOptions.paginationPageSize = 10;
  15638. $scope.gridOptions.multiSelect = false;
  15639. $scope.gridOptions.rowIdentity = function (row) {
  15640. return row.id;
  15641. };
  15642. $scope.gridOptions.getRowIdentity = function (row) {
  15643. return row.id;
  15644. };
  15645. $scope.gridOptions.rowTemplate =
  15646. '<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>';
  15647. $scope.gridOptions.columnDefs = [
  15648. {
  15649. name: "account",
  15650. displayName: "人员编号",
  15651. width: 120,
  15652. },
  15653. {
  15654. name: "name",
  15655. displayName: "姓名",
  15656. width: 100,
  15657. cellTemplate:
  15658. "<div>" +
  15659. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15660. "</div>",
  15661. },
  15662. // {
  15663. // name: 'gender.name',
  15664. // displayName: '性别',
  15665. // width: 80,
  15666. // enableFiltering: false
  15667. // },
  15668. {
  15669. name: "phone",
  15670. displayName: "电话",
  15671. width: 230,
  15672. enableFiltering: false,
  15673. },
  15674. {
  15675. name: "email",
  15676. displayName: "邮箱",
  15677. width: 180,
  15678. enableFiltering: false,
  15679. },
  15680. {
  15681. name: "dept.dept",
  15682. displayName: "科室",
  15683. width: 130,
  15684. enableFiltering: false,
  15685. },
  15686. {
  15687. name: "taskCount",
  15688. displayName: "处理中事件数",
  15689. enableFiltering: false,
  15690. },
  15691. ];
  15692. // $scope.selectButtonClick
  15693. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15694. $scope.gridApi = gridApi;
  15695. gridApi.pagination.on.paginationChanged(
  15696. $scope,
  15697. function (newPage, pageSize) {
  15698. var filtersData = $scope.memoryfilterData;
  15699. filtersData.idx = newPage - 1;
  15700. filtersData.sum = pageSize;
  15701. $scope.loadData(filtersData);
  15702. //console.log(pageSize);
  15703. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  15704. }
  15705. );
  15706. gridApi.selection.on.rowSelectionChanged(
  15707. $scope,
  15708. function (data) {
  15709. $scope.selected.items = data.entity;
  15710. //console.log(data);
  15711. }
  15712. );
  15713. gridApi.selection.on.rowSelectionChangedBatch(
  15714. $scope,
  15715. function (data) {
  15716. $scope.selected.items = data.entity;
  15717. //console.log(data);
  15718. }
  15719. );
  15720. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  15721. // // if (row.entity.age > 45) {
  15722. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15723. // // }
  15724. // };
  15725. gridApi.core.on.filterChanged($scope, function () {
  15726. var grid = this.grid;
  15727. var filtersData = {
  15728. idx: 0,
  15729. sum: 10,
  15730. user: {
  15731. roledata: {
  15732. rolecode: "roleset",
  15733. },
  15734. selectType: "1",
  15735. },
  15736. };
  15737. angular.forEach(grid.columns, function (item) {
  15738. if (item.enableFiltering) {
  15739. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  15740. if (
  15741. angular.isDefined(item.filters[0].term) &&
  15742. item.filters[0].term != ""
  15743. ) {
  15744. if (angular.isUndefined(filtersData["user"])) {
  15745. filtersData["user"] = {};
  15746. }
  15747. filtersData["user"][item.field] =
  15748. item.filters[0].term;
  15749. }
  15750. }
  15751. });
  15752. $scope.memoryfilterData = filtersData;
  15753. $scope.loadData(filtersData);
  15754. });
  15755. };
  15756. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  15757. // if (row.entity.age > 45) {
  15758. // row.grid.api.selection.selectRow(row.entity); // 选中行
  15759. // }
  15760. // },
  15761. $scope.onDblClick = function (data, event) {
  15762. // $scope.selected.items = data.entity;
  15763. $scope.selectButtonClick(data, event);
  15764. };
  15765. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  15766. // $scope.selected.items = data.entity;
  15767. // })
  15768. // };
  15769. $scope.memoryfilterData = {
  15770. idx: 0,
  15771. sum: 10,
  15772. user: {
  15773. roledata: {
  15774. rolecode: "roleset",
  15775. },
  15776. selectType: "1",
  15777. },
  15778. };
  15779. $scope.loadData = function (filterData) {
  15780. // console.log("filtersData=111" + JSON.stringify(filterData))
  15781. items
  15782. .fetchItems(filterData, APIService)
  15783. .then(function (data) {
  15784. var myData = Restangular.stripRestangular(data);
  15785. $scope.gridOptions.totalItems = myData.totalNum;
  15786. $scope.myData = myData.list;
  15787. });
  15788. };
  15789. // $scope.title = title;
  15790. $scope.loadData({
  15791. idx: 0,
  15792. sum: 10,
  15793. user: {
  15794. roledata: {
  15795. rolecode: "roleset",
  15796. },
  15797. selectType: "1",
  15798. },
  15799. });
  15800. $scope.selected = {
  15801. items: {},
  15802. };
  15803. $scope.ok = function () {
  15804. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  15805. // onDataCallback($scope.selected.item, parentScope);
  15806. // }
  15807. $modalInstance.close($scope.selected.items);
  15808. };
  15809. $scope.cancel = function () {
  15810. $modalInstance.dismiss("cancel");
  15811. };
  15812. },
  15813. size: size,
  15814. resolve: {
  15815. items: function () {
  15816. return {
  15817. fetchItems: function (filterData, APIService) {
  15818. filterData = filterData || {};
  15819. if (
  15820. angular.isDefined(filterData.idx) &&
  15821. filterData.idx == null
  15822. ) {
  15823. filterData = {
  15824. idx: 0,
  15825. sum: 10,
  15826. user: {
  15827. roledata: {
  15828. rolecode: "roleset",
  15829. },
  15830. selectType: "1",
  15831. },
  15832. };
  15833. }
  15834. return options.templateOptions.fetchItems(
  15835. filterData,
  15836. APIService
  15837. );
  15838. },
  15839. };
  15840. },
  15841. title: function () {
  15842. return options.templateOptions.label;
  15843. },
  15844. Restangular: function () {
  15845. return options.templateOptions.Restangular;
  15846. },
  15847. APIService: function () {
  15848. return options.templateOptions.ApiService;
  15849. },
  15850. onDataCallback: function () {
  15851. return options.templateOptions.callback;
  15852. },
  15853. parentScope: function () {
  15854. return options.templateOptions.that;
  15855. },
  15856. },
  15857. });
  15858. modalInstance.result.then(
  15859. function (selectedItem) {
  15860. // console.log(selectedItem);
  15861. options.value(selectedItem);
  15862. if (
  15863. options.templateOptions.callback &&
  15864. angular.isFunction(options.templateOptions.callback)
  15865. ) {
  15866. options.templateOptions.callback(
  15867. selectedItem,
  15868. options.templateOptions.that
  15869. );
  15870. }
  15871. if (
  15872. options.templateOptions.linkData &&
  15873. angular.isFunction(options.templateOptions.linkData)
  15874. ) {
  15875. options.templateOptions.linkData(
  15876. selectedItem,
  15877. options.templateOptions.that
  15878. );
  15879. }
  15880. },
  15881. function () {
  15882. //console.log('Modal dismissed at: ' + new Date());
  15883. }
  15884. );
  15885. },
  15886. },
  15887. };
  15888. },
  15889. controller: [
  15890. "$scope",
  15891. function ($scope) {
  15892. $scope.options.templateOptions.that = $scope;
  15893. // $scope.options.model[$scope.options.key] = {}
  15894. },
  15895. ],
  15896. });
  15897. //用户单选控件(dd 单选input带搜索)
  15898. formlyConfigProvider.setType({
  15899. name: "ui-userselectSearch",
  15900. templateUrl: "assets/views/customform/tpl/ui-userselectSearch.html",
  15901. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  15902. defaultOptions: function (options) {
  15903. return {
  15904. templateOptions: {
  15905. openModal: function (size, options, modal) {
  15906. var modalInstance = modal.open({
  15907. templateUrl:
  15908. "assets/views/customform/tpl/checktable-modal-content.html",
  15909. controller: function (
  15910. $scope,
  15911. i18nService,
  15912. $modalInstance,
  15913. items,
  15914. title,
  15915. Restangular,
  15916. APIService,
  15917. onDataCallback,
  15918. parentScope
  15919. ) {
  15920. $scope.langs = i18nService.getAllLangs();
  15921. $scope.lang = "zh-cn";
  15922. i18nService.setCurrentLang($scope.lang);
  15923. $scope.gridOptions = {};
  15924. $scope.gridOptions.data = "myData";
  15925. $scope.gridOptions.enableColumnResizing = true;
  15926. $scope.gridOptions.enableFiltering = true;
  15927. $scope.gridOptions.enableGridMenu = false;
  15928. $scope.gridOptions.showGridFooter = true;
  15929. $scope.gridOptions.showColumnFooter = false;
  15930. $scope.gridOptions.fastWatch = true;
  15931. $scope.gridOptions.useExternalFiltering = true;
  15932. $scope.gridOptions.useExternalPagination = true;
  15933. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  15934. $scope.gridOptions.paginationPageSize = 10;
  15935. $scope.gridOptions.multiSelect = false;
  15936. $scope.gridOptions.rowIdentity = function (row) {
  15937. return row.id;
  15938. };
  15939. $scope.gridOptions.getRowIdentity = function (row) {
  15940. return row.id;
  15941. };
  15942. $scope.gridOptions.rowTemplate =
  15943. '<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>';
  15944. $scope.gridOptions.columnDefs = [
  15945. {
  15946. name: "account",
  15947. displayName: "人员编号",
  15948. width: 120,
  15949. },
  15950. {
  15951. name: "name",
  15952. displayName: "姓名",
  15953. width: 100,
  15954. cellTemplate:
  15955. "<div>" +
  15956. '<div class="ui-grid-cell-contents"><div class="listcenter">{{row.entity.name}}</div></div>' +
  15957. "</div>",
  15958. },
  15959. // {
  15960. // name: 'gender.name',
  15961. // displayName: '性别',
  15962. // width: 80,
  15963. // enableFiltering: false
  15964. // },
  15965. {
  15966. name: "phone",
  15967. displayName: "电话",
  15968. width: 230,
  15969. enableFiltering: false,
  15970. },
  15971. {
  15972. name: "email",
  15973. displayName: "邮箱",
  15974. width: 180,
  15975. enableFiltering: false,
  15976. },
  15977. {
  15978. name: "dept.dept",
  15979. displayName: "科室",
  15980. width: 130,
  15981. enableFiltering: false,
  15982. },
  15983. {
  15984. name: "taskCount",
  15985. displayName: "处理中事件数",
  15986. enableFiltering: false,
  15987. },
  15988. ];
  15989. // $scope.selectButtonClick
  15990. $scope.gridOptions.onRegisterApi = function (gridApi) {
  15991. $scope.gridApi = gridApi;
  15992. gridApi.pagination.on.paginationChanged(
  15993. $scope,
  15994. function (newPage, pageSize) {
  15995. var filtersData = $scope.memoryfilterData;
  15996. filtersData.idx = newPage - 1;
  15997. filtersData.sum = pageSize;
  15998. $scope.loadData(filtersData);
  15999. //console.log(pageSize);
  16000. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  16001. }
  16002. );
  16003. gridApi.selection.on.rowSelectionChanged(
  16004. $scope,
  16005. function (data) {
  16006. $scope.selected.items = data.entity;
  16007. //console.log(data);
  16008. }
  16009. );
  16010. gridApi.selection.on.rowSelectionChangedBatch(
  16011. $scope,
  16012. function (data) {
  16013. $scope.selected.items = data.entity;
  16014. //console.log(data);
  16015. }
  16016. );
  16017. // gridApi.selection.on.selectAllRows = function(row) { //GridRow
  16018. // // if (row.entity.age > 45) {
  16019. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16020. // // }
  16021. // };
  16022. gridApi.core.on.filterChanged($scope, function () {
  16023. var grid = this.grid;
  16024. var filtersData = {
  16025. idx: 0,
  16026. sum: 10,
  16027. user: {
  16028. roledata: {
  16029. rolecode: "first-line support",
  16030. },
  16031. selectType: "1",
  16032. },
  16033. };
  16034. angular.forEach(grid.columns, function (item) {
  16035. if (item.enableFiltering) {
  16036. // console.log("item.filters[0]=" + JSON.stringify(item.filters));
  16037. if (
  16038. angular.isDefined(item.filters[0].term) &&
  16039. item.filters[0].term != ""
  16040. ) {
  16041. if (angular.isUndefined(filtersData["user"])) {
  16042. filtersData["user"] = {};
  16043. }
  16044. filtersData["user"][item.field] =
  16045. item.filters[0].term;
  16046. }
  16047. }
  16048. });
  16049. $scope.memoryfilterData = filtersData;
  16050. $scope.loadData(filtersData);
  16051. });
  16052. };
  16053. // $scope.gridOptions.isRowSelectable = function(row) { //GridRow
  16054. // if (row.entity.age > 45) {
  16055. // row.grid.api.selection.selectRow(row.entity); // 选中行
  16056. // }
  16057. // },
  16058. $scope.onDblClick = function (data, event) {
  16059. // $scope.selected.items = data.entity;
  16060. $scope.selectButtonClick(data, event);
  16061. };
  16062. // $scope.gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  16063. // $scope.selected.items = data.entity;
  16064. // })
  16065. // };
  16066. $scope.memoryfilterData = {
  16067. idx: 0,
  16068. sum: 10,
  16069. user: {
  16070. roledata: {
  16071. rolecode: "first-line support",
  16072. },
  16073. selectType: "1",
  16074. },
  16075. };
  16076. $scope.loadData = function (filterData) {
  16077. // console.log("filtersData=111" + JSON.stringify(filterData))
  16078. items
  16079. .fetchItems(filterData, APIService)
  16080. .then(function (data) {
  16081. var myData = Restangular.stripRestangular(data);
  16082. $scope.gridOptions.totalItems = myData.totalNum;
  16083. $scope.myData = myData.list;
  16084. });
  16085. };
  16086. $scope.title = title;
  16087. $scope.loadData({
  16088. idx: 0,
  16089. sum: 10,
  16090. user: {
  16091. roledata: {
  16092. rolecode: "first-line support",
  16093. },
  16094. selectType: "1",
  16095. },
  16096. });
  16097. $scope.selected = {
  16098. items: {},
  16099. };
  16100. $scope.ok = function () {
  16101. // if(onDataCallback&&angular.isFunction(onDataCallback)){
  16102. // onDataCallback($scope.selected.item, parentScope);
  16103. // }
  16104. $modalInstance.close($scope.selected.items);
  16105. };
  16106. $scope.cancel = function () {
  16107. $modalInstance.dismiss("cancel");
  16108. };
  16109. },
  16110. size: size,
  16111. resolve: {
  16112. items: function () {
  16113. return {
  16114. fetchItems: function (filterData, APIService) {
  16115. filterData = filterData || {};
  16116. if (
  16117. angular.isDefined(filterData.idx) &&
  16118. filterData.idx == null
  16119. ) {
  16120. filterData = {
  16121. idx: 0,
  16122. sum: 10,
  16123. user: {
  16124. roledata: {
  16125. rolecode: "first-line support",
  16126. },
  16127. selectType: "1",
  16128. },
  16129. };
  16130. }
  16131. return options.templateOptions.fetchItems(
  16132. filterData,
  16133. APIService
  16134. );
  16135. },
  16136. };
  16137. },
  16138. title: function () {
  16139. return options.templateOptions.label;
  16140. },
  16141. Restangular: function () {
  16142. return options.templateOptions.Restangular;
  16143. },
  16144. APIService: function () {
  16145. return options.templateOptions.ApiService;
  16146. },
  16147. onDataCallback: function () {
  16148. return options.templateOptions.callback;
  16149. },
  16150. parentScope: function () {
  16151. return options.templateOptions.that;
  16152. },
  16153. },
  16154. });
  16155. modalInstance.result.then(
  16156. function (selectedItem) {
  16157. // console.log(selectedItem);
  16158. options.value(selectedItem);
  16159. if (
  16160. options.templateOptions.callback &&
  16161. angular.isFunction(options.templateOptions.callback)
  16162. ) {
  16163. options.templateOptions.callback(
  16164. selectedItem,
  16165. options.templateOptions.that
  16166. );
  16167. }
  16168. if (
  16169. options.templateOptions.linkData &&
  16170. angular.isFunction(options.templateOptions.linkData)
  16171. ) {
  16172. options.templateOptions.linkData(
  16173. selectedItem,
  16174. options.templateOptions.that
  16175. );
  16176. }
  16177. },
  16178. function () {
  16179. //console.log('Modal dismissed at: ' + new Date());
  16180. }
  16181. );
  16182. },
  16183. },
  16184. };
  16185. },
  16186. controller: [
  16187. "$scope",
  16188. function ($scope) {
  16189. $scope.options.templateOptions.that = $scope;
  16190. },
  16191. ],
  16192. });
  16193. //用户多选控件
  16194. formlyConfigProvider.setType({
  16195. name: "ui-multiuserselect",
  16196. templateUrl: "assets/views/customform/tpl/ui-multiuserselect.html",
  16197. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  16198. defaultOptions: function (options) {
  16199. return {
  16200. templateOptions: {
  16201. openModal: function (size, options, modal, model) {
  16202. var modalInstance = modal.open({
  16203. templateUrl:
  16204. "assets/views/customform/tpl/checktable-modal-content.html",
  16205. controller: function (
  16206. $scope,
  16207. $modalInstance,
  16208. i18nService,
  16209. $timeout,
  16210. items,
  16211. title,
  16212. Restangular,
  16213. APIService,
  16214. selectItems
  16215. ) {
  16216. $scope.langs = i18nService.getAllLangs();
  16217. $scope.lang = "zh-cn";
  16218. i18nService.setCurrentLang($scope.lang);
  16219. $scope.gridOptions = {};
  16220. $scope.gridOptions.data = "myData";
  16221. $scope.gridOptions.enableColumnResizing = true;
  16222. $scope.gridOptions.enableFiltering = true;
  16223. $scope.gridOptions.enableGridMenu = true;
  16224. $scope.gridOptions.showGridFooter = true;
  16225. $scope.gridOptions.showColumnFooter = true;
  16226. $scope.gridOptions.fastWatch = true;
  16227. $scope.gridOptions.useExternalFiltering = true;
  16228. $scope.gridOptions.useExternalPagination = true;
  16229. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16230. $scope.gridOptions.paginationPageSize = 10;
  16231. $scope.gridOptions.multiSelect = true;
  16232. $scope.gridOptions.rowIdentity = function (row) {
  16233. return row.id;
  16234. };
  16235. $scope.gridOptions.getRowIdentity = function (row) {
  16236. return row.id;
  16237. };
  16238. //{"id":1,"phone":"15071189091","name":"管理员","gender":"男","flag":1,"email":"asda@qq.com","account":"000001","group":[{"id":3,"groupName":"运行监控科"}]}
  16239. $scope.gridOptions.columnDefs = [
  16240. // { name:'id', width:80, enableFiltering:false},
  16241. {
  16242. name: "account",
  16243. displayName: "账号",
  16244. width: 140,
  16245. },
  16246. {
  16247. name: "name",
  16248. displayName: "名称",
  16249. width: 100,
  16250. },
  16251. {
  16252. name: "gender.name",
  16253. displayName: "性别",
  16254. width: 140,
  16255. enableFiltering: false,
  16256. },
  16257. {
  16258. name: "phone",
  16259. displayName: "电话",
  16260. width: 100,
  16261. enableFiltering: false,
  16262. },
  16263. {
  16264. name: "email",
  16265. displayName: "邮件",
  16266. width: 100,
  16267. enableFiltering: false,
  16268. },
  16269. {
  16270. name: "dept.dept",
  16271. displayName: "科室",
  16272. width: 100,
  16273. enableFiltering: false,
  16274. },
  16275. {
  16276. name: "group[0].groupName",
  16277. displayName: "职位",
  16278. width: 100,
  16279. enableFiltering: false,
  16280. },
  16281. ];
  16282. $scope.selected = {
  16283. items: selectItems,
  16284. };
  16285. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16286. $scope.gridApi = gridApi;
  16287. gridApi.pagination.on.paginationChanged(
  16288. $scope,
  16289. function (newPage, pageSize) {
  16290. var filtersData = $scope.memoryfilterData;
  16291. filtersData.idx = newPage - 1;
  16292. filtersData.sum = pageSize;
  16293. $scope.loadData(filtersData);
  16294. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  16295. }
  16296. );
  16297. gridApi.selection.on.rowSelectionChanged(
  16298. $scope,
  16299. function (scope) {
  16300. var j = 0;
  16301. for (
  16302. var i = 0;
  16303. i <= scope.grid.appScope.selected.items.length;
  16304. i++
  16305. ) {
  16306. if (
  16307. scope.grid.appScope.selected.items[i] == scope.entity
  16308. ) {
  16309. j++;
  16310. break;
  16311. }
  16312. }
  16313. if (j == 1) {
  16314. scope.grid.appScope.selected.items.splice(i, 1);
  16315. } else {
  16316. scope.grid.appScope.selected.items.push(scope.entity);
  16317. for (
  16318. var i = 0;
  16319. i < scope.grid.appScope.selected.items.length;
  16320. i++
  16321. ) {
  16322. for (
  16323. var z = 0;
  16324. z < scope.grid.appScope.selected.items.length;
  16325. z++
  16326. ) {
  16327. // console.log("$scope.selected.items="+JSON.stringify($scope.selected.items));
  16328. // console.log("scope.grid.appScope.selected.items="+JSON.stringify(scope.grid.appScope.selected.items))
  16329. if (
  16330. angular.isDefined(
  16331. scope.grid.appScope.selected.items
  16332. ) &&
  16333. scope.grid.appScope.selected.items[i].id ==
  16334. scope.grid.appScope.selected.items[z].id &&
  16335. i != z
  16336. ) {
  16337. scope.grid.appScope.selected.items.splice(i, 1);
  16338. }
  16339. }
  16340. }
  16341. }
  16342. }
  16343. );
  16344. // gridApi.selection.on.rowSelectionChanged($scope, function($scope, rows){
  16345. // $scope.grid.appScope.selected.items.push($scope.entity);
  16346. // });
  16347. gridApi.core.on.filterChanged($scope, function () {
  16348. var grid = this.grid;
  16349. var filtersData = {
  16350. idx: 0,
  16351. sum: 10,
  16352. user: {
  16353. roledata: {
  16354. rolecode: options.model.currentRole,
  16355. },
  16356. selectType: "1",
  16357. },
  16358. };
  16359. angular.forEach(grid.columns, function (item) {
  16360. if (item.enableFiltering) {
  16361. //console.log("filtersData="+JSON.stringify(filtersData))
  16362. if (
  16363. angular.isDefined(item.filters[0].term) &&
  16364. item.filters[0].term != ""
  16365. ) {
  16366. if (angular.isUndefined(filtersData["user"])) {
  16367. filtersData["user"] = {};
  16368. }
  16369. filtersData["user"][item.field] =
  16370. item.filters[0].term;
  16371. }
  16372. }
  16373. });
  16374. $scope.memoryfilterData = filtersData;
  16375. $scope.loadData(filtersData);
  16376. });
  16377. };
  16378. if (!options.model) {
  16379. var mouse = {
  16380. model: {
  16381. currentRole: "",
  16382. },
  16383. };
  16384. angular.extend(options, mouse);
  16385. }
  16386. $scope.memoryfilterData = {
  16387. idx: 0,
  16388. sum: 10,
  16389. user: {
  16390. roledata: {
  16391. rolecode: options.model.currentRole,
  16392. },
  16393. selectType: "1",
  16394. },
  16395. };
  16396. $scope.loadData = function (filterData) {
  16397. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  16398. items
  16399. .fetchItems(filterData, APIService)
  16400. .then(function (data) {
  16401. var myData = Restangular.stripRestangular(data);
  16402. $scope.gridOptions.totalItems = myData.totalNum;
  16403. $scope.myData = myData.list;
  16404. //console.log($scope.gridOptions.pagination.getTotalPages());
  16405. // if($scope.selected.items){
  16406. // angular.forEach($scope.selected.items,function(selectItem){
  16407. // $scope.gridApi.selection.selectRow(selectItem);
  16408. // });
  16409. // }
  16410. });
  16411. };
  16412. // $scope.title = title;
  16413. $scope.loadData({
  16414. idx: 0,
  16415. sum: 10,
  16416. user: {
  16417. roledata: {
  16418. rolecode: options.model.currentRole,
  16419. },
  16420. selectType: "1",
  16421. },
  16422. });
  16423. // $timeout(function(){
  16424. // if($scope.selected.items){
  16425. // angular.forEach($scope.selected.items,function(selectItem){
  16426. // $scope.gridApi.selection.selectRow(selectItem);
  16427. // });
  16428. // }
  16429. // },2000)
  16430. $scope.ok = function () {
  16431. // $scope.selected.items = $scope.gridApi.selection.getSelectedRows();
  16432. $modalInstance.close($scope.selected.items);
  16433. };
  16434. $scope.cancel = function () {
  16435. $modalInstance.dismiss("cancel");
  16436. };
  16437. },
  16438. size: size,
  16439. resolve: {
  16440. items: function () {
  16441. return {
  16442. fetchItems: function (filterData, APIService) {
  16443. filterData = filterData || {};
  16444. if (
  16445. angular.isDefined(filterData.idx) &&
  16446. filterData.idx == null
  16447. ) {
  16448. filterData = {
  16449. idx: 0,
  16450. sum: 10,
  16451. user: {
  16452. roledata: {
  16453. rolecode: options.model.incident.currentRole,
  16454. },
  16455. selectType: "1",
  16456. },
  16457. };
  16458. }
  16459. return options.templateOptions.fetchItems(
  16460. filterData,
  16461. APIService
  16462. );
  16463. },
  16464. };
  16465. },
  16466. title: function () {
  16467. return options.templateOptions.modalTitle;
  16468. },
  16469. Restangular: function () {
  16470. return options.templateOptions.Restangular;
  16471. },
  16472. APIService: function () {
  16473. return options.templateOptions.ApiService;
  16474. },
  16475. selectItems: function () {
  16476. return model || [];
  16477. },
  16478. },
  16479. });
  16480. modalInstance.result.then(
  16481. function (selectedItem) {
  16482. options.value(selectedItem);
  16483. options.formControl.$validate();
  16484. },
  16485. function () {
  16486. //console.log('Modal dismissed at: ' + new Date());
  16487. }
  16488. );
  16489. },
  16490. },
  16491. validators: {
  16492. required: {
  16493. expression: function (viewValue, modelValue) {
  16494. var value = modelValue || viewValue;
  16495. return value.length >= 1;
  16496. },
  16497. },
  16498. },
  16499. };
  16500. },
  16501. controller: [
  16502. "$scope",
  16503. function ($scope) {
  16504. $scope.model[$scope.options.key] = [];
  16505. $scope.remove = function (itemId) {
  16506. angular.forEach(
  16507. $scope.model[$scope.options.key],
  16508. function (entry, index) {
  16509. if (entry.id == itemId) {
  16510. $scope.model[$scope.options.key].splice(index, 1);
  16511. // console.log($scope.options.formControl)
  16512. $scope.options.formControl.$validate();
  16513. } else {
  16514. }
  16515. }
  16516. );
  16517. };
  16518. },
  16519. ],
  16520. });
  16521. //用户多选控件-字符串展示
  16522. formlyConfigProvider.setType({
  16523. name: "ui-stringuserselect",
  16524. extends: "input",
  16525. templateUrl: "assets/views/customform/tpl/ui-stringuserselect.html",
  16526. defaultOptions: function (options) {
  16527. return {
  16528. templateOptions: {
  16529. translate: "",
  16530. refreshDelay: 0,
  16531. },
  16532. };
  16533. },
  16534. controller: [
  16535. "$scope",
  16536. function ($scope) {
  16537. var keydata = "";
  16538. if (angular.isArray($scope.model)) {
  16539. angular.forEach($scope.model, function (item) {
  16540. keydata = keydata + "," + item.name;
  16541. });
  16542. }
  16543. // $scope.model[$scope.options.key] = [];
  16544. },
  16545. ],
  16546. });
  16547. //重复事件
  16548. formlyConfigProvider.setType({
  16549. name: "ui-incidentmodelselect",
  16550. extends: "input",
  16551. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  16552. defaultOptions: function (options) {
  16553. return {
  16554. templateOptions: {
  16555. openModal: function (size, options, modal) {
  16556. var modalInstance = modal.open({
  16557. templateUrl:
  16558. "assets/views/customform/tpl/checktable-modal-content.html",
  16559. controller: function (
  16560. $scope,
  16561. $rootScope,
  16562. $modalInstance,
  16563. items,
  16564. title,
  16565. Restangular,
  16566. APIService,
  16567. i18nService,
  16568. api_configure_data,
  16569. api_user_data,
  16570. api_bpm_data
  16571. ) {
  16572. $scope.langs = i18nService.getAllLangs();
  16573. $scope.lang = "zh-cn";
  16574. i18nService.setCurrentLang($scope.lang);
  16575. $scope.gridOptions = {};
  16576. $scope.gridOptions.data = "myData";
  16577. $scope.gridOptions.enableColumnResizing = true;
  16578. $scope.gridOptions.enableFiltering = true;
  16579. $scope.gridOptions.enableGridMenu = false;
  16580. $scope.gridOptions.enableRowSelection = true;
  16581. $scope.gridOptions.showGridFooter = true;
  16582. $scope.gridOptions.showColumnFooter = false;
  16583. $scope.gridOptions.fastWatch = true;
  16584. $scope.gridOptions.useExternalFiltering = true;
  16585. $scope.gridOptions.useExternalPagination = true;
  16586. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  16587. $scope.gridOptions.paginationPageSize = 10;
  16588. $scope.gridOptions.multiSelect = false;
  16589. var mun = $scope.gridOptions.paginationPageSize;
  16590. $scope.gridOptions.rowIdentity = function (row) {
  16591. return row.id;
  16592. };
  16593. $scope.gridOptions.getRowIdentity = function (row) {
  16594. return row.id;
  16595. };
  16596. $scope.gridOptions.columnDefs = items.columnDefs();
  16597. $scope.transferTime = function (time) {
  16598. return moment(time).format("YYYY-MM-DD HH:mm");
  16599. };
  16600. $scope.gridOptions.onRegisterApi = function (gridApi) {
  16601. $scope.gridApi = gridApi;
  16602. gridApi.pagination.on.paginationChanged(
  16603. $scope,
  16604. function (newPage, pageSize) {
  16605. // console.log(newPage);
  16606. // console.log(pageSize);
  16607. $scope.loadData({
  16608. idx: newPage - 1,
  16609. sum: pageSize,
  16610. });
  16611. }
  16612. );
  16613. gridApi.core.on.filterChanged($scope, function () {
  16614. var grid = this.grid;
  16615. var filtersData = {
  16616. idx: 0,
  16617. sum: 100,
  16618. };
  16619. angular.forEach(grid.columns, function (item) {
  16620. if (item.enableFiltering) {
  16621. if (
  16622. angular.isDefined(item.filters[0].term) &&
  16623. item.filters[0].term != ""
  16624. ) {
  16625. // console.log("filtersData="+JSON.stringify(filtersData))
  16626. if (angular.isUndefined(filtersData["incident"])) {
  16627. filtersData["incident"] = {};
  16628. }
  16629. filtersData["incident"][item.field] =
  16630. item.filters[0].term;
  16631. if (angular.isUndefined(filtersData["problem"])) {
  16632. filtersData["problem"] = {};
  16633. }
  16634. filtersData["problem"][item.field] =
  16635. item.filters[0].term;
  16636. if (angular.isUndefined(filtersData["change"])) {
  16637. filtersData["change"] = {};
  16638. }
  16639. filtersData["change"][item.field] =
  16640. item.filters[0].term;
  16641. if (angular.isUndefined(filtersData["release"])) {
  16642. filtersData["release"] = {};
  16643. }
  16644. filtersData["release"][item.field] =
  16645. item.filters[0].term;
  16646. }
  16647. }
  16648. });
  16649. $scope.loadData(filtersData);
  16650. });
  16651. gridApi.selection.on.rowSelectionChanged(
  16652. $scope,
  16653. function (data) {
  16654. $scope.selected.item = data.entity;
  16655. //console.log(data);
  16656. }
  16657. );
  16658. };
  16659. //资产
  16660. $scope.cmdb = {};
  16661. //资产状态
  16662. $scope.state_data = [
  16663. {
  16664. name: "全部状态",
  16665. value: "",
  16666. },
  16667. {
  16668. name: "在库",
  16669. value: "1",
  16670. },
  16671. {
  16672. name: "在线",
  16673. value: "2",
  16674. },
  16675. {
  16676. name: "借出",
  16677. value: "3",
  16678. },
  16679. {
  16680. name: "报修",
  16681. value: "4",
  16682. },
  16683. {
  16684. name: "报废",
  16685. value: "5",
  16686. },
  16687. {
  16688. name: "备用",
  16689. value: "6",
  16690. },
  16691. ];
  16692. //资产类型
  16693. $scope.wt_zcfl = function () {
  16694. api_configure_data
  16695. .fetchDataList("ciclassify", {
  16696. idx: 0,
  16697. sum: 100,
  16698. })
  16699. .then(function (data) {
  16700. console.log(data);
  16701. // $scope.wt_zclx = data.list;
  16702. console.log(data);
  16703. $scope.wtData = [];
  16704. if (data.status == 200) {
  16705. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  16706. var root = null; //Initially set our loop to null
  16707. var parentNode = null;
  16708. //loop over data
  16709. // $scope.wtData=data.list;
  16710. data = data.list;
  16711. //知识库分类数据三级处理
  16712. for (var i = 0; i < data.length; i++) {
  16713. // console.log(data[i])
  16714. var datum = data[i];
  16715. //each node will have children, so let's give it a "children" poperty
  16716. // console.log(datum);
  16717. datum.children = [];
  16718. if (!datum.parent) {
  16719. $scope.wtData.push(datum);
  16720. // console.log($scope.wtData)
  16721. } else {
  16722. if ($scope.wtData[0]) {
  16723. if ($scope.wtData[0].id == datum.parent.id) {
  16724. $scope.wtData[0].children.push(datum);
  16725. }
  16726. for (
  16727. var j = 0;
  16728. j < $scope.wtData[0].children.length;
  16729. j++
  16730. ) {
  16731. if (
  16732. $scope.wtData[0].children[j].id ==
  16733. datum.parent.id
  16734. ) {
  16735. $scope.wtData[0].children[j].children.push(
  16736. datum
  16737. );
  16738. }
  16739. }
  16740. }
  16741. if ($scope.wtData[1]) {
  16742. if ($scope.wtData[1].id == datum.parent.id) {
  16743. $scope.wtData[1].children.push(datum);
  16744. }
  16745. for (
  16746. var j = 0;
  16747. j < $scope.wtData[1].children.length;
  16748. j++
  16749. ) {
  16750. if (
  16751. $scope.wtData[1].children[j].id ==
  16752. datum.parent.id
  16753. ) {
  16754. $scope.wtData[1].children[j].children.push(
  16755. datum
  16756. );
  16757. }
  16758. }
  16759. }
  16760. if ($scope.wtData[2]) {
  16761. if ($scope.wtData[2].id == datum.parent.id) {
  16762. $scope.wtData[2].children.push(datum);
  16763. }
  16764. for (
  16765. var j = 0;
  16766. j < $scope.wtData[2].children.length;
  16767. j++
  16768. ) {
  16769. if (
  16770. $scope.wtData[2].children[j].id ==
  16771. datum.parent.id
  16772. ) {
  16773. $scope.wtData[2].children[j].children.push(
  16774. datum
  16775. );
  16776. }
  16777. }
  16778. }
  16779. }
  16780. // console.log($scope.wtData)
  16781. idToNodeMap[datum.id] = datum;
  16782. root = datum;
  16783. // treeMap[datum.id] = root;
  16784. }
  16785. }
  16786. });
  16787. };
  16788. $scope.wt_zcfl();
  16789. //事件
  16790. //受理人,处理人
  16791. $scope.searchkeys = {};
  16792. var fieldata = {
  16793. idx: 0,
  16794. sum: 100,
  16795. flag: -1,
  16796. };
  16797. getUser(fieldata, 3);
  16798. function getUser(fieldatas, it) {
  16799. api_user_data
  16800. .fetchDataList("user", fieldatas)
  16801. .then(function (data) {
  16802. if (it == 1) {
  16803. $scope.acceptUser = data.list;
  16804. } else if (it == 2) {
  16805. $scope.handlingPersonnelUser = data.list;
  16806. } else if (it == 3) {
  16807. $scope.acceptUser = data.list;
  16808. $scope.handlingPersonnelUser = data.list;
  16809. }
  16810. });
  16811. }
  16812. //状态
  16813. $scope.othcode = {};
  16814. api_bpm_data
  16815. .fetchDataList("incidentstatus", {
  16816. idx: 0,
  16817. sum: 100,
  16818. })
  16819. .then(function (response) {
  16820. if (response) {
  16821. if ((response.status = 200)) {
  16822. $scope.state = response.list;
  16823. }
  16824. }
  16825. });
  16826. var defaultFilterData = {
  16827. assignee: $rootScope.user.id,
  16828. searchType: "todo",
  16829. idx: 0,
  16830. sum: mun,
  16831. };
  16832. var defaultFilterData1 = {
  16833. // "searchType": "todo",
  16834. idx: 0,
  16835. sum: mun,
  16836. };
  16837. //搜索
  16838. $scope.chiceIncident = function (parameters, item, stateid) {
  16839. console.log(item, stateid);
  16840. console.log($scope);
  16841. if ($scope.title == "关联资产编号") {
  16842. // alert('222222222222');
  16843. var fildata = defaultFilterData1;
  16844. $scope.gridOptions.paginationCurrentPage = 1;
  16845. var transitiondata = angular.copy(item);
  16846. angular.extend(fildata, transitiondata);
  16847. if (fildata.hw_state) {
  16848. fildata.hw_state = fildata.hw_state.name;
  16849. }
  16850. if (fildata.sign) {
  16851. fildata.sign = fildata.sign.prefix + fildata.sign.sign;
  16852. fildata.sign = fildata.sign.split(";");
  16853. fildata.sign = fildata.sign.join("");
  16854. fildata.sign = fildata.sign.toLowerCase();
  16855. }
  16856. if (fildata.keys) {
  16857. fildata["searchCriteria"] = "uuid";
  16858. }
  16859. console.log(fildata);
  16860. $scope.loadData(fildata);
  16861. }
  16862. if ($scope.title == "关联事件工单") {
  16863. // alert('3333333333333333')
  16864. if (stateid && stateid.code) {
  16865. item.statusId = stateid.code;
  16866. }
  16867. var fildata = defaultFilterData;
  16868. // $scope.memoryfilterData = fildata;
  16869. if (!fildata.incident) {
  16870. fildata["incident"] = {};
  16871. }
  16872. $scope.gridOptions.paginationCurrentPage = 1;
  16873. var transitiondata = angular.copy(item);
  16874. angular.extend(fildata.incident, transitiondata);
  16875. console.log(fildata);
  16876. // $scope.loadData(fildata);
  16877. api_bpm_data
  16878. .fetchDataList("incident", fildata)
  16879. .then(function (data) {
  16880. console.log(data);
  16881. if (data) {
  16882. $scope.myData = data.list;
  16883. $scope.gridOptions.totalItems = data.totalNum;
  16884. }
  16885. });
  16886. }
  16887. };
  16888. //重置
  16889. $scope.replacement = function (
  16890. parameters,
  16891. searchkeys,
  16892. othcode
  16893. ) {
  16894. // console.log(parameters, searchkeys, othcode);
  16895. delete defaultFilterData.incident;
  16896. console.log(defaultFilterData);
  16897. $scope.parameters = null;
  16898. $scope.searchkeys = {};
  16899. $scope.othcode = {};
  16900. $scope.wt_zcfl();
  16901. };
  16902. $scope.loadData = function (filterData) {
  16903. items
  16904. .fetchItems(filterData, APIService, $rootScope)
  16905. .then(function (data) {
  16906. var myData = Restangular.stripRestangular(data);
  16907. if (myData.data && myData.data.node) {
  16908. $scope.gridOptions.totalItems = myData.total;
  16909. $scope.myData = myData.data.node;
  16910. } else {
  16911. if (myData.resultCount) {
  16912. $scope.gridOptions["totalItems"] = myData.resultCount;
  16913. } else {
  16914. $scope.gridOptions.totalItems = myData.totalNum;
  16915. }
  16916. if (myData.list) {
  16917. $scope.myData = myData.list;
  16918. } else {
  16919. $scope.myData = myData.data;
  16920. }
  16921. }
  16922. });
  16923. };
  16924. $scope.title = title;
  16925. $scope.loadData({
  16926. idx: 0,
  16927. sum: 10,
  16928. });
  16929. $scope.selected = {
  16930. item: {},
  16931. };
  16932. $scope.ok = function () {
  16933. //console.log($scope.selected.item);
  16934. $modalInstance.close($scope.selected.item);
  16935. };
  16936. $scope.cancel = function () {
  16937. $modalInstance.dismiss("cancel");
  16938. };
  16939. },
  16940. size: size,
  16941. resolve: {
  16942. items: function () {
  16943. return {
  16944. fetchItems: function (filterData, APIService, $rootScope) {
  16945. filterData = filterData || {};
  16946. // if(!filterData.idx){
  16947. if (
  16948. angular.isDefined(filterData.idx) &&
  16949. filterData.idx == null
  16950. ) {
  16951. filterData = {
  16952. idx: 0,
  16953. sum: 10,
  16954. };
  16955. }
  16956. return options.templateOptions.fetchItems(
  16957. filterData,
  16958. APIService,
  16959. $rootScope
  16960. );
  16961. },
  16962. columnDefs: function () {
  16963. return options.templateOptions.columnDefs;
  16964. },
  16965. };
  16966. },
  16967. title: function () {
  16968. return options.templateOptions.modalTitle;
  16969. },
  16970. Restangular: function () {
  16971. return options.templateOptions.Restangular;
  16972. },
  16973. APIService: function () {
  16974. return options.templateOptions.ApiService;
  16975. },
  16976. },
  16977. });
  16978. modalInstance.result.then(
  16979. function (selectedItem) {
  16980. var selectitem = {
  16981. title: selectedItem.title,
  16982. description: selectedItem.description,
  16983. };
  16984. if (options.key == "chuku") {
  16985. if (selectedItem.assets) {
  16986. $scope.$parent.$parent.$parent.model.applicationForm.assets =
  16987. selectedItem.assets;
  16988. }
  16989. if (selectedItem.consumables) {
  16990. $scope.$parent.$parent.$parent.model.applicationForm.consumables =
  16991. selectedItem.consumables;
  16992. }
  16993. angular.extend(
  16994. $scope.$parent.$parent.$parent.model,
  16995. selectitem
  16996. );
  16997. options.value(selectedItem);
  16998. // options.model.consumables = JSON.parse(consumables);
  16999. } else if (options.templateOptions.pkey == "change") {
  17000. console.log(options);
  17001. angular.extend(options.model);
  17002. options.value(selectedItem);
  17003. } else if (options.key == "cmdbCode") {
  17004. var zc_selectitem = selectedItem.uuid;
  17005. // angular.extend(options.model,zc_selectitem);
  17006. options.model.cmdbCode = zc_selectitem;
  17007. // angular.extend(options.model,zc_selectitem);
  17008. // options.templateOptions.displayName=zc_selectitem;
  17009. options.value(selectedItem);
  17010. console.log(options.model);
  17011. } else {
  17012. angular.extend(options.model, selectitem);
  17013. options.value(selectedItem);
  17014. }
  17015. },
  17016. function () {
  17017. //console.log('Modal dismissed at: ' + new Date());
  17018. }
  17019. );
  17020. },
  17021. },
  17022. };
  17023. },
  17024. });
  17025. //选项选择控件
  17026. formlyConfigProvider.setType({
  17027. name: "ui-modelselect",
  17028. extends: "input",
  17029. templateUrl: "assets/views/customform/tpl/ui-modelselect.html",
  17030. defaultOptions: function (options) {
  17031. return {
  17032. templateOptions: {
  17033. openModal: function (size, options, modal) {
  17034. var modalInstance = modal.open({
  17035. templateUrl:
  17036. "assets/views/customform/tpl/checktable-modal-content.html",
  17037. controller: function (
  17038. $scope,
  17039. $modalInstance,
  17040. items,
  17041. title,
  17042. Restangular,
  17043. APIService,
  17044. i18nService
  17045. ) {
  17046. $scope.langs = i18nService.getAllLangs();
  17047. $scope.lang = "zh-cn";
  17048. i18nService.setCurrentLang($scope.lang);
  17049. $scope.gridOptions = {};
  17050. $scope.gridOptions.data = "myData";
  17051. $scope.gridOptions.enableColumnResizing = true;
  17052. $scope.gridOptions.enableFiltering = true;
  17053. $scope.gridOptions.enableGridMenu = false;
  17054. $scope.gridOptions.enableRowSelection = true;
  17055. $scope.gridOptions.showGridFooter = true;
  17056. $scope.gridOptions.showColumnFooter = true;
  17057. $scope.gridOptions.fastWatch = true;
  17058. $scope.gridOptions.useExternalFiltering = true;
  17059. $scope.gridOptions.useExternalPagination = true;
  17060. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  17061. $scope.gridOptions.paginationPageSize = 10;
  17062. $scope.gridOptions.multiSelect = false;
  17063. $scope.gridOptions.rowIdentity = function (row) {
  17064. return row.id;
  17065. };
  17066. $scope.gridOptions.getRowIdentity = function (row) {
  17067. return row.id;
  17068. };
  17069. $scope.gridOptions.columnDefs = items.columnDefs();
  17070. $scope.gridOptions.onRegisterApi = function (gridApi) {
  17071. $scope.gridApi = gridApi;
  17072. gridApi.pagination.on.paginationChanged(
  17073. $scope,
  17074. function (newPage, pageSize) {
  17075. // console.log(newPage);
  17076. // console.log(pageSize);
  17077. $scope.loadData({
  17078. idx: newPage - 1,
  17079. sum: pageSize,
  17080. });
  17081. }
  17082. );
  17083. gridApi.core.on.filterChanged($scope, function () {
  17084. var grid = this.grid;
  17085. var filtersData = {
  17086. idx: 0,
  17087. sum: 10,
  17088. };
  17089. angular.forEach(grid.columns, function (item) {
  17090. if (item.enableFiltering) {
  17091. if (
  17092. angular.isDefined(item.filters[0].term) &&
  17093. item.filters[0].term != ""
  17094. ) {
  17095. // console.log("filtersData="+JSON.stringify(filtersData))
  17096. if (angular.isUndefined(filtersData["incident"])) {
  17097. filtersData["incident"] = {};
  17098. }
  17099. filtersData["incident"][item.field] =
  17100. item.filters[0].term;
  17101. if (angular.isUndefined(filtersData["problem"])) {
  17102. filtersData["problem"] = {};
  17103. }
  17104. filtersData["problem"][item.field] =
  17105. item.filters[0].term;
  17106. if (angular.isUndefined(filtersData["change"])) {
  17107. filtersData["change"] = {};
  17108. }
  17109. filtersData["change"][item.field] =
  17110. item.filters[0].term;
  17111. if (angular.isUndefined(filtersData["release"])) {
  17112. filtersData["release"] = {};
  17113. }
  17114. filtersData["release"][item.field] =
  17115. item.filters[0].term;
  17116. }
  17117. }
  17118. });
  17119. $scope.loadData(filtersData);
  17120. });
  17121. gridApi.selection.on.rowSelectionChanged(
  17122. $scope,
  17123. function (data) {
  17124. $scope.selected.item = data.entity;
  17125. //console.log(data);
  17126. }
  17127. );
  17128. };
  17129. $scope.loadData = function (filterData) {
  17130. items
  17131. .fetchItems(filterData, APIService)
  17132. .then(function (data) {
  17133. var myData = Restangular.stripRestangular(data);
  17134. $scope.gridOptions.totalItems = myData.totalNum;
  17135. $scope.myData = myData.list;
  17136. });
  17137. };
  17138. $scope.title = title;
  17139. $scope.loadData({
  17140. idx: 0,
  17141. sum: 10,
  17142. });
  17143. $scope.selected = {
  17144. item: {},
  17145. };
  17146. $scope.ok = function () {
  17147. if ($scope.selected.item.scheduleOrder) {
  17148. $scope.selected.item.descriptionData =
  17149. "日期:" +
  17150. $scope.selected.item.watchTime +
  17151. ";" +
  17152. "班次:" +
  17153. $scope.selected.item.scheduleOrder.description +
  17154. ";" +
  17155. "值班人:" +
  17156. $scope.selected.item.scheduleOrder.users[0].name;
  17157. }
  17158. //console.log($scope.selected.item);
  17159. $modalInstance.close($scope.selected.item);
  17160. };
  17161. $scope.cancel = function () {
  17162. $modalInstance.dismiss("cancel");
  17163. };
  17164. },
  17165. size: size,
  17166. resolve: {
  17167. items: function () {
  17168. return {
  17169. fetchItems: function (filterData, APIService) {
  17170. filterData = filterData || {};
  17171. // if(!filterData.idx){
  17172. if (
  17173. angular.isDefined(filterData.idx) &&
  17174. filterData.idx == null
  17175. ) {
  17176. filterData = {
  17177. idx: 0,
  17178. sum: 10,
  17179. };
  17180. }
  17181. return options.templateOptions.fetchItems(
  17182. filterData,
  17183. APIService,
  17184. options
  17185. );
  17186. },
  17187. columnDefs: function () {
  17188. return options.templateOptions.columnDefs;
  17189. },
  17190. };
  17191. },
  17192. title: function () {
  17193. return options.templateOptions.modalTitle;
  17194. },
  17195. Restangular: function () {
  17196. return options.templateOptions.Restangular;
  17197. },
  17198. APIService: function () {
  17199. return options.templateOptions.ApiService;
  17200. },
  17201. },
  17202. });
  17203. modalInstance.result.then(
  17204. function (selectedItem) {
  17205. options.value(selectedItem);
  17206. },
  17207. function () {
  17208. //console.log('Modal dismissed at: ' + new Date());
  17209. }
  17210. );
  17211. },
  17212. },
  17213. };
  17214. },
  17215. });
  17216. formlyConfigProvider.setType({
  17217. name: "ui-requestform",
  17218. extends: "input",
  17219. templateUrl: "assets/views/customform/tpl/ui-requestform.html",
  17220. controller: [
  17221. "$scope",
  17222. function ($scope) {
  17223. setTimeout(function () {
  17224. var filterData = {
  17225. idx: 0,
  17226. sum: 5,
  17227. incident: {
  17228. requester: {
  17229. id: "",
  17230. },
  17231. },
  17232. };
  17233. $scope.options.templateOptions
  17234. .getWorkernumber(
  17235. $scope.options.templateOptions.ApiService,
  17236. filterData
  17237. )
  17238. .then(function (result) {
  17239. var modelData =
  17240. $scope.options.templateOptions.Restangular.stripRestangular(
  17241. result
  17242. );
  17243. });
  17244. }, 1000);
  17245. },
  17246. ],
  17247. });
  17248. //报修图片展示
  17249. formlyConfigProvider.setType({
  17250. name: "ui-repair-photos",
  17251. // extends: 'label',
  17252. templateUrl: "assets/views/customform/tpl/ui-repair-photos.html",
  17253. controller: [
  17254. "$scope",
  17255. "api_wechatfile",
  17256. "$stateParams",
  17257. function ($scope, api_wechatfile, $stateParams) {
  17258. console.log($scope);
  17259. $scope.fileUrls = [];
  17260. if ($scope.model.wxFile) {
  17261. api_wechatfile
  17262. .listAttachment("wechatRequesterIncident", $scope.model.incident.id)
  17263. .then(function (res) {
  17264. $scope.fileUrls = res.data;
  17265. });
  17266. }
  17267. console.log($stateParams);
  17268. if (
  17269. $stateParams &&
  17270. $stateParams.model &&
  17271. JSON.parse($stateParams.model) &&
  17272. JSON.parse($stateParams.model).model &&
  17273. JSON.parse($stateParams.model).model.flow
  17274. ) {
  17275. api_wechatfile
  17276. .listAttachment(
  17277. "wechatRequesterIncident",
  17278. JSON.parse($stateParams.model).model.flow
  17279. )
  17280. .then(function (res) {
  17281. $scope.fileUrls = res.data;
  17282. });
  17283. }
  17284. if ($scope.model.flow) {
  17285. api_wechatfile
  17286. .listAttachment("wechatRequesterIncident", $scope.model.flow)
  17287. .then(function (res) {
  17288. $scope.fileUrls = res.data;
  17289. });
  17290. }
  17291. // if (angular.isUndefined($scope.model[$scope.options.key]) || $scope.model[$scope.options.key] == null) {
  17292. // // setTimeout(function () {
  17293. // // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function (result) {
  17294. // // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  17295. // // if (modelData.status == 200) {
  17296. // // $scope.model[$scope.options.key] = modelData.data;
  17297. // // $scope.options.initialValue = $scope.model[$scope.options.key];
  17298. // // }
  17299. // // });
  17300. // // }, 1000);
  17301. // }
  17302. $scope.showBigImg = false;
  17303. $scope.showBigImgCli = function (data) {
  17304. $scope.showBigImg = true;
  17305. $scope.bigImgUrl = data;
  17306. };
  17307. $scope.closeBigImg = function () {
  17308. $scope.showBigImg = false;
  17309. };
  17310. },
  17311. ],
  17312. });
  17313. //图片展示
  17314. formlyConfigProvider.setType({
  17315. name: "ui-showImgs",
  17316. templateUrl: "assets/views/customform/tpl/ui-showImgs.html",
  17317. defaultOptions: function (options) {
  17318. return {
  17319. templateOptions: {
  17320. refresh: function (APIService, processInstanceId, data) {
  17321. return APIService.listAttachments(processInstanceId);
  17322. },
  17323. downloadUri: function (APIService, contentId) {
  17324. return APIService.downloadAttachment(contentId).getRequestedUrl();
  17325. },
  17326. view: function (APIService, contentId) {
  17327. return APIService.attachmentsPreviewUrl(contentId);
  17328. },
  17329. download: function (APIService, contentId, item) {
  17330. var item = {
  17331. url: APIService.download(contentId),
  17332. headers: headers,
  17333. };
  17334. return item;
  17335. },
  17336. refreshDelay: 0,
  17337. },
  17338. };
  17339. },
  17340. controller: [
  17341. "$scope",
  17342. "$timeout",
  17343. "$modal",
  17344. "$rootScope",
  17345. "$http",
  17346. "up_down_file",
  17347. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  17348. var _refreshDelayPromise;
  17349. /**
  17350. * refresh
  17351. */
  17352. $scope._refresh = function (refreshAttr) {
  17353. $scope.attachments = [];
  17354. if (refreshAttr !== undefined) {
  17355. if (_refreshDelayPromise) {
  17356. $timeout.cancel(_refreshDelayPromise);
  17357. }
  17358. _refreshDelayPromise = $timeout(function () {
  17359. // 暂存附件
  17360. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  17361. $scope.options.templateOptions
  17362. .refresh(
  17363. $scope.options.templateOptions.ApiService,
  17364. $scope.options.templateOptions.processInstanceId,
  17365. {
  17366. idx: 0,
  17367. sum: 1000,
  17368. }
  17369. )
  17370. .then(function (response) {
  17371. var myData =
  17372. $scope.options.templateOptions.Restangular.stripRestangular(
  17373. response
  17374. );
  17375. if (myData) {
  17376. for (var i = 0; i < myData.data.length; i++) {
  17377. $scope.attachments.push(myData.data[i]);
  17378. }
  17379. }
  17380. $scope.options.templateOptions
  17381. .refresh(
  17382. $scope.options.templateOptions.ApiService,
  17383. $scope.$parent.$parent.$parent.model.save_fileId,
  17384. {
  17385. idx: 0,
  17386. sum: 1000,
  17387. }
  17388. )
  17389. .then(function (response2) {
  17390. var myData2 =
  17391. $scope.options.templateOptions.Restangular.stripRestangular(
  17392. response2
  17393. );
  17394. if (myData2) {
  17395. for (var i = 0; i < myData2.data.length; i++) {
  17396. $scope.attachments.push(myData2.data[i]);
  17397. }
  17398. }
  17399. console.log($scope.attachments);
  17400. });
  17401. });
  17402. // 正常附件
  17403. } else {
  17404. $scope.options.templateOptions
  17405. .refresh(
  17406. $scope.options.templateOptions.ApiService,
  17407. $scope.options.templateOptions.processInstanceId,
  17408. {
  17409. idx: 0,
  17410. sum: 1000,
  17411. }
  17412. )
  17413. .then(function (response) {
  17414. var myData =
  17415. $scope.options.templateOptions.Restangular.stripRestangular(
  17416. response
  17417. );
  17418. if (myData) {
  17419. $scope.attachments = [];
  17420. $scope.imgs = [];
  17421. myData.data.forEach((e) => {
  17422. if (
  17423. e.suffix == "jpeg" ||
  17424. e.suffix == "jpg" ||
  17425. e.suffix == "svg" ||
  17426. e.suffix == "png" ||
  17427. e.suffix == "bmp" ||
  17428. e.suffix == "gif" ||
  17429. e.suffix == "tif"
  17430. ) {
  17431. $scope.imgs.push(e);
  17432. }
  17433. });
  17434. $scope.imgs = $scope.imgs.splice(0, 3);
  17435. console.log($scope.imgs);
  17436. }
  17437. });
  17438. }
  17439. }, $scope.options.templateOptions.refreshDelay);
  17440. }
  17441. };
  17442. $scope._refresh({});
  17443. // $scope.attachments = $scope.model[$scope.options.key]
  17444. // 预览
  17445. $scope.preview = function (url, idx) {
  17446. var title = $scope.imgs[idx].title;
  17447. $modal.open({
  17448. backdrop: false,
  17449. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17450. controller: function ($scope, scope, $modalInstance) {
  17451. $scope.title = title;
  17452. $scope.imageurl = url;
  17453. $scope.cancel = function () {
  17454. $modalInstance.dismiss("cancel");
  17455. };
  17456. },
  17457. resolve: {
  17458. scope: function () {
  17459. return $scope;
  17460. },
  17461. },
  17462. });
  17463. };
  17464. },
  17465. ],
  17466. });
  17467. //工单/受理人控件
  17468. formlyConfigProvider.setType({
  17469. name: "ui-workernumbersign",
  17470. // extends: 'label',
  17471. templateUrl: "assets/views/customform/tpl/ui-workernumbersign.html",
  17472. controller: [
  17473. "$scope",
  17474. function ($scope) {
  17475. // 2020年4月24日13:20:40
  17476. console.log($scope, "docu");
  17477. // 左侧事件工单区域地点填充
  17478. $scope.model.selecthouseNumber = $scope.model.place;
  17479. if (
  17480. angular.isUndefined($scope.model[$scope.options.key]) ||
  17481. $scope.model[$scope.options.key] == null
  17482. ) {
  17483. setTimeout(function () {
  17484. $scope.options.templateOptions
  17485. .getWorkernumber($scope.options.templateOptions.ApiService)
  17486. .then(function (result) {
  17487. var modelData =
  17488. $scope.options.templateOptions.Restangular.stripRestangular(
  17489. result
  17490. );
  17491. if (modelData.status == 200) {
  17492. $scope.model[$scope.options.key] = modelData.data;
  17493. $scope.options.initialValue =
  17494. $scope.model[$scope.options.key];
  17495. }
  17496. });
  17497. }, 1000);
  17498. }
  17499. if (
  17500. $scope.options.templateOptions.user &&
  17501. (angular.isUndefined($scope.model.acceptUser) ||
  17502. $scope.model.acceptUser == null)
  17503. ) {
  17504. if (angular.isFunction($scope.options.templateOptions.transform)) {
  17505. // if ($scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user)) {
  17506. // $scope.$parent.$parent.$parent.model['start_code'] = $scope.options.templateOptions.transform($scope.options, $scope.model, $scope.options.templateOptions.user);
  17507. // }
  17508. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17509. $scope.$parent.$parent.$parent.model["directClose"] = false;
  17510. $scope.$parent.$parent.$parent.model["isHandlerUser"] = false;
  17511. }
  17512. $scope.model.acceptUser = $scope.options.templateOptions.user;
  17513. // $scope.options.initialValue = $scope.model.acceptUser;
  17514. }
  17515. },
  17516. ],
  17517. });
  17518. //工单控件-only number
  17519. formlyConfigProvider.setType({
  17520. name: "ui-workernumber",
  17521. extends: "input",
  17522. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17523. controller: [
  17524. "$scope",
  17525. function ($scope) {
  17526. if (
  17527. angular.isUndefined($scope.model[$scope.options.key]) ||
  17528. $scope.model[$scope.options.key] == null
  17529. ) {
  17530. setTimeout(function () {
  17531. $scope.options.templateOptions
  17532. .getWorkernumber($scope.options.templateOptions.ApiService)
  17533. .then(function (result) {
  17534. var modelData =
  17535. $scope.options.templateOptions.Restangular.stripRestangular(
  17536. result
  17537. );
  17538. if (modelData.status == 200) {
  17539. $scope.model[$scope.options.key] = modelData.data;
  17540. $scope.options.initialValue =
  17541. $scope.model[$scope.options.key];
  17542. }
  17543. });
  17544. }, 1000);
  17545. }
  17546. },
  17547. ],
  17548. });
  17549. //cmdb工单
  17550. formlyConfigProvider.setType({
  17551. name: "ui-cmdbworkernumber",
  17552. extends: "input",
  17553. templateUrl: "assets/views/customform/tpl/ui-workernumber.html",
  17554. controller: [
  17555. "$scope",
  17556. function ($scope) {
  17557. if (
  17558. angular.isUndefined($scope.model[$scope.options.key]) ||
  17559. $scope.model[$scope.options.key] == null
  17560. ) {
  17561. setTimeout(function () {
  17562. $scope.options.templateOptions
  17563. .getWorkernumber(
  17564. $scope.options.templateOptions.ApiService,
  17565. $scope.$parent.$parent.$parent.$parent.$parent.$parent.$parent
  17566. .cifilter_classics.id
  17567. )
  17568. .then(function (result) {
  17569. var modelData =
  17570. $scope.options.templateOptions.Restangular.stripRestangular(
  17571. result
  17572. );
  17573. // if(modelData.status==200){
  17574. $scope.model[$scope.options.key] =
  17575. modelData[$scope.options.key];
  17576. $scope.options.initialValue = $scope.model[$scope.options.key];
  17577. // }
  17578. });
  17579. }, 1000);
  17580. }
  17581. },
  17582. ],
  17583. });
  17584. //简易上传图片组件
  17585. formlyConfigProvider.setType({
  17586. name: "ui-uploadImgs",
  17587. templateUrl: "assets/views/customform/tpl/ui-uploadImgs.html",
  17588. wrapper: ["bootstrapHasError"],
  17589. controller: [
  17590. "$scope",
  17591. "fileReader",
  17592. "$parse",
  17593. "$modal",
  17594. function ($scope, fileReader, $parse, $modal) {
  17595. $scope.imgshows = [];
  17596. $scope.uploadimgs = [];
  17597. var model = $parse("upload_img");
  17598. var modelSetter = model.assign;
  17599. var uploader = ($scope.uploader =
  17600. $scope.options.templateOptions.fileUploader);
  17601. uploader.filters.push({
  17602. name: "customFilter",
  17603. fn: function (item /*{File|FileLikeObject}*/, options) {
  17604. return this.queue.length < 10;
  17605. },
  17606. });
  17607. // 添加
  17608. $scope.change = function (event) {
  17609. var element = $(".upinp");
  17610. modelSetter($scope, element[0].files[0]);
  17611. //附件预览
  17612. $scope.imgupload = event.files[0];
  17613. getFile($scope.imgupload, $scope);
  17614. //获得预览图地址并且把file对象放入上传合集内
  17615. function getFile(imgupload, $scope) {
  17616. if (!imgupload) {
  17617. return;
  17618. }
  17619. fileReader.readAsDataUrl(imgupload, $scope).then(function (result) {
  17620. $scope.imgshows.push(result);
  17621. var file = document.querySelector("input[type=file]").files[0];
  17622. $scope.uploadimgs.push(file); //这里是放着传给后台的数据file,下面controller的时候会有
  17623. console.log($scope.imgshows, $scope.uploadimgs);
  17624. if ($scope.imgshows.length < 3) {
  17625. $("#upup").show();
  17626. } else {
  17627. $("#upup").hide();
  17628. }
  17629. });
  17630. }
  17631. };
  17632. // 删除
  17633. $scope.uploadimg_del = function (index, imgs) {
  17634. console.log(index, imgs);
  17635. $scope.imgshows.splice(index, 1);
  17636. $scope.uploadimgs.splice(index, 1);
  17637. if ($scope.imgshows.length < 3) {
  17638. $("#upup").show();
  17639. } else {
  17640. $("#upup").hide();
  17641. }
  17642. };
  17643. // 预览
  17644. $scope.preview = function (url, idx) {
  17645. var name = $scope.uploadimgs[idx].name;
  17646. $modal.open({
  17647. backdrop: false,
  17648. templateUrl: "assets/views/customform/tpl/ui-showimage.html",
  17649. controller: function ($scope, scope, $modalInstance) {
  17650. $scope.title = name;
  17651. $scope.imageurl = url;
  17652. $scope.cancel = function () {
  17653. $modalInstance.dismiss("cancel");
  17654. };
  17655. },
  17656. resolve: {
  17657. scope: function () {
  17658. return $scope;
  17659. },
  17660. },
  17661. });
  17662. };
  17663. if (uploader) {
  17664. uploader.onWhenAddingFileFailed = function (
  17665. item /*{File|FileLikeObject}*/,
  17666. filter,
  17667. options
  17668. ) {
  17669. console.info("onWhenAddingFileFailed", item, filter, options);
  17670. };
  17671. uploader.onAfterAddingFile = function (fileItem) {
  17672. console.info("onAfterAddingFile", fileItem);
  17673. };
  17674. uploader.onAfterAddingAll = function (addedFileItems) {
  17675. console.info("onAfterAddingAll", addedFileItems);
  17676. };
  17677. uploader.onBeforeUploadItem = function (item) {
  17678. console.info("onBeforeUploadItem", item);
  17679. };
  17680. uploader.onProgressItem = function (fileItem, progress) {
  17681. console.info("onProgressItem", fileItem, progress);
  17682. };
  17683. uploader.onProgressAll = function (progress) {
  17684. console.info("onProgressAll", progress);
  17685. };
  17686. uploader.onSuccessItem = function (
  17687. fileItem,
  17688. response,
  17689. status,
  17690. headers
  17691. ) {
  17692. console.info("onSuccessItem", fileItem, response, status, headers);
  17693. };
  17694. uploader.onErrorItem = function (
  17695. fileItem,
  17696. response,
  17697. status,
  17698. headers
  17699. ) {
  17700. console.info("onErrorItem", fileItem, response, status, headers);
  17701. };
  17702. uploader.onCancelItem = function (
  17703. fileItem,
  17704. response,
  17705. status,
  17706. headers
  17707. ) {
  17708. console.info("onCancelItem", fileItem, response, status, headers);
  17709. };
  17710. uploader.onCompleteItem = function (
  17711. fileItem,
  17712. response,
  17713. status,
  17714. headers
  17715. ) {
  17716. console.info("onCompleteItem", fileItem, response, status, headers);
  17717. };
  17718. uploader.onCompleteAll = function () {
  17719. console.info("onCompleteAll");
  17720. };
  17721. }
  17722. // console.log(modelSetter)
  17723. },
  17724. ],
  17725. });
  17726. //jry-上传下载一体
  17727. formlyConfigProvider.setType({
  17728. name: "ui-upDropFile",
  17729. templateUrl: "assets/views/customform/tpl/ui-upDropFile.html",
  17730. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  17731. defaultOptions: function (options) {
  17732. return {
  17733. templateOptions: {
  17734. view: function (APIService, contentId) {
  17735. return APIService.downloadAttachment(contentId);
  17736. },
  17737. // ApiService: 'api_wechatfile',
  17738. // refresh: "(function(APIService,model,data){return APIService.listAttachments(model, data)})",
  17739. // upUrl: 'common/common/uploadAttachment',
  17740. // listAttachmentUrl: 'common/common/listAttachment',
  17741. // downUrl: 'common/common/downloadAttachment',
  17742. // bindType: 'incident',
  17743. // bindId: 2323
  17744. },
  17745. // validators: {
  17746. // required: {
  17747. // expression: function(viewValue, modelValue) {
  17748. // var value = modelValue || viewValue;
  17749. // return value.length >= 1;
  17750. // }
  17751. // }
  17752. // }
  17753. };
  17754. },
  17755. controller: [
  17756. "$scope",
  17757. "$rootScope",
  17758. "Restangular",
  17759. "up_down_file",
  17760. "$http",
  17761. "api_bpm",
  17762. function ($scope, $rootScope, Restangular, up_down_file, $http, api_bpm) {
  17763. console.log($scope);
  17764. $scope.showFileUp = true;
  17765. if ($scope.model.isKnowledge_detail) {
  17766. $scope.showFileUp = false;
  17767. }
  17768. if (angular.isUndefined($scope.form.dropState)) {
  17769. $scope.form.dropState = false;
  17770. }
  17771. if ($scope.model.incident) {
  17772. if ($scope.model.incident.alarm) {
  17773. console.log($scope);
  17774. if ($scope.model.incident.alarm) {
  17775. if ($scope.model.incident.alarm.alarmExtension) {
  17776. $scope.model.incident.alarm.alarmExtension =
  17777. $scope.model.incident.alarm.alarmExtension.replace("{", "");
  17778. $scope.model.incident.alarm.alarmExtension =
  17779. $scope.model.incident.alarm.alarmExtension.replace("}", "");
  17780. $scope.model.incident.description =
  17781. $scope.model.incident.alarm.alarmExtension;
  17782. console.log($scope.model.incident.description);
  17783. $scope.model.incident.description =
  17784. '"' +
  17785. "告警名称" +
  17786. '":' +
  17787. '"' +
  17788. $scope.model.incident.alarm.alarmSystem +
  17789. '",' +
  17790. '"' +
  17791. "告警状态" +
  17792. '":' +
  17793. '"' +
  17794. $scope.model.incident.alarm.alarmStatus +
  17795. '",' +
  17796. '"' +
  17797. "告警内容" +
  17798. '":' +
  17799. '"' +
  17800. $scope.model.incident.alarm.alarmContent +
  17801. '",' +
  17802. $scope.model.incident.description;
  17803. } else {
  17804. $scope.model.incident.description =
  17805. '"' +
  17806. "告警名称" +
  17807. '":' +
  17808. '"' +
  17809. $scope.model.incident.alarm.alarmSystem +
  17810. '",' +
  17811. '"' +
  17812. "告警状态" +
  17813. '":' +
  17814. '"' +
  17815. $scope.model.incident.alarm.alarmStatus +
  17816. '",' +
  17817. '"' +
  17818. "告警内容" +
  17819. '":' +
  17820. '"' +
  17821. $scope.model.incident.alarm.alarmContent +
  17822. '",';
  17823. }
  17824. $scope.model.incident.description =
  17825. $scope.model.incident.description.replace(/,/g, "\n");
  17826. console.log($scope.model.incident.description);
  17827. }
  17828. }
  17829. api_bpm
  17830. .tellCategory($scope.model.incident.category.id)
  17831. .then(function (wt_data) {
  17832. console.log(wt_data);
  17833. if (wt_data) {
  17834. $rootScope.wt_category = wt_data.data;
  17835. $rootScope.wt_categoryId = $scope.model.incident.category.id;
  17836. $rootScope.wt_child = wt_data.child;
  17837. }
  17838. });
  17839. if ($scope.model.titleName == "接单") {
  17840. $scope.model.receive_code = "handler";
  17841. if (
  17842. $scope.model.incident.groupLeader &&
  17843. !$scope.model.incident.repeat
  17844. ) {
  17845. $scope.model.isHandlerUser = true;
  17846. }
  17847. }
  17848. if ($scope.model.titleName == "事件处理") {
  17849. console.log($scope.model.cmdbCode);
  17850. if ($scope.model.cmdbCode) {
  17851. $scope.model.incident.cmdbCode = $scope.model.cmdbCode;
  17852. }
  17853. }
  17854. } else {
  17855. $rootScope.wt_category = "";
  17856. }
  17857. //附件上传数据
  17858. if ($scope.options.templateOptions.fileUploader) {
  17859. var uploader = ($scope.uploader =
  17860. $scope.options.templateOptions.fileUploader);
  17861. //$scope.options.templateOptions.uploader();
  17862. console.log(uploader);
  17863. // FILTERS
  17864. uploader.filters.push({
  17865. name: "customFilter",
  17866. fn: function (item /*{File|FileLikeObject}*/, options) {
  17867. return this.queue.length < 10;
  17868. },
  17869. });
  17870. }
  17871. var to = $scope.options.templateOptions;
  17872. // var bindType = $scope.model.bindType;
  17873. if (to.bindType == "incident") {
  17874. var bindId = $scope.model[to.bindType].processInstanceId;
  17875. } else if (to.bindType == "change") {
  17876. var bindId = $scope.model[to.bindType].processInstanceId;
  17877. } else {
  17878. var bindId = $scope.model[to.bindType].id;
  17879. }
  17880. //获取附件列表
  17881. $scope.listAttachmen = function () {
  17882. to.ApiService.listAttachment(
  17883. to.listAttachmentUrl,
  17884. to.bindType,
  17885. bindId
  17886. ).then(function (result) {
  17887. var myData = Restangular.stripRestangular(result);
  17888. // $scope.listAttachmens = myData;
  17889. $scope.attachments = myData.data;
  17890. });
  17891. };
  17892. if (to.bindType && $scope.model[to.bindType].processInstanceId) {
  17893. $scope.listAttachmen();
  17894. } else if (to.bindType && $scope.model[to.bindType].id) {
  17895. $scope.listAttachmen();
  17896. }
  17897. //附件上传
  17898. $scope.isUpfload = to.isUpfload;
  17899. $scope.dropfile = function (
  17900. APIService,
  17901. processInstanceId,
  17902. taskId,
  17903. userId
  17904. ) {
  17905. uploader.onBeforeUploadItem = function (item) {
  17906. angular.extend(item.headers, $rootScope.getSession());
  17907. item.url = to.ApiService.saveAttachments(
  17908. to.uploadUrl,
  17909. to.bindType,
  17910. bindId
  17911. ).getRequestedUrl();
  17912. item.formData.push({
  17913. filename: item.file.name,
  17914. });
  17915. };
  17916. uploader.uploadAll();
  17917. };
  17918. //附件下载
  17919. $scope.download = function (attachment) {
  17920. // $scope.download = function (token, filename) {
  17921. var downUrl = attachment.previewUrl;
  17922. // var downUrl = to.ApiService.downloadAttachment(
  17923. // to.downUrl,
  17924. // token
  17925. // ).getRequestedUrl();
  17926. // window.open(downUrl);
  17927. var a = document.createElement("a");
  17928. a.href = downUrl;
  17929. a.target = "_blank";
  17930. a.download = attachment.name;
  17931. document.body.appendChild(a);
  17932. a.click();
  17933. };
  17934. //附件预览
  17935. $scope.view = function (id, previewUrl) {
  17936. if (previewUrl) {
  17937. window.open(previewUrl);
  17938. }
  17939. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, bindId).then(function(response) {
  17940. // if (response.state == 200) {
  17941. // window.open(response.previewUrl);
  17942. // }
  17943. // })
  17944. };
  17945. // CALLBACKS
  17946. if (uploader) {
  17947. uploader.onWhenAddingFileFailed = function (
  17948. item /*{File|FileLikeObject}*/,
  17949. filter,
  17950. options
  17951. ) {
  17952. console.info("onWhenAddingFileFailed", item, filter, options);
  17953. };
  17954. uploader.onAfterAddingFile = function (fileItem) {
  17955. console.info("onAfterAddingFile", fileItem);
  17956. };
  17957. uploader.onAfterAddingAll = function (addedFileItems) {
  17958. console.info("onAfterAddingAll", addedFileItems);
  17959. };
  17960. uploader.onBeforeUploadItem = function (item) {
  17961. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  17962. // // $scope.uploader.options.url();
  17963. // $scope.uploader.onBeforeUploadItem = function(item) {
  17964. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  17965. // console.info('onBeforeUploadItem', item);
  17966. // };
  17967. // $scope.uploader.uploadAll();
  17968. // }
  17969. console.info("onBeforeUploadItem", item);
  17970. };
  17971. uploader.onProgressItem = function (fileItem, progress) {
  17972. console.info("onProgressItem", fileItem, progress);
  17973. };
  17974. uploader.onProgressAll = function (progress) {
  17975. console.info("onProgressAll", progress);
  17976. };
  17977. uploader.onSuccessItem = function (
  17978. fileItem,
  17979. response,
  17980. status,
  17981. headers
  17982. ) {
  17983. console.info("onSuccessItem", fileItem, response, status, headers);
  17984. if (response.status == 200) {
  17985. $scope.listAttachmen();
  17986. }
  17987. };
  17988. uploader.onErrorItem = function (
  17989. fileItem,
  17990. response,
  17991. status,
  17992. headers
  17993. ) {
  17994. console.info("onErrorItem", fileItem, response, status, headers);
  17995. };
  17996. uploader.onCancelItem = function (
  17997. fileItem,
  17998. response,
  17999. status,
  18000. headers
  18001. ) {
  18002. console.info("onCancelItem", fileItem, response, status, headers);
  18003. };
  18004. uploader.onCompleteItem = function (
  18005. fileItem,
  18006. response,
  18007. status,
  18008. headers
  18009. ) {
  18010. console.info("onCompleteItem", fileItem, response, status, headers);
  18011. };
  18012. uploader.onCompleteAll = function () {
  18013. console.info("onCompleteAll");
  18014. };
  18015. }
  18016. },
  18017. ],
  18018. });
  18019. //简易上传下载附件组件
  18020. formlyConfigProvider.setType({
  18021. name: "ui-upDownFiles",
  18022. templateUrl: "assets/views/customform/tpl/ui-upDownFiles.html",
  18023. wrapper: ["bootstrapHasError"],
  18024. defaultOptions: function (options) {
  18025. return {
  18026. templateOptions: {
  18027. refresh: function (APIService, processInstanceId, data) {
  18028. return APIService.listAttachments(processInstanceId);
  18029. },
  18030. downloadUri: function (APIService, contentId) {
  18031. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18032. },
  18033. view: function (APIService, contentId) {
  18034. return APIService.attachmentsPreviewUrl(contentId);
  18035. },
  18036. download: function (APIService, contentId, item) {
  18037. var item = {
  18038. url: APIService.download(contentId),
  18039. headers: headers,
  18040. };
  18041. return item;
  18042. },
  18043. refreshDelay: 0,
  18044. },
  18045. };
  18046. },
  18047. controller: [
  18048. "$scope",
  18049. "$timeout",
  18050. "$modal",
  18051. "$rootScope",
  18052. "$http",
  18053. "up_down_file",
  18054. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18055. if (angular.isUndefined($scope.form.dropState)) {
  18056. $scope.form.dropState = false;
  18057. }
  18058. //附件上传数据
  18059. var uploader = ($scope.uploader =
  18060. $scope.options.templateOptions.fileUploader);
  18061. //$scope.options.templateOptions.uploader();
  18062. // FILTERS
  18063. uploader.filters.push({
  18064. name: "customFilter",
  18065. fn: function (item /*{File|FileLikeObject}*/, options) {
  18066. return this.queue.length < 10;
  18067. },
  18068. });
  18069. // $scope.dropfile = function (APIService, processInstanceId, taskId, userId) {
  18070. // uploader.onBeforeUploadItem = function (item) {
  18071. // angular.extend(item.headers, $rootScope.getSession());
  18072. // item.url = APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl();
  18073. // item.formData.push({
  18074. // 'fileName': item.file.name
  18075. // });
  18076. // console.info('onBeforeUploadItem', item);
  18077. // };
  18078. // }
  18079. // CALLBACKS
  18080. uploader.onWhenAddingFileFailed = function (
  18081. item /*{File|FileLikeObject}*/,
  18082. filter,
  18083. options
  18084. ) {
  18085. console.info("onWhenAddingFileFailed", item, filter, options);
  18086. };
  18087. uploader.onAfterAddingFile = function (fileItem) {
  18088. console.info("onAfterAddingFile", fileItem);
  18089. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18090. alert("文件过大");
  18091. fileItem.uploader.queue.pop();
  18092. console.log($scope);
  18093. }
  18094. };
  18095. uploader.onAfterAddingAll = function (addedFileItems) {
  18096. // console.info('onAfterAddingAll', addedFileItems);
  18097. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18098. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18099. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18100. // console.log(123)
  18101. };
  18102. uploader.onBeforeUploadItem = function (item) {
  18103. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18104. // // $scope.uploader.options.url();
  18105. // $scope.uploader.onBeforeUploadItem = function(item) {
  18106. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18107. // console.info('onBeforeUploadItem', item);
  18108. // };
  18109. // $scope.uploader.uploadAll();
  18110. // }
  18111. console.info("onBeforeUploadItem", item);
  18112. };
  18113. uploader.onProgressItem = function (fileItem, progress) {
  18114. console.info("onProgressItem", fileItem, progress);
  18115. };
  18116. uploader.onProgressAll = function (progress) {
  18117. console.info("onProgressAll", progress);
  18118. };
  18119. uploader.onSuccessItem = function (
  18120. fileItem,
  18121. response,
  18122. status,
  18123. headers
  18124. ) {
  18125. console.info("onSuccessItem", fileItem, response, status, headers);
  18126. };
  18127. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18128. console.info("onErrorItem", fileItem, response, status, headers);
  18129. };
  18130. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18131. console.info("onCancelItem", fileItem, response, status, headers);
  18132. };
  18133. uploader.onCompleteItem = function (
  18134. fileItem,
  18135. response,
  18136. status,
  18137. headers
  18138. ) {
  18139. console.info("onCompleteItem", fileItem, response, status, headers);
  18140. };
  18141. uploader.onCompleteAll = function () {
  18142. console.info("onCompleteAll");
  18143. };
  18144. var _refreshDelayPromise;
  18145. // 下载
  18146. $scope.download = function (contentId, filename, token) {
  18147. // console.log(contentId, filename, token)
  18148. //附件下载
  18149. var downUrl = up_down_file
  18150. .downloadAttachment("common/common/downloadAttachment", token)
  18151. .getRequestedUrl();
  18152. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18153. // console.log(downUrl)
  18154. var a = document.createElement("a");
  18155. a.href = downUrl;
  18156. a.target = "_blank";
  18157. a.download = filename;
  18158. document.body.appendChild(a);
  18159. a.click();
  18160. };
  18161. $scope._refresh = function (refreshAttr) {
  18162. $scope.attachments = [];
  18163. if (refreshAttr !== undefined) {
  18164. if (_refreshDelayPromise) {
  18165. $timeout.cancel(_refreshDelayPromise);
  18166. }
  18167. _refreshDelayPromise = $timeout(function () {
  18168. // 暂存附件
  18169. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18170. $scope.options.templateOptions
  18171. .refresh(
  18172. $scope.options.templateOptions.ApiService,
  18173. $scope.options.templateOptions.processInstanceId,
  18174. {
  18175. idx: 0,
  18176. sum: 1000,
  18177. }
  18178. )
  18179. .then(function (response) {
  18180. var myData =
  18181. $scope.options.templateOptions.Restangular.stripRestangular(
  18182. response
  18183. );
  18184. if (myData) {
  18185. for (var i = 0; i < myData.data.length; i++) {
  18186. $scope.attachments.push(myData.data[i]);
  18187. }
  18188. }
  18189. $scope.options.templateOptions
  18190. .refresh(
  18191. $scope.options.templateOptions.ApiService,
  18192. $scope.$parent.$parent.$parent.model.save_fileId,
  18193. {
  18194. idx: 0,
  18195. sum: 1000,
  18196. }
  18197. )
  18198. .then(function (response2) {
  18199. var myData2 =
  18200. $scope.options.templateOptions.Restangular.stripRestangular(
  18201. response2
  18202. );
  18203. if (myData2) {
  18204. for (var i = 0; i < myData2.data.length; i++) {
  18205. $scope.attachments.push(myData2.data[i]);
  18206. }
  18207. // 只展示除图片以外的附件
  18208. var a = [];
  18209. $scope.attachments.forEach((e) => {
  18210. if (
  18211. e.suffix == "jpeg" ||
  18212. e.suffix == "jpg" ||
  18213. e.suffix == "svg" ||
  18214. e.suffix == "png" ||
  18215. e.suffix == "bmp" ||
  18216. e.suffix == "gif" ||
  18217. e.suffix == "tif"
  18218. ) {
  18219. // $scope.imgs.push(e)
  18220. } else {
  18221. a.push(e);
  18222. }
  18223. });
  18224. $scope.attachments = a;
  18225. }
  18226. console.log($scope.attachments);
  18227. });
  18228. });
  18229. // 正常附件
  18230. } else {
  18231. $scope.options.templateOptions
  18232. .refresh(
  18233. $scope.options.templateOptions.ApiService,
  18234. $scope.options.templateOptions.processInstanceId,
  18235. {
  18236. idx: 0,
  18237. sum: 1000,
  18238. }
  18239. )
  18240. .then(function (response) {
  18241. var myData =
  18242. $scope.options.templateOptions.Restangular.stripRestangular(
  18243. response
  18244. );
  18245. if (myData) {
  18246. $scope.attachments = myData.data;
  18247. // 只展示除图片以外的附件
  18248. var a = [];
  18249. $scope.attachments.forEach((e) => {
  18250. if (
  18251. e.suffix == "jpeg" ||
  18252. e.suffix == "jpg" ||
  18253. e.suffix == "svg" ||
  18254. e.suffix == "png" ||
  18255. e.suffix == "bmp" ||
  18256. e.suffix == "gif" ||
  18257. e.suffix == "tif"
  18258. ) {
  18259. // $scope.imgs.push(e)
  18260. } else {
  18261. a.push(e);
  18262. }
  18263. });
  18264. $scope.attachments = a;
  18265. }
  18266. });
  18267. }
  18268. }, $scope.options.templateOptions.refreshDelay);
  18269. }
  18270. };
  18271. $scope._refresh({});
  18272. },
  18273. ],
  18274. });
  18275. //简易上传附件组件
  18276. formlyConfigProvider.setType({
  18277. name: "ui-uploadFiles",
  18278. templateUrl: "assets/views/customform/tpl/ui-uploadFiles.html",
  18279. wrapper: ["bootstrapHasError"],
  18280. controller: [
  18281. "$scope",
  18282. function ($scope) {
  18283. if (angular.isUndefined($scope.form.dropState)) {
  18284. $scope.form.dropState = false;
  18285. }
  18286. //附件上传数据
  18287. var uploader = ($scope.uploader =
  18288. $scope.options.templateOptions.fileUploader);
  18289. //$scope.options.templateOptions.uploader();
  18290. // FILTERS
  18291. uploader.filters.push({
  18292. name: "customFilter",
  18293. fn: function (item /*{File|FileLikeObject}*/, options) {
  18294. return this.queue.length < 10;
  18295. },
  18296. });
  18297. $scope.dropfile = function (
  18298. APIService,
  18299. processInstanceId,
  18300. taskId,
  18301. userId
  18302. ) {
  18303. uploader.onBeforeUploadItem = function (item) {
  18304. angular.extend(item.headers, $rootScope.getSession());
  18305. item.url = APIService.saveAttachments(
  18306. processInstanceId,
  18307. taskId,
  18308. userId
  18309. ).getRequestedUrl();
  18310. item.formData.push({
  18311. fileName: item.file.name,
  18312. });
  18313. console.info("onBeforeUploadItem", item);
  18314. };
  18315. };
  18316. // CALLBACKS
  18317. uploader.onWhenAddingFileFailed = function (
  18318. item /*{File|FileLikeObject}*/,
  18319. filter,
  18320. options
  18321. ) {
  18322. console.info("onWhenAddingFileFailed", item, filter, options);
  18323. };
  18324. uploader.onAfterAddingFile = function (fileItem) {
  18325. console.info("onAfterAddingFile", fileItem);
  18326. if (fileItem.file.size >= 1024 * 1024 * 10) {
  18327. alert("文件过大");
  18328. fileItem.uploader.queue.pop();
  18329. console.log($scope);
  18330. }
  18331. };
  18332. uploader.onAfterAddingAll = function (addedFileItems) {
  18333. // console.info('onAfterAddingAll', addedFileItems);
  18334. // console.log($scope.options.templateOptions.APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18335. // console.log(APIService.saveAttachments(processInstanceId, taskId, userId).getRequestedUrl())
  18336. // console.log(api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl())
  18337. // console.log(123)
  18338. };
  18339. uploader.onBeforeUploadItem = function (item) {
  18340. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18341. // // $scope.uploader.options.url();
  18342. // $scope.uploader.onBeforeUploadItem = function(item) {
  18343. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18344. // console.info('onBeforeUploadItem', item);
  18345. // };
  18346. // $scope.uploader.uploadAll();
  18347. // }
  18348. console.info("onBeforeUploadItem", item);
  18349. };
  18350. uploader.onProgressItem = function (fileItem, progress) {
  18351. console.info("onProgressItem", fileItem, progress);
  18352. };
  18353. uploader.onProgressAll = function (progress) {
  18354. console.info("onProgressAll", progress);
  18355. };
  18356. uploader.onSuccessItem = function (
  18357. fileItem,
  18358. response,
  18359. status,
  18360. headers
  18361. ) {
  18362. console.info("onSuccessItem", fileItem, response, status, headers);
  18363. };
  18364. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18365. console.info("onErrorItem", fileItem, response, status, headers);
  18366. };
  18367. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18368. console.info("onCancelItem", fileItem, response, status, headers);
  18369. };
  18370. uploader.onCompleteItem = function (
  18371. fileItem,
  18372. response,
  18373. status,
  18374. headers
  18375. ) {
  18376. console.info("onCompleteItem", fileItem, response, status, headers);
  18377. };
  18378. uploader.onCompleteAll = function () {
  18379. console.info("onCompleteAll");
  18380. };
  18381. },
  18382. ],
  18383. });
  18384. //无上传按钮附件上传组件
  18385. formlyConfigProvider.setType({
  18386. name: "ui-dropfilenotup",
  18387. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18388. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18389. controller: [
  18390. "$scope",
  18391. function ($scope) {
  18392. if (angular.isUndefined($scope.form.dropState)) {
  18393. $scope.form.dropState = false;
  18394. }
  18395. //附件上传数据
  18396. var uploader = ($scope.uploader =
  18397. $scope.options.templateOptions.fileUploader);
  18398. //$scope.options.templateOptions.uploader();
  18399. // FILTERS
  18400. uploader.filters.push({
  18401. name: "customFilter",
  18402. fn: function (item /*{File|FileLikeObject}*/, options) {
  18403. return this.queue.length < 10;
  18404. },
  18405. });
  18406. $scope.dropfile = function (
  18407. APIService,
  18408. processInstanceId,
  18409. taskId,
  18410. userId
  18411. ) {
  18412. uploader.onBeforeUploadItem = function (item) {
  18413. angular.extend(item.headers, $rootScope.getSession());
  18414. item.url = APIService.saveAttachments(
  18415. processInstanceId,
  18416. taskId,
  18417. userId
  18418. ).getRequestedUrl();
  18419. item.formData.push({
  18420. fileName: item.file.name,
  18421. });
  18422. console.info("onBeforeUploadItem", item);
  18423. };
  18424. uploader.uploadAll();
  18425. };
  18426. // CALLBACKS
  18427. uploader.onWhenAddingFileFailed = function (
  18428. item /*{File|FileLikeObject}*/,
  18429. filter,
  18430. options
  18431. ) {
  18432. console.info("onWhenAddingFileFailed", item, filter, options);
  18433. };
  18434. uploader.onAfterAddingFile = function (fileItem) {
  18435. console.info("onAfterAddingFile", fileItem);
  18436. };
  18437. uploader.onAfterAddingAll = function (addedFileItems) {
  18438. console.info("onAfterAddingAll", addedFileItems);
  18439. };
  18440. uploader.onBeforeUploadItem = function (item) {
  18441. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18442. // // $scope.uploader.options.url();
  18443. // $scope.uploader.onBeforeUploadItem = function(item) {
  18444. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18445. // console.info('onBeforeUploadItem', item);
  18446. // };
  18447. // $scope.uploader.uploadAll();
  18448. // }
  18449. console.info("onBeforeUploadItem", item);
  18450. };
  18451. uploader.onProgressItem = function (fileItem, progress) {
  18452. console.info("onProgressItem", fileItem, progress);
  18453. };
  18454. uploader.onProgressAll = function (progress) {
  18455. console.info("onProgressAll", progress);
  18456. };
  18457. uploader.onSuccessItem = function (
  18458. fileItem,
  18459. response,
  18460. status,
  18461. headers
  18462. ) {
  18463. console.info("onSuccessItem", fileItem, response, status, headers);
  18464. };
  18465. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18466. console.info("onErrorItem", fileItem, response, status, headers);
  18467. };
  18468. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18469. console.info("onCancelItem", fileItem, response, status, headers);
  18470. };
  18471. uploader.onCompleteItem = function (
  18472. fileItem,
  18473. response,
  18474. status,
  18475. headers
  18476. ) {
  18477. console.info("onCompleteItem", fileItem, response, status, headers);
  18478. };
  18479. uploader.onCompleteAll = function () {
  18480. console.info("onCompleteAll");
  18481. };
  18482. },
  18483. ],
  18484. });
  18485. //无按钮知识库上传
  18486. formlyConfigProvider.setType({
  18487. name: "ui-dropfielkn",
  18488. templateUrl: "assets/views/customform/tpl/ui-dropfilenotup.html",
  18489. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18490. controller: [
  18491. "$scope",
  18492. function ($scope) {
  18493. if (angular.isUndefined($scope.form.dropState)) {
  18494. $scope.form.dropState = false;
  18495. }
  18496. //附件上传数据
  18497. var uploader = ($scope.uploader =
  18498. $scope.options.templateOptions.fileUploader);
  18499. //$scope.options.templateOptions.uploader();
  18500. // FILTERS
  18501. uploader.filters.push({
  18502. name: "customFilter",
  18503. fn: function (item /*{File|FileLikeObject}*/, options) {
  18504. return this.queue.length < 10;
  18505. },
  18506. });
  18507. $scope.dropfile = function (
  18508. APIService,
  18509. processInstanceId,
  18510. taskId,
  18511. userId
  18512. ) {
  18513. uploader.onBeforeUploadItem = function (item) {
  18514. angular.extend(item.headers, $rootScope.getSession());
  18515. item.url = APIService.addFile(
  18516. processInstanceId,
  18517. taskId,
  18518. userId
  18519. ).getRequestedUrl();
  18520. item.formData.push({
  18521. fileName: item.file.name,
  18522. });
  18523. console.info("onBeforeUploadItem", item);
  18524. };
  18525. uploader.uploadAll();
  18526. };
  18527. // CALLBACKS
  18528. uploader.onWhenAddingFileFailed = function (
  18529. item /*{File|FileLikeObject}*/,
  18530. filter,
  18531. options
  18532. ) {
  18533. console.info("onWhenAddingFileFailed", item, filter, options);
  18534. };
  18535. uploader.onAfterAddingFile = function (fileItem) {
  18536. console.info("onAfterAddingFile", fileItem);
  18537. };
  18538. uploader.onAfterAddingAll = function (addedFileItems) {
  18539. console.info("onAfterAddingAll", addedFileItems);
  18540. };
  18541. uploader.onBeforeUploadItem = function (item) {
  18542. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18543. // // $scope.uploader.options.url();
  18544. // $scope.uploader.onBeforeUploadItem = function(item) {
  18545. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18546. // console.info('onBeforeUploadItem', item);
  18547. // };
  18548. // $scope.uploader.uploadAll();
  18549. // }
  18550. console.info("onBeforeUploadItem", item);
  18551. };
  18552. uploader.onProgressItem = function (fileItem, progress) {
  18553. console.info("onProgressItem", fileItem, progress);
  18554. };
  18555. uploader.onProgressAll = function (progress) {
  18556. console.info("onProgressAll", progress);
  18557. };
  18558. uploader.onSuccessItem = function (
  18559. fileItem,
  18560. response,
  18561. status,
  18562. headers
  18563. ) {
  18564. console.info("onSuccessItem", fileItem, response, status, headers);
  18565. };
  18566. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18567. console.info("onErrorItem", fileItem, response, status, headers);
  18568. };
  18569. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18570. console.info("onCancelItem", fileItem, response, status, headers);
  18571. };
  18572. uploader.onCompleteItem = function (
  18573. fileItem,
  18574. response,
  18575. status,
  18576. headers
  18577. ) {
  18578. console.info("onCompleteItem", fileItem, response, status, headers);
  18579. };
  18580. uploader.onCompleteAll = function () {
  18581. console.info("onCompleteAll");
  18582. };
  18583. },
  18584. ],
  18585. });
  18586. //附件上传列表组件
  18587. formlyConfigProvider.setType({
  18588. name: "ui-dropfile",
  18589. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18590. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18591. controller: [
  18592. "$scope",
  18593. "$rootScope",
  18594. function ($scope, $rootScope) {
  18595. if (angular.isUndefined($scope.form.dropState)) {
  18596. $scope.form.dropState = false;
  18597. }
  18598. //附件上传数据
  18599. var uploader = ($scope.uploader =
  18600. $scope.options.templateOptions.fileUploader);
  18601. //$scope.options.templateOptions.uploader();
  18602. // FILTERS
  18603. uploader.filters.push({
  18604. name: "customFilter",
  18605. fn: function (item /*{File|FileLikeObject}*/, options) {
  18606. return this.queue.length < 10;
  18607. },
  18608. });
  18609. $scope.dropfile = function (
  18610. APIService,
  18611. processInstanceId,
  18612. taskId,
  18613. userId
  18614. ) {
  18615. uploader.onBeforeUploadItem = function (item) {
  18616. angular.extend(item.headers, $rootScope.getSession());
  18617. if (
  18618. $scope.options.templateOptions.upservice &&
  18619. $scope.options.templateOptions.formname
  18620. ) {
  18621. // if ($scope.options.templateOptions.formket) {
  18622. // item.url = APIService[$scope.options.templateOptions.upservice]($scope.model[$scope.options.templateOptions.formname][$scope.options.templateOptions.formket].id, taskId, userId).getRequestedUrl();
  18623. // } else {
  18624. item.url = APIService[$scope.options.templateOptions.upservice](
  18625. $scope.model[$scope.options.templateOptions.formname].id,
  18626. taskId,
  18627. userId
  18628. ).getRequestedUrl();
  18629. // }
  18630. } else {
  18631. item.url = APIService.saveAttachments(
  18632. processInstanceId,
  18633. taskId,
  18634. userId
  18635. ).getRequestedUrl();
  18636. }
  18637. item.formData.push({
  18638. filename: item.file.name,
  18639. });
  18640. console.info("onBeforeUploadItem", item);
  18641. };
  18642. uploader.uploadAll();
  18643. };
  18644. // CALLBACKS
  18645. uploader.onWhenAddingFileFailed = function (
  18646. item /*{File|FileLikeObject}*/,
  18647. filter,
  18648. options
  18649. ) {
  18650. console.info("onWhenAddingFileFailed", item, filter, options);
  18651. };
  18652. uploader.onAfterAddingFile = function (fileItem) {
  18653. console.info("onAfterAddingFile", fileItem);
  18654. };
  18655. uploader.onAfterAddingAll = function (addedFileItems) {
  18656. console.info("onAfterAddingAll", addedFileItems);
  18657. };
  18658. uploader.onBeforeUploadItem = function (item) {
  18659. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18660. // // $scope.uploader.options.url();
  18661. // $scope.uploader.onBeforeUploadItem = function(item) {
  18662. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18663. // console.info('onBeforeUploadItem', item);
  18664. // };
  18665. // $scope.uploader.uploadAll();
  18666. // }
  18667. console.info("onBeforeUploadItem", item);
  18668. };
  18669. uploader.onProgressItem = function (fileItem, progress) {
  18670. console.info("onProgressItem", fileItem, progress);
  18671. };
  18672. uploader.onProgressAll = function (progress) {
  18673. console.info("onProgressAll", progress);
  18674. };
  18675. uploader.onSuccessItem = function (
  18676. fileItem,
  18677. response,
  18678. status,
  18679. headers
  18680. ) {
  18681. console.info("onSuccessItem", fileItem, response, status, headers);
  18682. };
  18683. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18684. console.info("onErrorItem", fileItem, response, status, headers);
  18685. };
  18686. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18687. console.info("onCancelItem", fileItem, response, status, headers);
  18688. };
  18689. uploader.onCompleteItem = function (
  18690. fileItem,
  18691. response,
  18692. status,
  18693. headers
  18694. ) {
  18695. console.info("onCompleteItem", fileItem, response, status, headers);
  18696. };
  18697. uploader.onCompleteAll = function () {
  18698. console.info("onCompleteAll");
  18699. };
  18700. },
  18701. ],
  18702. });
  18703. //简易附件展示下载列表组件
  18704. formlyConfigProvider.setType({
  18705. name: "ui-dropFiles",
  18706. templateUrl: "assets/views/customform/tpl/ui-dropFiles.html",
  18707. defaultOptions: function (options) {
  18708. return {
  18709. templateOptions: {
  18710. refresh: function (APIService, processInstanceId, data) {
  18711. return APIService.listAttachments(processInstanceId);
  18712. },
  18713. downloadUri: function (APIService, contentId) {
  18714. return APIService.downloadAttachment(contentId).getRequestedUrl();
  18715. },
  18716. view: function (APIService, contentId) {
  18717. return APIService.attachmentsPreviewUrl(contentId);
  18718. },
  18719. download: function (APIService, contentId, item) {
  18720. var item = {
  18721. url: APIService.download(contentId),
  18722. headers: headers,
  18723. };
  18724. return item;
  18725. },
  18726. refreshDelay: 0,
  18727. },
  18728. };
  18729. },
  18730. controller: [
  18731. "$scope",
  18732. "$timeout",
  18733. "$modal",
  18734. "$rootScope",
  18735. "$http",
  18736. "up_down_file",
  18737. function ($scope, $timeout, $modal, $rootScope, $http, up_down_file) {
  18738. var _refreshDelayPromise;
  18739. // $scope.downloadUrl = function(contentId){
  18740. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  18741. // };
  18742. $scope.download = function (contentId, filename, token) {
  18743. // console.log(contentId, filename, token)
  18744. //附件下载
  18745. var downUrl = up_down_file
  18746. .downloadAttachment("common/common/downloadAttachment", token)
  18747. .getRequestedUrl();
  18748. // downUrl = downUrl.substring(0, downUrl.lastIndexOf("/"));
  18749. // console.log(downUrl)
  18750. var a = document.createElement("a");
  18751. a.href = downUrl;
  18752. a.target = "_blank";
  18753. a.download = filename;
  18754. document.body.appendChild(a);
  18755. a.click();
  18756. };
  18757. $scope.view = function (contentId, token, filename, type) {
  18758. $scope.options.templateOptions
  18759. .view($scope.options.templateOptions.ApiService, contentId)
  18760. .then(function (response) {
  18761. if (response.state == 200) {
  18762. window.open(response.previewUrl);
  18763. }
  18764. });
  18765. };
  18766. /**
  18767. * refresh
  18768. */
  18769. $scope._refresh = function (refreshAttr) {
  18770. $scope.attachments = [];
  18771. if (refreshAttr !== undefined) {
  18772. if (_refreshDelayPromise) {
  18773. $timeout.cancel(_refreshDelayPromise);
  18774. }
  18775. _refreshDelayPromise = $timeout(function () {
  18776. // 暂存附件
  18777. if ($scope.$parent.$parent.$parent.model.save_fileId) {
  18778. $scope.options.templateOptions
  18779. .refresh(
  18780. $scope.options.templateOptions.ApiService,
  18781. $scope.options.templateOptions.processInstanceId,
  18782. {
  18783. idx: 0,
  18784. sum: 1000,
  18785. }
  18786. )
  18787. .then(function (response) {
  18788. var myData =
  18789. $scope.options.templateOptions.Restangular.stripRestangular(
  18790. response
  18791. );
  18792. if (myData) {
  18793. for (var i = 0; i < myData.data.length; i++) {
  18794. $scope.attachments.push(myData.data[i]);
  18795. }
  18796. }
  18797. $scope.options.templateOptions
  18798. .refresh(
  18799. $scope.options.templateOptions.ApiService,
  18800. $scope.$parent.$parent.$parent.model.save_fileId,
  18801. {
  18802. idx: 0,
  18803. sum: 1000,
  18804. }
  18805. )
  18806. .then(function (response2) {
  18807. var myData2 =
  18808. $scope.options.templateOptions.Restangular.stripRestangular(
  18809. response2
  18810. );
  18811. if (myData2) {
  18812. for (var i = 0; i < myData2.data.length; i++) {
  18813. $scope.attachments.push(myData2.data[i]);
  18814. }
  18815. // 只展示除图片以外的附件
  18816. var a = [];
  18817. $scope.attachments.forEach((e) => {
  18818. if (
  18819. e.suffix == "jpeg" ||
  18820. e.suffix == "jpg" ||
  18821. e.suffix == "svg" ||
  18822. e.suffix == "png" ||
  18823. e.suffix == "bmp" ||
  18824. e.suffix == "gif" ||
  18825. e.suffix == "tif"
  18826. ) {
  18827. // $scope.imgs.push(e)
  18828. } else {
  18829. a.push(e);
  18830. }
  18831. });
  18832. $scope.attachments = a;
  18833. }
  18834. console.log($scope.attachments);
  18835. });
  18836. });
  18837. // 正常附件
  18838. } else {
  18839. $scope.options.templateOptions
  18840. .refresh(
  18841. $scope.options.templateOptions.ApiService,
  18842. $scope.options.templateOptions.processInstanceId,
  18843. {
  18844. idx: 0,
  18845. sum: 1000,
  18846. }
  18847. )
  18848. .then(function (response) {
  18849. var myData =
  18850. $scope.options.templateOptions.Restangular.stripRestangular(
  18851. response
  18852. );
  18853. if (myData) {
  18854. $scope.attachments = myData.data;
  18855. // 只展示除图片以外的附件
  18856. var a = [];
  18857. $scope.attachments.forEach((e) => {
  18858. if (
  18859. e.suffix == "jpeg" ||
  18860. e.suffix == "jpg" ||
  18861. e.suffix == "svg" ||
  18862. e.suffix == "png" ||
  18863. e.suffix == "bmp" ||
  18864. e.suffix == "gif" ||
  18865. e.suffix == "tif"
  18866. ) {
  18867. // $scope.imgs.push(e)
  18868. } else {
  18869. a.push(e);
  18870. }
  18871. });
  18872. $scope.attachments = a;
  18873. console.log($scope.attachments);
  18874. }
  18875. });
  18876. }
  18877. }, $scope.options.templateOptions.refreshDelay);
  18878. }
  18879. };
  18880. $scope._refresh({});
  18881. // $scope.attachments = $scope.model[$scope.options.key]
  18882. },
  18883. ],
  18884. });
  18885. //知识库附件上传
  18886. formlyConfigProvider.setType({
  18887. name: "ui-dropfielknow",
  18888. templateUrl: "assets/views/customform/tpl/ui-dropfile.html",
  18889. wrapper: ["bootstrapLabel", "bootstrapHasError"],
  18890. controller: [
  18891. "$scope",
  18892. "$rootScope",
  18893. function ($scope, $rootScope) {
  18894. if (angular.isUndefined($scope.form.dropState)) {
  18895. $scope.form.dropState = false;
  18896. }
  18897. //附件上传数据
  18898. var uploader = ($scope.uploader =
  18899. $scope.options.templateOptions.fileUploader);
  18900. //$scope.options.templateOptions.uploader();
  18901. // FILTERS
  18902. uploader.filters.push({
  18903. name: "customFilter",
  18904. fn: function (item /*{File|FileLikeObject}*/, options) {
  18905. return this.queue.length < 10;
  18906. },
  18907. });
  18908. $scope.dropfile = function (
  18909. APIService,
  18910. processInstanceId,
  18911. taskId,
  18912. userId
  18913. ) {
  18914. uploader.onBeforeUploadItem = function (item) {
  18915. angular.extend(item.headers, $rootScope.getSession());
  18916. item.url = APIService.upload(
  18917. processInstanceId,
  18918. taskId,
  18919. userId
  18920. ).getRequestedUrl();
  18921. item.formData.push({
  18922. fileName: item.file.name,
  18923. type: "solution",
  18924. solutionId: $scope.model.knowledge.id,
  18925. });
  18926. console.info("onBeforeUploadItem", item);
  18927. };
  18928. uploader.uploadAll();
  18929. };
  18930. // CALLBACKS
  18931. uploader.onWhenAddingFileFailed = function (
  18932. item /*{File|FileLikeObject}*/,
  18933. filter,
  18934. options
  18935. ) {
  18936. console.info("onWhenAddingFileFailed", item, filter, options);
  18937. };
  18938. uploader.onAfterAddingFile = function (fileItem) {
  18939. console.info("onAfterAddingFile", fileItem);
  18940. };
  18941. uploader.onAfterAddingAll = function (addedFileItems) {
  18942. console.info("onAfterAddingAll", addedFileItems);
  18943. };
  18944. uploader.onBeforeUploadItem = function (item) {
  18945. // if($scope.uploader.getNotUploadedItems().length>0&&response.data.processInstanceId){
  18946. // // $scope.uploader.options.url();
  18947. // $scope.uploader.onBeforeUploadItem = function(item) {
  18948. // item.url = api_bpm_domain.saveAttachments($stateParams.processInstanceId,$stateParams.taskId,$scope.user.id).getRequestedUrl();
  18949. // console.info('onBeforeUploadItem', item);
  18950. // };
  18951. // $scope.uploader.uploadAll();
  18952. // }
  18953. console.info("onBeforeUploadItem", item);
  18954. };
  18955. uploader.onProgressItem = function (fileItem, progress) {
  18956. console.info("onProgressItem", fileItem, progress);
  18957. };
  18958. uploader.onProgressAll = function (progress) {
  18959. console.info("onProgressAll", progress);
  18960. };
  18961. uploader.onSuccessItem = function (
  18962. fileItem,
  18963. response,
  18964. status,
  18965. headers
  18966. ) {
  18967. console.info("onSuccessItem", fileItem, response, status, headers);
  18968. };
  18969. uploader.onErrorItem = function (fileItem, response, status, headers) {
  18970. console.info("onErrorItem", fileItem, response, status, headers);
  18971. };
  18972. uploader.onCancelItem = function (fileItem, response, status, headers) {
  18973. console.info("onCancelItem", fileItem, response, status, headers);
  18974. };
  18975. uploader.onCompleteItem = function (
  18976. fileItem,
  18977. response,
  18978. status,
  18979. headers
  18980. ) {
  18981. console.info("onCompleteItem", fileItem, response, status, headers);
  18982. };
  18983. uploader.onCompleteAll = function () {
  18984. console.info("onCompleteAll");
  18985. };
  18986. },
  18987. ],
  18988. });
  18989. //知识库附件下载列表
  18990. formlyConfigProvider.setType({
  18991. name: "ui-dropfileknowledge",
  18992. templateUrl: "assets/views/customform/tpl/ui-dropfileknowledge.html",
  18993. defaultOptions: function (options) {
  18994. return {
  18995. templateOptions: {
  18996. refresh: function (APIService, contentId, data) {
  18997. return APIService.fetchDataList(contentId, data);
  18998. },
  18999. downloadUri: function (APIService, contentId) {
  19000. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19001. },
  19002. download: function (APIService, contentId) {
  19003. return APIService.getSolutionDowpath(contentId);
  19004. },
  19005. view: function (attachmentId) {
  19006. // return APIService.attachmentsPreviewUrl(contentId);
  19007. },
  19008. refreshDelay: 0,
  19009. },
  19010. };
  19011. },
  19012. controller: [
  19013. "$scope",
  19014. "$timeout",
  19015. "$modal",
  19016. "$rootScope",
  19017. "api_solution",
  19018. "$http",
  19019. function ($scope, $timeout, $modal, $rootScope, api_solution, $http) {
  19020. var _refreshDelayPromise;
  19021. $scope.attachments = [];
  19022. $scope.downloadUrl = function (contentId) {
  19023. return (
  19024. $scope.options.templateOptions.downloadUri(
  19025. $scope.options.templateOptions.ApiService,
  19026. contentId
  19027. ) || "#"
  19028. );
  19029. };
  19030. $scope.download = function (contentId, filename) {
  19031. $http({
  19032. url: $scope.options.templateOptions.ApiService.getSolutionDowpath(
  19033. contentId
  19034. ).getRequestedUrl(),
  19035. method: "GET",
  19036. headers: {
  19037. //'Content-type' : 'application/xls',
  19038. Accept: "*/*",
  19039. },
  19040. responseType: "arraybuffer",
  19041. })
  19042. .success(function (data, status, headers, config) {
  19043. var file = new Blob([data], {
  19044. type: "application/octet-stream",
  19045. });
  19046. //trick to download store a file having its URL
  19047. var fileURL = URL.createObjectURL(file);
  19048. var a = document.createElement("a");
  19049. a.href = fileURL;
  19050. a.target = "_blank";
  19051. a.download = filename;
  19052. document.body.appendChild(a);
  19053. a.click();
  19054. })
  19055. .error(function (data, status, headers, config) {
  19056. // console.log(data);
  19057. });
  19058. };
  19059. $scope.view = function (contentId, filename, attachment) {
  19060. var index = filename.indexOf(".");
  19061. var type = filename.substring(index + 1);
  19062. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19063. // $scope.imageurl = $scope.options.templateOptions.ApiService.getSolutionDowpath(contentId).getRequestedUrl();
  19064. // var modalInstance = $modal.open({
  19065. // backdrop: false,
  19066. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19067. // controller: function($scope, scope, $modalInstance, filename) {
  19068. // $scope.title = filename;
  19069. // $scope.imageurl = scope.imageurl;
  19070. // $scope.cancel = function() {
  19071. // $modalInstance.dismiss('cancel');
  19072. // }
  19073. // },
  19074. // resolve: {
  19075. // scope: function() {
  19076. // return $scope;
  19077. // },
  19078. // filename: function() {
  19079. // return filename;
  19080. // }
  19081. // }
  19082. // });
  19083. // event.preventDefault();
  19084. // } else {
  19085. // for (var i = 0; i < $scope.attachments.length; i++) {
  19086. // if ($scope.attachments[i].id == attachmentId) {
  19087. window.open(attachment.previewUrl);
  19088. // }
  19089. // }
  19090. // }
  19091. };
  19092. $scope._refresh = function (refreshAttr) {
  19093. if (refreshAttr !== undefined) {
  19094. if (_refreshDelayPromise) {
  19095. $timeout.cancel(_refreshDelayPromise);
  19096. }
  19097. _refreshDelayPromise = $timeout(function () {
  19098. $scope.options.templateOptions
  19099. .refresh($scope.options.templateOptions.ApiService, "file", {
  19100. file: {
  19101. solutionId: $scope.model.knowledge.id,
  19102. },
  19103. idx: "0",
  19104. sum: "1000",
  19105. })
  19106. .then(function (response) {
  19107. var myData =
  19108. $scope.options.templateOptions.Restangular.stripRestangular(
  19109. response
  19110. );
  19111. if (myData) {
  19112. $scope.attachments = myData.list;
  19113. // $scope.view = function(attachmentId) {
  19114. // for (var i = 0; i < $scope.attachments.length; i++) {
  19115. // if ($scope.attachments[i].id == attachmentId) {
  19116. // window.open($scope.attachments[i].previewUrl);
  19117. // // var modalInstance = $modal.open({
  19118. // // templateUrl: 'assets/views/knowledge/tpl/detailknowledge.html',
  19119. // // controller: function($scope, $http,$modalInstance, APIService, uploader,tree_data, currentUser){
  19120. // // }
  19121. // // });
  19122. // }
  19123. // }
  19124. // };
  19125. }
  19126. });
  19127. }, $scope.options.templateOptions.refreshDelay);
  19128. }
  19129. };
  19130. $scope._refresh({});
  19131. // $scope.attachments = $scope.model[$scope.options.key]
  19132. },
  19133. ],
  19134. });
  19135. //附件图片下载
  19136. formlyConfigProvider.setType({
  19137. name: "ui-downimage",
  19138. templateUrl: "assets/views/customform/tpl/ui-downimage.html",
  19139. defaultOptions: function (options) {
  19140. return {
  19141. templateOptions: {
  19142. refresh: function (APIService, processInstanceId, data) {
  19143. return APIService.listAttachments(processInstanceId, data);
  19144. },
  19145. downloadUri: function (APIService, contentId) {
  19146. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19147. },
  19148. view: function (APIService, contentId) {
  19149. return APIService.attachmentsPreviewUrl(contentId);
  19150. },
  19151. download: function (APIService, contentId, item) {
  19152. var item = {
  19153. url: APIService.download(contentId),
  19154. headers: headers,
  19155. };
  19156. return item;
  19157. },
  19158. refreshDelay: 0,
  19159. },
  19160. };
  19161. },
  19162. controller: [
  19163. "$scope",
  19164. "$timeout",
  19165. "$rootScope",
  19166. "$http",
  19167. function ($scope, $timeout, $rootScope, $http) {
  19168. var _refreshDelayPromise;
  19169. // $scope.downloadUrl = function(contentId){
  19170. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19171. // };
  19172. $scope.download = function (contentId, filename) {
  19173. // var headers=
  19174. $http({
  19175. url: $scope.options.templateOptions.ApiService.download(
  19176. contentId
  19177. ).getRequestedUrl(),
  19178. method: "GET",
  19179. headers: {
  19180. //'Content-type' : 'application/xls',
  19181. Accept: "*/*",
  19182. },
  19183. responseType: "arraybuffer",
  19184. })
  19185. .success(function (data, status, headers, config) {
  19186. var file = new Blob([data], {
  19187. type: "application/octet-stream",
  19188. });
  19189. //trick to download store a file having its URL
  19190. var fileURL = URL.createObjectURL(file);
  19191. var a = document.createElement("a");
  19192. a.href = fileURL;
  19193. a.target = "_blank";
  19194. a.download = filename;
  19195. document.body.appendChild(a);
  19196. a.click();
  19197. })
  19198. .error(function (data, status, headers, config) {
  19199. // console.log(data);
  19200. });
  19201. };
  19202. $scope.view = function (contentId) {
  19203. $scope.imageurl =
  19204. $scope.options.templateOptions.ApiService.download(
  19205. contentId
  19206. ).getRequestedUrl();
  19207. // $scope.options.templateOptions.view($scope.options.templateOptions.ApiService, contentId).then(function(response) {
  19208. // if (response.state == 200) {
  19209. // window.open(response.previewUrl);
  19210. // }
  19211. // })
  19212. };
  19213. /**
  19214. * refresh
  19215. */
  19216. $scope._refresh = function (refreshAttr) {
  19217. if (refreshAttr !== undefined) {
  19218. if (_refreshDelayPromise) {
  19219. $timeout.cancel(_refreshDelayPromise);
  19220. }
  19221. _refreshDelayPromise = $timeout(function () {
  19222. $scope.options.templateOptions
  19223. .refresh(
  19224. $scope.options.templateOptions.ApiService,
  19225. $scope.options.templateOptions.processInstanceId,
  19226. {
  19227. idx: 0,
  19228. sum: 1000,
  19229. }
  19230. )
  19231. .then(function (response) {
  19232. var myData =
  19233. $scope.options.templateOptions.Restangular.stripRestangular(
  19234. response
  19235. );
  19236. if (myData) {
  19237. $scope.attachments = myData.data;
  19238. }
  19239. });
  19240. }, $scope.options.templateOptions.refreshDelay);
  19241. }
  19242. };
  19243. $scope._refresh({});
  19244. // $scope.attachments = $scope.model[$scope.options.key]
  19245. },
  19246. ],
  19247. });
  19248. //附件下载列表组件
  19249. formlyConfigProvider.setType({
  19250. name: "ui-dropfiletable",
  19251. templateUrl: "assets/views/customform/tpl/ui-dropfiletable.html",
  19252. defaultOptions: function (options) {
  19253. return {
  19254. templateOptions: {
  19255. refresh: function (APIService, processInstanceId, data) {
  19256. return APIService.listAttachments(processInstanceId, data);
  19257. },
  19258. downloadUri: function (APIService, contentId) {
  19259. return APIService.downloadAttachment(contentId).getRequestedUrl();
  19260. },
  19261. view: function (APIService, contentId) {
  19262. return APIService.attachmentsPreviewUrl(contentId);
  19263. },
  19264. download: function (APIService, contentId, item) {
  19265. var item = {
  19266. url: APIService.download(contentId),
  19267. headers: headers,
  19268. };
  19269. return item;
  19270. },
  19271. refreshDelay: 0,
  19272. },
  19273. };
  19274. },
  19275. controller: [
  19276. "$scope",
  19277. "$timeout",
  19278. "$modal",
  19279. "$rootScope",
  19280. "$http",
  19281. function ($scope, $timeout, $modal, $rootScope, $http) {
  19282. var _refreshDelayPromise;
  19283. // $scope.downloadUrl = function(contentId){
  19284. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19285. // };
  19286. $scope.download = function (contentId, filename) {
  19287. // var headers=
  19288. $http({
  19289. url: $scope.options.templateOptions.ApiService.download(
  19290. contentId
  19291. ).getRequestedUrl(),
  19292. method: "GET",
  19293. headers: {
  19294. //'Content-type' : 'application/xls',
  19295. Accept: "*/*",
  19296. },
  19297. responseType: "arraybuffer",
  19298. })
  19299. .success(function (data, status, headers, config) {
  19300. var file = new Blob([data], {
  19301. type: "application/octet-stream",
  19302. });
  19303. //trick to download store a file having its URL
  19304. var fileURL = URL.createObjectURL(file);
  19305. var a = document.createElement("a");
  19306. a.href = fileURL;
  19307. a.target = "_blank";
  19308. a.download = filename;
  19309. document.body.appendChild(a);
  19310. a.click();
  19311. })
  19312. .error(function (data, status, headers, config) {
  19313. // console.log(data);
  19314. });
  19315. // $scope.options.templateOptions.ApiService.download(contentId).then(function(response){
  19316. // // $scope.options.templateOptions.download($scope.options.templateOptions.ApiService,contentId).then(function(response){
  19317. // var file = new Blob([response], {
  19318. // type : 'application/octet-stream'
  19319. // });
  19320. // // var filename = filename;
  19321. // //var file = new Blob([response], {type: 'application/pdf'});
  19322. // var fileURL = URL.createObjectURL(file);
  19323. // var a = document.createElement('a');
  19324. // a.href = fileURL;
  19325. // a.target = '_blank';
  19326. // a.download = filename ;
  19327. // document.body.appendChild(a);
  19328. // a.click();
  19329. // })
  19330. };
  19331. $scope.view = function (contentId, token, filename, type) {
  19332. // if (type == 'jpg' || type == 'png' || type == 'jpeg' || type == 'bmp' || type == 'gif') {
  19333. // $scope.imageurl = $scope.options.templateOptions.ApiService.download(contentId).getRequestedUrl();
  19334. // var modalInstance = $modal.open({
  19335. // backdrop: false,
  19336. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19337. // controller: function($scope, scope, $modalInstance, filename) {
  19338. // $scope.title = filename;
  19339. // $scope.imageurl = scope.imageurl;
  19340. // $scope.cancel = function() {
  19341. // $modalInstance.dismiss('cancel');
  19342. // }
  19343. // },
  19344. // resolve: {
  19345. // scope: function() {
  19346. // return $scope;
  19347. // },
  19348. // filename: function() {
  19349. // return filename;
  19350. // }
  19351. // }
  19352. // });
  19353. // event.preventDefault();
  19354. // } else {
  19355. $scope.options.templateOptions
  19356. .view($scope.options.templateOptions.ApiService, contentId)
  19357. .then(function (response) {
  19358. if (response.state == 200) {
  19359. window.open(response.previewUrl);
  19360. }
  19361. });
  19362. // }
  19363. };
  19364. /**
  19365. * refresh
  19366. */
  19367. $scope._refresh = function (refreshAttr) {
  19368. if (refreshAttr !== undefined) {
  19369. if (_refreshDelayPromise) {
  19370. $timeout.cancel(_refreshDelayPromise);
  19371. }
  19372. _refreshDelayPromise = $timeout(function () {
  19373. $scope.options.templateOptions
  19374. .refresh(
  19375. $scope.options.templateOptions.ApiService,
  19376. $scope.options.templateOptions.processInstanceId,
  19377. {
  19378. idx: 0,
  19379. sum: 1000,
  19380. }
  19381. )
  19382. .then(function (response) {
  19383. var myData =
  19384. $scope.options.templateOptions.Restangular.stripRestangular(
  19385. response
  19386. );
  19387. if (myData) {
  19388. $scope.attachments = myData.data;
  19389. }
  19390. });
  19391. }, $scope.options.templateOptions.refreshDelay);
  19392. }
  19393. };
  19394. $scope._refresh({});
  19395. // $scope.attachments = $scope.model[$scope.options.key]
  19396. },
  19397. ],
  19398. });
  19399. //微信附件下载列表组件
  19400. formlyConfigProvider.setType({
  19401. name: "ui-dropfilewechat",
  19402. templateUrl: "assets/views/customform/tpl/ui-dropfilewechat.html",
  19403. defaultOptions: function (options) {
  19404. return {
  19405. templateOptions: {
  19406. // refresh: function(APIService, processInstanceId, data) {
  19407. // return APIService.listAttachments(processInstanceId, data);
  19408. // },
  19409. // downloadUri: function(APIService, contentId) {
  19410. // return APIService.downloadAttachment(contentId).getRequestedUrl();
  19411. // },
  19412. view: function (APIService, contentId) {
  19413. // return APIService.attachmentsPreviewUrl(contentId);
  19414. return APIService.attachmentsPreviewUrl(contentId);
  19415. },
  19416. download: function (APIService, contentId, item) {
  19417. var item = {
  19418. url: APIService.download(contentId),
  19419. headers: headers,
  19420. };
  19421. return item;
  19422. },
  19423. // download: function(APIService, contentId, item) {
  19424. // var item = { 'url': APIService.downloadAttachment(contentId), 'headers': headers };
  19425. // return item;
  19426. // },
  19427. refreshDelay: 0,
  19428. },
  19429. };
  19430. },
  19431. controller: [
  19432. "$scope",
  19433. "$timeout",
  19434. "$modal",
  19435. "$stateParams",
  19436. "$rootScope",
  19437. "$http",
  19438. "api_wechatfile",
  19439. function (
  19440. $scope,
  19441. $timeout,
  19442. $modal,
  19443. $stateParams,
  19444. $rootScope,
  19445. $http,
  19446. api_wechatfile
  19447. ) {
  19448. var _refreshDelayPromise;
  19449. // $scope.downloadUrl = function(contentId){
  19450. // return $scope.options.templateOptions.downloadUri($scope.options.templateOptions.ApiService,contentId)||'#';
  19451. // };
  19452. $scope.attachments = {};
  19453. $scope.previewUrl = "";
  19454. $scope.download = function (token, filename) {
  19455. // var headers=
  19456. console.log($scope);
  19457. $http({
  19458. url: $scope.options.templateOptions.ApiService.jry_download(
  19459. token
  19460. ).getRequestedUrl(),
  19461. method: "GET",
  19462. headers: {
  19463. //'Content-type' : 'application/xls',
  19464. Accept: "*/*",
  19465. },
  19466. responseType: "arraybuffer",
  19467. })
  19468. .success(function (data, status, headers, config) {
  19469. var file = new Blob([data], {
  19470. type: "application/octet-stream",
  19471. });
  19472. //trick to download store a file having its URL
  19473. var fileURL = URL.createObjectURL(file);
  19474. var a = document.createElement("a");
  19475. a.href = fileURL;
  19476. a.target = "_blank";
  19477. a.download = filename;
  19478. document.body.appendChild(a);
  19479. a.click();
  19480. })
  19481. .error(function (data, status, headers, config) {
  19482. // console.log(data);
  19483. });
  19484. };
  19485. $scope.view = function (contentId, token, filename, type, previewUrl) {
  19486. // if (type) {
  19487. // $scope.imageurl = $scope.options.templateOptions.ApiService.downloadAttachment(token).getRequestedUrl();
  19488. // var modalInstance = $modal.open({
  19489. // backdrop: false,
  19490. // templateUrl: 'assets/views/customform/tpl/ui-showimage.html',
  19491. // controller: function($scope, scope, $modalInstance, filename) {
  19492. // $scope.title = filename;
  19493. // $scope.imageurl = scope.imageurl;
  19494. // $scope.cancel = function() {
  19495. // $modalInstance.dismiss('cancel');
  19496. // }
  19497. // },
  19498. // resolve: {
  19499. // scope: function() {
  19500. // return $scope;
  19501. // },
  19502. // filename: function() {
  19503. // return filename;
  19504. // }
  19505. // }
  19506. // });
  19507. // event.preventDefault();
  19508. // } else {
  19509. // $scope.options.templateOptions.view($scope.options.templateOptions.apiService, contentId).then(function(response) {
  19510. // if (response.state == 200) {
  19511. // window.open(response.previewUrl);
  19512. // }
  19513. // })
  19514. window.open(previewUrl);
  19515. // }
  19516. };
  19517. /**
  19518. * refresh
  19519. */
  19520. $scope._refresh = function (refreshAttr) {
  19521. if (refreshAttr !== undefined) {
  19522. if (_refreshDelayPromise) {
  19523. $timeout.cancel(_refreshDelayPromise);
  19524. }
  19525. _refreshDelayPromise = $timeout(function () {
  19526. // console.log(JSON.parse($stateParams.model))
  19527. var incidentChart = {};
  19528. if ($stateParams.model) {
  19529. incidentChart = JSON.parse($stateParams.model).model;
  19530. }
  19531. $scope.options.templateOptions
  19532. .refresh(
  19533. $scope.options.templateOptions.ApiService,
  19534. $scope.model
  19535. )
  19536. .then(function (response) {
  19537. // $scope.options.templateOptions.refresh($scope.options.templateOptions.ApiService,
  19538. // incidentChart.incident.type, incidentChart.flow).then(function(response) {
  19539. var myData =
  19540. $scope.options.templateOptions.Restangular.stripRestangular(
  19541. response
  19542. );
  19543. if (myData) {
  19544. $scope.attachments = myData.data;
  19545. }
  19546. });
  19547. }, $scope.options.templateOptions.refreshDelay);
  19548. }
  19549. };
  19550. $scope._refresh({});
  19551. // $scope.attachments = $scope.model[$scope.options.key]
  19552. },
  19553. ],
  19554. });
  19555. formlyConfigProvider.setType({
  19556. name: "ui-paralleltask",
  19557. templateUrl: "assets/views/customform/tpl/ui-paralleltask.html",
  19558. defaultOptions: function (options) {
  19559. return {
  19560. templateOptions: {
  19561. refresh: function (APIService, processInstanceId, data) {
  19562. //return APIService.listAttachments(processInstanceId, data);
  19563. },
  19564. refreshDelay: 0,
  19565. },
  19566. };
  19567. },
  19568. controller: ["$scope", "$timeout", function ($scope, $timeout) { }],
  19569. });
  19570. //repeatSection
  19571. //
  19572. formlyConfigProvider.setType({
  19573. name: "ui-repeatSection",
  19574. templateUrl: "assets/views/customform/tpl/ui-repeatSection.html",
  19575. defaultOptions: function (options) {
  19576. return {
  19577. templateOptions: {
  19578. unique: 1,
  19579. initDisplay: false,
  19580. },
  19581. };
  19582. },
  19583. controller: function ($scope) {
  19584. //$scope.options.templateOptions.unique;
  19585. $scope.formOptions = {
  19586. formState: $scope.formState,
  19587. };
  19588. $scope.addNew = addNew;
  19589. $scope.copyFields = copyFields;
  19590. function copyFields(fields) {
  19591. fields = angular.copy(fields);
  19592. addRandomIds(fields);
  19593. return fields;
  19594. }
  19595. function addNew() {
  19596. $scope.model[$scope.options.key] =
  19597. $scope.model[$scope.options.key] || [];
  19598. var repeatsection = $scope.model[$scope.options.key];
  19599. var lastSection = repeatsection[repeatsection.length - 1];
  19600. var newsection = {};
  19601. repeatsection.push(newsection);
  19602. }
  19603. function addRandomIds(fields) {
  19604. $scope.options.templateOptions.unique++;
  19605. angular.forEach(fields, function (field, index) {
  19606. if (field.fieldGroup) {
  19607. addRandomIds(field.fieldGroup);
  19608. return; // fieldGroups don't need an ID
  19609. }
  19610. if (field.templateOptions && field.templateOptions.fields) {
  19611. addRandomIds(field.templateOptions.fields);
  19612. }
  19613. field.id =
  19614. field.id ||
  19615. field.key +
  19616. "_" +
  19617. index +
  19618. "_" +
  19619. $scope.options.templateOptions.unique +
  19620. getRandomInt(0, 9999);
  19621. });
  19622. }
  19623. function getRandomInt(min, max) {
  19624. return Math.floor(Math.random() * (max - min)) + min;
  19625. }
  19626. if ($scope.options.templateOptions.initDisplay) {
  19627. addNew();
  19628. }
  19629. },
  19630. });
  19631. //时间轴任务列表组件
  19632. //cmdb控件
  19633. formlyConfigProvider.setType({
  19634. name: "ui-cmdb",
  19635. extends: "input",
  19636. templateUrl: "assets/views/customform/tpl/ui-cmdb.html",
  19637. defaultOptions: function (options) {
  19638. return {
  19639. templateOptions: {
  19640. onClick: function (size, options, modal, event, model) {
  19641. var modalInstance = modal.open({
  19642. templateUrl:
  19643. "assets/views/customform/tpl/cmdb-modal-content.html",
  19644. controller: function (
  19645. $scope,
  19646. $modalInstance,
  19647. title,
  19648. Restangular,
  19649. APIService,
  19650. ConfigDataService,
  19651. ConfigFormService,
  19652. SweetAlert,
  19653. Toaster,
  19654. api_wechatfile
  19655. ) {
  19656. var width = ($scope.width = 600);
  19657. var height = ($scope.height = 400);
  19658. var tree;
  19659. var d3 = window.d3;
  19660. $scope.my_tree_handler = function (branch) {
  19661. //var _ref;
  19662. var classify = ($scope.classify =
  19663. branch.prefix.toLowerCase() + branch.sign);
  19664. APIService.query({
  19665. sign: classify,
  19666. }).then(function (data) {
  19667. var myData = Restangular.stripRestangular(data);
  19668. // console.log(myData.data.node);
  19669. if (myData.data && myData.status == 200) {
  19670. var ret = myData.data;
  19671. redrawSvg(myData);
  19672. }
  19673. });
  19674. };
  19675. $scope.my_data = [];
  19676. function convertListToTree(data, treeMap) {
  19677. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  19678. var root = null; //Initially set our loop to null
  19679. var parentNode = null;
  19680. //loop over data
  19681. for (var i = 0; i < data.length; i++) {
  19682. var datum = data[i];
  19683. //each node will have children, so let's give it a "children" poperty
  19684. datum.children = [];
  19685. //add an entry for this node to the map so that any future children can
  19686. //lookup the parent
  19687. idToNodeMap[datum.id] = datum;
  19688. //Does this node have a parent?
  19689. if (
  19690. typeof datum.parent === "undefined" ||
  19691. datum.parent == null
  19692. ) {
  19693. //Doesn't look like it, so this node is the root of the tree
  19694. root = datum;
  19695. treeMap[datum.id] = root;
  19696. } else {
  19697. //This node has a parent, so let's look it up using the id
  19698. parentNode = idToNodeMap[datum.parent.id];
  19699. //We don't need this property, so let's delete it.
  19700. delete datum.parent;
  19701. //Let's add the current node as a child of the parent node.
  19702. parentNode.children.push(datum);
  19703. }
  19704. }
  19705. return root;
  19706. }
  19707. function convertParentToChildList(data) {
  19708. var treeMap = {};
  19709. var list = [];
  19710. convertListToTree(data, treeMap);
  19711. angular.forEach(treeMap, function (item) {
  19712. list.push(item);
  19713. });
  19714. return list;
  19715. }
  19716. $scope.my_tree = tree = {};
  19717. $scope.try_async_load = function () {
  19718. $scope.my_data = [];
  19719. $scope.select_treedata = [];
  19720. $scope.doing_async = true;
  19721. ConfigDataService.fetchDataList("ciclassify", {
  19722. idx: 0,
  19723. sum: 100,
  19724. }).then(function (result) {
  19725. $scope.select_treedata = $scope.my_data =
  19726. convertParentToChildList(result["list"]);
  19727. $scope.doing_async = false;
  19728. });
  19729. // api_wechatfile.getDictionary({ 'key': 'cmdb_status', 'type': 'list' }).then(function(result) {
  19730. // $scope.select_treedata = $scope.my_data = convertParentToChildList(result['list']);
  19731. // $scope.doing_async = false;
  19732. // });
  19733. };
  19734. $scope.select_treedata = [];
  19735. $scope.propTypeOptions = [];
  19736. $scope.try_async_load();
  19737. $scope.onFilterCallback = function (item) {
  19738. //console.log(item);
  19739. if (
  19740. angular.isDefined(item.children) &&
  19741. item.children.length >= 1
  19742. ) {
  19743. //not valid
  19744. } else {
  19745. var tempclassify = item.prefix.toLowerCase() + item.sign;
  19746. $scope.cifilter_classic = tempclassify;
  19747. ConfigFormService.renderTabForm(tempclassify).then(
  19748. function (data) {
  19749. var myData = Restangular.stripRestangular(data);
  19750. $scope.propTypeOptions = myData;
  19751. }
  19752. );
  19753. }
  19754. };
  19755. $scope.onPropTypeChange = function (form) {
  19756. $scope.propOptions = form.fields;
  19757. };
  19758. $scope.onPropChange = function (prop) {
  19759. $scope.cifilter_prop = prop;
  19760. };
  19761. $scope.searchCI = function (searchKey, propObj, ciclassify) {
  19762. //if(searchKey!=null&&searchKey.length>1){
  19763. var searchData = {};
  19764. if (angular.isUndefined(propObj)) {
  19765. propObj = $scope.cifilter_prop;
  19766. }
  19767. if (angular.isUndefined(ciclassify)) {
  19768. ciclassify = $scope.cifilter_classic;
  19769. }
  19770. searchData["sign"] = ciclassify;
  19771. if (angular.isDefined(propObj)) {
  19772. searchData[propObj.key] = searchKey;
  19773. }
  19774. APIService.query(searchData).then(function (response) {
  19775. var data = Restangular.stripRestangular(response);
  19776. //此处不清空nodes
  19777. var node = data.data.node;
  19778. var tempNode = [];
  19779. //nodes 或者links 要去重
  19780. for (var i = 0; i < node.length; i++) {
  19781. var tmp = 0;
  19782. for (var j = 0; j < nodes.length; j++) {
  19783. if (node[i].uuid == nodes[j].uuid) {
  19784. tmp++;
  19785. break;
  19786. }
  19787. }
  19788. if (tmp == 0) {
  19789. tempNode.push(node[i]);
  19790. }
  19791. }
  19792. for (var i = 0; i < tempNode.length; i++) {
  19793. //nodes 不清空
  19794. nodes.push(tempNode[i]);
  19795. }
  19796. restart();
  19797. });
  19798. };
  19799. $scope.refresh = function () {
  19800. nodes.length = 0;
  19801. links.length = 0;
  19802. restart();
  19803. };
  19804. $scope.traversal = function () {
  19805. if ($scope.selected_node == null) {
  19806. SweetAlert.swal({
  19807. title: "错误的操作!",
  19808. text: "没有配置项被选中!",
  19809. type: "error",
  19810. });
  19811. } else {
  19812. var uuid = $scope.selected_node.uuid;
  19813. APIService.traversal(uuid).then(function (response) {
  19814. var d = response.data;
  19815. var node = d.node;
  19816. var link = d.edge;
  19817. var tempNode = [];
  19818. var tempLink = [];
  19819. //nodes 或者links 要去重
  19820. for (var i = 0; i < node.length; i++) {
  19821. var tmp = 0;
  19822. for (var j = 0; j < nodes.length; j++) {
  19823. if (node[i].id == nodes[j].id) {
  19824. tmp++;
  19825. break;
  19826. }
  19827. }
  19828. if (tmp == 0) {
  19829. tempNode.push(node[i]);
  19830. }
  19831. }
  19832. for (var i = 0; i < link.length; i++) {
  19833. var tmp = 0;
  19834. for (var j = 0; j < links.length; j++) {
  19835. if (link[i].id == links[j].id) {
  19836. tmp++;
  19837. break;
  19838. }
  19839. }
  19840. if (tmp == 0) {
  19841. tempLink.push(link[i]);
  19842. }
  19843. }
  19844. //数据写入页面
  19845. for (var i = 0; i < tempNode.length; i++) {
  19846. //nodes 不清空
  19847. nodes.push(tempNode[i]);
  19848. }
  19849. for (var i = 0; i < tempLink.length; i++) {
  19850. //link 不清空
  19851. links.push(tempLink[i]);
  19852. }
  19853. //links转换
  19854. for (var i = 0; i < links.length; i++) {
  19855. for (var j = 0; j < nodes.length; j++) {
  19856. if (links[i].source == nodes[j].id) {
  19857. links[i].source = nodes[j];
  19858. }
  19859. if (links[i].target == nodes[j].id) {
  19860. links[i].target = nodes[j];
  19861. }
  19862. }
  19863. }
  19864. restart();
  19865. });
  19866. }
  19867. };
  19868. var svg;
  19869. var force;
  19870. var drag_line, path, circle;
  19871. //var svg = d3.select(angular.element('div#cmdbSVG')).append('svg').attr('width', width).attr('height', height);
  19872. //var svg = angular.element('div#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19873. //var svg = d3.select('#cmdbSVG').append('svg').attr('width', width).attr('height', height);
  19874. var nodes = [],
  19875. links = [];
  19876. var treeNodes = [];
  19877. //读取labels (node)
  19878. var labels = [];
  19879. function redrawSvg(json) {
  19880. nodes.length = 0; //先清空
  19881. links.length = 0;
  19882. var data = json.data;
  19883. for (var i = 0; i < data.node.length; i++) {
  19884. nodes.push(data.node[i]);
  19885. }
  19886. restart();
  19887. }
  19888. //读取status (节点 连线)
  19889. var statuses = [];
  19890. // ConfigDataService.fetchDataList('cistatus', { 'idx': 0, 'sum': 100 }).then(function(result) {
  19891. // if (result && result.status == 200) {
  19892. // d3.select('#nodeStatus').selectAll('option')
  19893. // .data(statuses).enter()
  19894. // .append('option')
  19895. // .attr('value', function(d) { return d.code; })
  19896. // .html(function(d) { return d.desc; });
  19897. // } else {
  19898. // SweetAlert.swal({
  19899. // title: "提示!",
  19900. // text: "服务器请求异常!",
  19901. // type: "error"
  19902. // });
  19903. // }
  19904. // });
  19905. api_wechatfile
  19906. .getDictionary({
  19907. key: "cmdb_status",
  19908. type: "list",
  19909. })
  19910. .then(function (result) {
  19911. if (result) {
  19912. d3.select("#nodeStatus")
  19913. .selectAll("option")
  19914. .data(statuses)
  19915. .enter()
  19916. .append("option")
  19917. .attr("value", function (d) {
  19918. return d.code;
  19919. })
  19920. .html(function (d) {
  19921. return d.desc;
  19922. });
  19923. } else {
  19924. SweetAlert.swal({
  19925. title: "提示!",
  19926. text: "服务器请求异常!",
  19927. type: "error",
  19928. });
  19929. }
  19930. });
  19931. //查询relationship_type表 name 为表里的type,label为显示值
  19932. var linkType = [];
  19933. function fetchEdgeTypes() {
  19934. ConfigDataService.fetchDataList("ciedgetype", {
  19935. idx: 0,
  19936. sum: 100,
  19937. }).then(function (response) {
  19938. if (response) {
  19939. if (response["list"]) {
  19940. linkType = response["list"];
  19941. // d3.select('#linkName').selectAll('option')
  19942. // .data(linkType).enter()
  19943. // .append('option')
  19944. // .attr('value',function(d){return d.type;})
  19945. // .html(function(d){ return d.label;});
  19946. } else {
  19947. SweetAlert.swal({
  19948. title: "提示!",
  19949. text: "服务器请求异常!",
  19950. type: "error",
  19951. });
  19952. }
  19953. } else {
  19954. SweetAlert.swal({
  19955. title: "提示!",
  19956. text: "服务器请求异常!",
  19957. type: "error",
  19958. });
  19959. }
  19960. });
  19961. }
  19962. // fetchEdgeTypes();
  19963. /*
  19964. // init D3 force layout
  19965. var force = d3.layout.force()
  19966. .nodes(nodes)
  19967. .links(links)
  19968. .size([width, height])
  19969. .gravity(.05)
  19970. .linkDistance(150)
  19971. .linkStrength(2)
  19972. .charge(-500)
  19973. .on('tick', tick);
  19974. // define arrow markers for graph links
  19975. svg.append('svg:defs').append('svg:marker')
  19976. .attr('id', 'end-arrow')
  19977. .attr('viewBox', '0 -5 10 10')
  19978. .attr('refX', 6)
  19979. .attr('markerWidth', 3)
  19980. .attr('markerHeight', 3)
  19981. .attr('orient', 'auto')
  19982. .append('svg:path')
  19983. .attr('d', 'M0,-5L10,0L0,5')
  19984. .attr('fill', '#000');
  19985. svg.append('svg:defs').append('svg:marker')
  19986. .attr('id', 'start-arrow')
  19987. .attr('viewBox', '0 -5 10 10')
  19988. .attr('refX', 4)
  19989. .attr('markerWidth', 3)
  19990. .attr('markerHeight', 3)
  19991. .attr('orient', 'auto')
  19992. .append('svg:path')
  19993. .attr('d', 'M10,-5L0,0L10,5')
  19994. .attr('fill', '#000');
  19995. // line displayed when dragging new nodes
  19996. var drag_line = svg.append('svg:path')
  19997. .attr('class', 'link dragline hidden')
  19998. .attr('d', 'M0,0L0,0');
  19999. // handles to link and node element groups
  20000. //(1)var path = svg.append('svg:g').selectAll('g')
  20001. var path = svg.append('svg:g').selectAll('g'),
  20002. circle = svg.append('svg:g').selectAll('g');
  20003. */
  20004. // mouse event vars
  20005. var selected_node = null,
  20006. selected_link = null,
  20007. mousedown_link = null,
  20008. mousedown_node = null,
  20009. mouseup_node = null;
  20010. function resetMouseVars() {
  20011. mousedown_node = null;
  20012. mouseup_node = null;
  20013. mousedown_link = null;
  20014. }
  20015. // update force layout (called automatically each iteration)
  20016. function tick() {
  20017. // draw directed edges with proper padding from node centers
  20018. path.selectAll("path").attr("d", function (d) {
  20019. var deltaX = d.target.x - d.source.x,
  20020. deltaY = d.target.y - d.source.y,
  20021. dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
  20022. normX = deltaX / dist,
  20023. normY = deltaY / dist,
  20024. sourcePadding = d.left ? 27 : 22,
  20025. targetPadding = d.right ? 27 : 22,
  20026. sourceX = d.source.x + sourcePadding * normX,
  20027. sourceY = d.source.y + sourcePadding * normY,
  20028. targetX = d.target.x - targetPadding * normX,
  20029. targetY = d.target.y - targetPadding * normY;
  20030. return (
  20031. "M" +
  20032. sourceX +
  20033. "," +
  20034. sourceY +
  20035. "L" +
  20036. targetX +
  20037. "," +
  20038. targetY
  20039. );
  20040. });
  20041. circle.attr("transform", function (d) {
  20042. return "translate(" + d.x + "," + d.y + ")";
  20043. });
  20044. }
  20045. // update graph (called when needed)
  20046. function restart() {
  20047. //绑定link 数据
  20048. path.datum(links);
  20049. // path (link) group
  20050. path = path.data(links, function (d) {
  20051. return d.id;
  20052. });
  20053. var p = path.enter().append("svg:g");
  20054. //update existing links
  20055. path
  20056. .selectAll("path")
  20057. .classed("selected", function (d) {
  20058. return d === selected_link;
  20059. })
  20060. .style("marker-start", function (d) {
  20061. return d.left ? "url(#start-arrow)" : "";
  20062. })
  20063. .style("marker-end", function (d) {
  20064. return d.right ? "url(#end-arrow)" : "";
  20065. });
  20066. // add new links
  20067. p.append("svg:path")
  20068. .attr("class", "link")
  20069. .attr("id", function (d) {
  20070. return "path_" + d.id;
  20071. })
  20072. // .attr('startOffset', '0%')
  20073. .classed("selected", function (d) {
  20074. return d === selected_link;
  20075. })
  20076. .style("marker-start", function (d) {
  20077. return d.left ? "url(#start-arrow)" : "";
  20078. })
  20079. .style("marker-end", function (d) {
  20080. return d.right ? "url(#end-arrow)" : "";
  20081. })
  20082. .on("mousedown", function (d) {
  20083. if (d3.event.ctrlKey) return;
  20084. //去除没有提交的连线
  20085. for (var i = 0; i < links.length; i++) {
  20086. if (links[i].id == -1 && d.id != -1) {
  20087. links.splice(i, 1);
  20088. }
  20089. }
  20090. // select link
  20091. mousedown_link = d;
  20092. if (mousedown_link === selected_link) {
  20093. selected_link = $scope.selected_link = null;
  20094. selected_node = $scope.selected_node = null;
  20095. // d3.select("#linkDetail").attr('style','display:none');
  20096. //hideLinkForm(true);//return ;
  20097. } else {
  20098. selected_link = $scope.selected_link = mousedown_link;
  20099. selected_node = $scope.selected_node = null;
  20100. }
  20101. selected_node = $scope.selected_node = null;
  20102. restart();
  20103. });
  20104. p.append("svg:text")
  20105. .attr("x", 30)
  20106. .attr("y", 20)
  20107. .attr("class", "fontM")
  20108. .append("textPath")
  20109. .attr("xlink:xlink:href", function (d, i) {
  20110. return "#path_" + d.id;
  20111. })
  20112. .html(function (d) {
  20113. for (var i = 0; i < linkType.length; i++) {
  20114. if (linkType[i].type == d.name) {
  20115. return linkType[i].label;
  20116. }
  20117. }
  20118. });
  20119. // remove old links
  20120. path.exit().remove();
  20121. // circle (node) group
  20122. // NB: the function arg is crucial here! nodes are known by id, not by index!
  20123. circle.datum(nodes);
  20124. circle = circle.data(nodes, function (d) {
  20125. return d.id;
  20126. });
  20127. // update existing nodes (reflexive & selected visual states)
  20128. circle
  20129. .selectAll("circle")
  20130. .style("fill", function (d) {
  20131. return d === selected_node
  20132. ? d3.rgb(colors(d.label)).brighter().toString()
  20133. : colors(d.label);
  20134. })
  20135. .style("fill-opacity", 0.75) // add by xi
  20136. .classed("reflexive", function (d) {
  20137. return d.reflexive;
  20138. });
  20139. // add new nodes
  20140. var g = circle.enter().append("svg:g");
  20141. //g.append('svg:circle').attr('r',22).style('fill','rgb(255,255,255)').style('stroke','rgb(255,255,255)').style('stroke-width','2');
  20142. //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');
  20143. g.append("svg:circle")
  20144. .attr("r", 24)
  20145. .style("fill", function (d) {
  20146. return d === selected_node
  20147. ? "rgb(153,153,153)"
  20148. : "rgb(255,255,255)";
  20149. })
  20150. .style("stroke", function (d) {
  20151. return d3.rgb(colors(d.label)).darker().toString();
  20152. })
  20153. .style("stroke-width", "2");
  20154. g.append("svg:circle")
  20155. .attr("class", "node")
  20156. .attr("r", 18)
  20157. .style("fill", function (d) {
  20158. return d === selected_node
  20159. ? d3.rgb(colors(d.label)).brighter().toString()
  20160. : colors(d.label);
  20161. })
  20162. .style("stroke", function (d) {
  20163. return d3.rgb(colors(d.label)).darker().toString();
  20164. })
  20165. .style("fill-opacity", 0.25) //add by xj
  20166. .style("stroke-opacity", 0.5) //add by xj
  20167. .classed("reflexive", function (d) {
  20168. return d.reflexive;
  20169. });
  20170. g.on("mouseover", function (d) {
  20171. //if(!mousedown_node || d === mousedown_node) return;
  20172. // enlarge target node
  20173. //d3.select(this).attr('transform', 'scale(1.1)');
  20174. })
  20175. .on("mouseout", function (d) {
  20176. //if(!mousedown_node || d === mousedown_node) return;
  20177. // unenlarge target node
  20178. //d3.select(this).attr('transform', '');
  20179. })
  20180. .on("mousedown", function (d) {
  20181. if (d3.event.ctrlKey) return;
  20182. //hideLinkForm(true);
  20183. //去除没有提交的连线
  20184. for (var i = 0; i < links.length; i++) {
  20185. if (links[i].id == -1) {
  20186. links.splice(i, 1);
  20187. }
  20188. }
  20189. // select node
  20190. mousedown_node = d;
  20191. if (mousedown_node === selected_node) {
  20192. selected_node = $scope.selected_node = null;
  20193. } else {
  20194. selected_node = $scope.selected_node = mousedown_node;
  20195. selected_link = $scope.selected_link = null;
  20196. // 点击节点 查询关系及节点 /traversal/{id}/{relation}
  20197. APIService.findRefById(selected_node.id).then(function (
  20198. result
  20199. ) {
  20200. var d = result.data;
  20201. var node = d.node;
  20202. var link = d.edge;
  20203. var tempNode = [];
  20204. var tempLink = [];
  20205. //nodes 或者links 要去重
  20206. for (var i = 0; i < node.length; i++) {
  20207. var tmp = 0;
  20208. for (var j = 0; j < nodes.length; j++) {
  20209. if (node[i].id == nodes[j].id) {
  20210. tmp++;
  20211. break;
  20212. }
  20213. }
  20214. if (tmp == 0) {
  20215. tempNode.push(node[i]);
  20216. }
  20217. }
  20218. for (var i = 0; i < link.length; i++) {
  20219. var tmp = 0;
  20220. for (var j = 0; j < links.length; j++) {
  20221. if (link[i].id == links[j].id) {
  20222. tmp++;
  20223. break;
  20224. }
  20225. }
  20226. if (tmp == 0) {
  20227. tempLink.push(link[i]);
  20228. }
  20229. }
  20230. //数据写入页面
  20231. for (var i = 0; i < tempNode.length; i++) {
  20232. //nodes 不清空
  20233. nodes.push(tempNode[i]);
  20234. }
  20235. for (var i = 0; i < tempLink.length; i++) {
  20236. //link 不清空
  20237. links.push(tempLink[i]);
  20238. }
  20239. //links转换
  20240. for (var i = 0; i < links.length; i++) {
  20241. for (var j = 0; j < nodes.length; j++) {
  20242. if (links[i].source == nodes[j].id) {
  20243. links[i].source = nodes[j];
  20244. }
  20245. if (links[i].target == nodes[j].id) {
  20246. links[i].target = nodes[j];
  20247. }
  20248. }
  20249. }
  20250. restart();
  20251. });
  20252. }
  20253. // reposition drag line
  20254. drag_line
  20255. .style("marker-end", "url(#end-arrow)")
  20256. .classed("hidden", false)
  20257. .attr(
  20258. "d",
  20259. "M" +
  20260. mousedown_node.x +
  20261. "," +
  20262. mousedown_node.y +
  20263. "L" +
  20264. mousedown_node.x +
  20265. "," +
  20266. mousedown_node.y
  20267. );
  20268. restart();
  20269. })
  20270. .on("mouseup", function (d) {
  20271. if (!mousedown_node) return;
  20272. });
  20273. // show node name
  20274. g.append("svg:text")
  20275. .attr("x", 0)
  20276. .attr("y", 34)
  20277. .attr("class", "id")
  20278. .text(function (d) {
  20279. return d.name;
  20280. }); //TODO 改为 d.name
  20281. //设置图片
  20282. g.append("svg:foreignObject")
  20283. .attr("width", 32)
  20284. .attr("height", 32)
  20285. .attr("x", "-16px")
  20286. .attr("y", "-11px")
  20287. .html(function (d) {
  20288. for (var i = 0; i < labels.length; i++) {
  20289. if (d.label == labels[i].sign) {
  20290. return (
  20291. '<i class="icon iconfont">' +
  20292. labels[i].iconname +
  20293. "</i>"
  20294. );
  20295. }
  20296. }
  20297. });
  20298. // remove old nodes
  20299. circle.exit().remove();
  20300. // set the graph in motion
  20301. force.start();
  20302. }
  20303. function mousedown() {
  20304. // prevent I-bar on drag
  20305. //d3.event.preventDefault();
  20306. // because :active only works in WebKit?
  20307. svg.classed("active", true);
  20308. if (mousedown_node) {
  20309. viewNode(mousedown_node);
  20310. }
  20311. if (d3.event.ctrlKey || mousedown_node || mousedown_link)
  20312. return;
  20313. restart();
  20314. }
  20315. function mousemove() {
  20316. if (!mousedown_node) return;
  20317. // update drag line
  20318. //drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]);
  20319. //restart();
  20320. }
  20321. function mouseup() {
  20322. if (mousedown_node) {
  20323. // hide drag line
  20324. drag_line.classed("hidden", true).style("marker-end", "");
  20325. }
  20326. // because :active only works in WebKit?
  20327. svg.classed("active", false);
  20328. // clear mouse event vars
  20329. resetMouseVars();
  20330. }
  20331. function spliceLinksForNode(node) {
  20332. var toSplice = links.filter(function (l) {
  20333. return l.source === node || l.target === node;
  20334. });
  20335. toSplice.map(function (l) {
  20336. links.splice(links.indexOf(l), 1);
  20337. });
  20338. }
  20339. // only respond once per keydown
  20340. var lastKeyDown = -1;
  20341. function keydown() {
  20342. //d3.event.preventDefault();
  20343. if (lastKeyDown !== -1) return;
  20344. lastKeyDown = d3.event.keyCode;
  20345. // ctrl
  20346. if (d3.event.keyCode === 17) {
  20347. circle.call(force.drag);
  20348. svg.classed("ctrl", true);
  20349. }
  20350. if (!selected_node && !selected_link) return;
  20351. switch (d3.event.keyCode) {
  20352. case 8: // backspace
  20353. case 66: // B
  20354. if (selected_link) {
  20355. // set link direction to both left and right
  20356. selected_link.left = true;
  20357. selected_link.right = true;
  20358. }
  20359. restart();
  20360. break;
  20361. case 76: // L
  20362. if (selected_link) {
  20363. // set link direction to left only
  20364. selected_link.left = true;
  20365. selected_link.right = false;
  20366. }
  20367. restart();
  20368. break;
  20369. case 82: // R
  20370. if (selected_node) {
  20371. // toggle node reflexivity
  20372. selected_node.reflexive = !selected_node.reflexive;
  20373. } else if (selected_link) {
  20374. // set link direction to right only
  20375. selected_link.left = false;
  20376. selected_link.right = true;
  20377. }
  20378. restart();
  20379. break;
  20380. }
  20381. }
  20382. function keyup() {
  20383. lastKeyDown = -1;
  20384. // ctrl
  20385. if (d3.event.keyCode === 17) {
  20386. circle
  20387. .on("mousedown.drag", null)
  20388. .on("touchstart.drag", null);
  20389. svg.classed("ctrl", false);
  20390. }
  20391. }
  20392. function viewNode(node) {
  20393. // console.log(svg.attr('left'));
  20394. //var el = angular.element('div.modal-dialog')[0];
  20395. var title =
  20396. $scope.selected_node.name +
  20397. "-[" +
  20398. $scope.selected_node.uuid +
  20399. "]";
  20400. if (!$scope.selected_node.props.state) {
  20401. $scope.selected_node.props.state = "空";
  20402. } else if ($scope.selected_node.props.state) {
  20403. if ($scope.selected_node.props.state == "1") {
  20404. $scope.selected_node.props.state = "未审核";
  20405. } else if ($scope.selected_node.props.state == "2") {
  20406. $scope.selected_node.props.state = "已审核";
  20407. } else if ($scope.selected_node.props.state == "3") {
  20408. $scope.selected_node.props.state = "不匹配";
  20409. } else if ($scope.selected_node.props.state == "4") {
  20410. $scope.selected_node.props.state = "丢失";
  20411. }
  20412. }
  20413. if (!$scope.selected_node.name) {
  20414. $scope.selected_node.name = "空";
  20415. }
  20416. if (!$scope.selected_node.status) {
  20417. $scope.selected_node.statu = "空";
  20418. }
  20419. if (!$scope.selected_node.props.useradmin) {
  20420. $scope.selected_node.props.useradmin = "空";
  20421. }
  20422. Toaster.pop({
  20423. // type: 'info',
  20424. // title: title,
  20425. body:
  20426. "<br/><p>搜索代码:" +
  20427. $scope.selected_node.uuid +
  20428. "</p>" +
  20429. "<p>配置标题:" +
  20430. $scope.selected_node.name +
  20431. "</p>" +
  20432. "<p>状态:" +
  20433. $scope.selected_node.status +
  20434. "</p>" +
  20435. "<p>审核状态:" +
  20436. $scope.selected_node.props.state +
  20437. "</p>" +
  20438. "<p>维护人员:" +
  20439. $scope.selected_node.props.useradmin +
  20440. "</p>",
  20441. bodyOutputType: "trustedHtml",
  20442. timeout: 3000,
  20443. });
  20444. }
  20445. //GT 颜色与数值对照表
  20446. function colors(sign) {
  20447. //num=num>20?num%20:parseInt(num);
  20448. for (var i = 0; i < labels.length; i++) {
  20449. var entity = labels[i];
  20450. if (sign == entity.sign) {
  20451. return entity.color;
  20452. }
  20453. if (i == labels.length - 1 && sign != entity.sign) {
  20454. return "#ffeeee";
  20455. }
  20456. }
  20457. }
  20458. $scope.init = function () {
  20459. svg = d3
  20460. .select("#cmdbSVG")
  20461. .append("svg")
  20462. .attr("width", width)
  20463. .attr("height", height);
  20464. // init D3 force layout
  20465. force = d3.layout
  20466. .force()
  20467. .nodes(nodes)
  20468. .links(links)
  20469. .size([width, height])
  20470. .gravity(0.05)
  20471. .linkDistance(150)
  20472. .linkStrength(2)
  20473. .charge(-500)
  20474. .on("tick", tick);
  20475. // define arrow markers for graph links
  20476. svg
  20477. .append("svg:defs")
  20478. .append("svg:marker")
  20479. .attr("id", "end-arrow")
  20480. .attr("viewBox", "0 -5 10 10")
  20481. .attr("refX", 6)
  20482. .attr("markerWidth", 3)
  20483. .attr("markerHeight", 3)
  20484. .attr("orient", "auto")
  20485. .append("svg:path")
  20486. .attr("d", "M0,-5L10,0L0,5")
  20487. .attr("fill", "#000");
  20488. svg
  20489. .append("svg:defs")
  20490. .append("svg:marker")
  20491. .attr("id", "start-arrow")
  20492. .attr("viewBox", "0 -5 10 10")
  20493. .attr("refX", 4)
  20494. .attr("markerWidth", 3)
  20495. .attr("markerHeight", 3)
  20496. .attr("orient", "auto")
  20497. .append("svg:path")
  20498. .attr("d", "M10,-5L0,0L10,5")
  20499. .attr("fill", "#000");
  20500. // line displayed when dragging new nodes
  20501. drag_line = svg
  20502. .append("svg:path")
  20503. .attr("class", "link dragline hidden")
  20504. .attr("d", "M0,0L0,0");
  20505. // handles to link and node element groups
  20506. //(1)var path = svg.append('svg:g').selectAll('g')
  20507. path = svg.append("svg:g").selectAll("g");
  20508. circle = svg.append("svg:g").selectAll("g");
  20509. svg
  20510. .on("mousedown", mousedown)
  20511. .on("mousemove", mousemove)
  20512. .on("mouseup", mouseup);
  20513. d3.select(window).on("keydown", keydown).on("keyup", keyup);
  20514. };
  20515. var CI = {};
  20516. window.CI = CI;
  20517. $scope.ok = function () {
  20518. $modalInstance.close($scope.selected_node);
  20519. };
  20520. $scope.cancel = function () {
  20521. $modalInstance.dismiss("cancel");
  20522. };
  20523. },
  20524. size: size,
  20525. resolve: {
  20526. title: function () {
  20527. return options.templateOptions.title;
  20528. },
  20529. Restangular: function () {
  20530. return options.templateOptions.Restangular;
  20531. },
  20532. APIService: function () {
  20533. return options.templateOptions.ApiService;
  20534. },
  20535. ConfigDataService: function () {
  20536. return options.templateOptions.ConfigDataService;
  20537. },
  20538. ConfigFormService: function () {
  20539. return options.templateOptions.ConfigFormService;
  20540. },
  20541. SweetAlert: function () {
  20542. return options.templateOptions.Alert;
  20543. },
  20544. Toaster: function () {
  20545. return options.templateOptions.toaster;
  20546. },
  20547. },
  20548. });
  20549. modalInstance.result.then(
  20550. function (selectedItem) {
  20551. options.value(selectedItem.name + "-" + selectedItem.uuid);
  20552. },
  20553. function () {
  20554. //console.log('Modal dismissed at: ' + new Date());
  20555. }
  20556. );
  20557. },
  20558. },
  20559. };
  20560. },
  20561. controller: [
  20562. "$scope",
  20563. function ($scope) {
  20564. // setTimeout(function(){
  20565. // $scope.options.templateOptions.getWorkernumber($scope.options.templateOptions.ApiService).then(function(result){
  20566. // var modelData = $scope.options.templateOptions.Restangular.stripRestangular(result);
  20567. // if(modelData.status==200){
  20568. // $scope.model[$scope.options.key] = modelData.data;
  20569. // $scope.options.initialValue = $scope.model[$scope.options.key];
  20570. // }
  20571. // });
  20572. // },1000);
  20573. },
  20574. ],
  20575. });
  20576. });
  20577. appFormly.run(function (formlyConfig, $parse) {
  20578. //formlyConfig.extras.fieldTransform=formlyConfig.extras.fieldTransform||[];
  20579. var removeOnHideTransformer = function (fields, model) {
  20580. return fields.map(function (field) {
  20581. if (
  20582. field.hideExpression &&
  20583. (!field.data || !field.data.dontRemoveOnHidden)
  20584. ) {
  20585. addFieldRemoveOnHideWatcher(field);
  20586. }
  20587. if (field.type == "ui-title") {
  20588. addFieldRemoveOnHideWatcher(field);
  20589. }
  20590. return field;
  20591. });
  20592. };
  20593. formlyConfig.extras.fieldTransform = removeOnHideTransformer;
  20594. function addFieldRemoveOnHideWatcher(field) {
  20595. var watcher = getWatcher();
  20596. if (field.watcher) {
  20597. if (!angular.isArray(field.watcher)) {
  20598. field.watcher = [field.watcher];
  20599. }
  20600. field.watcher.push(watcher);
  20601. } else {
  20602. field.watcher = watcher;
  20603. }
  20604. }
  20605. function getWatcher() {
  20606. return {
  20607. expression: function (field) {
  20608. return field.hide;
  20609. },
  20610. listener: function (field, newHide, oldHide, scope) {
  20611. if (field.hide) {
  20612. if (field.templateOptions.pkey) {
  20613. if (field.key == "transferuser") {
  20614. $parse(field.templateOptions.pkey + "." + field.key).assign(
  20615. scope.model,
  20616. undefined
  20617. );
  20618. }
  20619. } else if(typeof field.key =='string') {
  20620. $parse(field.key).assign(scope.model, undefined);
  20621. }
  20622. }
  20623. if (field.type == "ui-title") {
  20624. $parse(field.key).assign(scope.model, undefined);
  20625. }
  20626. },
  20627. };
  20628. }
  20629. });
  20630. appFormly.controller("CustomformCtrl", [
  20631. "$rootScope",
  20632. "$scope",
  20633. "$parse",
  20634. "$injector",
  20635. "$http",
  20636. "$q",
  20637. "$state",
  20638. "$stateParams",
  20639. "$modal",
  20640. "$timeout",
  20641. "$interval",
  20642. "SweetAlert",
  20643. "FileUploader",
  20644. "i18nService",
  20645. "Restangular",
  20646. "UserRestangular",
  20647. "BpmRestangular",
  20648. "WechatRestangular",
  20649. "api_configure_form",
  20650. "api_bpm_domain",
  20651. "api_bpm_domain1",
  20652. "api_bpm",
  20653. "api_bpm_data",
  20654. "api_user_data",
  20655. "api_statistic",
  20656. "up_down_file",
  20657. "fileReader",
  20658. "api_wechatfile",
  20659. function (
  20660. $rootScope,
  20661. $scope,
  20662. $parse,
  20663. $injector,
  20664. $http,
  20665. $q,
  20666. $state,
  20667. $stateParams,
  20668. $modal,
  20669. $timeout,
  20670. $interval,
  20671. SweetAlert,
  20672. FileUploader,
  20673. i18nService,
  20674. Restangular,
  20675. UserRestangular,
  20676. BpmRestangular,
  20677. WechatRestangular,
  20678. api_configure_form,
  20679. api_bpm_domain,
  20680. api_bpm_domain1,
  20681. api_bpm,
  20682. api_bpm_data,
  20683. api_user_data,
  20684. api_statistic,
  20685. up_down_file,
  20686. fileReader,
  20687. api_wechatfile
  20688. ) {
  20689. //console.log($parse('Restangular')($scope));
  20690. //console.log($injector.get('Restangular'));
  20691. //console.log($stateParams);
  20692. //保存报修主体
  20693. $scope.repairMain = JSON.parse(sessionStorage.getItem("repair_main"));
  20694. $scope.imgUrlList = [];
  20695. $scope.uploadimg_del = function () {
  20696. console.log(123);
  20697. };
  20698. var vm = this;
  20699. vm.options = {};
  20700. vm.exampleTitle = ["expressionProperties", "model property"];
  20701. vm.fields = [];
  20702. vm.model = {};
  20703. $scope.langs = i18nService.getAllLangs();
  20704. $scope.lang = "zh-cn";
  20705. i18nService.setCurrentLang($scope.lang);
  20706. //alert($rootScope.user.id,null,2);
  20707. vm.model["loginUser"] = $rootScope.user;
  20708. var loginUser = $rootScope.user;
  20709. // console.log(vm);
  20710. var that = $injector;
  20711. var parse = $parse;
  20712. var formKey = "";
  20713. var pdKey = "";
  20714. var modelWatch = "";
  20715. // 房间号是否显示
  20716. vm.model.isRoom = sessionStorage.getItem('ifRoom') == 1;
  20717. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  20718. modelWatch = JSON.parse($stateParams.model);
  20719. // console.log("modelWatch:"+ JSON.stringify(modelWatch));
  20720. // 进入页面时判断有无携带区域地点2020年4月24日10:30:41
  20721. console.log(modelWatch, $rootScope);
  20722. // if(modelWatch.model.incident){
  20723. // if(modelWatch.model.incident.place){
  20724. // $rootScope.selecthouseNumber = modelWatch.modle.incident.place;
  20725. // }else{
  20726. // $rootScope.selecthouseNumber = undefined;
  20727. // }
  20728. // }
  20729. // 初始化的时候判断是否是简单处理
  20730. if(modelWatch.model && modelWatch.model.incident && modelWatch.model.incident.category){
  20731. if (modelWatch.model.incident.category.hasSimple == 1) {
  20732. vm.model.isHasSimple = true;
  20733. }else{
  20734. vm.model.isHasSimple = false;
  20735. }
  20736. }
  20737. }
  20738. if (angular.isDefined($state.current.pdKey) && $state.current.pdKey != "") {
  20739. pdKey = $state.current.pdKey;
  20740. } else if ($stateParams.pdKey) {
  20741. pdKey = $stateParams.pdKey;
  20742. }
  20743. // console.log("pdKey::" + JSON.stringify($state.current.title));
  20744. if (angular.isDefined($stateParams.formKey) && $stateParams.formKey != "") {
  20745. formKey = $stateParams.formKey;
  20746. // console.log("formKey::"+JSON.stringify($stateParams.formKey));
  20747. }
  20748. if (angular.isDefined($stateParams.model)) {
  20749. var formModel = $stateParams.model;
  20750. }
  20751. //用户测试数据,后续从header的auth中获取
  20752. var userId = 2;
  20753. userId = $rootScope.user.id;
  20754. //==============处理表单设计数据 开始====================
  20755. //处理组件加载后台数据选项的方法
  20756. function refreshSelectOptions(searchVal, field) {
  20757. if (
  20758. field.templateOptions.optionsUrl &&
  20759. !field.templateOptions.isnosearch
  20760. ) {
  20761. var process = BpmRestangular.all("");
  20762. if (field.templateOptions.ApiService) {
  20763. process = UserRestangular.all("");
  20764. }
  20765. if (field.templateOptions.Apicommon) {
  20766. process = WechatRestangular.all("");
  20767. }
  20768. var datakey = {
  20769. idx: 0,
  20770. sum: 1000,
  20771. };
  20772. if (field.templateOptions.modelreasondata) {
  20773. datakey = field.templateOptions.modelreasondata;
  20774. }
  20775. process
  20776. .customPOST(datakey, field.templateOptions.optionsUrl)
  20777. .then(function (result) {
  20778. if (!field.templateOptions.options) {
  20779. field.templateOptions.options = [];
  20780. }
  20781. if (field.templateOptions.optionsDataKey) {
  20782. field.templateOptions.options =
  20783. result[field.templateOptions.optionsDataKey];
  20784. } else {
  20785. field.templateOptions.options = result;
  20786. }
  20787. });
  20788. }
  20789. }
  20790. //获取表单后数据处理
  20791. function formfield(field, result) {
  20792. // angular.forEach(fields.fields, function(field) {
  20793. if (field.key == "") {
  20794. delete field.key;
  20795. }
  20796. if (angular.isDefined(field.extjson)) {
  20797. var extObj = angular.fromJson(field.extjson); //JSON.parse(field.extjson);
  20798. angular.extend(field.templateOptions, extObj.templateOptions);
  20799. delete extObj.templateOptions;
  20800. for (var prop in extObj) {
  20801. if (new RegExp("Expression").test(prop)) {
  20802. //var obj = $scope.$eval(extObj[prop]);
  20803. //extObj[prop] = $scope.$eval(extObj[prop]);
  20804. if (extObj[prop] != null) {
  20805. if (new RegExp("function").test(extObj[prop])) {
  20806. var propValue = eval(extObj[prop]);
  20807. extObj[prop] = propValue;
  20808. } else {
  20809. //console.log(extObj[prop]);
  20810. var obj = $scope.$eval(extObj[prop]);
  20811. extObj[prop] = obj;
  20812. //console.log(obj);
  20813. }
  20814. }
  20815. } else if (new RegExp("expressionProperties").test(prop)) {
  20816. for (var p in extObj[prop]) {
  20817. if (new RegExp("function").test(extObj[prop][p])) {
  20818. var propValue = eval(extObj[prop][p]);
  20819. extObj[prop][p] = propValue;
  20820. } else {
  20821. //if(p.indexOf("'")>=0){
  20822. // var obj = $scope.$eval(extObj[prop][p]);
  20823. // extObj[prop][$scope.$eval(p)]=obj;
  20824. //}
  20825. }
  20826. }
  20827. } else if ("watcher" == prop) {
  20828. if (angular.isArray(extObj[prop])) {
  20829. angular.forEach(extObj[prop], function (item, index) {
  20830. for (var p in item) {
  20831. if (new RegExp("function").test(item[p])) {
  20832. var propValue = eval(item[p]);
  20833. extObj[prop][index][p] = propValue;
  20834. }
  20835. }
  20836. });
  20837. } else if (angular.isObject(extObj[prop])) {
  20838. for (var p in extObj[prop]) {
  20839. if (new RegExp("function").test(extObj[prop][p])) {
  20840. var propValue = eval(extObj[prop][p]);
  20841. extObj[prop][p] = propValue;
  20842. }
  20843. }
  20844. }
  20845. }
  20846. }
  20847. angular.extend(field, extObj);
  20848. delete field.extjson;
  20849. }
  20850. if (angular.isDefined(field.templateOptions)) {
  20851. var templateOs = field.templateOptions;
  20852. // console.log(templateOs,'come')
  20853. for (var property in templateOs) {
  20854. //console.log(angular.isString(templateOs[property]) +" "+property + " " + (!(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))));
  20855. if (angular.isString(templateOs[property])) {
  20856. //&& !(new RegExp("[\u4e00-\u9fa5]").test(templateOs[property]))
  20857. if (new RegExp("function").test(templateOs[property])) {
  20858. var propValue = eval(templateOs[property]);
  20859. field.templateOptions[property] = propValue;
  20860. } else {
  20861. if (that.has(templateOs[property])) {
  20862. field.templateOptions[property] = that.get(
  20863. templateOs[property]
  20864. );
  20865. } else {
  20866. field.templateOptions[property] = templateOs[property];
  20867. }
  20868. }
  20869. } else if (templateOs[property] == null) {
  20870. //delete field.templateOptions[property];
  20871. } else {
  20872. }
  20873. }
  20874. }
  20875. if (
  20876. angular.isDefined(field.templateOptions) &&
  20877. angular.isDefined(field.templateOptions.extjson)
  20878. ) {
  20879. var extObj = angular.fromJson(field.templateOptions.extjson); //JSON.parse(field.extjson);
  20880. angular.extend(field.templateOptions, extObj);
  20881. delete field.templateOptions.extjson;
  20882. }
  20883. // ...
  20884. if (field.templateOptions) {
  20885. //处理远程获取数据控件方法调用
  20886. if (
  20887. field.templateOptions.optionsUrl &&
  20888. !field.templateOptions.refresh
  20889. ) {
  20890. // if (!field.templateOptions.isnoreash) {
  20891. field.templateOptions.refresh = refreshSelectOptions;
  20892. // }
  20893. }
  20894. //处理嵌套属性数据绑定/
  20895. if (field.templateOptions.pkey) {
  20896. var pmodel,
  20897. i = 0;
  20898. angular.forEach(field.templateOptions.pkey.split("."), function (p) {
  20899. if (i == 0) {
  20900. if (result.model[p] == null) {
  20901. result.model[p] = {};
  20902. }
  20903. pmodel = result.model[p];
  20904. i++;
  20905. } else {
  20906. if (pmodel[p] == null) {
  20907. pmodel[p] = {};
  20908. }
  20909. pmodel = pmodel[p];
  20910. }
  20911. });
  20912. if (pmodel != null) {
  20913. field.model = pmodel;
  20914. if (pmodel[field.key] == null) {
  20915. pmodel[field.key] = null;
  20916. }
  20917. }
  20918. } else {
  20919. if (result.model[field.key] == null) {
  20920. result.model[field.key] = null;
  20921. }
  20922. }
  20923. //处理弹出框组件初始化
  20924. if (field.type == "ui-input-selectmodal") {
  20925. field.templateOptions.modal = $modal;
  20926. //field.templateOptions.Restangular = Restangular;
  20927. } else if (field.type == "ui-requesterselect") {
  20928. //field.templateOptions.language = $scope.lang;
  20929. field.templateOptions.modal = $modal;
  20930. field.templateOptions.UserService = api_user_data;
  20931. } else if (field.type == "ui-deptinformation") {
  20932. field.templateOptions.modal = $modal;
  20933. field.templateOptions.UserService = api_user_data;
  20934. } else if (field.type == "ui-requesterinformation") {
  20935. field.templateOptions.modal = $modal;
  20936. field.templateOptions.UserService = api_user_data;
  20937. } else if (field.type == "ui-userselect") {
  20938. field.templateOptions.modal = $modal;
  20939. //field.templateOptions.Restangular = Restangular;
  20940. } else if (field.type == "ui-userselectSearch") {
  20941. field.templateOptions.modal = $modal;
  20942. //field.templateOptions.Restangular = Restangular;
  20943. } else if (field.type == "ui-multiuserselect") {
  20944. field.templateOptions.modal = $modal;
  20945. } else if (field.type == "ui-stringuserselect") {
  20946. field.templateOptions.modal = $modal;
  20947. } else if (field.type == "ui-search") {
  20948. field.templateOptions.modal = $modal;
  20949. } else if (field.type == "ui-modelselect") {
  20950. field.templateOptions.modal = $modal;
  20951. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20952. field.templateOptions.loginUser = $rootScope.user;
  20953. //field.templateOptions.Restangular = Restangular;
  20954. } else if (field.type == "ui-incidentmodelselect") {
  20955. field.templateOptions.modal = $modal;
  20956. //console.log("$rootScope.user:" + JSON.stringify($rootScope.user));
  20957. field.templateOptions.loginUser = $rootScope.user;
  20958. //field.templateOptions.Restangular = Restangular;
  20959. } else if (field.type == "ui-dropfile") {
  20960. $scope.fileUploader = field.templateOptions.fileUploader =
  20961. new FileUploader({
  20962. url: "/uploader",
  20963. });
  20964. field.templateOptions.taskId = $stateParams.taskId;
  20965. field.templateOptions.processInstanceId =
  20966. $stateParams.processInstanceId;
  20967. field.templateOptions.userId = $rootScope.user.id;
  20968. } else if (field.type == "ui-dropfielknow") {
  20969. $scope.fileUploader = field.templateOptions.fileUploader =
  20970. new FileUploader({
  20971. url: "/uploader",
  20972. });
  20973. field.templateOptions.taskId = $stateParams.taskId;
  20974. field.templateOptions.processInstanceId =
  20975. $stateParams.processInstanceId;
  20976. field.templateOptions.userId = $rootScope.user.id;
  20977. } else if (field.type == "ui-upDropFile") {
  20978. $scope.fileUploader = field.templateOptions.fileUploader =
  20979. new FileUploader({
  20980. url: "/uploader",
  20981. });
  20982. field.templateOptions.taskId = $stateParams.taskId;
  20983. field.templateOptions.processInstanceId =
  20984. $stateParams.processInstanceId;
  20985. field.templateOptions.userId = $rootScope.user.id;
  20986. } else if (field.type == "ui-dropfilenotup") {
  20987. $scope.fileUploader = field.templateOptions.fileUploader =
  20988. new FileUploader({
  20989. url: "/uploader",
  20990. });
  20991. field.templateOptions.taskId = $stateParams.taskId;
  20992. field.templateOptions.processInstanceId =
  20993. $stateParams.processInstanceId;
  20994. field.templateOptions.userId = $rootScope.user.id;
  20995. //field.ApiService=api_bpm_domain;
  20996. } else if (field.type == "ui-uploadFiles") {
  20997. $scope.fileUploader = field.templateOptions.fileUploader =
  20998. new FileUploader({
  20999. url: "/uploader",
  21000. });
  21001. field.templateOptions.taskId = $stateParams.taskId;
  21002. field.templateOptions.processInstanceId =
  21003. $stateParams.processInstanceId;
  21004. field.templateOptions.userId = $rootScope.user.id;
  21005. //field.ApiService=api_bpm_domain;
  21006. } else if (field.type == "ui-upDownFiles") {
  21007. $scope.fileUploader = field.templateOptions.fileUploader =
  21008. new FileUploader({
  21009. url: "/uploader",
  21010. });
  21011. field.templateOptions.taskId = $stateParams.taskId;
  21012. field.templateOptions.processInstanceId =
  21013. $stateParams.processInstanceId;
  21014. field.templateOptions.userId = $rootScope.user.id;
  21015. //field.ApiService=api_bpm_domain;
  21016. } else if (field.type == "ui-uploadImgs") {
  21017. $scope.fileUploader = field.templateOptions.fileUploader =
  21018. new FileUploader({
  21019. url: "/uploader",
  21020. });
  21021. field.templateOptions.taskId = $stateParams.taskId;
  21022. field.templateOptions.processInstanceId =
  21023. $stateParams.processInstanceId;
  21024. field.templateOptions.userId = $rootScope.user.id;
  21025. //field.ApiService=api_bpm_domain;
  21026. } else if (field.type == "ui-dropfiletable") {
  21027. if (field.templateOptions.processInstanceId) {
  21028. } else {
  21029. field.templateOptions.processInstanceId =
  21030. $stateParams.processInstanceId;
  21031. }
  21032. } else if (field.type == "ui-dropFiles") {
  21033. if (field.templateOptions.processInstanceId) {
  21034. } else {
  21035. field.templateOptions.processInstanceId =
  21036. $stateParams.processInstanceId;
  21037. }
  21038. } else if (field.type == "ui-showImgs") {
  21039. if (field.templateOptions.processInstanceId) {
  21040. } else {
  21041. field.templateOptions.processInstanceId =
  21042. $stateParams.processInstanceId;
  21043. }
  21044. } else if (field.type == "ui-repeatSection") {
  21045. var repeatForm = {
  21046. model: {},
  21047. fields: field.templateOptions.fields,
  21048. };
  21049. repeatForm.model[field.key] = [];
  21050. decodeVMForm(repeatForm);
  21051. } else if (field.type == "ui-currentuser") {
  21052. field.templateOptions.user = vm.model["loginUser"];
  21053. } else if (field.type == "ui-workernumbersign") {
  21054. field.templateOptions.user = vm.model["loginUser"];
  21055. } else if (field.type == "ui-repair-photos") {
  21056. field.templateOptions.user = vm.model["loginUser"];
  21057. }
  21058. }
  21059. }
  21060. //解析自定义表单设计数据
  21061. $scope.oldfromtype = true;
  21062. function decodeVMForm(vmForm) {
  21063. if (vmForm.formType == "1") {
  21064. $scope.oldfromtype = false;
  21065. } else {
  21066. $scope.oldfromtype = true;
  21067. }
  21068. var result = {
  21069. model: {},
  21070. fields: [],
  21071. };
  21072. //设置模型实体数据 begin
  21073. // var mdata = vmForm.model;
  21074. //解析数据实体
  21075. var mdata = angular.fromJson(vmForm.model); //JSON.parse(field.extjson);
  21076. angular.extend(result.model, mdata);
  21077. if (modelWatch != null && modelWatch != "") {
  21078. //angular.extend(result.model.incident,modelWatch.incident);
  21079. //result.model.alarmType = modelWatch.alarmType;
  21080. // vmForm.cancelUrl = modelWatch.cancelUrl;
  21081. // console.log(modelWatch.cancelUrl)
  21082. for (var index in modelWatch.model) {
  21083. //console.log(JSON.stringify(index+" " +JSON.stringify( modelWatch.model[index])));
  21084. if (result.model[index] != null) {
  21085. angular.extend(result.model[index], modelWatch.model[index]);
  21086. } else {
  21087. result.model[index] = modelWatch.model[index];
  21088. }
  21089. }
  21090. }
  21091. //设置模型实体数据 end
  21092. //解析设计数据生成表单项 begin
  21093. var fields = [];
  21094. //处理修改设计数据中展示设置
  21095. angular.forEach(vmForm.fields, function (fields) {
  21096. if (vmForm.formType == "1") {
  21097. angular.forEach(fields.fields, function (field) {
  21098. formfield(field, result);
  21099. });
  21100. } else {
  21101. formfield(fields, result);
  21102. }
  21103. // console.log(field);
  21104. result.fields.push(fields);
  21105. });
  21106. angular.extend($scope.vm.fields, result.fields);
  21107. angular.extend($scope.vm.model, result.model);
  21108. vm.model["loginUser"] = $rootScope.user;
  21109. //增加识别报修主体seimin
  21110. vm.model.repairType = $scope.repairMain.valueconfig;
  21111. if (vm.model.incident) {
  21112. vm.model.incident.repairType = $scope.repairMain.valueconfig;
  21113. }
  21114. console.log(vm, "repairType"); //lmm
  21115. if (
  21116. modelWatch != null &&
  21117. modelWatch != "" &&
  21118. modelWatch.cancelUrl != null &&
  21119. modelWatch.cancelUrl != ""
  21120. ) {
  21121. vmForm.cancelUrl = modelWatch.cancelUrl;
  21122. }
  21123. $scope.formData = vmForm;
  21124. console.log($scope.formData, 4444444);
  21125. // console.log($scope.formData.url);
  21126. // console.log("$scope.formData="+JSON.stringify($scope.formData.url));
  21127. if ($scope.formData.url == "start") {
  21128. $scope.Reset = true;
  21129. $scope.close = true;
  21130. $rootScope.isMask = false;
  21131. } else if ($scope.formData.url == "complete") {
  21132. $scope.Reset = false;
  21133. $scope.close = true;
  21134. }
  21135. //解析设计数据生成表单项 end
  21136. return result;
  21137. }
  21138. //======================处理表单设计数据 结束========================
  21139. $scope.ldloading = {};
  21140. function filter(obj) {
  21141. angular.forEach(obj, function (key, value) {
  21142. if (value === "" || value === null) {
  21143. delete obj[key];
  21144. } else if (
  21145. Object.prototype.toString.call(value) === "[object Object]"
  21146. ) {
  21147. filter(value);
  21148. } else if (angular.isArray(value)) {
  21149. angular.forEach(value, function (item) {
  21150. filter(item);
  21151. });
  21152. }
  21153. });
  21154. }
  21155. $scope.closeModel = function () {
  21156. // console.log($stateParams);
  21157. $state.go($scope.formData.cancelUrl, {});
  21158. event.preventDefault();
  21159. };
  21160. // console.log(vm);
  21161. // 暂存
  21162. $scope.save = function (data) {
  21163. console.log(vm);
  21164. if (vm.model.startSave) {
  21165. vm.model["initUser"] = $rootScope.user.id;
  21166. vm.model.start_code = "temporary";
  21167. //处理请求数据0327
  21168. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21169. delete data0327.repairType;
  21170. // console.log($scope.$parent.$parent.$parent.$parent.$parent.$parent.selecthouseNumber,'2020年4月24日20:24:10');
  21171. if (
  21172. $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21173. .selecthouseNumber
  21174. ) {
  21175. data0327.incident.place = {
  21176. id: $scope.$parent.$parent.$parent.$parent.$parent.$parent
  21177. .selecthouseNumber.id,
  21178. };
  21179. }
  21180. api_bpm_domain.start(pdKey, data0327).then(function (response) {
  21181. if (response) {
  21182. var resData = Restangular.stripRestangular(response);
  21183. if (resData) {
  21184. if (
  21185. $scope.fileUploader != null &&
  21186. $scope.fileUploader.getNotUploadedItems().length > 0 &&
  21187. resData.id
  21188. ) {
  21189. $scope.fileUploader.onBeforeUploadItem = function (item) {
  21190. angular.extend(item.headers, $rootScope.getSession());
  21191. item.url = api_bpm_domain
  21192. .uploadAttachment(resData.id, "00000", $rootScope.user.id)
  21193. .getRequestedUrl();
  21194. item.formData.push({
  21195. fileName: item.file.name,
  21196. });
  21197. //console.log();
  21198. };
  21199. $scope.fileUploader.uploadAll();
  21200. }
  21201. }
  21202. SweetAlert.swal(
  21203. {
  21204. title: "提交成功!",
  21205. type: "success",
  21206. confirmButtonColor: "#007AFF",
  21207. },
  21208. function () {
  21209. $state.go($scope.formData.cancelUrl);
  21210. }
  21211. );
  21212. } else {
  21213. SweetAlert.swal({
  21214. title: "系统错误",
  21215. text: "系统错误,请稍后重试!",
  21216. type: "error",
  21217. confirmButtonColor: "#DD6B55",
  21218. });
  21219. }
  21220. $scope.ldloading[style.replace("-", "_")] = false;
  21221. });
  21222. event.preventDefault();
  21223. } else if (vm.model.saveAgain) {
  21224. var toData = {
  21225. incident: vm.model.incident,
  21226. };
  21227. api_user_data.updData("incident", toData).then(function (response) {
  21228. if (response) {
  21229. var resData = Restangular.stripRestangular(response);
  21230. SweetAlert.swal(
  21231. {
  21232. title: "提交成功!",
  21233. type: "success",
  21234. confirmButtonColor: "#007AFF",
  21235. },
  21236. function () {
  21237. $state.go($scope.formData.cancelUrl);
  21238. }
  21239. );
  21240. } else {
  21241. SweetAlert.swal({
  21242. title: "系统错误",
  21243. text: "系统错误,请稍后重试!",
  21244. type: "error",
  21245. confirmButtonColor: "#DD6B55",
  21246. });
  21247. }
  21248. $scope.ldloading[style.replace("-", "_")] = false;
  21249. });
  21250. event.preventDefault();
  21251. } else {
  21252. SweetAlert.swal({
  21253. title: "系统错误",
  21254. text: "系统错误,请稍后重试!",
  21255. type: "error",
  21256. confirmButtonColor: "#DD6B55",
  21257. });
  21258. }
  21259. };
  21260. // 巡检生成事件
  21261. $scope.inspectionToIncident = function () {
  21262. var userData = {
  21263. idx: 0,
  21264. sum: 10,
  21265. requester: {
  21266. name: loginUser.name,
  21267. },
  21268. };
  21269. api_user_data.fetchDataList("requester", userData).then(function (res) {
  21270. console.log(res);
  21271. var toUser = {};
  21272. if (res.list.length > 0) {
  21273. toUser = res.list[0];
  21274. } else {
  21275. toUser = loginUser;
  21276. }
  21277. console.log(vm);
  21278. var incidentDescription = "";
  21279. console.log($stateParams.formUiEdit);
  21280. if ($stateParams.formUiEdit == "inspection_LinHu_confirm") {
  21281. var fields = vm.fields
  21282. .filter((v) => {
  21283. v.key = (v.key || "").toString();
  21284. return v.key.indexOf("sdCheckEnable") > -1;
  21285. })
  21286. .map((v) => ({
  21287. key: v.key,
  21288. name: v.templateOptions.label,
  21289. value: vm.model[v.key],
  21290. }));
  21291. fields.forEach(v=>{
  21292. if (vm.model[v.key]) {
  21293. incidentDescription =
  21294. incidentDescription.concat(v.name);
  21295. }
  21296. })
  21297. if (vm.model.descriptionTextarea) {
  21298. incidentDescription = incidentDescription.concat(
  21299. " " + "整改意见:" + vm.model.descriptionTextarea
  21300. );
  21301. }
  21302. }
  21303. // console.log(incidentDescription)
  21304. var bxr = JSON.parse(localStorage.getItem("login_requester"));
  21305. var formdata = {
  21306. model: {
  21307. // 'isInspection': true,
  21308. // 'start_code':'assignment',
  21309. // 'isHandlerUser':false,
  21310. incident: {
  21311. requester: bxr,
  21312. area: bxr.place.area,
  21313. place: bxr.place,
  21314. houseNumber: bxr.houseNumber,
  21315. contacts: bxr.name,
  21316. contactsInformation: bxr.mphone,
  21317. // 'category': data.wxIncidentClassifyDTO.category,
  21318. description: incidentDescription,
  21319. source: {
  21320. id: 1552,
  21321. },
  21322. // 'handlingPersonnelUser': loginUser,//2020年4月27日22:29:02
  21323. // 'sourceType': data.incident.sourceType,
  21324. // 'fileUrl': data.incident.fileUrl
  21325. },
  21326. // 'requestershow': toUser,//2020年4月27日22:29:15
  21327. // 'flow': data.incident.id
  21328. // 'assignee': loginUser.id//2020年4月27日22:29:25
  21329. },
  21330. };
  21331. // console.log(formdata,toUser,'1111');
  21332. console.log(formdata, "1111");
  21333. // return;
  21334. $state.go("app.incident.chart", {
  21335. model: JSON.stringify(formdata),
  21336. });
  21337. });
  21338. // var formdata = {
  21339. // model:$rootScope.login_requester
  21340. // };
  21341. // console.log(formdata,'00000')
  21342. // return;
  21343. // $state.go("app.incident.chart", {
  21344. // 'model': JSON.stringify(formdata)
  21345. // });
  21346. event.preventDefault();
  21347. };
  21348. // console.log(vm);
  21349. // 创建事件seimin
  21350. vm.submit = function (data, style) {
  21351. console.log(vm, 22222);
  21352. // return;
  21353. if (vm.model.handler_code == undefined) {
  21354. vm.model.handler_code = "resolve";
  21355. }
  21356. if (
  21357. vm.model.change &&
  21358. vm.model.change.requestingPerson &&
  21359. vm.model.change.requestingPerson.menu
  21360. ) {
  21361. delete vm.model.change.requestingPerson.menu;
  21362. }
  21363. // var pdKey = $stateParams.pdKey;
  21364. if (vm.form.$valid) {
  21365. if (data.incident && data.incident.synergetic) {
  21366. console.log(data.incident.synergetic);
  21367. var synergetic = [];
  21368. for (var i = 0; i < data.incident.synergetic.length; i++) {
  21369. synergetic.push({
  21370. id: data.incident.synergetic[i],
  21371. });
  21372. }
  21373. data.incident.synergetic = synergetic;
  21374. vm.model.incident.synergetic = synergetic;
  21375. }
  21376. $scope.ldloading[style.replace("-", "_")] = true;
  21377. var startsub = true;
  21378. if (pdKey == "bpm_incident") {
  21379. angular.forEach(vm.fields, function (item) {
  21380. angular.forEach(item.fields, function (index) {
  21381. if (index.templateOptions.required && !index.hide) {
  21382. if (index.model) {
  21383. if (
  21384. angular.isDefined(index.model[index.key]) &&
  21385. index.model[index.key] != null
  21386. ) {
  21387. if (
  21388. index.model[index.key].id &&
  21389. index.model[index.key].id == ""
  21390. ) {
  21391. startsub = false;
  21392. $scope.ldloading.expand_right = false;
  21393. SweetAlert.swal({
  21394. title: index.templateOptions.label + "未填",
  21395. text: "请填写此项!",
  21396. type: "error",
  21397. confirmButtonColor: "#DD6B55",
  21398. });
  21399. } else {
  21400. }
  21401. } else {
  21402. startsub = false;
  21403. $scope.ldloading.expand_right = false;
  21404. console.log(vm);
  21405. SweetAlert.swal({
  21406. title: index.templateOptions.label + "未填",
  21407. text: "请填写此项!",
  21408. type: "error",
  21409. confirmButtonColor: "#DD6B55",
  21410. });
  21411. }
  21412. } else {
  21413. if (
  21414. data[index.key] &&
  21415. data[index.key] != "" &&
  21416. data[index.key] != null
  21417. ) {
  21418. } else {
  21419. startsub = false;
  21420. $scope.ldloading.expand_right = false;
  21421. SweetAlert.swal({
  21422. title: index.templateOptions.label + "未填",
  21423. text: "请填写此项!",
  21424. type: "error",
  21425. confirmButtonColor: "#DD6B55",
  21426. });
  21427. }
  21428. }
  21429. }
  21430. });
  21431. });
  21432. if (vm.model.incident){
  21433. if(!vm.model.incident.branch.id){
  21434. startsub = false;
  21435. $scope.ldloading.expand_right = false;
  21436. SweetAlert.swal({
  21437. title: '请填写校区',
  21438. text: "请填写此项!",
  21439. type: "error",
  21440. confirmButtonColor: "#DD6B55"
  21441. });
  21442. }
  21443. }
  21444. // if (vm.model.incident){
  21445. // if(vm.model.incident.branch.id && vm.model.incident.place.id){
  21446. // }else if(vm.model.incident.branch.id || vm.model.incident.place.id){
  21447. // startsub = false;
  21448. // $scope.ldloading.expand_right = false;
  21449. // SweetAlert.swal({
  21450. // title: '请填写完整的校区区域地点',
  21451. // text: "请填写此项!",
  21452. // type: "error",
  21453. // confirmButtonColor: "#DD6B55"
  21454. // });
  21455. // }
  21456. // }
  21457. // if (vm.model.requestershow && vm.model.requestershow != null && vm.model.requestershow != '') {} else {
  21458. // startsub = false;
  21459. // $scope.ldloading.expand_right = false;
  21460. // SweetAlert.swal({
  21461. // title: '保修人未填',
  21462. // text: "请填写此项!",
  21463. // type: "error",
  21464. // confirmButtonColor: "#DD6B55"
  21465. // });
  21466. // }
  21467. // if (vm.model.incident.category && vm.model.incident.category != null && vm.model.incident.category != '') {
  21468. // } else {
  21469. // startsub = false;
  21470. // $scope.ldloading.expand_right = false;
  21471. // SweetAlert.swal({
  21472. // title: '事件分类未填',
  21473. // text: "请填写此项!",
  21474. // type: "error",
  21475. // confirmButtonColor: "#DD6B55"
  21476. // });
  21477. // }
  21478. }
  21479. if (startsub) {
  21480. $scope.ldloading[style.replace("-", "_")] = true;
  21481. // if($scope.ldloading[style.replace('-', '_')] == true){$scope.lng=true}
  21482. // console.log("vm.options:"+ JSON.stringify(vm.options));
  21483. vm.options.updateInitialValue();
  21484. // console.log("dfjkasdhfkhskjf ")
  21485. var _ = window._;
  21486. vm.model = (function filter(obj) {
  21487. var dateTransKeys = [];
  21488. var filtered = _.pick(obj, function (v, k, obj) {
  21489. if (_.isDate(v)) {
  21490. dateTransKeys.push(k);
  21491. }
  21492. return (
  21493. angular.isDefined(v) &&
  21494. v !== null &&
  21495. (angular.isArray(v) ? v.length > 0 : true) &&
  21496. (_.isPlainObject(v) ? !_.isEmpty(v) : true)
  21497. );
  21498. });
  21499. return _.cloneDeep(filtered, function (v, index, object) {
  21500. if (angular.isArray(dateTransKeys) && dateTransKeys.length > 0) {
  21501. angular.forEach(dateTransKeys, function (item) {
  21502. v[item] = moment(v[item]).format("YYYY-MM-DD HH:mm:ss");
  21503. });
  21504. dateTransKey = [];
  21505. return v;
  21506. }
  21507. return !_.isEmpty(filtered) &&
  21508. v !== filtered &&
  21509. _.isPlainObject(v)
  21510. ? filter(v)
  21511. : undefined;
  21512. });
  21513. })(vm.model);
  21514. if (pdKey != "") {
  21515. if ($scope.oprcode == "save") {
  21516. //保存
  21517. api_bpm_domain.save(taskId, vm.model).then(function (response) {
  21518. if (response) {
  21519. var resData = Restangular.stripRestangular(response);
  21520. SweetAlert.swal(
  21521. {
  21522. title: "保存成功!",
  21523. confirmButtonColor: "#007AFF",
  21524. },
  21525. function () {
  21526. $state.go($scope.formData.cancelUri);
  21527. }
  21528. );
  21529. // if(resData.status){
  21530. // resData
  21531. // }
  21532. } else {
  21533. SweetAlert.swal({
  21534. title: "系统错误",
  21535. text: "系统错误,请稍后重试!",
  21536. type: "error",
  21537. confirmButtonColor: "#DD6B55",
  21538. });
  21539. }
  21540. $scope.ldloading[style.replace("-", "_")] = false;
  21541. });
  21542. } else {
  21543. console.log($scope.formData.url, "zzzz");
  21544. var integralMechanism = sessionStorage.getItem('integralMechanism');
  21545. let integralRoles = [];
  21546. let currentUserRoles = [];
  21547. let intersection = [];
  21548. switch ($scope.formData.url) {
  21549. case "start":
  21550. vm.model["initUser"] = $rootScope.user.id;
  21551. if (vm.model["assignee"] || vm.model["candidateGroups"]) {
  21552. } else {
  21553. vm.model["assignee"] = $rootScope.user.id;
  21554. }
  21555. if (
  21556. vm.model["candidateGroups"] &&
  21557. vm.model.candidateGroups.id
  21558. ) {
  21559. vm.model.candidateGroups = vm.model.candidateGroups.id;
  21560. }
  21561. if (pdKey == "bpm_service_request") {
  21562. delete vm.model.serviceCatalogueProcessActual.houseNumber;
  21563. angular.extend(vm.model.serviceCatalogueProcessActual, {
  21564. category: {
  21565. id: $stateParams.userId,
  21566. },
  21567. });
  21568. }
  21569. if (vm.model.schedule && vm.model.schedule.initUser) {
  21570. delete vm.model.schedule.initUser.menu;
  21571. }
  21572. if (
  21573. vm.model.isHandlerUser == "true" ||
  21574. vm.model.isHandlerUser == true
  21575. ) {
  21576. delete vm.model.candidateGroups;
  21577. }
  21578. if (vm.model.start_code == "close") {
  21579. // 直接处理
  21580. vm.model.incident.handlingPersonnelUser =
  21581. vm.model.incident.acceptUser;
  21582. delete vm.model.incident.handlerUser;
  21583. delete vm.model.candidateGroups;
  21584. } else if (vm.model.start_code == "assignment") {
  21585. // 派单
  21586. delete vm.model.incident.handlingPersonnelUser;
  21587. }
  21588. if ($stateParams.processInstanceId && vm.model.isZanCun) {
  21589. $scope.jry_processInstanceId =
  21590. $stateParams.processInstanceId;
  21591. }
  21592. if ($scope.jry_processInstanceId) {
  21593. vm.model["save_fileId"] = $scope.jry_processInstanceId;
  21594. }
  21595. //事件暂存判断
  21596. if (vm.model.saveAgain) {
  21597. if (
  21598. vm.model.directClose == "1" ||
  21599. vm.model.directClose == true
  21600. ) {
  21601. vm.model.start_code = "assignment";
  21602. vm.model.temporary_code = "assignment";
  21603. } else {
  21604. vm.model.start_code = "close";
  21605. vm.model.temporary_code = "close";
  21606. }
  21607. if (
  21608. vm.model.isHandlerUser == "true" ||
  21609. vm.model.isHandlerUser == true
  21610. ) {
  21611. delete vm.model.candidateGroups;
  21612. }
  21613. }
  21614. //处理请求数据0327
  21615. var data0327 = JSON.parse(JSON.stringify(vm.model));
  21616. delete data0327.repairType;
  21617. if (data0327.start_code == "close") {
  21618. data0327.incident.directProcess = 1;
  21619. }
  21620. console.log(vm);
  21621. if (angular.isDefined($stateParams.model) && $stateParams.model != "") {
  21622. var paramsModel = JSON.parse($stateParams.model)
  21623. //来电-传话机id
  21624. if (paramsModel.model.incident.sockid) {
  21625. data0327.incident.callID = paramsModel.model.incident.sockid;
  21626. }
  21627. }
  21628. // --------------------------- start----------------------------------------
  21629. // 积分机制,直接处理
  21630. // let integralRoles = [];
  21631. // let currentUserRoles = [];
  21632. // let intersection = [];
  21633. if(integralMechanism == 1){
  21634. integralRoles = sessionStorage.getItem("integralRole") ? sessionStorage.getItem("integralRole").split(',') : [];
  21635. currentUserRoles = $rootScope.user.role ? $rootScope.user.role.map(v=>String(v.id)) : [];
  21636. intersection = integralRoles.filter(function (val) { return currentUserRoles.indexOf(val) > -1 })
  21637. }
  21638. if(vm.model.start_code == "close"&&((integralMechanism == 1 && (intersection.length || integralRoles.length === 0)) || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21639. $modal.open({
  21640. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21641. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21642. console.log(incidentData,currentUserId);
  21643. $scope.flag = false;
  21644. $scope.complexityConfirm = {complexity:null,updateReason:'', auditor: undefined};
  21645. $scope.complexityFn = function(category){
  21646. if(category.complexity){
  21647. return category.complexity.value;
  21648. }else if(category.parent){
  21649. return $scope.complexityFn(category.parent);
  21650. }else{
  21651. return $scope.list[0]?$scope.list[0].value:1;
  21652. }
  21653. }
  21654. $scope.list = [];
  21655. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21656. $scope.list = res;
  21657. if(incidentData.category && incidentData.category.id){
  21658. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21659. if(result.status == 200){
  21660. $scope.complexity = $scope.complexityFn(result.data);
  21661. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21662. }
  21663. })
  21664. }
  21665. })
  21666. $scope.onChangehandling = function(key = ''){
  21667. api_user_data.fetchDataList('user', {
  21668. "idx": 0,
  21669. "sum": 9999,
  21670. "user": {
  21671. "name": key,
  21672. 'selectType': "pinyin_qs",
  21673. "roledata": { rolecode: "incident manager" }
  21674. }
  21675. }).then(function(response) {
  21676. if (response) {
  21677. if (response.status = 200) {
  21678. $scope.auditors = response.list;
  21679. }
  21680. }
  21681. })
  21682. }
  21683. $scope.auditors = [];
  21684. $scope.onChangehandling();
  21685. $scope.onChangeComplexity = function(item){
  21686. }
  21687. $scope.ok = function () {
  21688. if (!$scope.complexityConfirm.complexity){
  21689. Alert.swal({
  21690. title: "操作失败",
  21691. text: "请选择工时!",
  21692. type: "error"
  21693. });
  21694. return;
  21695. }
  21696. if (!$scope.complexityConfirm.auditor){
  21697. Alert.swal({
  21698. title: "操作失败",
  21699. text: "请选择审核人!",
  21700. type: "error"
  21701. });
  21702. return;
  21703. }
  21704. if ($scope.complexityConfirm.complexity.value != $scope.complexity&&!$scope.complexityConfirm.updateReason.trim()){
  21705. Alert.swal({
  21706. title: "操作失败",
  21707. text: "请填写升级原因!",
  21708. type: "error"
  21709. });
  21710. return;
  21711. }
  21712. $modalInstance.close('success');
  21713. handlerStart();
  21714. scope.complexity = $scope.complexity;
  21715. scope.complexityConfirm = $scope.complexityConfirm;
  21716. // 暂存--后面直接处理后调用积分接口
  21717. }
  21718. $scope.cancel = function () {
  21719. scope.ldloading.expand_right = false;
  21720. $modalInstance.dismiss('cancel');
  21721. }
  21722. },
  21723. size: 'sm',
  21724. resolve: {
  21725. scope: function () {
  21726. return $scope;
  21727. },
  21728. api_bpm: function () {
  21729. return api_bpm;
  21730. },
  21731. incidentData: function () {
  21732. return data0327.incident;
  21733. },
  21734. currentUserId: function () {
  21735. return loginUser.id;
  21736. },
  21737. Alert: function () {
  21738. return SweetAlert;
  21739. },
  21740. api_user_data: function () {
  21741. return api_user_data;
  21742. },
  21743. api_wechatfile: function () {
  21744. return api_wechatfile;
  21745. }
  21746. }
  21747. });
  21748. }else{
  21749. handlerStart();
  21750. }
  21751. // -------------------------------end------------------------------------
  21752. function handlerStart(){
  21753. api_bpm_domain
  21754. .start(pdKey, data0327)
  21755. .then(function (response) {
  21756. if (response) {
  21757. var resData = Restangular.stripRestangular(response);
  21758. if (resData) {
  21759. if (resData) {
  21760. if (
  21761. $scope.fileUploader != null &&
  21762. $scope.fileUploader.getNotUploadedItems().length >
  21763. 0 &&
  21764. resData.id
  21765. ) {
  21766. $scope.fileUploader.onBeforeUploadItem =
  21767. function (item) {
  21768. angular.extend(
  21769. item.headers,
  21770. $rootScope.getSession()
  21771. );
  21772. item.url = api_bpm_domain
  21773. .uploadAttachment(
  21774. resData.id,
  21775. "00000",
  21776. $rootScope.user.id
  21777. )
  21778. .getRequestedUrl();
  21779. item.formData.push({
  21780. fileName: item.file.name,
  21781. });
  21782. //console.log();
  21783. };
  21784. $scope.fileUploader.uploadAll();
  21785. }
  21786. }
  21787. }
  21788. let integralRoles = [];
  21789. let currentUserRoles = [];
  21790. let intersection = [];
  21791. if(integralMechanism == 1){
  21792. integralRoles = sessionStorage.getItem("integralRole") ? sessionStorage.getItem("integralRole").split(',') : [];
  21793. currentUserRoles = $rootScope.user.role ? $rootScope.user.role.map(v=>String(v.id)) : [];
  21794. intersection = integralRoles.filter(function (val) { return currentUserRoles.indexOf(val) > -1 })
  21795. }
  21796. if(vm.model.start_code == "close"&&((integralMechanism == 1 && (intersection.length || integralRoles.length === 0)) || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21797. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21798. var auditState = res.find(v=>v.value == 0);
  21799. var postData = {
  21800. incidentIntegral: {
  21801. incidentId:resData.bussId,
  21802. auditState:auditState,
  21803. handlerUser:$rootScope.user.id,
  21804. handlerUserName:$rootScope.user.name,
  21805. sourceScore:$scope.complexity,
  21806. currentScore:$scope.complexityConfirm.complexity.value,
  21807. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21808. auditUser: $scope.complexityConfirm.auditor.id
  21809. }
  21810. }
  21811. console.log(postData)
  21812. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21813. console.log(response)
  21814. if (response.status == 200) {
  21815. SweetAlert.swal(
  21816. {
  21817. title: "提交成功!",
  21818. type: "success",
  21819. confirmButtonColor: "#007AFF",
  21820. },
  21821. function () {
  21822. if (
  21823. vm.model.incident &&
  21824. vm.model.incident.callID &&
  21825. vm.model.incident.callID != ""
  21826. ) {
  21827. $rootScope.app.layout.isSidebarClosed = false;
  21828. if ($scope.login && !$rootScope.busy) {
  21829. // $rootScope.setidle();
  21830. }
  21831. }
  21832. $state.go($scope.formData.cancelUrl);
  21833. }
  21834. );
  21835. } else {
  21836. Alert.swal({
  21837. title: "操作失败",
  21838. text: "操作失败, 请稍后再试!",
  21839. type: "error"
  21840. });
  21841. }
  21842. });
  21843. })
  21844. }else{
  21845. SweetAlert.swal(
  21846. {
  21847. title: "提交成功!",
  21848. type: "success",
  21849. confirmButtonColor: "#007AFF",
  21850. },
  21851. function () {
  21852. if (
  21853. vm.model.incident &&
  21854. vm.model.incident.callID &&
  21855. vm.model.incident.callID != ""
  21856. ) {
  21857. $rootScope.app.layout.isSidebarClosed = false;
  21858. if ($scope.login && !$rootScope.busy) {
  21859. // $rootScope.setidle();
  21860. }
  21861. }
  21862. $state.go($scope.formData.cancelUrl);
  21863. }
  21864. );
  21865. }
  21866. } else {
  21867. SweetAlert.swal({
  21868. title: "系统错误",
  21869. text: "系统错误,请稍后重试!",
  21870. type: "error",
  21871. confirmButtonColor: "#DD6B55",
  21872. });
  21873. }
  21874. $scope.ldloading[style.replace("-", "_")] = false;
  21875. });
  21876. }
  21877. break;
  21878. case "complete":
  21879. //api_bpm_domain.complete(pdKey, userId, vm.model).then(function(response){
  21880. //console.log("complete taskId::"+$stateParams.taskId);
  21881. if (
  21882. $scope.formData.name == "transferform" &&
  21883. vm.model.ishandlers &&
  21884. !vm.model.incident.handlerUser
  21885. ) {
  21886. SweetAlert.swal({
  21887. title: "处理人未填",
  21888. text: "请填写此项!",
  21889. type: "error",
  21890. confirmButtonColor: "#DD6B55",
  21891. });
  21892. return;
  21893. }
  21894. console.log(vm);
  21895. // 积分机制,事件状态是“处理中”
  21896. // let integralRoles = [];
  21897. // let currentUserRoles = [];
  21898. // let intersection = [];
  21899. if(integralMechanism == 1){
  21900. integralRoles = sessionStorage.getItem("integralRole") ? sessionStorage.getItem("integralRole").split(',') : [];
  21901. currentUserRoles = $rootScope.user.role ? $rootScope.user.role.map(v=>String(v.id)) : [];
  21902. intersection = integralRoles.filter(function (val) { return currentUserRoles.indexOf(val) > -1 })
  21903. }
  21904. if($scope.formData.name === 'handlerform'&&((integralMechanism == 1 && (intersection.length || integralRoles.length === 0)) || (integralMechanism == 2 && $rootScope.user.userType.value == 2))){
  21905. $modal.open({
  21906. templateUrl: 'assets/views/incident/tpl/toIntegralMechanism.tpl.html',
  21907. controller: function ($scope, $modalInstance, api_bpm_domain, incidentData, currentUserId, Alert, api_user_data,api_wechatfile,scope,api_bpm_data) {
  21908. console.log(incidentData,currentUserId);
  21909. $scope.flag = true;
  21910. $scope.complexityConfirm = {complexity:null,updateReason:'', auditor: undefined};
  21911. $scope.complexityFn = function(category){
  21912. if(category.complexity){
  21913. return category.complexity.value;
  21914. }else if(category.parent){
  21915. return $scope.complexityFn(category.parent);
  21916. }else{
  21917. return $scope.list[0]?$scope.list[0].value:1;
  21918. }
  21919. }
  21920. $scope.list = [];
  21921. api_wechatfile.getDictionary({"key":"incident_complexity","type":"list"}).then(function(res){
  21922. $scope.list = res;
  21923. if(incidentData.category && incidentData.category.id){
  21924. api_bpm_data.fetchData("incidentCategory",incidentData.category.id).then(function(result){
  21925. if(result.status == 200){
  21926. $scope.complexity = $scope.complexityFn(result.data);
  21927. $scope.complexityConfirm.complexity = $scope.list.find(v=>v.value == $scope.complexity);
  21928. }
  21929. })
  21930. }
  21931. })
  21932. $scope.onChangehandling = function(key = ''){
  21933. api_user_data.fetchDataList('user', {
  21934. "idx": 0,
  21935. "sum": 9999,
  21936. "user": {
  21937. "name": key,
  21938. 'selectType': "pinyin_qs",
  21939. "roledata": { rolecode: "incident manager" }
  21940. }
  21941. }).then(function(response) {
  21942. if (response) {
  21943. if (response.status = 200) {
  21944. $scope.auditors = response.list;
  21945. }
  21946. }
  21947. })
  21948. }
  21949. $scope.auditors = [];
  21950. $scope.onChangehandling();
  21951. $scope.onChangeComplexity = function(item){
  21952. if($scope.complexityConfirm.complexity.value == $scope.complexity){
  21953. $scope.complexityConfirm.updateReason = '';
  21954. $scope.complexityConfirm.auditor = null;
  21955. }
  21956. }
  21957. $scope.ok = function () {
  21958. if (!$scope.complexityConfirm.complexity){
  21959. Alert.swal({
  21960. title: "操作失败",
  21961. text: "请选择工时!",
  21962. type: "error"
  21963. });
  21964. return;
  21965. }
  21966. if ($scope.complexityConfirm.complexity.value != $scope.complexity && !$scope.complexityConfirm.auditor){
  21967. Alert.swal({
  21968. title: "操作失败",
  21969. text: "请选择审核人!",
  21970. type: "error"
  21971. });
  21972. return;
  21973. }
  21974. if ($scope.complexityConfirm.complexity.value != $scope.complexity && !$scope.complexityConfirm.updateReason.trim()){
  21975. Alert.swal({
  21976. title: "操作失败",
  21977. text: "请填写升级原因!",
  21978. type: "error"
  21979. });
  21980. return;
  21981. }
  21982. api_wechatfile.getDictionary({"key":"incident_integral_state","type":"list"}).then(function(res){
  21983. // var auditState = $scope.complexityConfirm.complexity.value == $scope.complexity?res.find(v=>v.value == 1):res.find(v=>v.value == 0);
  21984. var auditState = $scope.complexityConfirm.complexity.value != $scope.complexity ? res.find(v=>v.value == 0) : res.find(v=>v.value == 1);
  21985. var postData = {
  21986. incidentIntegral: {
  21987. incidentId:incidentData.id,
  21988. auditState:auditState,
  21989. handlerUser:$rootScope.user.id,
  21990. handlerUserName:$rootScope.user.name,
  21991. sourceScore:$scope.complexity,
  21992. currentScore:$scope.complexityConfirm.complexity.value,
  21993. updateReason:$scope.complexityConfirm.updateReason.trim() || undefined,
  21994. auditUser: $scope.complexityConfirm.auditor ? $scope.complexityConfirm.auditor.id : undefined
  21995. }
  21996. }
  21997. console.log(postData)
  21998. api_bpm_data.addData('incidentIntegral', postData).then(function (response) {
  21999. console.log(response)
  22000. if (response.status == 200) {
  22001. $modalInstance.close('success');
  22002. handlerLogFn();
  22003. } else {
  22004. Alert.swal({
  22005. title: "操作失败",
  22006. text: "操作失败, 请稍后再试!",
  22007. type: "error"
  22008. });
  22009. }
  22010. });
  22011. })
  22012. }
  22013. $scope.cancel = function () {
  22014. scope.ldloading.expand_right = false;
  22015. $modalInstance.dismiss('cancel');
  22016. }
  22017. },
  22018. size: 'sm',
  22019. resolve: {
  22020. scope: function () {
  22021. return $scope;
  22022. },
  22023. api_bpm: function () {
  22024. return api_bpm;
  22025. },
  22026. incidentData: function () {
  22027. return $scope.formData.model.incident;
  22028. },
  22029. currentUserId: function () {
  22030. return loginUser.id;
  22031. },
  22032. Alert: function () {
  22033. return SweetAlert;
  22034. },
  22035. api_user_data: function () {
  22036. return api_user_data;
  22037. },
  22038. api_wechatfile: function () {
  22039. return api_wechatfile;
  22040. }
  22041. }
  22042. });
  22043. }else{
  22044. handlerLogFn();
  22045. }
  22046. function handlerLogFn(){
  22047. //沟通记录
  22048. // 沟通记录不为空并且事件是处理中状态
  22049. if (vm.model.handlerLog && vm.model.handlerLog.trim() && vm.model.incident.state.value == 'handler') {
  22050. api_bpm_data.addData('operationLog', { operationLog: { opType: 'handlerLog', opValue: vm.model.handlerLog, extra1: vm.model.incident.id } }).then(function (result1) {
  22051. baseHandler();
  22052. })
  22053. } else {
  22054. if($stateParams.formUiEdit === 'inspection_LinHu_confirm'){
  22055. //巡检计划
  22056. if(vm.model.inspectionProcessActual.group&&vm.model.inspectionProcessActual.group.id){
  22057. api_bpm.assign({ids:$stateParams.dataId.toString(),userId:$rootScope.user.id}).then(function (response) {
  22058. if (response.status == 200) {
  22059. baseHandler();
  22060. } else {
  22061. Alert.swal({
  22062. title: "操作失败",
  22063. text: "操作失败, 请稍后再试!",
  22064. type: "error"
  22065. });
  22066. }
  22067. });
  22068. }else{
  22069. baseHandler();
  22070. }
  22071. }else{
  22072. baseHandler();
  22073. }
  22074. }
  22075. }
  22076. // return;
  22077. function baseHandler() {
  22078. api_bpm_domain
  22079. .complete($stateParams.taskId, userId, vm.model)
  22080. .then(function (response) {
  22081. if (response) {
  22082. var resData = Restangular.stripRestangular(response);
  22083. SweetAlert.swal(
  22084. {
  22085. title: "提交成功!",
  22086. type: "success",
  22087. confirmButtonColor: "#007AFF",
  22088. },
  22089. function () {
  22090. if (
  22091. $scope.fileUploader != null &&
  22092. $scope.fileUploader.getNotUploadedItems().length >
  22093. 0
  22094. ) {
  22095. console.log(vm);
  22096. if (vm.model.incident) {
  22097. // $scope.fileUploader.onBeforeUploadItem = function (item) {
  22098. // angular.extend(item.headers, $rootScope.getSession());
  22099. // item.url = api_bpm_domain.uploadAttachmentJryModel("incident", vm.model.problem.id, '00000', $rootScope.user.id).getRequestedUrl();
  22100. // item.formData.push({
  22101. // 'fileName': item.file.name
  22102. // });
  22103. // };
  22104. // $scope.fileUploader.uploadAll();
  22105. $scope.fileUploader.onBeforeUploadItem =
  22106. function (item) {
  22107. angular.extend(
  22108. item.headers,
  22109. $rootScope.getSession()
  22110. );
  22111. item.url = api_bpm_domain
  22112. .uploadAttachment(
  22113. vm.model.incident.processInstanceId,
  22114. "00000",
  22115. $rootScope.user.id
  22116. )
  22117. .getRequestedUrl();
  22118. item.formData.push({
  22119. fileName: item.file.name,
  22120. });
  22121. //console.log();
  22122. };
  22123. $scope.fileUploader.uploadAll();
  22124. } else if (vm.model.problem) {
  22125. $scope.fileUploader.onBeforeUploadItem =
  22126. function (item) {
  22127. angular.extend(
  22128. item.headers,
  22129. $rootScope.getSession()
  22130. );
  22131. item.url = api_bpm_domain
  22132. .uploadAttachmentJryModel(
  22133. "problem",
  22134. vm.model.problem.id,
  22135. "00000",
  22136. $rootScope.user.id
  22137. )
  22138. .getRequestedUrl();
  22139. item.formData.push({
  22140. fileName: item.file.name,
  22141. });
  22142. };
  22143. $scope.fileUploader.uploadAll();
  22144. } else if (vm.model.change) {
  22145. }else if(vm.model.inspectionProcessActual){
  22146. //巡检图片上传yeye
  22147. $scope.fileUploader.onBeforeUploadItem =
  22148. function (item) {
  22149. angular.extend(
  22150. item.headers,
  22151. $rootScope.getSession()
  22152. );
  22153. item.url = api_bpm_domain1
  22154. .uploadAttachment(vm.model.inspectionProcessActual.processInstanceId)
  22155. .getRequestedUrl();
  22156. item.formData.push({
  22157. fileName: item.file.name,
  22158. });
  22159. //console.log();
  22160. };
  22161. $scope.fileUploader.uploadAll();
  22162. }
  22163. }
  22164. $state.go($scope.formData.cancelUrl);
  22165. }
  22166. );
  22167. } else {
  22168. SweetAlert.swal({
  22169. title: "系统错误",
  22170. text: "系统错误,请稍后重试!",
  22171. type: "error",
  22172. confirmButtonColor: "#DD6B55",
  22173. });
  22174. }
  22175. $scope.ldloading[style.replace("-", "_")] = false;
  22176. });
  22177. }
  22178. break;
  22179. case "back":
  22180. $state.go($scope.formData.cancelUrl);
  22181. break;
  22182. default:
  22183. $scope.ldloading[style.replace("-", "_")] = false;
  22184. break;
  22185. }
  22186. }
  22187. // var submitFunc = api_bpm_domain[$scope.formData.url]
  22188. // if(anuglar.isFunction(submitFunc)){
  22189. // submitFunc.apply(null, pdKey)
  22190. // }
  22191. }
  22192. }
  22193. } else {
  22194. // console.log(data)
  22195. // angular.forEach(vm.form.$error.required, function(item){
  22196. // var i=(item.$name).substring(item.$name.length-2)
  22197. var i = Number(vm.form.$error.required[0].$name.split("_")[4]);
  22198. // for(var i=0;i<vm.fields.length;i++){
  22199. if (vm.fields[i].name == vm.form.$error.required[0].$name) {
  22200. SweetAlert.swal({
  22201. title: vm.fields[i].templateOptions.label + "未填",
  22202. text: "请填写此项!",
  22203. type: "error",
  22204. confirmButtonColor: "#DD6B55",
  22205. });
  22206. }
  22207. // }
  22208. // angular.forEach(vm.fields,function(f){
  22209. // if(f.name == item.$name){
  22210. // f.validation.show = true;
  22211. // SweetAlert.swal({
  22212. // title: f.templateOptions.label+'未填',
  22213. // text: "请填写此项!",
  22214. // type: "error",
  22215. // confirmButtonColor: "#DD6B55"
  22216. // });
  22217. // }
  22218. // });
  22219. // })
  22220. }
  22221. };
  22222. $scope.vm = vm;
  22223. console.log($stateParams, pdKey, 88888);
  22224. console.log($scope.vm, "assdfsdf");
  22225. if (angular.isDefined($stateParams.taskId) && $stateParams.taskId != "") {
  22226. var processInstanceId = $stateParams.processInstanceId;
  22227. var itemId = $stateParams.dataId;
  22228. console.log($stateParams);
  22229. if (
  22230. angular.isDefined($stateParams.pdKey) &&
  22231. $stateParams.pdKey == "bpm_inspection"
  22232. ) {
  22233. api_configure_form
  22234. .renderForm(
  22235. $stateParams.formUiEdit,
  22236. userId,
  22237. processInstanceId,
  22238. itemId
  22239. )
  22240. .then(function (responseData) {
  22241. if (responseData) {
  22242. //console.log("responseData>>>");//console.log(responseData);
  22243. var vmForm = Restangular.stripRestangular(responseData);
  22244. if (vmForm) {
  22245. //console.log("vmForm>>>");//console.log(vmForm);
  22246. decodeVMForm(vmForm);
  22247. }
  22248. }
  22249. });
  22250. } else if (
  22251. angular.isDefined($stateParams.pdKey) &&
  22252. $stateParams.pdKey == "bpm_service_request"
  22253. ) {
  22254. api_configure_form
  22255. .renderForm($stateParams.formUiEdit, userId, processInstanceId)
  22256. .then(function (responseData) {
  22257. if (responseData) {
  22258. //console.log("responseData>>>");//console.log(responseData);
  22259. var vmForm = Restangular.stripRestangular(responseData);
  22260. if (vmForm) {
  22261. //console.log("vmForm>>>");//console.log(vmForm);
  22262. decodeVMForm(vmForm);
  22263. }
  22264. }
  22265. });
  22266. } else {
  22267. api_bpm_domain
  22268. .taskformkey($stateParams.taskId)
  22269. .then(function (response) {
  22270. if (response) {
  22271. var myData = Restangular.stripRestangular(response); //console.log("myData>>>");console.log(myData);
  22272. api_configure_form
  22273. .renderForm(myData.data, userId, processInstanceId, itemId)
  22274. .then(function (responseData) {
  22275. if (responseData) {
  22276. //console.log("responseData>>>");//console.log(responseData);
  22277. var vmForm = Restangular.stripRestangular(responseData);
  22278. if (vmForm) {
  22279. //console.log("vmForm>>>");//console.log(vmForm);
  22280. decodeVMForm(vmForm);
  22281. console.log(vmForm, 111111);
  22282. // $scope.model.selecthouseNumber = vmForm.model.incident.place;
  22283. console.log($scope, "今天"); //2020年4月24日11:40:55
  22284. }
  22285. }
  22286. });
  22287. }
  22288. });
  22289. }
  22290. } else {
  22291. // create process instance
  22292. if (pdKey != "") {
  22293. //for process
  22294. if (pdKey == "bpm_service_request") {
  22295. api_configure_form
  22296. .renderForm($stateParams.formUiStart, userId)
  22297. .then(function (responseData) {
  22298. if (responseData) {
  22299. var vmForm = Restangular.stripRestangular(responseData);
  22300. if (vmForm) {
  22301. decodeVMForm(vmForm);
  22302. }
  22303. }
  22304. });
  22305. } else {
  22306. api_bpm_domain.startformkey(pdKey).then(function (response) {
  22307. if (response) {
  22308. var myData = Restangular.stripRestangular(response);
  22309. //myData.data = "arrangeform";
  22310. api_configure_form
  22311. .renderForm(myData.data, userId)
  22312. .then(function (responseData) {
  22313. if (responseData) {
  22314. var vmForm = Restangular.stripRestangular(responseData);
  22315. if (vmForm) {
  22316. decodeVMForm(vmForm);
  22317. }
  22318. }
  22319. });
  22320. }
  22321. });
  22322. }
  22323. } else {
  22324. //for form
  22325. //TODO
  22326. //测试数据 开始
  22327. var testJson = {
  22328. fields: [
  22329. {
  22330. fields: [
  22331. {
  22332. className: "col-xs-12",
  22333. noFormControl: true,
  22334. key: "formtitle",
  22335. templateOptions: {
  22336. readOnly: false,
  22337. placeholder: "新建事件单",
  22338. hidden: false,
  22339. label: "事件工单",
  22340. required: false,
  22341. },
  22342. type: "ui-title",
  22343. },
  22344. ],
  22345. },
  22346. {
  22347. fields: [
  22348. {
  22349. key: "selectUser",
  22350. type: "ui-deptinformation",
  22351. className: "col-xs-12",
  22352. templateOptions: {
  22353. label: "请求人信息",
  22354. modalTitle: "请求人列表",
  22355. fetchItems: function (filterData, APIService) {
  22356. return APIService.fetchDataList("requester", filterData);
  22357. },
  22358. Restangular: Restangular,
  22359. ApiService: api_user_data,
  22360. // onClick:function(val, options, field, event , model){
  22361. // console.log(options);
  22362. // }
  22363. },
  22364. },
  22365. ],
  22366. },
  22367. {
  22368. fields: [
  22369. {
  22370. key: "first",
  22371. type: "ui-workernumber",
  22372. className: "col-xs-12",
  22373. templateOptions: {
  22374. type: "input",
  22375. label: "事件单号",
  22376. pkey: "name",
  22377. },
  22378. },
  22379. ],
  22380. },
  22381. {
  22382. fields: [
  22383. {
  22384. type: "ui-header",
  22385. key: "title",
  22386. className: "col-xs-12",
  22387. templateOptions: {
  22388. label: "报修人",
  22389. pkey: "change",
  22390. },
  22391. },
  22392. {
  22393. type: "ui-input",
  22394. key: "title",
  22395. className: "col-xs-4",
  22396. templateOptions: {
  22397. label: "报修人",
  22398. pkey: "change",
  22399. },
  22400. },
  22401. {
  22402. type: "ui-input",
  22403. key: "title",
  22404. className: "col-xs-4",
  22405. templateOptions: {
  22406. label: "联系人",
  22407. pkey: "change",
  22408. },
  22409. },
  22410. {
  22411. type: "ui-input",
  22412. key: "title",
  22413. className: "col-xs-4",
  22414. templateOptions: {
  22415. label: "联系电话",
  22416. pkey: "change",
  22417. },
  22418. },
  22419. ],
  22420. },
  22421. {
  22422. fields: [
  22423. {
  22424. type: "ui-header",
  22425. key: "title1",
  22426. className: "col-xs-12",
  22427. templateOptions: {
  22428. label: "报修人",
  22429. pkey: "change",
  22430. },
  22431. },
  22432. {
  22433. type: "ui-input",
  22434. key: "title2",
  22435. className: "col-xs-4",
  22436. templateOptions: {
  22437. label: "报修人",
  22438. pkey: "change",
  22439. },
  22440. },
  22441. {
  22442. type: "ui-input",
  22443. key: "title3",
  22444. className: "col-xs-4",
  22445. templateOptions: {
  22446. label: "联系人",
  22447. pkey: "change",
  22448. },
  22449. },
  22450. {
  22451. type: "ui-input",
  22452. key: "title4",
  22453. className: "col-xs-4",
  22454. templateOptions: {
  22455. label: "联系电话",
  22456. pkey: "change",
  22457. },
  22458. },
  22459. ],
  22460. },
  22461. ],
  22462. model: [
  22463. {
  22464. username: "robin lau",
  22465. password: "123456",
  22466. chkme: false,
  22467. start_code: 0,
  22468. formtitle: "Hey!I am title value!",
  22469. name: {
  22470. first: "robin",
  22471. last: "lau",
  22472. },
  22473. multiselectItem: [],
  22474. //date:"2015-09-15 00:00:00"
  22475. },
  22476. ],
  22477. // }
  22478. };
  22479. setTimeout(function () {
  22480. decodeVMForm(testJson);
  22481. $scope.$apply();
  22482. }, 500);
  22483. //测试数据结束
  22484. }
  22485. }
  22486. //console.log("end decode");
  22487. },
  22488. ]);