12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485 |
- /**
- ---------------------------------------
- 方法:bsselectdata //列表选择
- 引用:
- <span class="input-group-addon" data-url="../../api/DemandDev/FindSysdata" data-datatext="item.SystemName" data-dataval="item.SystemID" bsselectdata><i class="glyphicon glyphicon-zoom-in"></i></span>
- 参数说明
- data-url:数据源的url地址
- data-datatext:数据选择文字双向绑字段
- data-dataval:数据选择ID双向绑字段
- data-aid:扩展传参数(可空)
- ---------------------------------------
- 方法:flowaudit //流程提交服务
- 引用:
- controller('demandupCtrl', function (flowaudit) {
- flowaudit.startflow({appid: "",uid: "",flowname:"",onstartSuccess:function(rq){}})
- flowaudit.showaudit({pid: "", fid: "", onsuccess: function(){}});
- })
- 1.startflow开启流程实例
- 参数说明:
- appid:流程id
- uid:用户id
- flowname:流程名称用于待办
- onstartSuccess:返回function(rq){}
- rq: data {
- FlowID:流程实例ID,
- ProcessID:流程步骤ID,
- success:提升是否成功
- }
- 2.showaudit提交
- 参数说明:
- pid:环节id
- fid:流程实例id
- onsuccess:成功调用函数
- ---------------------------------------
- 方法:pagination //分页
- 引用:
- <pagination data-pageindex="finddata.pageindex" data-pagesize="finddata.pagesize" data-ptotal="finddata.ptotal"></pagination>
- 参数说明:
- data-pageindex:选择页面
- data-pagesize:页面展示数据条数
- data-ptotal:数据总数
- ---------------------------------------
- 方法:AuthUser //当前人员方法
- 引用:controller('demandlistCtrl', function (AuthUser){
- AuthUser.getUser();
- })
- getUser:获取当前登陆人员信息
- 返回:{人员信息}
- 字段
- DGUserID:用户ID
- Name:用户名
- Mobile:用户手机
- DPID:用户机构ID
- DPName:用户机构名
- DPCode:用户机构代号
- ---------------------------------------
- 方法:userselect //人员选择框
- 引用:
- 多选
- <span data-textids="test1" data-textnames="test2" data-datausers="test3" data-testguids="test4" userselect><i class="glyphicon glyphicon-zoom-in"></i></span>
- 单选
- <span data-textids="test1" data-textnames="test2" data-datausers="test3" data-testguids="test4" data-selecttype="single" userselect><i class="glyphicon glyphicon-zoom-in"></i></span>
- 参数说明
- data-textnames:所选人员的名字拼接字符串双向绑定 例如:"xxx,xxx,xxx"
- data-textids:所选人员的DGUserID拼接字符串双向绑定 例如"xxxxxxx,xxxxxx,xxxxxxx"
- data-textguids:所选人员的UserID拼接字符串双向绑定 例如"xxxxxxxxxx,xxxxxxxxxx,xxxxxxxxxx"
- data-datausers:所选人员的对象双向绑定,若没有使用到该数据,可以在引用的时候设置为 data-datausers="[]"
- data-selecttype:人员选择模式,默认为多选 可选值:single/multi
- data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
- ---------------------------------------
- 指令:bsfiles
- 必要参数:ngModel
- 示例:<bsfiles ng-model="viewdata.reqFileModel" />
- 参数格式:
- {
- selectdata: { FileRefID: '', pageindex: 1, pagesize: 10, ptotal: 0 },//查询参数:FileRefID为文件关联ID
- filetype:1,//文件类型
- items: [],//列表数据地址
- readonly:false,//是否只能查看
- canupfileAsync: function () {
- var deferred = $q.defer();
- if ($scope.item.DemandApplyID == GuidEmpty) {
- $scope.asyncSave().then(function (srq) {
- deferred.resolve($scope.item.DemandApplyID);
- }, function (flasesrq) {
- deferred.reject(flasesrq);
- });
- } else {
- deferred.resolve($scope.item.DemandApplyID);
- }
- return deferred.promise;
- }
- }
- ---------------------------------------
- 指令:bsLvtree
- 引用:<bs_lvtree ng-model="option"></bs_lvtree>
- $scope.option = {
- xAxis: [{ id: 0, name: '系统' }, { id: 1, name: '模块' }, { id: 2, name: '应用' }, { id: 3, name: '功能点' }],
- data: [{ id: 'xx01', xid: 0, pid: null, name: '协同办公平台' }, { id: 'xx11', xid: 1, pid: 'xx01', name: '业务支持中心' }, { id: 'xx12', xid: 1, pid: 'xx01', name: '开发易' }, { id: 'xx111', xid: 2, pid: 'xx11', name: '数据修改' }, { id: 'xx112', xid: 2, pid: 'xx11', name: '数据查询' },
- { id: 'xx1111', xid: 3, pid: 'xx111', name: '工作台' }, { id: 'xx1112', xid: 3, pid: 'xx111', name: '修改申请' }, { id: 'xx1113', xid: 3, pid: 'xx111', name: '查询修改' }
- ],
- canEdit: false,--是否显示编辑按钮
- canChecked: false ---是否显示选择最后一级按钮
- btnclick:function(item,type),type-1:新增同级,2:新增子级,3:删除节点,4:主窗口
- };
- ---------------------------------------
- 指令:sysselect 功能选择控件
- 必要参数:
- textids:选择完成后,返回的ID,格式如"xxx,xxx,xxx"
- texttext:选择完成后,返回对应的名称,格式如"xxx,xxx,xxx"
- selecteditems:选择完成后,返回选择的集合
- 可选参数:
- title:弹出模态框的标题
- selecttype:选择类型,若不填则默认为选择系统。0-选择系统;1-选择模块;2-选择菜单;3-选择功能点
- singlemode:选择模式,若不填则默认为多选模式。 true-单选模式,false-多选模式
- notrelated:是否取消关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true(关联)/fasle(不关联)
- 示例:
- 1:
- <button sysselect data-title="菜单选择" data-notrelated="true" data-textids="selectids" data-textnames="selectnames" data-selecteditems="selecteditems" data-selecttype="3">测试</button>
- 2:
- <label class="input-group">
- <input ng-model="sysselect.names" disabled/>
- <button sysselect data-title="菜单选择" data-textids="selectids" data-textnames="selectnames" data-selecteditems="selecteditems" data-singlemode="true" data-selecttype="0">测试按钮</button>
- </label>
- -------------------------------------------------------------------------
- 指令:bsselectdataPro
- 引用:<button dataoptions='param'>
- 参数格式:{
- url:'../../api/home/selectlist',
- title:'测试选择',
- isMulti:false,
- selectData:{dictypekey:'字典关系字',dicvalue:'字典值'},
- columns:{dickey:'字典数',dicvalue:'字典值',dictypekey:'字典关健类型',dictype:'字典类型'},
- selectLabelKey:'dicvalue',
- selectValuekey:'dictionaryid',
- selectedValueData:'id1,id2',
- selectedLabeData:'name1,name2',
- selectParams:{}
- }
- ---------------------------------------------------------------
- 服务$payService支付服务调用
- 方法 1.payShow(model)开始支付。model:{},字段查看yy_payOrder
- 例如:{amt:221.00,payRelID:'xxxxx1',companyID:'8c7d150b-9be7-4a06-a7cb-552a4ddc0ce9',creatorID:$scope.User.Id,commodityName:'测试商品'}
- */
- (function ($ang) {
- 'use strict';
- $ang.module('devself.common', []).factory("AuthUser", function ($window, $rootScope, $timeout, $q, $http) {
- var lstorage = $window.localStorage;
- var authUser = {
- islogin: function () {
- return lstorage["islogin"] == "1";
- },
- setlogin: function () {
- lstorage["islogin"] = "1";
- }, loginout: function () {
- lstorage["islogin"] = "0";
- }
- };
- authUser.getUser = function () {
- var d_user = {
- UserID: lstorage['UserID'],
- LoginID: lstorage['LoginID'],
- UserName: lstorage['UserName'],
- RoleName: lstorage["RoleName"],
- CurrentRoleID: lstorage['CurrentRoleID'],
- FunctionCodes: lstorage['CurrentFunctionCodes']
- };
- return d_user;
- };
- authUser.getExtData = function () {
- return angular.fromJson(lstorage['extData'] == "null" ? "{}" : lstorage['extData']);
- };
- authUser.setExtData = function (a_data) {
- lstorage['extData'] = angular.toJson(a_data);
- };
- authUser.clearExtData = function () {
- lstorage['extData'] = null;
- };
- authUser.setUser = function (d_user) {
- if (d_user) {
- //if ($rootScope.istkcon != 1) {
- // console.info('onservice');
- // var connection = new signalR.HubConnectionBuilder().withUrl("/hubs/token?userID=" + d_user.UserObj.UserID).build();
- // connection.keepAliveIntervalInMilliseconds = 12e4;
- // connection.serverTimeoutInMilliseconds = 6e4 * 60 * 24;
- // connection.on("getToken", function (token) {
- // lstorage['token'] = token;
- // console.info(token);
- // });
- // connection.start();
- //}
- lstorage['UserID'] = d_user.UserObj.UserID;
- lstorage['LoginID'] = d_user.UserObj.LoginID;
- lstorage['UserName'] = d_user.UserObj.UserName;
- lstorage['CurrentRoleID'] = d_user.UserObj.CurrentRoleID;
- lstorage['token'] = d_user.Token;
- console.info(d_user.Token);
- lstorage['tokenTime'] = d_user.TokenTime;
- lstorage['RoleName'] = d_user.UserObj.RoleName;
- if (d_user.UserObj.UserID) {
- authUser.setlogin();
- authUser.loadFunctionCode();
- }
- } else {
- authUser.loginout();
- }
- };
- authUser.loadFunctionCode = function () {
- $http.post('../../api/systemsetting/Account/GetUserFunctionCode', {}).then(function (res) {
- lstorage['CurrentFunctionCodes'] = res.data.Data;
- });
- };
- authUser.clearUser = function () {
- lstorage['UserID'] = null;
- lstorage['LoginID'] = null;
- lstorage['UserName'] = null;
- lstorage['CurrentRoleID'] = null;
- lstorage['token'] = null;
- authUser.loginout();
- authUser.clearExtData();
- };
- authUser.dofunAfterLogin = function () {
- var defer = $q.defer();
- $timeout(function () {
- if (authUser.islogin()) {
- defer.resolve(authUser.getUser());
- }
- }, 1000);
- return defer.promise;
- };
- return authUser;
- }).factory('authInterceptor', function ($q, $window) {
- var lstorage = $window.localStorage;
- return {
- request: function (config) {
- config.headers = config.headers || {};
- if (lstorage['token']) {
- config.headers.authorization = 'Bearer ' + lstorage['token'];
- }
- return config;
- },
- response: function (res) {
- if (res.headers('ServiceToken')) {
- lstorage['token'] = res.headers('ServiceToken');
- }
- return res;
- },
- responseError: function (response) {
- var deferred = $q.defer();
- if (response.status == 401) {
- window.location.href = "/app/main/index.html#!/login";
- deferred.reject(response);
- } else {
- return deferred.reject(response);
- }
- }
- };
- }).directive('functionCode', function (AuthUser) {
- var directiveObject = {
- restrict: 'A',
- link: function (scope, element, attr, controller) {
- if (!AuthUser.getUser().FunctionCodes || AuthUser.getUser().FunctionCodes.split(",").indexOf(attr.functionCode) < 0) {
- element.css("display", "none");
- }
- }
- };
- return directiveObject;
- }).directive('thSelectAll', function () {
- var directiveObject = {
- restrict: 'A',
- template: '<input type="checkbox" ng-click="checkAll()" />',
- scope: {
- datalist: '='
- },
- link: function (scope, element, attr, controller) {
- /* scope.allchecked = false;*/
- var selectAllbox = element.find('input[type="checkbox"]');
- scope.checkAll = function () {
- /*if (scope.allchecked == false) {
- scope.allchecked = true;
- } else {
- scope.allchecked = false;
- }*/
- if (scope.datalist) {
- angular.forEach(scope.datalist, function (val) {
- val.rowChecked = selectAllbox.prop("checked");
- });
- }
- };
- }
- };
- return directiveObject;
- }).directive('bsselectdata', function ($http, $modal) {
- var directiveObject = {
- restrict: 'EAC',
- scope: {
- dataval: '=',
- datatext: '=',
- title: '@'
- },
- link: function (scope, element, attr, controller) {
- if (angular.isDefined(attr['url']) && angular.isDefined(attr['dataval']) && angular.isDefined(attr['datatext'])) {
- var sdModalController = function ($scope) {
- //选择模式,默认单选;单选-single/多选-multi
- //判断是否为多选模式
- $scope.isMulti = attr['selecttype'] == "multi" ? true : false;
- //扩展Array类,通过员工号判断数组中是否存在某元素
- Array.prototype.contains = function (obj) {
- var i = this.length;
- while (i--) {
- if (this[i].val === obj.val) {
- return i;
- }
- }
- return -1;
- };
- $scope.finddata = {
- aid: angular.isDefined(attr['aid']) ? attr['aid'] : '', pageIndex: 1, pageSize: 5, ptotal: 0
- };
- //监视页面的变化
- $scope.$watch("finddata.pageIndex", function (newVal, oldVal) {
- if ($scope.finddata.ptotal > 0) {
- $scope.loadData();
- }
- });
- attr.$observe('aid', function (newValue, oldValue) {
- if (newValue) $scope.finddata.aid = newValue;
- });
- //多选缓存
- $scope.selecttemp = [];
- //多选模式中单击方法
- $scope.selectOne = function (item) {
- if (item.checked && $scope.selecttemp.indexOf(item) < 0) {
- $scope.selecttemp.push(item)
- }
- if (!item.checked) {
- var index = $scope.selecttemp.indexOf(item);
- if (index > -1) {
- $scope.selecttemp.splice(index, 1)
- }
- }
- };
- $scope.data = {
- findkey: '', items: [], radioit: null
- };
- $scope.title = scope.title;
- $scope.selectedData = function () {
- if ($scope.data.radioit) {
- scope.dataval = $scope.data.radioit.val;
- scope.datatext = $scope.data.radioit.label;
- }
- if ($scope.isMulti) {
- var valarr = [];
- var namearr = [];
- angular.forEach($scope.selecttemp, function (item) {
- valarr.push(item.val);
- namearr.push(item.label);
- });
- scope.dataval = valarr.join(",");
- scope.datatext = namearr.join(",");
- }
- $scope.$hide();
- };
- $scope.findData = function () {
- $scope.loadData();
- };
- $scope.search = function () {
- $scope.loadData();
- };
- $scope.loadData = function () {
- $http({
- method: 'Post',
- url: attr['url'],
- data: angular.extend($scope.finddata, { findkey: $scope.data.findkey })
- }).then(function (req) {
- $scope.data.items = req.data.Data.rows;
- $scope.finddata.ptotal = req.data.Data.total;
- //判断是否为多选,若是,则初始化checkbox选择状态
- if ($scope.isMulti) {
- $scope.multiselectFilter($scope.data.Data)
- }
- });
- };
- //初始化checkbox选择状态,主要用于分页后记录已选择的人员
- $scope.multiselectFilter = function (list) {
- angular.forEach(list, function (user) {
- if ($scope.selecttemp.contains(user) >= 0) {
- user.checked = true;
- }
- })
- };
- $scope.loadData();
- };
- sdModalController.$inject = ['$scope'];
- var sdModal = $modal({
- scope: scope,
- controller: sdModalController,
- templateUrl: '../js/template/modal_selectdata.html',
- show: false
- });
- //data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
- if (attr['isNotRelated']) {
- element.on("click", function () {
- sdModal.$promise.then(sdModal.show);
- });
- element.css({ cursor: 'pointer' });
- } else {
- element.parent().on("click", function () {
- sdModal.$promise.then(sdModal.show);
- });
- element.css({ cursor: 'pointer' });
- element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
- }
- }
- }
- };
- return directiveObject;
- }).provider("flowaudit", function () {
- //流程提交参数修改成可以在引用配置下面操作地址,用来解决不同应用调用问题
- var defaults = this.defaults = {
- appid: '', fid: '', pid: '', uid: '',
- flowurl: '../../api/systemsetting/flow/getflownextinfo',
- userurl: '../../api/systemsetting/flow/getflownextusers',
- putnexturl: '../../api/systemsetting/flow/putnextsteps',
- startflowurl: '../../api/systemsetting/flow/startflow',
- todourl: '../../api/systemsetting/flow/todoflowlist',
- };
- this.$get = function ($http, $modal, $alert, $q, $filter) {
- var faudit = {
- onnextsuccess: false,
- afuns: ''
- };
- angular.extend(faudit, defaults);
- faudit.startflow = function (sparams, option) {
- angular.extend(faudit, option);
- faudit.appid = sparams.appid;
- faudit.uid = sparams.uid;
- $http({
- url: faudit.startflowurl,
- method: 'post',
- data: { appId: faudit.appid, formidList: sparams.formidList, flowName: sparams.flowname, workBy: faudit.uid }
- }).then(sparams.onstartSuccess);
- };
- faudit.startflowAsync = function (sparams, option) {
- angular.extend(faudit, option);
- faudit.appid = sparams.appid;
- faudit.uid = sparams.uid;
- var deferred = $q.defer();
- $http({
- url: faudit.startflowurl,
- method: 'post',
- data: { appId: faudit.appid, formidList: sparams.formidList, flowName: sparams.flowname, workBy: faudit.uid }
- }).then(
- function (TureRq) {
- if (TureRq.data.IsSuccess) {
- deferred.resolve(TureRq);
- } else {
- deferred.reject(TureRq);
- }
- }, function (FalseRq) {
- deferred.reject(TureRq);
- }
- );
- return deferred.promise;
- };
-
- var faModalController = function ($scope, $filter, AuthUser) {
- $scope.title = '流程处理';
- $scope.flowdata = { selectedaction: false, flowInfo: {}, flowUsers: [], comment: "" };
-
- $scope.fauditInfo = faudit;
- $scope.loadflow = function () {
- $http({
- method: 'GET',
- url: $scope.fauditInfo.flowurl,
- params: { processId: $scope.fauditInfo.pid[0], afuns: $scope.fauditInfo.afuns }
- }).then(function (rq) {
- if (rq.data.IsSuccess) {
- $scope.flowdata.flowInfo = rq.data.Data;
- //flowtp工作流始终返回null,无法用于判断是否开始节点
- $scope.flowdata.comment = "同意";
- $scope.flowdata.selectedaction = $scope.flowdata.flowInfo.nextactions[0];
- } else {
- $alert({
- title: '消息',
- content: rq.data.Message,
- placement: 'centre',
- type: 'info',
- show: true,
- duration: 3
- });
- }
- });
- };
- $scope.$watch("flowdata.selectedaction", function (newVal, oldVal) {
- if (!$scope.flowdata.selectedaction) {
- return false;
- }
- $scope.flowdata.comment = $scope.fauditInfo.comment || $scope.flowdata.selectedaction.aname;
- if ($scope.flowdata.selectedaction.pusertype == "any") {
- return true;
- }
- $scope.flowdata.comment = $scope.flowdata.selectedaction.aname;
- $scope.flowdata.flowUsers.length = 0;
- $http({
- method: 'GET',
- url: $scope.fauditInfo.userurl,
- params: { processId: $scope.fauditInfo.pid[0], actionId: $scope.flowdata.selectedaction.actionid }
- }).then(function (rq) {
- //赋值时判断当前选中的步骤ID是否为改变值中的步骤ID,防止网络差时错误显示用户列表-hyl
- if (rq.data.IsSuccess && $scope.flowdata.selectedaction.actionid == newVal.actionid) {
- $scope.flowdata.flowUsers = rq.data.Data;
- angular.forEach($scope.flowdata.flowUsers, function (user) {
- user.checked = true;
- });
- } else {
- $alert({
- title: '消息',
- content: rq.data.Message,
- placement: 'top',
- type: 'error',
- show: true,
- duration: 3
- });
- }
- });
- });
- $scope.filterUserchecked = function (val) {
- return val.checked;
- };
- //全选,反选功能
- $scope.isAll = false;
- $scope.temparr = [];
- $scope.selectAll = function () {
- //判断单选或多选:1为单选,2和其它为多选
- if ($scope.flowdata.selectedaction.userchosemode == 1 && $scope.isAll) {
- $scope.isAll = false;
- $alert({
- title: '提示',
- content: '该环节用户为单选模式!',
- placement: 'top',
- type: 'warning',
- show: true,
- duration: 3
- });
- }
- angular.forEach($scope.flowdata.flowUsers, function (user) {
- user.checked = $scope.isAll;
- });
- };
- $scope.selectOne = function (it) {
- var count = 0;
- angular.forEach($scope.flowdata.flowUsers, function (user) {
- //判断单选或多选:1为单选,2和其它为多选
- if ($scope.flowdata.selectedaction.userchosemode == 1) {
- count = 1;
- if (it != user) user.checked = false;
- } else {
- if (user.checked) count++;
- }
- });
- if (count == 0) $scope.isAll = false;
- if (count == $scope.flowdata.flowUsers.length) $scope.isAll = true;
- };
- //全选,反选功能结束
- $scope.tonextstep = function () {
- var arruser = [];
- if ($scope.flowdata.comment.length == 0) {
- if (!($scope.flowdata.flowInfo.flowtp == 0 || $scope.flowdata.selectedaction.flowtp == 2 || $scope.flowdata.selectedaction.pusertype == 'any')) {
- $alert({
- title: '提示',
- content: '环节意见不能为空!',
- placement: 'top',
- type: 'warning',
- show: true,
- duration: 3
- });
- return;
- }
- }
- angular.forEach($scope.flowdata.flowUsers, function (u) {
- if (u.checked) {
- this.push(u.fuserid);
- }
- }, arruser);
- if (arruser.length == 0 && $scope.flowdata.selectedaction.flowtp != 2 && $scope.flowdata.selectedaction.pusertype != 'any') {
- $alert({
- title: '提示',
- content: '请选择下一步处理人!',
- placement: 'top',
- type: 'warning',
- show: true,
- duration: 3
- });
- return;
- }
- $http({
- method: 'post', url: $scope.fauditInfo.putnexturl,
- data: {
- processIdList: $scope.fauditInfo.pid, actionId: $scope.flowdata.selectedaction.actionid,
- users: arruser.join(','), comment: $scope.flowdata.comment, workby: AuthUser.getUser().UserID,
- nextusertype: $scope.flowdata.selectedaction.pusertype
- }
- }).then(function (rq) {
- $scope.$hide();
- if (rq.data.IsSuccess) {
- $alert({
- title: '成功',
- content: rq.data.Message,
- placement: 'top',
- type: 'success',
- show: true,
- duration: 3
- });
- if (angular.isFunction($scope.fauditInfo.onsuccess)) {
- $scope.fauditInfo.onsuccess();
- }
- }
- else {
- $alert({
- title: '失败',
- content: rq.data.Message,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 15
- });
- }
- });
- };
- $scope.loadflow();
- };
- faModalController.$inject = ['$scope', '$filter', 'AuthUser'];
- var faModal = $modal({
- controller: faModalController, resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- $ocLazyLoad.load('../js/template/modal_flowaudit.css');
- return true;
- }]
- }, templateUrl: '../js/template/modal_flowaudit.html', show: false
- });
- faudit.showaudit = function (option) {
- if (option.pid && option.pid.length > 0) {
- angular.extend(faudit, option);
- faModal.$promise.then(faModal.show);
- } else if (option.fid && option.fid.length > 0) {
- $http({
- method: 'post', url: faudit.todourl,
- data: {
- instanceIDList: option.fid
- }
- }).then(function (rq) {
- if (rq.data.IsSuccess) {
- var todoList = rq.data.Data;
- var isnopid = false;
- angular.forEach(option.fid, function (x) {
- if ($filter('filter')(todoList, function (w) {
- return w.fid == x
- }).length == 0) {
- isnopid = true;
- return false;
- }
- });
- if (isnopid) {
- $alert({
- title: '提示',
- content: '部分记录并没有推送到您的个人待办,无法审核。',
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- return;
- }
- faudit.pid = $.map(todoList, function (x) { return x.pid });
- angular.extend(faudit, option);
- faModal.$promise.then(faModal.show);
- }
- });
- }
- };
- return faudit;
- };
- }).directive('pagination', function () {
- return {
- restrict: 'EA',
- //作用域
- scope: {
- pageindex: '=', //等号是双向绑定 选中页面
- pagesize: '=',//最大页面
- loadPage: '&?',//翻页函数
- ptotal: '=', //数据长度
- mergetotal: '=?' //合并行后显示的总数
- },
- //html
- templateUrl: '../js/template/pagination.html',
- //替换
- replace: true,
- //link函数
- link: function ($scope) {
- $scope.numbers = [10, 30, 50, 100, 300, 500];
- $scope.initpage = function () {
- //分页总数
- $scope.pages = Math.ceil($scope.ptotal / $scope.pagesize); //分页数
- $scope.newPages = $scope.pages > 5 ? 5 : $scope.pages;
- $scope.pageList = [];
- //$scope.pageindex = 1;
- //分页要repeat的数组
- for (var i = 0; i < $scope.newPages; i++) {
- $scope.pageList.push(i + 1);
- }
- };
- //监测total数据数量的变化
- $scope.$watch("ptotal", function (newVal, oldVal) {
- $scope.initpage();
- if ($scope.pageindex > $scope.pages) {
- $scope.selectPage($scope.pages);
- }
- });
- //如果pageindex和pagesize同时监视,那么遇到二维表格,表头和内容就必须都重新加载,会影响翻页的性能,分开监视也可以达到相同效果,但可以绑定不同的查询方法,解决二维表格的问题
- $scope.$watch("pageindex", function (newVal, oldVal) {
- if ($scope.loadPage) {
- $scope.loadPage();
- } else {
- $scope.$parent.search();
- }
- if ($scope.pageindex > $scope.pages) {
- $scope.selectPage($scope.pages);
- }
- });
- $scope.$watch("pagesize", function (newVal, oldVal) {
- if (newVal == oldVal) {
- return;
- }
- $scope.initpage();
- $scope.$parent.search();
- /*var ctrlName = $scope.$parent.panedata.controller;
- $scope.$emit("tabReloadData", { name: ctrlName, data: 1 });*/
- if ($scope.pageindex > $scope.pages) {
- $scope.selectPage($scope.pages);
- }
- });
- //打印当前选中页索引
- $scope.selectPage = function (page) {
- //不能小于1大于最大
- if (page < 1 || page > $scope.pages) return;
- //最多显示分页数5
- if (page > 2) {
- //因为只显示5个页数,大于2页开始分页转换
- var newpageList = [];
- for (var i = (page - 3); i < ((page + 2) > $scope.pages ? $scope.pages : (page + 2)); i++) {
- newpageList.push(i + 1);
- }
- $scope.pageList = newpageList;
- }
- if (page >= 1 && page <= 2) {
- var newpageList = [];
- for (var i = 1; i <= ($scope.pages > 5 ? 5 : $scope.pages); i++) {
- newpageList.push(i);
- }
- $scope.pageList = newpageList;
- }
- $scope.pageindex = page;
- //$scope.isActivePage();
- //console.log("选择的页:" + page);
- };
- //设置当前选中页样式
- $scope.isActivePage = function (page) {
- return $scope.pageindex == page;
- };
- //第一页
- $scope.PreviousFirst = function () {
- if ($scope.pageindex == 1) {
- return false;
- } else {
- $scope.selectPage(1);
- }
- };
- //上一页
- $scope.Previous = function () {
- $scope.selectPage($scope.pageindex - 1);
- };
- //下一页
- $scope.Next = function () {
- $scope.selectPage($scope.pageindex + 1);
- };
- //最后一页
- $scope.NextLast = function () {
- $scope.selectPage($scope.pages);
- };
- //跳转
- $scope.skipPage = function (skipPageNumber) {
- var reg = /^[0-9]+$/;
- var r = reg.test(skipPageNumber);
- if (!isNaN(skipPageNumber) && r) {
- if (skipPageNumber <= $scope.pages) {
- $scope.skipError = true;
- $scope.selectPage(skipPageNumber);
- } else {
- $scope.skipError = false;
- alert("填入页数不能大于" + $scope.pages);
- }
- } else {
- $scope.skipError = true;
- alert("输入非法,请输入正确的页数");
- }
- }
- }
- }
- }).directive('titlemenu', function ($state, $http, $bsRouterState) {
- return {
- restrict: 'EA',
- //作用域
- scope: {
- parentno: '=' //父级no
- },
- //html
- templateUrl: '../js/template/title-menu.html',
- //替换
- replace: true,
- transclude: true,
- //link函数
- link: function (scope, element, attrs, controllers) {
- var inTab = $bsRouterState.$getRouteType() == 'tab';
- var menuno = inTab ? scope.$parent.name : $state.current.name;
- $http.post('../../api/menumanage/FindMenus', {
- menuno: menuno,
- parentNo: scope.parentno == undefined ? "" : scope.parentno
- }).then(function (rq) {
- scope.items = [];
- for (var i = rq.data.item.length - 1; i >= 0; i--) {
- scope.items.push(rq.data.item[i]);
- }
- });
- scope.back = function () {
- if (!inTab) {
- history.go(-1);
- }
- };
- scope.goto = function (menuno) {
- if (!inTab) {
- if (menuno.indexOf("home") > -1 || menuno.indexOf("homeE") > -1)
- $state.go(menuno);
- }
- }
- }
- }
- }).directive("bsflowstep", function ($http) {
- return {
- restrict: 'EA',
- //作用域
- scope: {
- fid: '='//数据长度
- },
- //html
- templateUrl: '../js/template/t_flowstep.html',
- //替换
- replace: true,
- //link函数
- link: function (scope, element, attr, controller) {
- if (angular.isDefined(scope.fid)) {
- var url = attr['url'] || '../../api/systemsetting/flow/getflowsteps';
- $http({ url: url, method: 'GET', params: { flowId: scope.fid } }).then(function (rq) {
- if (rq.data.IsSuccess) {
- scope.items = rq.data.Data;
- }
- });
- }
- }
- }
- }).directive('userselect', function ($http, $modal, $alert, AuthUser) {
- var directiveObject = {
- restrict: 'EAC',
- scope: {
- textids: '=',//已选择的人员ID
- textnames: '=',//已选择的人员
- textguids: '=',//已选择的人员guid
- datausers: '=',//已选人员对象
- },
- link: function (scope, element, attr, controller) {
- //判断绑定的变量是否已定义
- if (angular.isDefined(attr['textids']) && angular.isDefined(attr['textnames'])) {
- var usModalController = function ($scope) {
- //将参数传递的方式改成form
- $scope.postCfg = {
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data) {
- return $.param(data);
- }
- };
- $scope.title = '人员选择';
- $scope.rootDPID = "";
- $scope.selectdzzdm = AuthUser.getUser().gddwdm;//当前选中的组织机构
- $scope.$watch("selectdzzdm", function (newVal, oldVal) {
- $scope.clickDep();
- });
- //人员列表
- $scope.userSelectList = [];
- //部门列表
- $scope.depList = [];
- //选择模式,默认多选;单选/多选
- $scope.selecttype = attr['selecttype'] == "single" ? attr['selecttype'] : "multi";
- //如果datausers没有定义,赋值个空数组
- if (angular.isUndefined(scope.datausers)) {
- scope.datausers = [];
- }
- //待添加人员列表
- $scope.tempAdd = [];
- //拷贝对象,单次赋值给右边已选列表
- $scope.rightusers = angular.copy(scope.datausers);
- //确定选择按钮,统计所选择的人员,按照"xxxx,xxxx,xxxx"模板拼接
- $scope.selectedData = function () {
- var isFirst = true;
- scope.textnames = "";
- scope.textguids = "";
- scope.textids = "";
- angular.forEach($scope.rightusers, function (item) {
- if (isFirst) {
- scope.textnames = item.name;
- scope.textids = item.dguserid;
- scope.textguids = item.id;
- isFirst = false;
- } else {
- scope.textnames += ',' + item.name;
- scope.textids += ',' + item.dguserid;
- scope.textguids += ',' + item.id;
- }
- });
- scope.datausers = $scope.rightusers;
- $scope.$hide();
- };
- //添加已选择的人员
- $scope.addUser = function () {
- var isSingle = $scope.selecttype == "single";//判断是否为单选模式
- var isFlag = $scope.tempAdd.length <= 1 && $scope.rightusers.length == 0;//判断已选人数是否小于等于1
- if ((isSingle && isFlag) || !isSingle) {
- angular.forEach($scope.tempAdd, function (item) {
- //准备添加的人员是否在右边列表存在,如果存在,为false,不添加到右侧
- var isAdd = true;
- angular.forEach($scope.rightusers, function (user) {
- if (item.id == user.id) {
- isAdd = false;
- }
- });
- if (isAdd) {
- $scope.rightusers.push(item);
- }
- })
- } else {
- $alert({
- title: '错误:',
- content: '只可选择一名人员!',
- placement: 'center',
- type: 'info',
- container: '#userselect1',
- show: true,
- duration: 3
- });
- }
- };
- //删除已选择的人员
- $scope.deleteUser = function () {
- angular.forEach($scope.tempSelected, function (item) {
- var index = $scope.rightusers.indexOf(item);
- $scope.rightusers.splice(index, 1);
- })
- };
- //人员查询
- $scope.searchUser = function () {
- if (angular.isDefined($scope.searchParam) && $scope.searchParam != "" && $scope.searchParam != null) {
- $scope.loadUser();
- } else {
- $alert({
- title: '消息:',
- content: '请输入要查询的人员名',
- placement: 'center',
- type: 'info',
- container: '#userselect1',
- show: true,
- duration: 3
- });
- return false;
- }
- };
- //点击部门,通过部门ID获取人员列表
- $scope.clickDep = function () {
- $scope.searchParam = "";//查询条件清空
- $scope.loadUser();
- };
- $scope.loadUser = function () {
- $scope.isloading = true;
- $scope.userSelectList = [];
- $http.get("../../api/systemsetting/User/GetUserListByUserName", {
- params: {
- 'userName': $scope.searchParam,
- 'dpId': $scope.selectdzzdm
- }
- }).then(function (result) {
- $scope.userSelectList = result.data.Data;//返回的人员列表赋值给变量userSelectList
- $scope.isloading = false;
- }, function () {
- $alert({
- title: '错误:',
- content: '查询人员列表失败,服务器错误',
- placement: 'center',
- type: 'info',
- container: '#userselect1',
- show: true,
- duration: 3
- });
- });
- };
- };
- usModalController.$inject = ['$scope'];
- var usModal = $modal({
- scope: scope,
- controller: usModalController,
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- $ocLazyLoad.load('../js/template/modal_userselect.css');
- return true;
- }]
- },
- templateUrl: '../js/template/modal_userselect.html',
- show: false,
- animation: 'am-fade-and-slide-top'
- });
- //data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
- if (attr['isNotRelated']) {
- element.on("click", function () {
- usModal.$promise.then(usModal.show);
- });
- element.css({ cursor: 'pointer' });
- } else {
- element.parent().on("click", function () {
- usModal.$promise.then(usModal.show);
- });
- element.css({ cursor: 'pointer' });
- element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
- }
- }
- }
- };
- return directiveObject;
- }).directive('dpselect', function ($http, $modal, $alert) {
- var directiveObject = {
- restrict: 'EAC',
- scope: {
- dpid: '=',//已选择的部门ID
- dpname: '=',//已选择的部门名称
- dpitem: '=',//已选择的部门对象
- },
- link: function (scope, element, attr, controller) {
- //判断绑定的变量是否已定义
- if (angular.isDefined(attr['dpid']) && angular.isDefined(attr['dpname'])) {
- var dpModalController = function ($scope) {
- //将参数传递的方式改成form
- $scope.postCfg = {
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data) {
- return $.param(data);
- }
- };
- $scope.title = '部门选择';
- $scope.rootDPID = "";
- //当前展开的部门
- $scope.curdepid = "";
- //部门列表
- $scope.depList = [];
- $scope.dpitem = {
- selectDp: ""
- };
- $scope.dpresultlist = [];
- //如果datausers没有定义,赋值个空数组
- if (angular.isUndefined(scope.dpitem)) {
- scope.dpitem = null;
- }
- //初始化树列表,获取根节点
- $scope.initTree = function () {
- $http.post("../../api/dsUser/GetDPbyParentDPID", { 'DPID': $scope.rootDPID }, $scope.postCfg).then(function (result) {
- $scope.depList = result.data;
- }, function () {
- $alert({
- title: '错误:',
- content: '获取根节点失败,服务器错误',
- placement: 'center',
- type: 'info',
- container: '#userselect1',
- show: true,
- duration: 3
- });
- });
- };
- //加载子部门节点
- $scope.loadChildDep = function (item) {
- $scope.searchParam = "";//查询条件清空
- if (!item.isExpand)//如果该节点未展开
- {
- item.isExpand = true;
- $scope.getDPByParentID(item);
- } else {
- item.isExpand = false;
- }
- };
- //根据父部门获取子部门列表
- $scope.getDPByParentID = function (item) {
- $http.post("../../api/user/GetDpListByParentID", { 'parentDPID': item.dpid }).then(function (result) {
- item.childDepList = result.data.item;
- }, function () {
- $alert({
- title: '错误:',
- content: '查询子部门列表失败,服务器错误',
- placement: 'center',
- type: 'info',
- container: '#userselect1',
- show: true,
- duration: 3
- });
- });
- };
- $scope.initTree();
- //点击部门
- $scope.clickDep = function (item, $event) {
- if ($scope.curdepid != item.DPID) {
- $scope.searchParam = "";//查询条件清空
- $scope.dpresultlist = [];
- $scope.dpresultlist.push(item);
- $scope.curdepid = item.DPID;
- $scope.selectDP = item;
- }
- };
- //点击选择部门
- $scope.selectedDp = function () {
- if ($scope.selectDP != null) {
- scope.dpid = $scope.selectDP.DPID;
- scope.dpname = $scope.selectDP.DPName;
- scope.dpitem = $scope.selectDP;
- dpModal.$promise.then(dpModal.hide);
- }
- };
- //根据输入字段查询部门
- $scope.searchDP = function () {
- if (angular.isDefined($scope.searchParam) && $scope.searchParam != "" && $scope.searchParam != null) {//查询条件不为空时进行查询
- $scope.isloading = true;
- $scope.dpresultlist = [];
- $http.get("../../api/SysManage/findTargetDPlists", { params: { 'searchParam': $scope.searchParam } }).then(function (result) {
- $scope.dpresultlist = result.data.list;
- $scope.isloading = false;
- }, function () {
- $alert({
- title: '错误:',
- content: '查询部门失败,服务器错误',
- placement: 'center',
- type: 'info',
- show: true,
- duration: 3
- });
- });
- }
- };
- };
- dpModalController.$inject = ['$scope'];
- var dpModal = $modal({
- scope: scope,
- controller: dpModalController,
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- $ocLazyLoad.load('../js/template/modal_userselect.css');
- return true;
- }]
- },
- templateUrl: '../js/template/modal_dpselect.html',
- show: false,
- animation: 'am-fade-and-slide-top'
- });
- //data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
- if (attr['isNotRelated']) {
- element.on("click", function () {
- dpModal.$promise.then(dpModal.show);
- });
- element.css({ cursor: 'pointer' });
- } else {
- element.parent().on("click", function () {
- dpModal.$promise.then(dpModal.show);
- });
- element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
- element.css({ cursor: 'pointer' });
- }
- }
- }
- };
- return directiveObject;
- }).factory("$excel", function ($modal, $http, $window, $alert, $q) {
- var fileObject = {
- configdata: {
- uploadurl: '../../api/common/Common/ImportExcel',
- typeparams: false,//为false则可选择所有文件,限制格式:{types:['jpg','bmp','jpe','jpeg'],errormsg:'图片格式必须为*.jpg,*.bmp,*.jpe,*.jpeg等格式'}
- },
- fModal: {},
- addDefer: {}
- };
- fileObject.init = function (config) {
- //fileObject.configdata
- angular.extend(fileObject.configdata, config);
- };
- fileObject.addFile = function (fileoption) {
- fileObject.addDefer = $q.defer();
- //这里才传值到弹出页面
- if (angular.isDefined(fileoption)) {
- fileObject.fileoption = fileoption;
- }
- if (fileoption.uploadurl != null && fileoption.uploadurl != undefined) {
- fileObject.configdata.uploadurl = fileoption.uploadurl;
- }
- fileObject.fModal.$promise.then(fileObject.fModal.show);
- return fileObject.addDefer.promise;
- };
- fileObject.uploadMethod = function (file, scope, Upload, AuthUser) {
- //fileObject.fileoption.columns.file = file;
- //alert(scope);
- Upload.upload({
- url: fileObject.configdata.uploadurl,
- data: { file: file, columns: JSON.stringify(fileObject.fileoption.columns || []), firstRow: fileObject.fileoption.firstRow || 0, firstColumn: fileObject.fileoption.firstColumn || 0 }
- }).then(function (resp) {
- if (resp.data.success) {
- /*$alert({
- title: '消息',
- content: resp.data.msg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });*/
- //fileObject.loadItems(fileObject.fileoption);
- fileObject.addDefer.resolve(resp.data.item);
- scope.$hide();
- } else {
- fileObject.addDefer.reject(false);
- $alert({
- title: '消息:',
- content: resp.data.msg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 5
- });
- scope.$hide();
- }
- //console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
- }, function (resp) {
- fileObject.addDefer.reject(false);
- $alert({ title: '错误', content: "上传服务器错误!", placement: 'center', type: 'info', show: true, duration: 3 });
- console.log('Error status: ' + resp.status);
- scope.$hide();
- }, function (evt) {
- scope.updata.progressPer = parseInt(100.0 * evt.loaded / evt.total);
- //console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
- });
- };
- fileObject.initupload = function (upload) {
- //fileObject.configdata
- angular.extend(fileObject, upload);
- };
- fileObject.fileModalController = function ($scope, Upload, AuthUser) {
- $scope.filetype = fileObject.fileoption.filetype;
- $scope.updata = { isuping: false, progressPer: 0 };
- $scope.SettingID = "";
- $scope.templateUrl = fileObject.fileoption.templateUrl;
- $scope.submit = function () {
- if ($scope.fileform.file.$valid && $scope.file && $scope.valiFileType()) {
- $scope.updata.isuping = true;
- $scope.upload($scope.file);
- }
- //if ($scope.fileform.file.$error.minHeight) {
- // $alert({ title: '消息', content: "图片高度小于100px", placement: 'center', type: 'info', show: true, duration: 3, container: '#fileaddmodal' });
- //}
- if ($scope.fileform.file.$error.maxSize) {
- $alert({
- title: '消息',
- content: "文件不得大于20MB",
- placement: 'center',
- type: 'info',
- show: true,
- duration: 3,
- container: '#fileaddmodal'
- });
- }
- };
- //验证文件格式,返回布尔类型
- $scope.valiFileType = function () {
- //验证结果标识
- var isFlag = false;
- //如果没定义
- var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
- if ($scope.file != null) {
- var filename = $scope.file.name;
- var loc = filename.lastIndexOf('.');
- var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
- //如果限制了上传文件格式,则进入判断
- if (types) {
- angular.forEach(types, function (item) {
- if (item == filetype) {
- isFlag = true;
- }
- })
- } else {
- isFlag = true;
- }
- }
- //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
- if (!isFlag && $scope.file != null) {
- $scope.file = "";
- $alert({
- title: '消息',
- content: fileObject.fileoption.typeparams.errormsg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3,
- container: '#fileaddmodal'
- });
- }
- return isFlag;
- };
- $scope.upload = function () {
- fileObject.uploadMethod($scope.file, $scope, Upload, AuthUser);
- }
- };
- fileObject.fileModalController.$inject = ['$scope', 'Upload', 'AuthUser'];
- fileObject.fModal = $modal({
- controller: fileObject.fileModalController,
- templateUrl: '../js/template/modal_fileadd.html', show: false,
- placement: 'center', animation: 'am-fade-and-slide-top'
- });
- fileObject.showErrorInfo = function (errorList, stringColumn) {
- fileObject.errorList = errorList;
- fileObject.stringColumn = stringColumn;
- fileObject.eModal.$promise.then(fileObject.eModal.show);
- };
- fileObject.excelModalController = function ($scope, excelPopup) {
- $scope.fdata = { title: '导入失败列表' };
- $scope.fdata.items = fileObject.errorList;
- $scope.fdata.columns = fileObject.fileoption.errorcolumns;
- $scope.fdata.stringColumn = fileObject.stringColumn;
- if (!$scope.fdata.columns) {
- $scope.fdata.columns = fileObject.getErrorColumns(fileObject.fileoption.columns);
- }
- $scope.export = function () {
- excelPopup.export("../../api/common/Common/ImportErrorExport", $scope.fdata, "导入失败记录.xls");
- }
- };
- fileObject.excelModalController.$inject = ['$scope', 'excelPopup'];
- fileObject.eModal = $modal({
- controller: fileObject.excelModalController,
- templateUrl: '../js/template/modal_excelerrorinfo.html', show: false,
- placement: 'center', animation: 'am-fade-and-slide-top'
- });
- fileObject.getErrorColumns = function (columns, errorColumn) {
- var reverseColumns = {};
- for (var key in fileObject.fileoption.columns) {
- reverseColumns[fileObject.fileoption.columns[key]] = key;
- }
- return angular.extend(reverseColumns, (errorColumn ?? { 'Error': '错误明细' }));
- }
- //fileObject.fileModalController.$scope.upload();
- return fileObject;
- }).factory("$bsfiles", function ($modal, $http, $window, $alert, $q) {
- var fileObject = {
- configdata: {
- itemsurl: '../../api/common/File/GetFileList', uploadurl: '../../api/common/File/UploadFile',
- delfileurl: '../../api/common/File/DeleteFile',
- delfileByRefurl: '../../api/common/File/delfileByRefID',
- downFileUrl: '../../api/common/File/DownloadFile',
- showImgUrl: '../../api/common/File/showImg',
- typeparams: false,//为false则可选择所有文件,限制格式:{types:['jpg','bmp','jpe','jpeg'],errormsg:'图片格式必须为*.jpg,*.bmp,*.jpe,*.jpeg等格式'}
- },
- fModal: {},
- addDefer: {}
- };
- fileObject.init = function (config) {
- //fileObject.configdata
- angular.extend(fileObject.configdata, config);
- };
- fileObject.loadItems = function (fileoption) {
- if (!angular.isDefined(fileoption)) {
- return false;
- }
- if (angular.isUndefined(fileoption.selectdata.FileRefID) || fileoption.selectdata.FileRefID.length == 0) {
- return false;
- }
- //if (angular.isDefined(fileoption)) {
- // fileObject.fileoption = fileoption;
- //}
- $http({
- url: fileObject.configdata.itemsurl,
- method: 'GET',
- params: fileoption.selectdata
- }).then(function (rq) {
- fileoption.items.splice(0, fileoption.items.length);
- angular.forEach(rq.data.Data.Result.rows, function (val, key) {
- this.push(val);
- }, fileoption.items);
- fileoption.selectdata.ptotal = rq.data.Data.Result.total;
- });
- };
- fileObject.addFile = function (fileoption) {
- fileObject.addDefer = $q.defer();
- //这里才传值到弹出页面
- if (angular.isDefined(fileoption)) {
- fileObject.fileoption = fileoption;
- }
- fileObject.fModal.$promise.then(fileObject.fModal.show);
- return fileObject.addDefer.promise;
- };
- fileObject.delfile = function (fileid, fileoption) {
- if ($window.confirm("是否删除?")) {
- $http({
- url: fileObject.configdata.delfileurl,
- method: 'GET',
- params: { fileId: fileid }
- }).then(function (rq) {
- if (rq.data.IsSuccess) {
- fileObject.loadItems(fileoption);
- }
- $alert({
- title: '消息',
- content: rq.data.IsSuccess ? "删除成功" : rq.data.Message,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- });
- }
- };
- fileObject.delfileByRefID = function (noDeleteFileId, filerefid, fileoption) {
- $http({
- url: fileObject.configdata.delfileByRefurl,
- method: 'GET',
- params: { noDeleteFileId: noDeleteFileId, fileRefId: filerefid, fileType: fileoption.filetype }
- }).then(function (rq) {
- if (rq.data.IsSuccess) {
- fileObject.loadItems(fileoption);
- }
- });
- };
- fileObject.uploadMethod = function (file, scope, Upload, AuthUser) {
- Upload.upload({
- url: fileObject.configdata.uploadurl,
- data: { file: file, 'fileRefId': scope.refid, fileType: scope.filetype, uid: AuthUser.getUser().UserID }
- }).then(function (resp) {
- if (resp.data.success) {
- $alert({
- title: '消息',
- content: resp.data.msg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- //fileObject.loadItems(fileObject.fileoption);
- fileObject.addDefer.resolve(resp.data.item);
- scope.$hide();
- } else {
- fileObject.addDefer.reject(false);
- $alert({
- title: '消息',
- content: resp.data.msg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- fileObject.loadItems(fileObject.fileoption);
- scope.$hide();
- }
- //console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
- }, function (resp) {
- fileObject.addDefer.reject(false);
- $alert({ title: '错误', content: "上传服务器错误!", placement: 'center', type: 'info', show: true, duration: 3 });
- console.log('Error status: ' + resp.status);
- scope.$hide();
- }, function (evt) {
- scope.updata.progressPer = parseInt(100.0 * evt.loaded / evt.total);
- //console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
- });
- };
- fileObject.initupload = function (upload) {
- //fileObject.configdata
- angular.extend(fileObject, upload);
- };
- fileObject.fileModalController = function ($scope, Upload, AuthUser) {
- $scope.refid = fileObject.fileoption.selectdata.FileRefID;
- $scope.filetype = fileObject.fileoption.filetype;
- $scope.updata = { isuping: false, progressPer: 0 };
- $scope.SettingID = "";
- $scope.multiFile = fileObject.fileoption.multiFile == true;
- var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
- $scope.acceptType = types ? types.map(e => '.' + e).join(',') : '*';
- if (angular.isDefined(fileObject.fileoption.selectdata.SettingID)) {
- //$scope.SettingID = fileObject.fileoption.selectdata.FileRefID.SettingID;
- $scope.SettingID = fileObject.fileoption.selectdata.SettingID;
- }
- $scope.submit = function () {
- if ($scope.fileform.file.$valid && $scope.file && $scope.valiFileType()) {
- if (angular.isDefined(fileObject.fileoption.uploadbefore) && fileObject.fileoption.uploadbefore($scope.file) == false) {
- return;
- }
- $scope.updata.isuping = true;
- $scope.upload($scope.file);
- }
- //if ($scope.fileform.file.$error.minHeight) {
- // $alert({ title: '消息', content: "图片高度小于100px", placement: 'center', type: 'info', show: true, duration: 3, container: '#fileaddmodal' });
- //}
- if ($scope.fileform.file.$error.maxSize) {
- $alert({
- title: '消息',
- content: "文件不得大于20MB",
- placement: 'center',
- type: 'info',
- show: true,
- duration: 3,
- container: '#fileaddmodal'
- });
- }
- };
- //验证文件格式,返回布尔类型
- $scope.valiFileType = function () {
- //验证结果标识
- var isFlag = false;
- //如果没定义
- //var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
- if ($scope.file != null) {
- var a_files = [];
- if (Array.isArray($scope.file)) {
- a_files = $scope.file;
- } else {
- a_files.push($scope.file);
- }
- angular.forEach(a_files, function (a_file) {
- var filename = a_file.name;
- var loc = filename.lastIndexOf('.');
- var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
- //如果限制了上传文件格式,则进入判断
- if (types) {
- angular.forEach(types, function (item) {
- if (item == filetype) {
- isFlag = true;
- }
- })
- } else {
- isFlag = true;
- }
- });
- }
- //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
- if (!isFlag && $scope.file != null) {
- $scope.file = "";
- $alert({
- title: '消息',
- content: fileObject.fileoption.typeparams.errormsg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3,
- container: '#fileaddmodal'
- });
- }
- return isFlag;
- };
- $scope.upload = function () {
- fileObject.uploadMethod($scope.file, $scope, Upload, AuthUser);
- }
- };
- fileObject.fileModalController.$inject = ['$scope', 'Upload', 'AuthUser'];
- fileObject.fModal = $modal({
- controller: fileObject.fileModalController,
- templateUrl: '../js/template/modal_fileadd.html', show: false,
- placement: 'center', animation: 'am-fade-and-slide-top'
- });
- //fileObject.fileModalController.$scope.upload();
- return fileObject;
- }).directive('bsfiles', function ($bsfiles, $window) {
- var directiveObject = {
- restrict: 'EA',
- template: '<ng-include src="ngModel.templateUrl"/>',
- replace: true,
- require: 'ngModel',
- scope: { ngModel: '=' },
- link: function (scope, element, attr, ngmodel) {
- scope.styleConfig = {
- mainStyle: { "padding-top": "10px" },
- mainClass: "list-table-panel",
- titleClass: "list-table-title"
- };
- //添加自定义模板参数
- if (angular.isUndefined(scope.ngModel.templateUrl)) {
- scope.ngModel.templateUrl = '../js/template/filelist.html';
- }
- if (angular.isUndefined(scope.ngModel.downFun)) {
- scope.ngModel.downFun = function (id) {
- $window.open($bsfiles.configdata.downFileUrl + "?fileId=" + id);
- }
- }
- //读取自定义样式配置
- if (scope.ngModel.styles) {
- if (scope.ngModel.styles.padding != null) {
- scope.styleConfig.mainStyle = {
- "padding-top": scope.ngModel.styles.padding.toString() + "px"
- }
- }
- if (scope.ngModel.styles.customerClass) {
- if (scope.ngModel.styles.customerClass.mainClass) {
- scope.styleConfig.mainClass = scope.ngModel.styles.customerClass.mainClass;
- }
- if (scope.ngModel.styles.customerClass.titleClass) {
- scope.styleConfig.titleClass = scope.ngModel.styles.customerClass.titleClass;
- }
- }
- }
- if (scope.ngModel.configdata) {
- $bsfiles.init(scope.ngModel.configdata);
- }
- scope.$watch('ngModel.selectdata.FileRefID', function (newval, oldval) {
- $bsfiles.loadItems(scope.ngModel);
- });
- scope.downfile = function (id) {
- //console.log($bsfiles.configdata.downFileUrl);
- //console.log($bsfiles.configdata.downFileUrl)
- scope.ngModel.downFun(id);
- };
- scope.addFile = function () {
- //判断是否有同步方法
- if (angular.isFunction(scope.ngModel.canupfile)) {
- scope.ngModel.canupfile($bsfiles.addFile);
- } else if (angular.isFunction(scope.ngModel.canupfileAsync)) {
- scope.ngModel.canupfileAsync().then(function (id) {
- scope.ngModel.selectdata.FileRefID = id;
- $bsfiles.addFile(scope.ngModel).then(function (fid) {
- $bsfiles.loadItems(scope.ngModel);
- });
- });
- } else {
- $bsfiles.addFile(scope.ngModel).then(function (fid) {
- $bsfiles.loadItems(scope.ngModel);
- });
- }
- };
- scope.delfile = function (fid) {
- $bsfiles.delfile(fid, scope.ngModel);
- };
- scope.search = function () {
- };
- }
- };
- return directiveObject;
- }).directive('singlefile', function ($state, $http, $bsfiles, $window) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- //作用域
- scope: {
- id: '=', //父级no
- typeparams: '=?',
- isupload: '=?',
- readonly: '=?',
- filetype: '=?',
- uploadbefore: '=?'
- },
- //html
- templateUrl: '../js/template/single-file.html',
- //替换
- replace: true,
- transclude: true,
- //link函数
- link: function (scope, element, attrs, controllers) {
- scope.ngModel = {
- selectdata: { FileRefID: scope.id, pageindex: 1, pagesize: 10, ptotal: 0, fileType: scope.filetype },//查询参数:FileRefID为文件关联ID
- filetype: scope.filetype,//文件类型
- items: [],//列表数据地址
- readonly: scope.readonly,//是否只能查看
- addFileButton: '上传',
- configdata: {
- typeparams: false,
- uploadurl: '../../api/common/File/UploadFile',
- },
- uploadbefore: scope.uploadbefore
- };
- if (scope.typeparams != undefined) {
- scope.ngModel.typeparams = scope.typeparams;
- }
- if (scope.ngModel.configdata) {
- $bsfiles.init(scope.ngModel.configdata);
- }
- scope.$watch("id", function (newval, oldval) {
- scope.ngModel.selectdata.FileRefID = newval;
- $bsfiles.loadItems(scope.ngModel);
- });
- scope.item = {};
- scope.upload = function () {
- scope.ngModel.selectdata.FileRefID = scope.id;
- $bsfiles.addFile(scope.ngModel).then(function (fid) {
- $bsfiles.delfileByRefID(fid, scope.id, scope.ngModel);
- //$bsfiles.loadItems(scope.ngModel);
- scope.isupload = true;
- });
- }
- scope.downFun = function (id) {
- $window.open($bsfiles.configdata.downFileUrl + "?fileId=" + id);
- }
- scope.delfile = function (id) {
- $bsfiles.delfile(id, scope.ngModel);
- scope.isupload = false;
- }
- }
- }
- }).directive('upfile', function ($bsfiles, $window, $alert, Upload, AuthUser, $http, $modal) {
- var upfileObject = {
- restrict: 'EA',
- templateUrl: '../js/template/upfile.html',
- replace: true,
- require: 'ngModel',
- scope: { ngModel: '=' },
- link: function (scope, element, attr, ngmodel) {
- var fileObject = {
- configdata: {
- itemsurl: '../../api/ICTFileUpLoad/FindFile', uploadurl: '../../api/ICTFileUpLoad/PostFile',
- delfileurl: '../../api/FileUpload/delfile',
- typeparams: false,//为false则可选择所有文件,限制格式:{types:['jpg','bmp','jpe','jpeg'],errormsg:'图片格式必须为*.jpg,*.bmp,*.jpe,*.jpeg等格式'}
- },
- fileoption: scope.ngModel
- };
- scope.$watch('scope.ngModel.selectdata.FileRefID', function (newval, oldval) {
- scope.loadItem(scope.ngModel);
- });
- scope.title = scope.ngModel.title;
- scope.refid = fileObject.fileoption.selectdata.FileRefID;
- scope.filetype = fileObject.fileoption.filetype;
- //文件步骤
- scope.FlowStep = fileObject.fileoption.selectdata.FlowStep;
- //文件的配置ID
- scope.SettingID = fileObject.fileoption.selectdata.SettingID;
- //验证文件格式,返回布尔类型
- //scope.valiFileType = function () {
- // //验证结果标识
- // var isFlag = false;
- // //如果没定义
- // var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
- // if (scope.upfile != null) {
- // var filename = scope.upfile.name;
- // var loc = filename.lastIndexOf('.');
- // var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
- // //如果限制了上传文件格式,则进入判断
- // if (types&&types.length>0) {
- // angular.forEach(types, function (item) {
- // if (item == filetype) {
- // isFlag = true;
- // }
- // })
- // } else {
- // isFlag = true;
- // }
- // }
- // //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
- // if (!isFlag && scope.upfile != null) {
- // scope.upfile = "";
- // $alert({ title: '消息', content: fileObject.fileoption.typeparams.errormsg, placement: 'top', type: 'info', show: true, duration: 3});
- // }
- // return isFlag;
- //}
- //加载文件
- scope.loadItem = function (fileoption) {
- if (!angular.isDefined(fileoption)) {
- return false;
- }
- if (!angular.isDefined(fileoption.selectdata.FileRefID)) {
- return false;
- }
- fileoption.items.splice(0, fileoption.items.length);
- $http({
- url: fileObject.configdata.itemsurl,
- method: 'GET',
- params: {
- FileRefID: fileoption.selectdata.FileRefID,
- SettingID: fileoption.selectdata.SettingID,
- uid: fileObject.fileoption.selectdata.userID
- }
- }).then(function (rq) {
- if (rq.data.total > 0) {
- $("#" + fileoption.selectdata.SettingID).val(rq.data.items.FileName);
- fileObject.fileoption.isUpload = true;
- }
- fileoption.selectdata.ptotal = rq.data.total;
- });
- };
- //上传文件
- //scope.upfilemethod = function (file) {
- // //判断是否有同步方法
- // if (angular.isFunction(scope.ngModel.canupfileAsync)) {
- // scope.ngModel.canupfileAsync().then(function (id) {
- // scope.ngModel.selectdata.FileRefID = id;
- // Upload.upload({
- // url: fileObject.configdata.uploadurl,
- // data: { file: file, 'FileRefID': scope.ngModel.selectdata.FileRefID, uid: AuthUser.getUser().DGUserID, filetype: scope.filetype, SettingID: scope.SettingID }
- // }).then(function (resp) {
- // if (resp.data.success) {
- // $alert({ title: '消息', content: resp.data.msg, placement: 'top', type: 'info', show: true, duration: 3 });
- // fileObject.fileoption.isUpload = true;
- // fileObject.fileoption.updateFlag = !fileObject.fileoption.updateFlag;
- // fileObject.loadItems(fileObject.fileoption);
- // } else {
- // $alert({ title: '消息', content: resp.data.msg, placement: 'top', type: 'info', show: true, duration: 3 });
- // }
- // //console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
- // }, function (resp) {
- // $alert({ title: '错误', content: "上传服务器错误!", placement: 'center', type: 'info', show: true, duration: 3 });
- // console.log('Error status: ' + resp.status);
- // });
- // }, function () {
- // $alert({ title: '消息', content: "请填写完成表格后再上传", placement: 'top', type: 'info', show: true, duration: 3 });
- // });
- // } else {
- // $alert({ title: '消息', content: "无法上传", placement: 'top', type: 'info', show: true, duration: 3 });
- // }
- //};
- //文件上传方法
- scope.uploadMethod = function (file, scopes, Upload, AuthUser) {
- Upload.upload({
- url: fileObject.configdata.uploadurl,
- data: {
- file: file,
- 'FileRefID': fileObject.fileoption.selectdata.FileRefID,
- uid: AuthUser.getUser().DGUserID,
- filetype: fileObject.fileoption.filetype,
- SettingID: fileObject.fileoption.selectdata.SettingID
- }
- }).then(function (resp) {
- if (resp.data.success) {
- $alert({
- title: '消息',
- content: resp.data.msg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- fileObject.fileoption.isUpload = true;
- fileObject.fileoption.updateFlag = !fileObject.fileoption.updateFlag;
- scope.loadItem(fileObject.fileoption);
- scopes.$parent.$hide();
- } else {
- $alert({
- title: '消息',
- content: resp.data.msg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- scopes.$parent.$hide();
- }
- }, function (resp) {
- $alert({
- title: '错误',
- content: "上传服务器错误!",
- placement: 'center',
- type: 'info',
- show: true,
- duration: 3
- });
- console.log('Error status: ' + resp.status);
- scopes.$parent.$hide();
- }, function (evt) {
- scopes.updata.progressPer = parseInt(100.0 * evt.loaded / evt.total);
- });
- };
- //$bsfiles.initupload(scope.upload);
- scope.addFile = function () {
- //判断是否有同步方法
- if (angular.isFunction(scope.ngModel.canupfileAsync)) {
- scope.ngModel.canupfileAsync().then(function (id) {
- scope.ngModel.selectdata.FileRefID = id;
- scope.fModal.$promise.then(scope.fModal.show);
- });
- } else {
- scope.fModal.$promise.then(scope.fModal.show);
- }
- };
- //模态框
- scope.fileModalController = function ($scope, Upload, AuthUser) {
- $scope.refid = fileObject.fileoption.selectdata.FileRefID;
- $scope.filetype = fileObject.fileoption.filetype;
- $scope.updata = { isuping: false, progressPer: 0 };
- $scope.SettingID = "";
- if (angular.isDefined(fileObject.fileoption.selectdata.FileRefID.SettingID)) {
- $scope.SettingID = fileObject.fileoption.selectdata.FileRefID.SettingID;
- }
- $scope.submit = function () {
- if ($scope.fileform.file.$valid && $scope.file && $scope.valiFileType()) {
- $scope.updata.isuping = true;
- $scope.upload($scope.file);
- }
- if ($scope.fileform.file.$error.minHeight) {
- $alert({
- title: '消息',
- content: "图片高度小于100px",
- placement: 'center',
- type: 'info',
- show: true,
- duration: 3,
- container: '#fileaddmodal'
- });
- }
- if ($scope.fileform.file.$error.maxSize) {
- $alert({
- title: '消息',
- content: "文件不得大于20MB",
- placement: 'center',
- type: 'info',
- show: true,
- duration: 3,
- container: '#fileaddmodal'
- });
- }
- };
- //验证文件格式,返回布尔类型
- $scope.valiFileType = function () {
- //验证结果标识
- var isFlag = false;
- //如果没定义
- var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
- if ($scope.file != null) {
- var filename = $scope.file.name;
- var loc = filename.lastIndexOf('.');
- var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
- //如果限制了上传文件格式,则进入判断
- if (types) {
- angular.forEach(types, function (item) {
- if (item == filetype) {
- isFlag = true;
- }
- })
- } else {
- isFlag = true;
- }
- }
- //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
- if (!isFlag && $scope.file != null) {
- $scope.file = "";
- $alert({
- title: '消息',
- content: fileObject.fileoption.typeparams.errormsg,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3,
- container: '#fileaddmodal'
- });
- }
- return isFlag;
- };
- $scope.upload = function () {
- scope.uploadMethod($scope.file, $scope, Upload, AuthUser);
- }
- };
- scope.fileModalController.$inject = ['$scope', 'Upload', 'AuthUser'];
- scope.fModal = $modal({
- controller: scope.fileModalController,
- templateUrl: '../js/template/modal_fileadd.html', show: false,
- placement: 'center', animation: 'am-fade-and-slide-top'
- });
- }
- };
- return upfileObject;
- }).directive('uiKindeditor', function ($ocLazyLoad) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- link: function (scope, element, attrs, ctrl) {
- $ocLazyLoad.load('../../scripts/kindeditor/kindeditor-all-min.js').then(function () {
- var _initContent, editor;
- var fexUE = {
- initEditor: function () {
- editor = KindEditor.create(element[0], {
- width: '90%',
- height: '400px',
- resizeType: 1,
- langType: 'zh-CN',
- uploadJson: '',
- formatUploadUrl: false,
- allowImageUpload: false,
- allowFileManager: false,
- items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
- 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
- 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
- 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
- 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
- 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
- 'anchor', 'link', 'unlink', '|', 'about'],
- afterChange: function () {
- ctrl.$setViewValue(this.html());
- }
- });
- },
- setContent: function (content) {
- if (editor) {
- editor.html(content);
- }
- }
- };
- if (!ctrl) {
- return;
- }
- _initContent = ctrl.$viewValue;
- ctrl.$render = function () {
- _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
- fexUE.setContent(_initContent);
- };
- fexUE.initEditor();
- });
- }
- }
- }).provider('$ueditor', function () {
- var defaults = this.defaults = {
- UEDITOR_HOME_URL: '../../scripts/ueditor/',
- //initialContent: _initContent,
- initialFrameHeight: 400,
- autoHeightEnabled: false,
- autoFloatEnabled: false,
- serverUrl: '',
- wordCount: false,
- maximumWords: 10000000,
- elementPathEnabled: false,
- enableAutoSave: false,
- zIndex: 0,
- toolbars: [[
- 'fullscreen', 'source', '|', 'undo', 'redo', '|',
- 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
- 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
- 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
- 'directionalityltr', 'directionalityrtl', 'indent', '|',
- 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
- 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
- 'simpleupload', 'insertimage', 'emotion', 'scrawl', 'attachment', '|',
- 'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
- 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts'
- ]]
- };
- //var editor=null;
- this.$get = function () {
- var editor = new UE.ui.Editor(defaults);
- return { ue: editor, options: defaults };
- }
- }).directive('uiUeditor', ["$ocLazyLoad", "$compile", "$ueditor", function ($ocLazyLoad, $compile, $ueditor) {
- /* return {
- restrict: 'EA',
- require: '?ngModel',
- link: function (scope, element, attrs, ctrl) {
- //Ueditor富文本框先存代码,以后可能使用
- //$ocLazyLoad.load(['../../scripts/ueditor/ueditor.config.js',
- // '../../scripts/ueditor/ueditor.all.js']).then(function () {
- var _self = this,
- _initContent,
- editor,
- editorReady = false;
- var fexUE = {
- initEditor: function () {
- _self = this;
- if (typeof UE != 'undefined') {
- editor = new UE.ui.Editor($ueditor.options);
- //editor=UE.getEditor(attrs['id'],$ueditor.options);
- editor.render(element[0]);
- editor.ready(function () {
- editorReady = true;
- _self.setContent(_initContent);
- editor.addListener('contentChange', function () {
- scope.$apply(function () {
- ctrl.$setViewValue(editor.getContent());
- });
- });
- });
- }
- },
- setContent: function (content) {
- if (editor && editorReady) {
- editor.setContent(content);
- }
- },
- destroy:function () {
- //element.prev('.edui-default').remove();
- editor.destroy();
- $("[class*='edui-']").remove();
- }
- };
- if (!ctrl) {
- return;
- }
- _initContent = ctrl.$viewValue;
- ctrl.$render = function () {
- _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
- fexUE.setContent(_initContent);
- };
- scope.$on('$destroy',function(){
- fexUE.destroy();
- });
- fexUE.initEditor();
- //});
- }
- };*/
- return {
- restrict: 'EA',
- require: '?ngModel',
- link: function (scope, element, attrs, ctrl) {
- $ocLazyLoad.load('../../scripts/kindeditor/kindeditor-all-min.js').then(function () {
- var _initContent, editor;
- var fexUE = {
- initEditor: function () {
- editor = KindEditor.create(element[0], {
- width: '90%',
- height: '400px',
- resizeType: 1,
- langType: 'zh-CN',
- uploadJson: '',
- formatUploadUrl: false,
- allowImageUpload: true,
- uploadJson: '../../api/systemsetting/Upload/Post',
- allowFileManager: false,
- items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
- 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
- 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
- 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
- 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
- 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
- 'anchor', 'link', 'unlink', '|', 'about'],
- afterChange: function () {
- ctrl.$setViewValue(this.html());
- }
- });
- },
- setContent: function (content) {
- if (editor) {
- editor.html(content);
- }
- }
- };
- if (!ctrl) {
- return;
- }
- _initContent = ctrl.$viewValue;
- ctrl.$render = function () {
- _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
- fexUE.setContent(_initContent);
- };
- fexUE.initEditor();
- });
- }
- }
- }]).filter('showhtmlfilter', function ($sce) {
- return function (html) {
- return $sce.trustAsHtml(html);
- };
- }).filter('yearMonth', function () {
- return function (yearMonth, format) {
- return moment(yearMonth, 'YYYYMM').format(format);
- };
- }).directive('ngIndeterminate', function () {
- return {
- restrict: 'A',
- link: function (scope, element, attr) {
- attr.$observe('ngIndeterminate', function (value) {
- element.prop('indeterminate', value == "true");
- });
- }
- };
- //模态框方式载入loading
- }).factory("$loading", function ($modal) {
- var loadingObject = {};
- loadingObject.loadingModal = $modal({
- templateUrl: '../js/template/modal_loading.html', show: false,
- placement: 'center', animation: '.modal-backdrop.am-fade', backdrop: false
- });
- loadingObject.show = function () {
- loadingObject.loadingModal.$promise.then(loadingObject.loadingModal.show);
- };
- loadingObject.hide = function () {
- loadingObject.loadingModal.$promise.then(loadingObject.loadingModal.hide);
- };
- return loadingObject;
- }).directive('menupanel', function ($http, AuthUser, $state) {
- return {
- restrict: 'EA',
- templateUrl: '../js/template/t_menupanel.html',
- scope: true,
- link: function (scope, element, attr) {
- var menuobject = {
- param: {
- uid: AuthUser.getUser().DGUserID,
- appkey: attr['appkey'],
- defrolekey: attr['defrolekey']
- },
- getMenuUrl: '../../api/user/getmenubyuid'
- };
- scope.panels = [];
- scope.getMenuList = function () {
- $http({
- method: 'post', url: menuobject.getMenuUrl, data: menuobject.param
- }).then(function (result) {
- if (result.data.success) {
- scope.menuList = result.data.item;
- //$state.get('home');若路由不存在,返回null
- //$state.is('home');若路由不存在,返回undifined;
- if (scope.menuList.length > 0) {
- angular.forEach(scope.menuList, function (menu) {
- //如果为父节点
- if (menu.ParentMenuId == null || menu.ParentMenuId == "") {
- var pmenu = { title: menu.MenuName, cNodes: [] };
- //遍历插入子节点
- angular.forEach(scope.menuList, function (cli) {
- //截取路由
- var realstate = scope.sliceStateName(cli.MenuNo);
- //路由是否存在,若存在则为原路由,若不存在,为空
- var isExisted = angular.isDefined($state.is(realstate)) ? cli.MenuNo : '';
- if (cli.ParentMenuId == menu.MenuId) pmenu.cNodes.push({
- title: cli.MenuName,
- name: isExisted
- });
- });
- scope.panels.push(pmenu);
- }
- })
- }
- scope.initActive();
- } else {
- $alert({
- title: '错误:',
- content: result.data.msg,
- placement: 'centre',
- type: 'info',
- show: true,
- duration: 3
- });
- }
- });
- };
- //用于截取路由name,
- //如:home.roleList({appid:"CBFAF886-D757-46B5-A856-763AEEF6D3D3"})---返回home.roleList
- scope.sliceStateName = function (statename) {
- var index = statename.indexOf('(');
- if (index >= 0) {
- return statename.slice(0, index);
- }
- return statename;
- };
- //刷新页面时默认打开一级菜单
- scope.initActive = function () {
- //当前路由name
- var statename = $state.current.name;
- angular.forEach(scope.panels, function (value, index) {
- angular.forEach(value.cNodes, function (item) {
- //去掉参数的路由,如home.roleList({appid:"CBFAF886-D757-46B5-A856-763AEEF6D3D3"}),去参数路由:home.roleList
- var realState = scope.sliceStateName(item.name);
- if (realState == statename) {
- scope.panels.activePanel = index;
- }
- })
- });
- };
- if (angular.isDefined(attr['appkey']) && angular.isDefined(attr['defrolekey'])) {
- scope.getMenuList();
- }
- }
- };
- }).directive('bsLvtree', function ($filter, $timeout, $ocLazyLoad, $compile) {
- //生成树型结构
- var bindtree = function (vtree, model) {
- angular.forEach(vtree, function (val, key) {
- val.children = $filter('filter')(model.data, function (fdata) {
- return fdata.pid == val.id;
- });
- model.treelength++;
- //默认不显示按钮
- val.showbtn = false;
- //查看最后一级
- if (model.xAxis[model.xAxis.length - 1].id == val.xid) {
- val.islast = true;
- } else {
- val.islast = false;
- }
- bindtree(val.children, model);
- });
- };
- var htmlXaxisbind = function (xaxis, $xAxispanel) {
- angular.forEach(xaxis, function (xval) {
- $xAxispanel.append('<div data-id="' + xval.id + '">' + xval.name + '</div>');
- });
- };
- //画中间线
- var drawxAxisLine = function (ctx, xAxis, pheigth) {
- ctx.beginPath();
- ctx.lineWidth = 1;
- ctx.shadowBlur = 0;
- //ctx.setLineDash = [15,5];
- ctx.strokeStyle = '#000000';
- for (var i = 1; i < xAxis.length; i++) {
- ctx.moveTo(250 * i, 0);
- ctx.lineTo(250 * i, pheigth);
- ctx.stroke();
- }
- ctx.closePath();
- };
- //画对象之间的联线
- var drawRectToRectLine = function (ctx, vtreeit) {
- var $it, $cit;
- ctx.lineWidth = 1;
- ctx.shadowBlur = 0;
- ctx.strokeStyle = 'green';
- if (vtreeit.children && vtreeit.children.length > 0) {
- $it = $('.item_panel[data-id="' + vtreeit.id + '"]');
- angular.forEach(vtreeit.children, function (cv, ck) {
- $cit = $('.item_panel[data-id="' + cv.id + '"]');
- ctx.moveTo($it.position().left + $it.width() - 12, $it.position().top + 5);
- ctx.lineTo($cit.position().left + 10, $cit.position().top + 5);
- ctx.stroke();
- drawRectToRectLine(ctx, cv);
- });
- }
- };
- return {
- restrict: 'EA',
- require: '?ngModel',
- templateUrl: '../js/setting/sysduty/lv_tree.html',
- scope: { ngModel: '=' },
- controller: function ($scope) {
- $ocLazyLoad.load('../js/setting/sysduty/sdutyplate.css');
- $scope.ngModel.xAxis = $filter('orderBy')($scope.ngModel.xAxis, '+id') || [{ id: 0, name: '根节点' }];
- $scope.ngModel.treelength = 0;
- $scope.ngModel.treeloadlength = 0;
- //btntype:{1:'新增同级',2:'新增子级',3:'删除节点',4:'查看节点'}
- $scope.btnclick = function (titem, btntype) {
- if ($scope.ngModel.btnclick) {
- $scope.ngModel.btnclick(titem, btntype);
- }
- };
- $scope.loadIncrease = function () {
- $scope.ngModel.treeloadlength++;
- };
- },
- link: function ($scope, $elem, $attrs) {
- //htmlXaxisbind($scope.ngModel.showxAxis, $elem.find('.x_axis_div'));
- //开始添加节点
- //htmltreebind($scope.ngModel.treeNodes, $elem.find('.tree_div'));
- //$compile($elem.find('.tree_div'))($scope);
- $scope.$watch('ngModel.data', function () {
- //第一层节点
- $scope.ngModel.treeNodes = $filter('filter')($scope.ngModel.data, function (val) {
- return val.xid == $scope.ngModel.xAxis[0].id;
- });
- $scope.ngModel.treelength = 0;
- $scope.ngModel.treeloadlength = 0;
- bindtree($scope.ngModel.treeNodes, $scope.ngModel);
- });
- $scope.$watch('ngModel.treeloadlength', function () {
- if ($scope.ngModel.treelength == $scope.ngModel.treeloadlength && $scope.ngModel.treeloadlength > 0) {
- $timeout(function () {
- //开始画图
- var cvs = $elem.find('.dutypanel>canvas')[0];
- cvs.width = $elem.find('.dutypanel').width();
- cvs.height = $elem.find('.dutypanel').height();
- var ctx = cvs.getContext('2d');
- //drawxAxisLine(ctx, $scope.ngModel.xAxis, cvs.height);
- ctx.beginPath();
- angular.forEach($scope.ngModel.treeNodes, function (tn, tk) {
- drawRectToRectLine(ctx, tn);
- });
- ctx.closePath();
- ctx.save();
- }, 200);
- }
- });
- }
- }
- }).directive('sysselect', function ($http, AuthUser, $state, $modal) {
- var directiveObject = {
- restrict: 'EAC',
- scope: {
- textids: '=',//已选择的人员ID
- textnames: '=',//已选择的人员
- selecteditems: '=',//已选对象
- },
- link: function (scope, element, attr, controller) {
- //通过item的id判断该元素是否在arr里
- scope.contains = function (arr, item) {
- var i = arr.length;
- //如果选择系统,通过SystemID去判断
- //如果选择模块,菜单,功能点,通过SysDutyID去判断
- if (attr['selecttype'] == 0) {
- while (i--) {
- if (arr[i].SystemID === item.SystemID) {
- return true;
- }
- }
- } else {
- while (i--) {
- if (arr[i].SysDutyID === item.SysDutyID) {
- return true;
- }
- }
- }
- return false;
- };
- var sysModalController = function ($scope) {
- $scope.title = angular.isDefined(attr['title']) ? attr['title'] : "功能点选择";//模态框标题
- $scope.sysList = [];//系统列表
- $scope.curList = [];//当前选择列表,保存该控件打开时最右边div的那个集合,如selectType=0,则是系统,1则是模块
- $scope.selectedItems = angular.isDefined(scope.selecteditems) ? angular.copy(scope.selecteditems) : [];//已选择对象
- $scope.selectType = angular.isDefined(attr['selecttype']) && attr['selecttype'] > -1 && attr['selecttype'] < 4 ? attr['selecttype'] : 0;//选择类型 0-选择系统;1-选择模块;2-选择菜单;3-选择功能点;
- $scope.singleMode = attr['singlemode'] == "true" ? true : false;//选择模式 true-单选模式,false-多选模式
- //所有请求url
- var urls = {
- GetSysLisUrl: '../../api/SysManage/GetAllSysList',
- GetChildSysDutyListUrl: '../../api/SysDuty/GetChildSysDutyList'
- };
- //系统列表初始化
- $scope.SysListInit = function () {
- $http.post(urls.GetSysLisUrl).then(function (result) {
- $scope.sysList = result.data.list;
- if ($scope.selectType == 0) {
- $scope.curList = angular.copy(result.data.list);//当前需要添加的集合
- }
- }, function () {
- $alert({
- title: '错误:',
- content: '获取系统列表失败,服务器错误',
- placement: 'center',
- type: 'info',
- container: '#sysselect',
- show: true,
- duration: 3
- });
- });
- };
- //模态框样式初始化
- $scope.InitClass = function () {
- $scope.isZero = $scope.selectType == 0 ? true : false;
- $scope.isOne = $scope.selectType == 1 ? true : false;
- $scope.isTwo = $scope.selectType == 2 ? true : false;
- $scope.isThree = $scope.selectType == 3 ? true : false;
- };
- //执行初始化
- $scope.InitClass();
- $scope.SysListInit();
- //移除元素
- $scope.Remove = function (index, arr) {
- arr.splice(index, 1);
- };
- //确认选择
- $scope.Confirm = function () {
- scope.selecteditems = angular.copy($scope.selectedItems);
- scope.textids = "";
- scope.textnames = "";
- $scope.GenerateValue();
- $scope.$hide();
- };
- $scope.GenerateValue = function () {
- var isFirst = true;
- if ($scope.selectType == 0) {
- angular.forEach(scope.selecteditems, function (item) {
- if (isFirst) {
- scope.textnames = item.SystemName;
- scope.textids = item.SystemID;
- isFirst = false;
- } else {
- scope.textnames += "," + item.SystemName;
- scope.textids += "," + item.SystemID;
- }
- });
- } else {
- angular.forEach(scope.selecteditems, function (item) {
- if (isFirst) {
- scope.textnames = item.SysDutyName;
- scope.textids = item.SysDutyID;
- isFirst = false;
- } else {
- scope.textnames += "," + item.SysDutyName;
- scope.textids += "," + item.SysDutyID;
- }
- });
- }
- };
- //changeType为对应改变的下拉类型,0-系统,1-模块,2-菜单
- //arr 选中的值
- //list 当前列表
- $scope.SelectChange = function (changeType, arr, list) {
- //单选模式
- if ($scope.singleMode) {
- if ($scope.selectType == changeType && arr.length > 0) {
- arr.length = 1;
- $scope.selectedItems[0] = arr[0];
- } else if (arr.length > 0) {
- $scope.getSelectList(changeType, arr, list);
- }
- } else {
- //多选模式
- if ($scope.selectType == changeType) {
- $scope.tempSelected = angular.copy(arr);
- } else if (arr.length > 0) {
- $scope.getSelectList(changeType, arr, list);
- }
- }
- };
- //获得系统、模块、菜单、功能集合
- $scope.getSelectList = function (changeType, arr, list) {
- var SystemID = '';
- var PdutyID = '';
- var DutyLv = changeType + 1;
- if (changeType == 0) {
- SystemID = arr[0].SystemID;
- } else {
- PdutyID = arr[0].SysDutyID;
- }
- list.child = [];
- list.child.isloading = true;
- $http.post(urls.GetChildSysDutyListUrl, {
- SystemID: SystemID,
- PdutyID: PdutyID,
- DutyLv: DutyLv
- }).then(function (result) {
- list.child.isloading = false;
- arr.length = 1;
- //如果当前获取的列表为该选择模式需要的列表,则将次返回数据复制给curList
- if (DutyLv == $scope.selectType) {
- $scope.curList = angular.copy(result.data.list);//当前需要添加的集合
- } else {
- $scope.curList.length = 0;
- }
- list.child = result.data.list;
- }, function (result) {
- list.child.isloading = false;
- $alert({
- title: '错误:',
- content: '获列表失败,服务器错误',
- placement: 'center',
- type: 'info',
- container: '#sysselect',
- show: true,
- duration: 3
- });
- })
- };
- //添加到已选
- $scope.Add = function (type) {
- if (type == 0) {
- angular.forEach($scope.tempSelected, function (item) {
- if (scope.contains($scope.selectedItems, item) == false) {
- this.push(item);
- }
- }, $scope.selectedItems)
- } else {
- angular.forEach($scope.curList, function (item) {
- if (scope.contains($scope.selectedItems, item) == false) {
- this.push(item);
- }
- }, $scope.selectedItems)
- }
- };
- $scope.Delete = function () {
- $scope.selectedItems.length = [];
- }
- };
- sysModalController.$inject = ['$scope'];
- //模态框实例
- var sysModal = $modal({
- scope: scope,
- controller: sysModalController,
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- $ocLazyLoad.load('../js/template/modal_sysselect.css');
- return true;
- }]
- },
- templateUrl: '../js/template/modal_sysselect.html',
- show: false,
- animation: 'am-fade-and-slide-top'
- });
- //data-notrelated:是否取消关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true(关联)/fasle(不关联)
- if (attr['notrelated']) {
- element.on("click", function () {
- sysModal.$promise.then(sysModal.show);
- });
- element.css({ cursor: 'pointer' });
- } else {
- element.parent().on("click", function () {
- sysModal.$promise.then(sysModal.show);
- });
- element.css({ cursor: 'pointer' });
- element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
- }
- }
- };
- return directiveObject;
- }).directive('bsselectdataPro', function ($http, $modal, $filter) {
- var directiveObject = {
- restrict: 'EAC',
- scope: {
- dataoptions: '='
- },
- link: function (scope, element, attr, controller) {
- var sdModal = {}, selectHtml = '';
- /*
- angular.extend(scope.dataoptions,{
- isMulti:true,
- selectedLabeData:'',
- selectedValueData:'',
- selectedJData:[]
- });*/
- if (!scope.dataoptions.selectedJData) {
- scope.dataoptions.selectedJData = [];
- }
- scope.init = function () {
- scope.dataoptions.selectedJData = [];
- if (!scope.dataoptions.selectParams) {
- scope.dataoptions.selectParams = {};
- }
- if (scope.dataoptions.selectedValueData && scope.dataoptions.selectedValueData.length > 0) {
- var valueArray = scope.dataoptions.selectedValueData.split(',');
- var labelArray = scope.dataoptions.selectedLabeData.split(',');
- angular.forEach(valueArray, function (val, key) {
- var it = {};
- it[scope.dataoptions.selectValuekey] = val;
- it[scope.dataoptions.selectLabelKey] = labelArray[key];
- scope.dataoptions.selectedJData.push(it);
- });
- }
- };
- var sdModalController = function ($scope) {
- $scope.fdata = {
- selectParams: scope.dataoptions.selectParams,
- selectCols: [],
- columns: scope.dataoptions.columns,
- columnsFormatting: scope.dataoptions.columnsFormatting,
- items: [],
- ptotal: 0,
- title: scope.dataoptions.title,
- width: scope.dataoptions.width == null ? 70 : scope.dataoptions.width,
- selectedJData: scope.dataoptions.selectedJData,
- selectValuekey: scope.dataoptions.selectValuekey,
- selectLabelKey: scope.dataoptions.selectLabelKey,
- selectTemp: [],
- isMulti: scope.dataoptions.isMulti
- };
- //转成查询条件
- angular.extend($scope.fdata.selectParams, {
- pageIndex: 1,
- pageSize: 10
- });
- angular.forEach(scope.dataoptions.selectData, function (value, key) {
- $scope.fdata.selectParams[key] = '';
- $scope.fdata.selectCols.push({ text: value, val: key });
- });
- $scope.loadData = function () {
- $http.post(scope.dataoptions.url, $scope.fdata.selectParams).then(function (value) {
- $scope.fdata.items = value.data.Data.rows;
- $scope.fdata.ptotal = value.data.Data.total;
- });
- };
- $scope.search = function () {
- $scope.loadData();
- };
- $scope.findSData = function () {
- $scope.fdata.selectParams.pageindex = 1;
- $scope.loadData();
- };
- $scope.addItem = function () {
- var tableCheckedArray = $filter('filter')($scope.fdata.items, function (tIt) {
- return tIt.checked;
- });
- angular.forEach(tableCheckedArray, function (value, key) {
- var itemData = $filter('filter')($scope.fdata.selectedJData, function (it) {
- return it[$scope.fdata.selectValuekey] == value[$scope.fdata.selectValuekey];
- });
- if (itemData.length == 0) {
- $scope.fdata.selectedJData.push(value);
- }
- });
- };
- $scope.deleteItem = function (it) {
- var i = -1;
- if (it) {
- i = $scope.fdata.selectedJData.indexOf(it);
- $scope.fdata.selectedJData.splice(i, 1);
- } else {
- angular.forEach($scope.fdata.selectTemp, function (value, key) {
- i = $scope.fdata.selectedJData.indexOf(value);
- $scope.fdata.selectedJData.splice(i, 1);
- });
- }
- };
- /* $scope.$watch("fdata.selectParams.pageindex", function (newVal) {
- if ($scope.fdata.ptotal > 0) {
- $scope.loadData();
- }
- });*/
- $scope.selectedData = function () {
- scope.dataoptions.selectedLabeData = '';
- scope.dataoptions.selectedValueData = '';
- var selectItem = null;
- if ($scope.fdata.isMulti) {
- selectItem = [];
- angular.forEach($scope.fdata.selectedJData, function (value, key) {
- if (key > 0) {
- scope.dataoptions.selectedLabeData += ',';
- scope.dataoptions.selectedValueData += ','
- }
- scope.dataoptions.selectedLabeData += value[$scope.fdata.selectLabelKey];
- scope.dataoptions.selectedValueData += value[$scope.fdata.selectValuekey];
- selectItem.push(value);
- });
- } else {
- selectItem = {};
- angular.forEach($scope.fdata.items, function (value, key) {
- if (value.checked == true) {
- scope.dataoptions.selectedLabeData = value[$scope.fdata.selectLabelKey];
- scope.dataoptions.selectedValueData = value[$scope.fdata.selectValuekey];
- selectItem = value;
- }
- });
- }
- if (scope.dataoptions.onSelect != undefined) {
- scope.dataoptions.onSelect(scope.dataoptions.selectedValueData, selectItem);
- }
- $scope.$hide();
- };
- $scope.loadData();
- };
- sdModalController.$inject = ['$scope'];
- var selectCount = 0;
- //动态生成html
- //文本框查询条件
- angular.forEach(scope.dataoptions.selectData, function (value, key) {
- selectCount++;
- if ((selectCount - 1) % 2 == 0) {
- selectHtml += '<div class="row clearfix">';
- }
- selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5 form-control-label">';
- selectHtml += '<label for="' + key + '">' + value + '</label>';
- selectHtml += '</div>';
- selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5"><div class="form-group"><div class="form-line">';
- selectHtml += '<input type="text" class="form-control" ng-model="fdata.selectParams.' + key + '">';
- selectHtml += '</div></div></div>';
- if (selectCount % 2 == 0) {
- selectHtml += '</div>';
- }
- });
- //下拉框查询条件
- angular.forEach(scope.dataoptions.comboxData, function (value, key, item) {
- selectCount++;
- if ((selectCount - 1) % 2 == 0) {
- selectHtml += '<div class="row clearfix">';
- }
-
- selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5 form-control-label">';
- selectHtml += '<label for="' + key + '">' + value.text + '</label>';
- selectHtml += '</div>';
- selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5"><div class="form-group"><div class="form-line">';
- selectHtml += ' <select class="form-control show-tick" ng-model="fdata.selectParams.' + key + '"';
- selectHtml += ' class="form-control" name="selectname"> <option value="" selected>--请选择--</option> ';
- angular.forEach(value.data, function (dic, dicvalue) {
- selectHtml += '<option value="' + dic.valueField + '">' + dic.nameField + '</option> ';
- });
- selectHtml += '</select>';
- selectHtml += '</div></div></div>';
- if (selectCount % 2 == 0) {
- selectHtml += '</div>';
- }
- });
- //日期框查询条件
- angular.forEach(scope.dataoptions.selectDate, function (value, key) {
- selectCount++;
- if ((selectCount - 1) % 2 == 0) {
- selectHtml += '<div class="row clearfix">';
- }
- selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5 form-control-label">';
- selectHtml += '<label for="' + key + '">' + value + '</label>';
- selectHtml += '</div>';
- selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5"><div class="form-group"><div class="form-line">';
- selectHtml += '<input type="text" class="form-control fm-ct-first" ng-change="search()" autocomplete="off" autoclose="true" bs-datepicker data-date-format="yyyy-MM-dd" data-date-type="string" ng-model="fdata.selectParams.' + key + 'StartDate">';
- selectHtml += '<input type="text" class="form-control fm-ct-last" ng-change="search()" autocomplete="off" autoclose="true" bs-datepicker data-date-format="yyyy-MM-dd" data-date-type="string" ng-model="fdata.selectParams.' + key + 'EndDate">';
- selectHtml += '</div></div></div>';
- if (selectCount % 2 == 0) {
- selectHtml += '</div>';
- }
- });
- if (selectCount % 2 != 0) {
- selectHtml += '</div>';
- }
- $http.get("../js/template/modal_selectdatapro.html").then(function (value) {
- var showTemplate = value.data.replace(/\$\$selectdate\$\$/, selectHtml);
- showTemplate = showTemplate.replace(/\$\$itemlabel\$\$/, scope.dataoptions.selectLabelKey);
- sdModal = $modal({
- scope: scope, controller: sdModalController, template: showTemplate, show: false
- });
- });
- element.on('click', function () {
- scope.init();
- sdModal.$promise.then(sdModal.show);
- });
- }
- };
- return directiveObject;
- }).directive('bsDtable', function ($compile) {
- var directiveObject = {
- restrict: 'EAC',
- template: function (tElement, tAttrs) {
- var html = '<table class="table table-bordered tlist">\n';
- html += '<thead>\n';
- html += '<tr>\n';
- html += ' <th ng-if="showcheckbox!=false" style="width:100px;" class="th-checkbox"><input ng-if="ismulti" id="checkAll" class="pull-left filled-in chk-col-cyan" type="checkbox" ng-click="checkAll()" /><label ng-if="ismulti" for="checkAll">全选</label></th><th ng-repeat="cp in dtData.columns">{{cp.text}}</th>\n';
- html += '</tr>\n';
- html += '</thead>\n';
- html += '<tbody data-id="drow">\n';
- html += '</tbody>\n';
- html += '</table>';
- return html;
- },
- scope: {
- datarows: '=',
- datacols: '=',
- datacolsformatting: '=',
- ismulti: '=',
- showcheckbox: '='
- },
- link: function (scope, element, attr, controller) {
- scope.dtData = {
- columns: [],
- trHtml: '',
- showcheckbox: attr.showcheckbox == false ? false : true
- };
- scope.allchecked = false;
- scope.checkAll = function () {
- if (scope.allchecked == false) {
- scope.allchecked = true;
- } else {
- scope.allchecked = false;
- }
- angular.forEach(scope.datarows, function (value, key) {
- value.checked = scope.allchecked;
- });
- };
- scope.checkItem = function (it) {
- //单选
- //if (!scope.ismulti) {
- // angular.forEach(scope.datarows, function (value, key) {
- // value.checked = false;
- // if (it.checked == false && it == value) {
- // value.checked = true;
- // }
- // });
- //}
- angular.forEach(scope.datarows, function (value, key) {
- if (!scope.ismulti) {//单选
- value.checked = false;
- if (it.checked == false && it == value) {
- value.checked = true;
- }
- } else {//多选
- if (it == value) {
- value.checked = !value.checked;
- }
- }
- });
- };
- scope.dtData.trHtml += '<tr ng-repeat="it in datarows" ng-click="checkItem(it)">' +
- '<td ng-if="showcheckbox!=false"><input type="checkbox" id="{{$index}}" class="filled-in chk-col-cyan" ng-model="it.checked" ng-click="checkItem(it)" /><label for="{{$index}}"></label></td>';
- angular.forEach(scope.datacols, function (value, key) {
- scope.formatting = "";
- if (scope.datacolsformatting) {
- scope.datacolsformatting.filter(x => {
- if (x.key == key) {
- scope.formatting = x.val
- }
- });
- }
- if (scope.formatting != "") {
- scope.dtData.trHtml += '<td ng-bind="it.' + key + ' | ' + scope.formatting + '"></td>>';
- scope.formatting = "";
- } else {
- scope.dtData.trHtml += '<td ng-bind="it.' + key + '"></td>>';
- }
- this.push({ text: value, val: key });
- }, scope.dtData.columns);
- scope.dtData.trHtml += '</tr>';
- element.find('tbody[data-id="drow"]').append(scope.dtData.trHtml);
- $compile(element.find('tbody[data-id="drow"]'))(scope);
- }
- };
- return directiveObject;
- }).directive('autoHeight', function ($window, $timeout) {
- return {
- restrict: 'A',
- link: function (scope, element, attrs) {
- $timeout(function () {
- var winowHeight = $window.innerHeight; //获取窗口高度
- var headerHeight = element.offset().top;
- var footerHeight = 10;
- $("body").css("oveflow-y", "hidden");
- element.addClass('outoflow')
- .css('max-height',
- (winowHeight - headerHeight - footerHeight) + 'px');
- }, 1000);
- }
- };
- }).directive('autoHeightFixed', function ($window, $timeout) {
- return {
- restrict: 'A',
- link: function (scope, element, attrs) {
- $timeout(function () {
- var winowHeight = $window.innerHeight; //获取窗口高度
- var headerHeight = element.offset().top;
- var footerHeight = 10;
- $("body").css("oveflow-y", "hidden");
- element
- .css('height',
- (winowHeight - headerHeight - footerHeight) + 'px');
- }, 100);
- }
- };
- })
- /* .directive("fixHeaderTableRows", function ($window,$timeout) {
- return {
- restrict : 'A',
- link : function(scope, element, attrs) {
- var mybody = element.closest('table');
- var header = mybody.prev();
- header.css("position", "relative").css("background-color", "white").css("max-width", "none").css("margin-bottom", "0px");
- mybody.css("max-width", "none").css("width", "auto").css("margin-top", "0px");
- mybody.parent().scroll(function() {
- var scrollTop = $(this).scrollTop();
- header.css("top", scrollTop.toString() + "px");
- header.scrollLeft($(this).scrollLeft());
- });
- if (scope.$last === true) {
- $timeout(function (){
- var firstRow = mybody.children("tbody").children("tr");
- if (firstRow.length > 0) { //一行都没有一般就不会错位
- // header.width(mybody.width());
- var headerList = header.find("tr>th");
- // for (var i = headerList.length - 1; i >= 0; i --) {
- // var width = $($(firstRow[0]).children("td")[i]).width();
- //
- // $(headerList[i]).width(width);
- // }
- var bodyWidth = mybody.width();
- var totalWidth = 0;
- var headerColumnList = header.find("tr>th");
- var widthList = [headerColumnList.length];
- header.width(bodyWidth);
- headerColumnList.each(function(i, v) {
- var bodyColumn = $($(firstRow[firstRow.length - 1]).children("td")[i]);
- var width = bodyColumn.outerWidth();
- var borderWidth = parseInt(bodyColumn.css("border-width"));
-
- $(v).css("width", (width - borderWidth).toString() + "px");
- var nowWidth = $(v).outerWidth();
- if (nowWidth > width) {
- widthList[i] = nowWidth;
- totalWidth += nowWidth;
- } else {
- widthList[i] = width;
- totalWidth += width;
- }
- });
- var headerBorderWidth = parseInt(header.css("border-left-width"));
- header.width(totalWidth);
- mybody.width(totalWidth);
- headerColumnList.each(function(i, v) {
- var borderWidth = parseInt($(v).css("border-left-width"));
- $(v).css("width", (widthList[i] - borderWidth).toString() + "px");
- $($(firstRow[0]).children("td")[i]).css("width", (widthList[i] - borderWidth).toString() + "px");
- });
- }
- }, 1000);
- }
-
- // if (scope.$last === true) {
- // $timeout(function (){
- // var firstRow = mybody.children("tbody").children("tr");
- // if (firstRow.length > 0) { //一行都没有一般就不会错位
- // header.width(mybody.width());
- // var headerList = header.find("tr>th");
- // // for (var i = headerList.length - 1; i >= 0; i --) {
- // // var width = $($(firstRow[0]).children("td")[i]).width();
- // //
- // // $(headerList[i]).width(width);
- // // }
- // header.find("tr>th").each(function (i, v) {
- // var width = $($(firstRow[0]).children("td")[i]).width();
- //
- // $(v).css("width", Math.floor(width).toString() + "px");
- // });
- // }
- // }, 1000);
- // };
- }
- };
- })*/
- .factory('$payService', ['$q', '$rootScope', '$aside', '$alert', function ($q, $rootScope, $aside, $alert) {
- var paySModel = {};
- paySModel.rAside = $aside({
- scope: $rootScope,
- placement: 'right',
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- return $ocLazyLoad.load(['../js/setting/payment/payment.css', '../js/setting/payment/payment.js']);
- }]
- },
- controller: 'payAsideCtrl',
- templateUrl: '../js/setting/payment/pay_aside.html',
- show: false
- });
- paySModel.backAside = $aside({
- scope: $rootScope,
- placement: 'right',
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- return $ocLazyLoad.load(['../js/setting/payment/payment.css', '../js/setting/payment/payment.js']);
- }]
- },
- controller: 'backAsideCtrl',
- templateUrl: '../js/setting/payment/back_aside.html',
- show: false
- });
- paySModel.payShow = function (model) {
- var $defer = $q.defer();
- if (!angular.isNumber(model.amt)) {
- $alert({
- title: '参数错误',
- content: '支付金额必需为数字',
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- return;
- }
- if (angular.isUndefined(model.payRelID)) {
- $alert({
- title: '参数错误',
- content: 'payRelID:关系ID必填!',
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- return;
- }
- if (angular.isUndefined(model.companyID)) {
- $alert({
- title: '参数错误',
- content: 'companyID:公司ID必填!',
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- return;
- }
- if (angular.isUndefined(model.creatorID)) {
- $alert({
- title: '参数错误',
- content: 'creatorID:创建者ID必填!',
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- return;
- }
- $rootScope.payModel = model;
- $rootScope.paydefer$ = $defer;
- paySModel.rAside.$promise.then(paySModel.rAside.show);
- return $defer.promise;
- };
- paySModel.backShow = function (payRelID) {
- var $defer = $q.defer();
- $rootScope.payModel = { payRelID: payRelID };
- paySModel.backAside.$promise.then(paySModel.backAside.show);
- $rootScope.backpaydefer$ = $defer;
- return $defer.promise;
- };
- return paySModel;
- }]).directive("zeroTableTh", ['$timeout', function ($timeout) {
- var f_time = function (element) {
- var $table = element.parents('table');
- var $thead = $table.find('thead');
- var $preTitleTable = $table.prev('table.zero-theader');
- var td_width = [], t_width = 0;
- if ($preTitleTable.length == 0) {
- var $title_table = $('<div class="zero-thead-div"><table class="table table-bordered zero-theader"></table></div>');
- var $divBody = $('<div class="zero-body-div"></div>');
- $table.before($title_table);
- $table.before($divBody);
- $.each($thead.find('th'), function (i, th) {
- td_width.push(th.offsetWidth);
- t_width += th.offsetWidth;
- });
- $thead.appendTo($title_table.find('table'));
- $table.appendTo($divBody);
- $table.addClass('zero-body');
- $.each($thead.find("th"), function (i, th) {
- th.style.width = td_width[i] + "px";
- });
- $.each($table.find('tr:eq(0)>td'), function (i, td) {
- td.style.width = td_width[i] + "px";
- });
- $divBody.height($(window).height() - $table.offset().top);
- $divBody.scroll(function () {
- $title_table.scrollLeft($(this).scrollLeft());
- });
- } else {
- $thead = $table.parent().parent().find('.zero-theader>thead');
- $.each($thead.find('th'), function (i, th) {
- td_width.push(th.offsetWidth);
- });
- $.each($table.find('tr:eq(0)>td'), function (i, td) {
- td.style.width = td_width[i] + "px";
- });
- }
- };
- var directiveObject = {
- restrict: 'AC',
- link: function (scope, element, attr, controller) {
- if (scope.$last === true) {
- $timeout(function () {
- f_time(element);
- }, 100);
- }
- }
- };
- return directiveObject;
- }]).directive("eChart", function ($http, $window, $ocLazyLoad) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- link: function (scope, element, attrs, ctrl) {
- $ocLazyLoad.load('../../scripts/echarts.min.js').then(function () {
- //初始化图表
- var myChart = echarts.init(element[0]);
- //监控option数据变化
- scope.$watch(
- attrs["ecData"],
- function () {
- var option = scope.$eval(attrs.ecData);
- if (angular.isObject(option)) {
- //绘制图表
- myChart.setOption(option);
- }
- },
- true
- );
- scope.getDom = function () {
- return {
- height: element[0].offsetHeight,
- width: element[0].offsetWidth
- };
- };
- //监控图表宽高变化,响应式
- scope.$watch(
- scope.getDom,
- function () {
- // resize echarts图表
- myChart.resize();
- },
- true
- );
- });
- }
- }
- }).directive("partyTreeold", function ($http, $ocLazyLoad, AuthUser, $filter) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- //作用域
- scope: {
- selectdzzdm: '=', //等号是双向绑定,选中的党组织代码
- selectdzzmc: '=', //等号是双向绑定,选中的党组织名称
- height: '=',
- csssrc: '=?',
- showtogglebtn: '=?',
- onlyshowdw: '=?',//显示党委情况,1 组织架构只显示党委,2只显示一级党委(显示一级不能展开下一级)
- zzfbtype: '=?',//组织分部类型20191012
- defaultselected: '=?',//默认选中的党委代码
- isunfold: '=?',//是否展开
- //20190829版本更新,下列参数无效,不需要传
- isshowxz: '=?',//是否加载小组,0不加载,1加载
- parentcode: '=?', //父级
- parentname: '=?',
- dzzdm: '=?', //当前党组织
- dzzmc: '=?',
- userid: '=?'
- //
- },
- templateUrl: '../js/template/modal_partyTreeOld.html',
- link: function (scope, elemnet) {
- scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
- //组织树样式
- if (scope.csssrc) {
- $ocLazyLoad.load(scope.csssrc);
- } else {
- $ocLazyLoad.load('../js/template/modal_partyTree.css');
- }
- if (scope.showtogglebtn == null) {
- scope.showtogglebtn = true;
- }
- scope.isshowtogglebtn = false;
- var $sidebar = null;
- if (scope.showtogglebtn) {
- //sidebar初始化
- /*$sidebar = elemnet.parents('.row').first();
- $sidebar.addClass('pt-sidebar-collapsed-back');
- var sidebarDivs = $sidebar.parent().find('.row>div');
- //sidebarDivs.removeAttr('class');
- sidebarDivs.eq(0).addClass('sidebar1');
- sidebarDivs.eq(1).addClass('content1');
- //$sidebar.find('.icon-name').content('');
- $sidebar.find('.pt-sidebar-icon').click(function () {
- if ($sidebar) {
- if ($sidebar.is('.pt-sidebar-collapsed-back')) {
- $sidebar.removeClass('pt-sidebar-collapsed-back');
- $sidebar.addClass('pt-sidebar-collapsed');
- //$sidebar.find('.icon-name').content('keyboard_arrow_left');
- } else {
- $sidebar.removeClass('pt-sidebar-collapsed');
- $sidebar.addClass('pt-sidebar-collapsed-back');
- //$sidebar.find('.icon-name').content('keyboard_arrow_up');
- }
- }
- });*/
- //sidebar初始化
- $sidebar = elemnet.parents('.dj-list-body').first();
- if (scope.isunfold) {
- $sidebar.addClass('pt-sidebar-collapsed-back');
- } else {
- $sidebar.addClass('pt-sidebar-collapsed');
- }
- var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
- sidebarDivs.eq(0).addClass('sidebar1');
- sidebarDivs.eq(1).addClass('content1');
- }
- scope.$watch("isunfold", function (newVal, oldVal) {
- scope.isshowtogglebtn = newVal;
- if ($sidebar) {
- if (newVal) {
- $sidebar.removeClass('pt-sidebar-collapsed');
- $sidebar.addClass('pt-sidebar-collapsed-back');//展开
- } else {
- $sidebar.removeClass('pt-sidebar-collapsed-back');
- $sidebar.addClass('pt-sidebar-collapsed');//收缩
- }
- }
- });
- //定义组织树数据
- scope.treeList = [];//组织树数据
- scope.zzfbTypeList = [];//组织分类
- scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
- scope.isShowZZFBType = scope.gddwdm == AuthUser.getUser().DataDzzdm && !scope.csssrc;//是否需要显示分类下拉框
- //数据联动-添加分类下拉监视
- scope.$watch("zzfbtype", function (newVal, oldVal) {
- if (newVal != oldVal) {
- scope.treeList.length = 0;
- scope.defaultselected = "";
- scope.loadParentParty();
- }
- });
- //查询父级架构
- scope.loadParentParty = function () {
- var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
- scope.selectdzzdm = dataDzzdm;
- if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
- scope.parentcode = dataDzzdm;
- scope.dzzdm = "";
- scope.selectdzzmc = "全集团党组织";
- } else {
- scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
- scope.dzzdm = dataDzzdm;
- }
- $http
- ({
- method: 'get', url: '../../api/party/getPartyTreeList', params:
- {
- parentCode: scope.parentcode,
- isshowxz: 1,
- dzzdm: scope.dzzdm,
- onlyshow_dw: scope.onlyshowdw,
- zzfbType: scope.zzfbtype
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (node, index) {
- node.P_Code = scope.parentcode;
- list.push(node);
- });
- scope.treeList = list;
- if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].DZZDM == scope.selectdzzdm)) {
- scope.loadChildParty(scope.treeList[0]);
- }
- //默认选中党委
- if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
- var defaultItem = $filter("filter")(list, { DZZDM: scope.defaultselected.substring(0, 12) });
- if (defaultItem.length > 0) {
- scope.loadChildParty(defaultItem[0]);
- }
- }
- });
- };
- //查询子级架构
- scope.loadChildParty = function (item) {
- var CHILDSHOW = item.CHILDSHOW > 0 ? 0 : 1;
- scope.resetActive(item);
- item.CHILDSHOW = CHILDSHOW;
- scope.selectdzzdm = item.DZZDM;
- scope.selectdzzmc = item.DZZMC;
- //onlyshowdw==2 只显示一级党委 不加载下一级
- if (scope.onlyshowdw != 2 && item.CHILDSHOW > 0 && item.CHILDCOUNT > 0) {
- $http
- ({
- method: 'get', url: '../../api/party/getPartyTreeList', params:
- {
- parentCode: item.DZZDM,
- isshowxz: 1,
- onlyshow_dw: scope.onlyshowdw
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (node, index) {
- node.P_Code = item.P_Code + '.' + item.DZZDM;
- list.push(node);
- });
- item.CHILDPARTYS = list;
- //默认选中
- if (item.DZZDM != scope.defaultselected && scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- var defaultItem = $filter("filter")(list, { DZZDM: scope.defaultselected.substring(0, item.DZZDM.length + 3) });
- if (defaultItem.length > 0) {
- scope.loadChildParty(defaultItem[0]);
- }
- }
- });
- }
- };
- //重置选中项
- scope.resetActive = function (model) {
- var codes = model.P_Code.split('.');
- codes.push(model.DZZDM);
- angular.forEach(scope.treeList, function (node, index) {
- var index = $.inArray(node.DZZDM, codes);
- node.CHILDSHOW = index >= 0 ? 1 : 0;
- if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
- scope.resetActive_child(node.CHILDPARTYS, codes);
- }
- });
- };
- scope.resetActive_child = function (list, codes) {
- angular.forEach(list, function (node, index) {
- var index = $.inArray(node.DZZDM, codes);
- node.CHILDSHOW = index >= 0 ? 1 : 0;
- if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
- scope.resetActive_child(node.CHILDPARTYS, codes);
- }
- });
- };
- //获取组织分类数据
- scope.loadZzfbTypeList = function () {
- $http({
- method: 'get',
- url: '../../api/dictionary/getDictionaryListByDicTypeKey',
- params: {
- dicTypeKey: 'zzfb'
- }
- }).then(function (result) {
- scope.zzfbTypeList = result.data;
- }, function (resp) {
- });
- };
- //初始化数据
- scope.loadParentParty();
- scope.loadZzfbTypeList();
- }
- }
- }).directive("partyTree", function ($http, $ocLazyLoad, AuthUser, $filter) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- //作用域
- scope: {
- selectdzzdm: '=', //等号是双向绑定,选中的党组织代码
- selectdzzmc: '=', //等号是双向绑定,选中的党组织名称
- height: '=',
- csssrc: '=?',
- showtogglebtn: '=?',
- onlyshowdw: '=?',//显示党委情况,1 组织架构只显示党委,2只显示一级党委(显示一级不能展开下一级)
- zzfbtype: '=?',//组织分部类型20191012
- defaultselected: '=?',//默认选中的党委代码
- isunfold: '=?',//是否展开
- //20190829版本更新,下列参数无效,不需要传
- isshowxz: '=?',//是否加载小组,0不加载,1加载
- parentcode: '=?', //父级
- parentname: '=?',
- dzzdm: '=?', //当前党组织
- dzzmc: '=?',
- userid: '=?'
- //
- },
- /*templateUrl: '../js/template/modal_partyTree.html',
- link: function (scope, elemnet) {
- scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
-
- //组织树样式
- if (scope.csssrc) {
- $ocLazyLoad.load(scope.csssrc);
- } else {
- $ocLazyLoad.load('../js/template/modal_partyTree.css');
- }
- if (scope.showtogglebtn == null) {
- scope.showtogglebtn = true;
- }
- scope.isshowtogglebtn = false;
- var $sidebar = null;
- if (scope.showtogglebtn) {
- //sidebar初始化
- /!*$sidebar = elemnet.parents('.row').first();
- $sidebar.addClass('pt-sidebar-collapsed-back');
- var sidebarDivs = $sidebar.parent().find('.row>div');
- //sidebarDivs.removeAttr('class');
- sidebarDivs.eq(0).addClass('sidebar1');
- sidebarDivs.eq(1).addClass('content1');
- //$sidebar.find('.icon-name').content('');
- $sidebar.find('.pt-sidebar-icon').click(function () {
- if ($sidebar) {
- if ($sidebar.is('.pt-sidebar-collapsed-back')) {
- $sidebar.removeClass('pt-sidebar-collapsed-back');
- $sidebar.addClass('pt-sidebar-collapsed');
- //$sidebar.find('.icon-name').content('keyboard_arrow_left');
- } else {
- $sidebar.removeClass('pt-sidebar-collapsed');
- $sidebar.addClass('pt-sidebar-collapsed-back');
- //$sidebar.find('.icon-name').content('keyboard_arrow_up');
- }
- }
- });*!/
-
- //sidebar初始化
- $sidebar = elemnet.parents('.dj-list-body').first();
- if (scope.isunfold) {
- $sidebar.addClass('pt-sidebar-collapsed-back');
- } else {
- $sidebar.addClass('pt-sidebar-collapsed');
- }
- var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
- sidebarDivs.eq(0).addClass('sidebar1');
- sidebarDivs.eq(1).addClass('content1');
-
- }
-
- scope.$watch("isunfold", function (newVal, oldVal) {
- scope.isshowtogglebtn = newVal;
- if ($sidebar) {
- if (newVal) {
- $sidebar.removeClass('pt-sidebar-collapsed');
- $sidebar.addClass('pt-sidebar-collapsed-back');//展开
- } else {
- $sidebar.removeClass('pt-sidebar-collapsed-back');
- $sidebar.addClass('pt-sidebar-collapsed');//收缩
- }
- }
- });
-
- //定义组织树数据
- scope.treeList = [];//组织树数据
- scope.zzfbTypeList = [];//组织分类
- scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
- scope.isShowZZFBType = scope.gddwdm == AuthUser.getUser().DataDzzdm && !scope.csssrc;//是否需要显示分类下拉框
- //数据联动-添加分类下拉监视
- scope.$watch("zzfbtype", function (newVal, oldVal) {
- if (newVal != oldVal) {
- scope.treeList.length = 0;
- scope.defaultselected = "";
- scope.loadParentParty();
- }
- });
-
- //查询父级架构
- scope.loadParentParty = function () {
- var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
- scope.selectdzzdm = dataDzzdm;
- if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
- scope.parentcode = dataDzzdm;
- scope.dzzdm = "";
- scope.selectdzzmc = "全集团党组织";
- } else {
- scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
- scope.dzzdm = dataDzzdm;
- }
-
- $http
- ({
- method: 'get', url: '../../api/party/getPartyTreeList', params:
- {
- parentCode: scope.parentcode,
- isshowxz: 1,
- dzzdm: scope.dzzdm,
- onlyshow_dw: scope.onlyshowdw,
- zzfbType: scope.zzfbtype
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (node, index) {
- node.P_Code = scope.parentcode;
- list.push(node);
- });
-
- scope.treeList = list;
-
- if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].DZZDM == scope.selectdzzdm)) {
- scope.loadChildParty(scope.treeList[0]);
- }
-
- //默认选中党委
- if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
- var defaultItem = $filter("filter")(list, {DZZDM: scope.defaultselected.substring(0, 12)});
- if (defaultItem.length > 0) {
- scope.loadChildParty(defaultItem[0]);
- }
-
- }
-
- });
- };
- //查询子级架构
- scope.loadChildParty = function (item) {
- var CHILDSHOW = item.CHILDSHOW > 0 ? 0 : 1;
- scope.resetActive(item);
- item.CHILDSHOW = CHILDSHOW;
- scope.selectdzzdm = item.DZZDM;
- scope.selectdzzmc = item.DZZMC;
- //onlyshowdw==2 只显示一级党委 不加载下一级
- if (scope.onlyshowdw != 2 && item.CHILDSHOW > 0 && item.CHILDCOUNT > 0) {
- $http
- ({
- method: 'get', url: '../../api/party/getPartyTreeList', params:
- {
- parentCode: item.DZZDM,
- isshowxz: 1,
- onlyshow_dw: scope.onlyshowdw
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (node, index) {
- node.P_Code = item.P_Code + '.' + item.DZZDM;
- list.push(node);
- });
- item.CHILDPARTYS = list;
-
- //默认选中
- if (item.DZZDM != scope.defaultselected && scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- var defaultItem = $filter("filter")(list, {DZZDM: scope.defaultselected.substring(0, item.DZZDM.length + 3)});
- if (defaultItem.length > 0) {
- scope.loadChildParty(defaultItem[0]);
- }
-
- }
-
- });
- }
- };
-
- //重置选中项
- scope.resetActive = function (model) {
- var codes = model.P_Code.split('.');
- codes.push(model.DZZDM);
- angular.forEach(scope.treeList, function (node, index) {
- var index = $.inArray(node.DZZDM, codes);
- node.CHILDSHOW = index >= 0 ? 1 : 0;
- if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
- scope.resetActive_child(node.CHILDPARTYS, codes);
- }
- });
- };
- scope.resetActive_child = function (list, codes) {
- angular.forEach(list, function (node, index) {
- var index = $.inArray(node.DZZDM, codes);
- node.CHILDSHOW = index >= 0 ? 1 : 0;
- if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
- scope.resetActive_child(node.CHILDPARTYS, codes);
- }
- });
- };
-
- //获取组织分类数据
- scope.loadZzfbTypeList = function () {
- $http({
- method: 'get',
- url: '../../api/dictionary/getDictionaryListByDicTypeKey',
- params: {
- dicTypeKey: 'zzfb'
- }
- }).then(function (result) {
- scope.zzfbTypeList = result.data;
- }, function (resp) {
-
- });
- };
-
- //初始化数据
- scope.loadParentParty();
- scope.loadZzfbTypeList();
- }*/
- templateUrl: '../js/template/modal_partyTreeNew.html',
- link: function (scope, elemnet) {
- $ocLazyLoad.load('../js/template/modal_partyTree.css');
- scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
- //sidebar初始化
- var $sidebar = null;
- $sidebar = elemnet.parents('.dj-list-body').first();
- if (scope.isunfold) {
- $sidebar.addClass('pt-sidebar-collapsed-back');
- } else {
- $sidebar.addClass('pt-sidebar-collapsed');
- }
- var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
- sidebarDivs.eq(0).addClass('sidebar1');
- sidebarDivs.eq(1).addClass('content1');
- scope.$watch("isunfold", function (newVal, oldVal) {
- scope.isshowtogglebtn = newVal;
- if ($sidebar) {
- if (newVal) {
- $sidebar.removeClass('pt-sidebar-collapsed');
- $sidebar.addClass('pt-sidebar-collapsed-back');//展开
- } else {
- $sidebar.removeClass('pt-sidebar-collapsed-back');
- $sidebar.addClass('pt-sidebar-collapsed');//收缩
- }
- }
- });
- //定义组织树数据
- scope.treeList = [];//组织树数据
- scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
- var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
- var dwdm = "";//党委代码
- scope.selectdzzdm = dataDzzdm;
- if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
- scope.parentcode = dataDzzdm;
- scope.dzzdm = "";
- scope.selectdzzmc = "全集团党组织";
- } else {
- scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
- scope.dzzdm = dataDzzdm;
- dwdm = dataDzzdm.substring(0, 12);
- }
- //获取分组(集团领导)
- scope.loadPartyGroupList = function () {
- $http
- ({
- method: 'get', url: '../../api/party/getPartyGroupTreeList', params:
- { dzzdm: dwdm, onlyshow_dw: scope.onlyshowdw }
- }).then(function (result) {
- scope.treeList = result.data;
- //默认选中党委
- if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- var defaultItem = scope.getPartyNode(scope.treeList);
- if (defaultItem != null) {
- scope.groupClick(defaultItem);
- }
- }
- });
- };
- scope.getPartyNode = function (nodeList) {
- var defaultItem = null;
- for (var i = 0; i < nodeList.length; i++) {
- if (nodeList[i].id == scope.defaultselected.substring(0, 12)) {
- return nodeList[i];
- }
- if (nodeList[i].childs.length > 0) {
- defaultItem = scope.getPartyNode(nodeList[i].childs);
- if (defaultItem != null) {
- return defaultItem;
- }
- }
- }
- };
- //查询上级组织(党员)
- scope.loadParentParty = function () {
- $http
- ({
- method: 'get', url: '../../api/party/getNewPartyTreeList', params:
- {
- parentCode: scope.parentcode,
- isshowxz: 1,
- dzzdm: scope.dzzdm,
- onlyshow_dw: scope.onlyshowdw
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (val, index) {
- val.fullcode = scope.parentcode;
- list.push(val);
- });
- scope.treeList = list;
- if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].id == scope.selectdzzdm)) {
- scope.groupClick(scope.treeList[0]);
- }
- //默认选中党委
- if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
- var defaultItem = $filter("filter")(list, { id: scope.defaultselected.substring(0, 12) });
- if (defaultItem.length > 0) {
- scope.groupClick(defaultItem[0]);
- }
- }
- });
- };
- //查询子级架构
- scope.loadChildParty = function (node) {
- scope.selectdzzdm = node.id;
- scope.selectdzzmc = node.name;
- //onlyshowdw==2 只显示一级党委 不加载下一级
- if (scope.onlyshowdw != 2 && node.isexpand > 0 && node.partyCount > 0) {
- $http
- ({
- method: 'get', url: '../../api/party/getNewPartyTreeList', params:
- {
- parentCode: node.id,
- isshowxz: 1,
- onlyshow_dw: scope.onlyshowdw
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (val, index) {
- val.fullcode = node.fullcode + '.' + node.id;
- list.push(val);
- });
- node.childs = list;
- //默认选中
- if (node.id != scope.defaultselected && scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- var defaultItem = $filter("filter")(list, { id: scope.defaultselected.substring(0, node.id.length + 3) });
- if (defaultItem.length > 0) {
- scope.groupClick(defaultItem[0]);
- }
- }
- });
- }
- };
- //点击节点
- scope.groupClick = function (node) {
- var isexpand = node.isexpand > 0 ? 0 : 1;
- scope.resetActive(node);
- node.isexpand = isexpand;
- if (node.nodetype == 2) {
- scope.loadChildParty(node);
- }
- };
- //重置选中项
- scope.resetActive = function (node) {
- var checkIds = node.fullcode.split('.');
- checkIds.push(node.id);
- angular.forEach(scope.treeList, function (val, index) {
- val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
- if (val.childs != null && val.childs.length > 0) {
- scope.resetActive_child(val.childs, checkIds);
- }
- });
- };
- scope.resetActive_child = function (list, checkIds) {
- angular.forEach(list, function (val, index) {
- val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
- if (val.childs != null && val.childs.length > 0) {
- scope.resetActive_child(val.childs, checkIds);
- }
- });
- };
- if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
- //初始化数据
- scope.loadPartyGroupList();
- } else {
- scope.loadParentParty();
- }
- }
- }
- }).directive("gtCalendar", function ($http, $window, $ocLazyLoad, $timeout) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- link: function (scope, element, attrs, ctrl) {
- $ocLazyLoad.load(['../../scripts/calendar.css', '../../scripts/calendar.js']).then(function () {
- /*$timeout(function () {
- var option = scope.$eval(attrs.cdOption);
- option.height = element[0].offsetWidth - 10;
- option.width = element[0].offsetWidth;
- var myCalendar = $(element[0]).calendar(option);
- //监控option数据变化
- scope.$watch(
- attrs["cdOption"],
- function () {
- var option = scope.$eval(attrs.cdOption);
- if (angular.isObject(option)) {
- //绘制图表
- myCalendar.calendar(option)
- }
- },
- true
- );
- }, 100);
-
- scope.getDom = function () {
- return {
- height: element[0].parentElement.offsetHeight,
- width: element[0].parentElement.offsetWidth
- };
- };
- //监控图表宽高变化,响应式
- scope.$watch(
- scope.getDom,
- function () {
- var option = scope.$eval(attrs.cdOption);
- option.height = element[0].parentElement.offsetWidth - 10;
- option.width = element[0].parentElement.offsetWidth;
- var myCalendar = $(element[0]).calendar(option);
- },
- true
- );*/
- var option = scope.$eval(attrs.cdOption);
- option.height = option.height || (element[0].offsetWidth - 10);
- option.width = option.width || element[0].offsetWidth;
- var myCalendar = $(element[0]).calendar(option);
- //监控option数据变化
- scope.$watch(
- attrs["cdOption"],
- function () {
- var option = scope.$eval(attrs.cdOption);
- if (angular.isObject(option)) {
- //更新数据
- myCalendar.calendar("setData", option.data)
- }
- },
- true
- );
- });
- }
- }
- }).directive('rolePermissionCode', function ($http, AuthUser) {
- var sUrl = '/api/user/UserPermissionStatus';
- return {
- restrict: 'A',
- link: function (scope, element, attrs, ctrl) {
- //attrs['rolePermissionCode']
- element.hide();
- if (scope.PermissionCodeData == null) {
- scope.PermissionCodeData = {};
- }
- if (scope.PermissionCodeData[attrs['rolePermissionCode']] == null) {
- scope.PermissionCodeData[attrs['rolePermissionCode']] = { eles: [element], val: null };
- $http.get(sUrl, { params: { code: attrs['rolePermissionCode'], roleId: AuthUser.getUser().curRoleId } }).then(
- function (res) {
- scope.PermissionCodeData[attrs['rolePermissionCode']].val = res.data.success;
- if (res.data.success) {
- //一起处理显示状态
- $ang.forEach(scope.PermissionCodeData[attrs['rolePermissionCode']].eles, function (el) {
- el.show();
- });
- }
- }, function (rs) {
- }
- );
- } else {
- //网络返回速度慢过js执行数时,保存在列表上,等返回再一起处理显示状态。
- scope.PermissionCodeData[attrs['rolePermissionCode']].eles.push(element);
- if (scope.PermissionCodeData[attrs['rolePermissionCode']].val != null) {
- if (scope.PermissionCodeData[attrs['rolePermissionCode']].val) {
- element.show();
- }
- }
- }
- }
- };
- }).directive("bsDatetimepicker", ['$timeout', function ($timeout) {
- return {
- require: '?ngModel',
- restrict: 'AE',
- scope: {
- ngModel: '=',
- beginDate: '@',
- endDate: '@',
- minView: '@',// 最精确的时间 0-4越小越精确 0-分钟; 1-小时; 2-天; 3-月 ; 4-年
- maxView: '@',//最高能展示的时间,默认为年
- startView: '@', //— 选完时间首先显示的视图 0:分钟;1:小时;2:天:3:月;4:年
- format: '@',//默认显示月视图,不显示时分秒
- todayBtn: '@',//今天按钮是否显示, 默认显示
- todayHighlight: '@',//当天显示是否高亮,默认显示
- showMeridian: '@',//是否显示上下午,默认不显示
- weekStart: '@',// 一周从哪一天开始显示,默认为7,表示从周日开始显示
- daysOfWeekDisabled: '@', //一周的周几不能选择[0,4,6]
- forceParse: '@',//强制解析,输入的可能不正规,但是它胡强制尽量解析成你规定的格式(format) 默认解析
- autoclose: '@'//选完时间后是否自动关闭 ,默认true,表示关闭
- },
- link: function (scope, element, attr, ngModel) {
- $timeout(function () {
- element.datetimepicker({
- showMeridian: scope.showMeridian ? scope.showMeridian : false,
- todayBtn: scope.todayBtn ? scope.todayBtn : true,
- todayHighlight: scope.todayHighlight ? scope.todayHighlight : true,
- weekStart: scope.weekStart ? scope.weekStart : 0,
- daysOfWeekDisabled: scope.daysOfWeekDisabled ? scope.daysOfWeekDisabled : [],
- forceParse: scope.forceParse ? scope.forceParse : true,
- autoclose: scope.autoclose ? scope.autoclose : true, //
- minView: scope.minView ? scope.minView : 2,
- maxView: scope.maxView ? scope.maxView : 4,
- startView: scope.startView ? scope.startView : 2,
- format: scope.format ? scope.format : 'yyyy-mm-dd',
- inline: true,
- language: 'cn',
- keyboardNavigation: true,//方向键改变日期
- /*onSelect: function(dateText) {
- console.log(dateText)
- var modelPath = $(this).attr('ng-model');
- putObject(modelPath, scope, dateText);
- scope.$apply();
- },*/
- });
- element.on('click', function (e) {//设置最大最小时间限制
- e.currentTarget.blur();
- if (attr.hasOwnProperty('beginDate')) {
- element.datetimepicker('setStartDate', attr.beginDate);
- }
- if (attr.hasOwnProperty('endDate')) {
- element.datetimepicker('setEndDate', attr.endDate);
- }
- });
- }, 0)
- }
- }
- }]).directive('selectFilter', function ($ocLazyLoad, $parse) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- link: function (scope, element, attrs, ctrl) {
- $ocLazyLoad.load('../../scripts/jqueryPlugins/selectFilter.js').then(function () {
- element.selectFilter({
- callBack: function (val) {
- //返回选择的值
- console.log(val + '-是返回的值');
- if (!ctrl) {
- return;
- }
- //ctrl.$modelValue = val;
- element[0].value = val;
- //更新模型
- $parse(attrs['ngModel']).assign(scope, element[0].value);
- scope.$apply();
- }
- });
- });
- }
- }
- }).provider('$bsRouterState', function () {
- var defaults = this.defaults = {
- routeTypes: ['url', 'tab'],
- activeRouteType: 'tab',
- activeTabUrl: 'tabsIndex',
- activeRouteName: 'homeTabs',
- urlToTabRex: 'home.',
- initTabName: 'home.index'
- };
- var routes = [], tabs = [], iniComplete = false;
- tabs.activeTab = '';
- this.copyUrlState = function (urlStates) {
- angular.forEach(urlStates, function (val, key) {
- if (key.indexOf(defaults.urlToTabRex) >= 0) {
- this.push(val.self);
- }
- }, routes);
- };
- this.$get = function ($state, $filter, $http, $timeout) {
- var $link = {};
- var showTab = function (name, params, reload) {
- //当没有加载完就显示首页时等齐
- /*
- var addTitles=$filter('filter')(routes, function (route) {
- return route.title!=null;
- });*/
- if (!iniComplete) {
- $timeout(function () {
- showTab(name, params, reload);
- }, 100);
- return false;
- }
- var existTabs = $filter('filter')(tabs, function (x) {
- return x.name == name;
- });
- if (reload) {
- var indexTab = tabs.indexOf(existTabs[0]);
- if (indexTab >= 0) {
- tabs.splice(indexTab, 1);
- //existTabs.length=0;
- $timeout(function () {
- showTab(name, params);
- }, 100);
- return false;
- }
- }
- if (existTabs.length <= 0) {
- var curRoute = $filter('filter')(routes, function (route) {
- return route.name == name && route.title
- });
- if (curRoute.length > 0) {
- var newTabs = angular.copy(curRoute[0]);
- if (!newTabs.params) {
- newTabs.params = {};
- }
- angular.extend(newTabs.params, params);
- tabs.push(newTabs);
- //$link.params=params;
- tabs.activeTab = name;
- }
- } else {
- tabs.activeTab = name;
- }
- return true;
- };
- var closeTab = function (tab) {
- var indexTab = tabs.indexOf(tab.panedata);
- if (indexTab >= 0) {
- tabs.splice(indexTab, 1);
- }
- };
- var closeTabName = function (tabName) {
- var existTabs = $filter('filter')(tabs, function (val) {
- return val.name == tabName;
- });
- angular.forEach(existTabs, function (eTab) {
- var tabScope = { panedata: eTab };
- closeTab(tabScope);
- });
- };
- var buildTabRoute = function (menuList) {
- recursiveBuildTab(menuList);
- //angular.forEach(routes, function (route) {
- // route.canClose = true;
- // var menus = $filter('filter')(menuList, function (menu) {
- // return menu.Url == route.name;
- // });
- // if (menus.length > 0) {
- // route.title = menus[0].Title;
- // } else {
- // route.title = null;
- // }
- //});
- setCloseState(defaults.initTabName, false);
- iniComplete = true;
- /*
- var initTabs = $filter('filter')(routes, {name: defaults.initTabName});
- angular.forEach(initTabs, function (it) {
- it.canClose = false;
- });
- showTab(defaults.initTabName, {});
- */
- };
- var recursiveBuildTab = function (menuList) {
- angular.forEach(menuList, function (menu) {
- var routers = $filter('filter')(routes, function (route) {
- return menu.Url == route.name;
- });
- angular.forEach(routers, function (route) {
- route.title = menu.Title;
- route.canClose = true;
- });
- recursiveBuildTab(menu.Childrens);
- });
- };
- var setCloseState = function (tabName, canClose) {
- var initTabs = $filter('filter')(routes, function (val) {
- return val.name == tabName;
- });
- angular.forEach(initTabs, function (it) {
- it.canClose = canClose;
- });
- };
- //var setPath
- var loadTabMenu = function () {
- iniComplete = false;
- $http.get('../../api/menumanage/tabMenuList').then(function (req) {
- if (req.data.success) {
- buildTabRoute(req.data.item);
- }
- });
- };
- $link.defaults = defaults;
- $link.go = function (name, urlData, reload) {
- if (this.$getRouteType() == 'tab') {
- //$link.params=urlData;
- showTab(name, urlData, reload);
- } else {
- $state.go(name, urlData);
- }
- };
- $link.$getRouteType = function () {
- return $state.is(defaults.activeRouteName) ? defaults.routeTypes[1] : defaults.routeTypes[0];
- };
- $link.buildTabRoute = buildTabRoute;
- $link.loadTabMenu = loadTabMenu;
- $link.tabs = tabs;
- $link.$setCloseState = setCloseState;
- $link.$showTab = showTab;
- $link.$closeTab = closeTab;
- $link.$closeTabName = closeTabName;
- $link.$params = function (scope) {
- if ($link.$getRouteType() == 'tab') {
- return scope.panedata.params;
- } else {
- return $state.params;
- }
- };
- return $link;
- }
- }).directive('bsUiSref', function ($bsRouterState) {
- var directiveObject = {
- scope: true,
- link: function postLink(scope, element, attrs, controllers) {
- element.bind('click', function () {
- scope.$apply(function () {
- var uiSref = attrs['bsUiSref'];
- var dataJson = uiSref.match(/\((.+?)\)/);
- if (dataJson) {
- var nameJson = uiSref.match(/(.+?)\(/);
- $bsRouterState.go(nameJson[1], eval(dataJson[0]));
- } else {
- $bsRouterState.go(uiSref, {});
- }
- });
- });
- }
- };
- return directiveObject;
- }).directive('activePartytree', ['$timeout', function ($timeout) {
- var activateFun = function (scope, $element) {
- var scrollTop = 0;
- var el = $element.find("div");
- angular.forEach(el, function (item) {
- if (item.className == "party_active") {
- scrollTop = item.offsetTop;
- }
- });
- $element[0].scrollTop = scrollTop;
- };
- var directiveObject = {
- restrict: 'AC',
- link: function (scope, element, attr, controller) {
- $timeout(function () {
- activateFun(scope, element);
- }, 200)
- }
- };
- return directiveObject;
- }]).directive('selectedPartyname', function ($compile) {
- var directiveObject = {
- restrict: 'EAC',
- template: function (tElement, tAttrs) {
- var html = '<div class="select-party">当前选中组织:{{selectdzzmc}}<span ng-if="ptotal!=null">,共有{{ptotal}}{{unit}}。</span></div>';
- return html;
- },
- scope: {
- selectdzzmc: '=?',
- ptotal: '=?',
- unit: '=?'
- },
- link: function (scope, element, attr, controller) {
- }
- };
- return directiveObject;
- }).factory('$uuid', ['$filter', function ($filter) {
- var result = {};
- result.getUUID = function () {
- var d = new Date().getTime();
- var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
- var r = (d + Math.random() * 16) % 16 | 0;
- d = Math.floor(d / 16);
- return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
- });
- return uuid;
- };
- return result;
- }]).directive("zeroTableHeight", ['$timeout', function ($timeout) {
- var f_time = function (element) {
- var $tarTable = element.parents('table');
- var $sourceTable = element.parents('.zero-list-table-panel').find(".zero-source-table-div table");
- var $tarTr = $tarTable.find('tr');
- var $sourceTr = $sourceTable.find('tr');
- for (var i = 0; i < $tarTr.length; i++) {
- var $sourceTd = $sourceTr.eq(i).find('td:first');
- var $tarTd = $tarTr.eq(i).find('td:first');
- if ($sourceTd.height() >= $tarTd.height()) {
- $tarTd.height($sourceTd.height());
- } else {
- $sourceTd.height($tarTd.height());
- }
- }
- /*
- var $table=element.parents('table');
- var $thead=$table.find('thead');
- var t_width=0;
-
- if($table.parent('.zero-source-table-div').has()){
- var $divSourceDiv=$('<div class="zero-source-table-div"></div>');
- var $divTargetTable=$('<table class="zero-target-table"><thead></thead><tbody></tbody></table>');
- $table.before($divSourceDiv);
- $table.before($divTargetTable);
- $table.appendTo($divSourceDiv);
-
- $.each($thead.find('th[zero-table-th]').toArray().reverse(),function (i,th){
- t_width+=th.offsetWidth;
- var thIndex=th.index();
- var $tTh=$divTargetTable.find("thead tr").has()?$('<tr></tr>').appendTo($divTargetTable.find("thead")):$divTargetTable.find("thead tr").first();
-
- $tTh.append(th);
-
- $.each($table.find("tbody tr"),function (i,tr) {
- var $tTr=$divTargetTable.find("tbody tr").eq(i).has()?$('<tr></tr>').appendTo($divTargetTable.find("thead")):$divTargetTable.find("tbody tr").eq(i);
- tr.find('td').eq(thIndex).appendTo($tTr);
- });
-
- });
-
- $divTargetTable.width(t_width);
-
-
- }*/
- };
- var directiveObject = {
- restrict: 'AC',
- link: function (scope, element, attr, controller) {
- if (scope.$last === true) {
- $timeout(function () {
- f_time(element);
- }, 500);
- }
- }
- };
- return directiveObject;
- }]).filter('trustAsHtml',
- [
- '$sce', function ($sce) {
- return function (text) {
- return $sce.trustAsHtml(text);
- }
- }]).directive('panelTitle', function ($compile) {
- var directiveObject = {
- restrict: 'EAC',
- template: function (tElement, tAttrs) {
- var html = '<div class="dj-paneltitle"><div class="title-line"></div><span class="title-text">{{title}}</span> <span style="display: inline;float:right" ng-transclude></span></div>';
- return html;
- },
- scope: {
- title: '=?'
- },
- transclude: true,
- link: function (scope, element, attr, controller) {
- }
- };
- return directiveObject;
- }).directive('foldPartytree', function ($compile) {
- var directiveObject = {
- restrict: 'EA',
- require: '?ngModel',
- templateUrl: '../js/template/modal_foldPartytree.html',
- scope: {
- isunfold: '=?',
- },
- link: function (scope, element, attr, controller) {
- scope.isunfoldfun = function () {
- scope.isunfold = !scope.isunfold;
- scope.$emit('menudatas.toggle', !scope.isunfold);
- }
- }
- };
- return directiveObject;
- }).directive("partyTreenew", function ($http, $ocLazyLoad, AuthUser, $filter) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- //作用域
- scope: {
- selectdzzdm: '=', //等号是双向绑定,选中的党组织代码
- selectdzzmc: '=', //等号是双向绑定,选中的党组织名称
- height: '=',
- csssrc: '=?',
- onlyshowdw: '=?',//显示党委情况,1 组织架构只显示党委,2只显示一级党委(显示一级不能展开下一级)
- defaultselected: '=?',//默认选中的党委代码
- isunfold: '=?' //是否展开
- },
- templateUrl: '../js/template/modal_partyTreeNew.html',
- link: function (scope, elemnet) {
- $ocLazyLoad.load('../js/template/modal_partyTree.css');
- scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
- //sidebar初始化
- var $sidebar = null;
- $sidebar = elemnet.parents('.dj-list-body').first();
- if (scope.isunfold) {
- $sidebar.addClass('pt-sidebar-collapsed-back');
- } else {
- $sidebar.addClass('pt-sidebar-collapsed');
- }
- var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
- sidebarDivs.eq(0).addClass('sidebar1');
- sidebarDivs.eq(1).addClass('content1');
- scope.$watch("isunfold", function (newVal, oldVal) {
- scope.isshowtogglebtn = newVal;
- if ($sidebar) {
- if (newVal) {
- $sidebar.removeClass('pt-sidebar-collapsed');
- $sidebar.addClass('pt-sidebar-collapsed-back');//展开
- } else {
- $sidebar.removeClass('pt-sidebar-collapsed-back');
- $sidebar.addClass('pt-sidebar-collapsed');//收缩
- }
- }
- });
- //定义组织树数据
- scope.treeList = [];//组织树数据
- scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
- var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
- var dwdm = "";//党委代码
- scope.selectdzzdm = dataDzzdm;
- if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
- scope.parentcode = dataDzzdm;
- scope.dzzdm = "";
- scope.selectdzzmc = "全集团党组织";
- } else {
- scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
- scope.dzzdm = dataDzzdm;
- dwdm = dataDzzdm.substring(0, 12);
- }
- //获取分组(集团领导)
- scope.loadPartyGroupList = function () {
- $http
- ({
- method: 'get', url: '../../api/party/getPartyGroupTreeList', params:
- { dzzdm: dwdm }
- }).then(function (result) {
- scope.treeList = result.data;
- });
- };
- //查询上级组织(党员)
- scope.loadParentParty = function () {
- $http
- ({
- method: 'get', url: '../../api/party/getNewPartyTreeList', params:
- {
- parentCode: scope.parentcode,
- isshowxz: 1,
- dzzdm: scope.dzzdm,
- onlyshow_dw: scope.onlyshowdw
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (val, index) {
- val.fullcode = scope.parentcode;
- list.push(val);
- });
- scope.treeList = list;
- if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].id == scope.selectdzzdm)) {
- scope.groupClick(scope.treeList[0]);
- }
- //默认选中党委
- if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
- //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
- var defaultItem = $filter("filter")(list, { id: scope.defaultselected.substring(0, 12) });
- if (defaultItem.length > 0) {
- scope.groupClick(defaultItem[0]);
- }
- }
- });
- };
- //查询子级架构
- scope.loadChildParty = function (node) {
- scope.selectdzzdm = node.id;
- scope.selectdzzmc = node.name;
- //onlyshowdw==2 只显示一级党委 不加载下一级
- if (scope.onlyshowdw != 2 && node.isexpand > 0 && node.partyCount > 0) {
- $http
- ({
- method: 'get', url: '../../api/party/getNewPartyTreeList', params:
- {
- parentCode: node.id,
- isshowxz: 1,
- onlyshow_dw: scope.onlyshowdw
- }
- }).then(function (result) {
- var list = [];
- angular.forEach(result.data.item, function (val, index) {
- val.fullcode = node.fullcode + '.' + node.id;
- list.push(val);
- });
- node.childs = list;
- });
- }
- };
- //点击节点
- scope.groupClick = function (node) {
- var isexpand = node.isexpand > 0 ? 0 : 1;
- scope.resetActive(node);
- node.isexpand = isexpand;
- if (node.nodetype == 2) {
- scope.loadChildParty(node);
- }
- };
- //重置选中项
- scope.resetActive = function (node) {
- var checkIds = node.fullcode.split('.');
- checkIds.push(node.id);
- angular.forEach(scope.treeList, function (val, index) {
- val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
- if (val.childs != null && val.childs.length > 0) {
- scope.resetActive_child(val.childs, checkIds);
- }
- });
- };
- scope.resetActive_child = function (list, checkIds) {
- angular.forEach(list, function (val, index) {
- val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
- if (val.childs != null && val.childs.length > 0) {
- scope.resetActive_child(val.childs, checkIds);
- }
- });
- };
- if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
- //初始化数据
- scope.loadPartyGroupList();
- } else {
- scope.loadParentParty();
- }
- }
- }
- }).directive("dictionaryCode", function ($http, $compile) {
- return {
- restrict: 'A',
- template: '<option value="" selected>{{ (emptyTitle && emptyTitle != "") ? emptyTitle : "---全部---" }}</option></option><option ng-repeat="it in dicList" ng-selected="(it.Value == null && ngModel == null) || ngModel == it.Value" ng-value="{{it.Value}}">{{it.Name}}</option>',
- scope: {
- ngModel: '=',
- emptyTitle: '@'
- },
- link: function (scope, element, attr, controller) {
- if (element[0].tagName == "SELECT") {
- scope.dicList = [];
- $http.post('../../api/systemsetting/dictionary/getdicList', { code: attr.dictionaryCode })
- .then(function (res) {
- if (res.data.IsSuccess) {
- scope.dicList = res.data.Data;
- }
- });
- }
- }
- }
- }).directive("linkCondition", function ($http, $ocLazyLoad, AuthUser, $filter) {
- return {
- restrict: 'EA',
- require: 'ngModel',
- replace: true,
- //作用域
- scope: {
- ngModel: '=',
- sourceList: '=',
- valueField: '@',
- textField: '@',
- defaultCount: '@',
- alwaysSelectAll: '=',
- isMultiSelect: '=',
- colNum: '='
- },
- templateUrl: '../js/template/linkcondition.html',
- link: function (scope, elemnet, attr, controller) {
- scope.isShowAll = true;
- scope.showText = "展开";
- scope.selected = [];
- scope.rowList = [];
- scope.hide = true;
- scope.limit = parseInt(scope.defaultCount);
- if (scope.limit != null && !isNaN(scope.limit)) {
- scope.isShowAll = false;
- }
- scope.$watch('isShowAll', function (newVal, oldVal) {
- if (newVal) {
- scope.showText = "收起";
- } else {
- scope.showText = "展开";
- }
- });
- scope.isExists = function (val) {
- if (scope.selected.filter(function (x) {
- return x == val;
- }).length > 0) {
- return true;
- } else {
- return false;
- }
- };
- scope.onClick = function (val) {
- if (scope.alwaysSelectAll) {
- scope.selected = [];
- } else {
- if (scope.isExists(val)) {
- scope.selected = scope.selected.filter(function (x) {
- return x != val;
- });
- } else {
- if (scope.isMultiSelect != undefined && scope.isMultiSelect != null && scope.isMultiSelect == false && scope.selected.length != 0) {
- scope.selected = [];
- if (angular.isArray(scope.ngModel)) {
- scope.ngModel = [val];
- } else {
- scope.ngModel = val;
- }
- }
- scope.selected.push(val);
- }
- }
- };
- //反选操作
- scope.transfer = function () {
- if (scope.selected.length == 0) {
- return;
- }
- var replaceList = scope.sourceList.filter(function (it) {
- var ie = scope.selected.filter(function (x) {
- return x == it[scope.valueField];
- });
- return ie.length == 0;
- })
- scope.selected = $.map(replaceList, function (it) {
- return it[scope.valueField];
- });
- }
- scope.$watch('selected.length', function (newVal, oldVal) {
- if (newVal == oldVal) return;
- if (newVal != null && newVal != 0) {
- if (angular.isArray(scope.ngModel)) {
- scope.ngModel = scope.selected;
- } else {
- scope.ngModel = scope.selected.join(',');
- }
- } else {
- if (angular.isArray(scope.ngModel)) {
- scope.ngModel = [];
- } else {
- scope.ngModel = null;
- }
- }
- //$scope.loadData();
- });
- scope.$watch('ngModel', function (newVal, oldVal) {
- if (angular.isArray(newVal)) {
- scope.selected = newVal;
- } else if (newVal != null) {
- scope.selected = newVal.toString().split(",");
- } else {
- scope.selected = [];
- }
- });
- //数据分行
- scope.$watch('sourceList', function (newVal, oldVal) {
- if (scope.colNum > 0 && scope.sourceList.length > 0) {
- scope.hide = false;
- var arrLength = scope.sourceList.length; // 数组长度
- var num = scope.colNum > 0 ? scope.colNum : 10; // 列数
- var index = 0;
- for (let i = 0; i < arrLength; i++) {
- if (i % num === 0 && i !== 0) { // 可以被 列数 整除
- scope.rowList.push(scope.sourceList.slice(index, i));
- index = i;
- };
- if ((i + 1) === arrLength) {
- scope.rowList.push(scope.sourceList.slice(index, (i + 1)));
- }
- };
- }
- });
- }
- }
- }).directive('moreSpan', function ($compile) {
- var directiveObject = {
- restrict: 'EA',
- template: function (tElement, tAttrs) {
- var html = '<span class="moreSpan" ng-click="isShowClick()">{{moreTxt}}<i class="material-icons">{{isShow ? "expand_less" : "expand_more"}}</i></span>';
- return html;
- },
- scope: {
- isShow: '=?'
- },
- link: function (scope, element, attr, controller) {
- scope.isShow = scope.isShow || false;
- scope.moreTxt = scope.isShow ? "收起" : "更多";
- scope.isShowClick = function () {
- scope.isShow = !scope.isShow;
- scope.moreTxt = scope.isShow ? "收起" : "更多";
- };
- }
- };
- return directiveObject;
- }).directive('thBind', function () {
- var directiveObject = {
- restrict: 'A',
- template: function (tElement, tAttrs) {
- var html = '{{title}}<span ng-if="required" style="color: red;">*</span>';
- return html;
- },
- scope: {
- title: '=?',
- required: '=?',
- },
- link: function (scope, element, attr, controller) {
- scope.required = scope.required || false;
- }
- };
- return directiveObject;
- }).directive('tdRownum', function () {
- var directiveObject = {
- restrict: 'A',
- template: function (tElement, tAttrs) {
- var html = '<span>{{pagesize*(pageindex-1)+index+1}}</span>';
- return html;
- },
- scope: {
- index: '=',
- pageindex: '=',
- pagesize: '=',
- },
- link: function (scope, element, attr, controller) {
- element.parent().on('click', function () {
- var tar1 = event.target;
- if (tar1.nodeName == "TD") {
- var ngStr = $(this).find("[type='checkbox']").attr('ng-model');
- var funText = "scope.$parent." + ngStr + "=!scope.$parent." + ngStr + ";";
- scope.$apply(function () {
- eval(funText);
- });
- }
- //event.stopPropagation();
- });
- }
- };
- return directiveObject;
- }).directive('typeaheadInput', function ($http, $q, $ocLazyLoad) {
- $ocLazyLoad.load('../js/template/modal_typeahead.css');
- var directiveObject = {
- restrict: 'AE',
- require: 'ngModel',
- template: function (tElement, tAttrs) {
- var html = '<input ng-show="!readonly" type="text" data-watch-options="true" data-template-url="../js/template/modal_typeahead.html" data-min-length="0" data-limit="300" ng-model="selectData" bs-on-select="selectedItem" bs-typeahead data-animation="am-flip-x" class="form-control" bs-options="it as it.Text for it in selectList"';
- //data-trigger="click"
- html += '/>';
- html += '<input ng-show="readonly" class="form-control" readonly="readonly" ng-model="selectData.Text" type="text" />';
- return html;
- },
- scope: {
- url: '=',
- params: '=',
- readonly: '=',
- width: '=',
- selectname: '='
- },
- compile: function compile(tElement, tAttrs, transclude) {
- return {
- pre: function preLink(scope, iElement, iAttrs, ngModel) {
- scope.selectData = '';
- scope.selectList = [];
- scope.isId = true;
- scope.scollParams = {
- showMore: 0,
- canLoad: true,
- msgs: ['--滚动加载更多--', '--加载中--', '--无更多数据--']
- }
- scope.selectedParams = {
- pageIndex: 1,
- pageSize: 10,
- key: '',
- id: '',
- total: 10
- };
- scope.scollevent = function () {
- if (scope.scollParams.canLoad) {
- scope.scollParams.canLoad = false;
- scope.loadItems();
- }
- }
- scope.$watch(function () {
- return ngModel.$modelValue;
- }, function (newValue) {
- if (scope.selectData != null && scope.selectData.Value == ngModel.$modelValue) {
- return false;
- }
- if (newValue != null && newValue.length > 0 && scope.scollParams.canLoad) {
- scope.scollParams.canLoad = false;
- scope.selectedParams.id = newValue;
- scope.selectedParams.key = '';
- scope.loadItems();
- //scope.findItems('');
- }
- });
- scope.$watch('selectData', function (newValue, oldValue) {
- if (typeof (newValue) != 'string') {
- scope.selectname = newValue.Text;
- return false;
- }
- else {
- scope.selectname = newValue;
- }
- /*if (scope.scollParams.canLoad) {
- //重置加载
- scope.scollParams.showMore = 0;
- //scope.selectedParams.id = '';
- scope.selectedParams.key = newValue;
- scope.selectedParams.pageIndex = 1;
- scope.selectList.length = 0;
- scope.loadItems();
- }*/
- });
- scope.findItems = function (key) {
- var Items$ = $q.defer();
- if (scope.isId) {
- if (ngModel.$modelValue) {
- scope.selectedParams.id = ngModel.$modelValue;
- } else {
- scope.isId = false;
- }
- }
- var isLoadData = typeof (key) == 'string';
- isLoadData = isLoadData && key !== scope.selectData.Text;
- //isLoadData = isLoadData && (key + id).length > 0;
- scope.selectedParams.key = key;
- //isLoadData = false;
- if (isLoadData) {
- $http({
- method: "post",
- url: scope.url,
- data: angular.extend(scope.selectedParams, scope.params || {})
- }).then(function (result) {
- scope.selectList = result.data.Data;
- if (scope.selectedParams.id.length > 0) {
- if (result.data.Data.length == 1) {
- scope.selectData = scope.selectList[0];
- }
- }
- Items$.resolve(scope.selectList);
- }, Items$.reject);
- } else {
- Items$.resolve(scope.selectList);
- }
- return Items$.promise;
- };
- scope.loadItems = function () {
- var Items$ = $q.defer();
- $http({
- method: "post",
- url: scope.url,
- data: angular.extend(scope.selectedParams, scope.params || {})
- }).then(function (result) {
- //scope.selectList = result.data.Data;
- /*angular.forEach(result.data.Data, function (val) {
- scope.selectList.push(val);
- });*/
- scope.selectList = result.data.Data;
- if (result.data.Data.length == scope.selectedParams.pageSize) {
- scope.selectedParams.pageIndex++;
- } else {
- //不再加载
- scope.scollParams.showMore = 2;
- }
- scope.scollParams.canLoad = true;
- if (scope.selectedParams.id.length > 0) {
- if (result.data.Data.length == 1) {
- scope.selectData = scope.selectList[0];
- }
- scope.selectedParams.id = '';
- }
- if (!scope.selectData && ngModel.$modelValue) {
- scope.selectData = scope.selectList.filter(it => it.Value == ngModel.$modelValue)[0];
- }
- Items$.resolve(scope.selectList);
- }, Items$.reject);
- return Items$.promise;
- }
- scope.selectedItem = function () {
- if (scope.selectData.Value) {
- ngModel.$setViewValue(scope.selectData.Value);
- }
- }
- /*
- scope.$watch("selectData", function (newVal, oldVal) {
- if (typeof (newVal) == 'string' && newVal.length>0) {
- $http({
- method: "post",
- url: scope.url,
- data: { key: scope.selectData,id:'' }
- }).then(function (result) {
- scope.selectList = result.data.Data;
- });
- }
- });*/
- scope.loadItems();
- },
- post: function postLink(scope, iElement, iAttrs, controller) {
- }
- }
- }
- };
- return directiveObject;
- }).directive('whenScrolled', function () {
- return function (scope, elm, attr) {
- // 内层DIV的滚动加载
- var raw = elm[0];
- elm.on('scroll', function () {
- if (raw.scrollTop + raw.offsetHeight + 10 >= raw.scrollHeight) {
- raw.scrollTop -= 30;
- scope.$apply(attr.whenScrolled);
- };
- });
- };
- }).filter('ConvertCurrencyFilter', ["$filter", function () {
- return function (currency) {
- // Constants:
- var MAXIMUM_NUMBER = 99999999999.99;
- // Predefine the radix characters and currency symbols for output:
- var CN_ZERO = "零";
- var CN_ONE = "壹";
- var CN_TWO = "贰";
- var CN_THREE = "叁";
- var CN_FOUR = "肆";
- var CN_FIVE = "伍";
- var CN_SIX = "陆";
- var CN_SEVEN = "柒";
- var CN_EIGHT = "捌";
- var CN_NINE = "玖";
- var CN_TEN = "拾";
- var CN_HUNDRED = "佰";
- var CN_THOUSAND = "仟";
- var CN_TEN_THOUSAND = "万";
- var CN_HUNDRED_MILLION = "亿";
- var CN_SYMBOL = "人民币";
- var CN_DOLLAR = "元";
- var CN_TEN_CENT = "角";
- var CN_CENT = "分";
- var CN_INTEGER = "整";
- // Variables:
- var integral; // Represent integral part of digit number.
- var decimal; // Represent decimal part of digit number.
- var outputCharacters; // The output result.
- var parts;
- var digits, radices, bigRadices, decimals;
- var zeroCount;
- var i, p, d;
- var quotient, modulus;
- if (currency == null || currency == undefined) {
- return "零元整";
- }
- // Validate input string:
- currency = currency.toString();
- if (currency == "") {
- //alert("Empty input!");
- return "零元整";
- }
- if (currency.match(/[^-,.\d]/) != null) {
- //alert("Invalid characters in the input string!");
- //return "";
- return "零元整";
- }
- if ((currency).match(/^(-*((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?)))$/) == null) {
- /*alert("Illegal format of digit number!");
- return "";*/
- return "零元整";
- }
- // Normalize the format of input digits:
- currency = currency.replace(/,/g, ""); // Remove comma delimiters.
- currency = currency.replace(/^0+/, ""); // Trim zeros at the beginning.
- var currencyDigits = Math.abs(currency);
- currencyDigits = currencyDigits.toString();
- // Assert the number is not greater than the maximum number.
- if (Number(currencyDigits) > MAXIMUM_NUMBER) {
- alert("Too large a number to convert!");
- return "";
- }
- // Process the coversion from currency digits to characters:
- // Separate integral and decimal parts before processing coversion:
- parts = currencyDigits.split(".");
- if (parts.length > 1) {
- integral = parts[0];
- decimal = parts[1];
- // Cut down redundant decimal digits that are after the second.
- decimal = decimal.substr(0, 2);
- }
- else {
- integral = parts[0];
- decimal = "";
- }
- // Prepare the characters corresponding to the digits:
- digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
- radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
- bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
- decimals = new Array(CN_TEN_CENT, CN_CENT);
- // Start processing:
- outputCharacters = "";
- // Process integral part if it is larger than 0:
- if (Number(integral) > 0) {
- zeroCount = 0;
- for (i = 0; i < integral.length; i++) {
- p = integral.length - i - 1;
- d = integral.substr(i, 1);
- quotient = p / 4;
- modulus = p % 4;
- if (d == "0") {
- zeroCount++;
- }
- else {
- if (zeroCount > 0) {
- outputCharacters += digits[0];
- }
- zeroCount = 0;
- outputCharacters += digits[Number(d)] + radices[modulus];
- }
- if (modulus == 0 && zeroCount < 4) {
- outputCharacters += bigRadices[quotient];
- }
- }
- outputCharacters += CN_DOLLAR;
- }
- // Process decimal part if there is:
- if (decimal != "") {
- for (i = 0; i < decimal.length; i++) {
- d = decimal.substr(i, 1);
- if (d != "0") {
- outputCharacters += digits[Number(d)] + decimals[i];
- }
- }
- }
- // Confirm and return the final output string:
- if (outputCharacters == "") {
- outputCharacters = CN_ZERO + CN_DOLLAR;
- }
- if (decimal == "") {
- outputCharacters += CN_INTEGER;
- }
- outputCharacters = outputCharacters;
- if (currency.match(/^-/)) {
- outputCharacters = '负' + outputCharacters;
- }
- return outputCharacters;
- }
- }]).provider('popupReport', function () {
- this.$get = function ($modal, $http, $loading) {
- var popupReport = {
- popup: function (title, getFileUrl, data) {
- $loading.show();
- $http.post(getFileUrl, data).then(function (res) {
- $loading.hide();
- var filePath = res.data.Data;
- //filePath = '../../../../api/systemsetting/report?filePath=' + filePath;
- filePath = filePath.replace("/content/template/", "");
- popupReport.title = title;
- popupReport.reportUrl = '../../lib/pdf.js/web/viewer.html?file=' + escape(filePath);
- var modal = $modal({
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- }]
- },
- controller: ctrl,
- templateUrl: '../js/template/modal_report.html',
- show: false,
- size: 'lg',
- animation: 'am-fade-and-slide-top'
- });
- modal.$promise.then(modal.show);
- }, function (res) {
- $loading.hide();
- $scope.showMsg('系统信息', '服务器错误,打印失败。');
- });
- }
- };
- var ctrl = function ($scope) {
- $scope.title = popupReport.title;
- $scope.url = popupReport.reportUrl;
- };
- ctrl.$inject = ['$scope'];
- return popupReport;
- }
- }).provider('preViewPDF', function () {
- this.$get = function ($modal, $http, $loading) {
- var preViewPDF = {
- popup: function (title, url) {
- preViewPDF.title = title;
- preViewPDF.reportUrl = url;
- var modal = $modal({
- resolve: {
- load: ['$ocLazyLoad', function ($ocLazyLoad) {
- }]
- },
- controller: ctrl,
- templateUrl: '../js/template/modal_report.html',
- show: false,
- size: 'lg',
- animation: 'am-fade-and-slide-top'
- });
- modal.$promise.then(modal.show);
- }
- };
- var ctrl = function ($scope) {
- $scope.title = preViewPDF.title;
- $scope.url = preViewPDF.reportUrl;
- };
- ctrl.$inject = ['$scope'];
- return preViewPDF;
- }
- }).directive('bootsSelect', function ($compile) {
- return {
- restrict: 'A',
- require: 'ngModel',
- scope: {
- optionDatas: '=',
- ngModel: '='
- },
- link: function ($scope, $element, $attrs, $ngModel) {
- $scope.$watch('optionDatas', function () {
- var optionDatas = $scope.optionDatas;
- if (optionDatas != undefined) {
- $($element).selectpicker('refresh');
- }
- });
- $scope.$watch('ngModel', function () {
- $($element).selectpicker('refresh');
- });
- }
- };
- }).provider('excelPopup', function () {
- this.$get = function ($modal, $http, $loading) {
- var excelPopup = {
- export: function (url, data, fileName) {
- $loading.show();
- $http.post(url, data).then(function (res) {
- $loading.hide();
- if (res.data.IsSuccess) {
- var filePath = res.data.Data;
- filePath = '../../../../api/systemsetting/excel?fileName=' + filePath + '&fileNewName=' + escape(fileName);
- window.open(filePath);
- } else {
- $scope.showMsg('系统信息', '导出失败:' + res.data.Message);
- }
- }, function (res) {
- $loading.hide();
- $scope.showMsg('系统信息', '服务器错误,导出失败。');
- });
- }
- };
- return excelPopup;
- }
- }).directive('checkedRow', function () {
- var directiveObject = {
- restrict: 'AC',
- scope: {
- checkedRow: '='
- },
- link: function (scope, element, attr, controller) {
- //element.find('td')
- element.on('click', function () {
- var tar1 = event.target;
- if (tar1.nodeName == "TD") {
- scope.$apply(function () {
- scope.checkedRow = !scope.checkedRow;
- });
- }
- });
- }
- };
- return directiveObject;
- }).directive('fixedTableHeader', function ($timeout, $compile) {
- return {
- restrict: 'A',
- scope: {
- fiexdFooter: '=?',//是否固定表格tfoot
- /*fixedColumns:'=?',*/
- maxHeight: '=?', //最大高度,默认自适应表格到底部的高度
- fixedEndColumns: '=?'
- },
- link: function (scope, element, attr) {
- if (scope.$parent.$last === true) {
- var $table = $(element).parent().parent();
- var $parent = $table.parent();
- $table.fixedHeaderTable('destroy');
- $timeout(function () {
- $parent = $table.parent();
- var parentHeight = 0;
- var diffHeight = (scope.fixedEndColumns > 0 ? 15 : 0);//误差偏移量
- var maxHeight = scope.maxHeight || ($(window).actual('height') - $table.offset().top - ($parent.parent().find(".grid-page").height() || 0) - 10);
- if ($table.actual('height') < maxHeight) { //不需要出滚动条
- parentHeight = $table.actual('height') + 10;
- }
- else {
- parentHeight = maxHeight;
- }
- $parent.height(parentHeight + diffHeight);
- if ($table.height() >= $table.parent().height() || scope.fixedEndColumns > 0) {
- $table.fixedHeaderTable({ footer: scope.fiexdFooter || false, fixedEndColumns: scope.fixedEndColumns || 0 });
- //全选
- var $tableWrapper = $table.parent().parent();
- $tableWrapper.find(".fht-thead").find('input[type="checkbox"]').on('click', function () {
- var allChecked = this.checked;
- var allCheckedInput = $tableWrapper.find(".fht-tbody").find("thead").find('input[type="checkbox"]');
- var allCheckScope = allCheckedInput.scope();
- allCheckedInput.prop("checked", allChecked);
- allCheckScope.$apply(function () {
- allCheckScope.checkAll();
- });
- });
- //点击
- $table.find(".text-left").find('i').on('click', function () {
- try {
- var $fixedColumn = $table.parent().parent().parent().find(".fht-fixed-column");
- var trHeight = $(this).parent().parent().height() ?? 0;
- var trNextHeight = $(this).parent().parent().next().height() ?? 0;
- var name = $(this).attr('name');
- var isexpanded = $(this).attr('isexpanded');
- var $trs = $fixedColumn.find('.text-center');
- for (var i = 0; i < $trs.length; i++) {
- if ($trs[i].attributes.name.value == name) {
- $($trs[i]).parent().height(isexpanded == 'true' ? (trHeight + trNextHeight) : trHeight);
- break;
- }
- }
- } catch (exception) { }
- });
- //双击
- $table.find(".text-left").parent().on('dblclick', function () {
- try {
- var $fixedColumn = $table.parent().parent().parent().find(".fht-fixed-column");
- var trHeight = $(this).height() ?? 0;
- var trNextHeight = $(this).next().height() ?? 0;
- var name = $($($(this).children()[0]).children()[1]).attr('name')
- var isexpanded = $($($(this).children()[0]).children()[1]).attr('isexpanded')
- var $trs = $fixedColumn.find('.text-center');
- for (var i = 0; i < $trs.length; i++) {
- if ($trs[i].attributes.name.value == name) {
- $($trs[i]).parent().height(isexpanded == 'true' ? (trHeight + trNextHeight) : trHeight);
- break;
- }
- }
- } catch (exception) { }
- });
- //固定列
- if (scope.fixedEndColumns > 0) {
- try {
- var $fixedColumn = $table.parent().parent().parent().find(".fht-fixed-column");
- $compile($fixedColumn.contents())($table.scope());
- $tableWrapper.find(".fht-tbody").height($tableWrapper.find(".fht-tbody").height() - 2);
- $fixedColumn.find(".fht-tbody").height($fixedColumn.find(".fht-tbody").height() + 15);
- $table.find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').find("*").attr("disabled", true);
- var fiexdwidth = $tableWrapper.find(".fht-thead").find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').find(".fht-cell").width();
- /*$fixedColumn.width(fiexdwidth + 45);*/
- $table.find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').width(fiexdwidth + 1);
- $tableWrapper.find(".fht-thead").find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').width(fiexdwidth);
- var body = $tableWrapper.find(".fht-tbody");
- if (body[0].scrollWidth <= body[0].clientWidth) {
- $fixedColumn.width(fiexdwidth + 38);
- }
- //默认展开
- var trHeight = $($table.find('tbody').find("tr")[0]).height() ?? 0;
- var trNextHeight = $($table.find('tbody').find("tr")[0]).next().height() ?? 0;
- $($fixedColumn.find('.text-center').parent()[0]).height(trNextHeight > trHeight ? (trHeight + trNextHeight) : trHeight);
- } catch (exception) { }
- }
- }
- });
- }
- }
- };
- }).provider('$postopen', function () {
- this.$get = function () {
- var funPost = function (url, args) {
- var form = $("<form method='post'></form>");
- form.attr({ "action": url });
- $.each(args, function (i, n) {
- var input = $("<input type='hidden'>");
- input.attr({ "name": i });
- input.val(n);
- form.append(input);
- });
- $('body').append(form);
- form.submit();
- form.remove();
- };
- return funPost;
- }
- }).directive('tabExt', function () {
- return {
- restrict: 'A',
- link: function (scope, element, attr) {
- element.bind('contextmenu', function (event) {
- event.preventDefault();
- if (scope.$index != 0) {
- var menu = angular.element('.tab-menu');
- menu.css('display', 'block');
- menu.mouseleave(function () {
- menu.css('display', 'none');
- });
- menu.attr('index', scope.$index);
- menu.offset({
- left: event.pageX,
- top: event.pageY
- });
- }
- });
- }
- };
- }).directive('tabMenu', function ($bsRouterState) {
- return {
- restrict: 'C',
- link: function (scope, element, attr) {
- scope.closeOtherLabel = '关闭其他';
- scope.closeAllLabel = '关闭全部';
- element.bind('contextmenu', function (event) {
- event.preventDefault();
- });
- scope.closeOtherTab = function () {
- var tabCount = $bsRouterState.tabs.length;
- for (var i = tabCount - 1; i > 0; i--) {
- if (i.toString() != element.attr('index')) {
- $bsRouterState.$closeTabName($bsRouterState.tabs[i].name);
- }
- }
- var menu = angular.element('.tab-menu');
- menu.css('display', 'none');
- }
- scope.closeAllTab = function () {
- var tabCount = $bsRouterState.tabs.length;
- for (var i = tabCount - 1; i > 0; i--) {
- $bsRouterState.$closeTabName($bsRouterState.tabs[i].name);
- }
- var menu = angular.element('.tab-menu');
- menu.css('display', 'none');
- }
- }
- };
- }).directive('dragableHeader', function () {
- return {
- restrict: 'EAC',
- link: function (scope, element, attrs) {
- scope.obj = element[0];
- scope.startx = 0;
- scope.starty;
- scope.startLeft;
- scope.startTop;
- scope.mainDiv = scope.obj.parentNode;
- scope.isDown = false;
- scope.originIndex = scope.mainDiv.style.zIndex;
- var that = scope;
- scope.movedown = function (e) {
- e = e ? e : window.event;
- if (!window.captureEvents) {
- this.setCapture();
- }
- that.isDown = true;
- that.obj.style.cursor = 'move';
- that.mainDiv.style.zIndex = 1000;
- that.startx = e.clientX;
- that.starty = e.clientY;
- that.startLeft = parseInt(that.mainDiv.offsetLeft);
- that.startTop = parseInt(that.mainDiv.offsetTop);
- }
- scope.move = function (e) {
- e = e ? e : window.event;
- if (that.isDown) {
- that.mainDiv.style.left = e.clientX - (that.startx - that.startLeft) + "px";
- that.mainDiv.style.top = e.clientY - (that.starty - that.startTop) + "px";
- }
- }
- scope.moveup = function () {
- that.isDown = false;
- that.obj.style.cursor = 'default';
- that.mainDiv.style.zIndex = that.originIndex;
- if (!window.captureEvents) {
- this.releaseCapture();
- }
- }
- scope.obj.onmousedown = scope.movedown;
- scope.obj.onmousemove = scope.move;
- scope.obj.onmouseup = scope.moveup;
- //非ie浏览器
- document.addEventListener("mousemove", scope.move, true);
- }
- };
- }).directive('checkList', function () {
- return {
- restrict: 'EA',
- replace: true,
- require: 'ngModel',
- scope: {
- ngModel: '=',
- sourceList: '=',
- valueField: '@',
- textField: '@',
- defaultCount: '@?'
- },
- templateUrl: '../js/template/checklist.html',
- link: function (scope, element, attrs) {
- scope.isShowAll = true;
- scope.showText = "展开";
- scope.selected = [];
- scope.limit = parseInt(scope.defaultCount);
- if (scope.limit != null && !isNaN(scope.limit)) {
- scope.isShowAll = false;
- }
- scope.$watch('isShowAll', function (newVal, oldVal) {
- if (newVal) {
- scope.showText = "收起";
- } else {
- scope.showText = "展开";
- }
- });
- scope.isExists = function (val) {
- if (scope.selected.filter(function (x) {
- return x == val;
- }).length > 0) {
- return true;
- } else {
- return false;
- }
- };
- scope.onClick = function (val) {
- if (scope.isExists(val)) {
- scope.selected = scope.selected.filter(function (x) {
- return x != val;
- });
- } else {
- scope.selected.push(val);
- }
- };
- scope.$watch('selected.length', function (newVal, oldVal) {
- if (newVal == oldVal) return;
- if (newVal != null && newVal != 0) {
- if (angular.isArray(scope.ngModel)) {
- scope.ngModel = scope.selected;
- } else {
- scope.ngModel = scope.selected.join(',');
- }
- } else {
- if (angular.isArray(scope.ngModel)) {
- scope.ngModel = [];
- } else {
- scope.ngModel = null;
- }
- }
- });
- scope.$watch('ngModel', function (newVal, oldVal) {
- if (angular.isArray(newVal)) {
- scope.selected = newVal;
- } else if (newVal != null) {
- scope.selected = newVal.toString().split(",");
- } else {
- scope.selected = [];
- }
- });
- }
- };
- }).directive('tugItemSelect', function ($http, $modal, $filter) {
- var directiveObject = {
- restrict: 'EAC',
- scope: {
- dataoptions: '='
- },
- link: function (scope, element, attr, controller) {
- var sdModal = {};
- if (!scope.dataoptions.selectedJData) {
- scope.dataoptions.selectedJData = [];
- }
- scope.init = function () {
- scope.dataoptions.selectedJData = [];
- if (scope.dataoptions.selectedValueData && scope.dataoptions.selectedValueData.length > 0) {
- var valueArray = scope.dataoptions.selectedValueData.split(',');
- var labelArray = scope.dataoptions.selectedLabeData.split(',');
- angular.forEach(valueArray, function (val, key) {
- var it = {};
- it[scope.dataoptions.selectValuekey] = val;
- it[scope.dataoptions.selectLabelKey] = labelArray[key];
- scope.dataoptions.selectedJData.push(it);
- });
- }
- };
- var sdModalController = function ($scope) {
- $scope.selectparams = {
- pageIndex: 1,
- pageSize: 10,
- itemTypeID: null,
- code: null,
- name: null,
- itemType: null
- };
- $scope.ptotal = 0;
- $scope.itemTypeList = [];
- $scope.fdata = {
- selectCols: [],
- columns: scope.dataoptions.columns,
- items: [],
- ptotal: 0,
- title: scope.dataoptions.title,
- width: scope.dataoptions.width == null ? 70 : scope.dataoptions.width,
- selectedJData: scope.dataoptions.selectedJData,
- selectValuekey: scope.dataoptions.selectValuekey,
- selectLabelKey: scope.dataoptions.selectLabelKey,
- selectTemp: [],
- isMulti: scope.dataoptions.isMulti
- };
- angular.forEach(scope.dataoptions.selectData, function (value, key) {
- $scope.fdata.selectCols.push({ text: value, val: key });
- });
- $scope.getItemTypeList = function () {
- $http({
- method: 'post', url: '../../api/items/Item/GetTypeList', data: {}
- }).then(function (result) {
- if (result.data.IsSuccess) {
- $scope.itemTypeList = result.data.Data;
- } else {
- $scope.showMsg('错误', result.data.Message);
- }
- });
- };
- $scope.loadData = function () {
- $http.post(scope.dataoptions.url, $scope.selectparams).then(function (value) {
- $scope.fdata.items = value.data.Data.rows;
- $scope.ptotal = value.data.Data.total;
- });
- };
- $scope.search = function () {
- $scope.loadData();
- };
- $scope.findSData = function () {
- $scope.selectparams.pageIndex = 1;
- $scope.loadData();
- };
- $scope.addItem = function () {
- var tableCheckedArray = $filter('filter')($scope.fdata.items, function (tIt) {
- return tIt.checked;
- });
- angular.forEach(tableCheckedArray, function (value, key) {
- var itemData = $filter('filter')($scope.fdata.selectedJData, function (it) {
- return it[$scope.fdata.selectValuekey] == value[$scope.fdata.selectValuekey];
- });
- if (itemData.length == 0) {
- $scope.fdata.selectedJData.push(value);
- }
- });
- };
- $scope.deleteItem = function (it) {
- var i = -1;
- if (it) {
- i = $scope.fdata.selectedJData.indexOf(it);
- $scope.fdata.selectedJData.splice(i, 1);
- } else {
- angular.forEach($scope.fdata.selectTemp, function (value, key) {
- i = $scope.fdata.selectedJData.indexOf(value);
- $scope.fdata.selectedJData.splice(i, 1);
- });
- }
- };
- $scope.selectedData = function () {
- scope.dataoptions.selectedLabeData = '';
- scope.dataoptions.selectedValueData = '';
- var selectItem = {};
- if ($scope.fdata.isMulti) {
- angular.forEach($scope.fdata.selectedJData, function (value, key) {
- if (key > 0) {
- scope.dataoptions.selectedLabeData += ',';
- scope.dataoptions.selectedValueData += ','
- }
- scope.dataoptions.selectedLabeData += value[$scope.fdata.selectLabelKey];
- scope.dataoptions.selectedValueData += value[$scope.fdata.selectValuekey];
- });
- } else {
- angular.forEach($scope.fdata.items, function (value, key) {
- if (value.checked == true) {
- scope.dataoptions.selectedLabeData = value[$scope.fdata.selectLabelKey];
- scope.dataoptions.selectedValueData = value[$scope.fdata.selectValuekey];
- selectItem = value;
- }
- });
- }
- if (scope.dataoptions.onSelect != undefined) {
- scope.dataoptions.onSelect(scope.dataoptions.selectedValueData, selectItem);
- }
- $scope.$hide();
- };
- $scope.selectItemType = function (itemType) {
- if (itemType.ParentId != null && itemType.Childrens.length == 0) {
- $scope.selectparams.itemTypeID = itemType.ItemTypeId;
- $scope.selectparams.itemType = null;
- $scope.findSData();
- } else {
- $scope.selectparams.itemTypeID = null;
- $scope.selectparams.itemType = itemType.ItemTypeId;
- $scope.findSData();
- }
- }
- $scope.getItemTypeList();
- $scope.loadData();
- };
- sdModalController.$inject = ['$scope'];
- sdModal = $modal({
- scope: scope, controller: sdModalController, template: "../js/template/modal_tugitemselect.html", show: false
- });
- element.on('click', function () {
- scope.init();
- sdModal.$promise.then(sdModal.show);
- });
- }
- };
- return directiveObject;
- }).directive('contentEditable', function () {
- return {
- scope: {
- readonly: '='
- },
- require: 'ngModel',
- link: function (scope, element, attrs, ctrl) {
- // view -> model
- element.bind('keyup', function () {
- ctrl.$setViewValue(element.html());
- });
- element.bind('drop', function () {
- setTimeout(function () {
- ctrl.$setViewValue(element.html());
- }, 100);
- });
- ctrl.$render = function () {
- if (scope.readonly) {
- attrs.$set('contenteditable', false);
- } else {
- attrs.$set('contenteditable', true);
- element.addClass("editable-div");
- }
- element.html(ctrl.$viewValue);
- };
- }
- };
- }).filter('reportvalue', function () {
- return function (number) {
- return (number == 0) ? null : number;
- };
- }).directive("treeSelect", function ($http, $ocLazyLoad, AuthUser, $filter) {
- //<tree-select data-url="treeConfig.url" data-value="treeConfig.value" data-ismulti="treeConfig.ismulti"></tree-select>
- return {
- restrict: 'EA',
- require: '?ngModel',
- //作用域
- scope: {
- url: '=',//api
- params: '=?',//api参数,类型:对象 {}
- value: '=?',//选择id集合,类型:数组 [id1,id2]
- ismulti: "=?"//单选or多选,类型:boolean
- },
- templateUrl: '../js/template/modal_treeselect.html',
- link: function (scope, elemnet) {
- scope.className = Math.random().toString(36).slice(2, 8);
- scope.ismulti = !scope.ismulti ? false : scope.ismulti;
- scope.value = !scope.value ? (scope.ismulti ? [] : '') : scope.value;
- scope.dataList = [];
- scope.selectList = [];
- scope.containerShow = 0;
- scope.isGetList = false;
- scope.isDefaultVal = false;
- scope.getList = function () {
- $http
- ({
- method: 'get', url: scope.url, params: scope.params
- }).then(function (result) {
- scope.dataList = result.data.Data;
- if (scope.dataList.length > 0) {
- if (scope.value.length > 0) {
- scope.defaultVal(scope.dataList);
- }
- scope.dataList[0].chlidShow = 1;
- }
- });
- };
- scope.$watch("value", function (newVal) {
- if (scope.dataList.length <= 0) {
- if (!scope.isGetList) {
- scope.isGetList = true;
- scope.getList();
- }
- }
- else if (scope.value.length > 0 && !scope.isDefaultVal) {
- scope.defaultVal(scope.dataList);
- }
- }, true);
- scope.defaultVal = function (list) {
- scope.isDefaultVal = true;
- var chlidShow = 0;
- $.each(list, function (index, item) {
- if ($.inArray(item.id, scope.value) >= 0 || item.id == scope.value) {
- item.checked = 1;
- chlidShow = 1;
- //scope.select(item);
- if (scope.selectList.filter(val => val.id == item.id).length <= 0) {
- scope.selectList.push({ name: item.name, id: item.id });
- }
- }
- if (item.childrens != null && item.childrens.length > 0) {
- item.chlidShow = scope.defaultVal(item.childrens);
- }
- });
- return chlidShow;
- };
- scope.showContainer = function () {
- scope.containerShow = Math.abs((scope.containerShow | 0) - 1);
- };
- $(document).on('click', function (e) {
- if (typeof (e.target.className) == "string" && e.target.className.indexOf(scope.className) < 0) {
- scope.$apply(function () {
- scope.containerShow = 0;
- })
- }
- })
- scope.showChildren = function (node) {
- node.chlidShow = Math.abs((node.chlidShow | 0) - 1);
- };
- //选择节点
- scope.check = function (node) {
- if (scope.ismulti == true) {
- //多选
- node.checked = Math.abs((node.checked | 0) - 1);
- scope.select(node);
- if (node.checked == 1 && node.childrens.length > 0) {
- scope.checkChildren(node);
- }
- }
- else {
- //单选
- scope.selectList = [{ name: node.name, id: node.id }];
- scope.value = node.id;//[node.id];
- scope.showContainer();
- }
- };
- scope.checkChildren = function (node) {
- $.each(node.childrens, function (index, item) {
- item.checked = 1;
- scope.select(item);
- if (item.childrens.length > 0) {
- scope.checkChildren(item);
- }
- });
- };
- scope.select = function (node) {
- if (node.checked == 1) {
- if (scope.selectList.filter(val => val.id == node.id).length <= 0) {
- if (!node.isDisabled)
- scope.selectList.push({ name: node.name, id: node.id });
- }
- }
- else {
- scope.selectList = scope.selectList.filter(val => val.id != node.id);
- }
- scope.setValue();
- };
- scope.remove = function (node) {
- scope.selectList = scope.selectList.filter(val => val.id != node.id);
- scope.setValue();
- scope.uncheck(scope.dataList, node.id);
- };
- scope.uncheck = function (list, uncheckId) {
- $.each(list, function (index, item) {
- if (uncheckId) {
- if (item.id === uncheckId) {
- item.checked = 0;
- return;
- }
- }
- else {
- item.checked = 0;
- }
- if (item.childrens.length > 0) {
- scope.uncheck(item.childrens, uncheckId);
- }
- });
- };
- scope.clear = function () {
- scope.selectList = [];
- scope.value = scope.ismulti ? [] : '';
- scope.uncheck(scope.dataList, "");
- };
- scope.setValue = function () {
- scope.value = scope.ismulti ? scope.selectList.map(it => { return it.id }) : (scope.selectList.length > 0 ? scope.selectList[0].id : '');
- };
- //scope.getList();
- }
- }
- }).directive('imgComponent', function ($state, $http, $bsRouterState, $uuid, $bsfiles) {
- return {
- restrict: 'EA',
- require: '?ngModel',
- //作用域
- scope: {
- filerefid: '=',
- filetypeid: '=',
- readonly: '=',
- ismulti: "=?",
- height: '=?',
- imgList: '=?',
- width: '=?'
- },
- //html
- templateUrl: '../js/template/modal-showimg.html',
- //link函数
- link: function (scope) {
- scope.modalId = $uuid.getUUID();
- scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
- scope.imgList = [];
- scope.showIndex = -1;
- scope.height = scope.height || 100;
- scope.width = scope.width || 130;
- //图片附件
- scope.reqFileModel = {
- selectdata: { FileRefID: '', pageindex: 1, pagesize: 10, ptotal: 0 },
- filetype: 1,
- items: [],
- readonly: false,
- typeparams: {
- types: ['jpg', 'bmp', 'png', 'gif', 'jpe', 'jpeg'],
- errormsg: '图片格式必须为*.jpg,*.gif,*.png,*.bmp,*.jpe,*.jpeg等格式'
- }
- };
- scope.$watch('filerefid', function (newVal, oldVal) {
- if (newVal != null) {
- scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
- scope.getImgList();
- }
- });
- scope.getImgList = function () {
- $http
- ({
- method: 'get',
- url: '../../api/common/File/GetFileList',
- params: {
- fileRefId: scope.filerefid,
- fileType: scope.filetypeid,
- pageindex: 1,
- pagesize: 1000
- }
- }).then(function (result) {
- scope.imgList = result.data.Data.Result.rows;
- scope.imgList.forEach(img => {
- if (!img.base64) {
- $http
- ({
- method: 'get',
- url: '../../api/common/File/GetImageBase64',
- params: {
- fileId: img.AttachmentId,
- }
- }).then(function (imgRes) {
- if (imgRes.data.IsSuccess) {
- img.success = true;
- img.base64 = "data:image/png;base64," + imgRes.data.Data.Base64Data;
- img.height = imgRes.data.Data.Height;
- img.width = imgRes.data.Data.Width;
- img.blobUrl = URL.createObjectURL(scope.base64ToBlob(img.base64));
- }
- else {
- img.success = false;
- }
- }, (error) => {
- img.success = false;
- });
- }
- });
- });
- };
- scope.showImg = function (index) {
- scope.img.rotate = 0;
- scope.showIndex = index;
- scope.setBigImgUrl();
- };
- scope.uploadImg = function () {
- scope.reqFileModel.selectdata.FileRefID = scope.filerefid;
- scope.reqFileModel.filetype = scope.filetypeid;
- $bsfiles.addFile(scope.reqFileModel).then(function (fid) {
- scope.getImgList();
- });
- };
- scope.deleteImg = function (fid) {
- if (confirm("是否删除?")) {
- $http({
- url: '../../api/common/File/DeleteFile',
- method: 'GET',
- params: { fileId: fid }
- }).then(function (rq) {
- if (rq.data.IsSuccess) {
- scope.getImgList();
- }
- $alert({
- title: '消息',
- content: rq.data.Message,
- placement: 'top',
- type: 'info',
- show: true,
- duration: 3
- });
- });
- }
- };
- scope.up = function () {
- scope.showIndex -= 1;
- scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
- scope.setBigImgUrl();
- };
- scope.next = function () {
- scope.showIndex += 1;
- scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
- scope.setBigImgUrl();
- };
- scope.zoomIn = function () {
- scope.img.scale += 0.1;
- };
- scope.zoomOut = function () {
- scope.img.scale -= 0.1;
- };
- scope.setBigImgUrl = function () {
- scope.img.isload = scope.imgList[scope.showIndex].success;
- scope.img.url = scope.imgList[scope.showIndex].blobUrl;
- };
- scope.base64ToBlob = function (data) {
- var arr = data.split(','),
- mime = arr[0].match(/:(.*?);/)[1],
- bstr = atob(arr[1]),
- n = bstr.length,
- u8arr = new Uint8Array(n);
- while (n--) {
- u8arr[n] = bstr.charCodeAt(n);
- }
- return new Blob([u8arr], { type: mime });
- }
- }
- }
- });
- })(angular);
|