service.js 306 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485
  1. /**
  2. ---------------------------------------
  3. 方法:bsselectdata //列表选择
  4. 引用:
  5. <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>
  6. 参数说明
  7. data-url:数据源的url地址
  8. data-datatext:数据选择文字双向绑字段
  9. data-dataval:数据选择ID双向绑字段
  10. data-aid:扩展传参数(可空)
  11. ---------------------------------------
  12. 方法:flowaudit //流程提交服务
  13. 引用:
  14. controller('demandupCtrl', function (flowaudit) {
  15. flowaudit.startflow({appid: "",uid: "",flowname:"",onstartSuccess:function(rq){}})
  16. flowaudit.showaudit({pid: "", fid: "", onsuccess: function(){}});
  17. })
  18. 1.startflow开启流程实例
  19. 参数说明:
  20. appid:流程id
  21. uid:用户id
  22. flowname:流程名称用于待办
  23. onstartSuccess:返回function(rq){}
  24. rq: data {
  25. FlowID:流程实例ID,
  26. ProcessID:流程步骤ID,
  27. success:提升是否成功
  28. }
  29. 2.showaudit提交
  30. 参数说明:
  31. pid:环节id
  32. fid:流程实例id
  33. onsuccess:成功调用函数
  34. ---------------------------------------
  35. 方法:pagination //分页
  36. 引用:
  37. <pagination data-pageindex="finddata.pageindex" data-pagesize="finddata.pagesize" data-ptotal="finddata.ptotal"></pagination>
  38. 参数说明:
  39. data-pageindex:选择页面
  40. data-pagesize:页面展示数据条数
  41. data-ptotal:数据总数
  42. ---------------------------------------
  43. 方法:AuthUser //当前人员方法
  44. 引用:controller('demandlistCtrl', function (AuthUser){
  45. AuthUser.getUser();
  46. })
  47. getUser:获取当前登陆人员信息
  48. 返回:{人员信息}
  49. 字段
  50. DGUserID:用户ID
  51. Name:用户名
  52. Mobile:用户手机
  53. DPID:用户机构ID
  54. DPName:用户机构名
  55. DPCode:用户机构代号
  56. ---------------------------------------
  57. 方法:userselect //人员选择框
  58. 引用:
  59. 多选
  60. <span data-textids="test1" data-textnames="test2" data-datausers="test3" data-testguids="test4" userselect><i class="glyphicon glyphicon-zoom-in"></i></span>
  61. 单选
  62. <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>
  63. 参数说明
  64. data-textnames:所选人员的名字拼接字符串双向绑定 例如:"xxx,xxx,xxx"
  65. data-textids:所选人员的DGUserID拼接字符串双向绑定 例如"xxxxxxx,xxxxxx,xxxxxxx"
  66. data-textguids:所选人员的UserID拼接字符串双向绑定 例如"xxxxxxxxxx,xxxxxxxxxx,xxxxxxxxxx"
  67. data-datausers:所选人员的对象双向绑定,若没有使用到该数据,可以在引用的时候设置为 data-datausers="[]"
  68. data-selecttype:人员选择模式,默认为多选 可选值:single/multi
  69. data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
  70. ---------------------------------------
  71. 指令:bsfiles
  72. 必要参数:ngModel
  73. 示例:<bsfiles ng-model="viewdata.reqFileModel" />
  74. 参数格式:
  75. {
  76. selectdata: { FileRefID: '', pageindex: 1, pagesize: 10, ptotal: 0 },//查询参数:FileRefID为文件关联ID
  77. filetype:1,//文件类型
  78. items: [],//列表数据地址
  79. readonly:false,//是否只能查看
  80. canupfileAsync: function () {
  81. var deferred = $q.defer();
  82. if ($scope.item.DemandApplyID == GuidEmpty) {
  83. $scope.asyncSave().then(function (srq) {
  84. deferred.resolve($scope.item.DemandApplyID);
  85. }, function (flasesrq) {
  86. deferred.reject(flasesrq);
  87. });
  88. } else {
  89. deferred.resolve($scope.item.DemandApplyID);
  90. }
  91. return deferred.promise;
  92. }
  93. }
  94. ---------------------------------------
  95. 指令:bsLvtree
  96. 引用:<bs_lvtree ng-model="option"></bs_lvtree>
  97. $scope.option = {
  98. xAxis: [{ id: 0, name: '系统' }, { id: 1, name: '模块' }, { id: 2, name: '应用' }, { id: 3, name: '功能点' }],
  99. 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: '数据查询' },
  100. { id: 'xx1111', xid: 3, pid: 'xx111', name: '工作台' }, { id: 'xx1112', xid: 3, pid: 'xx111', name: '修改申请' }, { id: 'xx1113', xid: 3, pid: 'xx111', name: '查询修改' }
  101. ],
  102. canEdit: false,--是否显示编辑按钮
  103. canChecked: false ---是否显示选择最后一级按钮
  104. btnclick:function(item,type),type-1:新增同级,2:新增子级,3:删除节点,4:主窗口
  105. };
  106. ---------------------------------------
  107. 指令:sysselect 功能选择控件
  108. 必要参数:
  109. textids:选择完成后,返回的ID,格式如"xxx,xxx,xxx"
  110. texttext:选择完成后,返回对应的名称,格式如"xxx,xxx,xxx"
  111. selecteditems:选择完成后,返回选择的集合
  112. 可选参数:
  113. title:弹出模态框的标题
  114. selecttype:选择类型,若不填则默认为选择系统。0-选择系统;1-选择模块;2-选择菜单;3-选择功能点
  115. singlemode:选择模式,若不填则默认为多选模式。 true-单选模式,false-多选模式
  116. notrelated:是否取消关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true(关联)/fasle(不关联)
  117. 示例:
  118. 1:
  119. <button sysselect data-title="菜单选择" data-notrelated="true" data-textids="selectids" data-textnames="selectnames" data-selecteditems="selecteditems" data-selecttype="3">测试</button>
  120. 2:
  121. <label class="input-group">
  122. <input ng-model="sysselect.names" disabled/>
  123. <button sysselect data-title="菜单选择" data-textids="selectids" data-textnames="selectnames" data-selecteditems="selecteditems" data-singlemode="true" data-selecttype="0">测试按钮</button>
  124. </label>
  125. -------------------------------------------------------------------------
  126. 指令:bsselectdataPro
  127. 引用:<button dataoptions='param'>
  128. 参数格式:{
  129. url:'../../api/home/selectlist',
  130. title:'测试选择',
  131. isMulti:false,
  132. selectData:{dictypekey:'字典关系字',dicvalue:'字典值'},
  133. columns:{dickey:'字典数',dicvalue:'字典值',dictypekey:'字典关健类型',dictype:'字典类型'},
  134. selectLabelKey:'dicvalue',
  135. selectValuekey:'dictionaryid',
  136. selectedValueData:'id1,id2',
  137. selectedLabeData:'name1,name2',
  138. selectParams:{}
  139. }
  140. ---------------------------------------------------------------
  141. 服务$payService支付服务调用
  142. 方法 1.payShow(model)开始支付。model:{},字段查看yy_payOrder
  143. 例如:{amt:221.00,payRelID:'xxxxx1',companyID:'8c7d150b-9be7-4a06-a7cb-552a4ddc0ce9',creatorID:$scope.User.Id,commodityName:'测试商品'}
  144. */
  145. (function ($ang) {
  146. 'use strict';
  147. $ang.module('devself.common', []).factory("AuthUser", function ($window, $rootScope, $timeout, $q, $http) {
  148. var lstorage = $window.localStorage;
  149. var authUser = {
  150. islogin: function () {
  151. return lstorage["islogin"] == "1";
  152. },
  153. setlogin: function () {
  154. lstorage["islogin"] = "1";
  155. }, loginout: function () {
  156. lstorage["islogin"] = "0";
  157. }
  158. };
  159. authUser.getUser = function () {
  160. var d_user = {
  161. UserID: lstorage['UserID'],
  162. LoginID: lstorage['LoginID'],
  163. UserName: lstorage['UserName'],
  164. RoleName: lstorage["RoleName"],
  165. CurrentRoleID: lstorage['CurrentRoleID'],
  166. FunctionCodes: lstorage['CurrentFunctionCodes']
  167. };
  168. return d_user;
  169. };
  170. authUser.getExtData = function () {
  171. return angular.fromJson(lstorage['extData'] == "null" ? "{}" : lstorage['extData']);
  172. };
  173. authUser.setExtData = function (a_data) {
  174. lstorage['extData'] = angular.toJson(a_data);
  175. };
  176. authUser.clearExtData = function () {
  177. lstorage['extData'] = null;
  178. };
  179. authUser.setUser = function (d_user) {
  180. if (d_user) {
  181. //if ($rootScope.istkcon != 1) {
  182. // console.info('onservice');
  183. // var connection = new signalR.HubConnectionBuilder().withUrl("/hubs/token?userID=" + d_user.UserObj.UserID).build();
  184. // connection.keepAliveIntervalInMilliseconds = 12e4;
  185. // connection.serverTimeoutInMilliseconds = 6e4 * 60 * 24;
  186. // connection.on("getToken", function (token) {
  187. // lstorage['token'] = token;
  188. // console.info(token);
  189. // });
  190. // connection.start();
  191. //}
  192. lstorage['UserID'] = d_user.UserObj.UserID;
  193. lstorage['LoginID'] = d_user.UserObj.LoginID;
  194. lstorage['UserName'] = d_user.UserObj.UserName;
  195. lstorage['CurrentRoleID'] = d_user.UserObj.CurrentRoleID;
  196. lstorage['token'] = d_user.Token;
  197. console.info(d_user.Token);
  198. lstorage['tokenTime'] = d_user.TokenTime;
  199. lstorage['RoleName'] = d_user.UserObj.RoleName;
  200. if (d_user.UserObj.UserID) {
  201. authUser.setlogin();
  202. authUser.loadFunctionCode();
  203. }
  204. } else {
  205. authUser.loginout();
  206. }
  207. };
  208. authUser.loadFunctionCode = function () {
  209. $http.post('../../api/systemsetting/Account/GetUserFunctionCode', {}).then(function (res) {
  210. lstorage['CurrentFunctionCodes'] = res.data.Data;
  211. });
  212. };
  213. authUser.clearUser = function () {
  214. lstorage['UserID'] = null;
  215. lstorage['LoginID'] = null;
  216. lstorage['UserName'] = null;
  217. lstorage['CurrentRoleID'] = null;
  218. lstorage['token'] = null;
  219. authUser.loginout();
  220. authUser.clearExtData();
  221. };
  222. authUser.dofunAfterLogin = function () {
  223. var defer = $q.defer();
  224. $timeout(function () {
  225. if (authUser.islogin()) {
  226. defer.resolve(authUser.getUser());
  227. }
  228. }, 1000);
  229. return defer.promise;
  230. };
  231. return authUser;
  232. }).factory('authInterceptor', function ($q, $window) {
  233. var lstorage = $window.localStorage;
  234. return {
  235. request: function (config) {
  236. config.headers = config.headers || {};
  237. if (lstorage['token']) {
  238. config.headers.authorization = 'Bearer ' + lstorage['token'];
  239. }
  240. return config;
  241. },
  242. response: function (res) {
  243. if (res.headers('ServiceToken')) {
  244. lstorage['token'] = res.headers('ServiceToken');
  245. }
  246. return res;
  247. },
  248. responseError: function (response) {
  249. var deferred = $q.defer();
  250. if (response.status == 401) {
  251. window.location.href = "/app/main/index.html#!/login";
  252. deferred.reject(response);
  253. } else {
  254. return deferred.reject(response);
  255. }
  256. }
  257. };
  258. }).directive('functionCode', function (AuthUser) {
  259. var directiveObject = {
  260. restrict: 'A',
  261. link: function (scope, element, attr, controller) {
  262. if (!AuthUser.getUser().FunctionCodes || AuthUser.getUser().FunctionCodes.split(",").indexOf(attr.functionCode) < 0) {
  263. element.css("display", "none");
  264. }
  265. }
  266. };
  267. return directiveObject;
  268. }).directive('thSelectAll', function () {
  269. var directiveObject = {
  270. restrict: 'A',
  271. template: '<input type="checkbox" ng-click="checkAll()" />',
  272. scope: {
  273. datalist: '='
  274. },
  275. link: function (scope, element, attr, controller) {
  276. /* scope.allchecked = false;*/
  277. var selectAllbox = element.find('input[type="checkbox"]');
  278. scope.checkAll = function () {
  279. /*if (scope.allchecked == false) {
  280. scope.allchecked = true;
  281. } else {
  282. scope.allchecked = false;
  283. }*/
  284. if (scope.datalist) {
  285. angular.forEach(scope.datalist, function (val) {
  286. val.rowChecked = selectAllbox.prop("checked");
  287. });
  288. }
  289. };
  290. }
  291. };
  292. return directiveObject;
  293. }).directive('bsselectdata', function ($http, $modal) {
  294. var directiveObject = {
  295. restrict: 'EAC',
  296. scope: {
  297. dataval: '=',
  298. datatext: '=',
  299. title: '@'
  300. },
  301. link: function (scope, element, attr, controller) {
  302. if (angular.isDefined(attr['url']) && angular.isDefined(attr['dataval']) && angular.isDefined(attr['datatext'])) {
  303. var sdModalController = function ($scope) {
  304. //选择模式,默认单选;单选-single/多选-multi
  305. //判断是否为多选模式
  306. $scope.isMulti = attr['selecttype'] == "multi" ? true : false;
  307. //扩展Array类,通过员工号判断数组中是否存在某元素
  308. Array.prototype.contains = function (obj) {
  309. var i = this.length;
  310. while (i--) {
  311. if (this[i].val === obj.val) {
  312. return i;
  313. }
  314. }
  315. return -1;
  316. };
  317. $scope.finddata = {
  318. aid: angular.isDefined(attr['aid']) ? attr['aid'] : '', pageIndex: 1, pageSize: 5, ptotal: 0
  319. };
  320. //监视页面的变化
  321. $scope.$watch("finddata.pageIndex", function (newVal, oldVal) {
  322. if ($scope.finddata.ptotal > 0) {
  323. $scope.loadData();
  324. }
  325. });
  326. attr.$observe('aid', function (newValue, oldValue) {
  327. if (newValue) $scope.finddata.aid = newValue;
  328. });
  329. //多选缓存
  330. $scope.selecttemp = [];
  331. //多选模式中单击方法
  332. $scope.selectOne = function (item) {
  333. if (item.checked && $scope.selecttemp.indexOf(item) < 0) {
  334. $scope.selecttemp.push(item)
  335. }
  336. if (!item.checked) {
  337. var index = $scope.selecttemp.indexOf(item);
  338. if (index > -1) {
  339. $scope.selecttemp.splice(index, 1)
  340. }
  341. }
  342. };
  343. $scope.data = {
  344. findkey: '', items: [], radioit: null
  345. };
  346. $scope.title = scope.title;
  347. $scope.selectedData = function () {
  348. if ($scope.data.radioit) {
  349. scope.dataval = $scope.data.radioit.val;
  350. scope.datatext = $scope.data.radioit.label;
  351. }
  352. if ($scope.isMulti) {
  353. var valarr = [];
  354. var namearr = [];
  355. angular.forEach($scope.selecttemp, function (item) {
  356. valarr.push(item.val);
  357. namearr.push(item.label);
  358. });
  359. scope.dataval = valarr.join(",");
  360. scope.datatext = namearr.join(",");
  361. }
  362. $scope.$hide();
  363. };
  364. $scope.findData = function () {
  365. $scope.loadData();
  366. };
  367. $scope.search = function () {
  368. $scope.loadData();
  369. };
  370. $scope.loadData = function () {
  371. $http({
  372. method: 'Post',
  373. url: attr['url'],
  374. data: angular.extend($scope.finddata, { findkey: $scope.data.findkey })
  375. }).then(function (req) {
  376. $scope.data.items = req.data.Data.rows;
  377. $scope.finddata.ptotal = req.data.Data.total;
  378. //判断是否为多选,若是,则初始化checkbox选择状态
  379. if ($scope.isMulti) {
  380. $scope.multiselectFilter($scope.data.Data)
  381. }
  382. });
  383. };
  384. //初始化checkbox选择状态,主要用于分页后记录已选择的人员
  385. $scope.multiselectFilter = function (list) {
  386. angular.forEach(list, function (user) {
  387. if ($scope.selecttemp.contains(user) >= 0) {
  388. user.checked = true;
  389. }
  390. })
  391. };
  392. $scope.loadData();
  393. };
  394. sdModalController.$inject = ['$scope'];
  395. var sdModal = $modal({
  396. scope: scope,
  397. controller: sdModalController,
  398. templateUrl: '../js/template/modal_selectdata.html',
  399. show: false
  400. });
  401. //data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
  402. if (attr['isNotRelated']) {
  403. element.on("click", function () {
  404. sdModal.$promise.then(sdModal.show);
  405. });
  406. element.css({ cursor: 'pointer' });
  407. } else {
  408. element.parent().on("click", function () {
  409. sdModal.$promise.then(sdModal.show);
  410. });
  411. element.css({ cursor: 'pointer' });
  412. element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
  413. }
  414. }
  415. }
  416. };
  417. return directiveObject;
  418. }).provider("flowaudit", function () {
  419. //流程提交参数修改成可以在引用配置下面操作地址,用来解决不同应用调用问题
  420. var defaults = this.defaults = {
  421. appid: '', fid: '', pid: '', uid: '',
  422. flowurl: '../../api/systemsetting/flow/getflownextinfo',
  423. userurl: '../../api/systemsetting/flow/getflownextusers',
  424. putnexturl: '../../api/systemsetting/flow/putnextsteps',
  425. startflowurl: '../../api/systemsetting/flow/startflow',
  426. todourl: '../../api/systemsetting/flow/todoflowlist',
  427. };
  428. this.$get = function ($http, $modal, $alert, $q, $filter) {
  429. var faudit = {
  430. onnextsuccess: false,
  431. afuns: ''
  432. };
  433. angular.extend(faudit, defaults);
  434. faudit.startflow = function (sparams, option) {
  435. angular.extend(faudit, option);
  436. faudit.appid = sparams.appid;
  437. faudit.uid = sparams.uid;
  438. $http({
  439. url: faudit.startflowurl,
  440. method: 'post',
  441. data: { appId: faudit.appid, formidList: sparams.formidList, flowName: sparams.flowname, workBy: faudit.uid }
  442. }).then(sparams.onstartSuccess);
  443. };
  444. faudit.startflowAsync = function (sparams, option) {
  445. angular.extend(faudit, option);
  446. faudit.appid = sparams.appid;
  447. faudit.uid = sparams.uid;
  448. var deferred = $q.defer();
  449. $http({
  450. url: faudit.startflowurl,
  451. method: 'post',
  452. data: { appId: faudit.appid, formidList: sparams.formidList, flowName: sparams.flowname, workBy: faudit.uid }
  453. }).then(
  454. function (TureRq) {
  455. if (TureRq.data.IsSuccess) {
  456. deferred.resolve(TureRq);
  457. } else {
  458. deferred.reject(TureRq);
  459. }
  460. }, function (FalseRq) {
  461. deferred.reject(TureRq);
  462. }
  463. );
  464. return deferred.promise;
  465. };
  466. var faModalController = function ($scope, $filter, AuthUser) {
  467. $scope.title = '流程处理';
  468. $scope.flowdata = { selectedaction: false, flowInfo: {}, flowUsers: [], comment: "" };
  469. $scope.fauditInfo = faudit;
  470. $scope.loadflow = function () {
  471. $http({
  472. method: 'GET',
  473. url: $scope.fauditInfo.flowurl,
  474. params: { processId: $scope.fauditInfo.pid[0], afuns: $scope.fauditInfo.afuns }
  475. }).then(function (rq) {
  476. if (rq.data.IsSuccess) {
  477. $scope.flowdata.flowInfo = rq.data.Data;
  478. //flowtp工作流始终返回null,无法用于判断是否开始节点
  479. $scope.flowdata.comment = "同意";
  480. $scope.flowdata.selectedaction = $scope.flowdata.flowInfo.nextactions[0];
  481. } else {
  482. $alert({
  483. title: '消息',
  484. content: rq.data.Message,
  485. placement: 'centre',
  486. type: 'info',
  487. show: true,
  488. duration: 3
  489. });
  490. }
  491. });
  492. };
  493. $scope.$watch("flowdata.selectedaction", function (newVal, oldVal) {
  494. if (!$scope.flowdata.selectedaction) {
  495. return false;
  496. }
  497. $scope.flowdata.comment = $scope.fauditInfo.comment || $scope.flowdata.selectedaction.aname;
  498. if ($scope.flowdata.selectedaction.pusertype == "any") {
  499. return true;
  500. }
  501. $scope.flowdata.comment = $scope.flowdata.selectedaction.aname;
  502. $scope.flowdata.flowUsers.length = 0;
  503. $http({
  504. method: 'GET',
  505. url: $scope.fauditInfo.userurl,
  506. params: { processId: $scope.fauditInfo.pid[0], actionId: $scope.flowdata.selectedaction.actionid }
  507. }).then(function (rq) {
  508. //赋值时判断当前选中的步骤ID是否为改变值中的步骤ID,防止网络差时错误显示用户列表-hyl
  509. if (rq.data.IsSuccess && $scope.flowdata.selectedaction.actionid == newVal.actionid) {
  510. $scope.flowdata.flowUsers = rq.data.Data;
  511. angular.forEach($scope.flowdata.flowUsers, function (user) {
  512. user.checked = true;
  513. });
  514. } else {
  515. $alert({
  516. title: '消息',
  517. content: rq.data.Message,
  518. placement: 'top',
  519. type: 'error',
  520. show: true,
  521. duration: 3
  522. });
  523. }
  524. });
  525. });
  526. $scope.filterUserchecked = function (val) {
  527. return val.checked;
  528. };
  529. //全选,反选功能
  530. $scope.isAll = false;
  531. $scope.temparr = [];
  532. $scope.selectAll = function () {
  533. //判断单选或多选:1为单选,2和其它为多选
  534. if ($scope.flowdata.selectedaction.userchosemode == 1 && $scope.isAll) {
  535. $scope.isAll = false;
  536. $alert({
  537. title: '提示',
  538. content: '该环节用户为单选模式!',
  539. placement: 'top',
  540. type: 'warning',
  541. show: true,
  542. duration: 3
  543. });
  544. }
  545. angular.forEach($scope.flowdata.flowUsers, function (user) {
  546. user.checked = $scope.isAll;
  547. });
  548. };
  549. $scope.selectOne = function (it) {
  550. var count = 0;
  551. angular.forEach($scope.flowdata.flowUsers, function (user) {
  552. //判断单选或多选:1为单选,2和其它为多选
  553. if ($scope.flowdata.selectedaction.userchosemode == 1) {
  554. count = 1;
  555. if (it != user) user.checked = false;
  556. } else {
  557. if (user.checked) count++;
  558. }
  559. });
  560. if (count == 0) $scope.isAll = false;
  561. if (count == $scope.flowdata.flowUsers.length) $scope.isAll = true;
  562. };
  563. //全选,反选功能结束
  564. $scope.tonextstep = function () {
  565. var arruser = [];
  566. if ($scope.flowdata.comment.length == 0) {
  567. if (!($scope.flowdata.flowInfo.flowtp == 0 || $scope.flowdata.selectedaction.flowtp == 2 || $scope.flowdata.selectedaction.pusertype == 'any')) {
  568. $alert({
  569. title: '提示',
  570. content: '环节意见不能为空!',
  571. placement: 'top',
  572. type: 'warning',
  573. show: true,
  574. duration: 3
  575. });
  576. return;
  577. }
  578. }
  579. angular.forEach($scope.flowdata.flowUsers, function (u) {
  580. if (u.checked) {
  581. this.push(u.fuserid);
  582. }
  583. }, arruser);
  584. if (arruser.length == 0 && $scope.flowdata.selectedaction.flowtp != 2 && $scope.flowdata.selectedaction.pusertype != 'any') {
  585. $alert({
  586. title: '提示',
  587. content: '请选择下一步处理人!',
  588. placement: 'top',
  589. type: 'warning',
  590. show: true,
  591. duration: 3
  592. });
  593. return;
  594. }
  595. $http({
  596. method: 'post', url: $scope.fauditInfo.putnexturl,
  597. data: {
  598. processIdList: $scope.fauditInfo.pid, actionId: $scope.flowdata.selectedaction.actionid,
  599. users: arruser.join(','), comment: $scope.flowdata.comment, workby: AuthUser.getUser().UserID,
  600. nextusertype: $scope.flowdata.selectedaction.pusertype
  601. }
  602. }).then(function (rq) {
  603. $scope.$hide();
  604. if (rq.data.IsSuccess) {
  605. $alert({
  606. title: '成功',
  607. content: rq.data.Message,
  608. placement: 'top',
  609. type: 'success',
  610. show: true,
  611. duration: 3
  612. });
  613. if (angular.isFunction($scope.fauditInfo.onsuccess)) {
  614. $scope.fauditInfo.onsuccess();
  615. }
  616. }
  617. else {
  618. $alert({
  619. title: '失败',
  620. content: rq.data.Message,
  621. placement: 'top',
  622. type: 'info',
  623. show: true,
  624. duration: 15
  625. });
  626. }
  627. });
  628. };
  629. $scope.loadflow();
  630. };
  631. faModalController.$inject = ['$scope', '$filter', 'AuthUser'];
  632. var faModal = $modal({
  633. controller: faModalController, resolve: {
  634. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  635. $ocLazyLoad.load('../js/template/modal_flowaudit.css');
  636. return true;
  637. }]
  638. }, templateUrl: '../js/template/modal_flowaudit.html', show: false
  639. });
  640. faudit.showaudit = function (option) {
  641. if (option.pid && option.pid.length > 0) {
  642. angular.extend(faudit, option);
  643. faModal.$promise.then(faModal.show);
  644. } else if (option.fid && option.fid.length > 0) {
  645. $http({
  646. method: 'post', url: faudit.todourl,
  647. data: {
  648. instanceIDList: option.fid
  649. }
  650. }).then(function (rq) {
  651. if (rq.data.IsSuccess) {
  652. var todoList = rq.data.Data;
  653. var isnopid = false;
  654. angular.forEach(option.fid, function (x) {
  655. if ($filter('filter')(todoList, function (w) {
  656. return w.fid == x
  657. }).length == 0) {
  658. isnopid = true;
  659. return false;
  660. }
  661. });
  662. if (isnopid) {
  663. $alert({
  664. title: '提示',
  665. content: '部分记录并没有推送到您的个人待办,无法审核。',
  666. placement: 'top',
  667. type: 'info',
  668. show: true,
  669. duration: 3
  670. });
  671. return;
  672. }
  673. faudit.pid = $.map(todoList, function (x) { return x.pid });
  674. angular.extend(faudit, option);
  675. faModal.$promise.then(faModal.show);
  676. }
  677. });
  678. }
  679. };
  680. return faudit;
  681. };
  682. }).directive('pagination', function () {
  683. return {
  684. restrict: 'EA',
  685. //作用域
  686. scope: {
  687. pageindex: '=', //等号是双向绑定 选中页面
  688. pagesize: '=',//最大页面
  689. loadPage: '&?',//翻页函数
  690. ptotal: '=', //数据长度
  691. mergetotal: '=?' //合并行后显示的总数
  692. },
  693. //html
  694. templateUrl: '../js/template/pagination.html',
  695. //替换
  696. replace: true,
  697. //link函数
  698. link: function ($scope) {
  699. $scope.numbers = [10, 30, 50, 100, 300, 500];
  700. $scope.initpage = function () {
  701. //分页总数
  702. $scope.pages = Math.ceil($scope.ptotal / $scope.pagesize); //分页数
  703. $scope.newPages = $scope.pages > 5 ? 5 : $scope.pages;
  704. $scope.pageList = [];
  705. //$scope.pageindex = 1;
  706. //分页要repeat的数组
  707. for (var i = 0; i < $scope.newPages; i++) {
  708. $scope.pageList.push(i + 1);
  709. }
  710. };
  711. //监测total数据数量的变化
  712. $scope.$watch("ptotal", function (newVal, oldVal) {
  713. $scope.initpage();
  714. if ($scope.pageindex > $scope.pages) {
  715. $scope.selectPage($scope.pages);
  716. }
  717. });
  718. //如果pageindex和pagesize同时监视,那么遇到二维表格,表头和内容就必须都重新加载,会影响翻页的性能,分开监视也可以达到相同效果,但可以绑定不同的查询方法,解决二维表格的问题
  719. $scope.$watch("pageindex", function (newVal, oldVal) {
  720. if ($scope.loadPage) {
  721. $scope.loadPage();
  722. } else {
  723. $scope.$parent.search();
  724. }
  725. if ($scope.pageindex > $scope.pages) {
  726. $scope.selectPage($scope.pages);
  727. }
  728. });
  729. $scope.$watch("pagesize", function (newVal, oldVal) {
  730. if (newVal == oldVal) {
  731. return;
  732. }
  733. $scope.initpage();
  734. $scope.$parent.search();
  735. /*var ctrlName = $scope.$parent.panedata.controller;
  736. $scope.$emit("tabReloadData", { name: ctrlName, data: 1 });*/
  737. if ($scope.pageindex > $scope.pages) {
  738. $scope.selectPage($scope.pages);
  739. }
  740. });
  741. //打印当前选中页索引
  742. $scope.selectPage = function (page) {
  743. //不能小于1大于最大
  744. if (page < 1 || page > $scope.pages) return;
  745. //最多显示分页数5
  746. if (page > 2) {
  747. //因为只显示5个页数,大于2页开始分页转换
  748. var newpageList = [];
  749. for (var i = (page - 3); i < ((page + 2) > $scope.pages ? $scope.pages : (page + 2)); i++) {
  750. newpageList.push(i + 1);
  751. }
  752. $scope.pageList = newpageList;
  753. }
  754. if (page >= 1 && page <= 2) {
  755. var newpageList = [];
  756. for (var i = 1; i <= ($scope.pages > 5 ? 5 : $scope.pages); i++) {
  757. newpageList.push(i);
  758. }
  759. $scope.pageList = newpageList;
  760. }
  761. $scope.pageindex = page;
  762. //$scope.isActivePage();
  763. //console.log("选择的页:" + page);
  764. };
  765. //设置当前选中页样式
  766. $scope.isActivePage = function (page) {
  767. return $scope.pageindex == page;
  768. };
  769. //第一页
  770. $scope.PreviousFirst = function () {
  771. if ($scope.pageindex == 1) {
  772. return false;
  773. } else {
  774. $scope.selectPage(1);
  775. }
  776. };
  777. //上一页
  778. $scope.Previous = function () {
  779. $scope.selectPage($scope.pageindex - 1);
  780. };
  781. //下一页
  782. $scope.Next = function () {
  783. $scope.selectPage($scope.pageindex + 1);
  784. };
  785. //最后一页
  786. $scope.NextLast = function () {
  787. $scope.selectPage($scope.pages);
  788. };
  789. //跳转
  790. $scope.skipPage = function (skipPageNumber) {
  791. var reg = /^[0-9]+$/;
  792. var r = reg.test(skipPageNumber);
  793. if (!isNaN(skipPageNumber) && r) {
  794. if (skipPageNumber <= $scope.pages) {
  795. $scope.skipError = true;
  796. $scope.selectPage(skipPageNumber);
  797. } else {
  798. $scope.skipError = false;
  799. alert("填入页数不能大于" + $scope.pages);
  800. }
  801. } else {
  802. $scope.skipError = true;
  803. alert("输入非法,请输入正确的页数");
  804. }
  805. }
  806. }
  807. }
  808. }).directive('titlemenu', function ($state, $http, $bsRouterState) {
  809. return {
  810. restrict: 'EA',
  811. //作用域
  812. scope: {
  813. parentno: '=' //父级no
  814. },
  815. //html
  816. templateUrl: '../js/template/title-menu.html',
  817. //替换
  818. replace: true,
  819. transclude: true,
  820. //link函数
  821. link: function (scope, element, attrs, controllers) {
  822. var inTab = $bsRouterState.$getRouteType() == 'tab';
  823. var menuno = inTab ? scope.$parent.name : $state.current.name;
  824. $http.post('../../api/menumanage/FindMenus', {
  825. menuno: menuno,
  826. parentNo: scope.parentno == undefined ? "" : scope.parentno
  827. }).then(function (rq) {
  828. scope.items = [];
  829. for (var i = rq.data.item.length - 1; i >= 0; i--) {
  830. scope.items.push(rq.data.item[i]);
  831. }
  832. });
  833. scope.back = function () {
  834. if (!inTab) {
  835. history.go(-1);
  836. }
  837. };
  838. scope.goto = function (menuno) {
  839. if (!inTab) {
  840. if (menuno.indexOf("home") > -1 || menuno.indexOf("homeE") > -1)
  841. $state.go(menuno);
  842. }
  843. }
  844. }
  845. }
  846. }).directive("bsflowstep", function ($http) {
  847. return {
  848. restrict: 'EA',
  849. //作用域
  850. scope: {
  851. fid: '='//数据长度
  852. },
  853. //html
  854. templateUrl: '../js/template/t_flowstep.html',
  855. //替换
  856. replace: true,
  857. //link函数
  858. link: function (scope, element, attr, controller) {
  859. if (angular.isDefined(scope.fid)) {
  860. var url = attr['url'] || '../../api/systemsetting/flow/getflowsteps';
  861. $http({ url: url, method: 'GET', params: { flowId: scope.fid } }).then(function (rq) {
  862. if (rq.data.IsSuccess) {
  863. scope.items = rq.data.Data;
  864. }
  865. });
  866. }
  867. }
  868. }
  869. }).directive('userselect', function ($http, $modal, $alert, AuthUser) {
  870. var directiveObject = {
  871. restrict: 'EAC',
  872. scope: {
  873. textids: '=',//已选择的人员ID
  874. textnames: '=',//已选择的人员
  875. textguids: '=',//已选择的人员guid
  876. datausers: '=',//已选人员对象
  877. },
  878. link: function (scope, element, attr, controller) {
  879. //判断绑定的变量是否已定义
  880. if (angular.isDefined(attr['textids']) && angular.isDefined(attr['textnames'])) {
  881. var usModalController = function ($scope) {
  882. //将参数传递的方式改成form
  883. $scope.postCfg = {
  884. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  885. transformRequest: function (data) {
  886. return $.param(data);
  887. }
  888. };
  889. $scope.title = '人员选择';
  890. $scope.rootDPID = "";
  891. $scope.selectdzzdm = AuthUser.getUser().gddwdm;//当前选中的组织机构
  892. $scope.$watch("selectdzzdm", function (newVal, oldVal) {
  893. $scope.clickDep();
  894. });
  895. //人员列表
  896. $scope.userSelectList = [];
  897. //部门列表
  898. $scope.depList = [];
  899. //选择模式,默认多选;单选/多选
  900. $scope.selecttype = attr['selecttype'] == "single" ? attr['selecttype'] : "multi";
  901. //如果datausers没有定义,赋值个空数组
  902. if (angular.isUndefined(scope.datausers)) {
  903. scope.datausers = [];
  904. }
  905. //待添加人员列表
  906. $scope.tempAdd = [];
  907. //拷贝对象,单次赋值给右边已选列表
  908. $scope.rightusers = angular.copy(scope.datausers);
  909. //确定选择按钮,统计所选择的人员,按照"xxxx,xxxx,xxxx"模板拼接
  910. $scope.selectedData = function () {
  911. var isFirst = true;
  912. scope.textnames = "";
  913. scope.textguids = "";
  914. scope.textids = "";
  915. angular.forEach($scope.rightusers, function (item) {
  916. if (isFirst) {
  917. scope.textnames = item.name;
  918. scope.textids = item.dguserid;
  919. scope.textguids = item.id;
  920. isFirst = false;
  921. } else {
  922. scope.textnames += ',' + item.name;
  923. scope.textids += ',' + item.dguserid;
  924. scope.textguids += ',' + item.id;
  925. }
  926. });
  927. scope.datausers = $scope.rightusers;
  928. $scope.$hide();
  929. };
  930. //添加已选择的人员
  931. $scope.addUser = function () {
  932. var isSingle = $scope.selecttype == "single";//判断是否为单选模式
  933. var isFlag = $scope.tempAdd.length <= 1 && $scope.rightusers.length == 0;//判断已选人数是否小于等于1
  934. if ((isSingle && isFlag) || !isSingle) {
  935. angular.forEach($scope.tempAdd, function (item) {
  936. //准备添加的人员是否在右边列表存在,如果存在,为false,不添加到右侧
  937. var isAdd = true;
  938. angular.forEach($scope.rightusers, function (user) {
  939. if (item.id == user.id) {
  940. isAdd = false;
  941. }
  942. });
  943. if (isAdd) {
  944. $scope.rightusers.push(item);
  945. }
  946. })
  947. } else {
  948. $alert({
  949. title: '错误:',
  950. content: '只可选择一名人员!',
  951. placement: 'center',
  952. type: 'info',
  953. container: '#userselect1',
  954. show: true,
  955. duration: 3
  956. });
  957. }
  958. };
  959. //删除已选择的人员
  960. $scope.deleteUser = function () {
  961. angular.forEach($scope.tempSelected, function (item) {
  962. var index = $scope.rightusers.indexOf(item);
  963. $scope.rightusers.splice(index, 1);
  964. })
  965. };
  966. //人员查询
  967. $scope.searchUser = function () {
  968. if (angular.isDefined($scope.searchParam) && $scope.searchParam != "" && $scope.searchParam != null) {
  969. $scope.loadUser();
  970. } else {
  971. $alert({
  972. title: '消息:',
  973. content: '请输入要查询的人员名',
  974. placement: 'center',
  975. type: 'info',
  976. container: '#userselect1',
  977. show: true,
  978. duration: 3
  979. });
  980. return false;
  981. }
  982. };
  983. //点击部门,通过部门ID获取人员列表
  984. $scope.clickDep = function () {
  985. $scope.searchParam = "";//查询条件清空
  986. $scope.loadUser();
  987. };
  988. $scope.loadUser = function () {
  989. $scope.isloading = true;
  990. $scope.userSelectList = [];
  991. $http.get("../../api/systemsetting/User/GetUserListByUserName", {
  992. params: {
  993. 'userName': $scope.searchParam,
  994. 'dpId': $scope.selectdzzdm
  995. }
  996. }).then(function (result) {
  997. $scope.userSelectList = result.data.Data;//返回的人员列表赋值给变量userSelectList
  998. $scope.isloading = false;
  999. }, function () {
  1000. $alert({
  1001. title: '错误:',
  1002. content: '查询人员列表失败,服务器错误',
  1003. placement: 'center',
  1004. type: 'info',
  1005. container: '#userselect1',
  1006. show: true,
  1007. duration: 3
  1008. });
  1009. });
  1010. };
  1011. };
  1012. usModalController.$inject = ['$scope'];
  1013. var usModal = $modal({
  1014. scope: scope,
  1015. controller: usModalController,
  1016. resolve: {
  1017. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  1018. $ocLazyLoad.load('../js/template/modal_userselect.css');
  1019. return true;
  1020. }]
  1021. },
  1022. templateUrl: '../js/template/modal_userselect.html',
  1023. show: false,
  1024. animation: 'am-fade-and-slide-top'
  1025. });
  1026. //data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
  1027. if (attr['isNotRelated']) {
  1028. element.on("click", function () {
  1029. usModal.$promise.then(usModal.show);
  1030. });
  1031. element.css({ cursor: 'pointer' });
  1032. } else {
  1033. element.parent().on("click", function () {
  1034. usModal.$promise.then(usModal.show);
  1035. });
  1036. element.css({ cursor: 'pointer' });
  1037. element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
  1038. }
  1039. }
  1040. }
  1041. };
  1042. return directiveObject;
  1043. }).directive('dpselect', function ($http, $modal, $alert) {
  1044. var directiveObject = {
  1045. restrict: 'EAC',
  1046. scope: {
  1047. dpid: '=',//已选择的部门ID
  1048. dpname: '=',//已选择的部门名称
  1049. dpitem: '=',//已选择的部门对象
  1050. },
  1051. link: function (scope, element, attr, controller) {
  1052. //判断绑定的变量是否已定义
  1053. if (angular.isDefined(attr['dpid']) && angular.isDefined(attr['dpname'])) {
  1054. var dpModalController = function ($scope) {
  1055. //将参数传递的方式改成form
  1056. $scope.postCfg = {
  1057. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  1058. transformRequest: function (data) {
  1059. return $.param(data);
  1060. }
  1061. };
  1062. $scope.title = '部门选择';
  1063. $scope.rootDPID = "";
  1064. //当前展开的部门
  1065. $scope.curdepid = "";
  1066. //部门列表
  1067. $scope.depList = [];
  1068. $scope.dpitem = {
  1069. selectDp: ""
  1070. };
  1071. $scope.dpresultlist = [];
  1072. //如果datausers没有定义,赋值个空数组
  1073. if (angular.isUndefined(scope.dpitem)) {
  1074. scope.dpitem = null;
  1075. }
  1076. //初始化树列表,获取根节点
  1077. $scope.initTree = function () {
  1078. $http.post("../../api/dsUser/GetDPbyParentDPID", { 'DPID': $scope.rootDPID }, $scope.postCfg).then(function (result) {
  1079. $scope.depList = result.data;
  1080. }, function () {
  1081. $alert({
  1082. title: '错误:',
  1083. content: '获取根节点失败,服务器错误',
  1084. placement: 'center',
  1085. type: 'info',
  1086. container: '#userselect1',
  1087. show: true,
  1088. duration: 3
  1089. });
  1090. });
  1091. };
  1092. //加载子部门节点
  1093. $scope.loadChildDep = function (item) {
  1094. $scope.searchParam = "";//查询条件清空
  1095. if (!item.isExpand)//如果该节点未展开
  1096. {
  1097. item.isExpand = true;
  1098. $scope.getDPByParentID(item);
  1099. } else {
  1100. item.isExpand = false;
  1101. }
  1102. };
  1103. //根据父部门获取子部门列表
  1104. $scope.getDPByParentID = function (item) {
  1105. $http.post("../../api/user/GetDpListByParentID", { 'parentDPID': item.dpid }).then(function (result) {
  1106. item.childDepList = result.data.item;
  1107. }, function () {
  1108. $alert({
  1109. title: '错误:',
  1110. content: '查询子部门列表失败,服务器错误',
  1111. placement: 'center',
  1112. type: 'info',
  1113. container: '#userselect1',
  1114. show: true,
  1115. duration: 3
  1116. });
  1117. });
  1118. };
  1119. $scope.initTree();
  1120. //点击部门
  1121. $scope.clickDep = function (item, $event) {
  1122. if ($scope.curdepid != item.DPID) {
  1123. $scope.searchParam = "";//查询条件清空
  1124. $scope.dpresultlist = [];
  1125. $scope.dpresultlist.push(item);
  1126. $scope.curdepid = item.DPID;
  1127. $scope.selectDP = item;
  1128. }
  1129. };
  1130. //点击选择部门
  1131. $scope.selectedDp = function () {
  1132. if ($scope.selectDP != null) {
  1133. scope.dpid = $scope.selectDP.DPID;
  1134. scope.dpname = $scope.selectDP.DPName;
  1135. scope.dpitem = $scope.selectDP;
  1136. dpModal.$promise.then(dpModal.hide);
  1137. }
  1138. };
  1139. //根据输入字段查询部门
  1140. $scope.searchDP = function () {
  1141. if (angular.isDefined($scope.searchParam) && $scope.searchParam != "" && $scope.searchParam != null) {//查询条件不为空时进行查询
  1142. $scope.isloading = true;
  1143. $scope.dpresultlist = [];
  1144. $http.get("../../api/SysManage/findTargetDPlists", { params: { 'searchParam': $scope.searchParam } }).then(function (result) {
  1145. $scope.dpresultlist = result.data.list;
  1146. $scope.isloading = false;
  1147. }, function () {
  1148. $alert({
  1149. title: '错误:',
  1150. content: '查询部门失败,服务器错误',
  1151. placement: 'center',
  1152. type: 'info',
  1153. show: true,
  1154. duration: 3
  1155. });
  1156. });
  1157. }
  1158. };
  1159. };
  1160. dpModalController.$inject = ['$scope'];
  1161. var dpModal = $modal({
  1162. scope: scope,
  1163. controller: dpModalController,
  1164. resolve: {
  1165. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  1166. $ocLazyLoad.load('../js/template/modal_userselect.css');
  1167. return true;
  1168. }]
  1169. },
  1170. templateUrl: '../js/template/modal_dpselect.html',
  1171. show: false,
  1172. animation: 'am-fade-and-slide-top'
  1173. });
  1174. //data-isNotRelated:是否关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true/fasle(不关联)
  1175. if (attr['isNotRelated']) {
  1176. element.on("click", function () {
  1177. dpModal.$promise.then(dpModal.show);
  1178. });
  1179. element.css({ cursor: 'pointer' });
  1180. } else {
  1181. element.parent().on("click", function () {
  1182. dpModal.$promise.then(dpModal.show);
  1183. });
  1184. element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
  1185. element.css({ cursor: 'pointer' });
  1186. }
  1187. }
  1188. }
  1189. };
  1190. return directiveObject;
  1191. }).factory("$excel", function ($modal, $http, $window, $alert, $q) {
  1192. var fileObject = {
  1193. configdata: {
  1194. uploadurl: '../../api/common/Common/ImportExcel',
  1195. typeparams: false,//为false则可选择所有文件,限制格式:{types:['jpg','bmp','jpe','jpeg'],errormsg:'图片格式必须为*.jpg,*.bmp,*.jpe,*.jpeg等格式'}
  1196. },
  1197. fModal: {},
  1198. addDefer: {}
  1199. };
  1200. fileObject.init = function (config) {
  1201. //fileObject.configdata
  1202. angular.extend(fileObject.configdata, config);
  1203. };
  1204. fileObject.addFile = function (fileoption) {
  1205. fileObject.addDefer = $q.defer();
  1206. //这里才传值到弹出页面
  1207. if (angular.isDefined(fileoption)) {
  1208. fileObject.fileoption = fileoption;
  1209. }
  1210. if (fileoption.uploadurl != null && fileoption.uploadurl != undefined) {
  1211. fileObject.configdata.uploadurl = fileoption.uploadurl;
  1212. }
  1213. fileObject.fModal.$promise.then(fileObject.fModal.show);
  1214. return fileObject.addDefer.promise;
  1215. };
  1216. fileObject.uploadMethod = function (file, scope, Upload, AuthUser) {
  1217. //fileObject.fileoption.columns.file = file;
  1218. //alert(scope);
  1219. Upload.upload({
  1220. url: fileObject.configdata.uploadurl,
  1221. data: { file: file, columns: JSON.stringify(fileObject.fileoption.columns || []), firstRow: fileObject.fileoption.firstRow || 0, firstColumn: fileObject.fileoption.firstColumn || 0 }
  1222. }).then(function (resp) {
  1223. if (resp.data.success) {
  1224. /*$alert({
  1225. title: '消息',
  1226. content: resp.data.msg,
  1227. placement: 'top',
  1228. type: 'info',
  1229. show: true,
  1230. duration: 3
  1231. });*/
  1232. //fileObject.loadItems(fileObject.fileoption);
  1233. fileObject.addDefer.resolve(resp.data.item);
  1234. scope.$hide();
  1235. } else {
  1236. fileObject.addDefer.reject(false);
  1237. $alert({
  1238. title: '消息:',
  1239. content: resp.data.msg,
  1240. placement: 'top',
  1241. type: 'info',
  1242. show: true,
  1243. duration: 5
  1244. });
  1245. scope.$hide();
  1246. }
  1247. //console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
  1248. }, function (resp) {
  1249. fileObject.addDefer.reject(false);
  1250. $alert({ title: '错误', content: "上传服务器错误!", placement: 'center', type: 'info', show: true, duration: 3 });
  1251. console.log('Error status: ' + resp.status);
  1252. scope.$hide();
  1253. }, function (evt) {
  1254. scope.updata.progressPer = parseInt(100.0 * evt.loaded / evt.total);
  1255. //console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
  1256. });
  1257. };
  1258. fileObject.initupload = function (upload) {
  1259. //fileObject.configdata
  1260. angular.extend(fileObject, upload);
  1261. };
  1262. fileObject.fileModalController = function ($scope, Upload, AuthUser) {
  1263. $scope.filetype = fileObject.fileoption.filetype;
  1264. $scope.updata = { isuping: false, progressPer: 0 };
  1265. $scope.SettingID = "";
  1266. $scope.templateUrl = fileObject.fileoption.templateUrl;
  1267. $scope.submit = function () {
  1268. if ($scope.fileform.file.$valid && $scope.file && $scope.valiFileType()) {
  1269. $scope.updata.isuping = true;
  1270. $scope.upload($scope.file);
  1271. }
  1272. //if ($scope.fileform.file.$error.minHeight) {
  1273. // $alert({ title: '消息', content: "图片高度小于100px", placement: 'center', type: 'info', show: true, duration: 3, container: '#fileaddmodal' });
  1274. //}
  1275. if ($scope.fileform.file.$error.maxSize) {
  1276. $alert({
  1277. title: '消息',
  1278. content: "文件不得大于20MB",
  1279. placement: 'center',
  1280. type: 'info',
  1281. show: true,
  1282. duration: 3,
  1283. container: '#fileaddmodal'
  1284. });
  1285. }
  1286. };
  1287. //验证文件格式,返回布尔类型
  1288. $scope.valiFileType = function () {
  1289. //验证结果标识
  1290. var isFlag = false;
  1291. //如果没定义
  1292. var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
  1293. if ($scope.file != null) {
  1294. var filename = $scope.file.name;
  1295. var loc = filename.lastIndexOf('.');
  1296. var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
  1297. //如果限制了上传文件格式,则进入判断
  1298. if (types) {
  1299. angular.forEach(types, function (item) {
  1300. if (item == filetype) {
  1301. isFlag = true;
  1302. }
  1303. })
  1304. } else {
  1305. isFlag = true;
  1306. }
  1307. }
  1308. //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
  1309. if (!isFlag && $scope.file != null) {
  1310. $scope.file = "";
  1311. $alert({
  1312. title: '消息',
  1313. content: fileObject.fileoption.typeparams.errormsg,
  1314. placement: 'top',
  1315. type: 'info',
  1316. show: true,
  1317. duration: 3,
  1318. container: '#fileaddmodal'
  1319. });
  1320. }
  1321. return isFlag;
  1322. };
  1323. $scope.upload = function () {
  1324. fileObject.uploadMethod($scope.file, $scope, Upload, AuthUser);
  1325. }
  1326. };
  1327. fileObject.fileModalController.$inject = ['$scope', 'Upload', 'AuthUser'];
  1328. fileObject.fModal = $modal({
  1329. controller: fileObject.fileModalController,
  1330. templateUrl: '../js/template/modal_fileadd.html', show: false,
  1331. placement: 'center', animation: 'am-fade-and-slide-top'
  1332. });
  1333. fileObject.showErrorInfo = function (errorList, stringColumn) {
  1334. fileObject.errorList = errorList;
  1335. fileObject.stringColumn = stringColumn;
  1336. fileObject.eModal.$promise.then(fileObject.eModal.show);
  1337. };
  1338. fileObject.excelModalController = function ($scope, excelPopup) {
  1339. $scope.fdata = { title: '导入失败列表' };
  1340. $scope.fdata.items = fileObject.errorList;
  1341. $scope.fdata.columns = fileObject.fileoption.errorcolumns;
  1342. $scope.fdata.stringColumn = fileObject.stringColumn;
  1343. if (!$scope.fdata.columns) {
  1344. $scope.fdata.columns = fileObject.getErrorColumns(fileObject.fileoption.columns);
  1345. }
  1346. $scope.export = function () {
  1347. excelPopup.export("../../api/common/Common/ImportErrorExport", $scope.fdata, "导入失败记录.xls");
  1348. }
  1349. };
  1350. fileObject.excelModalController.$inject = ['$scope', 'excelPopup'];
  1351. fileObject.eModal = $modal({
  1352. controller: fileObject.excelModalController,
  1353. templateUrl: '../js/template/modal_excelerrorinfo.html', show: false,
  1354. placement: 'center', animation: 'am-fade-and-slide-top'
  1355. });
  1356. fileObject.getErrorColumns = function (columns, errorColumn) {
  1357. var reverseColumns = {};
  1358. for (var key in fileObject.fileoption.columns) {
  1359. reverseColumns[fileObject.fileoption.columns[key]] = key;
  1360. }
  1361. return angular.extend(reverseColumns, (errorColumn ?? { 'Error': '错误明细' }));
  1362. }
  1363. //fileObject.fileModalController.$scope.upload();
  1364. return fileObject;
  1365. }).factory("$bsfiles", function ($modal, $http, $window, $alert, $q) {
  1366. var fileObject = {
  1367. configdata: {
  1368. itemsurl: '../../api/common/File/GetFileList', uploadurl: '../../api/common/File/UploadFile',
  1369. delfileurl: '../../api/common/File/DeleteFile',
  1370. delfileByRefurl: '../../api/common/File/delfileByRefID',
  1371. downFileUrl: '../../api/common/File/DownloadFile',
  1372. showImgUrl: '../../api/common/File/showImg',
  1373. typeparams: false,//为false则可选择所有文件,限制格式:{types:['jpg','bmp','jpe','jpeg'],errormsg:'图片格式必须为*.jpg,*.bmp,*.jpe,*.jpeg等格式'}
  1374. },
  1375. fModal: {},
  1376. addDefer: {}
  1377. };
  1378. fileObject.init = function (config) {
  1379. //fileObject.configdata
  1380. angular.extend(fileObject.configdata, config);
  1381. };
  1382. fileObject.loadItems = function (fileoption) {
  1383. if (!angular.isDefined(fileoption)) {
  1384. return false;
  1385. }
  1386. if (angular.isUndefined(fileoption.selectdata.FileRefID) || fileoption.selectdata.FileRefID.length == 0) {
  1387. return false;
  1388. }
  1389. //if (angular.isDefined(fileoption)) {
  1390. // fileObject.fileoption = fileoption;
  1391. //}
  1392. $http({
  1393. url: fileObject.configdata.itemsurl,
  1394. method: 'GET',
  1395. params: fileoption.selectdata
  1396. }).then(function (rq) {
  1397. fileoption.items.splice(0, fileoption.items.length);
  1398. angular.forEach(rq.data.Data.Result.rows, function (val, key) {
  1399. this.push(val);
  1400. }, fileoption.items);
  1401. fileoption.selectdata.ptotal = rq.data.Data.Result.total;
  1402. });
  1403. };
  1404. fileObject.addFile = function (fileoption) {
  1405. fileObject.addDefer = $q.defer();
  1406. //这里才传值到弹出页面
  1407. if (angular.isDefined(fileoption)) {
  1408. fileObject.fileoption = fileoption;
  1409. }
  1410. fileObject.fModal.$promise.then(fileObject.fModal.show);
  1411. return fileObject.addDefer.promise;
  1412. };
  1413. fileObject.delfile = function (fileid, fileoption) {
  1414. if ($window.confirm("是否删除?")) {
  1415. $http({
  1416. url: fileObject.configdata.delfileurl,
  1417. method: 'GET',
  1418. params: { fileId: fileid }
  1419. }).then(function (rq) {
  1420. if (rq.data.IsSuccess) {
  1421. fileObject.loadItems(fileoption);
  1422. }
  1423. $alert({
  1424. title: '消息',
  1425. content: rq.data.IsSuccess ? "删除成功" : rq.data.Message,
  1426. placement: 'top',
  1427. type: 'info',
  1428. show: true,
  1429. duration: 3
  1430. });
  1431. });
  1432. }
  1433. };
  1434. fileObject.delfileByRefID = function (noDeleteFileId, filerefid, fileoption) {
  1435. $http({
  1436. url: fileObject.configdata.delfileByRefurl,
  1437. method: 'GET',
  1438. params: { noDeleteFileId: noDeleteFileId, fileRefId: filerefid, fileType: fileoption.filetype }
  1439. }).then(function (rq) {
  1440. if (rq.data.IsSuccess) {
  1441. fileObject.loadItems(fileoption);
  1442. }
  1443. });
  1444. };
  1445. fileObject.uploadMethod = function (file, scope, Upload, AuthUser) {
  1446. Upload.upload({
  1447. url: fileObject.configdata.uploadurl,
  1448. data: { file: file, 'fileRefId': scope.refid, fileType: scope.filetype, uid: AuthUser.getUser().UserID }
  1449. }).then(function (resp) {
  1450. if (resp.data.success) {
  1451. $alert({
  1452. title: '消息',
  1453. content: resp.data.msg,
  1454. placement: 'top',
  1455. type: 'info',
  1456. show: true,
  1457. duration: 3
  1458. });
  1459. //fileObject.loadItems(fileObject.fileoption);
  1460. fileObject.addDefer.resolve(resp.data.item);
  1461. scope.$hide();
  1462. } else {
  1463. fileObject.addDefer.reject(false);
  1464. $alert({
  1465. title: '消息',
  1466. content: resp.data.msg,
  1467. placement: 'top',
  1468. type: 'info',
  1469. show: true,
  1470. duration: 3
  1471. });
  1472. fileObject.loadItems(fileObject.fileoption);
  1473. scope.$hide();
  1474. }
  1475. //console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
  1476. }, function (resp) {
  1477. fileObject.addDefer.reject(false);
  1478. $alert({ title: '错误', content: "上传服务器错误!", placement: 'center', type: 'info', show: true, duration: 3 });
  1479. console.log('Error status: ' + resp.status);
  1480. scope.$hide();
  1481. }, function (evt) {
  1482. scope.updata.progressPer = parseInt(100.0 * evt.loaded / evt.total);
  1483. //console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
  1484. });
  1485. };
  1486. fileObject.initupload = function (upload) {
  1487. //fileObject.configdata
  1488. angular.extend(fileObject, upload);
  1489. };
  1490. fileObject.fileModalController = function ($scope, Upload, AuthUser) {
  1491. $scope.refid = fileObject.fileoption.selectdata.FileRefID;
  1492. $scope.filetype = fileObject.fileoption.filetype;
  1493. $scope.updata = { isuping: false, progressPer: 0 };
  1494. $scope.SettingID = "";
  1495. $scope.multiFile = fileObject.fileoption.multiFile == true;
  1496. var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
  1497. $scope.acceptType = types ? types.map(e => '.' + e).join(',') : '*';
  1498. if (angular.isDefined(fileObject.fileoption.selectdata.SettingID)) {
  1499. //$scope.SettingID = fileObject.fileoption.selectdata.FileRefID.SettingID;
  1500. $scope.SettingID = fileObject.fileoption.selectdata.SettingID;
  1501. }
  1502. $scope.submit = function () {
  1503. if ($scope.fileform.file.$valid && $scope.file && $scope.valiFileType()) {
  1504. if (angular.isDefined(fileObject.fileoption.uploadbefore) && fileObject.fileoption.uploadbefore($scope.file) == false) {
  1505. return;
  1506. }
  1507. $scope.updata.isuping = true;
  1508. $scope.upload($scope.file);
  1509. }
  1510. //if ($scope.fileform.file.$error.minHeight) {
  1511. // $alert({ title: '消息', content: "图片高度小于100px", placement: 'center', type: 'info', show: true, duration: 3, container: '#fileaddmodal' });
  1512. //}
  1513. if ($scope.fileform.file.$error.maxSize) {
  1514. $alert({
  1515. title: '消息',
  1516. content: "文件不得大于20MB",
  1517. placement: 'center',
  1518. type: 'info',
  1519. show: true,
  1520. duration: 3,
  1521. container: '#fileaddmodal'
  1522. });
  1523. }
  1524. };
  1525. //验证文件格式,返回布尔类型
  1526. $scope.valiFileType = function () {
  1527. //验证结果标识
  1528. var isFlag = false;
  1529. //如果没定义
  1530. //var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
  1531. if ($scope.file != null) {
  1532. var a_files = [];
  1533. if (Array.isArray($scope.file)) {
  1534. a_files = $scope.file;
  1535. } else {
  1536. a_files.push($scope.file);
  1537. }
  1538. angular.forEach(a_files, function (a_file) {
  1539. var filename = a_file.name;
  1540. var loc = filename.lastIndexOf('.');
  1541. var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
  1542. //如果限制了上传文件格式,则进入判断
  1543. if (types) {
  1544. angular.forEach(types, function (item) {
  1545. if (item == filetype) {
  1546. isFlag = true;
  1547. }
  1548. })
  1549. } else {
  1550. isFlag = true;
  1551. }
  1552. });
  1553. }
  1554. //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
  1555. if (!isFlag && $scope.file != null) {
  1556. $scope.file = "";
  1557. $alert({
  1558. title: '消息',
  1559. content: fileObject.fileoption.typeparams.errormsg,
  1560. placement: 'top',
  1561. type: 'info',
  1562. show: true,
  1563. duration: 3,
  1564. container: '#fileaddmodal'
  1565. });
  1566. }
  1567. return isFlag;
  1568. };
  1569. $scope.upload = function () {
  1570. fileObject.uploadMethod($scope.file, $scope, Upload, AuthUser);
  1571. }
  1572. };
  1573. fileObject.fileModalController.$inject = ['$scope', 'Upload', 'AuthUser'];
  1574. fileObject.fModal = $modal({
  1575. controller: fileObject.fileModalController,
  1576. templateUrl: '../js/template/modal_fileadd.html', show: false,
  1577. placement: 'center', animation: 'am-fade-and-slide-top'
  1578. });
  1579. //fileObject.fileModalController.$scope.upload();
  1580. return fileObject;
  1581. }).directive('bsfiles', function ($bsfiles, $window) {
  1582. var directiveObject = {
  1583. restrict: 'EA',
  1584. template: '<ng-include src="ngModel.templateUrl"/>',
  1585. replace: true,
  1586. require: 'ngModel',
  1587. scope: { ngModel: '=' },
  1588. link: function (scope, element, attr, ngmodel) {
  1589. scope.styleConfig = {
  1590. mainStyle: { "padding-top": "10px" },
  1591. mainClass: "list-table-panel",
  1592. titleClass: "list-table-title"
  1593. };
  1594. //添加自定义模板参数
  1595. if (angular.isUndefined(scope.ngModel.templateUrl)) {
  1596. scope.ngModel.templateUrl = '../js/template/filelist.html';
  1597. }
  1598. if (angular.isUndefined(scope.ngModel.downFun)) {
  1599. scope.ngModel.downFun = function (id) {
  1600. $window.open($bsfiles.configdata.downFileUrl + "?fileId=" + id);
  1601. }
  1602. }
  1603. //读取自定义样式配置
  1604. if (scope.ngModel.styles) {
  1605. if (scope.ngModel.styles.padding != null) {
  1606. scope.styleConfig.mainStyle = {
  1607. "padding-top": scope.ngModel.styles.padding.toString() + "px"
  1608. }
  1609. }
  1610. if (scope.ngModel.styles.customerClass) {
  1611. if (scope.ngModel.styles.customerClass.mainClass) {
  1612. scope.styleConfig.mainClass = scope.ngModel.styles.customerClass.mainClass;
  1613. }
  1614. if (scope.ngModel.styles.customerClass.titleClass) {
  1615. scope.styleConfig.titleClass = scope.ngModel.styles.customerClass.titleClass;
  1616. }
  1617. }
  1618. }
  1619. if (scope.ngModel.configdata) {
  1620. $bsfiles.init(scope.ngModel.configdata);
  1621. }
  1622. scope.$watch('ngModel.selectdata.FileRefID', function (newval, oldval) {
  1623. $bsfiles.loadItems(scope.ngModel);
  1624. });
  1625. scope.downfile = function (id) {
  1626. //console.log($bsfiles.configdata.downFileUrl);
  1627. //console.log($bsfiles.configdata.downFileUrl)
  1628. scope.ngModel.downFun(id);
  1629. };
  1630. scope.addFile = function () {
  1631. //判断是否有同步方法
  1632. if (angular.isFunction(scope.ngModel.canupfile)) {
  1633. scope.ngModel.canupfile($bsfiles.addFile);
  1634. } else if (angular.isFunction(scope.ngModel.canupfileAsync)) {
  1635. scope.ngModel.canupfileAsync().then(function (id) {
  1636. scope.ngModel.selectdata.FileRefID = id;
  1637. $bsfiles.addFile(scope.ngModel).then(function (fid) {
  1638. $bsfiles.loadItems(scope.ngModel);
  1639. });
  1640. });
  1641. } else {
  1642. $bsfiles.addFile(scope.ngModel).then(function (fid) {
  1643. $bsfiles.loadItems(scope.ngModel);
  1644. });
  1645. }
  1646. };
  1647. scope.delfile = function (fid) {
  1648. $bsfiles.delfile(fid, scope.ngModel);
  1649. };
  1650. scope.search = function () {
  1651. };
  1652. }
  1653. };
  1654. return directiveObject;
  1655. }).directive('singlefile', function ($state, $http, $bsfiles, $window) {
  1656. return {
  1657. restrict: 'EA',
  1658. require: '?ngModel',
  1659. //作用域
  1660. scope: {
  1661. id: '=', //父级no
  1662. typeparams: '=?',
  1663. isupload: '=?',
  1664. readonly: '=?',
  1665. filetype: '=?',
  1666. uploadbefore: '=?'
  1667. },
  1668. //html
  1669. templateUrl: '../js/template/single-file.html',
  1670. //替换
  1671. replace: true,
  1672. transclude: true,
  1673. //link函数
  1674. link: function (scope, element, attrs, controllers) {
  1675. scope.ngModel = {
  1676. selectdata: { FileRefID: scope.id, pageindex: 1, pagesize: 10, ptotal: 0, fileType: scope.filetype },//查询参数:FileRefID为文件关联ID
  1677. filetype: scope.filetype,//文件类型
  1678. items: [],//列表数据地址
  1679. readonly: scope.readonly,//是否只能查看
  1680. addFileButton: '上传',
  1681. configdata: {
  1682. typeparams: false,
  1683. uploadurl: '../../api/common/File/UploadFile',
  1684. },
  1685. uploadbefore: scope.uploadbefore
  1686. };
  1687. if (scope.typeparams != undefined) {
  1688. scope.ngModel.typeparams = scope.typeparams;
  1689. }
  1690. if (scope.ngModel.configdata) {
  1691. $bsfiles.init(scope.ngModel.configdata);
  1692. }
  1693. scope.$watch("id", function (newval, oldval) {
  1694. scope.ngModel.selectdata.FileRefID = newval;
  1695. $bsfiles.loadItems(scope.ngModel);
  1696. });
  1697. scope.item = {};
  1698. scope.upload = function () {
  1699. scope.ngModel.selectdata.FileRefID = scope.id;
  1700. $bsfiles.addFile(scope.ngModel).then(function (fid) {
  1701. $bsfiles.delfileByRefID(fid, scope.id, scope.ngModel);
  1702. //$bsfiles.loadItems(scope.ngModel);
  1703. scope.isupload = true;
  1704. });
  1705. }
  1706. scope.downFun = function (id) {
  1707. $window.open($bsfiles.configdata.downFileUrl + "?fileId=" + id);
  1708. }
  1709. scope.delfile = function (id) {
  1710. $bsfiles.delfile(id, scope.ngModel);
  1711. scope.isupload = false;
  1712. }
  1713. }
  1714. }
  1715. }).directive('upfile', function ($bsfiles, $window, $alert, Upload, AuthUser, $http, $modal) {
  1716. var upfileObject = {
  1717. restrict: 'EA',
  1718. templateUrl: '../js/template/upfile.html',
  1719. replace: true,
  1720. require: 'ngModel',
  1721. scope: { ngModel: '=' },
  1722. link: function (scope, element, attr, ngmodel) {
  1723. var fileObject = {
  1724. configdata: {
  1725. itemsurl: '../../api/ICTFileUpLoad/FindFile', uploadurl: '../../api/ICTFileUpLoad/PostFile',
  1726. delfileurl: '../../api/FileUpload/delfile',
  1727. typeparams: false,//为false则可选择所有文件,限制格式:{types:['jpg','bmp','jpe','jpeg'],errormsg:'图片格式必须为*.jpg,*.bmp,*.jpe,*.jpeg等格式'}
  1728. },
  1729. fileoption: scope.ngModel
  1730. };
  1731. scope.$watch('scope.ngModel.selectdata.FileRefID', function (newval, oldval) {
  1732. scope.loadItem(scope.ngModel);
  1733. });
  1734. scope.title = scope.ngModel.title;
  1735. scope.refid = fileObject.fileoption.selectdata.FileRefID;
  1736. scope.filetype = fileObject.fileoption.filetype;
  1737. //文件步骤
  1738. scope.FlowStep = fileObject.fileoption.selectdata.FlowStep;
  1739. //文件的配置ID
  1740. scope.SettingID = fileObject.fileoption.selectdata.SettingID;
  1741. //验证文件格式,返回布尔类型
  1742. //scope.valiFileType = function () {
  1743. // //验证结果标识
  1744. // var isFlag = false;
  1745. // //如果没定义
  1746. // var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
  1747. // if (scope.upfile != null) {
  1748. // var filename = scope.upfile.name;
  1749. // var loc = filename.lastIndexOf('.');
  1750. // var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
  1751. // //如果限制了上传文件格式,则进入判断
  1752. // if (types&&types.length>0) {
  1753. // angular.forEach(types, function (item) {
  1754. // if (item == filetype) {
  1755. // isFlag = true;
  1756. // }
  1757. // })
  1758. // } else {
  1759. // isFlag = true;
  1760. // }
  1761. // }
  1762. // //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
  1763. // if (!isFlag && scope.upfile != null) {
  1764. // scope.upfile = "";
  1765. // $alert({ title: '消息', content: fileObject.fileoption.typeparams.errormsg, placement: 'top', type: 'info', show: true, duration: 3});
  1766. // }
  1767. // return isFlag;
  1768. //}
  1769. //加载文件
  1770. scope.loadItem = function (fileoption) {
  1771. if (!angular.isDefined(fileoption)) {
  1772. return false;
  1773. }
  1774. if (!angular.isDefined(fileoption.selectdata.FileRefID)) {
  1775. return false;
  1776. }
  1777. fileoption.items.splice(0, fileoption.items.length);
  1778. $http({
  1779. url: fileObject.configdata.itemsurl,
  1780. method: 'GET',
  1781. params: {
  1782. FileRefID: fileoption.selectdata.FileRefID,
  1783. SettingID: fileoption.selectdata.SettingID,
  1784. uid: fileObject.fileoption.selectdata.userID
  1785. }
  1786. }).then(function (rq) {
  1787. if (rq.data.total > 0) {
  1788. $("#" + fileoption.selectdata.SettingID).val(rq.data.items.FileName);
  1789. fileObject.fileoption.isUpload = true;
  1790. }
  1791. fileoption.selectdata.ptotal = rq.data.total;
  1792. });
  1793. };
  1794. //上传文件
  1795. //scope.upfilemethod = function (file) {
  1796. // //判断是否有同步方法
  1797. // if (angular.isFunction(scope.ngModel.canupfileAsync)) {
  1798. // scope.ngModel.canupfileAsync().then(function (id) {
  1799. // scope.ngModel.selectdata.FileRefID = id;
  1800. // Upload.upload({
  1801. // url: fileObject.configdata.uploadurl,
  1802. // data: { file: file, 'FileRefID': scope.ngModel.selectdata.FileRefID, uid: AuthUser.getUser().DGUserID, filetype: scope.filetype, SettingID: scope.SettingID }
  1803. // }).then(function (resp) {
  1804. // if (resp.data.success) {
  1805. // $alert({ title: '消息', content: resp.data.msg, placement: 'top', type: 'info', show: true, duration: 3 });
  1806. // fileObject.fileoption.isUpload = true;
  1807. // fileObject.fileoption.updateFlag = !fileObject.fileoption.updateFlag;
  1808. // fileObject.loadItems(fileObject.fileoption);
  1809. // } else {
  1810. // $alert({ title: '消息', content: resp.data.msg, placement: 'top', type: 'info', show: true, duration: 3 });
  1811. // }
  1812. // //console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
  1813. // }, function (resp) {
  1814. // $alert({ title: '错误', content: "上传服务器错误!", placement: 'center', type: 'info', show: true, duration: 3 });
  1815. // console.log('Error status: ' + resp.status);
  1816. // });
  1817. // }, function () {
  1818. // $alert({ title: '消息', content: "请填写完成表格后再上传", placement: 'top', type: 'info', show: true, duration: 3 });
  1819. // });
  1820. // } else {
  1821. // $alert({ title: '消息', content: "无法上传", placement: 'top', type: 'info', show: true, duration: 3 });
  1822. // }
  1823. //};
  1824. //文件上传方法
  1825. scope.uploadMethod = function (file, scopes, Upload, AuthUser) {
  1826. Upload.upload({
  1827. url: fileObject.configdata.uploadurl,
  1828. data: {
  1829. file: file,
  1830. 'FileRefID': fileObject.fileoption.selectdata.FileRefID,
  1831. uid: AuthUser.getUser().DGUserID,
  1832. filetype: fileObject.fileoption.filetype,
  1833. SettingID: fileObject.fileoption.selectdata.SettingID
  1834. }
  1835. }).then(function (resp) {
  1836. if (resp.data.success) {
  1837. $alert({
  1838. title: '消息',
  1839. content: resp.data.msg,
  1840. placement: 'top',
  1841. type: 'info',
  1842. show: true,
  1843. duration: 3
  1844. });
  1845. fileObject.fileoption.isUpload = true;
  1846. fileObject.fileoption.updateFlag = !fileObject.fileoption.updateFlag;
  1847. scope.loadItem(fileObject.fileoption);
  1848. scopes.$parent.$hide();
  1849. } else {
  1850. $alert({
  1851. title: '消息',
  1852. content: resp.data.msg,
  1853. placement: 'top',
  1854. type: 'info',
  1855. show: true,
  1856. duration: 3
  1857. });
  1858. scopes.$parent.$hide();
  1859. }
  1860. }, function (resp) {
  1861. $alert({
  1862. title: '错误',
  1863. content: "上传服务器错误!",
  1864. placement: 'center',
  1865. type: 'info',
  1866. show: true,
  1867. duration: 3
  1868. });
  1869. console.log('Error status: ' + resp.status);
  1870. scopes.$parent.$hide();
  1871. }, function (evt) {
  1872. scopes.updata.progressPer = parseInt(100.0 * evt.loaded / evt.total);
  1873. });
  1874. };
  1875. //$bsfiles.initupload(scope.upload);
  1876. scope.addFile = function () {
  1877. //判断是否有同步方法
  1878. if (angular.isFunction(scope.ngModel.canupfileAsync)) {
  1879. scope.ngModel.canupfileAsync().then(function (id) {
  1880. scope.ngModel.selectdata.FileRefID = id;
  1881. scope.fModal.$promise.then(scope.fModal.show);
  1882. });
  1883. } else {
  1884. scope.fModal.$promise.then(scope.fModal.show);
  1885. }
  1886. };
  1887. //模态框
  1888. scope.fileModalController = function ($scope, Upload, AuthUser) {
  1889. $scope.refid = fileObject.fileoption.selectdata.FileRefID;
  1890. $scope.filetype = fileObject.fileoption.filetype;
  1891. $scope.updata = { isuping: false, progressPer: 0 };
  1892. $scope.SettingID = "";
  1893. if (angular.isDefined(fileObject.fileoption.selectdata.FileRefID.SettingID)) {
  1894. $scope.SettingID = fileObject.fileoption.selectdata.FileRefID.SettingID;
  1895. }
  1896. $scope.submit = function () {
  1897. if ($scope.fileform.file.$valid && $scope.file && $scope.valiFileType()) {
  1898. $scope.updata.isuping = true;
  1899. $scope.upload($scope.file);
  1900. }
  1901. if ($scope.fileform.file.$error.minHeight) {
  1902. $alert({
  1903. title: '消息',
  1904. content: "图片高度小于100px",
  1905. placement: 'center',
  1906. type: 'info',
  1907. show: true,
  1908. duration: 3,
  1909. container: '#fileaddmodal'
  1910. });
  1911. }
  1912. if ($scope.fileform.file.$error.maxSize) {
  1913. $alert({
  1914. title: '消息',
  1915. content: "文件不得大于20MB",
  1916. placement: 'center',
  1917. type: 'info',
  1918. show: true,
  1919. duration: 3,
  1920. container: '#fileaddmodal'
  1921. });
  1922. }
  1923. };
  1924. //验证文件格式,返回布尔类型
  1925. $scope.valiFileType = function () {
  1926. //验证结果标识
  1927. var isFlag = false;
  1928. //如果没定义
  1929. var types = angular.isDefined(fileObject.fileoption.typeparams) ? fileObject.fileoption.typeparams.types : false;
  1930. if ($scope.file != null) {
  1931. var filename = $scope.file.name;
  1932. var loc = filename.lastIndexOf('.');
  1933. var filetype = filename.substring(loc + 1, filename.length).toLowerCase();
  1934. //如果限制了上传文件格式,则进入判断
  1935. if (types) {
  1936. angular.forEach(types, function (item) {
  1937. if (item == filetype) {
  1938. isFlag = true;
  1939. }
  1940. })
  1941. } else {
  1942. isFlag = true;
  1943. }
  1944. }
  1945. //若文件格式非法,并且文件不为空,则弹出错误信息,并且清空文件
  1946. if (!isFlag && $scope.file != null) {
  1947. $scope.file = "";
  1948. $alert({
  1949. title: '消息',
  1950. content: fileObject.fileoption.typeparams.errormsg,
  1951. placement: 'top',
  1952. type: 'info',
  1953. show: true,
  1954. duration: 3,
  1955. container: '#fileaddmodal'
  1956. });
  1957. }
  1958. return isFlag;
  1959. };
  1960. $scope.upload = function () {
  1961. scope.uploadMethod($scope.file, $scope, Upload, AuthUser);
  1962. }
  1963. };
  1964. scope.fileModalController.$inject = ['$scope', 'Upload', 'AuthUser'];
  1965. scope.fModal = $modal({
  1966. controller: scope.fileModalController,
  1967. templateUrl: '../js/template/modal_fileadd.html', show: false,
  1968. placement: 'center', animation: 'am-fade-and-slide-top'
  1969. });
  1970. }
  1971. };
  1972. return upfileObject;
  1973. }).directive('uiKindeditor', function ($ocLazyLoad) {
  1974. return {
  1975. restrict: 'EA',
  1976. require: '?ngModel',
  1977. link: function (scope, element, attrs, ctrl) {
  1978. $ocLazyLoad.load('../../scripts/kindeditor/kindeditor-all-min.js').then(function () {
  1979. var _initContent, editor;
  1980. var fexUE = {
  1981. initEditor: function () {
  1982. editor = KindEditor.create(element[0], {
  1983. width: '90%',
  1984. height: '400px',
  1985. resizeType: 1,
  1986. langType: 'zh-CN',
  1987. uploadJson: '',
  1988. formatUploadUrl: false,
  1989. allowImageUpload: false,
  1990. allowFileManager: false,
  1991. items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  1992. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  1993. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  1994. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  1995. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  1996. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  1997. 'anchor', 'link', 'unlink', '|', 'about'],
  1998. afterChange: function () {
  1999. ctrl.$setViewValue(this.html());
  2000. }
  2001. });
  2002. },
  2003. setContent: function (content) {
  2004. if (editor) {
  2005. editor.html(content);
  2006. }
  2007. }
  2008. };
  2009. if (!ctrl) {
  2010. return;
  2011. }
  2012. _initContent = ctrl.$viewValue;
  2013. ctrl.$render = function () {
  2014. _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
  2015. fexUE.setContent(_initContent);
  2016. };
  2017. fexUE.initEditor();
  2018. });
  2019. }
  2020. }
  2021. }).provider('$ueditor', function () {
  2022. var defaults = this.defaults = {
  2023. UEDITOR_HOME_URL: '../../scripts/ueditor/',
  2024. //initialContent: _initContent,
  2025. initialFrameHeight: 400,
  2026. autoHeightEnabled: false,
  2027. autoFloatEnabled: false,
  2028. serverUrl: '',
  2029. wordCount: false,
  2030. maximumWords: 10000000,
  2031. elementPathEnabled: false,
  2032. enableAutoSave: false,
  2033. zIndex: 0,
  2034. toolbars: [[
  2035. 'fullscreen', 'source', '|', 'undo', 'redo', '|',
  2036. 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
  2037. 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
  2038. 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
  2039. 'directionalityltr', 'directionalityrtl', 'indent', '|',
  2040. 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
  2041. 'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
  2042. 'simpleupload', 'insertimage', 'emotion', 'scrawl', 'attachment', '|',
  2043. 'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
  2044. 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts'
  2045. ]]
  2046. };
  2047. //var editor=null;
  2048. this.$get = function () {
  2049. var editor = new UE.ui.Editor(defaults);
  2050. return { ue: editor, options: defaults };
  2051. }
  2052. }).directive('uiUeditor', ["$ocLazyLoad", "$compile", "$ueditor", function ($ocLazyLoad, $compile, $ueditor) {
  2053. /* return {
  2054. restrict: 'EA',
  2055. require: '?ngModel',
  2056. link: function (scope, element, attrs, ctrl) {
  2057. //Ueditor富文本框先存代码,以后可能使用
  2058. //$ocLazyLoad.load(['../../scripts/ueditor/ueditor.config.js',
  2059. // '../../scripts/ueditor/ueditor.all.js']).then(function () {
  2060. var _self = this,
  2061. _initContent,
  2062. editor,
  2063. editorReady = false;
  2064. var fexUE = {
  2065. initEditor: function () {
  2066. _self = this;
  2067. if (typeof UE != 'undefined') {
  2068. editor = new UE.ui.Editor($ueditor.options);
  2069. //editor=UE.getEditor(attrs['id'],$ueditor.options);
  2070. editor.render(element[0]);
  2071. editor.ready(function () {
  2072. editorReady = true;
  2073. _self.setContent(_initContent);
  2074. editor.addListener('contentChange', function () {
  2075. scope.$apply(function () {
  2076. ctrl.$setViewValue(editor.getContent());
  2077. });
  2078. });
  2079. });
  2080. }
  2081. },
  2082. setContent: function (content) {
  2083. if (editor && editorReady) {
  2084. editor.setContent(content);
  2085. }
  2086. },
  2087. destroy:function () {
  2088. //element.prev('.edui-default').remove();
  2089. editor.destroy();
  2090. $("[class*='edui-']").remove();
  2091. }
  2092. };
  2093. if (!ctrl) {
  2094. return;
  2095. }
  2096. _initContent = ctrl.$viewValue;
  2097. ctrl.$render = function () {
  2098. _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
  2099. fexUE.setContent(_initContent);
  2100. };
  2101. scope.$on('$destroy',function(){
  2102. fexUE.destroy();
  2103. });
  2104. fexUE.initEditor();
  2105. //});
  2106. }
  2107. };*/
  2108. return {
  2109. restrict: 'EA',
  2110. require: '?ngModel',
  2111. link: function (scope, element, attrs, ctrl) {
  2112. $ocLazyLoad.load('../../scripts/kindeditor/kindeditor-all-min.js').then(function () {
  2113. var _initContent, editor;
  2114. var fexUE = {
  2115. initEditor: function () {
  2116. editor = KindEditor.create(element[0], {
  2117. width: '90%',
  2118. height: '400px',
  2119. resizeType: 1,
  2120. langType: 'zh-CN',
  2121. uploadJson: '',
  2122. formatUploadUrl: false,
  2123. allowImageUpload: true,
  2124. uploadJson: '../../api/systemsetting/Upload/Post',
  2125. allowFileManager: false,
  2126. items: ['source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  2127. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  2128. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  2129. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  2130. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  2131. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  2132. 'anchor', 'link', 'unlink', '|', 'about'],
  2133. afterChange: function () {
  2134. ctrl.$setViewValue(this.html());
  2135. }
  2136. });
  2137. },
  2138. setContent: function (content) {
  2139. if (editor) {
  2140. editor.html(content);
  2141. }
  2142. }
  2143. };
  2144. if (!ctrl) {
  2145. return;
  2146. }
  2147. _initContent = ctrl.$viewValue;
  2148. ctrl.$render = function () {
  2149. _initContent = ctrl.$isEmpty(ctrl.$viewValue) ? '' : ctrl.$viewValue;
  2150. fexUE.setContent(_initContent);
  2151. };
  2152. fexUE.initEditor();
  2153. });
  2154. }
  2155. }
  2156. }]).filter('showhtmlfilter', function ($sce) {
  2157. return function (html) {
  2158. return $sce.trustAsHtml(html);
  2159. };
  2160. }).filter('yearMonth', function () {
  2161. return function (yearMonth, format) {
  2162. return moment(yearMonth, 'YYYYMM').format(format);
  2163. };
  2164. }).directive('ngIndeterminate', function () {
  2165. return {
  2166. restrict: 'A',
  2167. link: function (scope, element, attr) {
  2168. attr.$observe('ngIndeterminate', function (value) {
  2169. element.prop('indeterminate', value == "true");
  2170. });
  2171. }
  2172. };
  2173. //模态框方式载入loading
  2174. }).factory("$loading", function ($modal) {
  2175. var loadingObject = {};
  2176. loadingObject.loadingModal = $modal({
  2177. templateUrl: '../js/template/modal_loading.html', show: false,
  2178. placement: 'center', animation: '.modal-backdrop.am-fade', backdrop: false
  2179. });
  2180. loadingObject.show = function () {
  2181. loadingObject.loadingModal.$promise.then(loadingObject.loadingModal.show);
  2182. };
  2183. loadingObject.hide = function () {
  2184. loadingObject.loadingModal.$promise.then(loadingObject.loadingModal.hide);
  2185. };
  2186. return loadingObject;
  2187. }).directive('menupanel', function ($http, AuthUser, $state) {
  2188. return {
  2189. restrict: 'EA',
  2190. templateUrl: '../js/template/t_menupanel.html',
  2191. scope: true,
  2192. link: function (scope, element, attr) {
  2193. var menuobject = {
  2194. param: {
  2195. uid: AuthUser.getUser().DGUserID,
  2196. appkey: attr['appkey'],
  2197. defrolekey: attr['defrolekey']
  2198. },
  2199. getMenuUrl: '../../api/user/getmenubyuid'
  2200. };
  2201. scope.panels = [];
  2202. scope.getMenuList = function () {
  2203. $http({
  2204. method: 'post', url: menuobject.getMenuUrl, data: menuobject.param
  2205. }).then(function (result) {
  2206. if (result.data.success) {
  2207. scope.menuList = result.data.item;
  2208. //$state.get('home');若路由不存在,返回null
  2209. //$state.is('home');若路由不存在,返回undifined;
  2210. if (scope.menuList.length > 0) {
  2211. angular.forEach(scope.menuList, function (menu) {
  2212. //如果为父节点
  2213. if (menu.ParentMenuId == null || menu.ParentMenuId == "") {
  2214. var pmenu = { title: menu.MenuName, cNodes: [] };
  2215. //遍历插入子节点
  2216. angular.forEach(scope.menuList, function (cli) {
  2217. //截取路由
  2218. var realstate = scope.sliceStateName(cli.MenuNo);
  2219. //路由是否存在,若存在则为原路由,若不存在,为空
  2220. var isExisted = angular.isDefined($state.is(realstate)) ? cli.MenuNo : '';
  2221. if (cli.ParentMenuId == menu.MenuId) pmenu.cNodes.push({
  2222. title: cli.MenuName,
  2223. name: isExisted
  2224. });
  2225. });
  2226. scope.panels.push(pmenu);
  2227. }
  2228. })
  2229. }
  2230. scope.initActive();
  2231. } else {
  2232. $alert({
  2233. title: '错误:',
  2234. content: result.data.msg,
  2235. placement: 'centre',
  2236. type: 'info',
  2237. show: true,
  2238. duration: 3
  2239. });
  2240. }
  2241. });
  2242. };
  2243. //用于截取路由name,
  2244. //如:home.roleList({appid:"CBFAF886-D757-46B5-A856-763AEEF6D3D3"})---返回home.roleList
  2245. scope.sliceStateName = function (statename) {
  2246. var index = statename.indexOf('(');
  2247. if (index >= 0) {
  2248. return statename.slice(0, index);
  2249. }
  2250. return statename;
  2251. };
  2252. //刷新页面时默认打开一级菜单
  2253. scope.initActive = function () {
  2254. //当前路由name
  2255. var statename = $state.current.name;
  2256. angular.forEach(scope.panels, function (value, index) {
  2257. angular.forEach(value.cNodes, function (item) {
  2258. //去掉参数的路由,如home.roleList({appid:"CBFAF886-D757-46B5-A856-763AEEF6D3D3"}),去参数路由:home.roleList
  2259. var realState = scope.sliceStateName(item.name);
  2260. if (realState == statename) {
  2261. scope.panels.activePanel = index;
  2262. }
  2263. })
  2264. });
  2265. };
  2266. if (angular.isDefined(attr['appkey']) && angular.isDefined(attr['defrolekey'])) {
  2267. scope.getMenuList();
  2268. }
  2269. }
  2270. };
  2271. }).directive('bsLvtree', function ($filter, $timeout, $ocLazyLoad, $compile) {
  2272. //生成树型结构
  2273. var bindtree = function (vtree, model) {
  2274. angular.forEach(vtree, function (val, key) {
  2275. val.children = $filter('filter')(model.data, function (fdata) {
  2276. return fdata.pid == val.id;
  2277. });
  2278. model.treelength++;
  2279. //默认不显示按钮
  2280. val.showbtn = false;
  2281. //查看最后一级
  2282. if (model.xAxis[model.xAxis.length - 1].id == val.xid) {
  2283. val.islast = true;
  2284. } else {
  2285. val.islast = false;
  2286. }
  2287. bindtree(val.children, model);
  2288. });
  2289. };
  2290. var htmlXaxisbind = function (xaxis, $xAxispanel) {
  2291. angular.forEach(xaxis, function (xval) {
  2292. $xAxispanel.append('<div data-id="' + xval.id + '">' + xval.name + '</div>');
  2293. });
  2294. };
  2295. //画中间线
  2296. var drawxAxisLine = function (ctx, xAxis, pheigth) {
  2297. ctx.beginPath();
  2298. ctx.lineWidth = 1;
  2299. ctx.shadowBlur = 0;
  2300. //ctx.setLineDash = [15,5];
  2301. ctx.strokeStyle = '#000000';
  2302. for (var i = 1; i < xAxis.length; i++) {
  2303. ctx.moveTo(250 * i, 0);
  2304. ctx.lineTo(250 * i, pheigth);
  2305. ctx.stroke();
  2306. }
  2307. ctx.closePath();
  2308. };
  2309. //画对象之间的联线
  2310. var drawRectToRectLine = function (ctx, vtreeit) {
  2311. var $it, $cit;
  2312. ctx.lineWidth = 1;
  2313. ctx.shadowBlur = 0;
  2314. ctx.strokeStyle = 'green';
  2315. if (vtreeit.children && vtreeit.children.length > 0) {
  2316. $it = $('.item_panel[data-id="' + vtreeit.id + '"]');
  2317. angular.forEach(vtreeit.children, function (cv, ck) {
  2318. $cit = $('.item_panel[data-id="' + cv.id + '"]');
  2319. ctx.moveTo($it.position().left + $it.width() - 12, $it.position().top + 5);
  2320. ctx.lineTo($cit.position().left + 10, $cit.position().top + 5);
  2321. ctx.stroke();
  2322. drawRectToRectLine(ctx, cv);
  2323. });
  2324. }
  2325. };
  2326. return {
  2327. restrict: 'EA',
  2328. require: '?ngModel',
  2329. templateUrl: '../js/setting/sysduty/lv_tree.html',
  2330. scope: { ngModel: '=' },
  2331. controller: function ($scope) {
  2332. $ocLazyLoad.load('../js/setting/sysduty/sdutyplate.css');
  2333. $scope.ngModel.xAxis = $filter('orderBy')($scope.ngModel.xAxis, '+id') || [{ id: 0, name: '根节点' }];
  2334. $scope.ngModel.treelength = 0;
  2335. $scope.ngModel.treeloadlength = 0;
  2336. //btntype:{1:'新增同级',2:'新增子级',3:'删除节点',4:'查看节点'}
  2337. $scope.btnclick = function (titem, btntype) {
  2338. if ($scope.ngModel.btnclick) {
  2339. $scope.ngModel.btnclick(titem, btntype);
  2340. }
  2341. };
  2342. $scope.loadIncrease = function () {
  2343. $scope.ngModel.treeloadlength++;
  2344. };
  2345. },
  2346. link: function ($scope, $elem, $attrs) {
  2347. //htmlXaxisbind($scope.ngModel.showxAxis, $elem.find('.x_axis_div'));
  2348. //开始添加节点
  2349. //htmltreebind($scope.ngModel.treeNodes, $elem.find('.tree_div'));
  2350. //$compile($elem.find('.tree_div'))($scope);
  2351. $scope.$watch('ngModel.data', function () {
  2352. //第一层节点
  2353. $scope.ngModel.treeNodes = $filter('filter')($scope.ngModel.data, function (val) {
  2354. return val.xid == $scope.ngModel.xAxis[0].id;
  2355. });
  2356. $scope.ngModel.treelength = 0;
  2357. $scope.ngModel.treeloadlength = 0;
  2358. bindtree($scope.ngModel.treeNodes, $scope.ngModel);
  2359. });
  2360. $scope.$watch('ngModel.treeloadlength', function () {
  2361. if ($scope.ngModel.treelength == $scope.ngModel.treeloadlength && $scope.ngModel.treeloadlength > 0) {
  2362. $timeout(function () {
  2363. //开始画图
  2364. var cvs = $elem.find('.dutypanel>canvas')[0];
  2365. cvs.width = $elem.find('.dutypanel').width();
  2366. cvs.height = $elem.find('.dutypanel').height();
  2367. var ctx = cvs.getContext('2d');
  2368. //drawxAxisLine(ctx, $scope.ngModel.xAxis, cvs.height);
  2369. ctx.beginPath();
  2370. angular.forEach($scope.ngModel.treeNodes, function (tn, tk) {
  2371. drawRectToRectLine(ctx, tn);
  2372. });
  2373. ctx.closePath();
  2374. ctx.save();
  2375. }, 200);
  2376. }
  2377. });
  2378. }
  2379. }
  2380. }).directive('sysselect', function ($http, AuthUser, $state, $modal) {
  2381. var directiveObject = {
  2382. restrict: 'EAC',
  2383. scope: {
  2384. textids: '=',//已选择的人员ID
  2385. textnames: '=',//已选择的人员
  2386. selecteditems: '=',//已选对象
  2387. },
  2388. link: function (scope, element, attr, controller) {
  2389. //通过item的id判断该元素是否在arr里
  2390. scope.contains = function (arr, item) {
  2391. var i = arr.length;
  2392. //如果选择系统,通过SystemID去判断
  2393. //如果选择模块,菜单,功能点,通过SysDutyID去判断
  2394. if (attr['selecttype'] == 0) {
  2395. while (i--) {
  2396. if (arr[i].SystemID === item.SystemID) {
  2397. return true;
  2398. }
  2399. }
  2400. } else {
  2401. while (i--) {
  2402. if (arr[i].SysDutyID === item.SysDutyID) {
  2403. return true;
  2404. }
  2405. }
  2406. }
  2407. return false;
  2408. };
  2409. var sysModalController = function ($scope) {
  2410. $scope.title = angular.isDefined(attr['title']) ? attr['title'] : "功能点选择";//模态框标题
  2411. $scope.sysList = [];//系统列表
  2412. $scope.curList = [];//当前选择列表,保存该控件打开时最右边div的那个集合,如selectType=0,则是系统,1则是模块
  2413. $scope.selectedItems = angular.isDefined(scope.selecteditems) ? angular.copy(scope.selecteditems) : [];//已选择对象
  2414. $scope.selectType = angular.isDefined(attr['selecttype']) && attr['selecttype'] > -1 && attr['selecttype'] < 4 ? attr['selecttype'] : 0;//选择类型 0-选择系统;1-选择模块;2-选择菜单;3-选择功能点;
  2415. $scope.singleMode = attr['singlemode'] == "true" ? true : false;//选择模式 true-单选模式,false-多选模式
  2416. //所有请求url
  2417. var urls = {
  2418. GetSysLisUrl: '../../api/SysManage/GetAllSysList',
  2419. GetChildSysDutyListUrl: '../../api/SysDuty/GetChildSysDutyList'
  2420. };
  2421. //系统列表初始化
  2422. $scope.SysListInit = function () {
  2423. $http.post(urls.GetSysLisUrl).then(function (result) {
  2424. $scope.sysList = result.data.list;
  2425. if ($scope.selectType == 0) {
  2426. $scope.curList = angular.copy(result.data.list);//当前需要添加的集合
  2427. }
  2428. }, function () {
  2429. $alert({
  2430. title: '错误:',
  2431. content: '获取系统列表失败,服务器错误',
  2432. placement: 'center',
  2433. type: 'info',
  2434. container: '#sysselect',
  2435. show: true,
  2436. duration: 3
  2437. });
  2438. });
  2439. };
  2440. //模态框样式初始化
  2441. $scope.InitClass = function () {
  2442. $scope.isZero = $scope.selectType == 0 ? true : false;
  2443. $scope.isOne = $scope.selectType == 1 ? true : false;
  2444. $scope.isTwo = $scope.selectType == 2 ? true : false;
  2445. $scope.isThree = $scope.selectType == 3 ? true : false;
  2446. };
  2447. //执行初始化
  2448. $scope.InitClass();
  2449. $scope.SysListInit();
  2450. //移除元素
  2451. $scope.Remove = function (index, arr) {
  2452. arr.splice(index, 1);
  2453. };
  2454. //确认选择
  2455. $scope.Confirm = function () {
  2456. scope.selecteditems = angular.copy($scope.selectedItems);
  2457. scope.textids = "";
  2458. scope.textnames = "";
  2459. $scope.GenerateValue();
  2460. $scope.$hide();
  2461. };
  2462. $scope.GenerateValue = function () {
  2463. var isFirst = true;
  2464. if ($scope.selectType == 0) {
  2465. angular.forEach(scope.selecteditems, function (item) {
  2466. if (isFirst) {
  2467. scope.textnames = item.SystemName;
  2468. scope.textids = item.SystemID;
  2469. isFirst = false;
  2470. } else {
  2471. scope.textnames += "," + item.SystemName;
  2472. scope.textids += "," + item.SystemID;
  2473. }
  2474. });
  2475. } else {
  2476. angular.forEach(scope.selecteditems, function (item) {
  2477. if (isFirst) {
  2478. scope.textnames = item.SysDutyName;
  2479. scope.textids = item.SysDutyID;
  2480. isFirst = false;
  2481. } else {
  2482. scope.textnames += "," + item.SysDutyName;
  2483. scope.textids += "," + item.SysDutyID;
  2484. }
  2485. });
  2486. }
  2487. };
  2488. //changeType为对应改变的下拉类型,0-系统,1-模块,2-菜单
  2489. //arr 选中的值
  2490. //list 当前列表
  2491. $scope.SelectChange = function (changeType, arr, list) {
  2492. //单选模式
  2493. if ($scope.singleMode) {
  2494. if ($scope.selectType == changeType && arr.length > 0) {
  2495. arr.length = 1;
  2496. $scope.selectedItems[0] = arr[0];
  2497. } else if (arr.length > 0) {
  2498. $scope.getSelectList(changeType, arr, list);
  2499. }
  2500. } else {
  2501. //多选模式
  2502. if ($scope.selectType == changeType) {
  2503. $scope.tempSelected = angular.copy(arr);
  2504. } else if (arr.length > 0) {
  2505. $scope.getSelectList(changeType, arr, list);
  2506. }
  2507. }
  2508. };
  2509. //获得系统、模块、菜单、功能集合
  2510. $scope.getSelectList = function (changeType, arr, list) {
  2511. var SystemID = '';
  2512. var PdutyID = '';
  2513. var DutyLv = changeType + 1;
  2514. if (changeType == 0) {
  2515. SystemID = arr[0].SystemID;
  2516. } else {
  2517. PdutyID = arr[0].SysDutyID;
  2518. }
  2519. list.child = [];
  2520. list.child.isloading = true;
  2521. $http.post(urls.GetChildSysDutyListUrl, {
  2522. SystemID: SystemID,
  2523. PdutyID: PdutyID,
  2524. DutyLv: DutyLv
  2525. }).then(function (result) {
  2526. list.child.isloading = false;
  2527. arr.length = 1;
  2528. //如果当前获取的列表为该选择模式需要的列表,则将次返回数据复制给curList
  2529. if (DutyLv == $scope.selectType) {
  2530. $scope.curList = angular.copy(result.data.list);//当前需要添加的集合
  2531. } else {
  2532. $scope.curList.length = 0;
  2533. }
  2534. list.child = result.data.list;
  2535. }, function (result) {
  2536. list.child.isloading = false;
  2537. $alert({
  2538. title: '错误:',
  2539. content: '获列表失败,服务器错误',
  2540. placement: 'center',
  2541. type: 'info',
  2542. container: '#sysselect',
  2543. show: true,
  2544. duration: 3
  2545. });
  2546. })
  2547. };
  2548. //添加到已选
  2549. $scope.Add = function (type) {
  2550. if (type == 0) {
  2551. angular.forEach($scope.tempSelected, function (item) {
  2552. if (scope.contains($scope.selectedItems, item) == false) {
  2553. this.push(item);
  2554. }
  2555. }, $scope.selectedItems)
  2556. } else {
  2557. angular.forEach($scope.curList, function (item) {
  2558. if (scope.contains($scope.selectedItems, item) == false) {
  2559. this.push(item);
  2560. }
  2561. }, $scope.selectedItems)
  2562. }
  2563. };
  2564. $scope.Delete = function () {
  2565. $scope.selectedItems.length = [];
  2566. }
  2567. };
  2568. sysModalController.$inject = ['$scope'];
  2569. //模态框实例
  2570. var sysModal = $modal({
  2571. scope: scope,
  2572. controller: sysModalController,
  2573. resolve: {
  2574. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  2575. $ocLazyLoad.load('../js/template/modal_sysselect.css');
  2576. return true;
  2577. }]
  2578. },
  2579. templateUrl: '../js/template/modal_sysselect.html',
  2580. show: false,
  2581. animation: 'am-fade-and-slide-top'
  2582. });
  2583. //data-notrelated:是否取消关联用一个父元素的input标签(点击input标签时也可以触发该控件),默认为false 可选值:true(关联)/fasle(不关联)
  2584. if (attr['notrelated']) {
  2585. element.on("click", function () {
  2586. sysModal.$promise.then(sysModal.show);
  2587. });
  2588. element.css({ cursor: 'pointer' });
  2589. } else {
  2590. element.parent().on("click", function () {
  2591. sysModal.$promise.then(sysModal.show);
  2592. });
  2593. element.css({ cursor: 'pointer' });
  2594. element.parent().children("input").css({ cursor: 'pointer', "background-color": "#FFFFFF" });
  2595. }
  2596. }
  2597. };
  2598. return directiveObject;
  2599. }).directive('bsselectdataPro', function ($http, $modal, $filter) {
  2600. var directiveObject = {
  2601. restrict: 'EAC',
  2602. scope: {
  2603. dataoptions: '='
  2604. },
  2605. link: function (scope, element, attr, controller) {
  2606. var sdModal = {}, selectHtml = '';
  2607. /*
  2608. angular.extend(scope.dataoptions,{
  2609. isMulti:true,
  2610. selectedLabeData:'',
  2611. selectedValueData:'',
  2612. selectedJData:[]
  2613. });*/
  2614. if (!scope.dataoptions.selectedJData) {
  2615. scope.dataoptions.selectedJData = [];
  2616. }
  2617. scope.init = function () {
  2618. scope.dataoptions.selectedJData = [];
  2619. if (!scope.dataoptions.selectParams) {
  2620. scope.dataoptions.selectParams = {};
  2621. }
  2622. if (scope.dataoptions.selectedValueData && scope.dataoptions.selectedValueData.length > 0) {
  2623. var valueArray = scope.dataoptions.selectedValueData.split(',');
  2624. var labelArray = scope.dataoptions.selectedLabeData.split(',');
  2625. angular.forEach(valueArray, function (val, key) {
  2626. var it = {};
  2627. it[scope.dataoptions.selectValuekey] = val;
  2628. it[scope.dataoptions.selectLabelKey] = labelArray[key];
  2629. scope.dataoptions.selectedJData.push(it);
  2630. });
  2631. }
  2632. };
  2633. var sdModalController = function ($scope) {
  2634. $scope.fdata = {
  2635. selectParams: scope.dataoptions.selectParams,
  2636. selectCols: [],
  2637. columns: scope.dataoptions.columns,
  2638. columnsFormatting: scope.dataoptions.columnsFormatting,
  2639. items: [],
  2640. ptotal: 0,
  2641. title: scope.dataoptions.title,
  2642. width: scope.dataoptions.width == null ? 70 : scope.dataoptions.width,
  2643. selectedJData: scope.dataoptions.selectedJData,
  2644. selectValuekey: scope.dataoptions.selectValuekey,
  2645. selectLabelKey: scope.dataoptions.selectLabelKey,
  2646. selectTemp: [],
  2647. isMulti: scope.dataoptions.isMulti
  2648. };
  2649. //转成查询条件
  2650. angular.extend($scope.fdata.selectParams, {
  2651. pageIndex: 1,
  2652. pageSize: 10
  2653. });
  2654. angular.forEach(scope.dataoptions.selectData, function (value, key) {
  2655. $scope.fdata.selectParams[key] = '';
  2656. $scope.fdata.selectCols.push({ text: value, val: key });
  2657. });
  2658. $scope.loadData = function () {
  2659. $http.post(scope.dataoptions.url, $scope.fdata.selectParams).then(function (value) {
  2660. $scope.fdata.items = value.data.Data.rows;
  2661. $scope.fdata.ptotal = value.data.Data.total;
  2662. });
  2663. };
  2664. $scope.search = function () {
  2665. $scope.loadData();
  2666. };
  2667. $scope.findSData = function () {
  2668. $scope.fdata.selectParams.pageindex = 1;
  2669. $scope.loadData();
  2670. };
  2671. $scope.addItem = function () {
  2672. var tableCheckedArray = $filter('filter')($scope.fdata.items, function (tIt) {
  2673. return tIt.checked;
  2674. });
  2675. angular.forEach(tableCheckedArray, function (value, key) {
  2676. var itemData = $filter('filter')($scope.fdata.selectedJData, function (it) {
  2677. return it[$scope.fdata.selectValuekey] == value[$scope.fdata.selectValuekey];
  2678. });
  2679. if (itemData.length == 0) {
  2680. $scope.fdata.selectedJData.push(value);
  2681. }
  2682. });
  2683. };
  2684. $scope.deleteItem = function (it) {
  2685. var i = -1;
  2686. if (it) {
  2687. i = $scope.fdata.selectedJData.indexOf(it);
  2688. $scope.fdata.selectedJData.splice(i, 1);
  2689. } else {
  2690. angular.forEach($scope.fdata.selectTemp, function (value, key) {
  2691. i = $scope.fdata.selectedJData.indexOf(value);
  2692. $scope.fdata.selectedJData.splice(i, 1);
  2693. });
  2694. }
  2695. };
  2696. /* $scope.$watch("fdata.selectParams.pageindex", function (newVal) {
  2697. if ($scope.fdata.ptotal > 0) {
  2698. $scope.loadData();
  2699. }
  2700. });*/
  2701. $scope.selectedData = function () {
  2702. scope.dataoptions.selectedLabeData = '';
  2703. scope.dataoptions.selectedValueData = '';
  2704. var selectItem = null;
  2705. if ($scope.fdata.isMulti) {
  2706. selectItem = [];
  2707. angular.forEach($scope.fdata.selectedJData, function (value, key) {
  2708. if (key > 0) {
  2709. scope.dataoptions.selectedLabeData += ',';
  2710. scope.dataoptions.selectedValueData += ','
  2711. }
  2712. scope.dataoptions.selectedLabeData += value[$scope.fdata.selectLabelKey];
  2713. scope.dataoptions.selectedValueData += value[$scope.fdata.selectValuekey];
  2714. selectItem.push(value);
  2715. });
  2716. } else {
  2717. selectItem = {};
  2718. angular.forEach($scope.fdata.items, function (value, key) {
  2719. if (value.checked == true) {
  2720. scope.dataoptions.selectedLabeData = value[$scope.fdata.selectLabelKey];
  2721. scope.dataoptions.selectedValueData = value[$scope.fdata.selectValuekey];
  2722. selectItem = value;
  2723. }
  2724. });
  2725. }
  2726. if (scope.dataoptions.onSelect != undefined) {
  2727. scope.dataoptions.onSelect(scope.dataoptions.selectedValueData, selectItem);
  2728. }
  2729. $scope.$hide();
  2730. };
  2731. $scope.loadData();
  2732. };
  2733. sdModalController.$inject = ['$scope'];
  2734. var selectCount = 0;
  2735. //动态生成html
  2736. //文本框查询条件
  2737. angular.forEach(scope.dataoptions.selectData, function (value, key) {
  2738. selectCount++;
  2739. if ((selectCount - 1) % 2 == 0) {
  2740. selectHtml += '<div class="row clearfix">';
  2741. }
  2742. selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5 form-control-label">';
  2743. selectHtml += '<label for="' + key + '">' + value + '</label>';
  2744. selectHtml += '</div>';
  2745. selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5"><div class="form-group"><div class="form-line">';
  2746. selectHtml += '<input type="text" class="form-control" ng-model="fdata.selectParams.' + key + '">';
  2747. selectHtml += '</div></div></div>';
  2748. if (selectCount % 2 == 0) {
  2749. selectHtml += '</div>';
  2750. }
  2751. });
  2752. //下拉框查询条件
  2753. angular.forEach(scope.dataoptions.comboxData, function (value, key, item) {
  2754. selectCount++;
  2755. if ((selectCount - 1) % 2 == 0) {
  2756. selectHtml += '<div class="row clearfix">';
  2757. }
  2758. selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5 form-control-label">';
  2759. selectHtml += '<label for="' + key + '">' + value.text + '</label>';
  2760. selectHtml += '</div>';
  2761. selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5"><div class="form-group"><div class="form-line">';
  2762. selectHtml += ' <select class="form-control show-tick" ng-model="fdata.selectParams.' + key + '"';
  2763. selectHtml += ' class="form-control" name="selectname"> <option value="" selected>--请选择--</option> ';
  2764. angular.forEach(value.data, function (dic, dicvalue) {
  2765. selectHtml += '<option value="' + dic.valueField + '">' + dic.nameField + '</option> ';
  2766. });
  2767. selectHtml += '</select>';
  2768. selectHtml += '</div></div></div>';
  2769. if (selectCount % 2 == 0) {
  2770. selectHtml += '</div>';
  2771. }
  2772. });
  2773. //日期框查询条件
  2774. angular.forEach(scope.dataoptions.selectDate, function (value, key) {
  2775. selectCount++;
  2776. if ((selectCount - 1) % 2 == 0) {
  2777. selectHtml += '<div class="row clearfix">';
  2778. }
  2779. selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5 form-control-label">';
  2780. selectHtml += '<label for="' + key + '">' + value + '</label>';
  2781. selectHtml += '</div>';
  2782. selectHtml += '<div class="col-lg-3 col-md-3 col-sm-4 col-xs-5"><div class="form-group"><div class="form-line">';
  2783. 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">';
  2784. 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">';
  2785. selectHtml += '</div></div></div>';
  2786. if (selectCount % 2 == 0) {
  2787. selectHtml += '</div>';
  2788. }
  2789. });
  2790. if (selectCount % 2 != 0) {
  2791. selectHtml += '</div>';
  2792. }
  2793. $http.get("../js/template/modal_selectdatapro.html").then(function (value) {
  2794. var showTemplate = value.data.replace(/\$\$selectdate\$\$/, selectHtml);
  2795. showTemplate = showTemplate.replace(/\$\$itemlabel\$\$/, scope.dataoptions.selectLabelKey);
  2796. sdModal = $modal({
  2797. scope: scope, controller: sdModalController, template: showTemplate, show: false
  2798. });
  2799. });
  2800. element.on('click', function () {
  2801. scope.init();
  2802. sdModal.$promise.then(sdModal.show);
  2803. });
  2804. }
  2805. };
  2806. return directiveObject;
  2807. }).directive('bsDtable', function ($compile) {
  2808. var directiveObject = {
  2809. restrict: 'EAC',
  2810. template: function (tElement, tAttrs) {
  2811. var html = '<table class="table table-bordered tlist">\n';
  2812. html += '<thead>\n';
  2813. html += '<tr>\n';
  2814. 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';
  2815. html += '</tr>\n';
  2816. html += '</thead>\n';
  2817. html += '<tbody data-id="drow">\n';
  2818. html += '</tbody>\n';
  2819. html += '</table>';
  2820. return html;
  2821. },
  2822. scope: {
  2823. datarows: '=',
  2824. datacols: '=',
  2825. datacolsformatting: '=',
  2826. ismulti: '=',
  2827. showcheckbox: '='
  2828. },
  2829. link: function (scope, element, attr, controller) {
  2830. scope.dtData = {
  2831. columns: [],
  2832. trHtml: '',
  2833. showcheckbox: attr.showcheckbox == false ? false : true
  2834. };
  2835. scope.allchecked = false;
  2836. scope.checkAll = function () {
  2837. if (scope.allchecked == false) {
  2838. scope.allchecked = true;
  2839. } else {
  2840. scope.allchecked = false;
  2841. }
  2842. angular.forEach(scope.datarows, function (value, key) {
  2843. value.checked = scope.allchecked;
  2844. });
  2845. };
  2846. scope.checkItem = function (it) {
  2847. //单选
  2848. //if (!scope.ismulti) {
  2849. // angular.forEach(scope.datarows, function (value, key) {
  2850. // value.checked = false;
  2851. // if (it.checked == false && it == value) {
  2852. // value.checked = true;
  2853. // }
  2854. // });
  2855. //}
  2856. angular.forEach(scope.datarows, function (value, key) {
  2857. if (!scope.ismulti) {//单选
  2858. value.checked = false;
  2859. if (it.checked == false && it == value) {
  2860. value.checked = true;
  2861. }
  2862. } else {//多选
  2863. if (it == value) {
  2864. value.checked = !value.checked;
  2865. }
  2866. }
  2867. });
  2868. };
  2869. scope.dtData.trHtml += '<tr ng-repeat="it in datarows" ng-click="checkItem(it)">' +
  2870. '<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>';
  2871. angular.forEach(scope.datacols, function (value, key) {
  2872. scope.formatting = "";
  2873. if (scope.datacolsformatting) {
  2874. scope.datacolsformatting.filter(x => {
  2875. if (x.key == key) {
  2876. scope.formatting = x.val
  2877. }
  2878. });
  2879. }
  2880. if (scope.formatting != "") {
  2881. scope.dtData.trHtml += '<td ng-bind="it.' + key + ' | ' + scope.formatting + '"></td>>';
  2882. scope.formatting = "";
  2883. } else {
  2884. scope.dtData.trHtml += '<td ng-bind="it.' + key + '"></td>>';
  2885. }
  2886. this.push({ text: value, val: key });
  2887. }, scope.dtData.columns);
  2888. scope.dtData.trHtml += '</tr>';
  2889. element.find('tbody[data-id="drow"]').append(scope.dtData.trHtml);
  2890. $compile(element.find('tbody[data-id="drow"]'))(scope);
  2891. }
  2892. };
  2893. return directiveObject;
  2894. }).directive('autoHeight', function ($window, $timeout) {
  2895. return {
  2896. restrict: 'A',
  2897. link: function (scope, element, attrs) {
  2898. $timeout(function () {
  2899. var winowHeight = $window.innerHeight; //获取窗口高度
  2900. var headerHeight = element.offset().top;
  2901. var footerHeight = 10;
  2902. $("body").css("oveflow-y", "hidden");
  2903. element.addClass('outoflow')
  2904. .css('max-height',
  2905. (winowHeight - headerHeight - footerHeight) + 'px');
  2906. }, 1000);
  2907. }
  2908. };
  2909. }).directive('autoHeightFixed', function ($window, $timeout) {
  2910. return {
  2911. restrict: 'A',
  2912. link: function (scope, element, attrs) {
  2913. $timeout(function () {
  2914. var winowHeight = $window.innerHeight; //获取窗口高度
  2915. var headerHeight = element.offset().top;
  2916. var footerHeight = 10;
  2917. $("body").css("oveflow-y", "hidden");
  2918. element
  2919. .css('height',
  2920. (winowHeight - headerHeight - footerHeight) + 'px');
  2921. }, 100);
  2922. }
  2923. };
  2924. })
  2925. /* .directive("fixHeaderTableRows", function ($window,$timeout) {
  2926. return {
  2927. restrict : 'A',
  2928. link : function(scope, element, attrs) {
  2929. var mybody = element.closest('table');
  2930. var header = mybody.prev();
  2931. header.css("position", "relative").css("background-color", "white").css("max-width", "none").css("margin-bottom", "0px");
  2932. mybody.css("max-width", "none").css("width", "auto").css("margin-top", "0px");
  2933. mybody.parent().scroll(function() {
  2934. var scrollTop = $(this).scrollTop();
  2935. header.css("top", scrollTop.toString() + "px");
  2936. header.scrollLeft($(this).scrollLeft());
  2937. });
  2938. if (scope.$last === true) {
  2939. $timeout(function (){
  2940. var firstRow = mybody.children("tbody").children("tr");
  2941. if (firstRow.length > 0) { //一行都没有一般就不会错位
  2942. // header.width(mybody.width());
  2943. var headerList = header.find("tr>th");
  2944. // for (var i = headerList.length - 1; i >= 0; i --) {
  2945. // var width = $($(firstRow[0]).children("td")[i]).width();
  2946. //
  2947. // $(headerList[i]).width(width);
  2948. // }
  2949. var bodyWidth = mybody.width();
  2950. var totalWidth = 0;
  2951. var headerColumnList = header.find("tr>th");
  2952. var widthList = [headerColumnList.length];
  2953. header.width(bodyWidth);
  2954. headerColumnList.each(function(i, v) {
  2955. var bodyColumn = $($(firstRow[firstRow.length - 1]).children("td")[i]);
  2956. var width = bodyColumn.outerWidth();
  2957. var borderWidth = parseInt(bodyColumn.css("border-width"));
  2958. $(v).css("width", (width - borderWidth).toString() + "px");
  2959. var nowWidth = $(v).outerWidth();
  2960. if (nowWidth > width) {
  2961. widthList[i] = nowWidth;
  2962. totalWidth += nowWidth;
  2963. } else {
  2964. widthList[i] = width;
  2965. totalWidth += width;
  2966. }
  2967. });
  2968. var headerBorderWidth = parseInt(header.css("border-left-width"));
  2969. header.width(totalWidth);
  2970. mybody.width(totalWidth);
  2971. headerColumnList.each(function(i, v) {
  2972. var borderWidth = parseInt($(v).css("border-left-width"));
  2973. $(v).css("width", (widthList[i] - borderWidth).toString() + "px");
  2974. $($(firstRow[0]).children("td")[i]).css("width", (widthList[i] - borderWidth).toString() + "px");
  2975. });
  2976. }
  2977. }, 1000);
  2978. }
  2979. // if (scope.$last === true) {
  2980. // $timeout(function (){
  2981. // var firstRow = mybody.children("tbody").children("tr");
  2982. // if (firstRow.length > 0) { //一行都没有一般就不会错位
  2983. // header.width(mybody.width());
  2984. // var headerList = header.find("tr>th");
  2985. // // for (var i = headerList.length - 1; i >= 0; i --) {
  2986. // // var width = $($(firstRow[0]).children("td")[i]).width();
  2987. // //
  2988. // // $(headerList[i]).width(width);
  2989. // // }
  2990. // header.find("tr>th").each(function (i, v) {
  2991. // var width = $($(firstRow[0]).children("td")[i]).width();
  2992. //
  2993. // $(v).css("width", Math.floor(width).toString() + "px");
  2994. // });
  2995. // }
  2996. // }, 1000);
  2997. // };
  2998. }
  2999. };
  3000. })*/
  3001. .factory('$payService', ['$q', '$rootScope', '$aside', '$alert', function ($q, $rootScope, $aside, $alert) {
  3002. var paySModel = {};
  3003. paySModel.rAside = $aside({
  3004. scope: $rootScope,
  3005. placement: 'right',
  3006. resolve: {
  3007. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  3008. return $ocLazyLoad.load(['../js/setting/payment/payment.css', '../js/setting/payment/payment.js']);
  3009. }]
  3010. },
  3011. controller: 'payAsideCtrl',
  3012. templateUrl: '../js/setting/payment/pay_aside.html',
  3013. show: false
  3014. });
  3015. paySModel.backAside = $aside({
  3016. scope: $rootScope,
  3017. placement: 'right',
  3018. resolve: {
  3019. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  3020. return $ocLazyLoad.load(['../js/setting/payment/payment.css', '../js/setting/payment/payment.js']);
  3021. }]
  3022. },
  3023. controller: 'backAsideCtrl',
  3024. templateUrl: '../js/setting/payment/back_aside.html',
  3025. show: false
  3026. });
  3027. paySModel.payShow = function (model) {
  3028. var $defer = $q.defer();
  3029. if (!angular.isNumber(model.amt)) {
  3030. $alert({
  3031. title: '参数错误',
  3032. content: '支付金额必需为数字',
  3033. placement: 'top',
  3034. type: 'info',
  3035. show: true,
  3036. duration: 3
  3037. });
  3038. return;
  3039. }
  3040. if (angular.isUndefined(model.payRelID)) {
  3041. $alert({
  3042. title: '参数错误',
  3043. content: 'payRelID:关系ID必填!',
  3044. placement: 'top',
  3045. type: 'info',
  3046. show: true,
  3047. duration: 3
  3048. });
  3049. return;
  3050. }
  3051. if (angular.isUndefined(model.companyID)) {
  3052. $alert({
  3053. title: '参数错误',
  3054. content: 'companyID:公司ID必填!',
  3055. placement: 'top',
  3056. type: 'info',
  3057. show: true,
  3058. duration: 3
  3059. });
  3060. return;
  3061. }
  3062. if (angular.isUndefined(model.creatorID)) {
  3063. $alert({
  3064. title: '参数错误',
  3065. content: 'creatorID:创建者ID必填!',
  3066. placement: 'top',
  3067. type: 'info',
  3068. show: true,
  3069. duration: 3
  3070. });
  3071. return;
  3072. }
  3073. $rootScope.payModel = model;
  3074. $rootScope.paydefer$ = $defer;
  3075. paySModel.rAside.$promise.then(paySModel.rAside.show);
  3076. return $defer.promise;
  3077. };
  3078. paySModel.backShow = function (payRelID) {
  3079. var $defer = $q.defer();
  3080. $rootScope.payModel = { payRelID: payRelID };
  3081. paySModel.backAside.$promise.then(paySModel.backAside.show);
  3082. $rootScope.backpaydefer$ = $defer;
  3083. return $defer.promise;
  3084. };
  3085. return paySModel;
  3086. }]).directive("zeroTableTh", ['$timeout', function ($timeout) {
  3087. var f_time = function (element) {
  3088. var $table = element.parents('table');
  3089. var $thead = $table.find('thead');
  3090. var $preTitleTable = $table.prev('table.zero-theader');
  3091. var td_width = [], t_width = 0;
  3092. if ($preTitleTable.length == 0) {
  3093. var $title_table = $('<div class="zero-thead-div"><table class="table table-bordered zero-theader"></table></div>');
  3094. var $divBody = $('<div class="zero-body-div"></div>');
  3095. $table.before($title_table);
  3096. $table.before($divBody);
  3097. $.each($thead.find('th'), function (i, th) {
  3098. td_width.push(th.offsetWidth);
  3099. t_width += th.offsetWidth;
  3100. });
  3101. $thead.appendTo($title_table.find('table'));
  3102. $table.appendTo($divBody);
  3103. $table.addClass('zero-body');
  3104. $.each($thead.find("th"), function (i, th) {
  3105. th.style.width = td_width[i] + "px";
  3106. });
  3107. $.each($table.find('tr:eq(0)>td'), function (i, td) {
  3108. td.style.width = td_width[i] + "px";
  3109. });
  3110. $divBody.height($(window).height() - $table.offset().top);
  3111. $divBody.scroll(function () {
  3112. $title_table.scrollLeft($(this).scrollLeft());
  3113. });
  3114. } else {
  3115. $thead = $table.parent().parent().find('.zero-theader>thead');
  3116. $.each($thead.find('th'), function (i, th) {
  3117. td_width.push(th.offsetWidth);
  3118. });
  3119. $.each($table.find('tr:eq(0)>td'), function (i, td) {
  3120. td.style.width = td_width[i] + "px";
  3121. });
  3122. }
  3123. };
  3124. var directiveObject = {
  3125. restrict: 'AC',
  3126. link: function (scope, element, attr, controller) {
  3127. if (scope.$last === true) {
  3128. $timeout(function () {
  3129. f_time(element);
  3130. }, 100);
  3131. }
  3132. }
  3133. };
  3134. return directiveObject;
  3135. }]).directive("eChart", function ($http, $window, $ocLazyLoad) {
  3136. return {
  3137. restrict: 'EA',
  3138. require: '?ngModel',
  3139. link: function (scope, element, attrs, ctrl) {
  3140. $ocLazyLoad.load('../../scripts/echarts.min.js').then(function () {
  3141. //初始化图表
  3142. var myChart = echarts.init(element[0]);
  3143. //监控option数据变化
  3144. scope.$watch(
  3145. attrs["ecData"],
  3146. function () {
  3147. var option = scope.$eval(attrs.ecData);
  3148. if (angular.isObject(option)) {
  3149. //绘制图表
  3150. myChart.setOption(option);
  3151. }
  3152. },
  3153. true
  3154. );
  3155. scope.getDom = function () {
  3156. return {
  3157. height: element[0].offsetHeight,
  3158. width: element[0].offsetWidth
  3159. };
  3160. };
  3161. //监控图表宽高变化,响应式
  3162. scope.$watch(
  3163. scope.getDom,
  3164. function () {
  3165. // resize echarts图表
  3166. myChart.resize();
  3167. },
  3168. true
  3169. );
  3170. });
  3171. }
  3172. }
  3173. }).directive("partyTreeold", function ($http, $ocLazyLoad, AuthUser, $filter) {
  3174. return {
  3175. restrict: 'EA',
  3176. require: '?ngModel',
  3177. //作用域
  3178. scope: {
  3179. selectdzzdm: '=', //等号是双向绑定,选中的党组织代码
  3180. selectdzzmc: '=', //等号是双向绑定,选中的党组织名称
  3181. height: '=',
  3182. csssrc: '=?',
  3183. showtogglebtn: '=?',
  3184. onlyshowdw: '=?',//显示党委情况,1 组织架构只显示党委,2只显示一级党委(显示一级不能展开下一级)
  3185. zzfbtype: '=?',//组织分部类型20191012
  3186. defaultselected: '=?',//默认选中的党委代码
  3187. isunfold: '=?',//是否展开
  3188. //20190829版本更新,下列参数无效,不需要传
  3189. isshowxz: '=?',//是否加载小组,0不加载,1加载
  3190. parentcode: '=?', //父级
  3191. parentname: '=?',
  3192. dzzdm: '=?', //当前党组织
  3193. dzzmc: '=?',
  3194. userid: '=?'
  3195. //
  3196. },
  3197. templateUrl: '../js/template/modal_partyTreeOld.html',
  3198. link: function (scope, elemnet) {
  3199. scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
  3200. //组织树样式
  3201. if (scope.csssrc) {
  3202. $ocLazyLoad.load(scope.csssrc);
  3203. } else {
  3204. $ocLazyLoad.load('../js/template/modal_partyTree.css');
  3205. }
  3206. if (scope.showtogglebtn == null) {
  3207. scope.showtogglebtn = true;
  3208. }
  3209. scope.isshowtogglebtn = false;
  3210. var $sidebar = null;
  3211. if (scope.showtogglebtn) {
  3212. //sidebar初始化
  3213. /*$sidebar = elemnet.parents('.row').first();
  3214. $sidebar.addClass('pt-sidebar-collapsed-back');
  3215. var sidebarDivs = $sidebar.parent().find('.row>div');
  3216. //sidebarDivs.removeAttr('class');
  3217. sidebarDivs.eq(0).addClass('sidebar1');
  3218. sidebarDivs.eq(1).addClass('content1');
  3219. //$sidebar.find('.icon-name').content('');
  3220. $sidebar.find('.pt-sidebar-icon').click(function () {
  3221. if ($sidebar) {
  3222. if ($sidebar.is('.pt-sidebar-collapsed-back')) {
  3223. $sidebar.removeClass('pt-sidebar-collapsed-back');
  3224. $sidebar.addClass('pt-sidebar-collapsed');
  3225. //$sidebar.find('.icon-name').content('keyboard_arrow_left');
  3226. } else {
  3227. $sidebar.removeClass('pt-sidebar-collapsed');
  3228. $sidebar.addClass('pt-sidebar-collapsed-back');
  3229. //$sidebar.find('.icon-name').content('keyboard_arrow_up');
  3230. }
  3231. }
  3232. });*/
  3233. //sidebar初始化
  3234. $sidebar = elemnet.parents('.dj-list-body').first();
  3235. if (scope.isunfold) {
  3236. $sidebar.addClass('pt-sidebar-collapsed-back');
  3237. } else {
  3238. $sidebar.addClass('pt-sidebar-collapsed');
  3239. }
  3240. var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
  3241. sidebarDivs.eq(0).addClass('sidebar1');
  3242. sidebarDivs.eq(1).addClass('content1');
  3243. }
  3244. scope.$watch("isunfold", function (newVal, oldVal) {
  3245. scope.isshowtogglebtn = newVal;
  3246. if ($sidebar) {
  3247. if (newVal) {
  3248. $sidebar.removeClass('pt-sidebar-collapsed');
  3249. $sidebar.addClass('pt-sidebar-collapsed-back');//展开
  3250. } else {
  3251. $sidebar.removeClass('pt-sidebar-collapsed-back');
  3252. $sidebar.addClass('pt-sidebar-collapsed');//收缩
  3253. }
  3254. }
  3255. });
  3256. //定义组织树数据
  3257. scope.treeList = [];//组织树数据
  3258. scope.zzfbTypeList = [];//组织分类
  3259. scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
  3260. scope.isShowZZFBType = scope.gddwdm == AuthUser.getUser().DataDzzdm && !scope.csssrc;//是否需要显示分类下拉框
  3261. //数据联动-添加分类下拉监视
  3262. scope.$watch("zzfbtype", function (newVal, oldVal) {
  3263. if (newVal != oldVal) {
  3264. scope.treeList.length = 0;
  3265. scope.defaultselected = "";
  3266. scope.loadParentParty();
  3267. }
  3268. });
  3269. //查询父级架构
  3270. scope.loadParentParty = function () {
  3271. var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
  3272. scope.selectdzzdm = dataDzzdm;
  3273. if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
  3274. scope.parentcode = dataDzzdm;
  3275. scope.dzzdm = "";
  3276. scope.selectdzzmc = "全集团党组织";
  3277. } else {
  3278. scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
  3279. scope.dzzdm = dataDzzdm;
  3280. }
  3281. $http
  3282. ({
  3283. method: 'get', url: '../../api/party/getPartyTreeList', params:
  3284. {
  3285. parentCode: scope.parentcode,
  3286. isshowxz: 1,
  3287. dzzdm: scope.dzzdm,
  3288. onlyshow_dw: scope.onlyshowdw,
  3289. zzfbType: scope.zzfbtype
  3290. }
  3291. }).then(function (result) {
  3292. var list = [];
  3293. angular.forEach(result.data.item, function (node, index) {
  3294. node.P_Code = scope.parentcode;
  3295. list.push(node);
  3296. });
  3297. scope.treeList = list;
  3298. if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].DZZDM == scope.selectdzzdm)) {
  3299. scope.loadChildParty(scope.treeList[0]);
  3300. }
  3301. //默认选中党委
  3302. if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  3303. //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
  3304. var defaultItem = $filter("filter")(list, { DZZDM: scope.defaultselected.substring(0, 12) });
  3305. if (defaultItem.length > 0) {
  3306. scope.loadChildParty(defaultItem[0]);
  3307. }
  3308. }
  3309. });
  3310. };
  3311. //查询子级架构
  3312. scope.loadChildParty = function (item) {
  3313. var CHILDSHOW = item.CHILDSHOW > 0 ? 0 : 1;
  3314. scope.resetActive(item);
  3315. item.CHILDSHOW = CHILDSHOW;
  3316. scope.selectdzzdm = item.DZZDM;
  3317. scope.selectdzzmc = item.DZZMC;
  3318. //onlyshowdw==2 只显示一级党委 不加载下一级
  3319. if (scope.onlyshowdw != 2 && item.CHILDSHOW > 0 && item.CHILDCOUNT > 0) {
  3320. $http
  3321. ({
  3322. method: 'get', url: '../../api/party/getPartyTreeList', params:
  3323. {
  3324. parentCode: item.DZZDM,
  3325. isshowxz: 1,
  3326. onlyshow_dw: scope.onlyshowdw
  3327. }
  3328. }).then(function (result) {
  3329. var list = [];
  3330. angular.forEach(result.data.item, function (node, index) {
  3331. node.P_Code = item.P_Code + '.' + item.DZZDM;
  3332. list.push(node);
  3333. });
  3334. item.CHILDPARTYS = list;
  3335. //默认选中
  3336. if (item.DZZDM != scope.defaultselected && scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  3337. var defaultItem = $filter("filter")(list, { DZZDM: scope.defaultselected.substring(0, item.DZZDM.length + 3) });
  3338. if (defaultItem.length > 0) {
  3339. scope.loadChildParty(defaultItem[0]);
  3340. }
  3341. }
  3342. });
  3343. }
  3344. };
  3345. //重置选中项
  3346. scope.resetActive = function (model) {
  3347. var codes = model.P_Code.split('.');
  3348. codes.push(model.DZZDM);
  3349. angular.forEach(scope.treeList, function (node, index) {
  3350. var index = $.inArray(node.DZZDM, codes);
  3351. node.CHILDSHOW = index >= 0 ? 1 : 0;
  3352. if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
  3353. scope.resetActive_child(node.CHILDPARTYS, codes);
  3354. }
  3355. });
  3356. };
  3357. scope.resetActive_child = function (list, codes) {
  3358. angular.forEach(list, function (node, index) {
  3359. var index = $.inArray(node.DZZDM, codes);
  3360. node.CHILDSHOW = index >= 0 ? 1 : 0;
  3361. if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
  3362. scope.resetActive_child(node.CHILDPARTYS, codes);
  3363. }
  3364. });
  3365. };
  3366. //获取组织分类数据
  3367. scope.loadZzfbTypeList = function () {
  3368. $http({
  3369. method: 'get',
  3370. url: '../../api/dictionary/getDictionaryListByDicTypeKey',
  3371. params: {
  3372. dicTypeKey: 'zzfb'
  3373. }
  3374. }).then(function (result) {
  3375. scope.zzfbTypeList = result.data;
  3376. }, function (resp) {
  3377. });
  3378. };
  3379. //初始化数据
  3380. scope.loadParentParty();
  3381. scope.loadZzfbTypeList();
  3382. }
  3383. }
  3384. }).directive("partyTree", function ($http, $ocLazyLoad, AuthUser, $filter) {
  3385. return {
  3386. restrict: 'EA',
  3387. require: '?ngModel',
  3388. //作用域
  3389. scope: {
  3390. selectdzzdm: '=', //等号是双向绑定,选中的党组织代码
  3391. selectdzzmc: '=', //等号是双向绑定,选中的党组织名称
  3392. height: '=',
  3393. csssrc: '=?',
  3394. showtogglebtn: '=?',
  3395. onlyshowdw: '=?',//显示党委情况,1 组织架构只显示党委,2只显示一级党委(显示一级不能展开下一级)
  3396. zzfbtype: '=?',//组织分部类型20191012
  3397. defaultselected: '=?',//默认选中的党委代码
  3398. isunfold: '=?',//是否展开
  3399. //20190829版本更新,下列参数无效,不需要传
  3400. isshowxz: '=?',//是否加载小组,0不加载,1加载
  3401. parentcode: '=?', //父级
  3402. parentname: '=?',
  3403. dzzdm: '=?', //当前党组织
  3404. dzzmc: '=?',
  3405. userid: '=?'
  3406. //
  3407. },
  3408. /*templateUrl: '../js/template/modal_partyTree.html',
  3409. link: function (scope, elemnet) {
  3410. scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
  3411. //组织树样式
  3412. if (scope.csssrc) {
  3413. $ocLazyLoad.load(scope.csssrc);
  3414. } else {
  3415. $ocLazyLoad.load('../js/template/modal_partyTree.css');
  3416. }
  3417. if (scope.showtogglebtn == null) {
  3418. scope.showtogglebtn = true;
  3419. }
  3420. scope.isshowtogglebtn = false;
  3421. var $sidebar = null;
  3422. if (scope.showtogglebtn) {
  3423. //sidebar初始化
  3424. /!*$sidebar = elemnet.parents('.row').first();
  3425. $sidebar.addClass('pt-sidebar-collapsed-back');
  3426. var sidebarDivs = $sidebar.parent().find('.row>div');
  3427. //sidebarDivs.removeAttr('class');
  3428. sidebarDivs.eq(0).addClass('sidebar1');
  3429. sidebarDivs.eq(1).addClass('content1');
  3430. //$sidebar.find('.icon-name').content('');
  3431. $sidebar.find('.pt-sidebar-icon').click(function () {
  3432. if ($sidebar) {
  3433. if ($sidebar.is('.pt-sidebar-collapsed-back')) {
  3434. $sidebar.removeClass('pt-sidebar-collapsed-back');
  3435. $sidebar.addClass('pt-sidebar-collapsed');
  3436. //$sidebar.find('.icon-name').content('keyboard_arrow_left');
  3437. } else {
  3438. $sidebar.removeClass('pt-sidebar-collapsed');
  3439. $sidebar.addClass('pt-sidebar-collapsed-back');
  3440. //$sidebar.find('.icon-name').content('keyboard_arrow_up');
  3441. }
  3442. }
  3443. });*!/
  3444. //sidebar初始化
  3445. $sidebar = elemnet.parents('.dj-list-body').first();
  3446. if (scope.isunfold) {
  3447. $sidebar.addClass('pt-sidebar-collapsed-back');
  3448. } else {
  3449. $sidebar.addClass('pt-sidebar-collapsed');
  3450. }
  3451. var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
  3452. sidebarDivs.eq(0).addClass('sidebar1');
  3453. sidebarDivs.eq(1).addClass('content1');
  3454. }
  3455. scope.$watch("isunfold", function (newVal, oldVal) {
  3456. scope.isshowtogglebtn = newVal;
  3457. if ($sidebar) {
  3458. if (newVal) {
  3459. $sidebar.removeClass('pt-sidebar-collapsed');
  3460. $sidebar.addClass('pt-sidebar-collapsed-back');//展开
  3461. } else {
  3462. $sidebar.removeClass('pt-sidebar-collapsed-back');
  3463. $sidebar.addClass('pt-sidebar-collapsed');//收缩
  3464. }
  3465. }
  3466. });
  3467. //定义组织树数据
  3468. scope.treeList = [];//组织树数据
  3469. scope.zzfbTypeList = [];//组织分类
  3470. scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
  3471. scope.isShowZZFBType = scope.gddwdm == AuthUser.getUser().DataDzzdm && !scope.csssrc;//是否需要显示分类下拉框
  3472. //数据联动-添加分类下拉监视
  3473. scope.$watch("zzfbtype", function (newVal, oldVal) {
  3474. if (newVal != oldVal) {
  3475. scope.treeList.length = 0;
  3476. scope.defaultselected = "";
  3477. scope.loadParentParty();
  3478. }
  3479. });
  3480. //查询父级架构
  3481. scope.loadParentParty = function () {
  3482. var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
  3483. scope.selectdzzdm = dataDzzdm;
  3484. if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
  3485. scope.parentcode = dataDzzdm;
  3486. scope.dzzdm = "";
  3487. scope.selectdzzmc = "全集团党组织";
  3488. } else {
  3489. scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
  3490. scope.dzzdm = dataDzzdm;
  3491. }
  3492. $http
  3493. ({
  3494. method: 'get', url: '../../api/party/getPartyTreeList', params:
  3495. {
  3496. parentCode: scope.parentcode,
  3497. isshowxz: 1,
  3498. dzzdm: scope.dzzdm,
  3499. onlyshow_dw: scope.onlyshowdw,
  3500. zzfbType: scope.zzfbtype
  3501. }
  3502. }).then(function (result) {
  3503. var list = [];
  3504. angular.forEach(result.data.item, function (node, index) {
  3505. node.P_Code = scope.parentcode;
  3506. list.push(node);
  3507. });
  3508. scope.treeList = list;
  3509. if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].DZZDM == scope.selectdzzdm)) {
  3510. scope.loadChildParty(scope.treeList[0]);
  3511. }
  3512. //默认选中党委
  3513. if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  3514. //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
  3515. var defaultItem = $filter("filter")(list, {DZZDM: scope.defaultselected.substring(0, 12)});
  3516. if (defaultItem.length > 0) {
  3517. scope.loadChildParty(defaultItem[0]);
  3518. }
  3519. }
  3520. });
  3521. };
  3522. //查询子级架构
  3523. scope.loadChildParty = function (item) {
  3524. var CHILDSHOW = item.CHILDSHOW > 0 ? 0 : 1;
  3525. scope.resetActive(item);
  3526. item.CHILDSHOW = CHILDSHOW;
  3527. scope.selectdzzdm = item.DZZDM;
  3528. scope.selectdzzmc = item.DZZMC;
  3529. //onlyshowdw==2 只显示一级党委 不加载下一级
  3530. if (scope.onlyshowdw != 2 && item.CHILDSHOW > 0 && item.CHILDCOUNT > 0) {
  3531. $http
  3532. ({
  3533. method: 'get', url: '../../api/party/getPartyTreeList', params:
  3534. {
  3535. parentCode: item.DZZDM,
  3536. isshowxz: 1,
  3537. onlyshow_dw: scope.onlyshowdw
  3538. }
  3539. }).then(function (result) {
  3540. var list = [];
  3541. angular.forEach(result.data.item, function (node, index) {
  3542. node.P_Code = item.P_Code + '.' + item.DZZDM;
  3543. list.push(node);
  3544. });
  3545. item.CHILDPARTYS = list;
  3546. //默认选中
  3547. if (item.DZZDM != scope.defaultselected && scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  3548. var defaultItem = $filter("filter")(list, {DZZDM: scope.defaultselected.substring(0, item.DZZDM.length + 3)});
  3549. if (defaultItem.length > 0) {
  3550. scope.loadChildParty(defaultItem[0]);
  3551. }
  3552. }
  3553. });
  3554. }
  3555. };
  3556. //重置选中项
  3557. scope.resetActive = function (model) {
  3558. var codes = model.P_Code.split('.');
  3559. codes.push(model.DZZDM);
  3560. angular.forEach(scope.treeList, function (node, index) {
  3561. var index = $.inArray(node.DZZDM, codes);
  3562. node.CHILDSHOW = index >= 0 ? 1 : 0;
  3563. if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
  3564. scope.resetActive_child(node.CHILDPARTYS, codes);
  3565. }
  3566. });
  3567. };
  3568. scope.resetActive_child = function (list, codes) {
  3569. angular.forEach(list, function (node, index) {
  3570. var index = $.inArray(node.DZZDM, codes);
  3571. node.CHILDSHOW = index >= 0 ? 1 : 0;
  3572. if (node.CHILDPARTYS != null && node.CHILDPARTYS.length > 0) {
  3573. scope.resetActive_child(node.CHILDPARTYS, codes);
  3574. }
  3575. });
  3576. };
  3577. //获取组织分类数据
  3578. scope.loadZzfbTypeList = function () {
  3579. $http({
  3580. method: 'get',
  3581. url: '../../api/dictionary/getDictionaryListByDicTypeKey',
  3582. params: {
  3583. dicTypeKey: 'zzfb'
  3584. }
  3585. }).then(function (result) {
  3586. scope.zzfbTypeList = result.data;
  3587. }, function (resp) {
  3588. });
  3589. };
  3590. //初始化数据
  3591. scope.loadParentParty();
  3592. scope.loadZzfbTypeList();
  3593. }*/
  3594. templateUrl: '../js/template/modal_partyTreeNew.html',
  3595. link: function (scope, elemnet) {
  3596. $ocLazyLoad.load('../js/template/modal_partyTree.css');
  3597. scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
  3598. //sidebar初始化
  3599. var $sidebar = null;
  3600. $sidebar = elemnet.parents('.dj-list-body').first();
  3601. if (scope.isunfold) {
  3602. $sidebar.addClass('pt-sidebar-collapsed-back');
  3603. } else {
  3604. $sidebar.addClass('pt-sidebar-collapsed');
  3605. }
  3606. var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
  3607. sidebarDivs.eq(0).addClass('sidebar1');
  3608. sidebarDivs.eq(1).addClass('content1');
  3609. scope.$watch("isunfold", function (newVal, oldVal) {
  3610. scope.isshowtogglebtn = newVal;
  3611. if ($sidebar) {
  3612. if (newVal) {
  3613. $sidebar.removeClass('pt-sidebar-collapsed');
  3614. $sidebar.addClass('pt-sidebar-collapsed-back');//展开
  3615. } else {
  3616. $sidebar.removeClass('pt-sidebar-collapsed-back');
  3617. $sidebar.addClass('pt-sidebar-collapsed');//收缩
  3618. }
  3619. }
  3620. });
  3621. //定义组织树数据
  3622. scope.treeList = [];//组织树数据
  3623. scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
  3624. var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
  3625. var dwdm = "";//党委代码
  3626. scope.selectdzzdm = dataDzzdm;
  3627. if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
  3628. scope.parentcode = dataDzzdm;
  3629. scope.dzzdm = "";
  3630. scope.selectdzzmc = "全集团党组织";
  3631. } else {
  3632. scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
  3633. scope.dzzdm = dataDzzdm;
  3634. dwdm = dataDzzdm.substring(0, 12);
  3635. }
  3636. //获取分组(集团领导)
  3637. scope.loadPartyGroupList = function () {
  3638. $http
  3639. ({
  3640. method: 'get', url: '../../api/party/getPartyGroupTreeList', params:
  3641. { dzzdm: dwdm, onlyshow_dw: scope.onlyshowdw }
  3642. }).then(function (result) {
  3643. scope.treeList = result.data;
  3644. //默认选中党委
  3645. if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  3646. var defaultItem = scope.getPartyNode(scope.treeList);
  3647. if (defaultItem != null) {
  3648. scope.groupClick(defaultItem);
  3649. }
  3650. }
  3651. });
  3652. };
  3653. scope.getPartyNode = function (nodeList) {
  3654. var defaultItem = null;
  3655. for (var i = 0; i < nodeList.length; i++) {
  3656. if (nodeList[i].id == scope.defaultselected.substring(0, 12)) {
  3657. return nodeList[i];
  3658. }
  3659. if (nodeList[i].childs.length > 0) {
  3660. defaultItem = scope.getPartyNode(nodeList[i].childs);
  3661. if (defaultItem != null) {
  3662. return defaultItem;
  3663. }
  3664. }
  3665. }
  3666. };
  3667. //查询上级组织(党员)
  3668. scope.loadParentParty = function () {
  3669. $http
  3670. ({
  3671. method: 'get', url: '../../api/party/getNewPartyTreeList', params:
  3672. {
  3673. parentCode: scope.parentcode,
  3674. isshowxz: 1,
  3675. dzzdm: scope.dzzdm,
  3676. onlyshow_dw: scope.onlyshowdw
  3677. }
  3678. }).then(function (result) {
  3679. var list = [];
  3680. angular.forEach(result.data.item, function (val, index) {
  3681. val.fullcode = scope.parentcode;
  3682. list.push(val);
  3683. });
  3684. scope.treeList = list;
  3685. if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].id == scope.selectdzzdm)) {
  3686. scope.groupClick(scope.treeList[0]);
  3687. }
  3688. //默认选中党委
  3689. if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  3690. //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
  3691. var defaultItem = $filter("filter")(list, { id: scope.defaultselected.substring(0, 12) });
  3692. if (defaultItem.length > 0) {
  3693. scope.groupClick(defaultItem[0]);
  3694. }
  3695. }
  3696. });
  3697. };
  3698. //查询子级架构
  3699. scope.loadChildParty = function (node) {
  3700. scope.selectdzzdm = node.id;
  3701. scope.selectdzzmc = node.name;
  3702. //onlyshowdw==2 只显示一级党委 不加载下一级
  3703. if (scope.onlyshowdw != 2 && node.isexpand > 0 && node.partyCount > 0) {
  3704. $http
  3705. ({
  3706. method: 'get', url: '../../api/party/getNewPartyTreeList', params:
  3707. {
  3708. parentCode: node.id,
  3709. isshowxz: 1,
  3710. onlyshow_dw: scope.onlyshowdw
  3711. }
  3712. }).then(function (result) {
  3713. var list = [];
  3714. angular.forEach(result.data.item, function (val, index) {
  3715. val.fullcode = node.fullcode + '.' + node.id;
  3716. list.push(val);
  3717. });
  3718. node.childs = list;
  3719. //默认选中
  3720. if (node.id != scope.defaultselected && scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  3721. var defaultItem = $filter("filter")(list, { id: scope.defaultselected.substring(0, node.id.length + 3) });
  3722. if (defaultItem.length > 0) {
  3723. scope.groupClick(defaultItem[0]);
  3724. }
  3725. }
  3726. });
  3727. }
  3728. };
  3729. //点击节点
  3730. scope.groupClick = function (node) {
  3731. var isexpand = node.isexpand > 0 ? 0 : 1;
  3732. scope.resetActive(node);
  3733. node.isexpand = isexpand;
  3734. if (node.nodetype == 2) {
  3735. scope.loadChildParty(node);
  3736. }
  3737. };
  3738. //重置选中项
  3739. scope.resetActive = function (node) {
  3740. var checkIds = node.fullcode.split('.');
  3741. checkIds.push(node.id);
  3742. angular.forEach(scope.treeList, function (val, index) {
  3743. val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
  3744. if (val.childs != null && val.childs.length > 0) {
  3745. scope.resetActive_child(val.childs, checkIds);
  3746. }
  3747. });
  3748. };
  3749. scope.resetActive_child = function (list, checkIds) {
  3750. angular.forEach(list, function (val, index) {
  3751. val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
  3752. if (val.childs != null && val.childs.length > 0) {
  3753. scope.resetActive_child(val.childs, checkIds);
  3754. }
  3755. });
  3756. };
  3757. if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
  3758. //初始化数据
  3759. scope.loadPartyGroupList();
  3760. } else {
  3761. scope.loadParentParty();
  3762. }
  3763. }
  3764. }
  3765. }).directive("gtCalendar", function ($http, $window, $ocLazyLoad, $timeout) {
  3766. return {
  3767. restrict: 'EA',
  3768. require: '?ngModel',
  3769. link: function (scope, element, attrs, ctrl) {
  3770. $ocLazyLoad.load(['../../scripts/calendar.css', '../../scripts/calendar.js']).then(function () {
  3771. /*$timeout(function () {
  3772. var option = scope.$eval(attrs.cdOption);
  3773. option.height = element[0].offsetWidth - 10;
  3774. option.width = element[0].offsetWidth;
  3775. var myCalendar = $(element[0]).calendar(option);
  3776. //监控option数据变化
  3777. scope.$watch(
  3778. attrs["cdOption"],
  3779. function () {
  3780. var option = scope.$eval(attrs.cdOption);
  3781. if (angular.isObject(option)) {
  3782. //绘制图表
  3783. myCalendar.calendar(option)
  3784. }
  3785. },
  3786. true
  3787. );
  3788. }, 100);
  3789. scope.getDom = function () {
  3790. return {
  3791. height: element[0].parentElement.offsetHeight,
  3792. width: element[0].parentElement.offsetWidth
  3793. };
  3794. };
  3795. //监控图表宽高变化,响应式
  3796. scope.$watch(
  3797. scope.getDom,
  3798. function () {
  3799. var option = scope.$eval(attrs.cdOption);
  3800. option.height = element[0].parentElement.offsetWidth - 10;
  3801. option.width = element[0].parentElement.offsetWidth;
  3802. var myCalendar = $(element[0]).calendar(option);
  3803. },
  3804. true
  3805. );*/
  3806. var option = scope.$eval(attrs.cdOption);
  3807. option.height = option.height || (element[0].offsetWidth - 10);
  3808. option.width = option.width || element[0].offsetWidth;
  3809. var myCalendar = $(element[0]).calendar(option);
  3810. //监控option数据变化
  3811. scope.$watch(
  3812. attrs["cdOption"],
  3813. function () {
  3814. var option = scope.$eval(attrs.cdOption);
  3815. if (angular.isObject(option)) {
  3816. //更新数据
  3817. myCalendar.calendar("setData", option.data)
  3818. }
  3819. },
  3820. true
  3821. );
  3822. });
  3823. }
  3824. }
  3825. }).directive('rolePermissionCode', function ($http, AuthUser) {
  3826. var sUrl = '/api/user/UserPermissionStatus';
  3827. return {
  3828. restrict: 'A',
  3829. link: function (scope, element, attrs, ctrl) {
  3830. //attrs['rolePermissionCode']
  3831. element.hide();
  3832. if (scope.PermissionCodeData == null) {
  3833. scope.PermissionCodeData = {};
  3834. }
  3835. if (scope.PermissionCodeData[attrs['rolePermissionCode']] == null) {
  3836. scope.PermissionCodeData[attrs['rolePermissionCode']] = { eles: [element], val: null };
  3837. $http.get(sUrl, { params: { code: attrs['rolePermissionCode'], roleId: AuthUser.getUser().curRoleId } }).then(
  3838. function (res) {
  3839. scope.PermissionCodeData[attrs['rolePermissionCode']].val = res.data.success;
  3840. if (res.data.success) {
  3841. //一起处理显示状态
  3842. $ang.forEach(scope.PermissionCodeData[attrs['rolePermissionCode']].eles, function (el) {
  3843. el.show();
  3844. });
  3845. }
  3846. }, function (rs) {
  3847. }
  3848. );
  3849. } else {
  3850. //网络返回速度慢过js执行数时,保存在列表上,等返回再一起处理显示状态。
  3851. scope.PermissionCodeData[attrs['rolePermissionCode']].eles.push(element);
  3852. if (scope.PermissionCodeData[attrs['rolePermissionCode']].val != null) {
  3853. if (scope.PermissionCodeData[attrs['rolePermissionCode']].val) {
  3854. element.show();
  3855. }
  3856. }
  3857. }
  3858. }
  3859. };
  3860. }).directive("bsDatetimepicker", ['$timeout', function ($timeout) {
  3861. return {
  3862. require: '?ngModel',
  3863. restrict: 'AE',
  3864. scope: {
  3865. ngModel: '=',
  3866. beginDate: '@',
  3867. endDate: '@',
  3868. minView: '@',// 最精确的时间 0-4越小越精确 0-分钟; 1-小时; 2-天; 3-月 ; 4-年
  3869. maxView: '@',//最高能展示的时间,默认为年
  3870. startView: '@', //— 选完时间首先显示的视图 0:分钟;1:小时;2:天:3:月;4:年
  3871. format: '@',//默认显示月视图,不显示时分秒
  3872. todayBtn: '@',//今天按钮是否显示, 默认显示
  3873. todayHighlight: '@',//当天显示是否高亮,默认显示
  3874. showMeridian: '@',//是否显示上下午,默认不显示
  3875. weekStart: '@',// 一周从哪一天开始显示,默认为7,表示从周日开始显示
  3876. daysOfWeekDisabled: '@', //一周的周几不能选择[0,4,6]
  3877. forceParse: '@',//强制解析,输入的可能不正规,但是它胡强制尽量解析成你规定的格式(format) 默认解析
  3878. autoclose: '@'//选完时间后是否自动关闭 ,默认true,表示关闭
  3879. },
  3880. link: function (scope, element, attr, ngModel) {
  3881. $timeout(function () {
  3882. element.datetimepicker({
  3883. showMeridian: scope.showMeridian ? scope.showMeridian : false,
  3884. todayBtn: scope.todayBtn ? scope.todayBtn : true,
  3885. todayHighlight: scope.todayHighlight ? scope.todayHighlight : true,
  3886. weekStart: scope.weekStart ? scope.weekStart : 0,
  3887. daysOfWeekDisabled: scope.daysOfWeekDisabled ? scope.daysOfWeekDisabled : [],
  3888. forceParse: scope.forceParse ? scope.forceParse : true,
  3889. autoclose: scope.autoclose ? scope.autoclose : true, //
  3890. minView: scope.minView ? scope.minView : 2,
  3891. maxView: scope.maxView ? scope.maxView : 4,
  3892. startView: scope.startView ? scope.startView : 2,
  3893. format: scope.format ? scope.format : 'yyyy-mm-dd',
  3894. inline: true,
  3895. language: 'cn',
  3896. keyboardNavigation: true,//方向键改变日期
  3897. /*onSelect: function(dateText) {
  3898. console.log(dateText)
  3899. var modelPath = $(this).attr('ng-model');
  3900. putObject(modelPath, scope, dateText);
  3901. scope.$apply();
  3902. },*/
  3903. });
  3904. element.on('click', function (e) {//设置最大最小时间限制
  3905. e.currentTarget.blur();
  3906. if (attr.hasOwnProperty('beginDate')) {
  3907. element.datetimepicker('setStartDate', attr.beginDate);
  3908. }
  3909. if (attr.hasOwnProperty('endDate')) {
  3910. element.datetimepicker('setEndDate', attr.endDate);
  3911. }
  3912. });
  3913. }, 0)
  3914. }
  3915. }
  3916. }]).directive('selectFilter', function ($ocLazyLoad, $parse) {
  3917. return {
  3918. restrict: 'EA',
  3919. require: '?ngModel',
  3920. link: function (scope, element, attrs, ctrl) {
  3921. $ocLazyLoad.load('../../scripts/jqueryPlugins/selectFilter.js').then(function () {
  3922. element.selectFilter({
  3923. callBack: function (val) {
  3924. //返回选择的值
  3925. console.log(val + '-是返回的值');
  3926. if (!ctrl) {
  3927. return;
  3928. }
  3929. //ctrl.$modelValue = val;
  3930. element[0].value = val;
  3931. //更新模型
  3932. $parse(attrs['ngModel']).assign(scope, element[0].value);
  3933. scope.$apply();
  3934. }
  3935. });
  3936. });
  3937. }
  3938. }
  3939. }).provider('$bsRouterState', function () {
  3940. var defaults = this.defaults = {
  3941. routeTypes: ['url', 'tab'],
  3942. activeRouteType: 'tab',
  3943. activeTabUrl: 'tabsIndex',
  3944. activeRouteName: 'homeTabs',
  3945. urlToTabRex: 'home.',
  3946. initTabName: 'home.index'
  3947. };
  3948. var routes = [], tabs = [], iniComplete = false;
  3949. tabs.activeTab = '';
  3950. this.copyUrlState = function (urlStates) {
  3951. angular.forEach(urlStates, function (val, key) {
  3952. if (key.indexOf(defaults.urlToTabRex) >= 0) {
  3953. this.push(val.self);
  3954. }
  3955. }, routes);
  3956. };
  3957. this.$get = function ($state, $filter, $http, $timeout) {
  3958. var $link = {};
  3959. var showTab = function (name, params, reload) {
  3960. //当没有加载完就显示首页时等齐
  3961. /*
  3962. var addTitles=$filter('filter')(routes, function (route) {
  3963. return route.title!=null;
  3964. });*/
  3965. if (!iniComplete) {
  3966. $timeout(function () {
  3967. showTab(name, params, reload);
  3968. }, 100);
  3969. return false;
  3970. }
  3971. var existTabs = $filter('filter')(tabs, function (x) {
  3972. return x.name == name;
  3973. });
  3974. if (reload) {
  3975. var indexTab = tabs.indexOf(existTabs[0]);
  3976. if (indexTab >= 0) {
  3977. tabs.splice(indexTab, 1);
  3978. //existTabs.length=0;
  3979. $timeout(function () {
  3980. showTab(name, params);
  3981. }, 100);
  3982. return false;
  3983. }
  3984. }
  3985. if (existTabs.length <= 0) {
  3986. var curRoute = $filter('filter')(routes, function (route) {
  3987. return route.name == name && route.title
  3988. });
  3989. if (curRoute.length > 0) {
  3990. var newTabs = angular.copy(curRoute[0]);
  3991. if (!newTabs.params) {
  3992. newTabs.params = {};
  3993. }
  3994. angular.extend(newTabs.params, params);
  3995. tabs.push(newTabs);
  3996. //$link.params=params;
  3997. tabs.activeTab = name;
  3998. }
  3999. } else {
  4000. tabs.activeTab = name;
  4001. }
  4002. return true;
  4003. };
  4004. var closeTab = function (tab) {
  4005. var indexTab = tabs.indexOf(tab.panedata);
  4006. if (indexTab >= 0) {
  4007. tabs.splice(indexTab, 1);
  4008. }
  4009. };
  4010. var closeTabName = function (tabName) {
  4011. var existTabs = $filter('filter')(tabs, function (val) {
  4012. return val.name == tabName;
  4013. });
  4014. angular.forEach(existTabs, function (eTab) {
  4015. var tabScope = { panedata: eTab };
  4016. closeTab(tabScope);
  4017. });
  4018. };
  4019. var buildTabRoute = function (menuList) {
  4020. recursiveBuildTab(menuList);
  4021. //angular.forEach(routes, function (route) {
  4022. // route.canClose = true;
  4023. // var menus = $filter('filter')(menuList, function (menu) {
  4024. // return menu.Url == route.name;
  4025. // });
  4026. // if (menus.length > 0) {
  4027. // route.title = menus[0].Title;
  4028. // } else {
  4029. // route.title = null;
  4030. // }
  4031. //});
  4032. setCloseState(defaults.initTabName, false);
  4033. iniComplete = true;
  4034. /*
  4035. var initTabs = $filter('filter')(routes, {name: defaults.initTabName});
  4036. angular.forEach(initTabs, function (it) {
  4037. it.canClose = false;
  4038. });
  4039. showTab(defaults.initTabName, {});
  4040. */
  4041. };
  4042. var recursiveBuildTab = function (menuList) {
  4043. angular.forEach(menuList, function (menu) {
  4044. var routers = $filter('filter')(routes, function (route) {
  4045. return menu.Url == route.name;
  4046. });
  4047. angular.forEach(routers, function (route) {
  4048. route.title = menu.Title;
  4049. route.canClose = true;
  4050. });
  4051. recursiveBuildTab(menu.Childrens);
  4052. });
  4053. };
  4054. var setCloseState = function (tabName, canClose) {
  4055. var initTabs = $filter('filter')(routes, function (val) {
  4056. return val.name == tabName;
  4057. });
  4058. angular.forEach(initTabs, function (it) {
  4059. it.canClose = canClose;
  4060. });
  4061. };
  4062. //var setPath
  4063. var loadTabMenu = function () {
  4064. iniComplete = false;
  4065. $http.get('../../api/menumanage/tabMenuList').then(function (req) {
  4066. if (req.data.success) {
  4067. buildTabRoute(req.data.item);
  4068. }
  4069. });
  4070. };
  4071. $link.defaults = defaults;
  4072. $link.go = function (name, urlData, reload) {
  4073. if (this.$getRouteType() == 'tab') {
  4074. //$link.params=urlData;
  4075. showTab(name, urlData, reload);
  4076. } else {
  4077. $state.go(name, urlData);
  4078. }
  4079. };
  4080. $link.$getRouteType = function () {
  4081. return $state.is(defaults.activeRouteName) ? defaults.routeTypes[1] : defaults.routeTypes[0];
  4082. };
  4083. $link.buildTabRoute = buildTabRoute;
  4084. $link.loadTabMenu = loadTabMenu;
  4085. $link.tabs = tabs;
  4086. $link.$setCloseState = setCloseState;
  4087. $link.$showTab = showTab;
  4088. $link.$closeTab = closeTab;
  4089. $link.$closeTabName = closeTabName;
  4090. $link.$params = function (scope) {
  4091. if ($link.$getRouteType() == 'tab') {
  4092. return scope.panedata.params;
  4093. } else {
  4094. return $state.params;
  4095. }
  4096. };
  4097. return $link;
  4098. }
  4099. }).directive('bsUiSref', function ($bsRouterState) {
  4100. var directiveObject = {
  4101. scope: true,
  4102. link: function postLink(scope, element, attrs, controllers) {
  4103. element.bind('click', function () {
  4104. scope.$apply(function () {
  4105. var uiSref = attrs['bsUiSref'];
  4106. var dataJson = uiSref.match(/\((.+?)\)/);
  4107. if (dataJson) {
  4108. var nameJson = uiSref.match(/(.+?)\(/);
  4109. $bsRouterState.go(nameJson[1], eval(dataJson[0]));
  4110. } else {
  4111. $bsRouterState.go(uiSref, {});
  4112. }
  4113. });
  4114. });
  4115. }
  4116. };
  4117. return directiveObject;
  4118. }).directive('activePartytree', ['$timeout', function ($timeout) {
  4119. var activateFun = function (scope, $element) {
  4120. var scrollTop = 0;
  4121. var el = $element.find("div");
  4122. angular.forEach(el, function (item) {
  4123. if (item.className == "party_active") {
  4124. scrollTop = item.offsetTop;
  4125. }
  4126. });
  4127. $element[0].scrollTop = scrollTop;
  4128. };
  4129. var directiveObject = {
  4130. restrict: 'AC',
  4131. link: function (scope, element, attr, controller) {
  4132. $timeout(function () {
  4133. activateFun(scope, element);
  4134. }, 200)
  4135. }
  4136. };
  4137. return directiveObject;
  4138. }]).directive('selectedPartyname', function ($compile) {
  4139. var directiveObject = {
  4140. restrict: 'EAC',
  4141. template: function (tElement, tAttrs) {
  4142. var html = '<div class="select-party">当前选中组织:{{selectdzzmc}}<span ng-if="ptotal!=null">,共有{{ptotal}}{{unit}}。</span></div>';
  4143. return html;
  4144. },
  4145. scope: {
  4146. selectdzzmc: '=?',
  4147. ptotal: '=?',
  4148. unit: '=?'
  4149. },
  4150. link: function (scope, element, attr, controller) {
  4151. }
  4152. };
  4153. return directiveObject;
  4154. }).factory('$uuid', ['$filter', function ($filter) {
  4155. var result = {};
  4156. result.getUUID = function () {
  4157. var d = new Date().getTime();
  4158. var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  4159. var r = (d + Math.random() * 16) % 16 | 0;
  4160. d = Math.floor(d / 16);
  4161. return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
  4162. });
  4163. return uuid;
  4164. };
  4165. return result;
  4166. }]).directive("zeroTableHeight", ['$timeout', function ($timeout) {
  4167. var f_time = function (element) {
  4168. var $tarTable = element.parents('table');
  4169. var $sourceTable = element.parents('.zero-list-table-panel').find(".zero-source-table-div table");
  4170. var $tarTr = $tarTable.find('tr');
  4171. var $sourceTr = $sourceTable.find('tr');
  4172. for (var i = 0; i < $tarTr.length; i++) {
  4173. var $sourceTd = $sourceTr.eq(i).find('td:first');
  4174. var $tarTd = $tarTr.eq(i).find('td:first');
  4175. if ($sourceTd.height() >= $tarTd.height()) {
  4176. $tarTd.height($sourceTd.height());
  4177. } else {
  4178. $sourceTd.height($tarTd.height());
  4179. }
  4180. }
  4181. /*
  4182. var $table=element.parents('table');
  4183. var $thead=$table.find('thead');
  4184. var t_width=0;
  4185. if($table.parent('.zero-source-table-div').has()){
  4186. var $divSourceDiv=$('<div class="zero-source-table-div"></div>');
  4187. var $divTargetTable=$('<table class="zero-target-table"><thead></thead><tbody></tbody></table>');
  4188. $table.before($divSourceDiv);
  4189. $table.before($divTargetTable);
  4190. $table.appendTo($divSourceDiv);
  4191. $.each($thead.find('th[zero-table-th]').toArray().reverse(),function (i,th){
  4192. t_width+=th.offsetWidth;
  4193. var thIndex=th.index();
  4194. var $tTh=$divTargetTable.find("thead tr").has()?$('<tr></tr>').appendTo($divTargetTable.find("thead")):$divTargetTable.find("thead tr").first();
  4195. $tTh.append(th);
  4196. $.each($table.find("tbody tr"),function (i,tr) {
  4197. var $tTr=$divTargetTable.find("tbody tr").eq(i).has()?$('<tr></tr>').appendTo($divTargetTable.find("thead")):$divTargetTable.find("tbody tr").eq(i);
  4198. tr.find('td').eq(thIndex).appendTo($tTr);
  4199. });
  4200. });
  4201. $divTargetTable.width(t_width);
  4202. }*/
  4203. };
  4204. var directiveObject = {
  4205. restrict: 'AC',
  4206. link: function (scope, element, attr, controller) {
  4207. if (scope.$last === true) {
  4208. $timeout(function () {
  4209. f_time(element);
  4210. }, 500);
  4211. }
  4212. }
  4213. };
  4214. return directiveObject;
  4215. }]).filter('trustAsHtml',
  4216. [
  4217. '$sce', function ($sce) {
  4218. return function (text) {
  4219. return $sce.trustAsHtml(text);
  4220. }
  4221. }]).directive('panelTitle', function ($compile) {
  4222. var directiveObject = {
  4223. restrict: 'EAC',
  4224. template: function (tElement, tAttrs) {
  4225. 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>';
  4226. return html;
  4227. },
  4228. scope: {
  4229. title: '=?'
  4230. },
  4231. transclude: true,
  4232. link: function (scope, element, attr, controller) {
  4233. }
  4234. };
  4235. return directiveObject;
  4236. }).directive('foldPartytree', function ($compile) {
  4237. var directiveObject = {
  4238. restrict: 'EA',
  4239. require: '?ngModel',
  4240. templateUrl: '../js/template/modal_foldPartytree.html',
  4241. scope: {
  4242. isunfold: '=?',
  4243. },
  4244. link: function (scope, element, attr, controller) {
  4245. scope.isunfoldfun = function () {
  4246. scope.isunfold = !scope.isunfold;
  4247. scope.$emit('menudatas.toggle', !scope.isunfold);
  4248. }
  4249. }
  4250. };
  4251. return directiveObject;
  4252. }).directive("partyTreenew", function ($http, $ocLazyLoad, AuthUser, $filter) {
  4253. return {
  4254. restrict: 'EA',
  4255. require: '?ngModel',
  4256. //作用域
  4257. scope: {
  4258. selectdzzdm: '=', //等号是双向绑定,选中的党组织代码
  4259. selectdzzmc: '=', //等号是双向绑定,选中的党组织名称
  4260. height: '=',
  4261. csssrc: '=?',
  4262. onlyshowdw: '=?',//显示党委情况,1 组织架构只显示党委,2只显示一级党委(显示一级不能展开下一级)
  4263. defaultselected: '=?',//默认选中的党委代码
  4264. isunfold: '=?' //是否展开
  4265. },
  4266. templateUrl: '../js/template/modal_partyTreeNew.html',
  4267. link: function (scope, elemnet) {
  4268. $ocLazyLoad.load('../js/template/modal_partyTree.css');
  4269. scope.isunfold = scope.isunfold == undefined ? true : scope.isunfold;
  4270. //sidebar初始化
  4271. var $sidebar = null;
  4272. $sidebar = elemnet.parents('.dj-list-body').first();
  4273. if (scope.isunfold) {
  4274. $sidebar.addClass('pt-sidebar-collapsed-back');
  4275. } else {
  4276. $sidebar.addClass('pt-sidebar-collapsed');
  4277. }
  4278. var sidebarDivs = $sidebar.parent().find('.dj-list-body>div');
  4279. sidebarDivs.eq(0).addClass('sidebar1');
  4280. sidebarDivs.eq(1).addClass('content1');
  4281. scope.$watch("isunfold", function (newVal, oldVal) {
  4282. scope.isshowtogglebtn = newVal;
  4283. if ($sidebar) {
  4284. if (newVal) {
  4285. $sidebar.removeClass('pt-sidebar-collapsed');
  4286. $sidebar.addClass('pt-sidebar-collapsed-back');//展开
  4287. } else {
  4288. $sidebar.removeClass('pt-sidebar-collapsed-back');
  4289. $sidebar.addClass('pt-sidebar-collapsed');//收缩
  4290. }
  4291. }
  4292. });
  4293. //定义组织树数据
  4294. scope.treeList = [];//组织树数据
  4295. scope.gddwdm = AuthUser.getUser().gddwdm;//广东党委代码
  4296. var dataDzzdm = AuthUser.getUser().DataDzzdm;//数据权限
  4297. var dwdm = "";//党委代码
  4298. scope.selectdzzdm = dataDzzdm;
  4299. if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
  4300. scope.parentcode = dataDzzdm;
  4301. scope.dzzdm = "";
  4302. scope.selectdzzmc = "全集团党组织";
  4303. } else {
  4304. scope.parentcode = dataDzzdm.substring(0, dataDzzdm.length - 3);
  4305. scope.dzzdm = dataDzzdm;
  4306. dwdm = dataDzzdm.substring(0, 12);
  4307. }
  4308. //获取分组(集团领导)
  4309. scope.loadPartyGroupList = function () {
  4310. $http
  4311. ({
  4312. method: 'get', url: '../../api/party/getPartyGroupTreeList', params:
  4313. { dzzdm: dwdm }
  4314. }).then(function (result) {
  4315. scope.treeList = result.data;
  4316. });
  4317. };
  4318. //查询上级组织(党员)
  4319. scope.loadParentParty = function () {
  4320. $http
  4321. ({
  4322. method: 'get', url: '../../api/party/getNewPartyTreeList', params:
  4323. {
  4324. parentCode: scope.parentcode,
  4325. isshowxz: 1,
  4326. dzzdm: scope.dzzdm,
  4327. onlyshow_dw: scope.onlyshowdw
  4328. }
  4329. }).then(function (result) {
  4330. var list = [];
  4331. angular.forEach(result.data.item, function (val, index) {
  4332. val.fullcode = scope.parentcode;
  4333. list.push(val);
  4334. });
  4335. scope.treeList = list;
  4336. if (scope.treeList.length == 1 || (scope.treeList.length > 0 && scope.treeList[0].id == scope.selectdzzdm)) {
  4337. scope.groupClick(scope.treeList[0]);
  4338. }
  4339. //默认选中党委
  4340. if (scope.defaultselected != "" && scope.defaultselected != null && scope.defaultselected != undefined) {
  4341. //var defaultItem = list.filter(it => it.DZZDM == scope.defaultselected);
  4342. var defaultItem = $filter("filter")(list, { id: scope.defaultselected.substring(0, 12) });
  4343. if (defaultItem.length > 0) {
  4344. scope.groupClick(defaultItem[0]);
  4345. }
  4346. }
  4347. });
  4348. };
  4349. //查询子级架构
  4350. scope.loadChildParty = function (node) {
  4351. scope.selectdzzdm = node.id;
  4352. scope.selectdzzmc = node.name;
  4353. //onlyshowdw==2 只显示一级党委 不加载下一级
  4354. if (scope.onlyshowdw != 2 && node.isexpand > 0 && node.partyCount > 0) {
  4355. $http
  4356. ({
  4357. method: 'get', url: '../../api/party/getNewPartyTreeList', params:
  4358. {
  4359. parentCode: node.id,
  4360. isshowxz: 1,
  4361. onlyshow_dw: scope.onlyshowdw
  4362. }
  4363. }).then(function (result) {
  4364. var list = [];
  4365. angular.forEach(result.data.item, function (val, index) {
  4366. val.fullcode = node.fullcode + '.' + node.id;
  4367. list.push(val);
  4368. });
  4369. node.childs = list;
  4370. });
  4371. }
  4372. };
  4373. //点击节点
  4374. scope.groupClick = function (node) {
  4375. var isexpand = node.isexpand > 0 ? 0 : 1;
  4376. scope.resetActive(node);
  4377. node.isexpand = isexpand;
  4378. if (node.nodetype == 2) {
  4379. scope.loadChildParty(node);
  4380. }
  4381. };
  4382. //重置选中项
  4383. scope.resetActive = function (node) {
  4384. var checkIds = node.fullcode.split('.');
  4385. checkIds.push(node.id);
  4386. angular.forEach(scope.treeList, function (val, index) {
  4387. val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
  4388. if (val.childs != null && val.childs.length > 0) {
  4389. scope.resetActive_child(val.childs, checkIds);
  4390. }
  4391. });
  4392. };
  4393. scope.resetActive_child = function (list, checkIds) {
  4394. angular.forEach(list, function (val, index) {
  4395. val.isexpand = $.inArray(val.id, checkIds) >= 0 ? 1 : 0;
  4396. if (val.childs != null && val.childs.length > 0) {
  4397. scope.resetActive_child(val.childs, checkIds);
  4398. }
  4399. });
  4400. };
  4401. if (dataDzzdm == scope.gddwdm) {//有查看全集团数据的权限
  4402. //初始化数据
  4403. scope.loadPartyGroupList();
  4404. } else {
  4405. scope.loadParentParty();
  4406. }
  4407. }
  4408. }
  4409. }).directive("dictionaryCode", function ($http, $compile) {
  4410. return {
  4411. restrict: 'A',
  4412. 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>',
  4413. scope: {
  4414. ngModel: '=',
  4415. emptyTitle: '@'
  4416. },
  4417. link: function (scope, element, attr, controller) {
  4418. if (element[0].tagName == "SELECT") {
  4419. scope.dicList = [];
  4420. $http.post('../../api/systemsetting/dictionary/getdicList', { code: attr.dictionaryCode })
  4421. .then(function (res) {
  4422. if (res.data.IsSuccess) {
  4423. scope.dicList = res.data.Data;
  4424. }
  4425. });
  4426. }
  4427. }
  4428. }
  4429. }).directive("linkCondition", function ($http, $ocLazyLoad, AuthUser, $filter) {
  4430. return {
  4431. restrict: 'EA',
  4432. require: 'ngModel',
  4433. replace: true,
  4434. //作用域
  4435. scope: {
  4436. ngModel: '=',
  4437. sourceList: '=',
  4438. valueField: '@',
  4439. textField: '@',
  4440. defaultCount: '@',
  4441. alwaysSelectAll: '=',
  4442. isMultiSelect: '=',
  4443. colNum: '='
  4444. },
  4445. templateUrl: '../js/template/linkcondition.html',
  4446. link: function (scope, elemnet, attr, controller) {
  4447. scope.isShowAll = true;
  4448. scope.showText = "展开";
  4449. scope.selected = [];
  4450. scope.rowList = [];
  4451. scope.hide = true;
  4452. scope.limit = parseInt(scope.defaultCount);
  4453. if (scope.limit != null && !isNaN(scope.limit)) {
  4454. scope.isShowAll = false;
  4455. }
  4456. scope.$watch('isShowAll', function (newVal, oldVal) {
  4457. if (newVal) {
  4458. scope.showText = "收起";
  4459. } else {
  4460. scope.showText = "展开";
  4461. }
  4462. });
  4463. scope.isExists = function (val) {
  4464. if (scope.selected.filter(function (x) {
  4465. return x == val;
  4466. }).length > 0) {
  4467. return true;
  4468. } else {
  4469. return false;
  4470. }
  4471. };
  4472. scope.onClick = function (val) {
  4473. if (scope.alwaysSelectAll) {
  4474. scope.selected = [];
  4475. } else {
  4476. if (scope.isExists(val)) {
  4477. scope.selected = scope.selected.filter(function (x) {
  4478. return x != val;
  4479. });
  4480. } else {
  4481. if (scope.isMultiSelect != undefined && scope.isMultiSelect != null && scope.isMultiSelect == false && scope.selected.length != 0) {
  4482. scope.selected = [];
  4483. if (angular.isArray(scope.ngModel)) {
  4484. scope.ngModel = [val];
  4485. } else {
  4486. scope.ngModel = val;
  4487. }
  4488. }
  4489. scope.selected.push(val);
  4490. }
  4491. }
  4492. };
  4493. //反选操作
  4494. scope.transfer = function () {
  4495. if (scope.selected.length == 0) {
  4496. return;
  4497. }
  4498. var replaceList = scope.sourceList.filter(function (it) {
  4499. var ie = scope.selected.filter(function (x) {
  4500. return x == it[scope.valueField];
  4501. });
  4502. return ie.length == 0;
  4503. })
  4504. scope.selected = $.map(replaceList, function (it) {
  4505. return it[scope.valueField];
  4506. });
  4507. }
  4508. scope.$watch('selected.length', function (newVal, oldVal) {
  4509. if (newVal == oldVal) return;
  4510. if (newVal != null && newVal != 0) {
  4511. if (angular.isArray(scope.ngModel)) {
  4512. scope.ngModel = scope.selected;
  4513. } else {
  4514. scope.ngModel = scope.selected.join(',');
  4515. }
  4516. } else {
  4517. if (angular.isArray(scope.ngModel)) {
  4518. scope.ngModel = [];
  4519. } else {
  4520. scope.ngModel = null;
  4521. }
  4522. }
  4523. //$scope.loadData();
  4524. });
  4525. scope.$watch('ngModel', function (newVal, oldVal) {
  4526. if (angular.isArray(newVal)) {
  4527. scope.selected = newVal;
  4528. } else if (newVal != null) {
  4529. scope.selected = newVal.toString().split(",");
  4530. } else {
  4531. scope.selected = [];
  4532. }
  4533. });
  4534. //数据分行
  4535. scope.$watch('sourceList', function (newVal, oldVal) {
  4536. if (scope.colNum > 0 && scope.sourceList.length > 0) {
  4537. scope.hide = false;
  4538. var arrLength = scope.sourceList.length; // 数组长度
  4539. var num = scope.colNum > 0 ? scope.colNum : 10; // 列数
  4540. var index = 0;
  4541. for (let i = 0; i < arrLength; i++) {
  4542. if (i % num === 0 && i !== 0) { // 可以被 列数 整除
  4543. scope.rowList.push(scope.sourceList.slice(index, i));
  4544. index = i;
  4545. };
  4546. if ((i + 1) === arrLength) {
  4547. scope.rowList.push(scope.sourceList.slice(index, (i + 1)));
  4548. }
  4549. };
  4550. }
  4551. });
  4552. }
  4553. }
  4554. }).directive('moreSpan', function ($compile) {
  4555. var directiveObject = {
  4556. restrict: 'EA',
  4557. template: function (tElement, tAttrs) {
  4558. var html = '<span class="moreSpan" ng-click="isShowClick()">{{moreTxt}}<i class="material-icons">{{isShow ? "expand_less" : "expand_more"}}</i></span>';
  4559. return html;
  4560. },
  4561. scope: {
  4562. isShow: '=?'
  4563. },
  4564. link: function (scope, element, attr, controller) {
  4565. scope.isShow = scope.isShow || false;
  4566. scope.moreTxt = scope.isShow ? "收起" : "更多";
  4567. scope.isShowClick = function () {
  4568. scope.isShow = !scope.isShow;
  4569. scope.moreTxt = scope.isShow ? "收起" : "更多";
  4570. };
  4571. }
  4572. };
  4573. return directiveObject;
  4574. }).directive('thBind', function () {
  4575. var directiveObject = {
  4576. restrict: 'A',
  4577. template: function (tElement, tAttrs) {
  4578. var html = '{{title}}<span ng-if="required" style="color: red;">*</span>';
  4579. return html;
  4580. },
  4581. scope: {
  4582. title: '=?',
  4583. required: '=?',
  4584. },
  4585. link: function (scope, element, attr, controller) {
  4586. scope.required = scope.required || false;
  4587. }
  4588. };
  4589. return directiveObject;
  4590. }).directive('tdRownum', function () {
  4591. var directiveObject = {
  4592. restrict: 'A',
  4593. template: function (tElement, tAttrs) {
  4594. var html = '<span>{{pagesize*(pageindex-1)+index+1}}</span>';
  4595. return html;
  4596. },
  4597. scope: {
  4598. index: '=',
  4599. pageindex: '=',
  4600. pagesize: '=',
  4601. },
  4602. link: function (scope, element, attr, controller) {
  4603. element.parent().on('click', function () {
  4604. var tar1 = event.target;
  4605. if (tar1.nodeName == "TD") {
  4606. var ngStr = $(this).find("[type='checkbox']").attr('ng-model');
  4607. var funText = "scope.$parent." + ngStr + "=!scope.$parent." + ngStr + ";";
  4608. scope.$apply(function () {
  4609. eval(funText);
  4610. });
  4611. }
  4612. //event.stopPropagation();
  4613. });
  4614. }
  4615. };
  4616. return directiveObject;
  4617. }).directive('typeaheadInput', function ($http, $q, $ocLazyLoad) {
  4618. $ocLazyLoad.load('../js/template/modal_typeahead.css');
  4619. var directiveObject = {
  4620. restrict: 'AE',
  4621. require: 'ngModel',
  4622. template: function (tElement, tAttrs) {
  4623. 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"';
  4624. //data-trigger="click"
  4625. html += '/>';
  4626. html += '<input ng-show="readonly" class="form-control" readonly="readonly" ng-model="selectData.Text" type="text" />';
  4627. return html;
  4628. },
  4629. scope: {
  4630. url: '=',
  4631. params: '=',
  4632. readonly: '=',
  4633. width: '=',
  4634. selectname: '='
  4635. },
  4636. compile: function compile(tElement, tAttrs, transclude) {
  4637. return {
  4638. pre: function preLink(scope, iElement, iAttrs, ngModel) {
  4639. scope.selectData = '';
  4640. scope.selectList = [];
  4641. scope.isId = true;
  4642. scope.scollParams = {
  4643. showMore: 0,
  4644. canLoad: true,
  4645. msgs: ['--滚动加载更多--', '--加载中--', '--无更多数据--']
  4646. }
  4647. scope.selectedParams = {
  4648. pageIndex: 1,
  4649. pageSize: 10,
  4650. key: '',
  4651. id: '',
  4652. total: 10
  4653. };
  4654. scope.scollevent = function () {
  4655. if (scope.scollParams.canLoad) {
  4656. scope.scollParams.canLoad = false;
  4657. scope.loadItems();
  4658. }
  4659. }
  4660. scope.$watch(function () {
  4661. return ngModel.$modelValue;
  4662. }, function (newValue) {
  4663. if (scope.selectData != null && scope.selectData.Value == ngModel.$modelValue) {
  4664. return false;
  4665. }
  4666. if (newValue != null && newValue.length > 0 && scope.scollParams.canLoad) {
  4667. scope.scollParams.canLoad = false;
  4668. scope.selectedParams.id = newValue;
  4669. scope.selectedParams.key = '';
  4670. scope.loadItems();
  4671. //scope.findItems('');
  4672. }
  4673. });
  4674. scope.$watch('selectData', function (newValue, oldValue) {
  4675. if (typeof (newValue) != 'string') {
  4676. scope.selectname = newValue.Text;
  4677. return false;
  4678. }
  4679. else {
  4680. scope.selectname = newValue;
  4681. }
  4682. /*if (scope.scollParams.canLoad) {
  4683. //重置加载
  4684. scope.scollParams.showMore = 0;
  4685. //scope.selectedParams.id = '';
  4686. scope.selectedParams.key = newValue;
  4687. scope.selectedParams.pageIndex = 1;
  4688. scope.selectList.length = 0;
  4689. scope.loadItems();
  4690. }*/
  4691. });
  4692. scope.findItems = function (key) {
  4693. var Items$ = $q.defer();
  4694. if (scope.isId) {
  4695. if (ngModel.$modelValue) {
  4696. scope.selectedParams.id = ngModel.$modelValue;
  4697. } else {
  4698. scope.isId = false;
  4699. }
  4700. }
  4701. var isLoadData = typeof (key) == 'string';
  4702. isLoadData = isLoadData && key !== scope.selectData.Text;
  4703. //isLoadData = isLoadData && (key + id).length > 0;
  4704. scope.selectedParams.key = key;
  4705. //isLoadData = false;
  4706. if (isLoadData) {
  4707. $http({
  4708. method: "post",
  4709. url: scope.url,
  4710. data: angular.extend(scope.selectedParams, scope.params || {})
  4711. }).then(function (result) {
  4712. scope.selectList = result.data.Data;
  4713. if (scope.selectedParams.id.length > 0) {
  4714. if (result.data.Data.length == 1) {
  4715. scope.selectData = scope.selectList[0];
  4716. }
  4717. }
  4718. Items$.resolve(scope.selectList);
  4719. }, Items$.reject);
  4720. } else {
  4721. Items$.resolve(scope.selectList);
  4722. }
  4723. return Items$.promise;
  4724. };
  4725. scope.loadItems = function () {
  4726. var Items$ = $q.defer();
  4727. $http({
  4728. method: "post",
  4729. url: scope.url,
  4730. data: angular.extend(scope.selectedParams, scope.params || {})
  4731. }).then(function (result) {
  4732. //scope.selectList = result.data.Data;
  4733. /*angular.forEach(result.data.Data, function (val) {
  4734. scope.selectList.push(val);
  4735. });*/
  4736. scope.selectList = result.data.Data;
  4737. if (result.data.Data.length == scope.selectedParams.pageSize) {
  4738. scope.selectedParams.pageIndex++;
  4739. } else {
  4740. //不再加载
  4741. scope.scollParams.showMore = 2;
  4742. }
  4743. scope.scollParams.canLoad = true;
  4744. if (scope.selectedParams.id.length > 0) {
  4745. if (result.data.Data.length == 1) {
  4746. scope.selectData = scope.selectList[0];
  4747. }
  4748. scope.selectedParams.id = '';
  4749. }
  4750. if (!scope.selectData && ngModel.$modelValue) {
  4751. scope.selectData = scope.selectList.filter(it => it.Value == ngModel.$modelValue)[0];
  4752. }
  4753. Items$.resolve(scope.selectList);
  4754. }, Items$.reject);
  4755. return Items$.promise;
  4756. }
  4757. scope.selectedItem = function () {
  4758. if (scope.selectData.Value) {
  4759. ngModel.$setViewValue(scope.selectData.Value);
  4760. }
  4761. }
  4762. /*
  4763. scope.$watch("selectData", function (newVal, oldVal) {
  4764. if (typeof (newVal) == 'string' && newVal.length>0) {
  4765. $http({
  4766. method: "post",
  4767. url: scope.url,
  4768. data: { key: scope.selectData,id:'' }
  4769. }).then(function (result) {
  4770. scope.selectList = result.data.Data;
  4771. });
  4772. }
  4773. });*/
  4774. scope.loadItems();
  4775. },
  4776. post: function postLink(scope, iElement, iAttrs, controller) {
  4777. }
  4778. }
  4779. }
  4780. };
  4781. return directiveObject;
  4782. }).directive('whenScrolled', function () {
  4783. return function (scope, elm, attr) {
  4784. // 内层DIV的滚动加载
  4785. var raw = elm[0];
  4786. elm.on('scroll', function () {
  4787. if (raw.scrollTop + raw.offsetHeight + 10 >= raw.scrollHeight) {
  4788. raw.scrollTop -= 30;
  4789. scope.$apply(attr.whenScrolled);
  4790. };
  4791. });
  4792. };
  4793. }).filter('ConvertCurrencyFilter', ["$filter", function () {
  4794. return function (currency) {
  4795. // Constants:
  4796. var MAXIMUM_NUMBER = 99999999999.99;
  4797. // Predefine the radix characters and currency symbols for output:
  4798. var CN_ZERO = "零";
  4799. var CN_ONE = "壹";
  4800. var CN_TWO = "贰";
  4801. var CN_THREE = "叁";
  4802. var CN_FOUR = "肆";
  4803. var CN_FIVE = "伍";
  4804. var CN_SIX = "陆";
  4805. var CN_SEVEN = "柒";
  4806. var CN_EIGHT = "捌";
  4807. var CN_NINE = "玖";
  4808. var CN_TEN = "拾";
  4809. var CN_HUNDRED = "佰";
  4810. var CN_THOUSAND = "仟";
  4811. var CN_TEN_THOUSAND = "万";
  4812. var CN_HUNDRED_MILLION = "亿";
  4813. var CN_SYMBOL = "人民币";
  4814. var CN_DOLLAR = "元";
  4815. var CN_TEN_CENT = "角";
  4816. var CN_CENT = "分";
  4817. var CN_INTEGER = "整";
  4818. // Variables:
  4819. var integral; // Represent integral part of digit number.
  4820. var decimal; // Represent decimal part of digit number.
  4821. var outputCharacters; // The output result.
  4822. var parts;
  4823. var digits, radices, bigRadices, decimals;
  4824. var zeroCount;
  4825. var i, p, d;
  4826. var quotient, modulus;
  4827. if (currency == null || currency == undefined) {
  4828. return "零元整";
  4829. }
  4830. // Validate input string:
  4831. currency = currency.toString();
  4832. if (currency == "") {
  4833. //alert("Empty input!");
  4834. return "零元整";
  4835. }
  4836. if (currency.match(/[^-,.\d]/) != null) {
  4837. //alert("Invalid characters in the input string!");
  4838. //return "";
  4839. return "零元整";
  4840. }
  4841. if ((currency).match(/^(-*((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?)))$/) == null) {
  4842. /*alert("Illegal format of digit number!");
  4843. return "";*/
  4844. return "零元整";
  4845. }
  4846. // Normalize the format of input digits:
  4847. currency = currency.replace(/,/g, ""); // Remove comma delimiters.
  4848. currency = currency.replace(/^0+/, ""); // Trim zeros at the beginning.
  4849. var currencyDigits = Math.abs(currency);
  4850. currencyDigits = currencyDigits.toString();
  4851. // Assert the number is not greater than the maximum number.
  4852. if (Number(currencyDigits) > MAXIMUM_NUMBER) {
  4853. alert("Too large a number to convert!");
  4854. return "";
  4855. }
  4856. // Process the coversion from currency digits to characters:
  4857. // Separate integral and decimal parts before processing coversion:
  4858. parts = currencyDigits.split(".");
  4859. if (parts.length > 1) {
  4860. integral = parts[0];
  4861. decimal = parts[1];
  4862. // Cut down redundant decimal digits that are after the second.
  4863. decimal = decimal.substr(0, 2);
  4864. }
  4865. else {
  4866. integral = parts[0];
  4867. decimal = "";
  4868. }
  4869. // Prepare the characters corresponding to the digits:
  4870. digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
  4871. radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
  4872. bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
  4873. decimals = new Array(CN_TEN_CENT, CN_CENT);
  4874. // Start processing:
  4875. outputCharacters = "";
  4876. // Process integral part if it is larger than 0:
  4877. if (Number(integral) > 0) {
  4878. zeroCount = 0;
  4879. for (i = 0; i < integral.length; i++) {
  4880. p = integral.length - i - 1;
  4881. d = integral.substr(i, 1);
  4882. quotient = p / 4;
  4883. modulus = p % 4;
  4884. if (d == "0") {
  4885. zeroCount++;
  4886. }
  4887. else {
  4888. if (zeroCount > 0) {
  4889. outputCharacters += digits[0];
  4890. }
  4891. zeroCount = 0;
  4892. outputCharacters += digits[Number(d)] + radices[modulus];
  4893. }
  4894. if (modulus == 0 && zeroCount < 4) {
  4895. outputCharacters += bigRadices[quotient];
  4896. }
  4897. }
  4898. outputCharacters += CN_DOLLAR;
  4899. }
  4900. // Process decimal part if there is:
  4901. if (decimal != "") {
  4902. for (i = 0; i < decimal.length; i++) {
  4903. d = decimal.substr(i, 1);
  4904. if (d != "0") {
  4905. outputCharacters += digits[Number(d)] + decimals[i];
  4906. }
  4907. }
  4908. }
  4909. // Confirm and return the final output string:
  4910. if (outputCharacters == "") {
  4911. outputCharacters = CN_ZERO + CN_DOLLAR;
  4912. }
  4913. if (decimal == "") {
  4914. outputCharacters += CN_INTEGER;
  4915. }
  4916. outputCharacters = outputCharacters;
  4917. if (currency.match(/^-/)) {
  4918. outputCharacters = '负' + outputCharacters;
  4919. }
  4920. return outputCharacters;
  4921. }
  4922. }]).provider('popupReport', function () {
  4923. this.$get = function ($modal, $http, $loading) {
  4924. var popupReport = {
  4925. popup: function (title, getFileUrl, data) {
  4926. $loading.show();
  4927. $http.post(getFileUrl, data).then(function (res) {
  4928. $loading.hide();
  4929. var filePath = res.data.Data;
  4930. //filePath = '../../../../api/systemsetting/report?filePath=' + filePath;
  4931. filePath = filePath.replace("/content/template/", "");
  4932. popupReport.title = title;
  4933. popupReport.reportUrl = '../../lib/pdf.js/web/viewer.html?file=' + escape(filePath);
  4934. var modal = $modal({
  4935. resolve: {
  4936. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  4937. }]
  4938. },
  4939. controller: ctrl,
  4940. templateUrl: '../js/template/modal_report.html',
  4941. show: false,
  4942. size: 'lg',
  4943. animation: 'am-fade-and-slide-top'
  4944. });
  4945. modal.$promise.then(modal.show);
  4946. }, function (res) {
  4947. $loading.hide();
  4948. $scope.showMsg('系统信息', '服务器错误,打印失败。');
  4949. });
  4950. }
  4951. };
  4952. var ctrl = function ($scope) {
  4953. $scope.title = popupReport.title;
  4954. $scope.url = popupReport.reportUrl;
  4955. };
  4956. ctrl.$inject = ['$scope'];
  4957. return popupReport;
  4958. }
  4959. }).provider('preViewPDF', function () {
  4960. this.$get = function ($modal, $http, $loading) {
  4961. var preViewPDF = {
  4962. popup: function (title, url) {
  4963. preViewPDF.title = title;
  4964. preViewPDF.reportUrl = url;
  4965. var modal = $modal({
  4966. resolve: {
  4967. load: ['$ocLazyLoad', function ($ocLazyLoad) {
  4968. }]
  4969. },
  4970. controller: ctrl,
  4971. templateUrl: '../js/template/modal_report.html',
  4972. show: false,
  4973. size: 'lg',
  4974. animation: 'am-fade-and-slide-top'
  4975. });
  4976. modal.$promise.then(modal.show);
  4977. }
  4978. };
  4979. var ctrl = function ($scope) {
  4980. $scope.title = preViewPDF.title;
  4981. $scope.url = preViewPDF.reportUrl;
  4982. };
  4983. ctrl.$inject = ['$scope'];
  4984. return preViewPDF;
  4985. }
  4986. }).directive('bootsSelect', function ($compile) {
  4987. return {
  4988. restrict: 'A',
  4989. require: 'ngModel',
  4990. scope: {
  4991. optionDatas: '=',
  4992. ngModel: '='
  4993. },
  4994. link: function ($scope, $element, $attrs, $ngModel) {
  4995. $scope.$watch('optionDatas', function () {
  4996. var optionDatas = $scope.optionDatas;
  4997. if (optionDatas != undefined) {
  4998. $($element).selectpicker('refresh');
  4999. }
  5000. });
  5001. $scope.$watch('ngModel', function () {
  5002. $($element).selectpicker('refresh');
  5003. });
  5004. }
  5005. };
  5006. }).provider('excelPopup', function () {
  5007. this.$get = function ($modal, $http, $loading) {
  5008. var excelPopup = {
  5009. export: function (url, data, fileName) {
  5010. $loading.show();
  5011. $http.post(url, data).then(function (res) {
  5012. $loading.hide();
  5013. if (res.data.IsSuccess) {
  5014. var filePath = res.data.Data;
  5015. filePath = '../../../../api/systemsetting/excel?fileName=' + filePath + '&fileNewName=' + escape(fileName);
  5016. window.open(filePath);
  5017. } else {
  5018. $scope.showMsg('系统信息', '导出失败:' + res.data.Message);
  5019. }
  5020. }, function (res) {
  5021. $loading.hide();
  5022. $scope.showMsg('系统信息', '服务器错误,导出失败。');
  5023. });
  5024. }
  5025. };
  5026. return excelPopup;
  5027. }
  5028. }).directive('checkedRow', function () {
  5029. var directiveObject = {
  5030. restrict: 'AC',
  5031. scope: {
  5032. checkedRow: '='
  5033. },
  5034. link: function (scope, element, attr, controller) {
  5035. //element.find('td')
  5036. element.on('click', function () {
  5037. var tar1 = event.target;
  5038. if (tar1.nodeName == "TD") {
  5039. scope.$apply(function () {
  5040. scope.checkedRow = !scope.checkedRow;
  5041. });
  5042. }
  5043. });
  5044. }
  5045. };
  5046. return directiveObject;
  5047. }).directive('fixedTableHeader', function ($timeout, $compile) {
  5048. return {
  5049. restrict: 'A',
  5050. scope: {
  5051. fiexdFooter: '=?',//是否固定表格tfoot
  5052. /*fixedColumns:'=?',*/
  5053. maxHeight: '=?', //最大高度,默认自适应表格到底部的高度
  5054. fixedEndColumns: '=?'
  5055. },
  5056. link: function (scope, element, attr) {
  5057. if (scope.$parent.$last === true) {
  5058. var $table = $(element).parent().parent();
  5059. var $parent = $table.parent();
  5060. $table.fixedHeaderTable('destroy');
  5061. $timeout(function () {
  5062. $parent = $table.parent();
  5063. var parentHeight = 0;
  5064. var diffHeight = (scope.fixedEndColumns > 0 ? 15 : 0);//误差偏移量
  5065. var maxHeight = scope.maxHeight || ($(window).actual('height') - $table.offset().top - ($parent.parent().find(".grid-page").height() || 0) - 10);
  5066. if ($table.actual('height') < maxHeight) { //不需要出滚动条
  5067. parentHeight = $table.actual('height') + 10;
  5068. }
  5069. else {
  5070. parentHeight = maxHeight;
  5071. }
  5072. $parent.height(parentHeight + diffHeight);
  5073. if ($table.height() >= $table.parent().height() || scope.fixedEndColumns > 0) {
  5074. $table.fixedHeaderTable({ footer: scope.fiexdFooter || false, fixedEndColumns: scope.fixedEndColumns || 0 });
  5075. //全选
  5076. var $tableWrapper = $table.parent().parent();
  5077. $tableWrapper.find(".fht-thead").find('input[type="checkbox"]').on('click', function () {
  5078. var allChecked = this.checked;
  5079. var allCheckedInput = $tableWrapper.find(".fht-tbody").find("thead").find('input[type="checkbox"]');
  5080. var allCheckScope = allCheckedInput.scope();
  5081. allCheckedInput.prop("checked", allChecked);
  5082. allCheckScope.$apply(function () {
  5083. allCheckScope.checkAll();
  5084. });
  5085. });
  5086. //点击
  5087. $table.find(".text-left").find('i').on('click', function () {
  5088. try {
  5089. var $fixedColumn = $table.parent().parent().parent().find(".fht-fixed-column");
  5090. var trHeight = $(this).parent().parent().height() ?? 0;
  5091. var trNextHeight = $(this).parent().parent().next().height() ?? 0;
  5092. var name = $(this).attr('name');
  5093. var isexpanded = $(this).attr('isexpanded');
  5094. var $trs = $fixedColumn.find('.text-center');
  5095. for (var i = 0; i < $trs.length; i++) {
  5096. if ($trs[i].attributes.name.value == name) {
  5097. $($trs[i]).parent().height(isexpanded == 'true' ? (trHeight + trNextHeight) : trHeight);
  5098. break;
  5099. }
  5100. }
  5101. } catch (exception) { }
  5102. });
  5103. //双击
  5104. $table.find(".text-left").parent().on('dblclick', function () {
  5105. try {
  5106. var $fixedColumn = $table.parent().parent().parent().find(".fht-fixed-column");
  5107. var trHeight = $(this).height() ?? 0;
  5108. var trNextHeight = $(this).next().height() ?? 0;
  5109. var name = $($($(this).children()[0]).children()[1]).attr('name')
  5110. var isexpanded = $($($(this).children()[0]).children()[1]).attr('isexpanded')
  5111. var $trs = $fixedColumn.find('.text-center');
  5112. for (var i = 0; i < $trs.length; i++) {
  5113. if ($trs[i].attributes.name.value == name) {
  5114. $($trs[i]).parent().height(isexpanded == 'true' ? (trHeight + trNextHeight) : trHeight);
  5115. break;
  5116. }
  5117. }
  5118. } catch (exception) { }
  5119. });
  5120. //固定列
  5121. if (scope.fixedEndColumns > 0) {
  5122. try {
  5123. var $fixedColumn = $table.parent().parent().parent().find(".fht-fixed-column");
  5124. $compile($fixedColumn.contents())($table.scope());
  5125. $tableWrapper.find(".fht-tbody").height($tableWrapper.find(".fht-tbody").height() - 2);
  5126. $fixedColumn.find(".fht-tbody").height($fixedColumn.find(".fht-tbody").height() + 15);
  5127. $table.find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').find("*").attr("disabled", true);
  5128. var fiexdwidth = $tableWrapper.find(".fht-thead").find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').find(".fht-cell").width();
  5129. /*$fixedColumn.width(fiexdwidth + 45);*/
  5130. $table.find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').width(fiexdwidth + 1);
  5131. $tableWrapper.find(".fht-thead").find('tr > *:nth-child(n+' + ($table.find('th').length - scope.fixedEndColumns + 1) + ')').width(fiexdwidth);
  5132. var body = $tableWrapper.find(".fht-tbody");
  5133. if (body[0].scrollWidth <= body[0].clientWidth) {
  5134. $fixedColumn.width(fiexdwidth + 38);
  5135. }
  5136. //默认展开
  5137. var trHeight = $($table.find('tbody').find("tr")[0]).height() ?? 0;
  5138. var trNextHeight = $($table.find('tbody').find("tr")[0]).next().height() ?? 0;
  5139. $($fixedColumn.find('.text-center').parent()[0]).height(trNextHeight > trHeight ? (trHeight + trNextHeight) : trHeight);
  5140. } catch (exception) { }
  5141. }
  5142. }
  5143. });
  5144. }
  5145. }
  5146. };
  5147. }).provider('$postopen', function () {
  5148. this.$get = function () {
  5149. var funPost = function (url, args) {
  5150. var form = $("<form method='post'></form>");
  5151. form.attr({ "action": url });
  5152. $.each(args, function (i, n) {
  5153. var input = $("<input type='hidden'>");
  5154. input.attr({ "name": i });
  5155. input.val(n);
  5156. form.append(input);
  5157. });
  5158. $('body').append(form);
  5159. form.submit();
  5160. form.remove();
  5161. };
  5162. return funPost;
  5163. }
  5164. }).directive('tabExt', function () {
  5165. return {
  5166. restrict: 'A',
  5167. link: function (scope, element, attr) {
  5168. element.bind('contextmenu', function (event) {
  5169. event.preventDefault();
  5170. if (scope.$index != 0) {
  5171. var menu = angular.element('.tab-menu');
  5172. menu.css('display', 'block');
  5173. menu.mouseleave(function () {
  5174. menu.css('display', 'none');
  5175. });
  5176. menu.attr('index', scope.$index);
  5177. menu.offset({
  5178. left: event.pageX,
  5179. top: event.pageY
  5180. });
  5181. }
  5182. });
  5183. }
  5184. };
  5185. }).directive('tabMenu', function ($bsRouterState) {
  5186. return {
  5187. restrict: 'C',
  5188. link: function (scope, element, attr) {
  5189. scope.closeOtherLabel = '关闭其他';
  5190. scope.closeAllLabel = '关闭全部';
  5191. element.bind('contextmenu', function (event) {
  5192. event.preventDefault();
  5193. });
  5194. scope.closeOtherTab = function () {
  5195. var tabCount = $bsRouterState.tabs.length;
  5196. for (var i = tabCount - 1; i > 0; i--) {
  5197. if (i.toString() != element.attr('index')) {
  5198. $bsRouterState.$closeTabName($bsRouterState.tabs[i].name);
  5199. }
  5200. }
  5201. var menu = angular.element('.tab-menu');
  5202. menu.css('display', 'none');
  5203. }
  5204. scope.closeAllTab = function () {
  5205. var tabCount = $bsRouterState.tabs.length;
  5206. for (var i = tabCount - 1; i > 0; i--) {
  5207. $bsRouterState.$closeTabName($bsRouterState.tabs[i].name);
  5208. }
  5209. var menu = angular.element('.tab-menu');
  5210. menu.css('display', 'none');
  5211. }
  5212. }
  5213. };
  5214. }).directive('dragableHeader', function () {
  5215. return {
  5216. restrict: 'EAC',
  5217. link: function (scope, element, attrs) {
  5218. scope.obj = element[0];
  5219. scope.startx = 0;
  5220. scope.starty;
  5221. scope.startLeft;
  5222. scope.startTop;
  5223. scope.mainDiv = scope.obj.parentNode;
  5224. scope.isDown = false;
  5225. scope.originIndex = scope.mainDiv.style.zIndex;
  5226. var that = scope;
  5227. scope.movedown = function (e) {
  5228. e = e ? e : window.event;
  5229. if (!window.captureEvents) {
  5230. this.setCapture();
  5231. }
  5232. that.isDown = true;
  5233. that.obj.style.cursor = 'move';
  5234. that.mainDiv.style.zIndex = 1000;
  5235. that.startx = e.clientX;
  5236. that.starty = e.clientY;
  5237. that.startLeft = parseInt(that.mainDiv.offsetLeft);
  5238. that.startTop = parseInt(that.mainDiv.offsetTop);
  5239. }
  5240. scope.move = function (e) {
  5241. e = e ? e : window.event;
  5242. if (that.isDown) {
  5243. that.mainDiv.style.left = e.clientX - (that.startx - that.startLeft) + "px";
  5244. that.mainDiv.style.top = e.clientY - (that.starty - that.startTop) + "px";
  5245. }
  5246. }
  5247. scope.moveup = function () {
  5248. that.isDown = false;
  5249. that.obj.style.cursor = 'default';
  5250. that.mainDiv.style.zIndex = that.originIndex;
  5251. if (!window.captureEvents) {
  5252. this.releaseCapture();
  5253. }
  5254. }
  5255. scope.obj.onmousedown = scope.movedown;
  5256. scope.obj.onmousemove = scope.move;
  5257. scope.obj.onmouseup = scope.moveup;
  5258. //非ie浏览器
  5259. document.addEventListener("mousemove", scope.move, true);
  5260. }
  5261. };
  5262. }).directive('checkList', function () {
  5263. return {
  5264. restrict: 'EA',
  5265. replace: true,
  5266. require: 'ngModel',
  5267. scope: {
  5268. ngModel: '=',
  5269. sourceList: '=',
  5270. valueField: '@',
  5271. textField: '@',
  5272. defaultCount: '@?'
  5273. },
  5274. templateUrl: '../js/template/checklist.html',
  5275. link: function (scope, element, attrs) {
  5276. scope.isShowAll = true;
  5277. scope.showText = "展开";
  5278. scope.selected = [];
  5279. scope.limit = parseInt(scope.defaultCount);
  5280. if (scope.limit != null && !isNaN(scope.limit)) {
  5281. scope.isShowAll = false;
  5282. }
  5283. scope.$watch('isShowAll', function (newVal, oldVal) {
  5284. if (newVal) {
  5285. scope.showText = "收起";
  5286. } else {
  5287. scope.showText = "展开";
  5288. }
  5289. });
  5290. scope.isExists = function (val) {
  5291. if (scope.selected.filter(function (x) {
  5292. return x == val;
  5293. }).length > 0) {
  5294. return true;
  5295. } else {
  5296. return false;
  5297. }
  5298. };
  5299. scope.onClick = function (val) {
  5300. if (scope.isExists(val)) {
  5301. scope.selected = scope.selected.filter(function (x) {
  5302. return x != val;
  5303. });
  5304. } else {
  5305. scope.selected.push(val);
  5306. }
  5307. };
  5308. scope.$watch('selected.length', function (newVal, oldVal) {
  5309. if (newVal == oldVal) return;
  5310. if (newVal != null && newVal != 0) {
  5311. if (angular.isArray(scope.ngModel)) {
  5312. scope.ngModel = scope.selected;
  5313. } else {
  5314. scope.ngModel = scope.selected.join(',');
  5315. }
  5316. } else {
  5317. if (angular.isArray(scope.ngModel)) {
  5318. scope.ngModel = [];
  5319. } else {
  5320. scope.ngModel = null;
  5321. }
  5322. }
  5323. });
  5324. scope.$watch('ngModel', function (newVal, oldVal) {
  5325. if (angular.isArray(newVal)) {
  5326. scope.selected = newVal;
  5327. } else if (newVal != null) {
  5328. scope.selected = newVal.toString().split(",");
  5329. } else {
  5330. scope.selected = [];
  5331. }
  5332. });
  5333. }
  5334. };
  5335. }).directive('tugItemSelect', function ($http, $modal, $filter) {
  5336. var directiveObject = {
  5337. restrict: 'EAC',
  5338. scope: {
  5339. dataoptions: '='
  5340. },
  5341. link: function (scope, element, attr, controller) {
  5342. var sdModal = {};
  5343. if (!scope.dataoptions.selectedJData) {
  5344. scope.dataoptions.selectedJData = [];
  5345. }
  5346. scope.init = function () {
  5347. scope.dataoptions.selectedJData = [];
  5348. if (scope.dataoptions.selectedValueData && scope.dataoptions.selectedValueData.length > 0) {
  5349. var valueArray = scope.dataoptions.selectedValueData.split(',');
  5350. var labelArray = scope.dataoptions.selectedLabeData.split(',');
  5351. angular.forEach(valueArray, function (val, key) {
  5352. var it = {};
  5353. it[scope.dataoptions.selectValuekey] = val;
  5354. it[scope.dataoptions.selectLabelKey] = labelArray[key];
  5355. scope.dataoptions.selectedJData.push(it);
  5356. });
  5357. }
  5358. };
  5359. var sdModalController = function ($scope) {
  5360. $scope.selectparams = {
  5361. pageIndex: 1,
  5362. pageSize: 10,
  5363. itemTypeID: null,
  5364. code: null,
  5365. name: null,
  5366. itemType: null
  5367. };
  5368. $scope.ptotal = 0;
  5369. $scope.itemTypeList = [];
  5370. $scope.fdata = {
  5371. selectCols: [],
  5372. columns: scope.dataoptions.columns,
  5373. items: [],
  5374. ptotal: 0,
  5375. title: scope.dataoptions.title,
  5376. width: scope.dataoptions.width == null ? 70 : scope.dataoptions.width,
  5377. selectedJData: scope.dataoptions.selectedJData,
  5378. selectValuekey: scope.dataoptions.selectValuekey,
  5379. selectLabelKey: scope.dataoptions.selectLabelKey,
  5380. selectTemp: [],
  5381. isMulti: scope.dataoptions.isMulti
  5382. };
  5383. angular.forEach(scope.dataoptions.selectData, function (value, key) {
  5384. $scope.fdata.selectCols.push({ text: value, val: key });
  5385. });
  5386. $scope.getItemTypeList = function () {
  5387. $http({
  5388. method: 'post', url: '../../api/items/Item/GetTypeList', data: {}
  5389. }).then(function (result) {
  5390. if (result.data.IsSuccess) {
  5391. $scope.itemTypeList = result.data.Data;
  5392. } else {
  5393. $scope.showMsg('错误', result.data.Message);
  5394. }
  5395. });
  5396. };
  5397. $scope.loadData = function () {
  5398. $http.post(scope.dataoptions.url, $scope.selectparams).then(function (value) {
  5399. $scope.fdata.items = value.data.Data.rows;
  5400. $scope.ptotal = value.data.Data.total;
  5401. });
  5402. };
  5403. $scope.search = function () {
  5404. $scope.loadData();
  5405. };
  5406. $scope.findSData = function () {
  5407. $scope.selectparams.pageIndex = 1;
  5408. $scope.loadData();
  5409. };
  5410. $scope.addItem = function () {
  5411. var tableCheckedArray = $filter('filter')($scope.fdata.items, function (tIt) {
  5412. return tIt.checked;
  5413. });
  5414. angular.forEach(tableCheckedArray, function (value, key) {
  5415. var itemData = $filter('filter')($scope.fdata.selectedJData, function (it) {
  5416. return it[$scope.fdata.selectValuekey] == value[$scope.fdata.selectValuekey];
  5417. });
  5418. if (itemData.length == 0) {
  5419. $scope.fdata.selectedJData.push(value);
  5420. }
  5421. });
  5422. };
  5423. $scope.deleteItem = function (it) {
  5424. var i = -1;
  5425. if (it) {
  5426. i = $scope.fdata.selectedJData.indexOf(it);
  5427. $scope.fdata.selectedJData.splice(i, 1);
  5428. } else {
  5429. angular.forEach($scope.fdata.selectTemp, function (value, key) {
  5430. i = $scope.fdata.selectedJData.indexOf(value);
  5431. $scope.fdata.selectedJData.splice(i, 1);
  5432. });
  5433. }
  5434. };
  5435. $scope.selectedData = function () {
  5436. scope.dataoptions.selectedLabeData = '';
  5437. scope.dataoptions.selectedValueData = '';
  5438. var selectItem = {};
  5439. if ($scope.fdata.isMulti) {
  5440. angular.forEach($scope.fdata.selectedJData, function (value, key) {
  5441. if (key > 0) {
  5442. scope.dataoptions.selectedLabeData += ',';
  5443. scope.dataoptions.selectedValueData += ','
  5444. }
  5445. scope.dataoptions.selectedLabeData += value[$scope.fdata.selectLabelKey];
  5446. scope.dataoptions.selectedValueData += value[$scope.fdata.selectValuekey];
  5447. });
  5448. } else {
  5449. angular.forEach($scope.fdata.items, function (value, key) {
  5450. if (value.checked == true) {
  5451. scope.dataoptions.selectedLabeData = value[$scope.fdata.selectLabelKey];
  5452. scope.dataoptions.selectedValueData = value[$scope.fdata.selectValuekey];
  5453. selectItem = value;
  5454. }
  5455. });
  5456. }
  5457. if (scope.dataoptions.onSelect != undefined) {
  5458. scope.dataoptions.onSelect(scope.dataoptions.selectedValueData, selectItem);
  5459. }
  5460. $scope.$hide();
  5461. };
  5462. $scope.selectItemType = function (itemType) {
  5463. if (itemType.ParentId != null && itemType.Childrens.length == 0) {
  5464. $scope.selectparams.itemTypeID = itemType.ItemTypeId;
  5465. $scope.selectparams.itemType = null;
  5466. $scope.findSData();
  5467. } else {
  5468. $scope.selectparams.itemTypeID = null;
  5469. $scope.selectparams.itemType = itemType.ItemTypeId;
  5470. $scope.findSData();
  5471. }
  5472. }
  5473. $scope.getItemTypeList();
  5474. $scope.loadData();
  5475. };
  5476. sdModalController.$inject = ['$scope'];
  5477. sdModal = $modal({
  5478. scope: scope, controller: sdModalController, template: "../js/template/modal_tugitemselect.html", show: false
  5479. });
  5480. element.on('click', function () {
  5481. scope.init();
  5482. sdModal.$promise.then(sdModal.show);
  5483. });
  5484. }
  5485. };
  5486. return directiveObject;
  5487. }).directive('contentEditable', function () {
  5488. return {
  5489. scope: {
  5490. readonly: '='
  5491. },
  5492. require: 'ngModel',
  5493. link: function (scope, element, attrs, ctrl) {
  5494. // view -> model
  5495. element.bind('keyup', function () {
  5496. ctrl.$setViewValue(element.html());
  5497. });
  5498. element.bind('drop', function () {
  5499. setTimeout(function () {
  5500. ctrl.$setViewValue(element.html());
  5501. }, 100);
  5502. });
  5503. ctrl.$render = function () {
  5504. if (scope.readonly) {
  5505. attrs.$set('contenteditable', false);
  5506. } else {
  5507. attrs.$set('contenteditable', true);
  5508. element.addClass("editable-div");
  5509. }
  5510. element.html(ctrl.$viewValue);
  5511. };
  5512. }
  5513. };
  5514. }).filter('reportvalue', function () {
  5515. return function (number) {
  5516. return (number == 0) ? null : number;
  5517. };
  5518. }).directive("treeSelect", function ($http, $ocLazyLoad, AuthUser, $filter) {
  5519. //<tree-select data-url="treeConfig.url" data-value="treeConfig.value" data-ismulti="treeConfig.ismulti"></tree-select>
  5520. return {
  5521. restrict: 'EA',
  5522. require: '?ngModel',
  5523. //作用域
  5524. scope: {
  5525. url: '=',//api
  5526. params: '=?',//api参数,类型:对象 {}
  5527. value: '=?',//选择id集合,类型:数组 [id1,id2]
  5528. ismulti: "=?"//单选or多选,类型:boolean
  5529. },
  5530. templateUrl: '../js/template/modal_treeselect.html',
  5531. link: function (scope, elemnet) {
  5532. scope.className = Math.random().toString(36).slice(2, 8);
  5533. scope.ismulti = !scope.ismulti ? false : scope.ismulti;
  5534. scope.value = !scope.value ? (scope.ismulti ? [] : '') : scope.value;
  5535. scope.dataList = [];
  5536. scope.selectList = [];
  5537. scope.containerShow = 0;
  5538. scope.isGetList = false;
  5539. scope.isDefaultVal = false;
  5540. scope.getList = function () {
  5541. $http
  5542. ({
  5543. method: 'get', url: scope.url, params: scope.params
  5544. }).then(function (result) {
  5545. scope.dataList = result.data.Data;
  5546. if (scope.dataList.length > 0) {
  5547. if (scope.value.length > 0) {
  5548. scope.defaultVal(scope.dataList);
  5549. }
  5550. scope.dataList[0].chlidShow = 1;
  5551. }
  5552. });
  5553. };
  5554. scope.$watch("value", function (newVal) {
  5555. if (scope.dataList.length <= 0) {
  5556. if (!scope.isGetList) {
  5557. scope.isGetList = true;
  5558. scope.getList();
  5559. }
  5560. }
  5561. else if (scope.value.length > 0 && !scope.isDefaultVal) {
  5562. scope.defaultVal(scope.dataList);
  5563. }
  5564. }, true);
  5565. scope.defaultVal = function (list) {
  5566. scope.isDefaultVal = true;
  5567. var chlidShow = 0;
  5568. $.each(list, function (index, item) {
  5569. if ($.inArray(item.id, scope.value) >= 0 || item.id == scope.value) {
  5570. item.checked = 1;
  5571. chlidShow = 1;
  5572. //scope.select(item);
  5573. if (scope.selectList.filter(val => val.id == item.id).length <= 0) {
  5574. scope.selectList.push({ name: item.name, id: item.id });
  5575. }
  5576. }
  5577. if (item.childrens != null && item.childrens.length > 0) {
  5578. item.chlidShow = scope.defaultVal(item.childrens);
  5579. }
  5580. });
  5581. return chlidShow;
  5582. };
  5583. scope.showContainer = function () {
  5584. scope.containerShow = Math.abs((scope.containerShow | 0) - 1);
  5585. };
  5586. $(document).on('click', function (e) {
  5587. if (typeof (e.target.className) == "string" && e.target.className.indexOf(scope.className) < 0) {
  5588. scope.$apply(function () {
  5589. scope.containerShow = 0;
  5590. })
  5591. }
  5592. })
  5593. scope.showChildren = function (node) {
  5594. node.chlidShow = Math.abs((node.chlidShow | 0) - 1);
  5595. };
  5596. //选择节点
  5597. scope.check = function (node) {
  5598. if (scope.ismulti == true) {
  5599. //多选
  5600. node.checked = Math.abs((node.checked | 0) - 1);
  5601. scope.select(node);
  5602. if (node.checked == 1 && node.childrens.length > 0) {
  5603. scope.checkChildren(node);
  5604. }
  5605. }
  5606. else {
  5607. //单选
  5608. scope.selectList = [{ name: node.name, id: node.id }];
  5609. scope.value = node.id;//[node.id];
  5610. scope.showContainer();
  5611. }
  5612. };
  5613. scope.checkChildren = function (node) {
  5614. $.each(node.childrens, function (index, item) {
  5615. item.checked = 1;
  5616. scope.select(item);
  5617. if (item.childrens.length > 0) {
  5618. scope.checkChildren(item);
  5619. }
  5620. });
  5621. };
  5622. scope.select = function (node) {
  5623. if (node.checked == 1) {
  5624. if (scope.selectList.filter(val => val.id == node.id).length <= 0) {
  5625. if (!node.isDisabled)
  5626. scope.selectList.push({ name: node.name, id: node.id });
  5627. }
  5628. }
  5629. else {
  5630. scope.selectList = scope.selectList.filter(val => val.id != node.id);
  5631. }
  5632. scope.setValue();
  5633. };
  5634. scope.remove = function (node) {
  5635. scope.selectList = scope.selectList.filter(val => val.id != node.id);
  5636. scope.setValue();
  5637. scope.uncheck(scope.dataList, node.id);
  5638. };
  5639. scope.uncheck = function (list, uncheckId) {
  5640. $.each(list, function (index, item) {
  5641. if (uncheckId) {
  5642. if (item.id === uncheckId) {
  5643. item.checked = 0;
  5644. return;
  5645. }
  5646. }
  5647. else {
  5648. item.checked = 0;
  5649. }
  5650. if (item.childrens.length > 0) {
  5651. scope.uncheck(item.childrens, uncheckId);
  5652. }
  5653. });
  5654. };
  5655. scope.clear = function () {
  5656. scope.selectList = [];
  5657. scope.value = scope.ismulti ? [] : '';
  5658. scope.uncheck(scope.dataList, "");
  5659. };
  5660. scope.setValue = function () {
  5661. scope.value = scope.ismulti ? scope.selectList.map(it => { return it.id }) : (scope.selectList.length > 0 ? scope.selectList[0].id : '');
  5662. };
  5663. //scope.getList();
  5664. }
  5665. }
  5666. }).directive('imgComponent', function ($state, $http, $bsRouterState, $uuid, $bsfiles) {
  5667. return {
  5668. restrict: 'EA',
  5669. require: '?ngModel',
  5670. //作用域
  5671. scope: {
  5672. filerefid: '=',
  5673. filetypeid: '=',
  5674. readonly: '=',
  5675. ismulti: "=?",
  5676. height: '=?',
  5677. imgList: '=?',
  5678. width: '=?'
  5679. },
  5680. //html
  5681. templateUrl: '../js/template/modal-showimg.html',
  5682. //link函数
  5683. link: function (scope) {
  5684. scope.modalId = $uuid.getUUID();
  5685. scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
  5686. scope.imgList = [];
  5687. scope.showIndex = -1;
  5688. scope.height = scope.height || 100;
  5689. scope.width = scope.width || 130;
  5690. //图片附件
  5691. scope.reqFileModel = {
  5692. selectdata: { FileRefID: '', pageindex: 1, pagesize: 10, ptotal: 0 },
  5693. filetype: 1,
  5694. items: [],
  5695. readonly: false,
  5696. typeparams: {
  5697. types: ['jpg', 'bmp', 'png', 'gif', 'jpe', 'jpeg'],
  5698. errormsg: '图片格式必须为*.jpg,*.gif,*.png,*.bmp,*.jpe,*.jpeg等格式'
  5699. }
  5700. };
  5701. scope.$watch('filerefid', function (newVal, oldVal) {
  5702. if (newVal != null) {
  5703. scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
  5704. scope.getImgList();
  5705. }
  5706. });
  5707. scope.getImgList = function () {
  5708. $http
  5709. ({
  5710. method: 'get',
  5711. url: '../../api/common/File/GetFileList',
  5712. params: {
  5713. fileRefId: scope.filerefid,
  5714. fileType: scope.filetypeid,
  5715. pageindex: 1,
  5716. pagesize: 1000
  5717. }
  5718. }).then(function (result) {
  5719. scope.imgList = result.data.Data.Result.rows;
  5720. scope.imgList.forEach(img => {
  5721. if (!img.base64) {
  5722. $http
  5723. ({
  5724. method: 'get',
  5725. url: '../../api/common/File/GetImageBase64',
  5726. params: {
  5727. fileId: img.AttachmentId,
  5728. }
  5729. }).then(function (imgRes) {
  5730. if (imgRes.data.IsSuccess) {
  5731. img.success = true;
  5732. img.base64 = "data:image/png;base64," + imgRes.data.Data.Base64Data;
  5733. img.height = imgRes.data.Data.Height;
  5734. img.width = imgRes.data.Data.Width;
  5735. img.blobUrl = URL.createObjectURL(scope.base64ToBlob(img.base64));
  5736. }
  5737. else {
  5738. img.success = false;
  5739. }
  5740. }, (error) => {
  5741. img.success = false;
  5742. });
  5743. }
  5744. });
  5745. });
  5746. };
  5747. scope.showImg = function (index) {
  5748. scope.img.rotate = 0;
  5749. scope.showIndex = index;
  5750. scope.setBigImgUrl();
  5751. };
  5752. scope.uploadImg = function () {
  5753. scope.reqFileModel.selectdata.FileRefID = scope.filerefid;
  5754. scope.reqFileModel.filetype = scope.filetypeid;
  5755. $bsfiles.addFile(scope.reqFileModel).then(function (fid) {
  5756. scope.getImgList();
  5757. });
  5758. };
  5759. scope.deleteImg = function (fid) {
  5760. if (confirm("是否删除?")) {
  5761. $http({
  5762. url: '../../api/common/File/DeleteFile',
  5763. method: 'GET',
  5764. params: { fileId: fid }
  5765. }).then(function (rq) {
  5766. if (rq.data.IsSuccess) {
  5767. scope.getImgList();
  5768. }
  5769. $alert({
  5770. title: '消息',
  5771. content: rq.data.Message,
  5772. placement: 'top',
  5773. type: 'info',
  5774. show: true,
  5775. duration: 3
  5776. });
  5777. });
  5778. }
  5779. };
  5780. scope.up = function () {
  5781. scope.showIndex -= 1;
  5782. scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
  5783. scope.setBigImgUrl();
  5784. };
  5785. scope.next = function () {
  5786. scope.showIndex += 1;
  5787. scope.img = { rotate: 0, scale: 1, isload: false, url: '' };
  5788. scope.setBigImgUrl();
  5789. };
  5790. scope.zoomIn = function () {
  5791. scope.img.scale += 0.1;
  5792. };
  5793. scope.zoomOut = function () {
  5794. scope.img.scale -= 0.1;
  5795. };
  5796. scope.setBigImgUrl = function () {
  5797. scope.img.isload = scope.imgList[scope.showIndex].success;
  5798. scope.img.url = scope.imgList[scope.showIndex].blobUrl;
  5799. };
  5800. scope.base64ToBlob = function (data) {
  5801. var arr = data.split(','),
  5802. mime = arr[0].match(/:(.*?);/)[1],
  5803. bstr = atob(arr[1]),
  5804. n = bstr.length,
  5805. u8arr = new Uint8Array(n);
  5806. while (n--) {
  5807. u8arr[n] = bstr.charCodeAt(n);
  5808. }
  5809. return new Blob([u8arr], { type: mime });
  5810. }
  5811. }
  5812. }
  5813. });
  5814. })(angular);