| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386 |
- define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder', 'service/Product', 'service/Token', 'service/ProductUsers', 'service/File', 'service/PublicInquiry', 'service/Customer', 'service/PurcChange', 'angularTreeview'], function () {
- 'use strict';
- var app = angular.module('myApp', ['toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'common.directives', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService', 'ProductInfoServices', 'TokenService', 'ProductUserService', 'ui.tour', 'FileService', 'publicInquiryService', 'CustomerService', 'changeService', 'angularTreeview']);
- app.init = function () {
- angular.bootstrap(document, ['myApp']);
- };
- app.config(['$httpProvider', function ($httpProvider) {
- // http拦截
- $httpProvider.interceptors.push('httpInterceptor');
- }]);
- app.factory('httpInterceptor', ['$window', '$q', '$injector', 'BaseService', function ($window, $q, $injector, BaseService) {
- var httpInterceptor = {
- 'responseError': function (response) {
- if (response.status == 401) {// UNAUTHORIZED
- // window.location.href = response.data.loginUrl || 'index';
- // window.location.href = window.location.origin + window.location.pathname + '/login';
- window.location.reload();
- return $q.reject(response);
- }
- return $q.reject(response);
- }
- }
- return httpInterceptor;
- }]);
- app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
- $stateProvider.state('index', {
- url: "/index",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/home/right.html",
- controller: 'RightCtrl'
- }
- }
- }).state('home', {
- url: "/",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/home/right.html",
- controller: 'RightCtrl'
- }
- }
- }).state('sale', {
- url: "/sale",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/sale/right.html"
- }
- },
- controller: function ($scope) {
- $scope.truck = [];
- $scope.dataChanged = false;
- }
- }).state('sale.index', {
- url: "",
- templateUrl: "static/tpl/index/sale/index.html"
- }).state('sale.home', {
- url: "/",
- templateUrl: "static/tpl/index/sale/index.html"
- }).state('purc', {
- url: "/purc",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/purc/right.html"
- }
- },
- controller: function ($scope) {
- $scope.truck = [];
- $scope.dataChanged = false;
- }
- }).state('purc.index', {
- url: "",
- templateUrl: "static/tpl/index/purc/index.html"
- }).state('purc.home', {
- url: "/",
- templateUrl: "static/tpl/index/purc/index.html"
- }).state('purc.introduce', {
- url: "/introduce",
- templateUrl: "static/tpl/index/purc/introduce.html"
- }).state('purc.order', {
- url: "/order",
- templateUrl: "static/tpl/index/purc/order.html",
- controller: 'PurcOrderCtrl'
- }).state('purc.order_detail', {
- url: "/order/:id",
- templateUrl: "static/tpl/index/purc/order_detail.html",
- controller: 'PurcOrderDetailCtrl'
- }).state('purc.newOrder', {
- url: "/addOrder",
- templateUrl: "static/tpl/index/purc/addOrder.html",
- controller: 'PurcNewOrderCtrl'
- }).state('purc.cart', {
- url: "/cart",
- templateUrl: "static/tpl/index/purc/cart.html",
- controller: 'CartController'
- }).state('purc.cartDetail', {
- url: "/cart/:id",
- templateUrl: "static/tpl/index/purc/cart_detail.html",
- controller: 'CartDetailController'
- }).state('purc.deputy', {
- url: "/deputy",
- templateUrl: "static/tpl/index/purc/deputyOrder.html",
- controller: 'DeputyOrderCtrl'
- }).state('purc.deputylog', {
- url: "/deputylog",
- templateUrl: "static/tpl/index/purc/deputyorders_log.html",
- controller: 'DeputyOrderLogCtrl'
- }).state('purc.newdeputy', {
- url: "/deputy/add",
- templateUrl: "static/tpl/index/purc/deputyOrder_new.html",
- controller: 'NewDeputyOrderCtrl'
- }).state('purc.deputydetail', {
- url: "/deputy/:id",
- templateUrl: "static/tpl/index/purc/deputyOrder_detail.html",
- controller: 'DeputyOrderDetailCtrl'
- }).state('purc.changeList', {// 新增采购变更单
- url: "/change",
- templateUrl: "static/tpl/index/purc/changeList.html",
- controller: 'PurcChangeListCtrl'
- /* 采购变更单详情 */
- }).state('purc.change_detail', {
- url: "/change/:id",
- templateUrl: "static/tpl/index/purc/change_detail.html",
- controller: 'PurcChangeDetailCtrl'
- }).state('purc.changeNew', {// 新增采购变更单
- url: "/change_new",
- templateUrl: "static/tpl/index/purc/change_new.html",
- controller: 'PurcChangeNewCtrl'
- /* 招标列表 */
- }).state('purc.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/purc/tenderlist.html",
- controller: 'PurcTenderCtrl'
- /* 招标答疑列表 */
- }).state('purc.tenderanswerlist', {
- url: "/tender/answer",
- templateUrl: "static/tpl/index/purc/tender_answer_list.html",
- controller: 'PurcTenderAnswerListCtrl'
- /* 招标答疑详情 */
- }).state('purc.tenderanswerdetail', {
- url: "/tender/answer/:id",
- templateUrl: "static/tpl/index/purc/tender_answer_detail.html",
- controller: 'PurcTenderAnswerDetailCtrl'
- }).state('purc.waiting.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/purc/tenderlist.html",
- controller: 'PurcTenderCtrl'
- }).state('purc.todo.tenderlist', {
- url: "/tender/todo",
- templateUrl: "static/tpl/index/purc/tenderlist.html",
- controller: 'PurcTenderCtrl'
- /* 招标 */
- }).state('purc.tender', {
- url: "/addTender",
- templateUrl: "static/tpl/index/purc/tender.html",
- controller: 'PurcNewTenderCtrl'
- }).state('purc.savedtender', {
- url: "/tender/:id",
- templateUrl: "static/tpl/index/purc/tender.html",
- controller: 'PurcNewTenderCtrl'
- /* 评标 */
- }).state('purc.evaluation', {
- url: "/evaluation/:id",
- templateUrl: "static/tpl/index/purc/tender_evaluation.html",
- controller: 'PurcEvaluationCtrl'
- /* 采购供应商资料 */
- }).state('purc.vendor', {
- url: "/vendor",
- templateUrl: "static/tpl/index/purc/vendor.html",
- controller: 'PurcVendorCtrl'
- /* 采购供应商资料 详情*/
- }).state('purc.vendorserve', {
- url: "/vendor/serve",
- templateUrl: "static/tpl/index/cs/right.html",
- controller: 'CustServeCtrl'
- }).state('purc.vendordetail', {
- url: "/vendor/:id",
- templateUrl: "static/tpl/index/purc/vendor_detail.html",
- controller: 'PurcVendorDetailCtrl'
- /* 客户指定招标列表 */
- }).state('purc.makeoutorder', {
- url: "/makeoutorder",
- templateUrl: "static/tpl/index/make/outorder.html",
- controller: 'MakeOutOrderCtrl'
- }).state('purc.outorder_detail', {
- url: "/makeoutorder/:id",
- templateUrl: "static/tpl/index/make/outorder_detail.html",
- controller: 'MakeOutOrderDetailCtrl'
- /*平台新增询价单*/
- }).state('purc.inquiry_new', {
- url: "/purcinquiry",
- templateUrl: "static/tpl/index/purc/inquiry_new.html",
- controller: 'PurcInquiryCtrl'
- /*新增公共询价*/
- }).state('purc.pubinquiry_new', {
- url: "/pubinquiry/new",
- templateUrl: "static/tpl/index/purc/pubInquiry_new.html",
- controller: 'PurcInquiryCtrl'
- }).state('purc.purcinquiry_new', {
- url: "/purcinquiry/:bussinessCode",
- templateUrl: "static/tpl/index/purc/purcinquiry_new.html",
- controller: 'PurcInquiryNewCtrl'
- }).state('purc.inquiry', {
- url: "/purchaseinquiry",
- templateUrl: "static/tpl/index/purc/inquiry.html",
- controller: 'PurchaseInquiryCtrl'
- }).state('purc.inquiry_detail', {
- url: "/purcinquirydetail",
- templateUrl: "static/tpl/index/purc/inquiry_detail.html",
- controller: 'PurcInquiryDetailCtrl'
- }).state('purc.inquiryInfo_detail', {
- url: "/purcinquirydetail/:id",
- templateUrl: "static/tpl/index/purc/inquiryInfo_detail.html",
- controller: 'PurcInquiryInfoDetailCtrl'
- }).state('purc.inquiry_unapply', {
- url: "/inquiry_unapply",
- templateUrl: "static/tpl/index/purc/inquiry_unapply.html",
- controller: 'UnapplyInquiryCtrl'
- }).state('purc.pubInquiry', {
- /**
- * 针对客户,查询已转报价的公共询价单列表
- */
- url: "/publicInquiry",
- templateUrl: "static/tpl/index/purc/pubInquiry.html",
- controller: 'PurcPubInquiryCtrl'
- }).state('purc.pubInquiry_detail', {
- /**
- * 针对客户,查询已转报价单的公共询价详情
- */
- url: "/publicInquiry/:id",
- templateUrl: "static/tpl/index/purc/pubInquiry_detail.html",
- controller: 'PurcPubInquiryDetailCtrl'
- }).state('purc.product', {
- url: "/product",
- templateUrl: "static/tpl/index/purc/prodList.html",
- controller: 'PurcProductCtrl'
- }).state('purc.newProduct', {
- url: "/newProduct",
- templateUrl: "static/tpl/index/purc/newProdInfo.html",
- controller: 'PurcNewProdInfoCtrl'
- }).state('purc.productDetail', {
- url: "/prodList/:id",
- templateUrl: "static/tpl/index/purc/productDetail.html",
- controller: 'PurcProdDetailCtrl'
- }).state('purc.productmatches', {
- url: "/productmatches",
- templateUrl: "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesForPurcCtrl'
- }).state('purc.uploadProduct', {
- url: "/uploadProduct",
- templateUrl: "static/tpl/index/purc/uploadByBatch.html",
- controller: 'UploadProductCtrl'
- }).state('sale.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/sale/tenderlist.html",
- controller: 'SaleTenderCtrl'
- /* 招标提问列表 */
- }).state('sale.tenderquestionlist', {
- url: "/tender/question",
- templateUrl: "static/tpl/index/sale/tender_question_list.html",
- controller: 'SaleTenderQuestionListCtrl'
- /* 招标提问详情 */
- }).state('sale.tenderquestiondetail', {
- url: "/tender/question/:id",
- templateUrl: "static/tpl/index/sale/tender_question_detail.html",
- controller: 'SaleTenderQuestionDetailCtrl'
- }).state('sale.todo.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/sale/tenderlist.html",
- controller: 'SaleTenderCtrl'
- /* 平台公开招标列表 */
- }).state('baseInfo.openTenderList', {
- url: "/openTenderList",
- templateUrl: "static/tpl/index/sale/open_tender_list.html",
- controller: 'SaleOpenTenderCtrl'
- /* 查看公开招标详情 */
- }).state('baseInfo.open_tender_detail', {
- url: "/openTenderDetail/:id",
- templateUrl: "static/tpl/index/sale/open_tender_detail.html",
- controller: 'OpenSaleTenderDetailCtrl'
- /* 投标 */
- }).state('sale.tender', {
- url: "/tender/:id",
- templateUrl: "static/tpl/index/sale/tender.html",
- controller: 'SaleTenderDetailCtrl'
- /* 采购方查看供应商投标 */
- }).state('sale.vendortender', {
- url: "/tender/:vendUU/:id",
- templateUrl: "static/tpl/index/sale/vendor_tender.html",
- controller: 'SaleVendorTenderDetailCtrl'
- }).state('sale.todo', {
- url: "/todo",
- templateUrl: "static/tpl/index/sale/todo.html"
- }).state('sale.todo.inquiry', {
- url: "/inquiry",
- templateUrl: "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.todo.order', {
- url: "/order",
- templateUrl: "static/tpl/index/sale/order.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.todo.change', {
- url: "/change",
- templateUrl: "static/tpl/index/sale/change.html",
- controller: 'SaleChangeCtrl'
- }).state('sale.todo.notice', {
- url: "/notice",
- templateUrl: "static/tpl/index/sale/notice.html",
- controller: 'SaleNoticeCtrl'
- }).state('sale.customer', {
- url: "/customer",
- templateUrl: "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.customer_detail', {
- url: "/customer/:id",
- templateUrl: "static/tpl/index/sale/customer_detail.html",
- controller: 'CustomerDetailCtrl'
- }).state('sale.customerProduct', {
- url: "/customerProduct",
- templateUrl: "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.inquiry', {
- url: "/inquiry",
- templateUrl: "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.pubinquiry', {
- /**
- * 针对卖家,展示已转询价报价的公共询价单列表
- */
- url: "/pubinquiry",
- templateUrl: "static/tpl/index/sale/pubinquiry.html",
- controller: 'SalePubInquiryCtrl',
- params: {
- 'saleInquiryActive': null
- }
- }).state('sale.pubinquiry_detail', {
- /**
- * 针对卖家,已转询价报价单的公共询价单详情
- */
- url: "/pubinquiry/:id",
- templateUrl: "static/tpl/index/sale/pubinquiry_detail.html",
- controller: 'SalePubInquiryDetailCtrl'
- }).state('sale.inquiryRemind', {
- /**
- * 针对卖家,查询推荐的询价列表
- */
- url: "/inquiryRemind",
- templateUrl: "static/tpl/index/sale/inquiryRemind.html",
- controller: 'SaleInquiryRemindCtrl'
- }).state('sale.inquirymould', {
- url: "/mould",
- templateUrl: "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.todo.inquirymould', {
- url: "/mould",
- templateUrl: "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.inquiry_mould_detail', {
- url: "/mould/:id",
- templateUrl: "static/tpl/index/sale/inquiry_mould_detail.html",
- controller: 'SaleInquiryMouldDetailCtrl'
- }).state('sale.inquiry_detail', {
- url: "/inquiry/:id",
- templateUrl: "static/tpl/index/sale/inquiry_detail.html",
- controller: 'SaleInquiryDetailCtrl'
- }).state('sale.quotation', {
- url: "/quotation",
- templateUrl: "static/tpl/index/sale/quotation.html"
- }).state('sale.quotation.new', {
- url: "/new",
- templateUrl: "static/tpl/index/sale/quotation_new.html",
- controller: 'SaleQuotationNewCtrl',
- params: {
- 'inquiryItem': null
- }
- }).state('sale.quotation.list', {
- url: "/list",
- templateUrl: "static/tpl/index/sale/quotation_list.html",
- controller: 'SaleQuotationListCtrl'
- }).state('sale.quotation.item', {
- url: "/:id",
- templateUrl: "static/tpl/index/sale/quotation_new.html",
- controller: 'SaleQuotationNewCtrl'
- }).state('sale.order', {
- url: "/order",
- templateUrl: "static/tpl/index/sale/order.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.order_detail', {
- url: "/order/:id",
- templateUrl: "static/tpl/index/sale/order_detail.html",
- controller: 'SaleOrderDetailCtrl'
- }).state('sale.change', {
- url: "/change",
- templateUrl: "static/tpl/index/sale/change.html",
- controller: 'SaleChangeCtrl'
- }).state('sale.change_detail', {
- url: "/change/:id",
- templateUrl: "static/tpl/index/sale/change_detail.html",
- controller: 'SaleChangeDetailCtrl'
- }).state('sale.notice', {
- url: "/notice",
- templateUrl: "static/tpl/index/sale/notice.html",
- controller: 'SaleNoticeCtrl'
- }).state('sale.send', {
- url: "/send",
- templateUrl: "static/tpl/index/sale/send.html",
- controller: 'SaleSendCtrl'
- }).state('sale.send_detail', {
- url: "/send/:id",
- templateUrl: "static/tpl/index/sale/send_detail.html",
- controller: 'SaleSendDetailCtrl'
- }).state('sale.forecast', {
- url: "/forecast",
- templateUrl: "static/tpl/index/sale/forecast.html",
- controller: 'SaleForecastCtrl'
- }).state('sale.accept', {
- url: "/accept",
- templateUrl: "static/tpl/index/sale/accept.html",
- controller: 'SaleAcceptCtrl'
- }).state('sale.accept_detail', {
- url: "/accept/:id",
- templateUrl: "static/tpl/index/sale/accept_detail.html",
- controller: 'SaleAcceptDetailCtrl'
- }).state('sale.returns', {
- url: "/returns",
- templateUrl: "static/tpl/index/sale/returns.html",
- controller: 'SaleReturnsCtrl'
- }).state('sale.return_detail', {
- url: "/return/:id",
- templateUrl: "static/tpl/index/sale/return_detail.html",
- controller: 'SaleReturnsDetailCtrl'
- }).state('sale.sample', {
- url: "/sample",
- templateUrl: "static/tpl/index/sale/sample.html",
- controller: 'SaleSampleCtrl'
- }).state('sale.sample_detail', {
- url: "/sample/:id",
- templateUrl: "static/tpl/index/sale/sample_detail.html",
- controller: 'SaleSampleDetailCtrl'
- }).state('sale.approval', {
- url: "/approval",
- templateUrl: "static/tpl/index/sale/approval.html",
- controller: 'SaleApprovalCtrl'
- }).state('sale.prodList', {
- url: "/prodList",
- templateUrl: "static/tpl/index/baseInfo/prodList.html",
- controller: 'ProductListCtrl'
- }).state('sale.newProdInfo', {
- url: "/newProdInfo",
- templateUrl: "static/tpl/index/baseInfo/newProdInfo.html",
- controller: 'NewProdInfoCtrl'
- }).state('sale.uploadByBatch', {
- url: "/uploadByBatch",
- templateUrl: "static/tpl/index/baseInfo/uploadByBatch.html",
- controller: 'UploadByBatchCtrl'
- }).state('sale.productDetail', {
- url: "/prodList/:id",
- templateUrl: "static/tpl/index/baseInfo/productDetail.html",
- controller: 'ProductDetailCtrl'
- }).state('sale.productmatches', {
- url: "/productmatches",
- templateUrl: "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesForSaleCtrl'
- }).state('sale.maketodo', {
- url: "/maketodo",
- templateUrl: "static/tpl/index/make/todo.html"
- }).state('sale.maketodo.order', {
- url: "/makeorder",
- templateUrl: "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder', {
- url: "/makeorder",
- templateUrl: "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder_detail', {
- url: "/makeorder/:id",
- templateUrl: "static/tpl/index/make/order_detail.html",
- controller: 'MakeOrderDetailCtrl'
- }).state('sale.badOut', {
- url: "/badOut",
- templateUrl: "static/tpl/index/qc/badOut.html",
- controller: 'SaleBadOutCtrl'
- }).state('sale.MRB', {
- url: "/MRB",
- templateUrl: "static/tpl/index/qc/MRB.html",
- controller: 'SaleMRBCtrl'
- }).state('sale.badIn', {
- url: "/badIn",
- templateUrl: "static/tpl/index/qc/badIn.html",
- controller: 'SaleBadInCtrl'
- }).state('sale.makeaccept', {
- url: "/makeaccept",
- templateUrl: "static/tpl/index/make/accept.html",
- controller: 'MakeAcceptCtrl'
- }).state('sale.makereturns', {
- url: "/makereturns",
- templateUrl: "static/tpl/index/make/returns.html",
- controller: 'MakeReturnCtrl'
- }).state('sale.makechange', {
- url: "/makechange",
- templateUrl: "static/tpl/index/make/change.html",
- controller: 'MakeChangeCtrl'
- }).state('sale.makechange_detail', {
- url: "/makechange/:id",
- templateUrl: "static/tpl/index/make/change_detail.html",
- controller: 'MakeChangeDetailCtrl'
- }).state('account', {
- url: "/account",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/account/left.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/account/right.html"
- }
- }
- }).state('account.index', {
- url: "",
- templateUrl: "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('account.home', {
- url: "/",
- templateUrl: "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('baseInfo', {//基础资料
- url: "/baseInfo",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/baseInfo/right.html"
- }
- }
- }).state('baseInfo.index', {
- url: "/enterpriseList",
- templateUrl: "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.home', {
- url: "/enterpriseList",
- templateUrl: "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.enterpriseList', {
- url: "/enterpriseList",
- templateUrl: "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.myClient', {
- url: "/myClient",
- templateUrl: "static/tpl/index/baseInfo/myClient.html",
- controller: 'MyClientCtrl'
- }).state('baseInfo.mySupplier', {
- url: "/mySupplier",
- templateUrl: "static/tpl/index/baseInfo/mySupplier.html",
- controller: 'MySupplierCtrl'
- }).state('baseInfo.myRequest', {
- url: "/myRequest",
- templateUrl: "static/tpl/index/baseInfo/myRequest.html",
- controller: 'AddPartnerRequestCtrl'
- }).state('baseInfo.newPartner', {
- url: "/newPartner",
- templateUrl: "static/tpl/index/baseInfo/newPartner.html",
- controller: 'NewPartnerCtrl'
- }).state('baseInfo.myMessage', {
- url: "/myMessage",
- templateUrl: "static/tpl/index/baseInfo/myMessage.html",
- controller: 'AddPartnerMessageCtrl'
- }).state('baseInfo.myPartners', {
- url: '/myPartners',
- templateUrl: "static/tpl/index/baseInfo/myPartners.html",
- controller: 'MyPartnersCtrl'
- }).state('baseInfo.businessGroups', {
- url: '/businessGroups',
- controller: 'BusinessGroupsCtrl'
- }).state('baseInfo.inquiryList', {
- url: '/inquiryList',
- templateUrl: "static/tpl/index/baseInfo/inquiry_list.html",
- controller: 'PublicInquiryListCtrl'
- }).state('baseInfo.inquiryListDetail', {
- url: '/inquiryList/:id',
- templateUrl: "static/tpl/index/baseInfo/inquiryItem_detail.html",
- controller: 'PublicInquiryListDetailCtrl'
- }).state('baseInfo.vendorInfo', {
- url: '/enume/vendorInfo',
- templateUrl: "static/tpl/index/baseInfo/vendorsInfo.html",
- controller: 'VendorsInfoCtrl'
- }).state('baseInfo.servicerInfo', {
- url: '/enume/servicerInfo',
- templateUrl: "static/tpl/index/baseInfo/servicerInfo.html",
- controller: 'ServicerInfoCtrl'
- }).state('baseInfo.customerInfo', {
- url: '/enume/customerInfo',
- templateUrl: "static/tpl/index/baseInfo/customersInfo.html",
- controller: 'CustomersInfoCtrl'
- }).state('baseInfo.enume', {
- url: '/enume',
- templateUrl: "static/tpl/index/baseInfo/vendorAndCustomer.html"
- }).state('baseInfo.partner', {
- url: '/partner',
- templateUrl: "static/tpl/index/baseInfo/addPartners.html",
- controller: 'AddPartnersCtrl'
- }).state('baseInfo.partner_searchresult', {
- url: '/search',
- templateUrl: "static/tpl/index/baseInfo/searchresult.html",
- controller: 'EnterpriseSearchCtrl'
- }).state('baseInfo.invitation', {
- url: '/invitation',
- templateUrl: "static/tpl/index/baseInfo/invitation.html",
- controller: 'InvitationCtrl'
- }).state('qc', {
- url: "/qc",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/qc/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/qc/right.html"
- }
- }
- }).state('qc.index', {
- url: "",
- templateUrl: "static/tpl/index/qc/index.html"
- }).state('qc.home', {
- url: "/",
- templateUrl: "static/tpl/index/qc/index.html"
- }).state('fa', {
- url: "/fa",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/fa/right.html"
- }
- }
- }).state('fa.index', {
- url: "",
- templateUrl: "static/tpl/index/fa/index.html"
- }).state('fa.home', {
- url: "/",
- templateUrl: "static/tpl/index/fa/index.html"
- }).state('fa.apBill', {
- url: "/apBill",
- templateUrl: "static/tpl/index/fa/apBill.html",
- controller: 'SaleApBillCtrl'
- }).state('fa.apBill_detail', {
- url: "/apBill/:id",
- templateUrl: "static/tpl/index/fa/apBill_detail.html",
- controller: 'SaleApBillDetailCtrl'
- }).state('fa.arCheck', {
- url: "/arCheck",
- templateUrl: "static/tpl/index/fa/arCheck.html",
- controller: 'SaleArCheckCtrl'
- }).state('fa.arCheck_detail', {
- url: "/arCheck/:id",
- templateUrl: "static/tpl/index/fa/arCheck_detail.html",
- controller: 'SaleArCheckDetailCtrl'
- }).state('fa.apCheck', {
- url: "/apCheck",
- params: {
- 'id': null
- },
- templateUrl: "static/tpl/index/fa/apCheck.html",
- controller: 'PurchaseApCheckCtrl'
- }).state('fa.apCheck_detail', {
- url: "/apCheck/:id",
- templateUrl: "static/tpl/index/fa/apCheck_detail.html",
- controller: 'PurchaseApCheckDetailCtrl'
- }).state('fa.apCheckList', {
- url: "/apCheckList",
- templateUrl: "static/tpl/index/fa/apCheckList.html",
- controller: 'PurchaseApCheckListCtrl'
- }).state('fa.apBillOut', {
- url: "/apBillOut",
- params:{
- 'id':null
- },
- templateUrl: "static/tpl/index/fa/apBillOut.html",
- controller: 'PurchaseApBillOutCtrl'
- }).state('fa.apBillOut_detail', {
- url: "/apBillOut/:id",
- templateUrl: "static/tpl/index/fa/apBillOut_detail.html",
- controller: 'PurchaseApBillOutDetailCtrl'
- }).state('fa.apBillOutList', {
- url: "/apBillOutList",
- templateUrl: "static/tpl/index/fa/apBillOutList.html",
- controller: 'PurchaseApBillOutListCtrl'
- }).state('fa.adjustList', {
- url: "/adjustList",
- templateUrl: "static/tpl/index/fa/adjustList.html",
- controller: 'PurchaseAdjustListCtrl'
- }).state('make', {
- url: "/make",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/make/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/make/right.html"
- }
- }
- }).state('make.index', {
- url: "",
- templateUrl: "static/tpl/index/make/index.html"
- }).state('make.home', {
- url: "/",
- templateUrl: "static/tpl/index/make/index.html"
- }).state('cs', {// 客户服务
- url: "/cs",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/cs/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/cs/right.html"
- }
- }
- }).state('cs.index', {
- url: "",
- templateUrl: "static/tpl/index/cs/index.html"
- }).state('cs.home', {
- url: "/",
- templateUrl: "static/tpl/index/cs/index.html"
- }).state('search', { //顶部搜索
- url: "/search?keyword=",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/search/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/search/search_result.html",
- controller: 'TopSearchCtrl'
- }
- }
- }).state('approvalflow', { //审批流
- url: "/approvalFlow",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/approvalFlow/right.html",
- }
- }
- }).state('approvalflow.flow', {
- url: "/flow",
- templateUrl: "static/tpl/index/approvalFlow/home.html",
- controller: 'approvalFlowCtrl'
- }).state('approvalflow.enterprise', {
- url: "/enterprise",
- templateUrl: "static/tpl/index/approvalFlow/enterprise.html",
- controller: 'EnterpriseCtrl'
- }).state('approvalflow.user', {
- url: "/user",
- templateUrl: "static/tpl/index/approvalFlow/user.html",
- controller: 'UserCtrl'
- }).state('approvalflow.log', {
- url: "/log",
- templateUrl: "static/tpl/index/approvalFlow/log.html",
- controller: 'LogCtrl'
- }).state('approvalflow.resource', {
- url: "/resource",
- templateUrl: "static/tpl/index/approvalFlow/resource.html",
- controller: 'ResourceCtrl'
- }).state('approvalflow.role', {
- url: "/role",
- templateUrl: "static/tpl/index/approvalFlow/role.html",
- controller: 'RoleCtrl'
- }).state('approvalflow.product', {
- url: "/product",
- templateUrl: "static/tpl/index/approvalFlow/prodList.html",
- controller: 'ProductAllCtrl'
- }).state('approvalflow.userProduct', {
- url: "/userProduct",
- templateUrl: "static/tpl/index/approvalFlow/userProduct.html",
- controller: 'UserProductCtrl'
- }).state('approvalflow.productmatches', {
- url: "/productmatches",
- templateUrl: "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesCtrl'
- }).state('sale.vendorPerformanceAssess', {
- url: "/vendorPerformanceAssess",
- templateUrl: "static/tpl/index/sale/vendorPerformanceAssess.html",
- controller: 'VendorPerformanceAssessCtrl'
- }).state('sale.vendorPerformanceAssess_detail', {
- url: "/vendorPerformanceAssess/:id",
- templateUrl: "static/tpl/index/sale/vendorPerformanceAssess_detail.html",
- controller: 'VendorPerformanceAssessDetailCtrl'
- });
- $urlRouterProvider.otherwise('/index');
- }]);
- /**
- * 表示符号
- */
- app.factory('Symbol', function () {
- return {
- currency: function (cur) {
- if (cur == 'RMB') return '¥';
- else if (cur == 'USD') return '$';
- else if (cur == 'EUR') return '€';
- else if (cur == null || cur == '') return '¥';
- else return cur;
- }
- };
- }).factory('Lodop', function () {
- return {
- getLodop: function (oOBJECT, oEMBED) {
- var CreatedOKLodop7766 = null;
- /**************************
- 本函数根据浏览器类型决定采用哪个页面元素作为Lodop对象:
- IE系列、IE内核系列的浏览器采用oOBJECT,
- 其它浏览器(Firefox系列、Chrome系列、Opera系列、Safari系列等)采用oEMBED,
- 如果页面没有相关对象元素,则新建一个或使用上次那个,避免重复生成。
- 64位浏览器指向64位的安装程序install_lodop64.exe。
- **************************/
- var strHtmInstall = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtmUpdate = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtm64_Install = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtm64_Update = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtmFireFox = "<br><br><font color='#FF00FF'>(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)</font>";
- var strHtmChrome = "<br><br><font color='#FF00FF'>(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)</font>";
- var LODOP;
- try {
- //=====判断浏览器类型:===============
- var isIE = (navigator.userAgent.indexOf('MSIE') >= 0) || (navigator.userAgent.indexOf('Trident') >= 0);
- var is64IE = isIE && (navigator.userAgent.indexOf('x64') >= 0);
- //=====如果页面有Lodop就直接使用,没有则新建:==========
- if (oOBJECT != undefined || oEMBED != undefined) {
- if (isIE)
- LODOP = oOBJECT;
- else
- LODOP = oEMBED;
- } else {
- if (CreatedOKLodop7766 == null) {
- LODOP = document.createElement("object");
- LODOP.setAttribute("width", 0);
- LODOP.setAttribute("height", 0);
- LODOP.setAttribute("style", "position:absolute;left:0px;top:-100px;width:0px;height:0px;");
- if (isIE) LODOP.setAttribute("classid", "clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
- else LODOP.setAttribute("type", "application/x-print-lodop");
- document.documentElement.appendChild(LODOP);
- CreatedOKLodop7766 = LODOP;
- } else
- LODOP = CreatedOKLodop7766;
- }
- ;
- //=====判断Lodop插件是否安装过,没有安装或版本过低就提示下载安装:==========
- if ((LODOP == null) || (typeof(LODOP.VERSION) == "undefined")) {
- if (navigator.userAgent.indexOf('Chrome') >= 0)
- document.documentElement.innerHTML = strHtmChrome + document.documentElement.innerHTML;
- if (navigator.userAgent.indexOf('Firefox') >= 0)
- document.documentElement.innerHTML = strHtmFireFox + document.documentElement.innerHTML;
- if (is64IE) document.write(strHtm64_Install); else if (isIE) document.write(strHtmInstall); else
- document.documentElement.innerHTML = strHtmInstall + document.documentElement.innerHTML;
- return LODOP;
- } else if (LODOP.VERSION < "6.1.9.8") {
- if (is64IE) document.write(strHtm64_Update); else if (isIE) document.write(strHtmUpdate); else
- document.documentElement.innerHTML = strHtmUpdate + document.documentElement.innerHTML;
- return LODOP;
- }
- ;
- //=====如下空白位置适合调用统一功能(如注册码、语言选择等):====
- LODOP.SET_LICENSES("深圳市优软科技有限公司", "BBF53BD5AB0D522B3207D05CDE381F65", "", "");
- //============================================================
- return LODOP;
- } catch (err) {
- if (is64IE)
- document.documentElement.innerHTML = "Error:" + strHtm64_Install + document.documentElement.innerHTML; else
- document.documentElement.innerHTML = "Error:" + strHtmInstall + document.documentElement.innerHTML;
- return LODOP;
- }
- ;
- }
- }
- });
- app.controller('MyCtrl', ['$scope', '$rootScope', '$modal', 'toaster', 'AccountEnterprise', function ($scope, $rootScope, $modal, toaster, AccountEnterprise) {
- $rootScope.$on('$locationChangeSuccess', function (evt, newUrl) {
- var routeState = newUrl.substr(newUrl.indexOf('#/') + 2);
- if (routeState.indexOf('/') > -1)
- routeState = routeState.substring(0, routeState.indexOf('/'));
- if (routeState.indexOf('.') > -1)
- routeState = routeState.substring(0, routeState.indexOf('.'));
- $scope.routeState = routeState || 'home';
- });
- $scope.search = function (keyword) {
- if (keyword != null && keyword != '') {
- $rootScope.searchKeyword = keyword;
- window.location.hash = '#/search?keyword=' + keyword;
- } else {
- $rootScope.searchKeyword = null;
- window.location.hash = '#/search';
- }
- };
- $scope.showMessage = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/home/pagingRelease.html',
- controller: 'PagingReleaseCtrl'
- });
- };
- // 连接到询价
- $scope.linktoInquiry = function (active) {
- $rootScope.active = active;
- window.location.href = "#/sale/inquiry";
- }
- // 连接到招标
- $scope.linktoSaleTender = function (active) {
- $rootScope.active = active;
- window.location.href = "#/sale/tender";
- }
- // 链接到打样申请
- $scope.linktoSample = function (active) {
- $rootScope.active = active;
- window.location.href = "#/sale/sample";
- }
- // 链接到采购招标
- $scope.linktoPurcTender = function (active) {
- $rootScope.tenderActive = active;
- window.location.href = "#/purc/tender";
- }
- $scope.linktoPurcInquiry = function (active) {
- $rootScope.active = active;
- window.location.href = "#/purc/purchaseinquiry";
- }
- // 跳转到B2C
- $scope.b2cLink = function (url) {
- AccountEnterprise.getB2cUrl({}, function(data) {
- if (url == '/help/home') {
- window.open(data.url + url, '_target')
- } else {
- window.location.href = data.url + url;
- }
- });
- }
- }]);
- app.controller('AdController', ['$scope', '$modal', '$interval', function($scope, $modal, $interval) {
- // 广告操作
- $scope.count = 5;
- $scope.bannerShow = true;
- $scope.imgAnmiation = false;
- $scope.jingKongAnmiation = true;
- $scope.imgShow = true;
- $scope.Times = $interval(function () {
- $scope.count--;
- if ($scope.count <= 0) {
- $scope.count = 5;
- $scope.jingKongAnmiation = false;
- $interval.cancel($scope.Times);
- $scope.closeClick();
- }
- }, 1000);
- // 金控广告动画设置
- $scope.closeClick = function () {
- $scope.jingKongAnmiation = false;
- if ($scope.bannerShow === false) {
- $scope.imgAnmiation = false;
- $scope.imgShow = false;
- } else {
- $scope.bannerShow = false;
- $scope.imgAnmiation = true;
- }
- }
- }]);
- /**
- * 新消息提醒(调用公共服务接口) -2018-01-22 19:36:50
- * @author dongbw
- */
- app.controller('PagingReleaseCtrl', ['$scope', 'PagingRelease', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'PagingReleaseInfo',
- function ($scope, PagingRelease, BaseService, ngTableParams, toaster, $modalInstance, PagingReleaseInfo) {
- $scope.active = "todo";
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- /**
- * 页面状态按钮过滤
- */
- var getMessageState = function (active) {
- var fn = 'get';
- switch (active) {
- case 'done':
- fn = 'getDone';
- break;
- case 'todo':
- fn = 'getTodo';
- break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'createTime': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- // fromDate: getDateTime($scope.condition.dateFrom),
- // endDate: getDateTime($scope.condition.dateTo)
- };
- PagingRelease[getMessageState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.close = function () {
- $modalInstance.close();
- window.location.reload();
- };
- $scope.checks = {
- checked: false
- };// 全选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (message) {
- message.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function (vendor) {
- vendor.checked = true;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- // 单反选
- $scope.unCheckOne = function (vendor) {
- vendor.checked = false;
- $scope.checks.checked = false;
- };
- /**
- * 当前页标为已读
- */
- $scope.setRead = function () {
- $scope.loading = true;
- var messageIds = [];
- angular.forEach($scope.tableParams.data, function(message) {
- messageIds.push(message.id);
- });
- PagingRelease.setPageRead({}, messageIds, function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop("success", "设置已读成功");
- }
- if (data.error) {
- toaster.pop("error", "设置已读失败");
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- });
- };
- // 点击内容连接之后,信息标为已读
- $scope.setOneRead = function (id) {
- $scope.loading = true;
- $modalInstance.close();
- PagingRelease.setMessageRead({id: id}, {}, function (data) {
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 高亮显示关键词
- app.filter('getkey', ['$sce', '$rootScope', function ($sce, $rootScope) {
- var search = $rootScope.searchKeyword;
- return function (content, search) {
- content = encodeURI(content);
- search = encodeURI(search);
- var reg = new RegExp(search, 'gim');
- var result = content.replace(reg, '<font color="red">$&</font>');
- result = decodeURIComponent(result);
- return $sce.trustAsHtml(result);
- };
- $rootScope.searchKeyword = null;// 清除缓存的关键字
- }]);
- /**
- * 顶部搜索
- */
- app.controller('TopSearchCtrl', ['$scope', '$rootScope', 'getAccountUserSpace', 'ngTableParams', 'toaster', 'BaseService', 'AddPartner', '$filter', '$stateParams', 'SearchProd', '$sce', '$modal', 'InvitationRecord', function ($scope, $rootScope, getAccountUserSpace, ngTableParams, toaster, BaseService, AddPartner, $filter, $stateParams, SearchProd, $sce, $modal, InvitationRecord) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.tip = $rootScope.searchKeyword;
- // 企业搜索
- var getService = function () {
- return getAccountUserSpace;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $scope.total = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 添加合作关系
- $scope.addPartner = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- // 物料搜索
- var getProdService = function () {
- return SearchProd;
- };
- $scope.prodTableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getProdService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $scope.prodtotal = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- /**
- * 向企业购买
- */
- $scope.PurcByEn = function (businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function (businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 询价
- */
- $scope.PurcInquiry = function (businessCode, id) {
- $rootScope.prodId = id;
- window.location.hash = "#/purc/purcinquiry/" + businessCode;
- }
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function (name) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function () {
- return name
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- /**
- * 立即查看
- */
- $scope.view = function (name) {
- $rootScope.vendName = name;
- window.location.hash = "#/baseInfo/newPartner";
- }
- }]);
- app.controller('InviteCtrl', ['$scope', 'toaster', '$modalInstance', 'enname', 'InvitationRecord', '$modal', function ($scope, toaster, $modalInstance, enname, InvitationRecord, $modal) {
- $scope.enter = {
- vendname: enname
- };
- $scope.save = function (enter) {
- // 先检验是否已注册
- InvitationRecord.enterpriseList({name: enter.vendname}, {}, function(data) {
- $scope.existEn = data;
- if ($scope.existEn.length == 0) {
- $modalInstance.close(enter);
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/baseInfo/modal/QQshare_modal.html',
- controller: 'QQShareCtrl',
- });
- } else {
- $scope.enterprise = $scope.existEn[0];
- }
- });
- }
- $scope.viewDetail = function() {
- $scope.exist = 1;
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- $scope.closeDetail = function() {
- $scope.exist = 0;
- }
- /**
- * 添加合作伙伴
- * @param enterprise
- */
- $scope.addPartner = function(en) {
- InvitationRecord.addPart({inviteEnUU: $scope.enterprise.uu, inviteUserName: en.vendusername, inviteUserTel: en.vendusertel}, {}, function(data) {
- if (data.success) {
- toaster.pop('success', data.success);
- $modalInstance.dismiss();
- } else if (data.error) {
- toaster.pop('error', data.error);
- }
- }, function(response) {
- toaster.pop('error', response.data);
- });
- }
- }]);
- /**
- * QQ分享
- */
- app.controller('QQShareCtrl', ['$scope', 'InvitationRecord', '$modalInstance', function($scope, InvitationRecord, $modalInstance) {
- InvitationRecord.getInviteUrl({}, function(data) {
- $scope.inviteUrl = data.url;
- var p = {
- url: $scope.inviteUrl, /*获取URL,可加上来自分享到QQ标识,方便统计*/
- // desc: 'hejq', /*分享理由(风格应模拟用户对话),支持多分享语随机展现(使用|分隔)*/
- // title: '', /*分享标题(可选)*/
- // summary: '', /*分享摘要(可选)*/
- // pics: '', /*分享图片(可选)*/
- // flash: '', /*视频地址(可选)*/
- // site: '', /*分享来源(可选) 如:QQ分享*/
- // style: '201',
- // width: 32,
- // height: 32
- };
- var s = [];
- for(var i in p){
- s.push(i + '=' + encodeURIComponent(p[i]||''));
- }
- s.join('&');
- $scope.QQshare = function() {
- window.open("http://connect.qq.com/widget/shareqq/index.html?" + s)
- }
- });
- $scope.close = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 再次邀请
- */
- app.controller('ReInviteCtrl', ['$scope', 'toaster', '$modalInstance', 'id', 'InvitationRecord', function ($scope, toaster, $modalInstance, id, InvitationRecord) {
- var loadData = function (id) {
- InvitationRecord.getRecordById({id: id}, {}, function (data) {
- if (data.user !== null) {
- data.user = {};
- }
- $scope.enter = data;
- });
- };
- loadData(id);
- $scope.save = function (enter) {
- if (!enter.vendusertel && !enter.venduseremail) {
- toaster.pop('info', '提示', '手机号或邮箱至少填写一个才能通知到客户');
- } else {
- $modalInstance.close(enter);
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 邀请记录
- */
- app.controller('InvitationCtrl', ['$scope', 'toaster', 'InvitationRecord', 'BaseService', 'ngTableParams', '$modal', function ($scope, toaster, InvitationRecord, BaseService, ngTableParams, $modal) {
- BaseService.scrollBackToTop();
- $scope.status = "invitation";
- $scope.active = "invitation";
- var getService = function () {
- if ($scope.active === "invitation") {
- return InvitationRecord.records;
- } else if ($scope.active === "invitationTeam") {
- return InvitationRecord.getActiveRecordsByEn; // 只获取已激活的
- }
- };
- $scope.setActive = function (state) {
- if ($scope.active !== state) {
- $scope.active = state;
- if ($scope.tableParams.page() === 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.tip = keyword;
- }
- $scope.search = function (name) {
- $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/fuzzysearch_enterprise_modal.html',
- controller: 'FuzzySearchCtrl',
- resolve: {
- name: function () {
- return name
- }
- }
- }).result.then(function (data) {
- });
- };
- // 再次邀请
- $scope.reInvite = function (id) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'ReInviteCtrl',
- resolve: {
- id: function () {
- return id
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- }]);
- /**
- * 模糊查询相似的企业名称
- */
- app.controller('FuzzySearchCtrl', ['$scope', 'name', 'InvitationRecord', 'toaster', 'BaseService', function ($scope, name, InvitationRecord, toaster, BaseService) {
- $scope.name = name;
- if ($scope.name != null) {
- InvitationRecord.enterpriseList({name: $scope.name}, {}, function (data) {
- $scope.enterprises = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', 'toaster', 'BaseService', '$modal', function ($scope, $window, AuthenticationService, toaster, BaseService, $modal) {
- $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
- AuthenticationService.getAuthentication().success(function (data) {
- if (data.enterprises) {
- data.enterprise = data.enterprises[data.enterprises.length - 1];
- if (data.enterprises.length > 1) {
- var enSelect = [];
- angular.forEach(data.enterprises, function (e) {
- if (e.current)
- data.enterprise = e;
- else
- enSelect.push(e);
- });
- data.enSelect = enSelect;
- }
- }
- $scope.userInfo = data;
- if (data == null || !data.userUU) {
- $scope.isAuthed = false;
- AuthenticationService.redirectSignin();
- } else {
- }
- });
- $scope.logout = function () {
- $modal.open({
- templateUrl: 'static/tpl/index/account/logout.html',
- controller: 'LogOutCtrl'
- }).result.then(function (s) {
- if (s) {
- AuthenticationService.logout();
- }
- });
- };
- // 打开登录模态框
- $scope.signinModal = function() {
- // 跳转账户中心
- AuthenticationService.redirectSignin();
- };
- // 注册
- $scope.registerModal = function() {
- // 跳转账户中心
- AuthenticationService.redirectRegister();
- };
- $scope.switchto = function (enUU) {// 切换企业
- AuthenticationService.reSignin(enUU).success(function (response) {
- console.log(response);
- if (!response) $window.location.reload();
- $.ajax({
- url:response.url,
- data:response.data,
- type:"get",
- cache:false,
- dataType:"jsonp",
- jsonp:"callback",
- jsonpCallback:"successCallback",
- success:function(data){
- console.log(data);
- $window.location.reload();
- },
- error:function(data){
- console.log(data);
- $window.location.reload();
- }
- });
- });
- };
- $scope.addFavorite = function () {
- var url = encodeURI(window.location.href);
- try {
- //ie浏览器收藏方式
- window.external.addFavorite(url, "优软商务平台");
- } catch (e) {
- try {
- //火狐浏览器收藏方式
- window.sidebar.addPanel("优软商务平台", url);
- } catch (e) {
- toaster.pop('warning', '提示', "您的浏览器不支持自动添加收藏夹,请使用Ctrl+D进行添加," +
- "或手动在浏览器里进行设置。");
- }
- }
- };
- }]);
- app.controller('LogOutCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
- $scope.close = function (confirm) {
- $modalInstance.close(confirm);
- };
- }]);
- app.controller('ImageInsertCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
- $scope.image = {src: null};
- // 图片上传成功之后
- $scope.onUploadSuccess = function (data) {
- var path = data.path;
- path = path.substring(0, path.lastIndexOf('.')) + "_150x90" + path.substr(path.lastIndexOf('.'));
- $scope.$apply(function () {
- $scope.image.src = data.path;
- $scope.image.thumb = path;
- });
- };
- $scope.close = function () {
- $modalInstance.dismiss();
- };
- $scope.confirm = function () {
- $modalInstance.close($scope.image);
- $scope.imageUrl = null;
- };
- }]);
- app.controller('TodoCtrl', ['$scope', 'SnapshotService', 'BaseService', '$rootScope', '$modal',
- function ($scope, SnapshotService, BaseService, $rootScope, $modal) {
- BaseService.scrollBackToTop();
- SnapshotService.getTodo(function (data) {
- $scope.todo = data;
- });
- var getUnread = function () {
- SnapshotService.getUnread('all', function (data) {
- $scope.unread = data;
- });
- };
- getUnread();
- //去除红点
- $scope.setOrdersRead = function (type) {
- switch (type){
- case 'product':
- $scope.unread.product = 0;
- break;
- case 'vendorPerformanceAssess':
- $scope.unread.vendorPerformanceAssess = 0;
- break;
- case 'customer':
- $scope.unread.customer = 0;
- break;
- case 'purcProduct':
- $scope.unread.purcProduct = 0;
- break;
- case 'vendor':
- $scope.unread.purcVendor = 0;
- break;
- }
- };
- $scope.setTenderActive = function (active) {
- $rootScope.tenderActive = active;
- window.location.hash = '#/purc/tender';
- }
- }]);
- // header
- app.controller('HeaderCtrl', ['$scope', 'SnapshotService', function ($scope, SnapshotService) {
- SnapshotService.getMessage(function (data) {
- $scope.message = data;
- });
- }]);
- app.controller('TruckCtrl', ['$scope', '$rootScope', '$modal', 'SaleTruck', function ($scope, $rootScope, $modal, SaleTruck) {
- SaleTruck.query({}, function (data) {
- $rootScope.truck = data;
- $scope.truckCount = data ? data.length : 0;
- });
- $scope.$watch(function () {
- return $rootScope.truck;
- }, function (data) {
- $scope.truckCount = data ? data.length : 0;
- }, true);
- $scope.clearAll = function () {
- SaleTruck.remove({}, function () {
- $rootScope.truck = [];
- });
- };
-
- $scope.openTrack = function () {
- $modal.open({
- templateUrl: 'static/tpl/index/sale/track.html',
- controller: 'TruckModalCtrl',
- size: 'lg'
- }).result.then(function (s) {
- if (s) {
- $scope.clearAll();
- $rootScope.dataChanged = true;
- }
- });
- };
- }]);
- app.controller('TruckModalCtrl', ['$scope', '$rootScope', '$modalInstance', 'SaleTruck', 'PurcNotice', 'toaster', '$state', '$filter', '$timeout', 'token', function ($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice, toaster, $state, $filter, $timeout, token) {
- $scope.loading = false;
- $scope.saleSend = {sendItems: []};
- SaleTruck.detail({}, function (data) {
- // 按物料编号排序
- $scope.notices = $filter('orderBy')(data, 'orderItem.product.code');
- });
- $scope.remove = function (index, notice) {
- SaleTruck.remove({noticeId: notice.id}, function (data) {
- $rootScope.truck = data;
- $scope.notices.splice(index, 1);
- });
- };
- $scope.$watch(function () {
- return $scope.notices;
- }, function (data) {
- var q = 0, t = 0;
- if (data) {
- angular.forEach(data, function (d) {
- q += d.thisSendQty;
- t += d.thisSendQty * d.orderItem.price;
- });
- }
- $scope.totalQty = q;
- $scope.total = t;
- }, true);
- $scope.cancel = function () {
- $modalInstance.close();
- };
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function () {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- var getToken = function() {
- token.info({userType: 'salenotice'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- getToken();
- $scope.send = function () {// 发货
- $scope.loading = true;
- if (!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
- toaster.pop('error', '错误', '请输入送货单号');
- $scope.loading = false;
- return;
- }
- var currency = $scope.notices[0].orderItem.order.currency,
- custUU = $scope.notices[0].enUU,
- payments = $scope.notices[0].orderItem.order.payments, valid = true, items = [];
- var num = 1;
- for (var i in $scope.notices) {
- var item = $scope.notices[i];
- if (item.id) {
- if (item.orderItem.order.currency != currency || item.enUU != custUU || item.orderItem.order.payments != payments) {
- valid = false;
- break;
- }
- items[i] = {noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price, number: num++};
- }
- }
- if (!valid) {
- $scope.loading = false;
- toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致才能一起发货。');
- } else {
- var send = angular.extend(angular.copy($scope.saleSend), {
- currency: currency,
- custUU: custUU,
- payments: payments,
- sendItems: items
- });
- if($scope.token != null) {
- PurcNotice.sendByBatch({token: $scope.token}, send, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + send.code);
- $modalInstance.close(true);
- $state.go('sale.send_detail', {id: data.id});
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '错误', response.data);
- });
- }
- }
- $scope.setCheckedNoticeRead = function () {
- var ids = [];
- for (var i in $scope.notices) {
- var item = $scope.notices[i];
- if (item.id) {
- ids.push(item.id);
- }
- }
- PurcNotice.setRead({}, ids, function (message) {
-
- });
- }
- };
- }]);
- app.controller('PersonalSaleStatCtrl', ['$scope', 'SaleStat', function ($scope, SaleStat) {
- SaleStat.cust({}, function (data) {
- var p = [], q = [];
- angular.forEach(data.month, function (d) {
- p.push({
- x: (d.enterprise.enShortname || d.enterprise.enName),
- y: [(d.total || 0)],
- tooltip: (d.total || 0)
- });
- });
- angular.forEach(data.year, function (d) {
- q.push({
- x: (d.enterprise.enShortname || d.enterprise.enName),
- y: [(d.total || 0)],
- tooltip: (d.total || 0)
- });
- });
- $scope.custCharts = {
- month: {
- chartType: 'pie',
- datas: {
- data: p
- },
- config: {
- labels: false,
- title: "客户月采购量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- },
- year: {
- chartType: 'pie',
- datas: {
- data: q
- },
- config: {
- labels: false,
- title: "客户年采购量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- }
- };
- });
- SaleStat.seller({}, function (data) {
- var p = [], q = [];
- angular.forEach(data.month, function (d) {
- p.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function (d) {
- q.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.sellerCharts = {
- month: {
- chartType: 'pie',
- datas: {
- data: p
- },
- config: {
- labels: false,
- title: "业务员月销量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- },
- year: {
- chartType: 'pie',
- datas: {
- data: q
- },
- config: {
- labels: false,
- title: "业务员年销量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- }
- };
- });
- }]);
- app.controller('SaleStatCtrl', ['$scope', 'SaleStat', function ($scope, SaleStat) {
- SaleStat.get({}, function (data) {
- var p = [], q = [], r = [];
- angular.forEach(data.day, function (d) {
- p.push({x: d.day, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.month, function (d) {
- q.push({x: d.month, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function (d) {
- r.push({x: d.year, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.charts = {
- day: {
- chartType: "line",
- datas: {
- series: ['销售额'],
- data: p
- },
- config: {
- "labels": false,
- "title": "销售额统计(近15日线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors: ['#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- month: {
- chartType: "line",
- datas: {
- series: ['销售额'],
- data: q
- },
- config: {
- "labels": false,
- "title": "销售额统计(近12月线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors: ['#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- year: {
- chartType: "line",
- datas: {
- series: ['销售额'],
- data: r
- },
- config: {
- "labels": false,
- "title": "销售额统计(近10年线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors: ['#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- }
- };
- });
- }]);
- app.controller('NoticeCtrl', ['$scope', 'SnapshotService', 'AuthenticationService', function ($scope, SnapshotService, AuthenticationService) {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.useruu = data.userUU;
- SnapshotService.getNotice(7, $scope.useruu, function (data) { //5表示首页显示的公告条数
- $scope.notices = data;
- });
- /**
- * 设置单据阅读状态
- * @param id
- */
- $scope.setReadStatus = function(id) {
- SnapshotService.setNoticeStatusAfterRead(id, $scope.useruu);
- }
- /**
- * 判断是否当天时间
- * @param date
- * @param time
- * @returns {boolean}
- */
- $scope.isCurrentTime = function(date, time) {
- var date1 = date.getFullYear() + '-' + date.getMonth() + 1 + '-' + date.getDate();
- var date2 = new Date(time).getFullYear() + '-' + new Date(time).getMonth() + 1 + '-' + new Date(time).getDate();
- return date1 == date2;
- }
-
- });
- $scope.dateTime = new Date();
- $scope.time = new Date().getTime();
- /**
- * 收起展开公告
- */
- $scope.show = false;
- $scope.showGongGao = function () {
- $scope.show = !$scope.show
- }
- }]);
- app.controller('TenderCtrl', ['$scope', 'SnapshotService', function ($scope, SnapshotService) {
- SnapshotService.getOpenTender(5, function (data) {
- $scope.openTenders = data;
- var newDate = new Date();
- newDate = newDate.getTime() - 3 * 24 * 60 * 60 * 1000;
- angular.forEach($scope.openTenders, function (tender) {
- if (tender.date - newDate > 0) {
- tender.isNew = true;
- } else {
- tender.isNew = false;
- }
- });
- });
- $scope.dateTime = new Date();
- }]);
- app.controller('VendCountCtrl', ['$scope', 'VendorService', function ($scope, VendorService) {
- VendorService.getCount(function (date) {
- $scope.count = date;
- });
- }]);
- // 客户
- app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', 'Vendor', 'AccountUser', 'CurrentRole', function ($scope, VendorService, BaseService, AuthenticationService, ngTableParams, $modal, toaster, Vendor, AccountUser, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- // 获取当前用户分配客户的操作权限
- CurrentRole.roles({}, function (data) {
- // 存在权限或者user表sys字段为1时
- $scope.enabled = data.count > 0 || $scope.thisUser.sys;
- }, function (response) {
- });
- var getCustInfos = function (custuu) {
- if (custuu) {
- VendorService.userInfo.query({uu: custuu}, null, function (data) {
- $scope.custInfos = data;
- var getPage = function (page, size) {
- if ($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1) * size, page * size);
- if ($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- } else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1, 4);
- $scope.first = function () {
- $scope.userdata = getPage($scope.userdata.pre, 4);
- }
- $scope.last = function () {
- $scope.userdata = getPage($scope.userdata.next, 4);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }
- // 分配用户
- $scope.addUserInfo = function (customer) {
- if (!$scope.enabled) {
- toaster.pop('error', '您没有为当前客户分配用户的权限!');
- return;
- }
- // 获取当前用户在当前企业是否被转移权限
- AccountUser.getEnTransfer ({custUU: customer.myEnterprise.uu}, function(data) {
- customer.enTransfer = data.result;
- //是管理员,或者被转移了权限时
- if ($scope.enabled || customer.enTransfer) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function () {
- return customer;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- } else {
- toaster.pop('error', '您没有为当前客户分配用户的权限!');
- }
- });
- };
- // 转移权限
- $scope.transferUserInfo = function (customer) {
- customer.enDistribute = null;
- if (!$scope.enabled) {
- toaster.pop('error', '您没有转移当前客户权限的权限!');
- return;
- }
- // 获取当前用户在当前企业是否被转移权限
- AccountUser.getDistribute ({custUU: customer.myEnterprise.uu}, function(data) {
- customer.enDistribute = data.result;
- //是管理员,或者被分配时
- if ($scope.enabled || customer.enDistribute) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/transfer_userInfo.html',
- controller: 'TransferUserInfoCtrl',
- resolve: {
- customer: function () {
- return customer;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- } else {
- toaster.pop('error', '您没有转移当前客户权限的权限!');
- }
- });
- };
- $scope.showUserInfo = function (customer, boo) {
- $scope.custInfo = customer;
- if (boo) {
- getCustInfos(customer.myEnterprise.uu);
- $scope.userInfoResult = true;
- }
- };
- var getService = function () {
- return VendorService;
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = pageParams.keyword;
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //设置消息已读
- var setOrdersRead = function () {
- var sourceId = [];
- Vendor.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- });
- };
- setOrdersRead();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
- // 查看详情
- $scope.viewDetail = function (id) {
- window.location.hash = "#/sale/customer/" + id;
- }
- // 导出客户资料列表
- $scope.exportXls = function () {
- VendorService.exportXls.get({}, {}, function (data) {
- if (data.success){
- window.location.href = 'vendor/customer/xls?keyword='+ ($scope.keywordXls || '');
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // 客户详情
- app.controller('CustomerDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', 'VendorService', 'AuthenticationService', function ($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope, VendorService, AuthenticationService) {
- BaseService.scrollBackToTop();
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.vendorContacts = [];
- var loadData = function () {
- Vendor.getCustomerDetail({id: $stateParams.id}, {}, function (data) {
- $scope.customer = data.myEnterprise;
- $scope.customerInfo = data;
- Vendor.custContacts({enuu: $scope.customer.uu}, {}, function (data) {
- $scope.Contacts = data;
- });
- // 查看已分配人员
- VendorService.userInfo.query({uu: $scope.customer.uu}, null, function (data) {
- $scope.custInfos = data;
- var getPage = function (page, size) {
- if ($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1) * size, page * size);
- if ($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- } else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1, 4);
- $scope.first = function () {
- $scope.userdata = getPage($scope.userdata.pre, 4);
- }
- $scope.last = function () {
- $scope.userdata = getPage($scope.userdata.next, 4);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- // 新增客户联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.myenuu = uu;
- Vendor.saveCustContact({}, $scope.contact, function (data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.Contacts.push(data);
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- // 编辑客户联系人
- $scope.edit = function (contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function () {
- return contact;
- }
- }
- });
- modalInstance.result.then(function (data) {
- Vendor.saveContact({}, data, function (data) {
- loadData();
- toaster.pop('success', '提示', '联系人修改成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- // 删除客户联系人
- $scope.deleteById = function (id, index) {
- $scope.Contacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '客户联系人删除成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 供应商物料信息
- $scope.viewProdList = function (uu) {
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.addUserInfo = function () {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function () {
- return $scope.customerInfo;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- loadData();
- if (changed) {
- if (checked) {
- $scope.newUser.roles = checked;
- } else {
- loadUsers();
- }
- }
- });
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
- $scope.Quotation = function (uu, id) {
- $rootScope.custuu = uu;
- $rootScope.prodId = id;
- window.location.hash = "#/sale/quotation/new";
- }
- }]);
- app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function ($scope, $modalInstance, customer, AccountUser, toaster) {
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- $scope.distribute = [];
- AccountUser.findUsers({uu: customer.myEnterprise.uu}, null, function (data) {
- $scope.userinfos = data;
- var distribute = [];
- angular.forEach($scope.userinfos, function (user, index) {
- if (user.distribute) {
- distribute.push({num: index});
- }
- });
- $scope.distribute = distribute;
- $scope.havedone = angular.copy($scope.distribute);
- $scope.loading = false;
- })
- var checkStatus = function (userinfos) {
- var distribute = [];
- angular.forEach(userinfos, function (user, index) {
- if (user.distribute) {
- distribute.push({num: index});
- }
- });
- $scope.distribute = distribute;
- $scope.isChanged = !angular.equals($scope.havedone, $scope.distribute);
- }
- $scope.isChanged = false;
- $scope.isChangedAll = false;
- $scope.changes = [];
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.userinfos, function (item, index) {
- item.distribute = $scope.checkboxes.checked;
- });
- checkStatus($scope.userinfos);
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function () {
- var result = true;
- angular.forEach($scope.userinfos, function (item) {
- if (item.distribute != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- checkStatus($scope.userinfos);
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (customer.myEnterprise.uu) {
- angular.forEach($scope.userinfos, function (item, i) {
- chooseResult.push(item);
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.addUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- // 转移权限
- app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- $scope.transfer = [];
- AccountUser.findUsers({uu: customer.myEnterprise.uu}, {}, function (data) {
- $scope.userinfos = data;
- var transfer = [];
- angular.forEach($scope.userinfos, function (user, index) {
- // 当前用户是被管理员转移权限时,转移的是被管理员转移的权限。
- if ($scope.thisUser.userUU === user.userUU && user.transfer) {
- $scope.thisUser.transfer = true;
- }
- });
- angular.forEach($scope.userinfos, function (user, index) {
- if ($scope.thisUser.sys || $scope.thisUser.transfer) {
- if (user.transfer) {
- transfer.push({num: index});
- user.checked = true;
- }
- } else {
- if (user.distribute) {
- transfer.push({num: index});
- user.checked = true;
- }
- }
- });
- $scope.transfer = transfer;
- $scope.havedone = angular.copy($scope.transfer);
- $scope.loading = false;
- });
- var checkStatus = function (userinfos) {
- var transfer = [];
- angular.forEach(userinfos, function (user, index) {
- if ($scope.thisUser.sys || $scope.thisUser.transfer) {
- if (user.transfer) {
- transfer.push({num: index});
- }
- } else {
- if (user.distribute) {
- transfer.push({num: index});
- }
- }
- });
- $scope.transfer = transfer;
- $scope.isChanged = !angular.equals($scope.havedone, $scope.transfer);
- };
- $scope.isChanged = false;
- $scope.isChangedAll = false;
- $scope.changes = [];
- // 点击其中一个明细的复选框
- $scope.checkOne = function (user) {
- $scope.changes = [];
- if ($scope.thisUser.sys) { // 管理员操作
- user.$checked = !user.$checked;
- angular.forEach($scope.userinfos, function (userInfo) {
- if ($scope.thisUser.userUU === user.userUU && user.transfer) {
- $scope.thisUser.transfer = true;
- }
- if (user.userUU !== userInfo.userUU) {
- userInfo.transfer = false;
- }
- });
- } else if ($scope.thisUser.transfer) { // 被管理员转移权限的非管理员操作
- user.$checked = !user.$checked;
- angular.forEach($scope.userinfos, function (userInfo) {
- if (user.userUU !== userInfo.userUU) {
- userInfo.transfer = false;
- } else {
- userInfo.transfer = true;
- }
- });
- } else { // 被分配客户的用户
- user.$checked = !user.$checked;
- angular.forEach($scope.userinfos, function (userInfo) {
- if (user.userUU !== userInfo.userUU) {
- userInfo.distribute = false;
- } else {
- userInfo.distribute = true;
- }
- });
- }
- checkStatus($scope.userinfos);
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (customer.myEnterprise.uu) {
- // 当前用户是管理员时
- if ($scope.thisUser.sys) {
- angular.forEach($scope.userinfos, function (item, i) {
- chooseResult.push(item);
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.transferUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- // 非管理员转移自己的权限时
- angular.forEach($scope.userinfos, function (item, i) {
- if (item.transfer && item.userUU !== $scope.thisUser.userUU) {
- $scope.target = item;
- }
- });
- if (!$scope.target) {
- toaster.pop('error', '保存失败', "您未选择权限转移对象");
- } else {
- $scope.loading = true;
- AccountUser.transferMyDistribute({custUU: customer.myEnterprise.uu, userUU: $scope.target.userUU}, {} ,function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- });
- }
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- /**
- * 页面状态按钮过滤
- */
- var getState = function (active) {
- var fn = 'get';
- switch (active) {
- case 'done':
- fn = 'getDone';
- break;
- case 'todo':
- fn = 'getTodo';
- break;
- case 'end':
- fn = 'getEnd';
- break;
- case 'waiting':
- fn = 'getWaiting';
- break;
- case 'received':
- fn = 'getReceived';
- break;
- case 'invalid':
- fn = 'getInvalid';
- break;
- // 已采纳
- case 'agreed':
- fn = 'getAgreed';
- break;
- // 未采纳
- case 'refused':
- fn = 'getRefused';
- break;
- // 个人
- case 'personal':
- fn = 'getPersonal';
- break;
- // 集体
- case 'teams':
- fn = 'getTeams';
- break;
- // 非标准
- case 'nonstandard':
- fn = 'getNonstandard';
- break;
- // 标准
- case 'standard':
- fn = 'getStandard';
- break;
- // 变更单无需确认
- case 'unread':
- fn = 'getUnread';
- break;
- }
- return fn;
- };
- /**
- * 改变单据日期范围
- */
- var getDateCondition = function (zone, condition) {
- var fromDate = new Date();
- var toDate = new Date();
- //去除时分秒限制,dateFrom设置成0时0分0秒,dateTo设置成23时59分59秒
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- if (zone == -1) { // 自定义时间,什么都不做
- } else if (zone == 1) {
- fromDate.setMonth(fromDate.getMonth() - 1);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else if (zone == 3) {
- fromDate.setMonth(fromDate.getMonth() - 3);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else if (zone == 6) {
- fromDate.setMonth(fromDate.getMonth() - 6);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else {
- condition.dateFrom = null;
- condition.dateTo = null;
- }
- };
- /**
- * 改变单据交货日期范围
- */
- var getDelveryCondition = function (zone, condition) {
- var date = new Date();
- if (zone == -1) {
- condition.deliveryFrom = null;
- condition.deliveryTo = null;
- } else if (zone == 1) {
- date.setMonth(date.getMonth() + 1);
- condition.deliveryTo = date;
- condition.deliveryFrom = new Date();
- } else if (zone == 2) {
- date.setMonth(date.getMonth() + 2);
- condition.deliveryTo = date;
- condition.deliveryFrom = new Date();
- }
- };
- /**
- * 将日期转化为整数日期
- */
- var getDateTime = function (date) {
- if (angular.isDate(date)) {
- return date.getTime();
- } else {
- return null;
- }
- };
- /**
- * 删除数组里某个特定的值
- */
- var removeByValue = function (arr, val) {
- for(var i=0; i<arr.length; i++) {
- if(arr[i] == val) {
- arr.splice(i, 1);
- break;
- }
- }
- };
- app.controller('PurcOrderCtrl', ['$scope', '$filter', 'PurcOrders', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', '$rootScope', 'PurchaseOrder', 'PurcOrdersInfo', 'PurcOrderItem', 'CurrentRole',
- function ($scope, $filter, PurcOrders, PurcOrder, ngTableParams, toaster, ReportService, BaseService, $rootScope, PurchaseOrder, PurcOrdersInfo, PurcOrderItem, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'all';
- }
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcOrders : PurcOrdersInfo;
- };
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getPurcStatus = function (active) {
- var fn = 'getPurcAll';
- switch (active) {
- case 'done':
- fn = 'getPurcDone';
- break;
- case 'todo':
- fn = 'getPurcTodo';
- break;
- case 'end':
- fn = 'getPurcEnd';
- break;
- case 'waiting':
- fn = 'getPurcWaiting';
- break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {
- display: 'desc',
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 15, 25, 50],
- getData: function ($defer, params) {// 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $defer.resolve(page.content);
- $scope.total = page.totalElement;
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcOrders.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcOrders.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function () {
- PurcOrders.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.getOrderTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- // 需方 打印 采购单
- $scope.custPrint = function (order) {
- var newPage = window.open("about:blank");
- PurcOrder.printPermission({}, function () {
- PurcOrder.custPrintCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'PURCLIST_CUST', "where purc$orders.pu_id=" + order.id, newPage);
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (order) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.tip = keyword;
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 复制订单
- $scope.copyorder = function (id) {
- PurchaseOrder.copyorder({id: id}, {}, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '单据复制成功');
- window.location.hash = "#purc/cart/" + data.id;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 导出
- $scope.exportXls = function () {
- PurcOrders.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/orders/purc/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('PurcOrderDetailCtrl', ['$scope', '$stateParams', 'PurcOrder', 'PurcOrderItem', 'toaster', 'ReportService', 'PurcOrdersInfo', 'CurrentRole', function ($scope, $stateParams, PurcOrder, PurcOrderItem, toaster, ReportService, PurcOrdersInfo, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- $scope.loading = true;
- PurcOrdersInfo.getAll({id: $stateParams.id},{}, function (data) {
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function (item) {
- sum += item.qty * item.price;
- });
- $scope.order.total = sum;
- // if($scope.order.display == 1) {//未查看的设为已查看
- // $scope.setDisplay('setRead', $scope.order.id);
- // }
- //$scope.loading = false;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.onReplyClick = function (item, inverse) {
- if (item.reply) {
- if (!item.reply.qty || item.reply.qty < 0 || item.reply.qty > item.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- PurcOrderItem.reply({orderItemId: item.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- //设置为已查看
- $scope.setDisplay = function (state, orderId) {
- if (orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function () {
- // $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- if (str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if (str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- }]);
- app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PagingRelease', 'SnapshotService', 'PurcOrderItemInfo', 'token', 'CurrentRole', '$timeout', '$modal', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PagingRelease, SnapshotService, PurcOrderItemInfo, token, CurrentRole, $timeout, $modal) {
- BaseService.scrollBackToTop();
- // 判断是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.nowdate = new Date();
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function () {
- return $scope.searchMethod ? PurcOrderItem : PurcOrderItemInfo;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {
- date: 'desc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 15, 25, 50],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $defer.resolve(page.content);
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcOrderItem.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcOrderItem.setRead({}, sourceId, function (message) {
- getUnreadCount();
- });
- };
- //批量设置单据已读
- $scope.setOrdersReadByBatch = function () {
- var sourceId = [];
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- sourceId.push(order.id);
- }
- });
- PurcOrderItem.setRead({}, sourceId, function (message) {
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcOrderItem.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcOrderItem.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getOrderTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 获取token信息
- $scope.getToken = function() {
- token.info({userType: 'sale'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- $scope.onReplyClick = function (item, inverse) {
- if (item.reply) {
- if (!item.reply.qty || item.reply.qty < 0 /*|| item.reply.qty > item.qty*/) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- if($scope.token != null) {
- PurcOrderItem.reply({orderItemId: item.id, token: $scope.token}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- }
- };
- //打印 采购单
- $scope.print = function (order) {
- var newPage = window.open("about:blank");
- PurcOrder.printPermission({}, function () {
- PurcOrder.printCount({id: order.id}, {});//增加打印此次 // 在此方法内添加记录日志
- if (order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
- ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id , newPage);
- $scope.tableParams.reload();
- },function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (order) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- //批量回复采购订单
- $scope.replyByBatch = function () {
- $scope.loading = true;
- var str = '';
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- str += order.id;
- str += ',';
- }
- });
- if (!(str == '')) {
- $scope.loading = false;
- str = str.substr(0, str.length - 1);
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/modal/reply_bybatch.html',
- controller: 'ReplyByBatchCtrl',
- resolve: {}
- });
- modalInstance.result.then(function(data) {
- $scope.loading = true;
- var reply = data;
- var date = null;
- if (reply.date && reply.method == 1) {
- date = reply.date.getTime();
- }
- PurcOrderItem.replyByBatch({date: date}, str, function () {
- $scope.loading = false;
- $scope.tableParams.reload();
- toaster.pop('success', '提示', '批量回复成功');
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', '批量回复失败');
- });
- });
- } else {//没有勾选其中的明细
- toaster.pop('error', '提示', '请先选择需要回复的单据');
- $scope.loading = false;
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //设置为已查看
- $scope.setDisplay = function (state, orderId) {
- if (orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- if (str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if (str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- // 导出
- $scope.exportXls = function () {
- PurcOrderItem.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/orders/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 批量回复模态框
- */
- app.controller('ReplyByBatchCtrl', ['$scope', '$modalInstance', '$filter', 'toaster', function($scope, $modalInstance, $filter, toaster) {
- $scope.activeTab = 'custom';
- $scope.reply = {
- method: 1
- };
- $scope.getMinDate = function () {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.$dateOpen = !openParam;
- };
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- // 提交
- $scope.submit = function () {
- if ($scope.reply.method == 0) {
- $modalInstance.close($scope.reply);
- } else if ($scope.reply.method == 1) {
- if (angular.isUndefined($scope.reply.date)) {
- toaster.pop('error', '提示', '请先选择日期')
- } else {
- $modalInstance.close($scope.reply);
- }
- }
- }
- }]);
- app.controller('SaleOrderDetailCtrl', ['$scope', '$stateParams', 'PurcOrder', 'PurcOrderItem', 'toaster', 'ReportService', 'CurrentRole', 'token', 'file', function ($scope, $stateParams, PurcOrder, PurcOrderItem, toaster, ReportService, CurrentRole, token, file) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var existFile = false;
- var loadData = function () {
- PurcOrder.get({id: $stateParams.id}, function (data) {
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function (item) {
- sum += item.qty * item.price;
- if (item.attachs.length > 0) {
- existFile = true;
- }
- });
- $scope.order.total = sum;
- if ($scope.order.display == 1) {//未查看的设为已查看
- $scope.setDisplay('setRead', $scope.order.id);
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 获取token信息
- var getToken = function() {
- token.info({userType: 'sale'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- getToken();
- $scope.onReplyClick = function (item, inverse) {
- if (item.reply) {
- if (!item.reply.qty || item.reply.qty < 0 /*|| item.reply.qty > item.qty*/) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- if($scope.token != null) {
- PurcOrderItem.reply({orderItemId: item.id, token: $scope.token}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- }
- };
- // 采购单
- $scope.print = function (order) {
- var newPage = window.open("about:blank");
- PurcOrder.printPermission({}, function () {
- PurcOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id, newPage);
- },function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- //设置为已查看
- $scope.setDisplay = function (state, orderId) {
- if (orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- if (str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if (str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- // 下载附件
- $scope.fileDownload = function (id) {
- if (!existFile) {
- toaster.pop('error', '提示', "当前采购单不存在附件信息");
- } else {
- window.open("file/batch/" + id);
- }
- }
- }]);
- app.controller('SaleChangeCtrl', ['$scope', '$filter', 'PurcChange', 'PurcChanges', 'ngTableParams', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $filter, PurcChange, PurcChanges, ngTableParams, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcChange : PurcChanges;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcChange.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcChange.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcChange.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcChange.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- PurcChange.reply({changeId: change.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcChange.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/changes/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('SaleChangeDetailCtrl', ['$scope', '$stateParams', 'PurcChange', 'toaster', 'CurrentRole', function ($scope, $stateParams, PurcChange, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- PurcChange.getItem({id: $stateParams.id}, function (data) {
- $scope.change = data;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- PurcChange.reply({changeId: change.id}, reply, function () {
- toaster.pop('info', '提示', '回复成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- }]);
- //客户采购询价
- app.controller('SaleInquiryCtrl', ['$scope', '$filter', 'PurcInquiry', 'ngTableParams', 'toaster', 'BaseService', 'PurcInquiryInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', function ($scope, $filter, PurcInquiry, ngTableParams, toaster, BaseService, PurcInquiryInfo, $upload, $rootScope, token, $timeout, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- // 设置阅读状态
- $scope.setReadStatus = function(msg) {
- if(!msg.read) {
- PurcInquiry.setStatus({id: msg.inid}, {}, function(data) {
- });
- }
- }
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcInquiry : PurcInquiryInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcInquiry.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcInquiry.setRead({}, sourceId, function (message) {
- getUnreadCount();
- removeByValue($scope.unreadCode, id);
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcInquiry.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcInquiry.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.addStep = function (inquiryItem) {
- $scope.replyPrices.push(true);
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else {
- inquiryItem.replies.push({});
- if (inquiryItem.replies.length != 1) {
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- }
- }
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- $scope.replyPrices.splice(stepIndex, 1);
- $scope.replylapQtys.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id},function (data) {
- $scope.historyShow = true;
- item.history = data;
- }, function (response) {
- $scope.historyShow = false;
- //toaster.pop('error', '数据加载失败', response.data);
- });
- }
- };
- // 获取token信息
- $scope.getToken = function() {
- token.info({userType: 'saleinquiry'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- $scope.deleteAttach = function (attaches, index) {
- attaches.splice(index, 1);
- };
-
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- // 判断分段数是否合法
- var valid = true;
- var validLapQty = 0;
- angular.forEach(item.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price) {
- replies.push(r);
- }
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- });
- item.replies = replies;
- $scope.loading = true;
- if (!valid) {
- if (validLapQty) {
- toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('info', '提示', '分段数量不合法,不能保存!');
- }
- $scope.loading = false;
- } else {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- if (withSteps) { // 保存并报价
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'reply'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '附件上传失败');
- });
- } else {
- PurcInquiry.reply({itemId: item.id, token: $scope.token}, item, function (data) {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '询价失效', response.data);
- });
- }
- } else { // 保存
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'save'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '附件上传失败');
- });
- } else {
- PurcInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function (data) {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- $scope.verifylapQty(r.lapQty, i, item);
- bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
- });
- return bool;
- };
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,6})?$/;
- var valid = true;
- angular.forEach(inquiryItem.replies, function(reply, $index) {
- if ($index < index && reply.lapQty >= value) {
- valid = false;
- }
- });
- $scope.replylapQtys[index] = regex.test(value) && valid;
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- // 导出
- $scope.exportXls = function () {
- PurcInquiry.exportXls({}, {}, function (data) {
- if (data.success) {
- window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- }]);
- // 询价单明细
- app.controller('SaleInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', function ($scope, $stateParams, PurcInquiry, $filter, toaster, $upload, token, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- PurcInquiry.getAll({id: $stateParams.id}, function (data) {
- $scope.newinquiryItems = data;
- var inquiry = data[0].inquiry;
- //inquiry.inquiryItems = data;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,6})?$/;
- var valid = true;
- angular.forEach(inquiryItem.replies, function(reply, $index) {
- if ($index < index && reply.lapQty >= value) {
- valid = false;
- }
- });
- $scope.replylapQtys[index] = regex.test(value) && valid;
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- $scope.verifylapQty(r.lapQty, i, item);
- bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
- });
- return bool;
- };
- // 获取token信息
- $scope.getToken = function() {
- token.info({userType: 'saleinquiry'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- $scope.deleteAttach = function (attaches, index) {
- attaches.splice(index, 1);
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- var valid = true;
- var validLapQty = 0;
- angular.forEach(item.replies, function (r, i) {
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- $scope.loading = true;
- if (!valid) { // 不合法时给出提示
- if (validLapQty) {
- toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('info', '提示', '分段数量不合法,不能保存!');
- }
- $scope.loading = false;
- } else {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- if (withSteps) {
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'reply'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- window.location.reload();
- });
- } else {
- PurcInquiry.reply({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- // loadData();
- window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '询价失效', response.data);
- });
- }
- } else {
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'save'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- window.location.reload();
- });
- } else {
- PurcInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- // loadData();
- window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- }]);
- // 平台新增的询价单
- app.controller('PurcInquiryCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'PurcProduct', 'PurcProductNewest', '$timeout', '$http', 'ShipAddress', 'Search', 'ComponentActiveAPI', '$state',
- function ($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, PurcProduct, PurcProductNewest, $timeout, $http, ShipAddress, Search, ComponentActiveAPI, $state) {
- $scope.status = 'InquiryNew';
- $scope.active = 'all';
- $rootScope.tenderVendor = null;// 清除掉已选择的
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcProduct : PurcProductNewest;
- };
- $scope.inquiry = {
- code: 'XJ' + $filter('date')(new Date(), 'yyMMddsss'),
- showdate: $filter('date')(new Date, 'yyyy-MM-dd'),
- priceType: '采购',
- isOpen: 1,
- invoice: 0,
- ifTax: 1,
- currency: 'RMB',
- inquirytype: '询价'
- };
- $scope.changeCurrency = function (inquiry) {
- if (inquiry.currency !== 'RMB') {
- $scope.notRMB = true;
- inquiry.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- inquiry.invoice = 0;
- } else {
- $scope.notRMB = false;
- }
- };
- // 获取收货地址列表
- var loadShipAddress = function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- if (angular.isDefined($scope.ships)) {
- $scope.inquiry.ship = $scope.ships[0].address + $scope.ships[0].addressdet + $scope.ships[0].receiver + $scope.ships[0].usertel;
- }
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- $scope.currentDay = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.vendors = [];
- // 查找供应商
- $scope.dbfindVendor = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- var ifPush = true;
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (vendor) {
- if (!$scope.vendors) {// 不存在就先创建
- $scope.vendors = [{}];
- $scope.vendors.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0; i < $scope.vendors.length; i++) {
- ifPush = true;
- if ($scope.vendors[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.vendors.push({
- enName: vendor.vendorEnterprise.enName,
- enuu: vendor.vendorEnterprise.uu
- });
- }
- }
- });
- $rootScope.tenderVendor = $scope.vendors;
- }, function () {
- });
- }, function () {
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function (index) {
- $scope.vendors.splice(index, 1);
- };
- $scope.removeChecked = function () {
- if ($scope.vendors.length > 0) {
- $scope.vendors = [];
- $rootScope.tenderVendor = '';
- }
- }
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.inquiry.inquiryItems = [];
- var prod = {
- cmpCode: null,
- prodTitle: null,
- inbrand: null,
- toDate: null,
- unit: 'PCS',
- needquantity: null
- };
- $scope.inquiry.inquiryItems.push(prod);
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function (value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function (value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- $scope.selectKind = function (prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function () {
- return $scope.actives;
- }
- }
- }).result.then(function (data) {
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function () {
- });
- };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function (brand, prod) {
- if (brand instanceof String) {
- prod.inbrand = brand;
- } else if (brand instanceof Object) {
- prod.inbrand = brand.brandCn;
- }
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function (prod) { //打开模态
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller: 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function () {// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function (brand) {
- prod.inbrand = brand.nameCn;
- }, function (reason) {
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function (cmp, prod) {
- ComponentActiveAPI.get({uuid: cmp.uuid}, {}, function (data) {
- $scope.component = data;
- prod.cmpCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.inbrand = data.brand.nameCn;
- }, function (res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcInquiryUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.inquiry.inquiryItems.push(prod);
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- })
- }, function () {
- });
- }
- //增加商品
- $scope.add = function () {
- $scope.inquiry.inquiryItems.push(
- {
- cmpCode: null,
- prodTitle: null,
- unit: 'PCS',
- ibrand: null,
- toDate: null,
- needquantity: null
- });
- };
- //删除商品
- $scope.del = function (index) {
- $scope.inquiry.inquiryItems.splice(index, 1);
- };
- $scope.check = function (product) {
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- $scope.inquiry.inquiryItems.push({
- cmpCode: product.cmpCode, prodTitle: product.title, spec: product.spec, unit: product.unit,
- currency: null, toDate: null, needquantity: null, productId: product.id, inbrand: product.brand
- });
- }
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.inquiry.inquiryItems[index].$toDateOpen = !openParam;
- };
- $scope.openEndDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.ifrepeat = false;
- // 保存
- $scope.save = function () {
- $scope.loading = true;
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for (var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if (i != j) {
- if ($scope.item.prodCode == $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- if (!$scope.ifrepeat) {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- if ($scope.inquiry.isOpen == 0) { // 指定询价
- if ($scope.vendors.length > 0) {
- $upload.upload({
- url: 'purc/inquiry/save/withVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $rootScope.active = 'todo';
- window.location.hash = "#/purc/inquiry_unapply";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- } else {
- $upload.upload({
- url: 'purc/inquiry/save/withoutVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', '存在相同条件的物料信息');
- }
- }
- // 保存并提交
- $scope.submit = function () {
- $scope.loading = true;
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for (var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if (i != j) {
- if ($scope.item.prodCode == $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- if (!$scope.ifrepeat) {
- if ($scope.inquiry.isOpen == 0) { // 指定询价
- if ($scope.vendors.length > 0) {
- $upload.upload({
- url: 'purc/inquiry/submit/withVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- window.location.hash = "#/purc/purchaseinquiry";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- } else {
- $upload.upload({
- url: 'purc/inquiry/submit/withoutVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', '存在相同条件的物料信息');
- }
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- }]);
- /**
- * 代采订单批量导入
- */
- app.controller('PurcInquiryUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function () {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'purc/inquiry/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- toaster.pop('error', response.data || response);
- });
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'purc/inquiry/upload/template';
- };
- $scope.enSure = function () {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- // 平台询价单(已提交)
- app.controller('PurchaseInquiryCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', 'PurchaseInquiry', '$rootScope', 'CurrentRole', function ($scope, $filter, ngTableParams, toaster, BaseService, PurchaseInquiry, $rootScope, CurrentRole) {
- $scope.status = 'InquirySubmit';
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- }
- var getService = function () {
- return PurchaseInquiry;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurchaseInquiry.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurchaseInquiry.setRead({}, sourceId, function (message) {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获得未读单据id
- var getUnreadIds = function (){
- PurchaseInquiry.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 采纳
- $scope.accept = function (id) {
- PurchaseInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- PurchaseInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 导出
- $scope.exportXls = function () {
- PurchaseInquiry.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'purc/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // 平台询价单(未提交)
- app.controller('UnapplyInquiryCtrl', ['$scope', 'PurchaseInquiry', 'ngTableParams', 'BaseService', 'toaster', '$rootScope', function ($scope, PurchaseInquiry, ngTableParams, BaseService, toaster, $rootScope) {
- BaseService.scrollBackToTop();
- if ($rootScope.active = 'done') {
- $scope.active = 'done';
- $rootScope.active = '';
- }
- if ($rootScope.active = 'todo') {
- $scope.active = 'todo';
- $rootScope.active = '';
- }
- var getService = function () {
- if ($scope.active == 'todo') {
- return PurchaseInquiry.getUnapply;
- }
- if ($scope.active == 'done') {
- return PurchaseInquiry.getSubmit;
- }
- }
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- }
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc',
- 'enterprise.enName': 'asc',
- 'code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 删除明细
- $scope.deleteById = function (id) {
- PurchaseInquiry.deleteById({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 删除主表
- $scope.clearOrder = function (id) {
- PurchaseInquiry.clearOrder({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 提交
- $scope.submit = function (id) {
- PurchaseInquiry.submitUnapply({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '单据提交成功');
- $scope.active = 'done';
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 发布公共询价
- $scope.publish = function (id) {
- PurchaseInquiry.publishInquiry({id: id}, {}, function (data) {
- toaster.pop('success', '提示', data.success);
- $scope.active = 'done';
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- // 公共询价列表
- app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', 'publicInquiryList', '$modal', '$http', 'AccountEnterprise', 'customer', 'AuthenticationService', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry, publicInquiryList, $modal, $http, AccountEnterprise, customer, AuthenticationService) {
- BaseService.scrollBackToTop();
- }]);
- /**
- * 报价操作
- */
- app.controller('QuoteCtrl', ['$scope', 'inquiryItem', 'toaster', 'publicInquiry', '$modalInstance', '$upload', function($scope, inquiryItem, toaster, publicInquiry, $modalInstance, $upload) {
- $scope.inquiryItem = inquiryItem;
- if ($scope.inquiryItem.replies == null || $scope.inquiryItem.replies.length == 0) {
- $scope.inquiryItem.replies = [];
- var reply = {
- lapQty: 0,
- price: null
- };
- $scope.inquiryItem.replies.push(reply);
- }
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- // 获取默认币别
- publicInquiry.getCurrency({}, function(data) {
- $scope.currencies = data;
- });
- // 增加一列分段报价
- $scope.addStep = function (inquiryItem) {
- var check = true;
- angular.forEach(inquiryItem.replies, function(reply) {
- if (reply.lapQty == null) {
- toaster.pop('error', '提示', '存在未填写分段数量的分段,请先填写分段数量');
- check = false;
- }
- if (check && reply.price == null) {
- toaster.pop('error', '提示', '存在未填写价格的分段,请先填写价格');
- check = false;
- }
- });
- if (check) {
- $scope.replyPrices.push(true);
- if (inquiryItem.replies.length >= 5) {
- toaster.pop('warning', '提示', '最多支持5个分段!');
- } else {
- inquiryItem.replies.push({});
- if (inquiryItem.replies.length != 1) {
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- }
- }
- }
- };
- // 删除一列分段报价
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- $scope.replyPrices.splice(stepIndex, 1);
- $scope.replylapQtys.splice(stepIndex, 1);
- };
- // 取消,关闭弹出框
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- // 保存报价信息
- $scope.save = function(inquiryItem, method) {
- var replies = [];
- // 判断分段数是否合法
- var valid = true;
- var validLapQty = 0;
- angular.forEach(inquiryItem.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price) {
- replies.push(r);
- }
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(inquiryItem.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- });
- inquiryItem.replies = replies;
- $scope.loading = true;
- if (!valid) {
- if (validLapQty) {
- toaster.pop('error', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('error', '提示', '分段数量不合法,不能报价!');
- }
- } else {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'pubInquiry/turnToQuotation',
- file: file,
- method: 'POST',
- data: {
- item: inquiryItem,
- method: method
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $modalInstance.close();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '报价失败');
- });
- }
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- }]);
- /**
- * 公共询价详情
- */
- app.controller('PublicInquiryListDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'AccountEnterprise', 'publicInquiry', 'publicInquiryList', '$modal', '$http', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, AccountEnterprise, publicInquiry, publicInquiryList, $modal, $http) {
- BaseService.scrollBackToTop();
- $scope.currentHasBid = false;
- var loadData = function () {
- // 当前企业
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/sale/publicInquiry/detail',
- params: {id: $stateParams.id, enuu: $scope.enterprise.uu}
- }).success(function (response) {
- if (response) {
- $scope.inquiryItem = response.inquiryItem;
- }
- }).error(function (err) {
- toaster.pop('error', '数据加载失败', err);
- });
- });
- });
- };
- loadData();
- // 当前时间
- $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
- // 当前企业
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data;
- });
- $scope.isOverDue = function (date) {
- if (date) {
- var ndate = new Date();
- ndate.setHours(23, 59, 59 ,999);
- ndate.setDate(ndate.getDate());
- var timestamp = Date.parse(ndate);
- if (date > timestamp) {
- return true;
- } else {
- return false;
- }
- } else {
- return true;
- }
- }
- // 转客户询价
- $scope.transtoInquiry = function (inquiryItem) {
- publicInquiry.quotationInfo({id: inquiryItem.id}, function(data) {
- if (data.inquiryItem) { //存在已报价的就不进行报价操作
- toaster.pop('error', '该询价单已已经报价');
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }
- });
- }
- }]);
- // 询价单明细
- app.controller('PurcInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', 'CurrentRole', function ($scope, $stateParams, PurcInquiry, $filter, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = !data.isUser;
- });
- var loadData = function () {
- PurcInquiry.getAll({id: $stateParams.id}, function (data) {
- $scope.newinquiryItems = data;
- var inquiry = data[0].inquiry;
- //inquiry.inquiryItems = data;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- bool = (i > 0 ? r.lapQty : 1) && r.price;
- });
- return bool;
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- angular.forEach(item.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- if (withSteps) {
- PurcInquiry.reply({itemId: item.id}, item, function () {
- toaster.pop('info', '提示', '报价成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '报价失败', response.data);
- });
- }
- };
- }]);
- // 询价单明细(发出)
- app.controller('PurcInquiryInfoDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'CurrentRole', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- PurchaseInquiry.detail({id: $stateParams.id}, {},function (data) {
- $scope.inquiry = data;
- },function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.nowDate = new Date().getTime();
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- bool = (i > 0 ? r.lapQty : 1) && r.price;
- });
- return bool;
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- angular.forEach(item.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- if (withSteps) {
- PurcInquiry.reply({itemId: item.id}, item, function () {
- toaster.pop('info', '提示', '报价成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '报价失败', response.data);
- });
- }
- };
- // 采纳
- $scope.accept = function (id) {
- PurchaseInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- PurchaseInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- // 模具询价管理
- app.controller('SaleInquiryMouldCtrl', ['$scope', '$filter', 'PurcInquiryMould', 'ngTableParams', 'toaster', 'BaseService', '$upload', 'PurcInquiryMouldSql', 'CurrentRole', function ($scope, $filter, PurcInquiryMould, ngTableParams, toaster, BaseService, $upload, PurcInquiryMouldSql, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- var inquiryMould_copy = {};
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- };
- var getService = function () {
- if ($scope.keyword) {
- return PurcInquiryMould;
- } else {
- return PurcInquiryMouldSql;
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- // 用来验证价格修改
- var mould = page.content;
- inquiryMould_copy = angular.copy(mould);
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词 $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcInquiryMould.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcInquiryMould.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcInquiryMould.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcInquiryMould.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiryMould.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replyPrices.push(true);
- // 取消
- $scope.reload = function () {
- $scope.tableParams.reload();
- $scope.canSave = false;
- }
- // 能否保存设置
- $scope.canSave = false;
- // items价格验证
- $scope.verifyItems = function (price, reply) {
- var regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;// ^[0-9]+(\.[0-9]{1,6})?$
- if (regex.test(price) && price != 0) {
- if (price != reply) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- // prod下prods价格验证
- $scope.verifyProds = function (price, reply) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if (regex.test(price) && price != 0) {
- if (price != reply) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- //有价格为0或者不符合正则式,则不能报价
- $scope.notZero = function (mould) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- angular.forEach(mould.inquiryMouldItems, function (item) {
- if (item.price == 0 || !regex.test(item.price)) {
- $scope.canSave = false;
- }
- angular.forEach(item.inquiryMouldDetails, function (detail) {
- if (detail.price == 0 || !regex.test(detail.price)) {
- $scope.canSave = false;
- }
- })
- });
- }
- $scope.blurPrice = function (price) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (!regex.test(price)) {
- toaster.pop('warning', '格式错误', '请输入有效价格');
- }
- }
- // 获取历史报价
- $scope.getHistory = function (mould) {
- if (!mould.history) {
- PurcInquiryMould.getHistory({id: mould.id},{}, function (data) {
- $scope.historyShow = true;
- mould.history = data;
- },function (response) {
- $scope.historyShow = false;
- });
- }
- };
- var uploadAttach = function (mould, file) {
- // var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
- $scope.mould = mould;
- $upload.upload({
- url: 'sale/mould/' + mould.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.mould
- }
- }).success(function (res) {
- $scope.mould.sellAttachs.push(res);
- }).error(function (res) {
- });
- }
- $scope.pushFile = function(mould, file) {
- // var file = $scope.myFiles;
- if (file.length > 0) {
- for (var i = 0; i < file.length; i++) {
- console.log(file[i].name);
- var flag = true;
- if (mould.sellAttachs.length > 0) {
- for (var j = 0; j < mould.sellAttachs.length; j++) {
- if (mould.sellAttachs[j].name == file[i].name
- && mould.sellAttachs[j].size == file[i].size) {
- flag = false;
- break;
- }
- }
- }
- if (flag) {
- uploadAttach(mould, file[i]);
- $scope.canSave = true;
- }
- }
- }
- document.getElementById("inquiryMould.sellAttachs").value = "";
- };
- $scope.removeFile = function(mould, file) {
- $scope.inquiryMould = mould;
- if ($scope.inquiryMould.sellAttachs != null && $scope.inquiryMould.sellAttachs.length > 0) {
- for (var i = 0; i < $scope.inquiryMould.sellAttachs.length; i++) {
- if ($scope.inquiryMould.sellAttachs[i].name == file.name
- && $scope.inquiryMould.sellAttachs[i].size == file.size) {
- $scope.inquiryMould.sellAttachs.splice(i, 1);
- }
- }
- }
- };
- // 保存并确认报价
- $scope.onReplyClick = function (mould, withSteps) {
- $scope.loading = true;
- if (withSteps) {
- PurcInquiryMould.reply({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- $scope.canSave = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '报价失败', response.data);
- });
- PurcInquiryMould.saveHistory({id: mould.id}, mould, function () {
- }, function (response) {
- });
- } else {
- PurcInquiryMould.saveItem({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 导出客户资料列表
- $scope.exportXls = function () {
- PurcInquiryMould.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/mould/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // 模具询价单明细
- app.controller('SaleInquiryMouldDetailCtrl', ['$scope', '$stateParams', 'PurcInquiryMould', '$filter', 'toaster', '$upload', 'CurrentRole', function ($scope, $stateParams, PurcInquiryMould, $filter, toaster, $upload, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var inquiryMould_copy = {};
- var loadData = function () {
- PurcInquiryMould.getAll({id: $stateParams.id}, function (data) {
- // 用来验证价格修改
- inquiryMould_copy = angular.copy(data);
- $scope.inquiryMould_copy = inquiryMould_copy;
- $scope.newinquirymould = data;
- var mould = data;
- angular.forEach(mould.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiryMould = mould;
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- // 取消
- $scope.reload = function () {
- loadData();
- $scope.canSave = false;
- }
- //有价格为0,则不能报价
- $scope.notZero = function (mould) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- angular.forEach(mould.inquiryMouldItems, function (item) {
- if (item.price == 0 || !regex.test(item.price)) {
- $scope.canSave = false;
- }
- angular.forEach(item.inquiryMouldDetails, function (detail) {
- if (detail.price == 0 || !regex.test(detail.price)) {
- $scope.canSave = false;
- }
- })
- });
- }
- $scope.blurPrice = function (price) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (!regex.test(price)) {
- toaster.pop('warning', '格式错误', '请输入有效价格');
- }
- }
- // 获取历史报价
- $scope.getHistory = function (mould) {
- if (!mould.history) {
- PurcInquiryMould.getHistory({id: mould.id},{}, function (data) {
- $scope.historyShow = true;
- mould.history = data;
- },function (response) {
- $scope.historyShow = false;
- //toaster.pop('error', '提示', response.data);
- });
- }
- };
- $scope.canSave = false;
- // items价格验证
- $scope.verifyItems = function (price, index) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if (regex.test(price) && price != 0) {
- var itemprice = $scope.inquiryMould.inquiryMouldItems[index].price;
- if (itemprice != inquiryMould_copy.inquiryMouldItems[index].price) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- // prod下prods价格验证
- $scope.verifyProds = function (price, index, parentIndex) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if (regex.test(price) && price != 0) {
- var prodPrice = $scope.inquiryMould.inquiryMouldItems[parentIndex].inquiryMouldDetails[index].price;
- if (prodPrice != inquiryMould_copy.inquiryMouldItems[parentIndex].inquiryMouldDetails[index].price) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- // 上传附件
- var uploadAttach = function(file) {
- // var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
- $scope.mould = $scope.inquiryMould;
- $upload.upload({
- url: 'sale/mould/' + $scope.mould.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.mould
- }
- }).success(function(attach){
- if (attach){
- $scope.inquiryMould.sellAttachs.push(attach);
- }
- }).error(function(res){
- console.log("failure");
- console.log(res);
- });
- }
- $scope.pushFile = function(file) {
- // var file = $scope.myFiles;
- if (file.length > 0) {
- for (var i = 0; i < file.length; i++) {
- console.log(file[i].name);
- var flag = true;
- if ($scope.inquiryMould.sellAttachs.length > 0) {
- for (var j = 0; j < $scope.inquiryMould.sellAttachs.length; j++) {
- if ($scope.inquiryMould.sellAttachs[j].name == file[i].name
- && $scope.inquiryMould.sellAttachs[j].size == file[i].size) {
- flag = false;
- break;
- }
- }
- }
- if (flag) {
- uploadAttach(file[i]);
- }
- }
- }
- };
- $scope.removeFile = function(file) {
- if ($scope.inquiryMould.sellAttachs != null && $scope.inquiryMould.sellAttachs.length > 0) {
- for (var i = 0; i < $scope.inquiryMould.sellAttachs.length; i++) {
- if ($scope.inquiryMould.sellAttachs[i].name == file.name
- && $scope.inquiryMould.sellAttachs[i].size == file.size) {
- $scope.inquiryMould.sellAttachs.splice(i, 1);
- document.getElementById("file").value = "";
- }
- }
- }
- };
- $scope.onReplyClick = function (mould, withSteps) {
- $scope.loading = true;
- if (withSteps) {
- PurcInquiryMould.reply({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- loadData();
- $scope.canSave = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '报价失败', response.data);
- });
- PurcInquiryMould.saveHistory({id: mould.id}, mould, function () {
- }, function (response) {
- });
- } else {
- PurcInquiryMould.saveItem({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- }]);
- // 主动报价 - 列表
- app.controller('SaleQuotationListCtrl', ['$scope', '$filter', 'Quotation', 'PurcInquiry', 'ngTableParams', 'toaster', 'BaseService', '$rootScope', 'QuotationInfo', 'CurrentRole', function ($scope, $filter, Quotation, PurcInquiry, ngTableParams, toaster, BaseService, $rootScope, QuotationInfo, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $rootScope.enteryStatus = false;
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? Quotation : QuotationInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- bool = (i > 0 ? r.lapQty : 1) && r.price;
- });
- return bool;
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- Quotation.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/quotation/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // Controller 主动报价 - 新增
- app.controller('SaleQuotationNewCtrl', ['$scope', '$stateParams', '$filter', 'ngTableParams', 'toaster', 'BaseService', '$modal', 'Quotation', 'VendorInfo', '$rootScope', 'CurrentRole', function ($scope, $stateParams, $filter, ngTableParams, toaster, BaseService, $modal, Quotation, VendorInfo, $rootScope, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var staticItem = null;
- if (!angular.isUndefined($stateParams.id)) {// 查看模式
- $scope.loading = true;
- $rootScope.enteryStatus = true;
- Quotation.getItem({id: $stateParams.id}, function (data) {
- // data.$editing = false;
- $scope.item = data;
- $scope.item.$editing = true; // 取消要点击修改才可以编辑的交互
- staticItem = angular.copy(data);
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- } else {// 新增模式
- $rootScope.enteryStatus = false;
- $scope.item = {
- quotation: {
- currency: 'RMB',
- taxrate: 17,
- },
- product: {},
- prices: [{lapQty: 0}],
- minOrderQty: 1,
- minPackQty: 1,
- $endDateOpen: false,
- $editing: true
- };
- }
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- //是否不能被点击
- $scope.isDisabled = function () {
- return $scope.item.quotation.status == 101 && $scope.item.agreed == null;
- }
- $scope.openDatePicker = function ($event, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.item.$endDateOpen = !openParam;
- };
- // 增加一个分段
- $scope.addPrice = function () {
- if ($scope.item.prices.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- $scope.item.prices.push({});
- };
- // 删除一个分段
- $scope.removePrice = function (index) {
- $scope.item.prices.splice(index, 1);
- };
- // 查找客户
- $scope.dbfindCust = function () {
- if ($scope.item.$editing) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/quotation_new_cust.html',
- controller: 'DbfindCustCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.item.quotation.cust = data.myEnterprise;
- $scope.item.quotation.custUser = data.myUser;
- $scope.item.product = null;
- }, function () {
- });
- }
- };
- // 赋值客户信息
- if ($rootScope.custuu) {
- VendorInfo.customerInfo({custuu: $rootScope.custuu}, {}, function (data) {
- $scope.item.quotation.cust = data.myEnterprise;
- $scope.item.quotation.custUser = data.myUser;
- })
- }
- // 赋值物料信息
- if ($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function (data) {
- $scope.item.product.code = data.code;
- $scope.item.product.title = data.title;
- $scope.item.product.spec = data.spec;
- $scope.item.product.unit = data.unit;
- $scope.item.product.id = data.id;
- }, function (response) {
- });
- }
- // 查找客户物料
- $scope.dbfindCustProd = function () {
- if ($scope.item.$editing) {
- if ($scope.item.quotation.cust) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/quotation_new_custProd.html',
- controller: 'DbfindCustProdCtrl',
- size: 'lg',
- resolve: {
- custUU: function () {
- return $scope.item.quotation.cust.uu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.item.product = data;
- }, function () {
- });
- } else {
- toaster.pop('error', '错误', '请先选择客户');
- }
- }
- };
- // 根据传入的询价相关的信息封装成报价需要的信息
- if ($stateParams.inquiryItem != null) {
- var item = $stateParams.inquiryItem;
- $scope.item.quotation.cust = item.inquiry.enterprise;
- $scope.item.quotation.custUser = item.inquiry.recorderUser;
- $scope.item.quotation.custUserUU = item.inquiry.recorderUU;
- if (item.product == null || item.product.id == null) {
- toaster.pop('info', '暂未匹配到物料信息,请手动选择');
- } else {
- $scope.item.product = item.product;
- if (item.replies.length > 0) {
- $scope.item.prices = item.replies;
- angular.forEach($scope.item.prices, function(price) {
- price.id = null;
- });
- }
- $scope.item.quotation.taxrate = item.taxrate;
- $scope.item.minPackQty = item.minPackQty;
- $scope.item.minOrderQty = item.minOrderQty;
- $scope.item.leadtime = item.leadtime;
- $scope.item.quotation.currency = item.currency;
- }
- }
- // 保存
- $scope.save = function () {
- var valid = true;
- angular.forEach($scope.item.prices, function(price, $index) {
- if ($index > 0 && price.lapQty <= $scope.item.prices[$index - 1].lapQty) {
- valid = false;
- }
- });
- if (!valid) {
- toaster.pop('info', '提示', '分段数量请保持递增!');
- } else {
- $scope.loading = true;
- if (!$scope.item.quotation.code) //新增,设单号
- $scope.item.quotation.code = 'BJ' + $filter('date')(new Date(), 'yyMMddHHmmss_sss');
- $scope.item.quotation.custUU = $scope.item.quotation.cust.uu;
- if ($scope.item.quotation.custUserUU == null) {
- $scope.item.quotation.custUserUU = $scope.item.quotation.custUser.userUU;
- }
- $scope.item.productId = $scope.item.product.id;
- Quotation.save({}, $scope.item, function (data) {
- $scope.loading = false;
- $scope.item = data;
- toaster.pop('success', '成功', '保存成功');
- if ($stateParams.id)
- window.location.reload();
- else
- window.location.hash = '#/sale/quotation/list';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- // 更新
- $scope.update = function () {
- $scope.item.$editing = true;
- };
- // 取消
- $scope.cancel = function () {
- $scope.item.$editing = false;
- $scope.item = angular.copy(staticItem);
- };
- // 提交
- $scope.submit = function () {
- var valid = true;
- angular.forEach($scope.item.prices, function(price, $index) {
- if ($index > 0 && price.lapQty <= $scope.item.prices[$index - 1].lapQty) {
- valid = false;
- }
- });
- if (!valid) {
- toaster.pop('info', '提示', '分段数量请保持递增!');
- } else {
- $scope.loading = true;
- if (!$scope.item.quotation.code) //新增,设单号
- $scope.item.quotation.code = 'BJ' + $filter('date')(new Date(), 'yyMMddHHmmss_sss');
- $scope.item.quotation.custUU = $scope.item.quotation.cust.uu;
- if ($scope.item.quotation.custUserUU == null) {
- $scope.item.quotation.custUserUU = $scope.item.quotation.custUser.userUU;
- }
- $scope.item.productId = $scope.item.product.id;
- // $scope.item.quotation.status = 101;//已提交
- if ($scope.item.quotation.date instanceof Date) {
- $scope.item.quotation.date = $scope.item.quotation.date.getTime();
- }
- if ($scope.item.quotation.endDate instanceof Date) {
- $scope.item.quotation.endDate = $scope.item.quotation.endDate.getTime();
- }
- Quotation.submit({}, $scope.item, function (data) {
- $scope.loading = false;
- $scope.item = data;
- toaster.pop('success', '成功', '提交成功');
- // window.location.hash = '#/sale/quotation/' + data.id;
- window.location.hash = '#/sale/quotation/list';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- $scope.deleteById = function (id) {
- Quotation.deleteById({id: id}, {}, function (data) {
- window.location.href = "#/sale/quotation/list";
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- // 查找客户
- app.controller('DbfindCustCtrl', ['$scope', 'Customer', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function ($scope, Customer, BaseService, ngTableParams, toaster, $modalInstance) {
- BaseService.scrollBackToTop();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Customer.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.check = function (cust) {
- $modalInstance.close(cust);
- };
- }]);
- // 查找客户物料
- app.controller('DbfindCustProdCtrl', ['$scope', 'Product', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'custUU', function ($scope, Product, BaseService, ngTableParams, toaster, $modalInstance, custUU) {
- BaseService.scrollBackToTop();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.custUU = custUU;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 选择
- $scope.check = function (cust) {
- $modalInstance.close(cust);
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 查找供应商
- app.controller('DbfindVendorCtrl', ['$scope', 'Vendor', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', '$rootScope', function ($scope, Vendor, BaseService, ngTableParams, toaster, $modalInstance, $rootScope) {
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [10, 25, 50, 100],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // 添加供应商时,将已存在的选中
- if ($rootScope.tenderVendor) {
- angular.forEach(page.content, function (vendor) {
- for (var i = 0; i < $rootScope.tenderVendor.length; i++) {
- vendor.checked = false;
- if (vendor.vendorEnterprise.enName == $rootScope.tenderVendor[i].enName) {
- vendor.checked = true;
- break;
- }
- }
- });
- }
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.checks = {
- checked: false
- };// 全选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (vendor) {
- vendor.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function (vendor) {
- vendor.checked = true;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- // 单反选
- $scope.unCheckOne = function (vendor) {
- vendor.checked = false;
- $scope.checks.checked = false;
- };
- $scope.close = function () {
- var vendors = [];
- angular.forEach($scope.tableParams.data, function (vendor) {
- if (vendor.checked) {
- vendors.push(vendor);
- $modalInstance.close(vendors);
- }
- });
- };
- }]);
- // 发货提醒
- app.controller('SaleNoticeCtrl', ['$scope', '$rootScope', '$filter', 'PurcNotice', 'ngTableParams', 'toaster', 'BaseService', '$modal', 'SaleTruck', 'Symbol', '$state', '$timeout', 'PurcNoticeInfo', 'token', 'CurrentRole', function ($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, $modal, SaleTruck, Symbol, $state, $timeout, PurcNoticeInfo, token, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- // 用来记录已经选择的id
- $rootScope.ids = [];
- $scope.active = 'todo';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 6};
- $scope.searchStatus = false;
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 6);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- if ($scope.searchStatus) {
- return PurcNotice;
- }
- return PurcNoticeInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- $scope.checkall = true;
- angular.forEach(page.content, function (notice) {
- if ($rootScope.ids.indexOf(notice.id) > -1) {
- notice.$selected = true;
- } else {
- $scope.checkall = false;
- }
- });
- $scope.checkboxes = {
- checked: $scope.checkall
- };
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcNotice.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcNotice.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcNotice.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcNotice.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- //生成随机单号
- $scope.autoCode = function (notice) {
- notice.send.code = $filter('date')(new Date(), 'yyMMddHHmmss-sss');
- };
-
- // 获取token信息 并打开询价模态框
- $scope.getToken = function() {
- token.info({userType: 'salenotice'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- //可送货日期
- $scope.sendDate = function (notice) {
- var stock = notice.orderItem.product.ltinstock || 0;
- var de = new Date(notice.delivery);
- if (stock == -1) {
- de.setMonth(de.getMonth() - 1);
- de.setDate(26);
- } else if (stock >= 0) {
- de.setDate(de.getDate() - stock - 1);
- }
- return de;
- };
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function (notice) {
- if (!notice.send || !notice.send.qty || notice.send.qty > notice.qty - (notice.endQty || 0)) {
-
- } else if (!notice.send.code) {
-
- } else {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- };
- var isSumbit = false;
- $scope.onReplyClick = function (notice) {
- if (!notice.send || !notice.send.qty || notice.send.qty > notice.qty - (notice.endQty || 0)) {
- toaster.pop('warning', '警告', '数量填写错误!');
- } else if (!notice.send.code) {
- toaster.pop('warning', '警告', '请填写发货单号!');
- } else {
- if (!isSumbit) {
- var send = {
- code: notice.send.code,
- remark: notice.send.remark,
- sendItems: [{qty: notice.send.qty}]
- };
- $scope.loading = true;
- PurcNotice.save({id: notice.id, token: $scope.token}, send, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + notice.send.code);
- $state.go('sale.send_detail', {id: data.id});
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '发货失败', response.data);
- });
- isSumbit = true;
- return true;
- } else {
- toaster.pop('error', '提示', '为防止重复发货,请刷新页面后重新填写');
- return false;
- }
- }
- }
- $scope.checkboxes = {
- checked: false
- };
- angular.forEach($scope.tableParams.data, function (item) {
- $scope.checkboxes.checked = false;
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- $scope.checkboxes.checked = true;
- }
- });
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- if (!item.waiting) {
- item.$selected = $scope.checkboxes.checked;
- if(item.$selected) {
- if(!$rootScope.ids.in_array(item.id)) {
- $rootScope.ids.push(item.id);
- }
- } else {
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- }
- }
- }
- });
- };
- // 判断数组中是否存在某个对象
- Array.prototype.S = String.fromCharCode(2);
- Array.prototype.in_array = function(e) {
- var r = new RegExp(this.S + e + this.S);
- return (r.test(this.S + this.join(this.S) + this.S));
- }
- // 从数组中移除某个对象
- Array.prototype.remove = function(val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (order) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- if(order.$selected) {
- if(!$rootScope.ids.in_array(order.id)) {
- $rootScope.ids.push(order.id);
- }
- } else {
- if($rootScope.ids.in_array(order.id)) {
- $rootScope.ids.remove(order.id);
- }
- }
- $scope.checkboxes = {
- checked: result
- };
- };
- // 打开批量发货模态框
- var sendByBatch = function() {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sendByBatch.html',
- controller: 'SaleNoticeSendByBatchCtrl',
- size: 'lg',
- resolve: {
- selectedNotices: function () {
- return $scope.tableParams.data;
- },
- token: function() {
- return $scope.token;
- },
- ids: function() {
- return $rootScope.ids;
- }
- }
- });
- modalInstance.result.then(function () {
- $scope.tableParams.reload();
- }, function () {
- });
- }
- $scope.sendByBatch = function () {
- if($scope.token == null) {
- token.info({userType: 'salenotice'}, {}, function(data) {
- $scope.token = data.token;
- sendByBatch();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- } else {
- sendByBatch();
- }
- };
- $scope.getSends = function (notice) {
- if (!notice.sends && notice.endQty > 0) {
- notice.getSendsing = true;
- notice.getSendsError = false;
- PurcNotice.getSends({id: notice.id}, function (data) {
- notice.getSendsing = false;
- notice.getSendsError = false;
- notice.sends = data;
- }, function (response) {
- notice.getSendsing = false;
- notice.getSendsError = true;
- notice.getErrorMessage = response.data;
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.searchStatus = true;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //货车功能
- var truck = $rootScope.truck;
- if (!truck) {
- SaleTruck.query({}, function (data) {
- $rootScope.truck = data;
- });
- }
- $scope.isInTruck = function (noticeId) {
- return truck.indexOf(noticeId) > -1;
- };
- $scope.addtoTruck = function (notice) {
- SaleTruck.save({noticeId: notice.id}, {}, function (data) {
- $rootScope.truck = data;
- });
- };
- $scope.delFromTruck = function (notice) {
- SaleTruck.remove({noticeId: notice.id}, {}, function (data) {
- $rootScope.truck = data;
- });
- };
- $scope.$watch(function () {
- return $rootScope.truck;
- }, function (data) {
- truck = $rootScope.truck;
- }, true);
- $scope.$watch(function () {
- return $rootScope.dataChanged;
- }, function (data) {
- data && ($scope.tableParams.reload());
- }, true);
- // 导出
- $scope.exportXls = function () {
- PurcNotice.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/notice/xls?_state='+$scope.active+
- '&keyword='+($scope.keywordXls || '')+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('SaleNoticeSendByBatchCtrl', ['$scope', '$modalInstance', 'Symbol', 'selectedNotices', 'PurcNotice', 'toaster', '$state', '$timeout', 'token', 'ids', '$rootScope', function ($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster, $state, $timeout, token, ids, $rootScope) {
- // $scope.notices = angular.copy(selectedNotices);
- PurcNotice.findByIds({ids : angular.toJson(ids)}, function(data) {
- $scope.notices = angular.copy(data);
- }, function(res) {
- toaster.pop('error', '提示', '发货提醒查询失败');
- });
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.saleSend = {
- code: '',
- payments: '',
- currency: '',
- custUU: null,
- custUserUU: null,
- remark: '批量发货',
- sendItems: []
- };
- // 计算总数、总额
- $scope.$watch(function () {
- return $scope.notices;
- }, function (data) {
- var q = 0, t = 0;
- if (data) {
- angular.forEach(data, function (d) {
- q += (d.thisSendQty || 0);
- t += (d.thisSendQty || 0) * (d.orderItem.price || 0);
- });
- }
- $scope.totalQty = q;
- $scope.total = t;
- }, true);
- /**
- * 删除一个已选中的送货提醒
- */
- $scope.removeOne = function (index) {
- $scope.notices.splice(index, 1);
- };
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function () {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function (notice) {
- if ($scope.saleSend.code == '') {//送货单号为空
- return;
- } else {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- };
- var isSumbit = false;
- //确认送货
- $scope.sendByBatch = function () {
- $scope.saleSend.sendItems = [];
- if ($scope.saleSend.code == '') {//送货单号为空
- toaster.pop('error', '错误', '请输入送货单号');
- return;
- }
- var a = 0;
- var num = 1;
- var valid = true;
- angular.forEach($scope.notices, function (item, key) {
- if (a == 0) {//第一次
- $scope.saleSend.currency = item.orderItem.order.currency;
- $scope.saleSend.custUU = item.enUU;
- $scope.saleSend.payments = item.orderItem.order.payments;
- a = 1;
- } else {//其他
- if ($scope.saleSend.currency != item.orderItem.order.currency) valid = false;
- if ($scope.saleSend.custUU != item.enUU) valid = false;
- if ($scope.saleSend.payments != item.orderItem.order.payments) valid = false;
- }
- $scope.saleSend.sendItems.push({
- noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price, number: num++
- });
- });
- if (!valid) {
- toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致才能一起发货。');
- } else {
- if (!isSumbit) {
- PurcNotice.sendByBatch({token: token}, $scope.saleSend, function (data) {
- if(data.id) {
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + $scope.saleSend.code);
- $modalInstance.close('success');
- $state.go('sale.send_detail', {id: data.id});
- } else {
- toaster.pop('error', '提示', '发货失败,请刷新页面重试');
- }
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- isSumbit = true;
- return true;
- } else {
- toaster.pop('error', '提示', '为防止重复发货,请刷新页面后重新填写');
- return false;
- }
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 发货单
- */
- app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'ReportService', function ($scope, $filter, SaleSend, ngTableParams, toaster, BaseService, Symbol, ReportService) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return SaleSend;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //打印 发货单
- $scope.print = function (send) {
- var newPage = window.open("about:blank");
- SaleSend.printPermission({}, function () {
- SaleSend.printCount({id: send.id}, {}); //增加打印此次
- ReportService.print(send.custUU, 'SALESEND', "where sale$send.ss_id=" + send.id, newPage);
- $scope.tableParams.reload();
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.exportXls = function () {
- SaleSend.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/notice/sends/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || '')+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 发货单(包括发货条码维护)
- */
- app.controller('SaleSendDetailCtrl', ['$scope', '$stateParams', 'SaleSend', 'toaster', 'ReportService', 'ngTableParams', 'Lodop', '$modal', 'CurrentRole', function ($scope, $stateParams, SaleSend, toaster, ReportService, ngTableParams, Lodop, $modal, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loading = true;
- $scope.checkBarCode = [];
- $scope.checkBoxCode = [];
- var vm = $scope.vm = {};
- $scope.getCheckedItems = {};
- vm.editBar = false;
- vm.showBarCode = [];
- $scope.barCode = function () {
- vm.editBar = !vm.editBar;
- }
- $scope.checkboxes = {
- checked: false
- };
- $scope.checkbars = {
- checked: false
- };
- // 点击勾选barCode全部的复选框
- $scope.checkBarAll = function () {
- angular.forEach($scope.checkBarCode, function (item, key) {
- $scope.checkBarCode[key] = $scope.checkbars.checked;
- });
- };
- //点击barCode单选
- $scope.checkBarOne = function () {
- var result = true;
- angular.forEach($scope.checkBarCode, function (item, key) {
- if (item != true) {
- result = false;
- return;
- }
- });
- $scope.checkbars.checked = result;
- }
- // 点击boxCode全部的复选框
- $scope.checkBoxAll = function () {
- angular.forEach($scope.checkBoxCode, function (item, key) {
- $scope.checkBoxCode[key] = $scope.checkboxes.checked;
- });
- };
- //点击boxCode单选
- $scope.checkBoxOne = function () {
- var result = true;
- angular.forEach($scope.checkBoxCode, function (item) {
- if (item != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- }
- /**
- * 生成条码和箱号
- */
- $scope.generateBarCode = function (item) {
- //获取勾选了生成条码的明细行,只勾选生成箱号的明细行不会生成条码和箱号
- $scope.getCheckedItems = [];
- var warningdata = '';
- angular.forEach($scope.checkBarCode, function (item, key) {
- $scope.getCheckedItem = {};
- if (item == true) {
- $scope.getCheckedItem.id = $scope.order.sendItems[key].id;
- $scope.getCheckedItem.isOutboxChecked = $scope.checkBoxCode[key];
- $scope.getCheckedItems.push($scope.getCheckedItem);
- //判断是否生成过条码
- if ($scope.order.sendItems[key].barSendNotify.length > 0) {
- warningdata += $scope.order.sendItems[key].number + ","
- }
- }
- });
- if ($scope.getCheckedItems.length == 0) {
- toaster.pop('warning', '提示', '请勾选需要生成条码的明细行!');
- return;
- }
- if (warningdata != '') {
- if (!confirm('明细行序号:' + warningdata + "已经生成了条码,继续生成将清空原有条码?")) {
- return;
- }
- }
- SaleSend.generateBarcodes({id: $scope.order.id}, angular.fromJson($scope.getCheckedItems), function (data) {
- toaster.pop('success', '提示', '生成成功!');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '生成失败', response.data);
- });
- }
- /**
- * 打印条码和箱号
- */
- $scope.printCode = function (type) {
- var LODOP = Lodop.getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
- //勾选需要打印的行
- $scope.getCheckedItems = [];
- var warningdata = ''
- angular.forEach($scope.checkBarCode, function (item, key) {
- $scope.getCheckedItem = {};
- if (item == true) {
- $scope.getCheckedItem.id = $scope.order.sendItems[key].id;
- $scope.getCheckedItems.push($scope.getCheckedItem);
- //判断是否生成过条码
- if ($scope.order.sendItems[key].barSendNotify.length > 0) {
- warningdata += $scope.order.sendItems[key].number + ","
- }
- }
- });
- if ($scope.getCheckedItems.length == 0) {
- toaster.pop('warning', '提示', '请勾选需要打印的明细行!');
- return;
- }
- if (warningdata == '') {
- toaster.pop('warning', '提示', '明细行序号:' + warningdata + '未生成条码无法打印');
- return;
- }
- //选择打印模板
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/bar_print_template.html',
- controller: 'BarPrintModalCtrl',
- resolve: {
- typeItem: function () {
- return {'type': type, 'id': $scope.order.id};
- }
- }
- });
- modalInstance.result.then(function (s) {
- if (s) {
- //获取打印数据
- SaleSend.getPrintBarcodes({lpsId: s.tp_id}, angular.fromJson($scope.getCheckedItems), function (data) {
- if (s.type == 'print') {//判断选择是打印还是打印预览
- lodopPrint(data.message, LODOP, type);
- } else if (s.type == 'printPreview') {
- lodopPrintPreview(data.message, LODOP, type);
- }
- }, function (response) {
- toaster.pop('error', '获取打印数据失败', response.data);
- });
- }
- });
- };
- //打印单个条码
- $scope.printSingleCode = function (id) {
- var LODOP = Lodop.getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
- //选择打印模板
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/bar_print_template.html',
- controller: 'BarPrintModalCtrl',
- resolve: {
- typeItem: function () {
- return {'type': 'Bar', 'id': $scope.order.id};
- }
- }
- });
- modalInstance.result.then(function (s) {
- if (s) {
- //获取打印数据
- SaleSend.getSPrintBarcode({lpsId: s.tp_id, bsnId: id}, function (data) {
- if (s.type == 'print') {//判断选择是打印还是打印预览
- lodopSPrint(data.message, LODOP);
- } else if (s.type == 'printPreview') {
- lodopSPrintPreview(data.message, LODOP);
- }
- }, function (response) {
- toaster.pop('error', '获取打印数据失败', response.data);
- });
- }
- });
- }
- var lodopSPrint = function (printStore, LODOP) {//单个条码打印
- var selectOrNot = LODOP.SELECT_PRINTER();//选择打印机,未-1就是取消,如果是其他数字就是设置打印机序号
- if (selectOrNot != -1) {
- LODOP.PRINT_INIT("标签打印");//设定纸张大小
- var pagesize = printStore[0]['LA_PAGESIZE'];//获取标签的大小
- var strs = pagesize.split("*"); //字符分割
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- angular.forEach(printStore, function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- //“ShowBarText” :(一维)条码的码值是否显示 0/1
- //“AlignJustify”:设置“text文本”是否两端对齐或“barcode条码文字”靠齐方式
- //设置“barcode条码文字”时,0-两端对齐(默认) 1-左靠齐 2-居中 3-右靠齐
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- LODOP.SET_PRINT_STYLEA(0, "NotOnlyHighPrecision", true);//设置打印的精度
- LODOP.PRINT();
- }
- };
- var lodopSPrintPreview = function (printStore, LODOP) {//单个条码打印预览
- LODOP.PRINT_INIT("标签打印");//设定纸张大小
- var pagesize = printStore[0]['LA_PAGESIZE'];//获取标签的大小
- var strs = pagesize.split("*"); //字符分割
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- angular.forEach(printStore, function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, "");
- LODOP.SET_SHOW_MODE("HIDE_SBUTTIN_PREVIEW", 1);
- LODOP.PREVIEW();//打印预览
- };
- var lodopPrint = function (printStore, LODOP, type) {//勾选发货单明细进行打印
- var selectOrNot = LODOP.SELECT_PRINTER();//选择打印机,未-1就是取消,如果是其他数字就是设置打印机序号
- if (selectOrNot != -1) {
- LODOP.PRINT_INIT("标签打印");//设定纸张大小
- var pagesize = printStore[0]['pagesize'];//获取标签的大小
- var strs = new Array(); //定义一数组
- strs = pagesize.split("*"); //字符分割
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- var ids = new Array();
- angular.forEach(printStore, function (value, key) {
- //LODOP.NewPage();
- angular.forEach(value['data'], function (record, key) {
- angular.forEach(record['store'], function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- //“ShowBarText” :(一维)条码的码值是否显示 0/1
- //“AlignJustify”:设置“text文本”是否两端对齐或“barcode条码文字”靠齐方式
- //设置“barcode条码文字”时,0-两端对齐(默认) 1-左靠齐 2-居中 3-右靠齐
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- });
- var o = new Object();
- o['id'] = record['si_id']
- ids.push(o);
- LODOP.SET_PRINT_STYLEA(0, "NotOnlyHighPrecision", true);//设置打印的精度
- LODOP.PRINT();
- });
- //如果打印的是条码则更新打印状态,如果是箱号则不不要打印
- if (type == 'Bar') {
- //更新打印状态
- SaleSend.updatePrintStatus({}, ids, function (data) {
- }, function (res) {
- });
- }
- }
- };
- var lodopPrintPreview = function (printData, LODOP, type) {//打印预览
- var ids = new Array();
- angular.forEach(printData, function (record, index) {
- angular.forEach(record['data'], function (value, index) {
- LODOP.NewPage();
- angular.forEach(value['store'], function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- });
- var o = new Object();
- o['id'] = record['si_id']
- ids.push(o);
- });
- var pagesize = printData[0]['pagesize'];//获取标签的大小
- var strs = new Array(); //定义一数组
- strs = pagesize.split("*"); //字符分割
- LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, "");
- LODOP.SET_SHOW_MODE("HIDE_SBUTTIN_PREVIEW", 1);
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- var times = LODOP.PREVIEW();//打印预览
- if (times > 0) {//点击了打印预览内的打印按钮
- //如果打印的是条码则更新打印状态,如果是箱号则不不要打印
- if (type == 'Bar') {
- //更新打印状态
- SaleSend.updatePrintStatus({}, ids, function (data) {
- loadData();
- }, function (res) {
- });
- }
- }
- };
- /**
- * 查看条码按钮
- */
- $scope.showBarCode = function (number) {
- $scope.keys = number;
- for (var i = 0; i < vm.showBarCode.length; i++) {
- if (i != number) {
- vm.showBarCode[i] = false;
- }
- }
- vm.showBarCode[number] = !vm.showBarCode[number];
- $scope.barcodes = [];
- $scope.barcodes = $scope.order.sendItems[number].barSendNotify;
- var getPage = function (page, size) {
- if ($scope.barcodes) {
- var result = {};
- result.totalCount = $scope.barcodes.length;
- result.content = $scope.barcodes.slice((page - 1) * size, page * size);
- if ($scope.barcodes.length % size == 0) {
- result.totalPage = ($scope.barcodes.length - $scope.barcodes.length % size) / size;
- } else {
- result.totalPage = ($scope.barcodes.length - $scope.barcodes.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.barData = getPage(1, 5);
- $scope.first = function () {
- $scope.barData = getPage($scope.barData.pre, 5);
- }
- $scope.last = function () {
- $scope.barData = getPage($scope.barData.next, 5);
- }
- };
- /**
- * 更新外箱号
- */
- $scope.updateOutBox = function (item, number) {
- if ($scope.oldoutBoxQty[number] == item.outBoxQty) {
- } else {
- if (item.outBoxQty > 0) {
- if (!(item.outBoxQty % item.packageQty)) {
- SaleSend.update({id: item.id}, item, function () {
- toaster.pop('success', '提示', '保存成功!');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- })
- } else {
- toaster.pop('warning', '提示', '请输入最小包数的整数倍!(' + item.packageQty + '的整数倍)');
- }
- } else {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- }
- }
- loadData();
- };
- /**
- * 更新最小包数
- */
- $scope.updatePackage = function (item, number) {
- if (item.packageQty == $scope.oldpackageQty[number]) {
- } else {
- if (item.orderItem.product.minPack != 0) {
- if (item.packageQty > 0 && item.packageQty <= item.qty) {
- if (!(item.packageQty % item.orderItem.product.minPack)) {
- SaleSend.update({id: item.id}, item, function () {
- toaster.pop('success', '提示', '保存成功!');
- if (item.outBoxQty && item.outBoxQty % item.packageQty) {
- toaster.pop('warning', '提示', '外箱容量必须是最小包数的整数倍,请及时修改(' + item.packageQty + '的整数倍)');
- }
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- })
- } else {
- toaster.pop('warning', '提示', '请输入最小物料包装的整数倍!(' + item.orderItem.product.minPack + '的整数倍)');
- }
- } else {
- toaster.pop('warning', '提示', '请填写有效的数量!');
- }
- } else {
- if (item.packageQty > 0 && item.packageQty <= item.qty) {
- SaleSend.update({id: item.id}, item, function () {
- toaster.pop('success', '提示', '保存成功!');
- if (item.outBoxQty && item.outBoxQty % item.packageQty) {
- toaster.pop('warning', '提示', '外箱容量必须是最小包数的整数倍,请及时修改(' + item.packageQty + '的整数倍)');
- }
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- })
- } else {
- toaster.pop('warning', '提示', '请填写有效的数量!');
- }
- }
- }
- loadData();
- };
- var loadData = function () {
- SaleSend.getItem({id: $stateParams.id}, function (data) {
- $scope.order = data;
- var orderCount = $scope.order.sendItems.length;
- $scope.oldpackageQty = [];
- $scope.oldoutBoxQty = [];
- var sum = 0;
- vm.oldpackageQty = [];
- angular.forEach(data.sendItems, function (value, key) {
- //给showBarCode数组赋初值
- if (vm.showBarCode.length < orderCount) {
- vm.showBarCode.push(false);
- }
- if ($scope.checkBarCode.length < orderCount) {
- $scope.checkBarCode.push(false);
- }
- if ($scope.checkBoxCode.length < orderCount) {
- $scope.checkBoxCode.push(false);
- }
- //给个初值
- if (!value.packageQty) {
- value.packageQty = value.orderItem.product.minPack;
- }
- $scope.oldpackageQty.push(value.packageQty);
- if (value.outBoxQty) {
- $scope.oldoutBoxQty.push(value.outBoxQty);
- }
- sum += value.price * value.qty;
- });
- data.total = sum;
- $scope.loading = false;
- }, function (response) {
- loading = false;
- toaster.pop('error', '获取数据失败', response.data);
- });
- };
- loadData();
- }]);
- app.controller('BarPrintModalCtrl', ['$scope', 'typeItem', 'SaleSend', 'toaster', '$modalInstance', function ($scope, typeItem, SaleSend, toaster, $modalInstance) {
- $scope.typeItem = typeItem;
- $scope.template = [];
- $scope.choose = {};
- //获取打印模板
- SaleSend.getPrintTemplate({id: $scope.typeItem.id, type: $scope.typeItem.type}, function (data) {
- if (data.message) {
- $scope.template = data.message;
- $scope.choose.tp_id = $scope.template[0].id;
- }
- }, function (res) {
- toaster.pop('error', '获取模板错误', res.data);
- });
- $scope.print = function () {
- $scope.choose.type = 'print';
- $modalInstance.close($scope.choose);
- };
- $scope.printPreview = function () {
- $scope.choose.type = 'printPreview';
- $modalInstance.close($scope.choose);
- }
- $scope.cancel = function () {
- $modalInstance.close();
- }
- }]);
- app.controller('SaleSampleDetailCtrl', ['$scope', '$stateParams', 'PurcSample', 'toaster', '$modal', 'BaseService', 'CurrentRole', function ($scope, $stateParams, PurcSample, toaster, $modal, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loading = true;
- var loadData = function () {
- PurcSample.getItem({id: $stateParams.id}, function (data) {
- $scope.sample = data;
- if (!$scope.sample.sends) {
- $scope.sample.getSendInfo = '加载中...';
- PurcSample.getSend({id: $stateParams.id}, function (sendData) {
- if (sendData) {
- $scope.sample.getSendInfo = null;
- $scope.sample.sends = sendData;
- } else {
- $scope.sample.getSendInfo = '无送样信息';
- $scope.sample.sends = '无送样信息';
- }
- }, function (response) {
- $scope.sample.getSendInfo = '加载失败!';
- toaster.pop('error', '', response.data);
- });
- }
- $scope.loading = false;
- }, function (response) {
- loading = false;
- toaster.pop('error', '获取数据失败', response.data);
- });
- };
- loadData();
- $scope.openSend = function (index, sample) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sample_send.html',
- controller: 'SampleSendCtrl',
- resolve: {
- sampleItem: function () {
- return sample;
- }
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('info', '提示', '送样成功');
- $scope.tableParams.reload();
- }, function () {
- });
- };
- }]);
- /**
- * 客户打样申请
- */
- app.controller('SaleSampleCtrl', ['$scope', '$filter', 'PurcSample', 'ngTableParams', 'toaster', '$modal', 'BaseService', 'ReportService', 'Symbol', '$rootScope', 'PurcSampleInfo', 'CurrentRole', function ($scope, $filter, PurcSample, ngTableParams, toaster, $modal, BaseService, ReportService, Symbol, $rootScope, PurcSampleInfo, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /*初始化筛选时间*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcSample : PurcSampleInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- proofingDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- getUnreadCount();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcSample.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单个单据已读
- $scope.setOrdersRead = function (id) {
- if (!$scope.isUnread(id)) {
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcSample.setRead({}, sourceId, function (message) {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcSample.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.openSend = function (index, sample) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sample_send.html',
- controller: 'SampleSendCtrl',
- resolve: {
- sampleItem: function () {
- return sample;
- }
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('info', '提示', '送样成功');
- $scope.tableParams.reload();
- }, function () {
- });
- };
- //打印 样品采购单
- $scope.print = function (sample) {
- var newPage = window.open("about:blank");
- PurcSample.printPermission({}, function () {
- PurcSample.printCount({id: sample.id}, {});//增加打印此次
- ReportService.print(sample.proofing.enUU, 'PURCPROOFING', "where purc$proofingitems.ppi_id =" + sample.id, newPage);
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.getSend = function (proofing) {
- if (!proofing.sends) {
- proofing.getSendInfo = '加载中...';
- PurcSample.getSend({id: proofing.id}, function (data) {
- if (data) {
- proofing.getSendInfo = null;
- proofing.sends = data;
- } else {
- proofing.getSendInfo = '无送样信息';
- proofing.sends = '无送样信息';
- }
- }, function (response) {
- proofing.getSendInfo = '加载失败!';
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcSample.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/sample/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('SampleSendCtrl', ['$scope', '$modalInstance', 'sampleItem', 'PurcSample', '$upload', 'toaster', function ($scope, $modalInstance, sampleItem, PurcSample, $upload, toaster) {
- if (!sampleItem.sends) {
- PurcSample.getSend({id: sampleItem.id}, function (data) {
- if (data) {
- sampleItem.sends = data; // 获取送样信息
- angular.forEach(data, function (send) {
- sampleItem.sendQty = send.sendQty + (sampleItem.sendQty || 0);
- });
- }
- }, function (response) {
- });
- }
- $scope.sampleItem = sampleItem;
- $scope.sampleItem.sampleSend = $scope.sampleItem.sampleSend || {};
- //确认送样
- $scope.ok = function (form) {
- $scope.loading = true;
- // 多次送样时,由于ng-model是sendQty,所以需要加上送样历史中的数量
- $scope.sampleItem.sampleSend.sendQty = $scope.sampleItem.sampleSend.sendQty + ($scope.sampleItem.sendQty || 0);
- $scope.sampleItem.sendQty = $scope.sampleItem.sampleSend.sendQty; // 判断是否需要多次送样
- var files = form.attachFile.$viewValue, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'sale/sample/' + $scope.sampleItem.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.sampleItem.sampleSend
- }
- }).success(function (data) {
- $scope.loading = false;
- $modalInstance.close('success');
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '错误', data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss(sampleItem);
- };
- //设置单个单据已读
- $scope.setOrdersRead = function (id) {
- var sourceId = [];
- sourceId.push(id);
- PurcSample.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- });
- };
- }]);
- /**
- * 客户认定单
- */
- app.controller('SaleApprovalCtrl', ['$scope', '$filter', 'PurcApproval', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, PurcApproval, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcApproval;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- inDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcApproval.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/sample/approval/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户采购预测
- */
- app.controller('SaleForecastCtrl', ['$scope', '$filter', 'PurcForecast', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, PurcForecast, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcForecast;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- orderDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 客户采购验收
- */
- app.controller('SaleAcceptCtrl', ['$scope', '$filter', 'PurcAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcAccept, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcAccept;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcAccept.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/accept/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户采购验收详情
- */
- app.controller('SaleAcceptDetailCtrl', ['$scope', 'PurcAccept', 'toaster', 'BaseService', '$stateParams', 'CurrentRole', function ($scope, PurcAccept, toaster, BaseService, $stateParams, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($stateParams.id) {
- PurcAccept.getDetail({id: $stateParams.id}, {}, function (data) {
- $scope.accept = data;
- if ($scope.accept.acceptItems != null) {
- var sum = 0;
- angular.forEach($scope.accept.acceptItems, function (item) {
- if (item.orderPrice == null) {
- item.orderPrice = 0;
- }
- sum += item.orderPrice * item.qty;
- });
- $scope.totalPrice = sum;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 客户采购验退
- */
- app.controller('SaleReturnsCtrl', ['$scope', '$filter', 'PurcReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcReturn, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcReturn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- angular.forEach(page.content, function (data) {
- if (!data.returnItems[0].orderItem) {
- PurcReturn.getEnterpriseName({id: data.id, enuu: data.enUU}, function (enterprise) {
- data.enName = enterprise.enName;
- });
- }
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcReturn.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/return/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户采购验退详情
- */
- app.controller('SaleReturnsDetailCtrl', ['$scope', 'PurcReturn', 'toaster', 'BaseService', '$stateParams', 'CurrentRole', function ($scope, PurcReturn, toaster, BaseService, $stateParams, CurrentRole) {
- BaseService.scrollBackToTop();'' +
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($stateParams.id != null) {
- PurcReturn.getDetail({id: $stateParams.id}, {}, function (data) {
- $scope.returns = data;
- if ($scope.returns.returnItems != null) {
- var sum = 0;
- angular.forEach($scope.returns.returnItems, function (item) {
- if (null != item.orderPrice) {
- sum += item.orderPrice * item.qty;
- }
- });
- $scope.totalPrice = sum;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 客户不良品入库
- */
- app.controller('SaleBadInCtrl', ['$scope', '$filter', 'PurcBadIn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcBadIn, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcBadIn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcBadIn.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/badIn/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户不良品出库
- */
- app.controller('SaleBadOutCtrl', ['$scope', '$filter', 'PurcBadOut', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcBadOut, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcBadOut;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcBadOut.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/badOut/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户MRB
- */
- app.controller('SaleMRBCtrl', ['$scope', '$filter', 'PurcMRB', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, PurcMRB, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcMRB;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcMRB.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/MRB/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- //客户航天开票
- app.controller('PurchaseApBillOutCtrl',['$scope', 'FaApBillOut', 'BaseService', 'ngTableParams', 'toaster','ReportService', 'Symbol', function ($scope, FaApBillOut, BaseService, ngTableParams, toaster, ReportService , Symbol) {
- BaseService.scrollBackToTop();
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'all';
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0,0,0,0);
- toDate.setHours(23,59,59,999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- //打印 开票单
- $scope.print = function (billOut) {
- FaApBillOut.printCount({id: billOut.id},function (data) {
- if(!data.error) {
- toaster.pop('success', '提示', '打印成功');
- //$scope.tableParams.reload();
- }else{
- toaster.pop('error', '提示', '打印失败');
- }
- });
- //ReportService.print(billOut.custUu, 'PURCBILLOUT', 'where purc$apbillout.pabo_id =' + billOut.id);
- };
- //状态
- $scope.setActive = function (state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //获取全部已确定应收对账单
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- recordDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- FaApBillOut[getState($scope.active )](BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.data = $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]){
- $scope.tableParams.reload();
- }
- };
- // 计算开票数量
- $scope.getTotalProd = function (billOut) {
- var total = 0;
- if(billOut.items) {
- angular.forEach(billOut.items, function (value) {
- total += value.NowQty;
- });
- }
- return total;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- //开票单详情
- app.controller('PurchaseApBillOutDetailCtrl',['$scope', 'toaster', 'FaApBillOut', 'FaApCheck', '$stateParams', 'BaseService', function ($scope, toaster, FaApBillOut, FaApCheck, $stateParams, BaseService) {
- BaseService.scrollBackToTop();
- $scope.haveSelected = true;
- $scope.data = {};
- //控制提交和删除按钮的显示
- $scope.ifShow = true;
- var loadData = function () {
- FaApBillOut.get({id:$stateParams.id},function (data) {
- $scope.data = data;
- if($scope.data.status){
- }else{
- $scope.ifShow = true;
- }
- })
- };
- if($stateParams.id){
- loadData();
- }
- $scope.haveSource = false;
- //TODO 提交开票单
- $scope.invoiceIssued = function (apBillOut) {
- $scope.loading = true;
- FaApBillOut.invoiceIssued({id:apBillOut.id},function (data) {
- $scope.loading = false;
- if(data.apBillOut) {
- $scope.haveSelected = false;
- window.location.href = '#/fa/apBillOut';
- toaster.pop('success', '提示', '提交成功');
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- }
- })
- }
- //删除开票单(后台同时更新对账单明细表已开票数)
- $scope.deleteApBillOut = function () {
- FaApBillOut.deleteApBillOut({id:$stateParams.id},function (data) {
- window.location.href = '#/fa/apBillOut';
- toaster.pop('success','提示','删除成功');
- },function () {
- toaster.pop('error','提示','删除失败');
- });
- $scope.haveSelected = false;
- }
- //TODO 作废开票单
- $scope.InvoiceCancel = function () {
- $scope.loading = true;
- FaApBillOut.InvoiceCancel({id:$stateParams.id},function (data) {
- $scope.loading = false;
- if(!data.error) {
- toaster.pop('success', '提示', '作废成功');
- window.location.href = '#/fa/apBillOut';
- $scope.tableParams.reload();
- }else{
- toaster.pop('error', '提示', data.error);
- }
- },function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- //航天开票单据列表
- app.controller('PurchaseApBillOutListCtrl',['$scope', 'FaApCheck', 'FaApBillOut', 'toaster', '$state','$filter', '$modal', function ($scope, FaApCheck, FaApBillOut, toaster, $state, $filter, $modal) {
- $scope.data = [];// 列表数据
- $scope.condition = {
- $fromOpened: false
- }
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
- //查找客户
- $scope.searchCust = function (suuorname) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/fa/custInfo.html',
- controller: 'SearchCustInfoCtrl',
- resolve: {
- suuorname: function () {
- return suuorname;
- }
- }
- });
- modalInstance.result.then(function (suuorname) {
- $scope.suuorname = suuorname;
- });
- }
- // 点击筛选根据条件选择数据
- $scope.suuorname = '';
- // 默认本月
- $scope.sdateTo = new Date();
- $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
- $scope.vuuorname = '';
- $scope.factory = '';
- $scope.prodTitle = '';
- $scope.prodSpec = '';
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodTitle = '';
- $scope.condition.prodSpec = '';
- $scope.searchOrder = function (check) {
- $scope.data = [];
- $scope.checkboxes.checked = false;
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory;
- $scope.condition.prodTitle = $scope.prodTitle;
- $scope.condition.prodSpec = $scope.prodSpec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf()) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- if($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
- $scope.fromDate =$scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.keywordXls = angular.copy(($scope.condition.uuorname == null ? "" : $scope.condition.uuorname)
- + "|"+ ($scope.condition.venduuorname == null ? "" : $scope.condition.venduuorname)
- + "|"+ ($scope.condition.factory == null ? "" : $scope.condition.factory)
- + "|"+ ($scope.condition.prodTitle == null ? "" : $scope.condition.prodTitle)
- + "|"+ ($scope.condition.prodSpec == null ? "" : $scope.condition.prodSpec));//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if(!$scope.suuorname) {
- toaster.pop('warning','提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- $scope.loading = true;
- FaApBillOut.getDoneApCheckByKeywords({fromDate: $scope.fromDate, endDate: $scope.endDate, keyword:$scope.keywordXls}, function(data) {
- if(data.length > 0) {
- angular.forEach(data, function (checkItem) {
- checkItem.$selected = true;
- if(checkItem.billed) {
- checkItem.thisBilledQty = checkItem.checkQty - checkItem.billed;
- //$filter('number')(checkItem.thisBilledQty, 2);
- } else {
- checkItem.billed = 0;
- checkItem.thisBilledQty = checkItem.checkQty;
- }
- //最大最小开票数
- checkItem.maxThisBilledQty = checkItem.thisBilledQty;
- checkItem.minThisBilledQty = 0;
- });
- $scope.data = data;
- $scope.checkboxes.checked = true;
- $scope.getTotalMoney();
- } else {
- toaster.pop('info', '提示', '当前没有需要对账记录');
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- }
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.totalMoney = 0;
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- $scope.totalMoney = 0;
- $scope.filteredData = $filter('filter')($scope.data, $scope.condition.prodTitle || $scope.condition.uuorname || $scope.condition.venduuorname || $scope.condition.prodSpec || $scope.condition.factory);
- var uuorname = $scope.suuorname;
- var venduuorname = $scope.venduuorname;
- var dateFrom = $scope.condition.dateFrom;
- var dateTo = $scope.condition.dateTo;
- var prodTitle = $scope.condition.prodTitle;
- var prodSpec = $scope.condition.prodSpec;
- var factory = $scope.condition.factory;
- angular.forEach($scope.filteredData, function (item) {
- if((item.apCheck.apDate >= dateFrom || dateFrom == '') && (item.apCheck.apDate < dateTo || dateTo == '')){
- item.$selected = $scope.checkboxes.checked;
- }
- });
- $scope.getTotalMoney();
- };
- //获取已选单据总金额
- var total = true;
- $scope.getTotalMoney = function () {
- $scope.totalMoney = 0;
- angular.forEach($scope.data, function (check) {
- if(check.$selected){
- $scope.totalMoney += (check.CheckQty || 0)*(check.orderPrice || 0);
- }else{
- $scope.totalMoney += 0;
- }
- });
- }
- // 点击其中一个明细的复选框
- $scope.checkOne = function (check) {
- var result = true;
- angular.forEach($scope.data, function (item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.haveSelected = false;
- //生成开票单
- $scope.createApBillOut = function () {
- //保存应收对账单主记录字段
- $scope.apBillOut = {
- custUu: '',
- custName: '',
- beginDate: '',
- endDate: '',
- enUu: '',
- recordDate: '',
- checkStatus: '未开票',
- currency: '',
- rate: '',
- //billed:'',
- //apBillOutItemId:'',
- items: [],
- sourceInfos: []
- };
- //保存来源单据相关信息
- //var sourceInfos = [];
- //所允许的本次对账最大最小数量
- //$scope.data.maxThisCheckQty = 0;
- //$scope.data.minThisCheckQty = 0;
- $scope.sameCust = true;
- $scope.validQty = true;
- $scope.loading = true;
- angular.forEach($scope.data, function (checkItem) {
- //保存开票单明细行数据
- $scope.item = {
- inoutno: '',
- inoutnodetno: '',
- orderCode: '',
- orderClass: '',
- orderDetno: '',
- price: '',
- NowQty: '',
- //amount: '',
- sourceId:'',
- sourceTable:'',
- //oldYCheckQty:'',
- status: 0,
- //receiveCode:'',
- //receiveName:'',
- prodCode:'',
- //prodSpec:'',
- taxrate: '',
- //sendcode: '',
- //whname: '',
- };
- //开票单明细行来源表信息(新的已开票数)
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newBilledQty: 0
- };
- //本次开票新的开票数
- //$scope.thisBilledQty = 0;
- if(checkItem.$selected == true) {
- $scope.apBillOut.custName = checkItem.apCheck.custName;
- $scope.apBillOut.enUu = checkItem.apCheck.enUu;
- $scope.item.inoutno = checkItem.inoutno;
- $scope.item.inoutnodetno = checkItem.inoutnodetno;
- $scope.item.orderCode = checkItem.orderCode;
- $scope.item.orderClass = checkItem.orderClass;
- $scope.item.orderDetno = checkItem.orderDetno;
- $scope.item.NowQty = checkItem.thisBilledQty;
- if (typeof(checkItem.billed) == "undefined") {
- checkItem.billed = 0;
- $scope.sourceInfo.newBilledQty =checkItem.thisBilledQty;
- } else {
- //TODO 变成了字符串相加?
- $scope.sourceInfo.newBilledQty = checkItem.thisBilledQty + checkItem.billed;
- }
- //$scope.apBillOut.apBillOutItemId = check.id;
- $scope.apBillOut.recordDate = checkItem.recordDate;
- $scope.apBillOut.rate = checkItem.apCheck.rate;
- //必须是同一家客户才能生成对账单,否则提示错误
- if($scope.apBillOut.custUu == ''){
- $scope.apBillOut.custUu = checkItem.apCheck.custUu;
- }else if($scope.apBillOut.custUu !== checkItem.apCheck.custUu){
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一家客户');
- }
- //必须是相同币别才能生成对账单,否则提示错误
- if ($scope.apBillOut.currency == '') {
- $scope.apBillOut.currency = checkItem.apCheck.currency;
- } else if ($scope.apBillOut.currency !== checkItem.apCheck.currency) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一种币别');
- }
- //本次对账数量必须小于总对账数量
- if (checkItem.checkQty > 0) {
- if (checkItem.minThisBilledQty >checkItem.thisBilledQty || checkItem.maxThisBilledQty <checkItem.thisBilledQty) {
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error','本次开票数量,填写有误!');
- }
- } else if (check.qty < 0) {
- $scope.data.maxCheckQty = 0;
- $scope.data.minCheckQty = check.qty;
- if(((-check.qty)-(-check.yCheckQty) < (-check.CheckQty)) || check.CheckQty > 0 || check.CheckQty == 0){
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error','本次开票数量,填写有误!');
- }
- }
- //TODO
- //获取最小时间作为对账区间的起始时间
- if($scope.apBillOut.beginDate == ''){
- $scope.apBillOut.beginDate = checkItem.apCheck.apDate;
- }else{
- $scope.apBillOut.beginDate = $scope.apBillOut.beginDate>checkItem.apCheck.apDate? checkItem.apCheck.apDate : checkItem.apCheck.beginDate;
- }
- //获取最大时间作为对账区间的截止时间
- if($scope.apBillOut.endDate == ''){
- $scope.apBillOut.endDate = checkItem.apCheck.apDate;
- }else{
- $scope.apBillOut.endDate = $scope.apBillOut.endDate<checkItem.apCheck.apDate? checkItem.apCheck.apDate : checkItem.apCheck.endDate;
- }
- //应收开票单明细行数据
- $scope.item.price = checkItem.price;
- $scope.item.sourceId = checkItem.id;
- $scope.item.sourceTable = 'PURC$APCHECKITEM';//瑕疵
- $scope.item.NowQty = checkItem.thisBilledQty;
- $scope.item.prodCode = checkItem.prodCode;
- $scope.item.taxrate = checkItem.taxrate;
- //来源表相关信息
- $scope.sourceInfo.sourceId = checkItem.id;
- $scope.sourceInfo.sourceTable = 'PURC$APCHECKITEM';//瑕疵
- $scope.sourceInfo.newBilledQty = ((checkItem.billed || 0) + checkItem.thisBilledQty);
- //sourceInfos.push($scope.sourceInfo);
- $scope.apBillOut.items.push($scope.item);
- $scope.apBillOut.sourceInfos.push($scope.sourceInfo);
- $scope.haveSelected = true;
- }
- });
- //保存生成的开票单,后台同时更新对账单明细表中已开票数
- $scope.saveApBillOut = function () {
- FaApBillOut.saveApBillOut({}, $scope.apBillOut, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '生成开票单成功');
- $state.go('fa.apBillOut_detail', {id: data.id}, {reload:true});
- }, function (response) {
- toaster.pop('error', '生成开票单失败', response.data);
- });
- };
- //如果是同一家客户,生成对账单的同时,关闭模态框
- if($scope.sameCust && $scope.validQty) {
- $scope.saveApBillOut();
- }
- }
- }]);
- /**
- * 客户应付发票
- */
- app.controller('SaleApBillCtrl', ['$scope', '$filter', 'FaApBill', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, FaApBill, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return FaApBill;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- FaApBill.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/apBill/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户应付发票详情
- */
- app.controller('SaleApBillDetailCtrl', ['$scope', '$filter', 'FaApBill', 'toaster', '$stateParams', 'BaseService', 'CurrentRole', function ($scope, $filter, FaApBill, toaster, $stateParams, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- FaApBill.getAll({id: $stateParams.id}, function (data) {
- $scope.bill = data;
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData(); // 初始获取单据数据
- }]);
- /**
- * 应付对账单
- */
- app.controller('SaleArCheckCtrl', ['$scope', '$filter', 'FaArCheck', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, FaArCheck, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return FaArCheck;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 计算单据的商品总数
- $scope.getTotalProd = function (check) {
- var total = 0;
- if (check.items) {
- angular.forEach(check.items, function (value) {
- total += value.qty;
- });
- }
- return total;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 应付对账单详情页
- app.controller('SaleArCheckDetailCtrl', ['$scope', '$stateParams', 'FaArCheck', 'toaster', '$state', 'BaseService', function ($scope, $stateParams, FaArCheck, toaster, $state, BaseService) {
- BaseService.scrollBackToTop();
- var loadData = function () {
- FaArCheck.get({id: $stateParams.id}, function (data) {
- $scope.order = data;
- $scope.loading = false;
- });
- };
- loadData(); // 初始获取单据数据
- $scope.onReplyClick = function (item, isAgreed) {
- if (isAgreed) {// 同意确认
- FaArCheck.agree({itemId: item.id}, {}, function (data) {
- toaster.pop('success', '确认成功', '确认供应商对账数量成功');
- }, function (response) {
- toaster.pop('danger', '确认失败', response.data);
- });
- } else {// 不同意回复
- FaArCheck.disagree({itemId: item.id}, {
- qty: item.$replyQty,
- remark: item.$replyRemark
- }, function (data) {
- toaster.pop('success', '确认成功', '您提交的数量将发送给供应商确认');
- }, function (response) {
- toaster.pop('danger', '确认失败', response.data);
- });
- }
- };
- // 获取明细的回复记录
- $scope.getReplies = function (item) {
- if (!item.replies) {
- FaArCheck.getReplies({itemId: item.id}, function (data) {
- item.replies = data;
- }, function (response) {
- toaster.pop('danger', '获取对账记录失败', response.data);
- });
- }
- };
- }]);
- //应收对账单列表
- app.controller('PurchaseApCheckCtrl', ['$scope', 'FaApCheck', 'BaseService', 'ngTableParams', 'toaster', 'ReportService', 'Symbol', 'CurrentRole', function ($scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'todo';
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- //打印 对账单
- $scope.print = function (check) {
- var newPage = window.open("about:blank");
- FaApCheck.printPermission({}, function () {
- FaApCheck.printCount({id: check.id}, {});//增加打印此次
- ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id, newPage);
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- //状态
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //获取应收对账单全部
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- recordDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- FaApCheck[getState($scope.active)](BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.data = $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- FaApCheck.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- FaApCheck.setRead({}, sourceId, function (message) {
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- FaApCheck.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 计算单据的商品总数
- $scope.getTotalProd = function (check) {
- var total = 0;
- if (check.items) {
- angular.forEach(check.items, function (value) {
- total += value.checkQty;
- });
- }
- return total;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- FaApCheck.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/apCheck/xls/list?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- //应收对账单详情
- app.controller('PurchaseApCheckDetailCtrl', ['$scope', 'toaster', 'FaApCheck', '$stateParams', 'BaseService', 'CurrentRole', function ($scope, toaster, FaApCheck, $stateParams, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.haveSelected = true;
- $scope.data = {};
- //控制提交和删除按钮的显示
- $scope.ifShow = true;
- var loadData = function () {
- FaApCheck.getItem({id: $stateParams.id}, function (data) {
- $scope.data = data;
- if ($scope.data.status) {
- } else {
- $scope.ifShow = true;
- }
- }, function (response) {
- toaster.pop('error', '', response.data);
- })
- };
- if ($stateParams.id) {
- loadData();
- }
- $scope.haveSource = false;
- //提交应收对账单
- $scope.submitApCheck = function () {
- FaApCheck.updateStatus({id: $stateParams.id}, {}, function (data) {
- if (data.result) {
- toaster.pop('success', '提示', '提交成功');
- $scope.haveSelected = false;
- window.location.href = '#/fa/apCheck';
- } else {
- $scope.haveSource = true;
- loadData();
- toaster.pop('error', '提示', '单据被反过账,请立即作废本单据');
- $scope.haveSelected = true;
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '更新已转数失败', response.data);
- });
- }
- //删除应收对账单的同时更新来源表已转数
- var updateYCheckQty = function () {
- var sourceInfos = [];
- angular.forEach($scope.data.items, function (item) {
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newYCheckQty: ''
- };
- $scope.sourceInfo.sourceId = item.sourceId;
- $scope.sourceInfo.sourceTable = item.sourceTable;
- $scope.sourceInfo.newYCheckQty = item.oldYCheckQty;
- sourceInfos.push($scope.sourceInfo);
- });
- FaApCheck.update({}, sourceInfos, function () {
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '更新已转数失败', response.data);
- });
- }
- //删除应收对账单
- $scope.deleteApCheck = function () {
- FaApCheck.deleteApCheck({id: $stateParams.id}, {}, function (data) {
- updateYCheckQty();
- toaster.pop('success', '提示', '删除成功');
- }, function (response) {
- toaster.pop('error', '删除失败', response.data);
- });
- $scope.haveSelected = false;
- }
- //作废应收对账单
- $scope.cancelApCheck = function (check) {
- FaApCheck.cancel({id: check.id}, {}, function (data) {
- $scope.checkResult = false;
- if (data.result) {
- $scope.checkResult = true;
- toaster.pop('success', '提示', '作废成功');
- $scope.tableParams.reload();
- } else {
- toaster.pop('error', '提示', '作废失败');
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '作废失败', response.data);
- });
- }
- }]);
- //未对账单据列表
- app.controller('PurchaseApCheckListCtrl', ['$scope', 'FaApCheck', 'toaster', '$state', '$filter', '$modal', 'Vendor', 'DecimalNumber', function ($scope, FaApCheck, toaster, $state, $filter, $modal, Vendor, DecimalNumber) {
- $scope.data = [];// 列表数据
- $scope.condition = {
- $fromOpened: false
- }
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
- // 客户联想词
- $scope.getSimilarCustomers = function (value) {
- if (value) {
- return Vendor.getSimilarCustomers({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateCustomerClick = function (vendor) {
- if (vendor.apcheck == 0) {
- toaster.pop('info', '提示', '该客户暂未启用平台对账功能');
- $scope.suuorname = '';
- } else {
- $scope.suuorname = vendor.custName;
- }
- }
- //查找客户
- $scope.searchCust = function (suuorname) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/fa/apcheck_customer.html',
- controller: 'SearchCustInfoCtrl',
- size: 'lg',
- resolve: {
- suuorname: function () {
- return suuorname;
- }
- }
- });
- modalInstance.result.then(function (customer) {
- $scope.suuorname = customer.myEnterprise.enName;
- });
- }
- // 点击筛选根据条件选择数据
- // 默认本月
- $scope.sdateTo = new Date();
- $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodtitle = '';
- $scope.condition.prodspec = '';
- $scope.searchOrder = function (check) {
- $scope.data = [];
- $scope.checkboxes.checked = false;
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory
- $scope.condition.prodtitle = $scope.prodtitle;
- $scope.condition.prodspec = $scope.prodspec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if ($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf()) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- if ($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
- $scope.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.searchKeyWord = {
- receiveName: $scope.receiveName,
- factory: $scope.factory,
- prodTitle: $scope.prodTitle,
- prodSpec: $scope.prodSpec,
- taxRate: $scope.taxRate,
- suuorname: $scope.suuorname
- }
- $scope.exportKeywords = encodeURIComponent($scope.searchKeyWord);
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if (!$scope.suuorname) {
- toaster.pop('warning', '提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- $scope.loading = true;
- FaApCheck.getAllByKeywords({
- fromDate: $scope.fromDate,
- endDate: $scope.endDate,
- receiveName: $scope.receiveName,
- factory: $scope.factory,
- prodTitle: $scope.prodTitle,
- prodSpec: $scope.prodSpec,
- taxRate: $scope.taxRate,
- suuorname: $scope.suuorname
- }, function (data) {
- if (data.length > 0) {
- angular.forEach(data, function (item) {
- item.$selected = true;
- });
- $scope.data = data;
- $scope.checkboxes.checked = true;
- $scope.getTotalMoney();
- } else {
- toaster.pop('info', '提示', '当前没有需要对账记录');
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- }
- $scope.exportApcheckList = function() {
- var url = 'sale/apCheck/xls?fromDate=' + $scope.fromDate + '&endDate=' + $scope.endDate;
- if (angular.isDefined($scope.receiveName)) {
- url = url + '&receiveName=' + $scope.receiveName;
- }
- if (angular.isDefined($scope.factory)) {
- url = url + '&factory=' + $scope.factory;
- }
- if (angular.isDefined($scope.prodTitle)) {
- url = url + '&prodTitle=' + $scope.prodTitle;
- }
- if (angular.isDefined($scope.prodSpec)) {
- url = url + '&prodSpec=' + $scope.prodSpec;
- }
- if (angular.isDefined($scope.suuorname)) {
- url = url + '&suuorname=' + $scope.suuorname;
- }
- if (angular.isDefined($scope.taxRate)) {
- url = url + '&receiveName=' + $scope.taxRate;
- }
- window.location.href = url;
- }
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.totalMoney = 0;
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- $scope.totalMoney = 0;
- $scope.filteredData = $filter('filter')($scope.data, $scope.condition.prodtitle || $scope.condition.uuorname || $scope.condition.venduuorname || $scope.condition.prodspec || $scope.condition.factory);
- var dateFrom = $scope.condition.dateFrom;
- var dateTo = $scope.condition.dateTo;
- angular.forEach($scope.filteredData, function (item) {
- if ((item.pidate >= dateFrom || dateFrom == '') && (item.pidate < dateTo || dateTo == '')) {
- item.$selected = $scope.checkboxes.checked;
- }
- });
- $scope.getTotalMoney();
- };
- //获取已选单据总金额
- $scope.getTotalMoney = function () {
- $scope.totalMoney = 0;
- angular.forEach($scope.data, function (check) {
- if (check.$selected) {
- var price = DecimalNumber.accMul((check.thischeckqty || 0), (check.orderprice || 0));
- $scope.totalMoney += Math.round(price * 100) / 100;
- } else {
- $scope.totalMoney += 0;
- }
- });
- }
- // 点击其中一个明细的复选框
- $scope.checkOne = function (check) {
- var result = true;
- angular.forEach($scope.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.haveSelected = false;
- //生成应收对账单
- $scope.createApCheck = function () {
- //保存应收对账单主记录字段
- $scope.apCheck = {
- custUu: '',
- custName: '',
- enUu: '',
- apDate: '',
- beginDate: '',
- endDate: '',
- checkStatus: '未对账',
- checkAmount: 0,
- currency: '',
- rate: '',
- items: [],
- taxrate: ''
- };
- //保存来源单据相关信息
- var sourceInfos = [];
- //所允许的本次对账最大最小数量
- $scope.data.maxThisCheckQty = 0;
- $scope.data.minThisCheckQty = 0;
- $scope.sameCust = true;
- $scope.validQty = true;
- $scope.loading = true;
- angular.forEach($scope.data, function (check) {
- //保存应收对账单明细行数据
- $scope.item = {
- inoutno: '',
- inoutnodetno: '',
- orderCode: '',
- orderClass: '',
- orderDetno: '',
- price: '',
- checkQty: '',
- amount: '',
- sourceId: '',
- sourceTable: '',
- oldYCheckQty: '',
- status: 0,
- receiveCode: '',
- receiveName: '',
- prodCode: '',
- prodTitle: '',
- prodUnit: '',
- prodSpec: '',
- taxrate: '',
- sendcode: '',
- whname: '',
- };
- //应收对账单明细行来源表信息
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newYCheckQty: ''
- };
- //此次对账后新的已转数
- $scope.newYCheckQty = 0;
- if (check.$selected == true) {
- $scope.apCheck.custName = check.custname;
- $scope.apCheck.enUu = check.enuu;
- $scope.apCheck.checkAmount += (check.thischeckqty || 0) * (check.orderprice || 0);
- $scope.apCheck.apDate = check.pidate;
- $scope.apCheck.rate = check.rate;
- //必须是同一家客户才能生成对账单,否则提示错误
- if ($scope.apCheck.custUu == '') {
- $scope.apCheck.custUu = check.custuu;
- } else if ($scope.apCheck.custUu !== check.custuu) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一家客户');
- }
- //必须是相同币别才能生成对账单,否则提示错误
- if ($scope.apCheck.currency == '') {
- $scope.apCheck.currency = check.currency;
- } else if ($scope.apCheck.currency !== check.currency) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一种币别');
- }
- //必须是相同税率才能生成对账单,否则提示错误
- if (!angular.isNumber($scope.apCheck.taxrate)) {
- $scope.apCheck.taxrate = check.taxrate;
- } else if ($scope.apCheck.taxrate != check.taxrate) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择相同的税率');
- }
- //本次对账数量必须小于总对账数量
- if (check.qty > 0) {
- $scope.data.maxThisCheckQty = check.qty;
- $scope.data.minThisCheckQty = 0;
- if (check.qty - (check.ycheckqty || 0) < check.thischeckqty || check.thischeckqty < 0 || check.thischeckqty == 0) {
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error', '本次对账数量,填写有误!');
- }
- } else if (check.qty < 0) {
- $scope.data.maxThisCheckQty = 0;
- $scope.data.minThisCheckQty = check.qty;
- if (((-check.qty) - (-check.ycheckqty) < (-check.thischeckqty)) || check.thischeckqty > 0 || check.thischeckqty == 0) {
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error', '本次对账数量,填写有误!');
- }
- }
- //获取最小时间作为对账区间的起始时间
- if ($scope.apCheck.beginDate == '') {
- $scope.apCheck.beginDate = check.pidate;
- } else {
- $scope.apCheck.beginDate = $scope.apCheck.beginDate > check.pidate ? check.pidate : $scope.apCheck.beginDate;
- }
- //获取最大时间作为对账区间的截止时间
- if ($scope.apCheck.endDate == '') {
- $scope.apCheck.endDate = check.pidate;
- } else {
- $scope.apCheck.endDate = $scope.apCheck.endDate < check.pidate ? check.pidate : $scope.apCheck.endDate;
- }
- //应收对账单明细行数据
- $scope.item.orderCode = check.ordercode;
- $scope.item.orderClass = check.piclass;
- $scope.item.orderDetno = check.orderdetno;
- $scope.item.price = check.orderprice;
- $scope.item.checkQty = check.thischeckqty;
- $scope.item.amount = (check.thischeckqty || 0) * (check.orderprice || 0);
- $scope.item.sourceId = check.sourceid;
- $scope.item.sourceTable = check.sourcetable;
- $scope.item.oldYCheckQty = check.ycheckqty;
- $scope.item.prodCode = check.prodcode;
- $scope.item.prodTitle = check.prodtitle;
- $scope.item.prodSpec = check.prodspec;
- $scope.item.prodUnit = check.produnit;
- $scope.item.inoutno = check.inoutno;
- $scope.item.inoutnodetno = check.detno;
- $scope.item.taxrate = check.taxrate;
- $scope.item.receiveCode = check.receivecode;
- $scope.item.receiveName = check.receivename;
- $scope.item.sendcode = check.sendcode;
- $scope.item.whname = check.whname;
- //来源表相关信息
- $scope.sourceInfo.sourceid = check.sourceid;
- $scope.sourceInfo.sourcetable = check.sourcetable;
- $scope.sourceInfo.newYCheckQty = ((check.ycheckqty || 0) + check.thischeckqty);
- sourceInfos.push($scope.sourceInfo);
- $scope.apCheck.items.push($scope.item);
- $scope.haveSelected = true;
- }
- });
- //保存生成的应收对账单
- $scope.saveApCheck = function () {
- FaApCheck.saveApCheck({}, $scope.apCheck, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '生成应收对账成功');
- $state.go('fa.apCheck_detail', {id: data.id}, {reload: true});
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '生成对账单失败', response.data);
- })
- };
- //如果是同一家客户,生成对账单的同时,关闭模态框
- if ($scope.sameCust && $scope.validQty) {
- $scope.saveApCheck();
- }
- }
- }]);
- // 企业信息设置
- app.controller('EnterpriseCtrl', ['$scope', 'AccountEnterprise', 'toaster', '$state', '$modal', 'BaseService', 'ShipAddress', '$http', 'DeputyOrder', function ($scope, AccountEnterprise, toaster, $state, $modal, BaseService, ShipAddress, $http, DeputyOrder) {
- BaseService.scrollBackToTop();
- $scope.loading = true;
- AccountEnterprise.get({}, function (data) {
- $scope.loading = false;
- $scope.enterprise = data;
- if (data.tags) {
- $scope.tags = data.tags.split(','); // 将逗号分隔的标签字符串转换成数组,便于操作
- } else {
- $scope.tags = [];
- }
- // 获取付款企业信息
- DeputyOrder.paycompanies({enuu: $scope.enterprise.uu}, {}, function (data) {
- $scope.pays = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- // 更新企业信息
- $scope.updateDetailInfo = function () {
- $scope.loading = true;
- $scope.enterprise = $scope.copyEnterprise;
- $scope.enterprise.tags = $scope.tags.join(','); // 将标签数组转换成逗号分隔的字符串,便于储存
- AccountEnterprise.save($scope.enterprise, function () {
- $scope.loading = false;
- $scope.connectionEditing = false;
- toaster.pop('success', '提示', '修改企业信息成功');
- $state.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '修改信息失败', response.data);
- });
- };
- // 申请Saas
- $scope.applySaas = function () {
- if ($scope.enterprise.enUrl && $scope.enterprise.enAddress && $scope.enterprise.enIndustry) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/applySaas.html',
- controller: 'ApplySaasCtrl',
- resolve: {
- enterprise: function () {
- return angular.copy($scope.enterprise);
- }
- }
- });
- modalInstance.result.then(function () {
- $state.reload();
- }, function () {
- });
- } else {
- toaster.pop('info', '请完善信息', '申请优企云服请先完善企业详细信息');
- }
- };
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- });
- // 判断是否是代采企业
- DeputyOrder.isDeputyEnterprise({}, function (data) {
- $scope.deputyEnter = data;
- });
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- });
- toaster.pop('success', '提示', data.success);
- $scope.ship = {receiver: null, usertel: null, phone: null, email: null, province: null, city: null, district: null, addressdet: null, addalias: null, address: null};
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- // 删除收货地址
- $scope.removeShip = function (id, index) {
- ShipAddress.removeShipAddress({id: id}, {}, function (data) {
- $scope.ships.splice(index, 1);
- toaster.pop('success', '提示', '收货地址删除成功');
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 编辑收货地址
- $scope.editShip = function (ship) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/shipaddress_modal.html',
- controller: 'ShipAddressCtrl',
- resolve: {
- ship: function () {
- return ship;
- }
- }
- });
- modalInstance.result.then(function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- });
- }, function () {
- });
- };
- // 新增付款企业
- $scope.addPayCompany = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/paycompany_modal.html',
- controller: 'PayCompanyCtrl',
- resolve: {
- pay: function () {
- return null;
- }
- }
- });
- modalInstance.result.then(function () {
- DeputyOrder.paycompanies({enuu: uu}, {}, function (data) {
- $scope.pays = data;
- // 获取付款企业信息
- DeputyOrder.paycompanies({enuu: $scope.enterprise.uu}, {}, function (data) {
- $scope.pays = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function () {
- });
- }
- // 删除付款企业
- $scope.removePay = function (id, index) {
- DeputyOrder.removePayCompany({id: id}, {}, function (data) {
- $scope.pays.splice(index, 1);
- toaster.pop('success', '提示', '付款企业信息删除成功');
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 编辑付款企业
- $scope.editPay = function (pay, uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/paycompany_modal.html',
- controller: 'PayCompanyCtrl',
- resolve: {
- pay: function () {
- return pay;
- }
- }
- });
- modalInstance.result.then(function () {
- DeputyOrder.paycompanies({enuu: uu}, {}, function (data) {
- $scope.pays = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function () {
- });
- };
- // 设置logo
- $scope.showImageDialog = function (modal) {
- require(['jquery-uploadify'], function () {
- $modal.open({
- templateUrl: 'static/tpl/index/home/insert.html',
- controller: 'ImageInsertCtrl',
- backdrop: 'static'
- }).result.then(function (image) {
- $scope.imageUrl = image.thumb;
- User.postImageUrl(null, angular.toJson($scope.imageUrl), function (data) {
- $scope.user = data;
- }, function (response) {
- toaster.pop('error', '设置图像失败,' + response.data);
- });
- });
- });
- }
- // 添加经营范围标签
- $scope.addTag = function () {
- if ($scope.tags.indexOf($scope.tag) == -1){
- if (null != $scope.tag && '' != $scope.tag) {
- $scope.tags.push($scope.tag);
- }
- }
- $scope.tag = '';
- }
- // 移除经营范围标签
- $scope.removeTag = function (tag) {
- removeByValue($scope.tags, tag);
- }
- // 获取行业信息
- $http.get('static/data/profession.json').success(function (data) {
- $scope.list = data;
- });
- // 选择行业
- $scope.profession = new Array();
- $scope.showProfession = false;
- $scope.selectProfession = function () {
- $scope.professionArray = [];
- $scope.active = [];
- $scope.showProfession = !$scope.showProfession;
- $scope.profession[0] = $scope.list;
- }
- $scope.isInList = false;
- $scope.isInInput = false;
- $scope.hideList = function () {
- if (!$scope.isInList && !$scope.isInInput && $scope.showProfession) {
- $scope.showProfession = false;
- }
- }
- // 行业子菜单点击
- $scope.onItemClick = function (key, index, value) {
- $scope.active[index] = key;
- if (angular.isString(value)){ // 值为字符串说明点击的是最后一级
- $scope.copyEnterprise.profession = value;
- $scope.showProfession = false;
- return;
- }
- $scope.professionArray = [];
- $scope.profession.splice(index+1);
- if (angular.isArray(value)){ // 值为数组说明下一级是最后一级
- $scope.professionArray = value;
- } else if (angular.isObject(value)) {
- $scope.profession[index+1] = value;
- }
- }
- // 判断值是否为字符串
- $scope.isString = function (value) {
- return angular.isString(value);
- }
- // 拷贝企业数据,在编辑企业数据是使用拷贝数据
- $scope.copyData = function () {
- $scope.copyEnterprise = angular.copy($scope.enterprise);
- if ($scope.enterprise.tags) {
- $scope.tags = $scope.enterprise.tags.split(','); // 将逗号分隔的标签字符串转换成数组,便于操作
- } else {
- $scope.tags = [];
- }
- }
- }]);
- // 编辑收货地址
- app.controller('ShipAddressCtrl', ['$scope', 'ShipAddress', 'ship', '$modalInstance', 'toaster', '$http', function ($scope, ShipAddress, ship, $modalInstance, toaster, $http) {
- $scope.ship = ship;
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $modalInstance.close();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- // 编辑付款企业信息
- app.controller('PayCompanyCtrl', ['$scope', 'DeputyOrder', 'pay', '$modalInstance', 'toaster', '$http', function ($scope, DeputyOrder, pay, $modalInstance, toaster, $http) {
- $scope.pay = pay;
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.savePayCompany = function (pay) {
- pay.address = pay.province + pay.city + pay.district + pay.addressdet;
- DeputyOrder.savePaycompany({}, pay, function (data) {
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.dismiss();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- // 申请Saas Controller
- app.controller('ApplySaasCtrl', ['$scope', '$modalInstance', 'enterprise', 'AccountEnterprise', 'toaster', '$http', function ($scope, $modalInstance, enterprise, AccountEnterprise, toaster, $http) {
- $scope.enterprise = enterprise;
- $scope.checking = false;
- $scope.$watch('enterprise.enSaasUrl', function () {
- if ($scope.enterprise.enSaasUrl) {
- $http.get('signup/saasUrlEnable', {
- params: {
- enSaasUrl: $scope.enterprise.enSaasUrl
- }
- }).success(function (data) {
- if (data && data == 'true') {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', true);
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '优企云服域名已被使用';
- }
- }).error(function () {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '验证出错';
- });
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- }
- });
- var setSaasUrl = function (url) {
- var index = url.indexOf('www.');
- if (index != -1) {//包含www.
- var substr = url.substring(index + 4, url.length);
- $scope.enterprise.enSaasUrl = substr.substring(0, substr.indexOf('.'));
- } else {
- $scope.enterprise.enSaasUrl = getHost(url);
- }
- };
- // 解析获取网址的一级域名
- var getHost = function (host) {
- var newhost;
- var domain;
- var ArrDomain = new Array('.com.cn', '.net.cn', '.org.cn', '.gov.cn', '.com', '.cn', '.tel', '.mobi', '.net', '.org', '.asia', '.me', '.cc', '.name', '.info');//枚举所有后缀
- for (var k in ArrDomain) {
- var re = eval('/\\' + ArrDomain[k] + '$/g');
- newhost = host.replace(re, '');
- if (newhost != host) {
- domain = ArrDomain[k];
- break;
- }
- }
- var hostar = newhost.split('.');
- var s = hostar[hostar.length - 1];
- return s;
- };
- // 设置优企云服域名为官网网址一级域名
- if ($scope.enterprise.enUrl) setSaasUrl($scope.enterprise.enUrl);
- $scope.apply = function () {
- $scope.loading = true;
- AccountEnterprise.applySaas({
- enUU: $scope.enterprise.uu,
- enSaasUrl: $scope.enterprise.enSaasUrl,
- enAdminPassword: $scope.enterprise.enAdminPassword
- }, {}, function () {
- $scope.loading = false;
- toaster.pop('success', '申请成功', '已提交系统开通优企云服,开通后将会发送邮件至管理员邮箱');
- $modalInstance.close();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '申请失败', response.data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- app.controller('UserCtrl', ['$scope', '$filter', 'AuthenticationService', 'AccountUser', 'BaseService', 'ngTableParams', 'toaster', '$modal', '$http', 'ngAlert', 'AccountEnterprise', 'CurrentRole', function ($scope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http, ngAlert, AccountEnterprise, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.editing = false;
- $scope.loading = true;
- $scope.enterprise = null;
- $scope.searchMthod = false;
- $scope.keyword = null;
- AccountUser.findDistribute({}, function (data) {
- $scope.distributes = data;
- }, function (response) {
- toaster.pop('error', '系统错误', response.data);
- });
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- var users = [];
- var getMangagerInfo = function() {
- CurrentRole.isManager({}, function(data) {
- $scope.isManager = data.isManager || $scope.user.sys;
- });
- CurrentRole.roles({}, function(data) {
- $scope.roles = data.count || $scope.user.sys;
- });
- };
- getMangagerInfo();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- userName: 'asc'
- }
- }, {
- total: 0,
- counts: [15, 25, 50, 100],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- AccountUser.getAll.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- users = page.content;
- if(users.length > 0) {
- if(users.length > 0) {
- angular.forEach(users, function (user) { // 从验证中获取到的用户信息,不包含身份证号。在这里赋值
- if (user.userTel === $scope.user.userTel && user.userUU === $scope.user.userUU) {
- $scope.user.userIdcode = user.userIdcode;
- }
- });
- }
- }
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.reload();
- $scope.tableParams.page(1);
- }
- $scope.saveUser = function () {
- $scope.loading = true;
- AccountUser.update({}, $scope.user, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '修改用户信息成功');
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- });
- loadUsers();
- $scope.editing = false;
- }, function (reponse) {
- $scope.loading = false;
- toaster.pop('error', '失败', reponse.data);
- });
- };
- $scope.updatePassword = function () {
- var newPage = window.open("about:black");
- AccountUser.getUpdatePasswordUrl({returnUrl: window.location.href}, function (data) {
- newPage.location.href = data.url;
- });
- };
- $scope.updateDetail = function () {
- var newPage = window.open("about:black");
- AccountUser.getCloudCenterUrl({}, function (data) {
- newPage.location.href = data.url;
- });
- }
- $scope.newUser = {};
- //弹出添加用户模态框
- $scope.addExistUser = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/addExistUser.html',
- controller: 'AddExistUserCtrl'
- });
- modalInstance.result.then(function () {
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- $scope.tableParams.reload();
- }, function () {
- });
- };
- /**
- * 添加未注册用户
- */
- $scope.submit = false;
- $scope.addUser = function () {
- $scope.submit = true;
- $scope.adding = true;
- $scope.loading = true;
- AccountUser.save({}, $scope.newUser, function (data) {
- $scope.loading = false;
- $scope.submit = false;
- toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
- $scope.newUser = {userSex: 'M'};
- $scope.tableParams.reload();
- $scope.adding = false;
- $scope.newUserForm.newUserTel.$setValidity('available', false);
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- $scope.userEmailSuccess = false;
- $scope.userEmailError = false;
- }, function (response) {
- $scope.submit = false;
- $scope.loading = false;
- toaster.pop('error', '错误', response.data);
- });
- };
- /**
- * 验证手机号是否可用
- */
- $scope.telValid = function (tel) {
- if (tel) {
- $http.get('account/user/telEnable', {
- params: {
- tel: tel
- }
- }).success(function (data) {
- data = eval(data);
- if (data == true) {
- $scope.newUserForm.newUserTel.$setValidity('available', true);
- $scope.userTelSuccess = true;
- $scope.userTelError = false;
- } else {
- $scope.newUserForm.newUserTel.$setValidity('available', false);
- $scope.userTelError = true;
- $scope.userTelSuccess = false;
- if (tel.length == 11)
- toaster.pop('error', '错误', '手机号 ' + tel + ' 已被注册');
- }
- }).error(function () {
- $scope.userTelSuccess = false;
- $scope.userTelError = true;
- });
- } else {
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- }
- };
- /**
- * 验证邮箱是否可用
- */
- $scope.emailValid = function (email) {
- if (email) {
- $http.get('account/user/emailEnable', {
- params: {
- email: email
- }
- }).success(function (data) {
- data = eval(data);
- if (data == true) {
- $scope.newUserForm.newUserEmail.$setValidity('available', true);
- $scope.userEmailSuccess = true;
- $scope.userEmailError = false;
- } else {
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
- $scope.userEmailError = true;
- $scope.userEmailSuccess = false;
- }
- }).error(function () {
- $scope.userEmailError = true;
- $scope.userEmailSuccess = false;
- });
- } else {
- $scope.userEmailError = false;
- $scope.userEmailSuccess = false;
- }
- };
- /**
- * 删除用户
- */
- $scope.removeUser = function (user) {
- new ngAlert({
- title: '提示',
- content: '确定删除用户(' + user.userName + ')吗?'
- }, function () {
- AccountUser.remove({uu: user.userUU}, function () {
- toaster.pop('success', '提示', '用户删除成功。');
- loadUsers();
- }, function (response) {
- toaster.pop('error', '删除失败', response.data);
- });
- });
- };
- // 编辑用户的角色
- $scope.editUserRole = function (user) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/user_role.html',
- controller: 'UserRoleCtrl',
- resolve: {
- user: function () {
- return user;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- };
- // 为用户分配角色(删除企业)
- $scope.removeVendor = function (user) {
- var resultRole = true;
- angular.forEach(user.roles, function (role) {
- if (role.issys == 1 || role.name == 'ROLE_SALEMANAGER') {
- toaster.pop('error', '提示', '管理员和销售经理无需分配客户');
- resultRole = false;
- return;
- }
- });
- if (resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/remove_vendor.html',
- controller: 'RemoveVendorCtrl',
- resolve: {
- user: function () {
- return user;
- }
- }
- });
- }
- };
- // 为用户分配角色(添加企业)
- $scope.addVendor = function (user, isIssy) {
- if (!$scope.roles) {
- toaster.pop('error', '提示', '你不是管理员或销售经理,无权限分配!请立即联系管理员');
- return;
- }
- var resultRole = true;
- angular.forEach(user.roles, function (role) {
- if (role.issys == 1 || role.name == 'ROLE_SALEMANAGER') {
- toaster.pop('error', '提示', '管理员和销售经理无需分配客户');
- resultRole = false;
- return;
- }
- })
- if (resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_vendor.html',
- controller: 'AddVendorCtrl',
- resolve: {
- user: function () {
- return user;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- }
- };
- }]);
- // 登录手机号码验证
- app.controller('CheckTelCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'AuthenticationService', 'SendCheckMsg', 'SessionService', '$timeout', function ($scope, $modalInstance, user, AccountUser, AuthenticationService, SendCheckMsg, SessionService, $timeout) {
- $scope.user = user;
- $scope.cancel = function () {
- $modalInstance.close();
- }
- }]);
- app.controller('RemoveVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountUser, toaster) {
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- AccountUser.findChooseVendor({uu: user.userUU}, function (data) {
- $scope.enters = data;
- $scope.loading = false;
- angular.forEach($scope.enters, function (item) {
- item:{
- $selected:true;
- }
- });
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.enters, function (item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (vendor) {
- var result = true;
- angular.forEach($scope.enters, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (user.userUU) {
- angular.forEach($scope.enters, function (item, i) {
- if (item.$selected) {
- chooseResult.push(item.id);
- }
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.removeChooseVendor({uu: user.userUU}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '删除成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '删除失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '删除失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- app.controller('AddVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountUser, toaster) {
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- AccountUser.findVendor({uu: user.userUU}, function (data) {
- $scope.enters = data;
- $scope.loading = false;
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.enters, function (item) {
- item.distribute = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (vendor) {
- var result = true;
- angular.forEach($scope.enters, function (item) {
- if (item.distribute != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (user.userUU) {
- angular.forEach($scope.enters, function (item, i) {
- chooseResult.push(item);
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.addVendor({uu: user.userUU}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- app.controller('UserRoleCtrl', ['$scope', '$modalInstance', 'user', 'AccountRole', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountRole, AccountUser, toaster) {
- $scope.checked = [];
- $scope.master = [];
- AccountRole.query({}, function (data) {
- if (user && data) {
- var rs = [], checked = [];
- angular.forEach(user.roles, function (r) {
- rs.push(r.id);
- });
- angular.forEach(data, function (d) {
- if (rs.indexOf(d.id) > -1) {
- d.$checked = true;
- checked.push(d);
- }
- });
- }
- $scope.roles = data;
- $scope.checked = checked;
- $scope.master = angular.copy($scope.checked);
- });
- $scope.select = function (role) {
- role.$checked = !role.$checked;
- if (role.$checked) {
- if (role.desc === '管理员' || role.desc === '普通用户') {
- $scope.checked = [];
- angular.forEach($scope.roles, function (r) {
- r.$checked = false;
- });
- role.$checked = true;
- $scope.checked.push(role);
- } else {
- angular.forEach( $scope.checked, function (r, i) {
- if (r.desc === '管理员' || r.desc === '普通用户') {
- $scope.checked.splice(i, 1);
- }
- });
- angular.forEach($scope.roles, function (r) {
- if (r.desc === '管理员' || r.desc === '普通用户') {
- r.$checked = false;
- }
- });
- $scope.checked.push(role);
- }
- } else {
- angular.forEach($scope.checked, function (c, i) {
- if (c.id == role.id)
- $scope.checked.splice(i, 1);
- });
- }
- };
- $scope.isChanged = function () {
- return !angular.equals($scope.master, $scope.checked);
- };
- $scope.close = function (save) {
- if (save) {
- if (user.userUU) {
- user.roles = $scope.checked;
- AccountUser.updateRole({}, user, function () {
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '保存失败', response.data);
- });
- } else {
- $modalInstance.close(true, $scope.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- // 修改密码Controller
- app.controller('PasswordCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountUser, toaster) {
- $scope.user = user;
- $scope.checking = false;
- //输入原密码后验证原密码是否正确
- $scope.checkPassword = function (password) {
- $scope.checking = true;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- AccountUser.checkPassword({password: password}, function (data) {
- $scope.checkSuccess = true;
- $scope.checking = false;
- $scope.checkFailed = false;
- }, function (response) {
- $scope.checkFailed = true;
- $scope.checking = false;
- $scope.checkSuccess = false;
- });
- };
- //修改密码
- $scope.ok = function () {
- if ($scope.user.newPassword == $scope.user.newPassword1) {//验证重复密码相等
- AccountUser.updatePassword({
- password: $scope.user.password,
- newPassword: $scope.user.newPassword
- }, {}, function (data) {
- var tip = '修改成功,请牢记您的新密码:' + $scope.user.newPassword;
- toaster.pop('success', '成功', tip);
- $scope.user.password = null;
- $scope.user.newPassword = null;
- $scope.user.newPassword1 = null;
- $scope.checking = false;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- $modalInstance.close();
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- } else {
- toaster.pop('error', '错误', '重复密码不一致');
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- /*
- * 绑定用户到企业
- */
- app.controller('AddExistUserCtrl', ['$scope', '$modalInstance', 'FuzzySearch', 'AuthenticationService', '$timeout', 'toaster', function ($scope, $modalInstance, FuzzySearch, AuthenticationService, $timeout, toaster) {
- $scope.searching = false;
- //根据输入的内容查找用户
- $scope.searchUser = function (keyWord) {
- $scope.searching = true;
- $scope.searchSuccess = false;
- $scope.searchFailed = false;
- $scope.illegalError = false;
- $scope.reBindError = false;
- $scope.okDisabled = false;
- FuzzySearch.searchUser({keyWord: keyWord}, function (data) {
- $scope.searchSuccess = true;
- $scope.searchFailed = false;
- $scope.user = data; //查询到的用户
- }, function (response) {
- $scope.searchSuccess = false;
- $scope.searchFailed = true;
- });
- };
- //确认绑定
- $scope.ok = function (keyWord) {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.currentUser = data; //当前登录的用户(管理员)
- //不可自己绑定自己
- if ($scope.currentUser.userUU == $scope.user.userUU) {
- $scope.illegalError = true;
- $scope.okDisabled = true;
- return false;
- }
- //用户未绑定到任何企业时
- if (!$scope.user.enterprises) {
- //正常绑定
- FuzzySearch.bindUserToMyEnterprise({userUU: $scope.user.userUU}, function (data) {
- $scope.okDisabled = true;
- toaster.pop("success", "提示", "用户绑定成功");
- $modalInstance.close(true);
- }, function (response) {
- });
- return true;
- }
- //用户已绑定到某些企业时
- for (var i = 0; i < $scope.currentUser.enterprises.length; i++) {
- if ($scope.currentUser.enterprises[i].current) {
- for (var j = 0; j < $scope.user.enterprises.length; j++) {
- //该用户已绑定到当前企业,不可重复绑定
- if ($scope.currentUser.enterprises[i].uu == $scope.user.enterprises[j].uu) {
- $scope.reBindError = true;
- $scope.okDisabled = true;
- return false;
- }
- }
- //该用户未绑定到当前企业,可以进行绑定
- FuzzySearch.bindUserToMyEnterprise({userUU: $scope.user.userUU}, function (data) {
- $scope.okDisabled = true;
- toaster.pop("success", "提示", "用户绑定成功");
- $modalInstance.close(true);
- }, function (response) {
- console.log("绑定失败!");
- });
- }
- }
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- app.controller('LogCtrl', ['$scope', 'BaseService', 'ngTableParams', 'ErpLog', 'UsageLog', function ($scope, BaseService, ngTableParams, ErpLog, UsageLog) {
- $scope.erpParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- time: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- ErpLog.get(BaseService.parseParams(params.url()), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.usageParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- time: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- UsageLog.get(BaseService.parseParams(params.url()), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
- app.controller('ResourceCtrl', ['$scope', 'AccountResource', function ($scope, AccountResource) {
- AccountResource.query({}, function (data) {
- if (data && data.length > 0) {
- data[0].$open = true;
- }
- $scope.resources = data;
- });
- }]);
- app.controller('RoleCtrl', ['$scope', '$modal', 'AccountRole', function ($scope, $modal, AccountRole) {
- $scope.roles = {};
- var getData = function () {
- AccountRole.query({}, function (data) {
- var defaults = [], custom = [];
- angular.forEach(data, function (d) {
- if (d.isdefault == 1)
- defaults.push(d);
- else
- custom.push(d);
- });
- $scope.roles = {defaults: defaults, custom: custom};
- });
- };
- getData();
- $scope.editRole = function (role) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/role_detail.html',
- controller: 'RoleEditCtrl',
- resolve: {
- role: function () {
- return role;
- }
- }
- });
- modalInstance.result.then(function (added) {
- added && (getData());
- });
- };
- }]);
- app.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'ngAlert', 'BaseService', 'CurrentRole', 'AuthenticationService', function ($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, ngAlert, BaseService, CurrentRole, AuthenticationService) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为管理员
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- CurrentRole.isManager({}, {}, function (data) {
- $scope.isManager = data.isManager || $scope.user.sys;
- });
- $scope.role = role;
- $scope.master = angular.copy($scope.role);
- var isNew = role == null;
- $scope.cancel = function () {
- $modalInstance.close(false);
- };
- AccountResource.query({}, function (data) {
- if (data && data.length > 0) {
- if (role && role.resourceItems) {
- var rs = [];// 已分配的资源的id
- angular.forEach(role.resourceItems, function (item) {
- rs.push(item.id);
- });
- angular.forEach(data, function (resource) {
- var c = 0;
- angular.forEach(resource.items, function (item) {
- if (rs.indexOf(item.id) > -1) {
- item.$checked = true;
- c += 1;
- }
- });
- resource.$checked = c == resource.items.length;
- });
- }
- $scope.resourceItems = data[0].items;
- data[0].$active = true;
- }
- $scope.resources = data;
- $timeout(function () {
- angular.forEach($scope.resources, function (resource) {
- var c = 0;
- angular.forEach(resource.items, function (item) {
- item.$checked && (c += 1);
- });
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- });
- }, 100);
- });
- $scope.onItemClick = function (resource) {
- $scope.resourceItems = resource.items;
- angular.forEach($scope.resources, function (r) {
- r.$active = false;
- });
- resource.$active = true;
- };
- var getChecked = function () {
- var items = [];
- angular.forEach($scope.resources, function (resource) {
- angular.forEach(resource.items, function (item) {
- item.$checked && (items.push(item));
- });
- });
- $scope.role.resourceItems = items;
- };
- $scope.onResourceChange = function (resource) {
- angular.forEach(resource.items, function (item) {
- item.$checked = resource.$checked;
- });
- getChecked();
- };
- $scope.onItemChange = function () {
- angular.forEach($scope.resources, function (resource) {
- if (resource.$active) {
- var c = 0;
- angular.forEach(resource.items, function (item) {
- item.$checked && (c += 1);
- });
- resource.$checked = (c == resource.items.length);
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- }
- });
- getChecked();
- };
- $scope.isChanged = function (formData) {
- if (!$scope.master)
- return true;
- return !angular.equals(formData, $scope.master);
- };
- $scope.save = function () {
- $scope.master = angular.copy($scope.role);
- AccountRole.save($scope.master, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 资料' + (isNew ? '添加' : '修改') + '成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- };
- $scope.del = function () {
- new ngAlert({
- title: '提示',
- content: '确定删除角色(' + $scope.role.desc + ')吗?'
- }, function () {
- AccountRole.remove({id: role.id}, {}, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- })
- };
- $scope.updateDefault = function () {
- new ngAlert({
- title: '提示',
- content: '确定把(' + $scope.role.desc + ')信息更新到标准库吗?'
- }, function () {
- AccountRole.updateDefault({desc: $scope.role.desc}, $scope.role.resourceItems, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 更新成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- })
- }
- $scope.recover = function () {
- new ngAlert({
- title: '提示',
- content: '确定将“' + $scope.role.desc + '”恢复默认权限吗?'
- }, function () {
- AccountRole.recover({roleId: role.id}, {}, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 恢复默认权限成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- })
- };
- }]);
- /**
- * 委外订单
- */
- app.controller('MakeOrderCtrl', ['$scope', '$filter', 'MakeOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'CurrentRole',
- function ($scope, $filter, MakeOrder, ngTableParams, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeOrder;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- MakeOrder.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- MakeOrder.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- MakeOrder.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- MakeOrder.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getOrderTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 打开回复
- $scope.openReply = function (order) {
- if (!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (order) {
- order.$editing = false;
- }
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 点击回复
- $scope.onReplyClick = function (order, inverse) {
- if (order.reply) {
- if (!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOrder.reply({orderId: order.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- //委外加工单
- $scope.print = function (order) {
- MakeOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$orders.ma_id=' + order.id);
- };
- // 获取回复记录
- $scope.getReply = function (order) {
- if (!order.replies) {
- MakeOrder.getReply({orderId: order.id}, function (replies) {
- order.replies = replies;
- });
- }
- };
- // 导出
- $scope.exportXls = function () {
- MakeOrder.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/orders/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 委外加工单详细
- */
- app.controller('MakeOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOrder', 'toaster', 'ReportService', 'BaseService', 'CurrentRole', function ($scope, $stateParams, MakeOrder, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- MakeOrder.getItem({id: $stateParams.id}, function (data) {
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- // 获取回复记录
- $scope.getReply = function (item) {
- if (!item.replies) {
- MakeOrder.getReply({orderId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 点击回复
- $scope.onReplyClick = function (order, inverse) {
- if (order.reply) {
- if (!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOrder.reply({orderId: order.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 打开回复
- $scope.openReply = function (order) {
- if (!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (order) {
- order.$editing = false;
- }
- // 委外订单
- $scope.print = function (order) {
- MakeOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$orders.ma_id =' + order.id);
- };
- }]);
- /**
- * 客户委外验收
- */
- app.controller('MakeAcceptCtrl', ['$scope', '$filter', 'MakeAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, MakeAccept, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeAccept;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy(pageParams.searchFilter.fromDate);//保存当前取值的关键词
- $scope.endDateXls = angular.copy(pageParams.searchFilter.endDate);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeAccept.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/accept/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户委外验退
- */
- app.controller('MakeReturnCtrl', ['$scope', '$filter', 'MakeReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, MakeReturn, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeReturn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy(pageParams.searchFilter.fromDate);//保存当前取值的关键词
- $scope.endDateXls = angular.copy(pageParams.searchFilter.endDate);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeReturn.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/return/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 委外加工变更
- */
- app.controller('MakeChangeCtrl', ['$scope', '$filter', 'MakeChange', 'ngTableParams', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $filter, MakeChange, ngTableParams, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeChange;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- orderChangeDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 打开回复
- $scope.openReply = function (change) {
- change.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (change) {
- change.$editing = false;
- }
- // 确定回复
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- MakeChange.reply({itemId: change.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeChange.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/changes/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('MakeChangeDetailCtrl', ['$scope', '$stateParams', 'MakeChange', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $stateParams, MakeChange, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- MakeChange.getItem({id: $stateParams.id}, function (data) {
- $scope.change = data;
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- MakeChange.reply({itemId: change.id}, reply, function () {
- toaster.pop('info', '提示', '回复成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- }]);
- /**
- * 委外加工
- */
- app.controller('MakeOutOrderCtrl', ['$scope', '$filter', 'MakeOutOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'CurrentRole', function ($scope, $filter, MakeOutOrder, ngTableParams, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeOutOrder;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 获取回复记录
- $scope.getReply = function (item) {
- if (!item.replies) {
- MakeOutOrder.getReply({orderId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- // 打开回复
- $scope.openReply = function (change) {
- change.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (change) {
- change.$editing = false;
- }
- // 确定回复
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- MakeOutOrder.reply({itemId: change.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeOutOrder.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/outorders/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 委外加工详细
- */
- app.controller('MakeOutOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOutOrder', 'toaster', 'ReportService', 'BaseService', 'CurrentRole', function ($scope, $stateParams, MakeOutOrder, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- MakeOutOrder.getItem({id: $stateParams.id},{}, function (data) {
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- // 获取回复记录
- $scope.getReply = function (item) {
- if (!item.replies) {
- MakeOutOrder.getReply({orderId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 点击回复
- $scope.onReplyClick = function (order, inverse) {
- if (order.reply) {
- if (!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOutOrder.reply({orderId: order.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 打开回复
- $scope.openReply = function (order) {
- if (!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (order) {
- order.$editing = false;
- }
- // 自己委外加工订单
- $scope.print = function (order) {
- MakeOutOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$outorders.ma_id =' + order.id);
- };
- }]);
- /**
- * 计算时间差
- */
- app.filter('timespan', function () {
- return function (time) {
- if (time == null)
- return '9999年';
- var now = new Date().getTime(), span = time - now,
- d = Math.ceil(span / 86400000), h = Math.ceil(span / 3600000),
- m = Math.ceil(span / 60000);
- if (span < 0)
- return '1天';
- if (d > 0)
- return d + 1 + '天';
- if (h > 0)
- return h + '小时';
- if (m > 0)
- return m + '分钟';
- return '0天';
- };
- });
- /**
- * 公共询价计算时间差
- */
- app.filter('datespan', function () {
- return function (time) {
- if (time == null) {
- return '剩余9999年';
- }
- var now = new Date().getTime(), span = time - now,
- d = Math.floor(span / 86400000), h = Math.floor(span / 3600000),
- m = Math.floor(span / 60000);
- if (d > 0) {
- var day = d + 1;
- return '剩余' + day + '天';
- }
- if (h > 0) {
- return '<span class="text-inverse">剩余' + h + '小时</span>';
- }
- if (m > 0) {
- return '<span class="text-inverse">剩余' + m + '分钟</span>';
- }
- return '已结束';
- };
- });
- app.filter('firstchar', function () {
- return function (str) {
- if (str == null)
- return null;
- return str.substring(0, 1);
- };
- });
- app.filter('summary', function () {
- return function (data, field) {
- var sum = 0;
- if (data) {
- angular.forEach(data, function (d) {
- sum += d[field];
- });
- }
- return sum;
- };
- });
- /**
- * 搜索框,回车触发
- */
- app.directive('ngSearch', ['$parse', function ($parse) {
- return {
- require: '?ngModel',
- restrict: 'A',
- link: function (scope, element, attrs, ngModel) {
- var searchFn = $parse(attrs.ngSearch);
- element.bind('keypress', function (event) {
- if (event.keyCode == '13') {
- event.preventDefault();
- event.stopPropagation();
- searchFn(scope, {$data: ngModel.$modelValue, $event: event});
- }
- });
- }
- };
- }]);
- /**
- * 状态码 -> 描述
- */
- app.filter('status', function () {
- return function (data) {
- var statusConfig = {
- '101': '已提交',
- '102': '已审核',
- '103': '未通过',
- '200': '未回复',
- '201': '已回复',
- '313': '已激活',
- '316': '已过账',
- '311': '申请中',
- '312': '未激活'
- };
- return statusConfig[data];
- }
- });
- //弹出问题反馈模态框
- app.controller('LeftCtrl', ['$scope', '$modal', 'AuthenticationService', function ($scope, $modal, AuthenticationService) {
- //获取当前用户
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- });
- $scope.showModal = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/serve/feedback.html',
- controller: 'FeedbackCtrl',
- resolve: {
- user: function () {
- return $scope.user;
- } //传递当前用户到模态框Controller
- }
- });
- modalInstance.result.then(function () {
- }, function () {
- });
- }
- }]);
- /*
- * 提交我的反馈
- */
- app.controller('FeedbackCtrl', ['$scope', '$modalInstance', 'FeedBackService', 'toaster', 'AuthenticationService', 'user', function ($scope, $modalInstance, FeedBackService, toaster, AuthenticationService, user) {
- $scope.isPublic = 1; //默认公开
- $scope.classId = 1; //默认类别
- $scope.user = user;
- $scope.ok = function () {
- if (!$scope.user) { //用户未登录
- $scope.uu = null;
- } else { //用户已登录
- $scope.uu = $scope.user.userUU;
- }
- //FeedBackService定义于common/service.js里,供不同页面的问题反馈功能使用
- FeedBackService.feedBackQuestion({
- classId: $scope.classId,
- isPublic: $scope.isPublic,
- title: $scope.title,
- userUU: $scope.uu
- }, {},
- function (data) {
- toaster.pop('success', '成功', '您的问题反馈成功!');
- $scope.cancel();
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- //“我的问题反馈”跳转控制
- app.controller('RightCtrl', ['$scope', 'AuthenticationService', 'toaster', '$rootScope', function ($scope, AuthenticationService, toaster, $rootScope) {
- $scope.myFeedback = function () {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- if (!$scope.user) {
- toaster.pop('warning', '提示', '您还未登录,请登录后再查看!');
- return false;
- } else {
- window.location.href = "./serve#/question/myFeedback";
- }
- });
- };
- $scope.getSaleOrderCount = function (unread) {
- if (unread != undefined) {
- return unread.order + unread.change + unread.makeOrder;
- }
- };
- $scope.getSaleInquiryCount = function (unread) {
- if (unread != undefined) {
- return unread.inquiry + unread.mould;
- }
- };
- $scope.setActive = function (active) {
- $rootScope.active = active;
- }
- }]);
- //客户服务
- app.controller('CustServeCtrl', ['$scope', 'Vendor', function ($scope, Vendor) {
- Vendor.getServe(function (datas) {
- $scope.vendors = datas;
- // 自动跳转
- if (datas && datas.length == 1)
- $scope.redirect(datas[0]);
- });
- $scope.redirect = function (vendor) {
- window.open('purc/vendor/serve/' + vendor.vendorEnterprise.uu);
- };
- }]);
- /**
- * 物料资料
- */
- app.controller('ProductListCtrl', ['$scope', 'GetProductInfo', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', '$rootScope', '$modal', 'Products', 'GetProductInfoNewest', 'AccountEnterprise', function ($scope, GetProductInfo, ngTableParams, $filter, BaseService, toaster, $timeout, $rootScope, $modal, Products, GetProductInfoNewest, AccountEnterprise) {
- BaseService.scrollBackToTop();
- var loadAccount = function () {
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data;
- $scope.saleStatus = $scope.enterprise.prodsale;
- });
- }
- loadAccount();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? GetProductInfo : GetProductInfoNewest;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- id: 'desc',
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //删除
- $scope.deleteById = function (id) {
- $scope.loading = true;
- GetProductInfo.deleteById({}, id, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop("error", "删除失败", response.data);
- });
- };
- $rootScope.isProductEdit = false;
- // 编辑
- $scope.isProductEdit = function () {
- $rootScope.isProductEdit = true;
- };
- // 一键开启关闭
- $scope.toggle = function (status) {
- if ($scope.saleStatus == 0) {
- $scope.saleStatus = 1;
- } else {
- $scope.saleStatus = 0;
- }
- $scope.loading = true;
- GetProductInfo.toggle({status: status}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- loadAccount();
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- })
- }
- var products = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- products = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.cmpUuId == null) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- products = [];// 每次选择时先清空,防止重复
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.updateByBatch = function (updatetype) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/updateByBatch_modal.html',
- controller: 'UpdateByBatchCtrl',
- size: 'md',
- resolve: {
- updatetype: function () {
- return updatetype;
- },
- active: function () {
- return $scope.active;
- },
- type: function () {
- return 'sale';
- }
- }
- });
- modalInstance.result.then(function (data) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 一键匹配
- $scope.matchall = function () {
- $scope.loading = true;
- $scope.type = "sale";
- GetProductInfo.matchbytype({type: $scope.type}, {}, function (data) {
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- } else {
- toaster.pop('info', '提示', '匹配成功' + data.size + '个标准器件');
- window.location.href = "#/sale/productmatches";
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.exportXls = function () {
- GetProductInfo.exportXls({},{}, function (data) {
- if (data.success) {
- window.location.href = 'product/baseInfo/xls?_state='+$scope.active+'&keyword='+ ($scope.keywordXls || "");
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- }]);
- /**
- * 批量修改
- */
- app.controller('UpdateByBatchCtrl', ['$scope', '$modalInstance', 'toaster', 'BaseService', 'updatetype', 'Products', 'active', 'type', function ($scope, $modalInstance, toaster, BaseService, updatetype, Products, active, type) {
- $scope.updatetype = updatetype;
- $scope.changed = false;
- $scope.parameter = {
- updatetype: updatetype,
- standard: active,
- type: type,
- oldvalue: null,
- newvalue: null
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- if (updatetype === '品牌')
- var loadData = function () {
- Products.getBrands({parameter: $scope.parameter}, {}, function (data) {
- $scope.products = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- if (updatetype === '名称(类目)')
- var loadData = function () {
- Products.getTitles({parameter: $scope.parameter}, {}, function (data) {
- $scope.products = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- loadData();
- $scope.okay = function (newvalue) {
- if (newvalue == '' || newvalue == null) {
- toaster.pop('error', '提示', '修改的值不能为空');
- } else {
- $scope.loading = true;
- Products.alterByBatch({parameter: $scope.parameter}, {}, function (data) {
- $scope.loading = false;
- $modalInstance.close(data);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- }]);
- /**
- * 物料批量上传
- */
- app.controller('UploadByBatchCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function ($scope, $upload, toaster, BaseService) {
- BaseService.scrollBackToTop();
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- $scope.fileName = file.name;
- }
- })
- // 通过excel批量上传物料
- $scope.upload = function () {
- $scope.loading = true;
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- if (file.name) {
- $upload.upload({
- url: 'product/baseInfo/edit/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- // $scope.products = $scope.result.products;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- $scope.infos = $scope.result.infos;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_prod_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'product/baseInfo/upload/template';
- };
- }]);
- /**
- * 物料详情
- */
- app.controller('ProductDetailCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', 'AuthenticationService', '$filter', 'BaseService', '$rootScope', '$modal', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, AuthenticationService, $filter, BaseService, $rootScope, $modal, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.editstatus = false;
- var loadData = function () {
- GetProductInfo.getSaleProduct({id: $stateParams.id}, function (data) {
- if (data.attachment) {
- $scope.imgPreview = data.attachment;
- $scope.previewShow = true;
- }
- $scope.prodInfo = data;
- if ($scope.prodInfo.isbusiness == 0) {
- $scope.editstatus = true;
- }
- if ($scope.prodInfo.standard != 1) {// 非标准的先进行匹配
- Products.matchone({id: $scope.prodInfo.id}, {}, function (data) {
- $scope.matchresults = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 设置类目
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.kind = kind.kindName;
- }
- // 设置名称
- $scope.onAssociateTitleClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置导入品牌
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- // 设置标准品牌
- $scope.onAssociatePBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.pbranden = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置标准型号
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.pcmpcode = cmp.code;
- }
- // 设置导入的型号
- $scope.onAssociateCmpClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 选择类目
- $scope.selectKind = function (cmpcode) {
- if (cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function () {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
- // 取消
- $scope.cancel = function () {
- GetProductInfo.getOne({id: $stateParams.id}, function (data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
- // 删除
- $scope.clearfile = function () {
- $scope.prodInfo.attachment = null;
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //删除
- $scope.deleteById = function (id) {
- $scope.loading = true;
- GetProductInfo.deleteById({}, id, function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- window.location.href = "#/sale/prodList";
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop("error", "删除失败", response.data);
- });
- };
- $scope.submit = function (prodInfo) {
- $scope.prodInfo.isSale = 1;
- $scope.loading = true;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/edit/updateProdInfo',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $rootScope.isProductEdit = false;
- loadData();
- // window.location.href="#/sale/prodList";
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loading = false;
- $scope.loadingShow = false;
- if (status == 403){
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- // 查看范例
- $scope.showImg = function () {
- if ($scope.prodInfo.attachment) {
- $scope.imgPreview = $scope.prodInfo.attachment;
- var src = $scope.prodInfo.attachment, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- $scope.previewShow = true;
- } else if (imgurl != null) {
- var src = imgurl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- }]);
- /**
- * 新增物料(销售)
- */
- app.controller('NewProdInfoCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', '$modal', 'ComponentActive', 'KindAPI', '$timeout', '$filter', 'AuthenticationService', 'BaseService', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout, $filter, AuthenticationService, BaseService, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.prodInfo = {};
- // 选择类目
- $scope.selectKind = function () {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- };
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 删除
- $scope.clearfile = function () {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //提交
- $scope.submit = function (prodInfo) {
- $scope.loading = true;
- $scope.prodInfo.isSale = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/edit/addNewProduct',
- file: file,
- method: 'POST',
- data: {
- prodInfo: prodInfo
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', '产品添加成功');
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/sale/prodList/" + data.id;
- // window.location.href="#/sale/prodList";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/sale/prodList/" + data.id;
- // window.location.href="#/sale/prodList";
- }, 500);
- }
- }).error(function (data, status) {
- $scope.loading = false;
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- };
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgUrl = null
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgUrl = url;
- return url;
- };
- // 查看范例
- $scope.showImg = function () {
- var src = imgUrl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 取消
- $scope.cancel = function () {
- $scope.prodInfo = angular.copy($scope.prodInfo);
- };
- }]);
- /**
- * 类目选择模态框
- */
- app.controller('KindChooseCtrl', ['$scope', 'KindAPI', 'toaster', '$modalInstance', '$modal', function ($scope, KindAPI, toaster, $modalInstance, $modal) {
- $scope.kindId = null;
- $scope.kinds = [[], [], [], []];
- // 获取子类目
- var getChildren = function (pid, deep) {
- KindAPI.getChildren({parentId: pid}, function (data) {
- $scope.kinds[deep] = data;
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- };
- // 改变节点选中状态
- var changeStatus = function (item, deep) {
- var kindId = null, level = 0;
- angular.forEach($scope.kinds, function (ks, i) {
- if (i > deep) {
- $scope.kinds[i] = [];
- } else {
- angular.forEach(ks, function (k, j) {
- if (i == deep) {
- if (k.id == item.id) {
- $scope.kinds[i][j].$active = true;
- kindId = k.id;
- } else {
- k.$active = null;
- }
- }
- });
- }
- });
- // 选择的节点
- $scope.kindId = kindId;
- $scope.active = item;
- // 当前可操作的层级
- if (deep < 3) {
- $scope.activeDeep = deep + 1;
- }
- };
- // 节点点击后获取子类目,节点被选中
- $scope.onItemClick = function (item, deep) {
- changeStatus(item, deep);
- if (!item.isLeaf) {
- getChildren(item.id, deep + 1);
- }
- };
- // 重新加载数据
- function reload(deep) {
- var pid;
- if (deep) {
- pid = $scope.actives[deep - 1].id;
- } else {
- pid = 0;
- deep = 0;
- }
- getChildren(pid, deep);
- }
- // 初始加载数据,获取第一层的类目
- if ($scope.actives) {
- angular.forEach($scope.actives, function (v, k) {
- KindAPI.getChildren({parentId: v.parentid}, function (data) {
- $scope.kinds[k] = data;
- angular.forEach($scope.kinds[k], function (kind, i) {
- if (kind.id == v.id) {
- $scope.kinds[k][i].$active = true;
- $scope.actives[k] = $scope.kinds[k][i];
- }
- })
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- });
- } else {
- reload();
- }
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 确认选择
- $scope.check = function () {
- $modalInstance.close($scope.kindId);
- };
- }]);
- /**
- * 器件筛选
- */
- app.controller('FindComponentCtrl', ['$scope', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'ComponentActive', 'KindId', function ($scope, BaseService, ngTableParams, toaster, $modalInstance, ComponentActive, KindId) {
- //状态
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.kindId = KindId;
- ComponentActive.getComponentsByKindid(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 选择
- $scope.check = function (data) {
- $modalInstance.close(data);
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 企业列表
- */
- app.controller('EnterpriseListCtrl', ['$scope', 'getAccountUserSpace', 'ngTableParams', '$filter', 'BaseService', 'toaster', 'AddPartner', '$rootScope', function ($scope, getAccountUserSpace, ngTableParams, $filter, BaseService, toaster, AddPartner, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return getAccountUserSpace;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 添加合作关系
- $scope.addPartner = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- $scope.status = 'enList';
- }]);
- /**
- * 新增采购单
- */
- app.controller('PurcNewOrderCtrl', ['$scope', '$modal', 'toaster', '$filter', 'addtoCart', '$rootScope', 'VendorInfo', 'ngTableParams', 'BaseService', 'Product', 'newPurcOrder', 'cartOperation', 'ShipAddress', 'Vendor', '$http', '$window', 'token', 'recentPrice',
- function ($scope, $modal, toaster, $filter, addtoCart, $rootScope, VendorInfo, ngTableParams, BaseService, Product, newPurcOrder, cartOperation, ShipAddress, Vendor, $http, $window, token, recentPrice) {
- BaseService.scrollBackToTop();
- // 每次进入时先清除掉rootScope下的venduu
- $rootScope.venduu = null;
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- var getToken = function() {
- if($scope.token == null) {
- token.info({userType: 'purcorder'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- getToken();
-
- $scope.order = {
- date: new Date(),
- vend: {
- uu: '',
- },
- vendUser: {},
- code: $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- orderItems: {
- product: {},
- },
- rate: 17
- };
- //商品信息
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- prid: null,
- taxrate: null
- };
- if ($rootScope.businessCode) {
- VendorInfo.getVendorInfo({businessCode: $rootScope.businessCode}, {}, function (data) {
- $scope.id = data.id;
- $scope.order.vend.enName = data.vendorEnterprise.enName;
- $scope.order.vend.enAddress = data.vendorEnterprise.enAddress;
- $scope.order.vend.uu = data.vendorEnterprise.uu;
- $scope.order.paymethods = data.paymethod;
- $rootScope.venduu = data.vendorEnterprise.uu;
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }, function (response) {
- });
- }
- ;
- // 查找供应商
- $scope.dbfindVend = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
- controller: 'DbfindVendorInfoCtrl',
- size: 'lg',
- resolve: {
- orderItems: function () {
- return $scope.order.orderItems;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $rootScope.venduu = data.vendorEnterprise.uu;
- $scope.id = data.id;
- $scope.order.vend = data.vendorEnterprise;
- $scope.order.vend.enName = data.vendorEnterprise.enName;
- $scope.order.vendUser = data.vendorUser;
- $scope.order.payments = data.paymethod;
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- taxrate: null
- };
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }, function () {
- });
- };
- // 联想词 start
- // 获取供应商
- $scope.getSimilarVendors = function (value) {
- if (value) {
- return Vendor.getSimilarVendors({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateCmpClick = function (vendor, order) {
- $scope.order.vend.uu = vendor.venduu;
- $scope.id = vendor.id;
- $scope.order.payments = vendor.paymethod;
- $rootScope.venduu = $scope.order.vend.uu;
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }
- // 联想词 end
- // $scope.order.orderItems.push(item);
- if ($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function (data) {
- item.code = data.code;
- item.title = data.title;
- item.spec = data.spec;
- item.unit = data.unit;
- item.id = data.id;
- $scope.order.orderItems.push(item);
- $rootScope.prodId = null;// 清除掉prodId
- }, function (response) {
- });
- }
- //增加商品
- $scope.addProduct = function (index) {
- if ($scope.order.orderItems[index].code == null) {
- toaster.pop('info', '提示', '请先选择商品');
- } else {
- $scope.order.orderItems.push({
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- $endDateOpen: false,
- taxrate: $scope.order.rate,
- prodsource: 'seller'
- });
- }
- };
- //删除商品
- $scope.deleteProduct = function (index) {
- $scope.order.orderItems.splice(index, 1);
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.vendUU = $scope.order.vend.uu;
- Product.vendPord.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 选择
- $scope.check = function (data) {
- var price = null;
- var qty = null;
- var taxRate = null;
- if (data.id) {
- recentPrice.agreed({prId: data.id}, {}, function(response) {
- price = response.price;
- qty = response.qty;
- taxRate = response.taxRate;
- $scope.order.orderItems.push({
- code: data.code,
- title: data.title,
- spec: data.spec,
- unit: data.unit,
- qty: qty,
- price: price,
- remark: null,
- delivery: null,
- prid: data.id,
- taxrate: taxRate,
- prodsource: 'seller',
- });
- });
- }
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_uplodaByBatch.html',
- controller: 'PurcUploadByBatchCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.order.orderItems.push({
- code: prod.code,
- title: prod.title,
- unit: 'PCS',
- spec: prod.spec,
- qty: prod.amount,
- price: prod.price,
- remark: prod.remark,
- delivery: prod.date,
- prid: prod.id,
- taxrate: prod.rate,
- prodsource: 'purchaser'
- });
- })
- }, function () {
- });
- };
- // 监听venduu发生变化,重新加载物料信息
- $scope.$watch('order.vend.uu', function (n, o) {
- if (n == o) {
- return;
- } else {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, true);
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.order.orderItems[index].$endDateOpen = !openParam;
- };
- // 添加到购物车
- $scope.addToCart = function (order) {
- $scope.loading = true;
- $scope.order.status = 311;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.vendUU = $scope.order.vend.uu;
- $scope.order.vendUserUU = $scope.order.vendUser.userUU;
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/cart/' + data.id;
- $window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 立即购买
- $scope.addToOrder = function (order) {
- $scope.loading = true;
- $scope.order.status = 200;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.vendUU = $scope.order.vend.uu;
- $scope.order.vendUserUU = $scope.order.vendUser.userUU;
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/order/' + data.id;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- // 新增供应商联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function (data) {
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- }]);
- /**
- * 采购批量导入
- */
- app.controller('PurcUploadByBatchCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.loading = false;
- $scope.upload = function () {
- $scope.loading = true;
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'purchase/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'purchase/upload/template';
- };
- $scope.enSure = function () {
- $modalInstance.close($scope.result.products);
- }
- // 点击确定时增加加载标志
- $scope.addClass = function() {
- $scope.loading = true;
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- // 查找供应商
- app.controller('DbfindVendorInfoCtrl', ['$scope', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'Vendor', '$rootScope', 'orderItems', function ($scope, BaseService, ngTableParams, toaster, $modalInstance, Vendor, $rootScope, orderItems) {
- $scope.prod = false;
- if (orderItems.length != 0) {
- $scope.prod = true;
- }
- BaseService.scrollBackToTop();
- if ($rootScope.venduu != null) {
- $scope.venduu = $rootScope.venduu;
- }
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.ensure = false;
- $scope.check = function (vendor) { // 需要进行判断的选择
- $scope.vendorInfo = vendor;
- $scope.ensure = true;
- };
- $scope.checkVendor = function (vendor) { // 直接选择
- $modalInstance.close(vendor);
- }
- }]);
- /**
- * 我的客户
- */
- app.controller('MyClientCtrl', ['$scope', 'VendorService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', function ($scope, VendorService, BaseService, AuthenticationService, ngTableParams, $modal, toaster) {
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- var getCustInfos = function (custuu) {
- if (custuu) {
- VendorService.userInfo.query({uu: custuu}, null, function (data) {
- $scope.custInfos = data;
- var getPage = function (page, size) {
- if ($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1) * size, page * size);
- if ($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- } else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1, 4);
- $scope.first = function () {
- $scope.userdata = getPage($scope.userdata.pre, 4);
- }
- $scope.last = function () {
- $scope.userdata = getPage($scope.userdata.next, 4);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }
- // 分配权限
- $scope.addUserInfo = function (customer) {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function () {
- return customer;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- } else {
- toaster.pop('error', '您没有分配用户的权限!');
- }
- };
- $scope.showUserInfo = function (customer, boo) {
- $scope.custInfo = customer;
- if (boo) {
- getCustInfos(customer.myEnterprise.uu);
- $scope.userInfoResult = true;
- }
- }
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- VendorService.customer.get(BaseService.parseParams(params.url()), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
- /**
- * 我的供应商
- */
- app.controller('PurcVendorCtrl', ['$scope', 'Vendor', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', '$rootScope', 'VendorInfo', function ($scope, Vendor, BaseService, AuthenticationService, ngTableParams, $modal, toaster, $rootScope, VendorInfo) {
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //设置消息已读
- var setOrdersRead = function () {
- var ids=[];
- Vendor.setVendorRead({}, ids, function (message) {
- });
- };
- setOrdersRead();
- // 查看供应商详情
- $scope.VendorDetail = function (id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/" + $rootScope.vendorId;
- }
- // 向企业购买
- $scope.purcByEn = function (businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
- }]);
- /**
- * 供应商详情
- */
- app.controller('PurcVendorDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', function ($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.vendorContacts = [];
- var loadData = function () {
- Vendor.getVendorDetail({id: $stateParams.id}, {}, function (data) {
- $scope.vendor = data.vendorEnterprise;
- Vendor.contacts({venduu: $scope.vendor.uu}, {}, function (data) {
- $scope.vendorContacts = data;
- });
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- // 新增供应商联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function (data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.vendorContacts.push(data);
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- };
- // 编辑供应商联系人
- $scope.edit = function (contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function () {
- return contact;
- }
- }
- });
- modalInstance.result.then(function (data) {
- Vendor.saveContact({}, data, function (data) {
- loadData();
- toaster.pop('success', '提示', '联系人修改成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- // 删除供应商联系人
- $scope.deleteById = function (id, index) {
- $scope.vendorContacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '供应商联系人删除成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 供应商物料信息
- $scope.viewProdList = function (uu) {
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function (businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 询价
- */
- $scope.PurcInquiry = function (businessCode, id) {
- $rootScope.prodId = id;
- window.location.hash = "#/purc/purcinquiry/" + businessCode;
- }
- }]);
- /**
- * 编辑供应商联系人
- */
- app.controller('EditContacCtrl', ['$scope', 'toaster', '$modalInstance', 'contact', function ($scope, toaster, $modalInstance, contact) {
- $scope.contact = angular.copy(contact);
- $scope.save = function (contact) {
- $modalInstance.close(contact);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 新增供应商联系人
- */
- app.controller('AddContacCtrl', ['$scope', 'toaster', '$modalInstance', function ($scope, toaster, $modalInstance) {
- $scope.save = function (contact) {
- $modalInstance.close(contact);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 建立合作关系申请 (我的合作伙伴)
- */
- app.controller('AddPartnerRequestCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', '$rootScope', 'VendorInfo', '$window', function ($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout, $rootScope, VendorInfo, $window) {
- BaseService.scrollBackToTop();
- $scope.status = "partner";
- $scope.active = 'done';
- var getRequestStatus = function (active) {
- var fn = 'getAllRequest';
- switch (active) {
- case 'done':
- fn = 'getRequestDone';
- break;
- case 'todo':
- fn = 'getRequestTodo';
- break;
- case 'end':
- fn = 'getRequestEnd';
- break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function () {
- return AddPartnerMyRequest;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- if ($rootScope.vendName) {
- pageParams.keyword = $rootScope.vendName;
- $scope.keyword = $rootScope.vendName;
- $rootScope.vendName = null;
- }
- $scope.tip = $scope.keyword;
- getService()[getRequestStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 再次申请
- $scope.addAgain = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- // 添加为供应商
- $scope.addSupplier = function (vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加为供应商
- $scope.addServicer = function (vendUID) {
- AddPartner.addServicer({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加客户
- $scope.addCust = function (vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 同意申请
- $scope.agree = function (id) {
- AddPartner.agreeRequest({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 拒绝申请
- $scope.refuse = function (id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消供应商关系
- $scope.relieve = function (id) {
- VendorInfo.relieve({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 建立供应商关系
- $scope.activeVend = function (id) {
- VendorInfo.activeVend({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消服务商
- $scope.relieveServicer = function (id) {
- VendorInfo.relieveServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 启用服务商
- $scope.activeServicer = function (id) {
- VendorInfo.activeServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消客户关系
- $scope.disableCust = function (id) {
- VendorInfo.disableCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 激活客户关系
- $scope.activeCust = function (id) {
- VendorInfo.activeCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 建立合作关系申请 (新的合作伙伴)
- */
- app.controller('NewPartnerCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', '$rootScope', 'VendorInfo', '$window', '$modal',
- function ($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout, $rootScope, VendorInfo, $window, $modal) {
- BaseService.scrollBackToTop();
- $scope.status = "partner";
- $scope.active = 'all'; // 所有申请记录
- var getRequestStatus = function (active) {
- var fn = 'getAllRequest';
- switch (active) {
- case 'done':
- fn = 'getRequestDone';
- break;
- case 'todo':
- fn = 'getRequestTodo';
- break;
- case 'end':
- fn = 'getRequestEnd';
- break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function () {
- return AddPartnerMyRequest;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- if ($rootScope.vendName) {
- pageParams.keyword = $rootScope.vendName;
- $scope.keyword = $rootScope.vendName;
- $rootScope.vendName = null;
- }
- $scope.tip = $scope.keyword;
- getService()[getRequestStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 再次申请
- $scope.addAgain = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- // 添加为供应商
- $scope.addSupplier = function (vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加为供应商
- $scope.addServicer = function (vendUID) {
- AddPartner.addServicer({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加客户
- $scope.addCust = function (vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 同意申请
- $scope.agree = function (id) {
- AddPartner.agreeRequest({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- if (data.result) {
- //选择打印模板
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/partnership_modal.html',
- controller: 'PartnerShipCtrl',
- resolve: {
- PartnerShipInfo: function () {
- return data.result;
- }
- }
- });
- modalInstance.result.then(function () {
- window.location.reload();
- });
- }
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- AddPartnerMyRequest.requestAmount({}, function (data) {
- $scope.requestTodo = data;
- });
- // 拒绝申请
- $scope.refuse = function (id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消供应商关系
- $scope.relieve = function (id) {
- VendorInfo.relieve({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 建立供应商关系
- $scope.activeVend = function (id) {
- VendorInfo.activeVend({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 取消服务商
- $scope.relieveServicer = function (id) {
- VendorInfo.relieveServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 启用服务商
- $scope.activeServicer = function (id) {
- VendorInfo.activeServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 取消客户关系
- $scope.disableCust = function (id) {
- VendorInfo.disableCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 激活客户关系
- $scope.activeCust = function (id) {
- VendorInfo.activeCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 同意申请后续操作
- */
- app.controller('PartnerShipCtrl', ['$scope', 'PartnerShipInfo', '$modalInstance', 'AddPartner', 'toaster',
- function($scope, PartnerShipInfo, $modalInstance, AddPartner, toaster) {
- $scope.partInfo = PartnerShipInfo;
- // 添加为服务商
- $scope.addServicer = function (vendUID) {
- AddPartner.addServicer({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加客户
- $scope.addCust = function (vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加为供应商
- $scope.addSupplier = function (vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 关闭
- $scope.close = function() {
- $modalInstance.close();
- }
- }]);
- /**
- * 建立合作关系处理申请
- */
- app.controller('AddPartnerMessageCtrl', ['$scope', 'AddPartnerMyMessage', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', 'AddPartnerMyRequest', '$window', function ($scope, AddPartnerMyMessage, toaster, BaseService, ngTableParams, AddPartner, AddPartnerMyRequest, $window) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- var getMessagetStatus = function (active) {
- var fn = 'getAllMessage';
- switch (active) {
- case 'done':
- fn = 'getMessageDone';
- break;
- case 'todo':
- fn = 'getMessageTodo';
- break;
- case 'end':
- fn = 'getMessageEnd';
- break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return AddPartnerMyMessage;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 15, 25, 50],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- };
- getService()[getMessagetStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 同意申请
- $scope.agree = function (id) {
- AddPartner.agreeReq
- uest({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 拒绝申请
- $scope.refuse = function (id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- $scope.status = 'get';
- }]);
- /**
- * 我的合作伙伴
- */
- app.controller('MyPartnersCtrl', ['$scope', 'toaster', 'GetProductInfo', 'BaseService', function ($scope, toaster, GetProductInfo, BaseService) {
- BaseService.scrollBackToTop();
- // 默认显示合作伙伴
- $scope.status = 'news';
- // 获取所有的合作伙伴
- GetProductInfo.getAllPartners({}, function (data) {
- $scope.partners = data;
- }, function (res) {
- toaster.pop('error', '获取列表失败', res.data);
- });
- // 添加为客户
- $scope.addCust = function (partner) {
- GetProductInfo.addCust({}, partner, function (data) {
- toaster.pop('success', '提示', '添加客户成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '添加客户失败', response.data);
- });
- }
- // 添加为供应商
- $scope.addSupplier = function (partner) {
- GetProductInfo.addSupplier({}, partner, function (data) {
- toaster.pop('success', '提示', '添加供应商成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '添加供应商失败', response.data);
- });
- }
- }]);
- /**
- * 财务对账时,企业进行筛选操作
- */
- app.controller('SearchCustInfoCtrl', ['$scope', '$modalInstance', 'suuorname', 'FaApCheck', 'VendorService', 'ngTableParams', 'BaseService', function ($scope, $modalInstance, suuorname, FaApCheck, VendorService, ngTableParams, BaseService) {
- var getData = function () {
- $scope.loading = true;
- FaApCheck.getAllCustomers(function (data) {
- $scope.custs = data;
- $scope.loading = false;
- });
- };
- getData();
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
- $scope.select = function (customer) {
- if (customer.apcheck != 0) {
- $modalInstance.close(customer);
- }
- }
- $scope.close = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 跳转到企业圈
- */
- app.controller('BusinessGroupsCtrl', ['$scope', 'GetProductInfo', 'toaster', function ($scope, GetProductInfo, toaster) {
- GetProductInfo.businessGroups({}, function (data) {
- window.open(data.url);
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }]);
- /**
- * 购物车
- */
- app.controller('CartController', ['$scope', 'toaster', 'getCartList', 'ngTableParams', '$filter', 'BaseService', 'cartOperation', '$timeout', 'cartList', 'PurchaseOrder', function ($scope, toaster, getCartList, ngTableParams, $filter, BaseService, cartOperation, $timeout, cartList, PurchaseOrder) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.hasClick = false;
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? cartList : getCartList;
- };
- var getTodoCartCount = function () {
- cartOperation.getTodoCartCount({}, function (data) {
- $scope.countTodo = data.cartTodo;
- });
- };
- getTodoCartCount();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.getCartTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var changeClickStatus = function () {
- $scope.hasClick = true;
- $timeout(function () {
- $scope.hasClick = false;
- }, 500);
- }
- // 提交
- $scope.addtoOrder = function (id) {
- cartOperation.addToOrder({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- getTodoCartCount();
- $timeout(function () {
- window.location.hash = '#/purc/order/' + data.id;
- window.location.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
- // 删除一条主记录
- $scope.deleteCart = function (id) {
- changeClickStatus();
- $scope.loading = true;
- cartOperation.deleteCart({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- getTodoCartCount();
- getTodoCartCount();
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('erroer', '提示', response.data);
- });
- };
- // 删除一条明细
- $scope.deleteDetail = function (id) {
- changeClickStatus();
- $scope.loading = true;
- cartOperation.deleteCartDetail({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- $scope.loading = false;
- });
- };
- // 清空购物车
- $scope.clearCart = function () {
- changeClickStatus();
- $scope.loading = true;
- cartOperation.deleteCarts({}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- getTodoCartCount();
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- $scope.loading = false;
- });
- }
- // 复制订单
- $scope.copyorder = function (id) {
- changeClickStatus();
- $scope.loading = true;
- PurchaseOrder.copyorder({id: id}, {}, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '单据复制成功');
- getTodoCartCount();
- $scope.loading = false;
- window.location.hash = "#purc/cart/" + data.id;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- $scope.loading = false;
- });
- }
- }]);
- /**
- * 购物车详情
- */
- app.controller('CartDetailController', ['$scope', 'cartOperation', '$stateParams', 'toaster', '$timeout', 'BaseService', 'ngTableParams', '$filter', 'Product', 'Vendor', 'ShipAddress', '$modal', 'newPurcOrder', 'addtoCart', '$http', 'token', 'recentPrice',
- function ($scope, cartOperation, $stateParams, toaster, $timeout, BaseService, ngTableParams, $filter, Product, Vendor, ShipAddress, $modal, newPurcOrder, addtoCart, $http, token, recentPrice) {
- BaseService.scrollBackToTop();
- $scope.loading = true;
- var loadData = function () {
- cartOperation.getCartDetail({id: $stateParams.id}, function (data) {
- if (data.code) {
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function (item) {
- sum += item.qty * item.price;
- });
- $scope.order.total = sum;
- Vendor.contacts({venduu: $scope.order.receiveCode}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.order.venduser;
- });
- $scope.loading = false;
- } else {
- window.location.hash = '#/purc/cart';
- }
- });
- };
- loadData();
- var getToken = function() {
- token.info({userType: 'cart'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- getToken();
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- //增加商品
- $scope.addProduct = function (index) {
- if ($scope.order.orderItems[index].code == null) {
- toaster.pop('info', '提示', '请先选择商品');
- } else {
- $scope.order.orderItems.push({
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- $endDateOpen: false,
- taxrate: $scope.order.rate
- });
- }
- };
- //删除商品
- $scope.deleteProduct = function (index, id) {
- $scope.order.orderItems.splice(index, 1);
- if (id != null) {
- cartOperation.deleteCartDetail({id: id}, {}, function (data) {
- if (data.success) {
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.vendUU = $scope.order.receiveCode;
- Product.vendPord.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 选择
- $scope.check = function (data) {
- var price = null;
- var qty = null;
- var taxRate = null;
- if (data.id) {
- recentPrice.agreed({prId: data.id}, {}, function(response) {
- price = response.price;
- qty = response.qty;
- taxRate = response.taxRate;
- $scope.order.orderItems.push({
- code: data.code,
- title: data.title,
- spec: data.spec,
- unit: data.unit,
- qty: qty,
- price: price,
- remark: null,
- delivery: null,
- prid: data.id,
- taxrate: taxRate,
- prodsource: 'seller',
- });
- });
- }
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_uplodaByBatch.html',
- controller: 'PurcUploadByBatchCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.order.orderItems.push({
- code: prod.code,
- title: data.title,
- unit: 'PCS',
- spec: prod.spec,
- qty: prod.amount,
- price: prod.price,
- remark: prod.remark,
- delivery: prod.date,
- prid: prod.id,
- taxrate: prod.rate
- });
- })
- }, function () {
- });
- }
- // 删除一条主记录
- $scope.deleteCart = function (id) {
- cartOperation.deleteCart({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- window.location.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.order.orderItems[index].$endDateOpen = !openParam;
- };
- // 添加到购物车
- $scope.addToCart = function (order) {
- $scope.loading = true;
- if (order.vendor.tel != null) {
- $scope.order.vendusertel = order.vendor.tel;
- }
- if (order.vendor.venduser != null && order.vendor.tel != null) {
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- }
- if (order.shipadd != null) {
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- }
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- $scope.order.status = 311;
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 立即购买
- $scope.addToOrder = function (order) {
- $scope.loading = true;
- if (order.vendor.tel != null) {
- $scope.order.vendusertel = order.vendor.tel;
- }
- if (order.vendor.venduser != null && order.vendor.tel != null) {
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- }
- if (order.shipadd != null) {
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- }
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- $scope.order.status = 200;
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/order/' + data.id;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- // 新增供应商联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.venduu = $scope.order.receiveCode;
- Vendor.saveContact({}, $scope.contact, function (data) {
- Vendor.contacts({venduu: $scope.order.receiveCode}, {}, function (data) {
- $scope.contacts = data;
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- }]);
- /**
- * 审批流
- */
- app.controller('approvalFlowCtrl', ['$scope', 'toaster', '$modal', 'appFlow', 'BaseService', function ($scope, toaster, $modal, appFlow, BaseService) {
- BaseService.scrollBackToTop();
- $scope.vacation = false;
- $scope.workovertime = false;
- $scope.workdaily = false;
- $scope.feeplease = false;
- $scope.signapp = false;
- appFlow.viewAppFlow({}, function (data) {// 获取已设置的列表
- $scope.nodes = data;
- angular.forEach($scope.nodes, function (node) {
- if (node.appname = '请假单') {
- $scope.vacation = true;
- }
- if (node.appname = '加班单') {
- $scope.workovertime = true;
- }
- if (node.appname = '工作日报') {
- $scope.workdaily = true;
- }
- if (node.appname = '出差单') {
- $scope.feeplease = true;
- }
- if (node.appname = '申诉单') {
- $scope.signapp = true;
- }
- });
- }, function (response) {
- });
- $scope.NoteSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '请假单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.overTimeSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '加班单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.feePleaseSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '出差单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.workDailySet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '工作日报';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.signAppSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '申诉单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- }]);
- /**
- * 审核条件设置
- */
- app.controller('NoteStep1Ctrl', ['$scope', 'toaster', '$modalInstance', 'appFlow', 'AppName', '$filter', '$rootScope', function ($scope, toaster, $modalInstance, appFlow, AppName, $filter, $rootScope) {
- $scope.appName = AppName;// 标题名称
- $scope.AppFlow = {
- appName: $scope.appName,
- appNodes: {}
- };
- $scope.AppFlow.appNodes = [];
- appFlow.getNodeByName({name: AppName}, {}, function (data) {// 通过单据名称查询单个审批流
- if (data.appNodes.length != 0) {
- $scope.node = data;
- $scope.AppFlow = data;
- }
- }, function () {
- });
- $scope.copy = function () {//复制
- $rootScope.flowcopy = angular.copy($scope.AppFlow);
- toaster.pop('info', '提示', '复制成功');
- $modalInstance.dismiss();
- }
- $scope.paste = function () {
- $scope.AppFlow = {appName: $scope.appName, appNodes: {}};
- $scope.AppFlow.appNodes = $rootScope.flowcopy.appNodes;
- }
- $scope.clear = function () {// 清空
- $scope.AppFlow = {
- appName: $scope.appName,
- appNodes: {}
- };
- $scope.AppFlow.appNodes = [];
- }
- appFlow.getPositions({}, function (data) {// 获取人员信息
- $scope.users = data;
- }, function (response) {
- });
- appFlow.getPositionInfo({}, function (data) { // 获取职位信息
- $scope.roles = data;
- }, function (response) {
- });
- $scope.SelectUser = function (data) { // 添加人员
- var item = {
- useruu: null,
- username: null,
- level: null
- };
- item.useruu = data.useruu;
- item.username = data.username;
- $scope.AppFlow.appNodes.push(item);
- }
- $scope.SelectRole = function (data) {// 添加职位
- var item = {
- position: null,
- level: null
- };
- item.position = data;
- $scope.AppFlow.appNodes.push(item);
- }
- $scope.deleteNode = function (index) {// 删除节点
- $scope.AppFlow.appNodes.splice(index, 1);
- };
- $scope.saveNode = function () { // 保存
- angular.forEach($scope.AppFlow.appNodes, function (value, key) {
- $scope.AppFlow.appNodes[key].level = key;
- });
- if ($scope.AppFlow.appNodes.length == 0) {
- toaster.pop('info', '提示', '您还未设置审批人');
- } else {
- $modalInstance.close($scope.AppFlow);
- }
- ;
- };
- $scope.cancel = function () {// 取消
- $modalInstance.dismiss();
- }
- }]);
- /***
- * 代采定单
- */
- app.controller('DeputyOrderCtrl', ['$scope', 'toaster', 'getDeOrder', 'ngTableParams', 'BaseService', 'DeputyOrder', 'ReportService', 'getOrderInfo', '$modal', 'CurrentRole', function ($scope, toaster, getDeOrder, ngTableParams, BaseService, DeputyOrder, ReportService, getOrderInfo, $modal, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.total = null;
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.agreedText = '全部';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.searchMethod = false;
- var getSerivce = function() {
- return $scope.searchMethod ? getDeOrder : getOrderInfo;
- }
- getSerivce();
-
- // 获取订单总金额
- var getOrdersAmount = function() {
- DeputyOrder.odersAmount({}, function(data) {
- $scope.odersAmount = data.amount;
- });
- }
-
- getOrdersAmount();
-
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {'date': 'desc', 'id': 'desc'}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getSerivce()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //打印
- $scope.print = function (deputyOrder) {
- DeputyOrder.printCount({id: deputyOrder.id}, {});//增加打印此次
- $scope.tableParams.reload();
- ReportService.print(deputyOrder.deputyuu, 'PURCNOTICE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 定向采购通知
- ReportService.print(deputyOrder.deputyuu, 'PURCHASE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 采购订单
- ReportService.print(deputyOrder.deputyuu, 'PAYCONFIRM', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 付款确认
- ReportService.print(deputyOrder.deputyuu, 'TRADECONTRACT', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 买卖合同
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 复制采购单
- $scope.copyorder = function (id) {
- $scope.loading = true;
- DeputyOrder.copyOrder({id: id}, {}, function (data) {
- $scope.loading = false;
- if (data.id) {
- toaster.pop('success', '提示', '复制生成单据成功');
- window.location.hash = "#/purc/deputy/" + data.id;
- }
- if (data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- // 删除代采订单
- $scope.clear = function (id) {
- $scope.loading = true;
- DeputyOrder.clearOrder({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
-
- $scope.viewApprove = function(salecode, uu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/approval_detail.html',
- controller: 'ViewApprovalDetailCtrl',
- resolve: {
- uu: function () {
- return uu
- },
- salecode: function () {
- return salecode
- }
- }
- });
- }
- }]);
- // 查询代采定单在信扬中的审批情况
- app.controller('ViewApprovalDetailCtrl', ['$scope', 'toaster', '$modalInstance', 'DeputyOrder', 'BaseService', 'ngTableParams', 'uu', 'salecode', function ($scope, toaster, $modalInstance, DeputyOrder, BaseService, ngTableParams, uu, salecode) {
- DeputyOrder.approve({uu: uu, code: salecode}, {}, function (data) {
- $scope.nodes = data.nodes;
- $scope.process = data.process;
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', '暂未获取到相关单据的信息');
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.select = function (company) { // 直接选择
- $modalInstance.close(company);
- }
- }]);
- /**
- * 新增代采订单
- */
- app.controller('NewDeputyOrderCtrl', ['$scope', 'toaster', '$modal', 'DeputyOrder', '$filter', 'ngTableParams', 'BaseService', 'DecimalNumber', 'DekeyValue', function ($scope, toaster, $modal, DeputyOrder, $filter, ngTableParams, BaseService, DecimalNumber, DekeyValue) {
- BaseService.scrollBackToTop();
- //默认采购单号不重复
- $scope.orderCodeEnable = true;
- $scope.deOrder = {
- code: 'DC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- entrydate: new Date(),
- status: '在录入',
- goodspacking: '供应商原厂包装,如外包装完好视为货物完好',
- pickupdate: '我方自向贵公司支付货款之日起3个自然日内提货完毕',
- riskmethod: '甲方承担',
- taxpaymentmethod: '甲方承担',
- totalamount: 0,
- totalpayament: 0,
- orderamount: 0,
- usdpayment: 0
- };
- $scope.deOrder.deputyOrderItems = [];
- var item = {
- prodname: null,
- prodcode: null,
- prodspec: null,
- amount: null,
- unitprice: null,
- purcprice: null,
- remark: null,
- orderprice: null,
- };
- $scope.deOrder.deputyOrderItems.push(item);
- // 代采企业列表
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEnterprises = data;
- $scope.deOrder.deputyname = $scope.deputyEnterprises[0].deputyenname;
- $scope.deOrder.deputyuu = $scope.deputyEnterprises[0].deputyenuu;
- getPayMethod($scope.deOrder.deputyuu, 'paymentmethod');
- });
- var getPayMethod = function(enuu, key) {
- // 获取我方付款支付方式默认值
- DekeyValue.getValue({enuu: enuu, key: key}, function(data) {
- $scope.methods = data.content;
- });
- }
- // 更新名称时后台更改uu号
- $scope.change = function (deputyname) {
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEn = data;
- angular.forEach($scope.deputyEn, function (en) {
- if (deputyname == en.deputyenname) {
- $scope.deputyuu = en.deputyenuu;
- getPayMethod($scope.deputyuu, 'paymentmethod');
- }
- });
- });
- }
- // 查找付款企业
- $scope.dbfindPayCompany = function (deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/payCompany.html',
- controller: 'DbfindDeputyPayCompanyCtrl',
- resolve: {
- deputyuu: function () {
- return deputyuu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.deOrder.paycomname = data.enname;
- $scope.deOrder.paycomaddress = data.address;
- })
- }
- // 查询上次的关键词记录
- $scope.getHisKeyword = function (tervendor) {
- DeputyOrder.hisKeywords({tervendor: tervendor}, {}, function (data) {
- $scope.deOrder.vendtel = data.vendtel;
- $scope.deOrder.venduser = data.venduser;
- $scope.deOrder.otherdata = data.otherdata;
- $scope.deOrder.companyname = data.companyname;
- $scope.deOrder.bankaccount = data.bankaccount;
- $scope.deOrder.bankaddress = data.bankaddress;
- $scope.deOrder.bankcode = data.bankcode;
- $scope.deOrder.bankname = data.bankname;
- $scope.deOrder.legalrepresent = data.legalrepresent;
- $scope.deOrder.tervendaddress = data.tervendaddress;
- $scope.deOrder.enfax = data.enfax;
- $scope.deOrder.deliverymethod = data.deliverymethod;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 查询历史供应商
- DeputyOrder.hisvendors({}, function (data) {
- $scope.hisvendors = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- // 上次填写记录(不关联供应商)
- DeputyOrder.lastKeywords({}, function (data) {
- $scope.lastkeyowrds = data;
- $scope.deOrder.madealdate = $scope.lastkeyowrds.madealdate;
- $scope.deOrder.madealcode = $scope.lastkeyowrds.madealcode;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- //增加商品
- $scope.add = function (index) {
- if ($scope.deOrder.deputyOrderItems[index].prodcode == null) {
- toaster.pop('info', '提示', '请先填写商品信息');
- } else {
- $scope.deOrder.deputyOrderItems.push(
- {
- prodname: null,
- prodcode: null,
- prodspec: null,
- prodbrand: null,
- amount: null,
- unitprice: null,
- purcprice: null,
- remark: null,
- orderprice: null
- });
- }
- };
- //删除商品
- $scope.del = function (index) {
- $scope.deOrder.deputyOrderItems.splice(index, 1);
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'DeputyOrderUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (data) {
- $scope.deOrder.deputyOrderItems.push(data);
- for (var i = 0; i < $scope.deOrder.deputyOrderItems.length; i++) {
- if ($scope.deOrder.deputyOrderItems[i].prodname == null) { // 如果没有填写就删除这行数据
- $scope.deOrder.deputyOrderItems.splice(i, 1);
- }
- }
- })
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }, function () {
- });
- }
- // 查找供应商
- $scope.dbfindVendor = function (deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
- controller: 'DbfindDeputyVendorInfoCtrl',
- size: 'lg',
- resolve: {
- deputyuu: function () {
- return deputyuu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.deOrder.customer = data.vendorEnterprise.enName;
- $scope.deOrder.legalrepresent = data.vendorUser.userName;
- $scope.deOrder.enaddress = data.vendorEnterprise.enAddress;
- $scope.deOrder.usertel = data.vendorUser.userTel;
- })
- }
- // 检验订单编号是否存在
- $scope.checkOrder = function (salecode, deputyuu) {
- DeputyOrder.checkOrders({salecode: salecode, deputyuu: deputyuu}, {}, function (data) {
- $scope.orderCodeEnable = true;
- if (data.info) {
- toaster.pop('error', '提示', data.info);
- $scope.orderCodeEnable = false;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- //计算采购单价
- $scope.checkPrice = function (rate) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- if (rate == null) {
- toaster.pop('info', '提示', '请先填入税率');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- item.purcprice = DecimalNumber.accMul(item.unitprice, (1 + rate / 100));
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }
- }
- // 获取订单总价
- $scope.totalPrice = function () {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- if(item.amount != null && item.unitprice != null && item.purcprice != null) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- }
- });
- }
-
- $scope.checkresult = false;
- var checkKeyword = function () {
- if ($scope.deOrder.madealdate == null) {
- toaster.pop('info', '提示', '主协议签订日期未选择');
- } else if ($scope.deOrder.madealcode == null) {
- toaster.pop('info', '提示', '主协议签订编号未填写');
- } else if ($scope.deOrder.tervendor == null) {
- toaster.pop('info', '提示', '终端供应商名称未填写');
- } else if ($scope.deOrder.vendtel == null) {
- toaster.pop('info', '提示', '电话号码未填写');
- } else if ($scope.deOrder.venduser == null) {
- toaster.pop('info', '提示', '联系人未填写');
- } else if ($scope.deOrder.shipdate == null) {
- toaster.pop('info', '提示', '供应商发货时间未选择');
- } else if ($scope.deOrder.goodspacking == null) {
- toaster.pop('info', '提示', '货物包装要求未填写');
- } else if ($scope.deOrder.deliverymethod == null) {
- toaster.pop('info', '提示', '供应商交货方式未填写');
- } else if ($scope.deOrder.pickupmethod == null) {
- toaster.pop('info', '提示', '我方提货方式未填写');
- } else if ($scope.deOrder.paymentmethod == null) {
- toaster.pop('info', '提示', '我方付款方式未填写');
- } else if ($scope.deOrder.pickupdate == null) {
- toaster.pop('info', '提示', '我方提货时间未选择');
- } else if ($scope.deOrder.currency == null) {
- toaster.pop('info', '提示', '交易币别未选择');
- } else if ($scope.deOrder.deputyuu == null) {
- toaster.pop('info', '提示', '代采企业未选择');
- } else if ($scope.deOrder.salecode == null) {
- toaster.pop('info', '提示', '订单编号未填写');
- } else if ($scope.deOrder.paydeldate == null) {
- toaster.pop('info', '提示', '我方付款提货时间未选择');
- } else if ($scope.deOrder.riskmethod == null) {
- toaster.pop('info', '提示', '风险承担方式未填写');
- } else if ($scope.deOrder.taxpaymentmethod == null) {
- toaster.pop('info', '提示', '运、税费承担方式');
- } else if ($scope.deOrder.tervendaddress == null) {
- toaster.pop('info', '提示', '终端供应商地址未填写');
- } else if ($scope.deOrder.companyname == null) {
- toaster.pop('info', '提示', '公司全称(英文)未填写');
- } else if ($scope.deOrder.requirepaydate == null) {
- toaster.pop('info', '提示', '要求付汇日期未选择');
- } else if ($scope.deOrder.bankname == null) {
- toaster.pop('info', '提示', '银行名称(英文)未填写');
- } else if ($scope.deOrder.bankaccount == null) {
- toaster.pop('info', '提示', '银行账号未填写');
- } else if ($scope.deOrder.bankaddress == null) {
- toaster.pop('info', '提示', '银行地址未填写');
- } else if ($scope.deOrder.bankcode == null) {
- toaster.pop('info', '提示', '银行代码未填写');
- } else if ($scope.deOrder.salepocode == null) {
- toaster.pop('info', '提示', '合同编号未填写');
- } else if ($scope.deOrder.legalrepresent == null) {
- toaster.pop('info', '提示', '供应商方法定代表人未填写');
- } else if ($scope.deOrder.paycomname == null) {
- toaster.pop('info', '提示', '付款公司未填写');
- } else if ($scope.deOrder.paycomaddress == null) {
- toaster.pop('info', '提示', '付款公司地址未填写');
- } else if ($scope.deOrder.enfax == null) {
- toaster.pop('info', '提示', '供应商方法人电话未填写');
- } else if ($scope.deOrder.paydate == null) {
- toaster.pop('info', '提示', '货款支付时间未选择');
- } else if ($scope.deOrder.paymethod == null) {
- toaster.pop('info', '提示', '货款支付方式未填写');
- } else if ($scope.deOrder.deliverydate == null) {
- toaster.pop('info', '提示', '交货时间未选择');
- } else if (!$scope.orderCodeEnable) {
- toaster.pop('info', '提示', '采购单号重复');
- } else if ($scope.deOrder.currency == 'USD' && $scope.deOrder.totalpayament >= 300 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过300万美金');
- } else if ($scope.deOrder.currency == 'RMB' && $scope.deOrder.totalpayament >= 1000 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过1000万人民币');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (orderitem, index) {
- if (orderitem.prodname == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品名称未填写');
- } else if (orderitem.prodcode == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品编号未填写');
- } else if (orderitem.prodspec == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品规格未填写');
- } else if (orderitem.prodbrand == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品品牌未填写');
- } else if (orderitem.amount == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行数量未填写');
- } else if (orderitem.unitprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行单价未填写');
- } else if (orderitem.purcprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行订单单价未填写');
- } else {
- $scope.checkresult = true;
- $scope.isSave = true;
- }
- })
- };
- }
- // 保存
- $scope.isSave = false;
- $scope.save = function (status) {
- $scope.deOrder.entrystatus = status;
- checkKeyword();
- if ($scope.checkresult) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- if ($scope.deOrder.deputyOrderItems[0].prodcode == null) {
- toaster.pop('info', '提示', '您还未填写任何商品信息');
- } else {
- DeputyOrder.saveDeOrder({}, $scope.deOrder, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', status + '成功');
- window.location.hash = "#/purc/deputy/" + data.id;
- }
- if (data.error) {
- toaster.pop('error', '提示', status + '失败');
- }
- }, function (response) {
- });
- }
- }
- }
- $scope.openDatePicker = function ($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
- }]);
- // 代采企业供应商
- app.controller('DbfindDeputyVendorInfoCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', 'deputyuu', 'DeputyOrder', 'BaseService', 'ngTableParams', function ($scope, toaster, $upload, $modalInstance, deputyuu, DeputyOrder, BaseService, ngTableParams) {
- $scope.prod = false;
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.enuu = deputyuu;
- DeputyOrder.vendors.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.checkVendor = function (vendor) { // 直接选择
- $modalInstance.close(vendor);
- }
- }]);
- // 代采企业付款企业
- app.controller('DbfindDeputyPayCompanyCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', 'deputyuu', 'DeputyOrder', 'BaseService', 'ngTableParams', function ($scope, toaster, $upload, $modalInstance, deputyuu, DeputyOrder, BaseService, ngTableParams) {
- DeputyOrder.paycompanies({enuu: deputyuu}, {}, function (data) {
- $scope.paycompanies = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.select = function (company) { // 直接选择
- $modalInstance.close(company);
- }
- }]);
- /**
- * 代采订单批量导入
- */
- app.controller('DeputyOrderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function () {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'deputyOrder/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- toaster.pop('error', response.data || response);
- });
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'deputyOrder/upload/template';
- };
- $scope.enSure = function () {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 代采详情
- */
- app.controller('DeputyOrderDetailCtrl', ['$scope', 'toaster', 'DeputyOrder', '$stateParams', 'ngTableParams', 'BaseService', '$modal', 'DecimalNumber', 'CurrentRole', 'DekeyValue', function ($scope, toaster, DeputyOrder, $stateParams, ngTableParams, BaseService, $modal, DecimalNumber, CurrentRole, DekeyValue) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- DeputyOrder.getOrderDetail({id: $stateParams.id}, {}, function (data) {
- $scope.deOrder = data;
- $scope.deOrder.$editing = true;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- //默认采购单号不重复
- $scope.orderCodeEnable = true;
- // 查询历史供应商
- DeputyOrder.hisvendors({}, function (data) {
- $scope.hisvendors = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- // 代采企业列表
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEnterprises = data;
- $scope.deOrder.deputyname = $scope.deputyEnterprises[0].deputyenname;
- $scope.deOrder.deputyuu = $scope.deputyEnterprises[0].deputyenuu;
- getPayMethod($scope.deOrder.deputyuu, 'paymentmethod');
- });
- var getPayMethod = function(enuu, key) {
- // 获取我方付款支付方式默认值
- DekeyValue.getValue({enuu: enuu, key: key}, function(data) {
- $scope.methods = data.content;
- });
- }
- // 更新代采企业时更新费率
- $scope.change = function (deputyname) {
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEn = data;
- angular.forEach($scope.deputyEn, function (en) {
- if (deputyname == en.deputyenname) {
- $scope.deputyuu = en.deputyenuu;
- getPayMethod($scope.deputyuu, 'paymentmethod');
- }
- });
- });
- }
- // 查找付款企业
- $scope.dbfindPayCompany = function (deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/payCompany.html',
- controller: 'DbfindDeputyPayCompanyCtrl',
- resolve: {
- deputyuu: function () {
- return deputyuu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.deOrder.paycomname = data.enname;
- $scope.deOrder.paycomaddress = data.address;
- })
- }
- // 删除明细
- $scope.del = function (index, id) {
- DeputyOrder.deleteProdById({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.deOrder.deputyOrderItems.splice(index, 1)
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- //增加商品
- $scope.add = function (index) {
- if ($scope.deOrder.deputyOrderItems[index].prodcode == null) {
- toaster.pop('info', '提示', '请先填写商品信息');
- } else {
- $scope.deOrder.deputyOrderItems.push(
- {
- prodname: null,
- prodcode: null,
- prodspec: null,
- prodbrand: null,
- amount: null,
- unitprice: null,
- remark: null,
- orderprice: null
- });
- }
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'DeputyOrderUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (data) {
- $scope.deOrder.deputyOrderItems.push(data);
- for (var i = 0; i < $scope.deOrder.deputyOrderItems.length; i++) {
- if ($scope.deOrder.deputyOrderItems[i].prodname == null) { // 如果没有填写就删除这行数据
- $scope.deOrder.deputyOrderItems.splice(i, 1);
- }
- }
- })
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }, function () {
- });
- }
- //删除商品
- $scope.delItem = function (index) {
- $scope.deOrder.deputyOrderItems.splice(index, 1);
- };
- var getService = function () {
- return DeputyOrder.getProdList;
- };
- $scope.update = function () {
- $scope.deOrder.$editing = true;
- }
- $scope.cancel = function () {
- $scope.deOrder.$editing = false;
- }
- // 检验订单编号是否存在
- $scope.checkOrder = function (salecode, deputyuu) {
- DeputyOrder.checkOrders({salecode: salecode, deputyuu: deputyuu}, {}, function (data) {
- $scope.orderCodeEnable = true;
- if (data.info) {
- toaster.pop('error', '提示', data.info);
- $scope.orderCodeEnable = false;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- //计算采购单价
- $scope.checkPrice = function (rate) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- if (rate == null) {
- toaster.pop('info', '提示', '请先填入税率');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- item.purcprice = DecimalNumber.accMul(item.unitprice, (1 + rate / 100));
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }
- }
- // 获取订单总价
- $scope.totalPrice = function () {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- if(item.amount != null && item.unitprice != null && item.purcprice != null) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- }
- });
- }
- $scope.checkresult = false;
- var checkKeyword = function () {
- if ($scope.deOrder.madealdate == null) {
- toaster.pop('info', '提示', '主协议签订日期未选择');
- } else if ($scope.deOrder.madealcode == null) {
- toaster.pop('info', '提示', '主协议签订编号未填写');
- } else if ($scope.deOrder.tervendor == null) {
- toaster.pop('info', '提示', '终端供应商名称未填写');
- } else if ($scope.deOrder.vendtel == null) {
- toaster.pop('info', '提示', '电话号码未填写');
- } else if ($scope.deOrder.venduser == null) {
- toaster.pop('info', '提示', '联系人未填写');
- } else if ($scope.deOrder.shipdate == null) {
- toaster.pop('info', '提示', '供应商发货时间未选择');
- } else if ($scope.deOrder.goodspacking == null) {
- toaster.pop('info', '提示', '货物包装要求未填写');
- } else if ($scope.deOrder.deliverymethod == null) {
- toaster.pop('info', '提示', '供应商交货方式未填写');
- } else if ($scope.deOrder.pickupmethod == null) {
- toaster.pop('info', '提示', '我方提货方式未填写');
- } else if ($scope.deOrder.paymentmethod == null) {
- toaster.pop('info', '提示', '我方付款方式未填写');
- } else if ($scope.deOrder.pickupdate == null) {
- toaster.pop('info', '提示', '我方提货时间未选择');
- } else if ($scope.deOrder.currency == null) {
- toaster.pop('info', '提示', '交易币别未选择');
- } else if ($scope.deOrder.deputyuu == null) {
- toaster.pop('info', '提示', '代采企业未选择');
- } else if ($scope.deOrder.salecode == null) {
- toaster.pop('info', '提示', '订单编号未填写');
- } else if ($scope.deOrder.paydeldate == null) {
- toaster.pop('info', '提示', '我方付款提货时间未选择');
- } else if ($scope.deOrder.riskmethod == null) {
- toaster.pop('info', '提示', '风险承担方式未填写');
- } else if ($scope.deOrder.taxpaymentmethod == null) {
- toaster.pop('info', '提示', '运、税费承担方式');
- } else if ($scope.deOrder.tervendaddress == null) {
- toaster.pop('info', '提示', '终端供应商地址未填写');
- } else if ($scope.deOrder.companyname == null) {
- toaster.pop('info', '提示', '公司全称(英文)未填写');
- } else if ($scope.deOrder.requirepaydate == null) {
- toaster.pop('info', '提示', '要求付汇日期未选择');
- } else if ($scope.deOrder.bankname == null) {
- toaster.pop('info', '提示', '银行名称(英文)未填写');
- } else if ($scope.deOrder.bankaccount == null) {
- toaster.pop('info', '提示', '银行账号未填写');
- } else if ($scope.deOrder.bankaddress == null) {
- toaster.pop('info', '提示', '银行地址未填写');
- } else if ($scope.deOrder.bankcode == null) {
- toaster.pop('info', '提示', '银行代码未填写');
- } else if ($scope.deOrder.salepocode == null) {
- toaster.pop('info', '提示', '合同编号未填写');
- } else if ($scope.deOrder.legalrepresent == null) {
- toaster.pop('info', '提示', '供应商方法定代表人未填写');
- } else if ($scope.deOrder.paycomname == null) {
- toaster.pop('info', '提示', '付款公司未填写');
- } else if ($scope.deOrder.paycomaddress == null) {
- toaster.pop('info', '提示', '付款公司地址未填写');
- } else if ($scope.deOrder.enfax == null) {
- toaster.pop('info', '提示', '供应商方法人电话未填写');
- } else if ($scope.deOrder.paydate == null) {
- toaster.pop('info', '提示', '货款支付时间未选择');
- } else if ($scope.deOrder.paymethod == null) {
- toaster.pop('info', '提示', '货款支付方式未填写');
- } else if ($scope.deOrder.deliverydate == null) {
- toaster.pop('info', '提示', '交货时间未选择');
- } else if (!$scope.orderCodeEnable) {
- toaster.pop('info', '提示', '采购单号重复');
- } else if ($scope.deOrder.currency == 'USD' && $scope.deOrder.totalpayament >= 300 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过300万美金');
- } else if ($scope.deOrder.currency == 'RMB' && $scope.deOrder.totalpayament >= 1000 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过1000万人民币');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (orderitem, index) {
- if (orderitem.prodname == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品名称未填写');
- } else if (orderitem.prodcode == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品编号未填写');
- } else if (orderitem.prodspec == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品规格未填写');
- } else if (orderitem.prodbrand == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品品牌未填写');
- } else if (orderitem.amount == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行数量未填写');
- } else if (orderitem.unitprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行单价未填写');
- } else if (orderitem.purcprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行订单单价未填写');
- } else {
- $scope.checkresult = true;
- $scope.isSave = true;
- }
- });
- }
- }
- // 保存
- $scope.isSave = false;
- $scope.save = function (status) {
- checkKeyword();
- if ($scope.checkresult) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- if ($scope.deOrder.deputyOrderItems[0].prodcode == null) {
- toaster.pop('info', '提示', '您还未填写任何商品信息');
- } else {
- $scope.deOrder.entrystatus = status;
- DeputyOrder.saveDeOrder({}, $scope.deOrder, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '保存成功');
- loadData();
- window.location.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function (response) {
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- $scope.openDatePicker = function ($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
- //复制采购单
- $scope.copyorder = function (id) {
- DeputyOrder.copyOrder({id: id}, {}, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '复制生成单据成功');
- window.location.hash = "#/purc/deputy/" + data.id;
- }
- if (data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 删除代采订单
- $scope.clear = function (id) {
- DeputyOrder.clearOrder({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- window.location.hash = "#/purc/deputy";
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 代采错误日志
- */
- app.controller('DeputyOrderLogCtrl', ['$scope', 'DeputyOrder', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', function ($scope, DeputyOrder, ngTableParams, $filter, BaseService, toaster, $timeout) {
- BaseService.scrollBackToTop();
- var getService = function () {
- return DeputyOrder.getRepetitions;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //删除
- $scope.deleteById = function (id) {
- GetProductInfo.deleteById({id: id}, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function (response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
- }]);
- /**
- * 招标单
- */
- app.controller('PurcTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams',
- '$modal', '$rootScope', 'PurcTenderInfo', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, PurcTenderInfo) {
- BaseService.scrollBackToTop();
- $scope.searchStatus = false;
- if ($rootScope.tenderActive) {
- $scope.active = $rootScope.tenderActive;
- $rootScope.tenderActive = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getTenderStatus = function (active) {
- var fn = 'getMyAll';
- switch (active) {
- case 'done':
- fn = 'getMyDone';
- break;
- case 'todo':
- fn = 'getMyTodo';
- break;
- // case 'end':
- // fn = 'getMyEnd';break;
- case 'waiting':
- fn = 'getMyWaiting';
- break;
- }
- return fn;
- };
- var getService = function () {
- if ($scope.searchStatus) {
- return PurcTender;
- }
- return PurcTenderInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getTenderStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcTender.getPurcUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcTender.setPurcRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcTender.getPurcUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (tender){
- for (var i in $scope.unreadCode) {
- if (tender.id == $scope.unreadCode[i]) {
- var flag = tender.status == '待评标' && tender.overdue == 1 && tender.result != 1;
- if (!flag) {
- $scope.unreadCode.splice(i,1);
- return false;
- }
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.searchStatus = true;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 新增招标单
- */
- app.controller('PurcNewTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'ShipAddress', '$http', 'AuthenticationService', 'KindAPI', 'BrandActiveAPI', 'Search', 'ComponentActiveAPI', 'GetProductInfo', 'Vendor', 'PurcProduct', 'PurcProductNewest', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, ShipAddress, $http, AuthenticationService, KindAPI, BrandActiveAPI, Search, ComponentActiveAPI, GetProductInfo, Vendor, PurcProduct, PurcProductNewest) {
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcProduct : PurcProductNewest;
- };
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //在产品列表添加商品
- $scope.check = function (product) {
- $scope.tenderProd.push({
- prodTitle: product.title,
- prodCode: product.code,
- brand: product.brand,
- unit: product.unit,
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- });
- for (var i = 0; i < $scope.tenderProd.length; i++) {
- if ($scope.tenderProd[i].prodCode === null && $scope.tenderProd[i].prodTitle === null) { // 如果没有填写就删除这行数据
- $scope.tenderProd.splice(i, 1);
- }
- }
- };
- $scope.loading = false;
- // 获取收货地址列表
- var loadShipAddress = function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.tender.shipadd = $scope.ships[0];
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- // 可选的证照要求
- $scope.certificates = [{name: '三/五证合一'}, {name: '营业执照'}, {name: '组织机构代码证'}, {name: '一般纳税人证明材料'}, {name: '统计登记证'}, {name: '社会保险登记证'}];
- // 处理证照要求
- var parseCertificate = function (a) {
- if (a) {
- var arr = a.split(',');
- angular.forEach(arr, function (app) {
- var contained = false;
- angular.forEach($scope.certificates, function ($app) {
- if ($app.name == app) {
- $app.checked = true;
- contained = true;
- }
- });
- if (!contained) {
- $scope.certificates.push({name: app, checked: true});
- }
- });
- }
- };
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function (value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function (value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- // 选择类目
- $scope.selectKind = function (prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function () {
- return $scope.actives;
- }
- }
- }).result.then(function (data) {
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function () {
- });
- };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function (brand, prod) {
- if (brand instanceof String) {
- prod.brand = brand;
- } else if (brand instanceof Object) {
- prod.brand = brand.brandCn;
- }
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function (prod) { //打开模态
- var modalInstance = $modal.open({
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller: 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function () {// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function (brand) {
- prod.brand = brand.nameCn;
- }, function (reason) {
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function (cmp, prod) {
- ComponentActiveAPI.get({uuid: cmp.uuid}, {}, function (data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.brand = data.brand.nameCn;
- }, function (res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- $scope.condition = {dateZone: 1};
- $scope.tenderProd = [];
- var prod = {
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- };
- $scope.tender = {
- date: new Date(),
- unit: 'PCS',
- currency: 'RMB',
- ifOpen: 1,
- ifTax: 1,
- invoiceType: 2,
- tenderAttachs: [{}]
- };
- //
- $scope.tenderProd.push(prod);
- //增加商品
- $scope.add = function (index) {
- $scope.tenderProd.push({
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- });
- };
- //删除商品
- $scope.del = function (index) {
- $scope.tenderProd.splice(index, 1);
- };
- // 批量导入
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcTenderUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- // 获取上传的产品明细,前台展示
- angular.forEach(data, function (data) {
- $scope.tenderProd.push(data);
- for (var i = 0; i < $scope.tenderProd.length; i++) {
- if ($scope.tenderProd[i].prodTitle == null) { // 如果没有填写就删除这行数据
- $scope.tenderProd.splice(i, 1);
- }
- }
- });
- }, function () {
- });
- };
- $scope.isSave = false;
- // 已存在id的为查看招标单(用于在录入的招标单的发布和删除)
- if (!angular.isUndefined($stateParams.id)) {
- $scope.isSave = true; // 用于判断是新增还是已保存
- $scope.loading = true;
- PurcTender.getPurcTenderDetail({id: $stateParams.id}, function (data) {
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- parseCertificate($scope.tender.certificate);
- $scope.firstProd = data.purchaseTenderProds[0];
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function (item) {
- // 获取供应商联系人
- Vendor.contacts({venduu: item.saleTender.vendUU}, {}, function (data) {
- item.saleTender.enterpriseBaseInfo.contacts = data;
- // item.saleTender.enterpriseBaseInfo.contact = data[0];
- angular.forEach(item.saleTender.enterpriseBaseInfo.contacts, function (contact) {
- if (item.saleTender.userTel === contact.tel) {
- item.saleTender.enterpriseBaseInfo.contact = contact;
- }
- });
- });
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, item.saleTender.enterpriseBaseInfo);
- } else {
- $scope.tenderProd.enterpriseBaseInfo.push(item.saleTender.enterpriseBaseInfo);
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- if (angular.isUndefined($stateParams.id)) { // 发布招标单之后,再次新增招标单时,新增供应商时不会勾选上一个单据选择的供应商
- $rootScope.tenderVendor = [{}];
- }
- $scope.changeShipAddress = false;
- $scope.changeAddress = function () {
- if ($scope.changeShipAddress) {
- $scope.changeShipAddress = false;
- } else {
- $scope.changeShipAddress = true;
- }
- };
- $scope.changeContactInfo = function (en) {
- if (en.changeContact) {
- en.changeContact = false;
- } else {
- en.changeContact = true;
- }
- };
- $scope.changeCurrency = function (tender) {
- if (tender.currency !== 'RMB') {
- $scope.notRMB = true;
- tender.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- tender.invoiceType = 0;
- } else {
- $scope.notRMB = false;
- }
- };
- // 查找供应商
- $scope.dbfindVendor = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {}
- });
- var ifPush = true;
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (vendor) {
- // 获取供应商联系人
- Vendor.contacts({venduu: vendor.vendorEnterprise.uu}, {}, function (data) {
- vendor.vendorEnterprise.contacts = data;
- $scope.tenderProd.enterpriseBaseInfo.contact = vendor.vendorEnterprise.contacts[0];
- });
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- // 获取供应商联系人
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0; i < $scope.tenderProd.enterpriseBaseInfo.length; i++) {
- ifPush = true;
- if ($scope.tenderProd.enterpriseBaseInfo[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.tenderProd.enterpriseBaseInfo.push(vendor.vendorEnterprise);
- }
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- }, function () {
- });
- };
- // 新增供应商联系人
- $scope.addContact = function (en) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- en.contact = data;
- en.contact.venduu = en.uu;
- Vendor.saveContact({}, en.contact, function (data) {
- Vendor.contacts({venduu: en.uu}, {}, function (data) {
- en.contacts = data;
- en.contact = data[0]; // 新增的作为联系人
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function (index) {
- $scope.tenderProd.enterpriseBaseInfo.splice(index, 1);
- };
- // 删除供应商时,后台删除投标单
- $scope.removeSaleTender = function (id, vendUU) {
- var hasSaved = false;
- angular.forEach($scope.tender.purchaseTenderProds[0].saleTenderItems, function (saleTenderItem) {
- if (saleTenderItem.saleTender.vendUU === vendUU) { //有相等的说明是之前保存过的供应商
- hasSaved = true;
- }
- });
- if (hasSaved) {
- PurcTender.removeSaleTender({id: id, vendUU: vendUU}, {}, function (data) {
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- };
- // 删除产品明细时,后台删除产品明细
- $scope.deleteProd = function (tenderProd) {
- if (tenderProd.id) {
- PurcTender.deleteProd({tenderProdId: tenderProd.id}, {}, function (data) {
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- };
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- $scope.upload = function (myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderAttach',
- file: file,
- method: 'POST'
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function (id, index) {
- $scope.attaches.splice(index, 1);
- };
- var sleep = function (d) {
- for (var t = Date.now(); Date.now() - t <= d;);
- };
- // 保存和发布招标单
- $scope.save = function (isPublish) {
- if ($scope.tender.ifOpen == 0 && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info', '提示', '请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function (certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if (!$scope.tender.code) { //新增,设单号
- $scope.tender.code = 'ZB' + $filter('date')(new Date(), 'yyMMddHHmmss');
- }
- if ($scope.tender.date instanceof Date) {
- $scope.tender.date = $scope.tender.date.getTime();
- }
- if ($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if ($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- if ($scope.tender.questionEndDate instanceof Date) {
- $scope.tender.questionEndDate = $scope.tender.questionEndDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- var enInfos = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function (enterpriseBaseInfo) {
- var enInfo = {
- uu: null,
- contact: null,
- contactTel: null
- };
- enInfo.uu = enterpriseBaseInfo.uu;
- if (typeof enterpriseBaseInfo.contact !== 'undefined') {
- enInfo.contact = enterpriseBaseInfo.contact.venduser;
- enInfo.contactTel = enterpriseBaseInfo.contact.tel;
- }
- enInfos.push(enInfo);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- $scope.tender.isPublish = 1;
- PurcTender.publish({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- // sleep(1500); //当前方法暂停1.5秒
- $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- $scope.tender.isPublish = 0;
- PurcTender.save({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- $scope.loading = false;
- // sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- // 切换为在平台公开招标时,清除掉已添加的供应商信息
- $scope.removeChecked = function () {
- if ($scope.tenderProd.enterpriseBaseInfo.size > 0) {
- $scope.tenderProd.enterpriseBaseInfo = [];
- }
- };
- // 删除(在录入状态)
- $scope.deleteThis = function (id) {
- PurcTender.deleteOne({id: id}, {}, function (data) {
- toaster.pop('info', '提示', '删除成功');
- window.location.hash = '#/purc/tender';
- });
- };
- // 更新和发布(在录入状态)
- $scope.updateSaved = function (isPublish) {
- if (Number($scope.tender.ifOpen) === 0 && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info', '提示', '请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function (certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if ($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if ($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- if ($scope.tender.shipadd) {
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- }
- angular.forEach($scope.tender.purchaseTenderProds, function (tenderProd) {
- tenderProd.saleTenderItems = []; // 投标相关不用传参,否则会超长
- });
- var enInfos = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function (enterpriseBaseInfo) {
- var enInfo = {
- uu: null,
- contact: null,
- contactTel: null
- };
- enInfo.uu = enterpriseBaseInfo.uu;
- if (typeof enterpriseBaseInfo.contact !== 'undefined') {
- enInfo.contact = enterpriseBaseInfo.contact.venduser;
- enInfo.contactTel = enterpriseBaseInfo.contact.tel;
- }
- enInfos.push(enInfo);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- PurcTender.publishSaved({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- PurcTender.updateSaved({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- $scope.currentDay = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.getMinDate = function () {
- if ($scope.tender.endDate instanceof Date) {
- var minDate = new Date($scope.tender.endDate.getTime() + 2 * 24 * 60 * 60 * 1000 + 1); // 公布结果日期与截止报价日期至少隔一天
- }
- return $scope.tender.endDate ? $filter('date')(minDate, 'yyyy-MM-dd') : $filter('date')(new Date(new Date().getTime() + 24 * 60 * 60 * 1000 + 1), 'yyyy-MM-dd');
- };
- $scope.getMaxDate = function () {
- // var maxDate = angular.copy($scope.tender.publishDate);
- // maxDate = maxDate.setDate(maxDate.getDate() - 1);
- if ($scope.tender.publishDate instanceof Date) {
- var maxDate = new Date($scope.tender.publishDate.getTime() - 24 * 60 * 60 * 1000 - 1); // 至少提前两天
- }
- return $scope.tender.publishDate ? $filter('date')(maxDate, 'yyyy-MM-dd') : "";
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- //类目选择模态框(招标产品明细)
- app.controller('ProdKindChooseCtrl', ['$scope', 'KindAPI', 'actives', 'toaster', '$modalInstance', function ($scope, KindAPI, actives, toaster, $modalInstance) {
- $scope.actives = actives;
- $scope.kinds = [[], [], [], []];
- // 获取子类目
- var getChildren = function (pid, deep) {
- KindAPI.getChildren({parentId: pid}, function (data) {
- $scope.kinds[deep] = data;
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- };
- // 改变节点选中状态
- var changeStatus = function (item, deep) {
- var actives = [], level = 0;
- angular.forEach($scope.kinds, function (ks, i) {
- if (i > deep) {
- $scope.kinds[i] = [];
- } else {
- angular.forEach(ks, function (k, j) {
- if (i == deep) {
- if (k.id == item.id) {
- $scope.kinds[i][j].$active = true;
- actives.push(k);
- } else {
- k.$active = null;
- }
- } else {
- if (k.$active) {
- actives.push(k);
- }
- }
- });
- }
- });
- // 选择的节点
- $scope.actives = actives;
- $scope.active = item;
- // 当前可操作的层级
- if (deep < 3) {
- $scope.activeDeep = deep + 1;
- }
- };
- // 节点点击后获取子类目,节点被选中
- $scope.onItemClick = function (item, deep) {
- changeStatus(item, deep);
- if (!item.isLeaf) {
- getChildren(item.id, deep + 1);
- }
- };
- // 重新加载数据
- function reload(deep) {
- var pid;
- if (deep) {
- pid = $scope.actives[deep - 1].id;
- } else {
- pid = 0;
- deep = 0;
- }
- getChildren(pid, deep);
- }
- // 初始加载数据,获取第一层的类目
- if ($scope.actives) {
- angular.forEach($scope.actives, function (v, k) {
- KindAPI.getChildren({parentId: v.parentid}, function (data) {
- $scope.kinds[k] = data;
- angular.forEach($scope.kinds[k], function (kind, i) {
- if (kind.id == v.id) {
- $scope.kinds[k][i].$active = true;
- $scope.actives[k] = $scope.kinds[k][i];
- }
- })
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- });
- } else {
- reload();
- }
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 确认选择
- $scope.check = function () {
- var a = {
- active: $scope.active,
- actives: $scope.actives
- };
- $modalInstance.close(a);
- };
- }]);
- //品牌选择模态框的controller
- app.controller('BrandModalInstanceCtrl', ['$scope', '$modalInstance', 'ngTableParams', 'BrandActiveAPI', 'BaseService', function ($scope, $modalInstance, ngTableParams, BrandActiveAPI, BaseService) {
- $scope.filter = {};
- $scope.brandsTableParams = new ngTableParams({
- page: 1,
- count: 6,
- sorting: {
- nameCn: 'asc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- var param = BaseService.parseParams(params.url());
- param.keyword = $scope.filter.keyword;
- var keyword = $scope.filter.keyword;
- // param.keyword = $scope.filter.keyword;
- BrandActiveAPI.getSimpleInfoPage(param, {}, function (page) {
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function () {
- });
- }
- });
- // 搜索
- $scope.search = function () {
- // $scope.brandsTableParams.filter({$: $scope.filter.keyword});
- $scope.brandsTableParams.page(1);
- $scope.brandsTableParams.reload();
- };
- // 选择
- $scope.select = function (brand) {
- $modalInstance.close(brand);
- };
- // 关闭
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 招标单批量导入
- */
- app.controller('PurcTenderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function () {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'tender/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- toaster.pop('error', '提示', '上传失败,请检查填写格式');
- });
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadTenderProducts_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'tender/upload/template';
- };
- $scope.enSure = function () {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 评标
- */
- app.controller('PurcEvaluationCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'CurrentRole', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.tenderItems = [];
- // 采购方获取评标单
- var evaluation = function () {
- $scope.loading = true;
- PurcTender.getPurcTenderDetail({id: $stateParams.id}, function (data) {
- data.$editing = false;
- $scope.tender = data;
- $scope.tableParams = new ngTableParams({}, {dataset: data});
- // $scope.tableParams.sorting($scope.sort.field, $scope.sort.desc);
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- evaluation();
- $scope.orderType = '';
- // $scope.dir = '-';
- // 改变排序顺序
- $scope.changeOrder = function (type) {
- $scope.orderType = type;
- };
- $scope.submit = function (tender) {
- var canSubmit = false;
- var hasDecide = false;
- angular.forEach(tender.purchaseTenderProds, function (tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function (saleTenderItem) {
- if (saleTenderItem.price && 0 !== saleTenderItem.saleTender.auditStatus && typeof saleTenderItem.applyStatus !== 'undefined') { // 只要存在报价的行,就需要对其中一个定标
- hasDecide = true;
- }
- });
- if (hasDecide) {
- canSubmit = true;
- }
- });
- if (!canSubmit) {
- toaster.pop('info', '提示', '您还有已投标未选定的产品!');
- } else {
- PurcTender.decide(tender, function () {
- toaster.pop('success', '确认成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- toaster.pop('error', '确认失败', response.data);
- });
- }
- }
- }]);
- /**
- * 客户招标
- *
- */
- app.controller('SaleTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', 'PurcTenderInfo',
- function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise, PurcTenderInfo) {
- BaseService.scrollBackToTop();
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.searchStatus = false;
- /**
- * 改变类型
- */
- var getTypeCondition = function (zone, condition) {
- if (zone == -1) {
- condition.ifOpen = null;
- } else if (zone == 1) {
- condition.ifOpen = 1;
- } else {
- condition.ifOpen = 0;
- }
- };
- $scope.dateZoneText = '不限';
- $scope.typeText = '全部';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1, type: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeType = function (type) {
- $scope.condition.type = type;
- $scope.typeText = typeof type == 'undefined' ? '全部' : (type == -1 ? '全部' : (type == 1 ? '公开' : '指定'));
- getTypeCondition(type, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- if ($scope.searchStatus) {
- return PurcTender;
- }
- return PurcTenderInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- pt_ifopen: $scope.condition.ifOpen,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- angular.forEach(page.content, function (purcTender) {
- purcTender.vendorHasBid = false;
- angular.forEach(purcTender.purchaseTenderProds, function (tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function (saleTenderItem) {
- if ($scope.currentEn.uu === saleTenderItem.saleTender.vendUU) {
- tenderProd.currentItem = saleTenderItem;
- if (saleTenderItem.price && saleTenderItem.saleTender.auditStatus != 0) { //TODO 如果存在当前企业的投标明细已投标且不在已提交状态,即判断为已投标
- purcTender.vendorHasBid = true;
- }
- }
- });
- });
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcTender.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcTender.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcTender.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.searchStatus = true;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 招标提问列表
- *
- */
- app.controller('SaleTenderQuestionListCtrl', ['$scope', '$filter', 'SaleTenderQuestion', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise',
- function ($scope, $filter, SaleTenderQuestion, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.searchStatus = false;
- /**
- * 改变类型
- */
- var getTypeCondition = function (zone, condition) {
- if (zone == -1) {
- condition.ifOpen = null;
- } else if (zone == 1) {
- condition.ifOpen = 1;
- } else {
- condition.ifOpen = 0;
- }
- };
- $scope.dateZoneText = '不限';
- $scope.typeText = '全部';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1, type: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeType = function (type) {
- $scope.condition.type = type;
- $scope.typeText = typeof type == 'undefined' ? '全部' : (type == -1 ? '全部' : (type == 1 ? '公开' : '指定'));
- getTypeCondition(type, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- //TODO 增加直接从数据库取方法之后修改
- var getService = function () {
- if ($scope.searchStatus) {
- return SaleTenderQuestion;
- }
- return SaleTenderQuestion;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //TODO 获得各分类未阅读数量
- //TODO 设置单据已读
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 投标单提问单详情
- */
- app.controller('SaleTenderQuestionDetailCtrl', ['$scope', 'toaster', 'BaseService', 'SaleTenderQuestion', '$stateParams'
- , function($scope, toaster, BaseService, SaleTenderQuestion, $stateParams){
- BaseService.scrollBackToTop();
- $scope.loading = true;
- var loadData = function () {
- SaleTenderQuestion.getDetail({id: $stateParams.id}, function(data){
- $scope.loading = false;
- $scope.question = data;
- } , function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败');
- });
- };
- loadData();
- }]);
- /**
- * 招标答疑列表
- *
- */
- app.controller('PurcTenderAnswerListCtrl', ['$scope', '$filter', 'SaleTenderQuestion', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise',
- function ($scope, $filter, SaleTenderQuestion, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.searchStatus = false;
- /**
- * 改变类型
- */
- var getTypeCondition = function (zone, condition) {
- if (zone == -1) {
- condition.ifOpen = null;
- } else if (zone == 1) {
- condition.ifOpen = 1;
- } else {
- condition.ifOpen = 0;
- }
- };
- /**
- * 当前页面状态按钮过滤
- */
- var getAnswer = function (active) {
- var fn = 'getAllAnswer';
- switch (active) {
- case 'done':
- fn = 'getDoneAnswer';
- break;
- case 'todo':
- fn = 'getTodoAnswer';
- break;
- }
- return fn;
- };
- $scope.dateZoneText = '不限';
- $scope.typeText = '全部';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1, type: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeType = function (type) {
- $scope.condition.type = type;
- $scope.typeText = typeof type == 'undefined' ? '全部' : (type == -1 ? '全部' : (type == 1 ? '公开' : '指定'));
- getTypeCondition(type, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- //TODO 增加直接从数据库取方法之后修改
- var getService = function () {
- if ($scope.searchStatus) {
- return SaleTenderQuestion;
- }
- return SaleTenderQuestion;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- getService()[getAnswer($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //TODO 获得各分类未阅读数量
- //TODO 设置单据已读
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 招标答疑单详情
- */
- app.controller('PurcTenderAnswerDetailCtrl', ['$scope', 'toaster', 'BaseService', 'SaleTenderQuestion', '$stateParams', '$modal'
- , function($scope, toaster, BaseService, SaleTenderQuestion, $stateParams, $modal){
- BaseService.scrollBackToTop();
- $scope.loading = true;
- var loadData = function () {
- SaleTenderQuestion.getAnswerDetail({id: $stateParams.id}, function(data){
- $scope.loading = false;
- $scope.answer = data;
- var now = new Date();
- if ($scope.answer.questionEndDate < now.getTime()) {
- $scope.answer.questionEnd = 1;
- } else {
- $scope.answer.questionEnd = 0;
- }
- } , function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败');
- });
- };
- loadData();
- // 回答
- $scope.sendAnswer = function (){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/tender_answer.html',
- controller: 'PurcTenderAnswerCtrl',
- size: 'lg',
- resolve: {
- answer: function () {
- return $scope.answer;
- } //传递当前答疑单到模态框Controller
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('success', '答疑成功');
- }, function () {
- });
- };
- }]);
- /**
- * 招标单答疑
- */
- app.controller('PurcTenderAnswerCtrl', ['$scope', 'answer','$modalInstance', '$upload', 'toaster', function($scope, answer, $modalInstance, $upload ,toaster){
- $scope.answer = answer;
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- //确认回答
- $scope.ok = function (form) {
- $scope.loading = true;
- var files = form.attachFile.$viewValue, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'tender/question/answer/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.answer
- }
- }).success(function (data) {
- $scope.loading = false;
- $modalInstance.close('success');
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '错误', '出现异常,答疑失败');
- });
- };
- }]);
- /**
- * 平台公开招标
- *
- */
- app.controller('SaleOpenTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- /**
- * 改变单据日期范围
- */
- var getTenderDateCondition = function (zone, condition) {
- var date = new Date();
- if (zone == -1) {
- condition.dateFrom = null;
- condition.dateTo = null;
- } else if (zone == 7) { // 一星期内
- date.setDate(date.getDate() - 7);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 1) { // 一个月内
- date.setMonth(date.getMonth() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 3) { // 三个月内
- date.setMonth(date.getMonth() - 3);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 6) { // 半年内
- date.setMonth(date.getMonth() - 6);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else { // 一年内
- date.setYear(date.getYear() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- }
- };
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.condition.$dateZoneOpen = false;
- getTenderDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var getOpenState = function (active) {
- var fn = 'getOpenAll';
- switch (active) {
- case 'all':
- fn = 'getOpenAll';
- break;
- // case 'done':
- // fn = 'getOpenDone';break;
- case 'todo':
- fn = 'getOpenTodo';
- break;
- case 'end':
- fn = 'getOpenEnd';
- break;
- // case 'waiting':
- // fn = 'getOpenWaiting';break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'tender.endDate': 'desc',
- 'tender.enterprise.enName': 'asc',
- 'tender.code': 'asc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- PurcTender[getOpenState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.toDetail = function (id) {
- window.location.hash = '#/baseInfo/openTenderDetail/' + id;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 采购方查看供应商投标单
- */
- app.controller('SaleVendorTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- $scope.loading = true;
- PurcTender.getVendorSaleTenderDetail({tenderId: $stateParams.id, vendUU:$stateParams.vendUU}, function (data) {
- $scope.saleTender = data.saleTender;
- $scope.tender = data.tender;
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }]);
- /**
- * 查看投标单详情
- */
- app.controller('SaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', 'CurrentRole', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise, CurrentRole) {
- BaseService.scrollBackToTop();
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.loading = true;
- PurcTender.getSaleTenderDetail({tenderId: $stateParams.id}, function (data) {
- $scope.saleTender = data.saleTender;
- $scope.tender = data.tender;
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- // 提问
- $scope.sendQuestion = function (){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/tender_question.html',
- controller: 'SaleTenderQuestionCtrl',
- size: 'lg',
- resolve: {
- saleTender: function () {
- return $scope.saleTender;
- } //传递当前投标单到模态框Controller
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('success', '提问成功');
- }, function () {
- });
- };
- $scope.upload = function (myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderItemAttach',
- file: file,
- method: 'POST'
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function (attachId, index) {
- $scope.attaches.splice(index, 1);
- };
- var taxrateYes = false;
- var cycleYes = false;
- var priceYes = false;
- $scope.canSave = false;
- $scope.validateThis = function (value, type) {
- if ("" != value) {
- switch (type) {
- case 'taxrate':
- var regex = /^\+?[0-9][0-9]{0,1}$/;
- if (regex.test(value)) {
- taxrateYes = true;
- } else {
- toaster.pop('warning', '警告', '税率不合法,请重新填写');
- }
- break;
- case 'cycle':
- regex = /^\+?[1-9][0-9]*$/;
- if (regex.test(value)) {
- cycleYes = true;
- } else {
- toaster.pop('warning', '警告', '周期不合法,请重新填写');
- }
- break;
- case 'price':
- regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (regex.test(value) && value !== 0) {
- priceYes = true;
- } else {
- toaster.pop('warning', '警告', '请确认单价是否填写正确');
- }
- break;
- }
- }
- };
- $scope.emNumYes = true;
- $scope.validEmNum = function (value) {
- var regex = /^\+?[1-9][0-9]*$/;
- if (!regex.test(value) || value === 0 || value !== null) {
- $scope.emNumYes = false;
- toaster.pop('warning', '警告', '人数不合法,请重新填写');
- }
- };
- $scope.validateProds = function (saleTender) {
- $scope.canSave = true;
- var cycleRegex = /^\+?[1-9][0-9]*$/;
- var taxrateRegex = /^\+?[0-9][0-9]{0,1}$/;
- var priceRegex = /^(([0-9]+\.[0-9]{1,6})|([0-9]*[1-9][0-9]*\.[0-9]{1,6})|([0-9]*[1-9][0-9]*))$/; // 非零最多六位小数正实数
- if ($scope.tender.ifAll == 1) { // 全包时需要所有信息都填写并合法才可以投标
- // 全包全部需要填写,且需要符合正则式
- angular.forEach(saleTender.saleTenderItems, function(item) {
- if ((!item.cycle || !item.price) || (!cycleRegex.test(item.cycle) || !priceRegex.test(item.price))) {
- $scope.canSave = false;
- }
- });
- if (!saleTender.cycle || !saleTender.taxrate || !cycleRegex.test(saleTender.cycle) || !taxrateRegex.test(saleTender.taxrate)) {
- $scope.canSave = false;
- }
- } else { // 非全包模式
- angular.forEach(saleTender.saleTenderItems, function(item) {
- if (item.cycle || item.taxrate || item.price) {
- // /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- // 判断填写过的有为0或不符合正则式的,设置不能保存
- if (!cycleRegex.test(item.cycle) || !taxrateRegex.test(item.taxrate) || !priceRegex.test(item.price)) {
- $scope.canSave = false;
- } else {
- $scope.canSave = true;
- }
- }
- });
- }
- };
- // 投标
- $scope.bidIt = function (saleTender) {
- $scope.loading = true;
- if (saleTender.enterpriseBaseInfo.enEstablishDate instanceof Date) {
- saleTender.enterpriseBaseInfo.enEstablishDate = saleTender.enterpriseBaseInfo.enEstablishDate.getTime();
- }
- saleTender.bidAttaches.push.apply(saleTender.bidAttaches, $scope.attaches);
- angular.forEach(saleTender.saleTenderItems, function (item) {
- item.tenderProd = {};
- if ("" == item.price && "" == item.taxrate && "" == item.cycle) {
- item.price = 0;
- item.cycle = 0;
- item.taxrate = 0;
- }
- });
- PurcTender.reply({}, saleTender, function (data) {
- $scope.loading = false;
- toaster.pop('info', '成功', '投标成功');
- window.location.hash = '#/sale/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '投标失败', response.data);
- });
- };
- $scope.condition = {
- $fromOpened: false
- };
- $scope.getMaxDate = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- /**
- * 投标单提问
- */
- app.controller('SaleTenderQuestionCtrl', ['$scope', 'saleTender','$modalInstance', '$upload', 'toaster', function($scope, saleTender, $modalInstance, $upload ,toaster){
- $scope.saleTender = saleTender;
- // 当前日期,用作新增提问
- $scope.currentDay = new Date();
- $scope.question = {
- inDate : null,
- replyDate : null,
- topic : null,
- status : null,
- content : null,
- questionAttaches : []
- };
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- //确认提问
- $scope.ok = function (form) {
- $scope.loading = true;
- var files = form.attachFile.$viewValue, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'tender/question/send/' + $scope.saleTender.id,
- method: 'POST',
- file: file,
- data: {
- json: $scope.question
- }
- }).success(function (data) {
- $scope.loading = false;
- $modalInstance.close('success');
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '错误', '出现异常,提问失败');
- });
- };
- }]);
- /**
- * 公开招标转投标单
- */
- app.controller('OpenSaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise) {
- BaseService.scrollBackToTop();
- $scope.attaches = []; // 存放上传了的附件
- var sleep = function (d) {
- for (var t = Date.now(); Date.now() - t <= d;);
- }
- var getCurrentEn = function () {
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- }
- if (!angular.isUndefined($stateParams.id)) { // 获取招标单详情
- $scope.loading = true;
- getCurrentEn();
- PurcTender.getPurcTenderDetail({id: $stateParams.id}, function (data) {
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- $scope.currentHasBid = false; // 默认当前企业未转投标单
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function (item) {
- if ($scope.currentEn.uu === item.saleTender.vendUU) { // 存在当前企业为供应商的投标单,判断已转
- $scope.currentHasBid = true;
- }
- });
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- $scope.hasClick = false;
- $scope.iWantToBid = function (id) {
- $scope.hasClick = true;
- PurcTender.addItems({id: id}, {}, function (data) { // 添加明细
- toaster.pop('success', '成功', '转投标单成功');
- window.location.hash = "#/sale/tender/" + id;
- }, function (response) {
- toaster.pop('error', '操作失败', response.data);
- });
- };
- }]);
- // 基础资料客户详情
- app.controller('CustomersInfoCtrl', ['$scope', 'VendorService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', 'VendorInfo', function ($scope, VendorService, BaseService, AuthenticationService, ngTableParams, $modal, toaster, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = 'customer';
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
- // 查看详情
- $scope.viewDetail = function (id) {
- window.location.hash = "#/sale/customer/" + id;
- }
- // 取消合作关系
- $scope.disableCust = function (id) {
- VendorInfo.disableCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 解除禁用
- $scope.activeCust = function (id) {
- VendorInfo.activeCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 基础资料供应商
- app.controller('VendorsInfoCtrl', ['$scope', 'Vendor', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', '$rootScope', 'VendorInfo', function ($scope, Vendor, BaseService, AuthenticationService, ngTableParams, $modal, toaster, $rootScope, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = 'vendor';
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 查看供应商详情
- $scope.VendorDetail = function (id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/" + $rootScope.vendorId;
- }
- // 向企业购买
- $scope.purcByEn = function (businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
- // 取消合作关系
- $scope.relieve = function (id) {
- VendorInfo.relieve({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 建立合作关系
- $scope.activeVend = function (id) {
- VendorInfo.activeVend({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 基础资料服务商
- app.controller('ServicerInfoCtrl', ['$scope', 'Vendor', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', '$rootScope', 'VendorInfo', function ($scope, Vendor, BaseService, AuthenticationService, ngTableParams, $modal, toaster, $rootScope, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = 'servicer';
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getServicer.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 查看服务商详情
- $scope.VendorDetail = function (id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/" + $rootScope.vendorId;
- };
- // 取消合作关系
- $scope.relieveServicer = function (id) {
- VendorInfo.relieveServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 建立合作关系
- $scope.activeServicer = function (id) {
- VendorInfo.activeServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 企业圈搜索界面
- app.controller('AddPartnersCtrl', ['$scope', '$rootScope', function ($scope, $rootScope) {
- $scope.onSearch = function (keyword) {
- $rootScope.enterpriseKeyword = keyword;
- window.location.hash = "#/baseInfo/search?keyword=" + $rootScope.enterpriseKeyword;
- }
- }]);
- // 企业圈搜索结果
- app.controller('EnterpriseSearchCtrl', ['$scope', 'getAccountUserSpace', 'ngTableParams', '$filter', 'BaseService', 'toaster', 'AddPartner', '$rootScope', '$modal', 'InvitationRecord', function ($scope, getAccountUserSpace, ngTableParams, $filter, BaseService, toaster, AddPartner, $rootScope, $modal, InvitationRecord) {
- $scope.status = 'add';
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return getAccountUserSpace;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- if (keyword === '') {
- keyword = null;
- $rootScope.searchKeyword = keyword;
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- } else {
- $rootScope.searchKeyword = keyword;
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- };
- // 添加合作关系
- $scope.addPartner = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function (name) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function () {
- return name
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- /**
- * 立即查看
- */
- $scope.view = function (name) {
- $rootScope.vendName = name;
- window.location.hash = "#/baseInfo/newPartner";
- }
- }]);
- // 平台新增的询价单(指定一个供应商)
- app.controller('PurcInquiryNewCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'GetProductInfo', '$timeout', '$http', 'ShipAddress', '$stateParams', 'Vendor', 'Product', 'Search', 'ComponentActiveAPI', 'VendorInfo', function ($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, GetProductInfo, $timeout, $http, ShipAddress, $stateParams, Vendor, Product, Search, ComponentActiveAPI, VendorInfo) {
- $scope.active = 'all';
- // 供应商信息
- var loadData = function () {
- Vendor.enterpriseInfo({bussinessCode: $stateParams.bussinessCode}, {}, function (data) {
- $scope.vendor = data;
- Vendor.contacts({venduu: $scope.vendor.uu}, {}, function (data) {
- $scope.vendorContacts = data;
- });
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.custUU = $scope.vendor.uu;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- });
- };
- loadData();
- $rootScope.tenderVendor = null;// 清除掉已选择的
- var getService = function () {
- return GetProductInfo;
- };
- $scope.inquiry = {
- code: 'XJ' + $filter('date')(new Date(), 'yyMMddsss'),
- showdate: $filter('date')(new Date, 'yyyy-MM-dd'),
- priceType: '采购',
- isOpen: 0,
- invoice: 0,
- ifTax: 1,
- currency: 'RMB'
- };
- $scope.changeCurrency = function (inquiry) {
- if (inquiry.currency !== 'RMB') {
- $scope.notRMB = true;
- inquiry.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- inquiry.invoice = 0;
- } else {
- $scope.notRMB = false;
- }
- };
- // 获取收货地址列表
- var loadShipAddress = function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.inquiry.ship = $scope.ships[0].address + $scope.ships[0].addressdet + $scope.ships[0].receiver + $scope.ships[0].usertel;
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- $scope.currentDay = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.inquiry.inquiryItems = [];
- var prod = {
- prodCode: null,
- prodTitle: null,
- inbrand: null,
- currency: 'RMB',
- toDate: null,
- unit: 'PCS'
- };
- $scope.inquiry.inquiryItems.push(prod);
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function (value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function (value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- $scope.selectKind = function (prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function () {
- return $scope.actives;
- }
- }
- }).result.then(function (data) {
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function () {
- });
- };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function (brand, prod) {
- if (brand instanceof String) {
- prod.inbrand = brand;
- } else if (brand instanceof Object) {
- prod.inbrand = brand.brandCn;
- }
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function (prod) { //打开模态
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller: 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function () {// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function (brand) {
- prod.inbrand = brand.nameCn;
- }, function (reason) {
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function (cmp, prod) {
- ComponentActiveAPI.get({uuid: cmp.uuid}, {}, function (data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.inbrand = data.brand.nameCn;
- }, function (res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcInquiryUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.inquiry.inquiryItems.push(prod);
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- })
- }, function () {
- });
- }
- //增加商品
- $scope.add = function () {
- $scope.inquiry.inquiryItems.push(
- {
- prodCode: null,
- prodTitle: null,
- unit: 'PCS',
- ibrand: null,
- currency: 'RMB',
- toDate: null
- });
- };
- //删除商品
- $scope.del = function (index) {
- $scope.inquiry.inquiryItems.splice(index, 1);
- };
- // 搜索结果询价
- if ($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function (data) {
- prod.prodCode = data.code;
- prod.prodTitle = data.title;
- prod.spec = data.spec;
- prod.unit = data.unit;
- prod.productId = data.id;
- prod.inbrand = data.brand;
- $scope.inquiry.inquiryItems.push(prod);
- $rootScope.prodId = null;// 清除掉prodId
- }, function (response) {
- });
- }
- $scope.check = function (product) {
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- $scope.inquiry.inquiryItems.push({
- prodCode: product.code, prodTitle: product.title, spec: product.spec, unit: product.unit,
- currency: null, toDate: null, productId: product.id, inbrand: product.brand
- });
- }
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.inquiry.inquiryItems[index].$toDateOpen = !openParam;
- };
- $scope.openEndDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.ifrepeat = false;
- // 保存并提交
- $scope.submit = function () {
- $scope.loading = true;
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for (var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if (i != j) {
- if ($scope.item.prodCode = $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $scope.vendors = [];
- $scope.vendors.push({
- enName: $scope.vendor.enName,
- enuu: $scope.vendor.uu,
- currency: $scope.vendor.currency,
- rate: $scope.vendor.rate
- });
- if (!$scope.ifrepeat) {
- $upload.upload({
- url: 'purc/inquiry/submit/withVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function (data) {
- if (data.success) {
- $scope.loading = false;
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- window.location.hash = "#/purc/purchaseinquiry";
- }, 500);
- }
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', '存在条件相同的物料');
- }
- }
- }]);
- // 企业圈查询收到待处理的数目
- app.controller('RequestAmountCtrl', ['$scope', 'AddPartnerMyRequest', '$modal', 'InvitationRecord', 'toaster', function ($scope, AddPartnerMyRequest, $modal, InvitationRecord, toaster) {
- AddPartnerMyRequest.requestAmount({}, function (data) {
- $scope.requestTodo = data;
- });
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function () {
- return null
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- }]);
- // 当前企业所有的物料信息
- app.controller('ProductAllCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', 'ProductAllNewest', '$rootScope', 'prodUser', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, ProductAllNewest, $rootScope, prodUser) {
- BaseService.scrollBackToTop();
- $rootScope.ids = [];// 用来记录已经选择的物料
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? ProductAll : ProductAllNewest;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- standard: 'desc',
- id: 'desc',
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- $scope.checkall = true;
- if(page.content.length <= 2) {
- $scope.checkall = false;
- } else {
- angular.forEach(page.content, function (prod) {
- if ($rootScope.ids.indexOf(prod.id) > -1) {
- prod.$selected = true;
- } else {
- $scope.checkall = false;
- }
- });
- }
- $scope.checkboxes = {
- checked: $scope.checkall
- };
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 开启销售
- $scope.unlock = function (id) {
- $scope.loading = true;
- Products.unlock({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 关闭销售
- $scope.lock = function (id) {
- $scope.loading = true;
- Products.lock({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 开启购买
- $scope.unlockPurc = function (id) {
- $scope.loading = true;
- Products.unlockPurc({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 关闭购买
- $scope.lockPurc = function (id) {
- $scope.loading = true;
- Products.lockPurc({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 一键匹配
- $scope.matchall = function () {
- $scope.type = "all";
- $scope.loading = true;
- Products.matchbytype({type: $scope.type}, {}, function (data) {
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- } else {
- toaster.pop('info', '提示', '匹配成功' + data.size + '个标准器件');
- window.location.href = "#/approvalFlow/productmatches";
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.checkboxes = {
- checked: false
- };
- angular.forEach($scope.tableParams.data, function (item) {
- $scope.checkboxes.checked = false;
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- $scope.checkboxes.checked = true;
- }
- });
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- if (!item.waiting) {
- item.$selected = $scope.checkboxes.checked;
- if(item.$selected) {
- if(!$rootScope.ids.in_array(item.id)) {
- $rootScope.ids.push(item.id);
- }
- } else {
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- }
- }
- }
- });
- };
- // 判断数组中是否存在某个对象
- Array.prototype.S = String.fromCharCode(2);
- Array.prototype.in_array = function(e) {
- var r = new RegExp(this.S + e + this.S);
- return (r.test(this.S + this.join(this.S) + this.S));
- }
- // 从数组中移除某个对象
- Array.prototype.remove = function(val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (product) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- if(product.$selected) {
- if(!$rootScope.ids.in_array(product.id)) {
- $rootScope.ids.push(product.id);
- }
- } else {
- if($rootScope.ids.in_array(product.id)) {
- $rootScope.ids.remove(product.id);
- }
- }
- $scope.checkboxes = {
- checked: result
- };
- };
- // 批量转入我的产品库
- $scope.addtoUserByCheck = function() {
- var ids = angular.copy($rootScope.ids);
- if($rootScope.ids.length == 0) {
- toaster.pop('error', '提示', '请先选择产品');
- } else {
- prodUser.coverToUserByIds({}, ids, function(data) {
- toaster.pop('success', '提示', '选择' + $rootScope.ids.length + '个产品,成功转入' + data.count + '个产品');
- $rootScope.ids = [];
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(res) {
- toaster.pop('error', '提示', '转入失败');
- });
- }
- }
- // 转入我的产品库
- $scope.addtoUser = function(id) {
- $scope.loading = true;
- prodUser.coverToUser({id: id}, {}, function(data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '转入成功');
- }, function(res) {
- $scope.loading = false;
- toaster.pop('error', '提示', '转入失败');
- });
- }
- }]);
- // 当前企业匹配的标准物料信息
- app.controller('ProductmatchesCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- if ($rootScope.productMatchStatus === 'sale') {
- return $scope.searchMethod ? Products.matchResultforSale : Products.newestMatchResultforSale;
- } else if ($rootScope.productMatchStatus === 'purc') {
- return $scope.searchMethod ? Products.matchResultforPurc : Products.newestMatchResultforPurc;
- } else {
- return $scope.searchMethod ? Products.matchResult : Products.newestMatchResult;
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- matchsize: 'asc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- if (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function (product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var ids = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.product = {
- checked: false
- };
- var checkResults = function (result) {
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function (item) {
- if (result.id == item.id) {
- if (item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
- // 单选明细
- $scope.checkItem = function (result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
- // 一键更新
- $scope.updateAll = function () {
- $scope.loading = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.checked) {
- if (product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function (item) {
- if (item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall({status: $scope.checks.checked, type: 'all'}, ids, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.loading = false;
- }, 500);
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 当前企业匹配的标准物料信息(销售)
- app.controller('ProductmatchesForSaleCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? Products.matchResultforSale : Products.newestMatchResultforSale;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- matchsize: 'asc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- if (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function (product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var ids = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.product = {
- checked: false
- };
- var checkResults = function (result) {
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function (item) {
- if (result.id == item.id) {
- if (item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
- // 单选明细
- $scope.checkItem = function (result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
- // 一键更新
- $scope.updateAll = function () {
- $scope.loading = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.checked) {
- if (product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function (item) {
- if (item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall({status: $scope.checks.checked, type: 'sale'}, ids, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.loading = false;
- }, 500);
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function (response) {
- $scope.loading = true;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 当前企业匹配的标准物料信息(采购)
- app.controller('ProductmatchesForPurcCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? Products.matchResultforPurc : Products.newestMatchResultforPurc;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- matchsize: 'asc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- if (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function (product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- $scope.total = page.totalElement;
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var ids = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.product = {
- checked: false
- };
- var checkResults = function (result) {
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function (item) {
- if (result.id == item.id) {
- if (item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
- // 单选明细
- $scope.checkItem = function (result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
- // 一键更新
- $scope.updateAll = function () {
- $scope.loading = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.checked) {
- if (product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function (item) {
- if (item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall({status: $scope.checks.checked, type: 'purc'}, ids, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.loading = false;
- }, 500);
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 采购物料资料
- */
- app.controller('PurcProductCtrl', ['$scope', 'PurcProduct', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$modal', 'GetProductInfo', '$rootScope', 'PurcProductNewest', 'AccountEnterprise', function ($scope, PurcProduct, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $modal, GetProductInfo, $rootScope, PurcProductNewest, AccountEnterprise) {
- BaseService.scrollBackToTop();
- // 用来记录已经选择的id
- $rootScope.ids = [];
- var loadAccount = function () {
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data;
- $scope.purcStatus = $scope.enterprise.prodpurc;
- });
- }
- loadAccount();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcProduct : PurcProductNewest;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // //设置单据已读
- // var setOrdersRead = function () {
- // var ids = [];
- // PurcProduct.setRead({}, ids, function (message) {
- // // $scope.getUnreadIds();
- // });
- // };
- // setOrdersRead();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //删除
- $scope.deleteById = function (id) {
- GetProductInfo.deletePurcById({}, id, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function (response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
- // 一键开启关闭
- $scope.toggle = function (status) {
- $scope.loading = true;
- Products.toggle({status: status}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- loadAccount();
- $scope.tableParams.reload();
- if ($scope.purcStatus == 0) {
- $scope.purcStatus = 1;
- } else {
- $scope.purcStatus = 0;
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- })
- }
- var products = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- products = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.cmpUuId == null) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- products = [];// 每次选择时先清空,防止重复
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.updateByBatch = function (updatetype) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/updateByBatch_modal.html',
- controller: 'UpdateByBatchCtrl',
- size: 'md',
- resolve: {
- updatetype: function () {
- return updatetype;
- },
- active: function () {
- return $scope.active;
- },
- type: function () {
- return 'purchase';
- }
- }
- });
- modalInstance.result.then(function (data) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 一键匹配
- $scope.matchall = function () {
- $scope.type = "purc";
- $scope.loading = true;
- PurcProduct.matchbytype({type: $scope.type}, {}, function (data) {
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- } else {
- toaster.pop('info', '提示', '匹配成功' + data.size + '个标准器件');
- window.location.href = "#/purc/productmatches";
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- // 导出
- $scope.exportXls = function () {
- PurcProduct.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'purcProduct/xls?_state='+$scope.active+'&keyword='+ ($scope.keywordXls || "");
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 采购物料批量上传
- */
- app.controller('UploadProductCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function ($scope, $upload, toaster, BaseService) {
- BaseService.scrollBackToTop();
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- $scope.fileName = file.name;
- }
- })
- // 通过excel批量上传物料
- $scope.upload = function () {
- $scope.loading = true;
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- if (file.name) {
- $scope.loading = true;
- $upload.upload({
- url: 'purcProduct/edit/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- // $scope.products = $scope.result.products;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- $scope.infos = $scope.result.infos;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'product/baseInfo/upload/template';
- };
- }]);
- /**
- * 新增物料(采购)
- */
- app.controller('PurcNewProdInfoCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', '$modal', 'ComponentActive', 'KindAPI', '$timeout', '$filter', 'AuthenticationService', 'BaseService', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout, $filter, AuthenticationService, BaseService, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.prodInfo = {};
- // 选择类目
- $scope.selectKind = function () {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- };
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 删除
- $scope.clearfile = function () {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //提交
- $scope.submit = function (prodInfo) {
- $scope.loading = true;
- $scope.prodInfo.isPurchase = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'purcProduct/edit/addNewProduct',
- file: file,
- method: 'POST',
- data: {
- prodInfo: prodInfo
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/purc/prodList/" + data.id;
- // window.location.href="#/purc/product";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/purc/prodList/" + data.id;
- // window.location.href="#/purc/product";
- }, 500);
- }
- }).error(function (data, status, headers, config) {
- $scope.loading = false;
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- };
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- // 取消
- $scope.cancel = function () {
- $scope.prodInfo = angular.copy($scope.prodInfo);
- };
- // 查看大图
- $scope.showImg = function () {
- var src = imgurl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- }]);
- /**
- * 物料详情(采购)
- */
- app.controller('PurcProdDetailCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', 'AuthenticationService', '$filter', 'BaseService', '$modal', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, AuthenticationService, $filter, BaseService, $modal, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.editstatus = false;
- var loadData = function () {
- GetProductInfo.getPurcProduct({id: $stateParams.id}, function (data) {
- if (data.attach) {
- GetProductInfo.getAttach({id: data.attach.id}, function (data) {
- $scope.imgPreview = data.url;
- $scope.previewShow = true;
- })
- }
- $scope.prodInfo = data;
- if ($scope.prodInfo.isbusiness == 0) {
- $scope.editstatus = true;
- }
- if ($scope.prodInfo.standard != 1) {// 非标准的先进行匹配
- Products.matchone({id: $scope.prodInfo.id}, {}, function (data) {
- $scope.matchresults = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 设置类目
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.kind = kind.kindName;
- }
- // 设置名称
- $scope.onAssociateTitleClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置导入品牌
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- // 设置标准品牌
- $scope.onAssociatePBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.pbranden = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置标准型号
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.pcmpcode = cmp.code;
- }
- // 设置导入的型号
- $scope.onAssociateCmpClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 选择类目
- $scope.selectKind = function (cmpcode) {
- if (cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function () {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
- // 取消
- $scope.cancel = function () {
- GetProductInfo.getOne({id: $stateParams.id}, function (data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
- // 删除
- $scope.clearfile = function () {
- $scope.prodInfo.attach = null;
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //删除
- $scope.deleteById = function (id) {
- GetProductInfo.deletePurcById({}, id, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- window.location.href = "#/purc/product";
- }
- }, function (response) {
- toaster.pop("error", "删除失败", response.data);
- });
- }
- $scope.submit = function (prodInfo) {
- $scope.prodInfo.isPurchase = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'purcProduct/edit/updateProdInfo',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- // window.location.href="#/sale/prodList";
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- // 查看范例
- $scope.showImg = function () {
- if ($scope.prodInfo.attach) {
- GetProductInfo.getAttach({id: $scope.prodInfo.attach.id}, function (data) {
- var src = data.url, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- })
- } else if (imgurl != null) {
- var src = imgurl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- }]);
- // 供应商绩效考核
- app.controller('VendorPerformanceAssessCtrl', ['$scope', 'VendorPerformanceAssessService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', 'Vendor', 'AccountUser', 'CurrentRole', function ($scope, VendorPerformanceAssessService, BaseService, AuthenticationService, ngTableParams, $modal, toaster, Vendor, AccountUser, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.vendorPerformanceAssessParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorPerformanceAssessService.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = pageParams.keyword;
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //设置消息已读
- var setOrdersRead = function () {
- var sourceId = [];
- VendorPerformanceAssessService.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- });
- };
- setOrdersRead();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.vendorPerformanceAssessParams.page(1);
- $scope.vendorPerformanceAssessParams.reload();
- $scope.tip = keyword;
- };
- // 查看详情
- $scope.viewDetail = function (id) {
- window.location.hash = "#/sale/vendorPerformanceAssess/" + id;
- }
- }]);
- // 客户详情
- app.controller('VendorPerformanceAssessDetailCtrl', ['$scope', 'toaster', '$stateParams', 'VendorPerformanceAssessService', '$modal', 'ngTableParams', 'BaseService', '$rootScope', 'AuthenticationService', function ($scope, toaster, $stateParams, VendorPerformanceAssessService, $modal, ngTableParams, BaseService, $rootScope, AuthenticationService) {
- BaseService.scrollBackToTop();
- var loadData = function () {
- VendorPerformanceAssessService.getDetail({id: $stateParams.id}, {}, function (data) {
- $scope.vendorPerformanceAssess = data;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- }]);
- /**
- * 个人产品库
- */
- app.controller('UserProductCtrl', ['$scope', 'prodUser', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', '$modal', '$rootScope', function ($scope, prodUser, ngTableParams, $filter, BaseService, toaster, $timeout, $modal, $rootScope) {
- BaseService.scrollBackToTop();
- $rootScope.ids = [];// 每次加载先清空数据
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? prodUser.getInfo : prodUser.info;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc',
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.checkall = true;
- if(page.content.length <= 2) {
- $scope.checkall = false;
- } else {
- angular.forEach(page.content, function (prod) {
- if ($rootScope.ids.indexOf(prod.id) > -1) {
- prod.$selected = true;
- } else {
- $scope.checkall = false;
- }
- });
- }
- $scope.checkboxes = {
- checked: $scope.checkall
- };
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- $scope.tip = keyword;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 新增产品信息
- $scope.addProduct = function() {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/approvalFlow/modal/userprod_new_modal.html',
- controller: 'UserProductNewCtrl',
- }).result.then(function (data) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 导入商品信息
- $scope.uploadByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/modal/uplodaByBatch.html',
- controller: 'UserProdUploadCtrl',
- backdrop: 'static',
- keyboard: false,
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 删除
- $scope.deleteById = function(id) {
- prodUser.deleteById({}, id, function(data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(res) {
- toaster.pop('error', '提示', '删除失败');
- });
- }
- $scope.checkboxes = {
- checked: false
- };
- angular.forEach($scope.tableParams.data, function (item) {
- $scope.checkboxes.checked = false;
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- $scope.checkboxes.checked = true;
- }
- });
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- item.$selected = $scope.checkboxes.checked;
- if(item.$selected) {
- if(!$rootScope.ids.in_array(item.id)) {
- $rootScope.ids.push(item.id);
- }
- } else {
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- }
- }
- });
- };
- // 判断数组中是否存在某个对象
- Array.prototype.S = String.fromCharCode(2);
- Array.prototype.in_array = function(e) {
- var r = new RegExp(this.S + e + this.S);
- return (r.test(this.S + this.join(this.S) + this.S));
- }
- // 从数组中移除某个对象
- Array.prototype.remove = function(val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (product) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- if(product.$selected) {
- if(!$rootScope.ids.in_array(product.id)) {
- $rootScope.ids.push(product.id);
- }
- } else {
- if($rootScope.ids.in_array(product.id)) {
- $rootScope.ids.remove(product.id);
- }
- }
- $scope.checkboxes = {
- checked: result
- };
- };
- // 批量删除
- $scope.deleteByBatch = function() {
- var ids = angular.toJson($rootScope.ids);
- if($rootScope.ids.length > 0) {
- prodUser.deleteByBatch({ids: ids}, {}, function(data) {
- toaster.pop('success', '提示', '成功移除' + $rootScope.ids.length + '个产品');
- $rootScope.ids = [];
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(res) {
- toaster.pop('error', '提示', '移除失败');
- });
- } else {
- toaster.pop('error', '提示', '请先选择产品');
- }
- }
- }]);
- /**
- * 用户产品新增产品
- */
- app.controller('UserProductNewCtrl', ['$scope', 'toaster', 'prodUser', '$modalInstance', function($scope, toaster, prodUser, $modalInstance) {
- // 确定
- $scope.submit = function(prodInfo) {
- prodUser.addProduct({}, prodInfo, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- } else if(data.info) {
- toaster.pop('info', '提示', data.info);
- }
- $modalInstance.close('success');
- }, function(res) {
- toaster.pop('error', '提示', '添加失败');
- });
- }
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 用户产品批量导入产品
- */
- app.controller('UserProdUploadCtrl', ['$scope', 'toaster', 'prodUser', '$modalInstance', '$upload', function($scope, toaster, prodUser, $modalInstance, $upload) {
- // 通过excel批量上传物料
- $scope.upload = function () {
- $scope.loading = true;
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- if (file.name) {
- $upload.upload({
- url: 'productuser/edit/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- // 下载模板
- $scope.download = function () {
- window.location.href = 'productuser/upload/template';
- };
- // 确定
- $scope.enSure = function() {
- $modalInstance.close('success');
- }
- }]);
- /**
- * 针对卖家,已转询价的公共询价单列表
- */
- app.controller('SalePubInquiryCtrl', ['$scope', '$filter', 'PubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', '$modal', 'AccountEnterprise', '$http', 'customer', 'AuthenticationService','$stateParams',
- function ($scope, $filter, PubInquirySearchInfo, ngTableParams, toaster, BaseService, PubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry, $modal, AccountEnterprise, $http, customer, AuthenticationService, $stateParams) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- /**
- * active 状态说明:
- * all: 客户公共询价单全部
- * done: 已报价
- * agreed: 已采纳
- * refused: 未采纳
- * invalid: 已失效
- * todo**: 待报价
- * todoAll: 所有公共询价
- * todoRemind: 个人商机
- * todoComRemind: 企业商机
- */
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todoComRemind';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.url = null;
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- $scope.url = url;
- if ($scope.active == 'todoComRemind') {// 企业商机
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/sale/enremind',
- params: {
- pageNumber: pageParams.page,
- pageSize: pageParams.count,
- useruu: $scope.thisUser.userUU,
- enuu: $scope.currentEn.uu,
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo),
- enableOffer: 1
- }
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- } else if ($scope.active == 'todoRemind') {// 推荐报价信息
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/sale/remind',
- params: {
- pageNumber: pageParams.page,
- pageSize: pageParams.count,
- useruu: $scope.thisUser.userUU,
- enuu: $scope.currentEn.uu,
- enableOffer: 1,
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- }
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- } else if ($scope.active == 'todoAll') {// 全部
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/public',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, enUU: $scope.currentEn.uu, keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo), distribute: $scope.distribute, remind: $scope.remind}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- } else {
- var filter = {vendUU: $scope.currentEn.uu, keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)};
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/public/quotation/list',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, filter: filter, _state: $scope.active}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- }
- });
- });
- }
- });
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- // 导出
- $scope.exportXls = function () {
- PurcInquiry.exportXls({}, {}, function (data) {
- if (data.success) {
- window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- $scope.isOverDue = function (date) {
- if (date) {
- var ndate = new Date();
- ndate.setHours(23, 59, 59 ,999);
- ndate.setDate(ndate.getDate());
- var timestamp = Date.parse(ndate);
- if (date > timestamp) {
- return true;
- } else {
- return false;
- }
- } else {
- return true;
- }
- }
- $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
- customer.distribute({}, function(data) {
- $scope.customer = data;
- });
- $scope.toDetail = function (item) {
- if (item.quoted == 0) {
- window.location.hash = '#/baseInfo/inquiryList/' + item.id;
- } else {
- window.open("#/sale/pubinquiry/" + item.quteId);
- }
- };
- // 转客户询价
- $scope.qute = function (remind) {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/sale/quote',
- params: {id: remind.itemId, en_uu: $scope.currentEn.uu}
- }).success(function (response) {
- $scope.loading = false;
- if (response.inquiry != null) {
- toaster.pop('error', '该单据已报价');
- } else {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/public/findItemByItemId',
- params: {itemId: remind.itemId, enuu: $scope.currentEn.uu}
- }).success(function (response) {
- var inquiryItem = response;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }).error(function (error) {
- toaster.pop('error', '数据加载失败', error);
- });
- }
- }).error(function (err) {
- toaster.pop('error', '数据加载失败', err);
- });
- }
- // 跳转详情
- $scope.remindDetail = function(remind) {
- if (remind.newId == null) {
- window.location.hash = '#/baseInfo/inquiryList/' + remind.itemId;
- } else {
- window.open("#/sale/pubinquiry/" + remind.newId);
- }
- }
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 转客户询价
- $scope.transtoInquiry = function (inquiryItem) {
- if ($scope.currentEn.uu == inquiryItem.inquiry.enUU) {
- toaster.pop('warning', '不能对自己企业报价');
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }
- }
- // 跳转到我的报价列表
- $scope.linkToInquiry = function () {
- window.open("#/sale/pubinquiry");
- }
- }]);
- /**
- * 针对卖家,已转询价单的客户公共询价单明细
- */
- app.controller('SalePubInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', 'publicInquiry', function ($scope, $stateParams, PurcInquiry, $filter, toaster, $upload, token, CurrentRole, publicInquiry) {
- // 获取当前用户是否为普通用户
- var loadData = function () {
- publicInquiry.inquiryDetail({id: $stateParams.id}, function (data) {
- $scope.inquiryItem = data;
- var inquiry = data.inquiry;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- $scope.attach = null;
- if ($scope.inquiryItem.attaches.length > 0) {
- $scope.attach = $scope.inquiryItem.attaches[0];
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- publicInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,6})?$/;
- var valid = true;
- angular.forEach(inquiryItem.replies, function(reply, $index) {
- if ($index < index && reply.lapQty >= value) {
- valid = false;
- }
- });
- $scope.replylapQtys[index] = regex.test(value) && valid;
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- $scope.verifylapQty(r.lapQty, i, item);
- bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
- });
- return bool;
- };
- $scope.deleteAttach = function (attaches, index) {
- attaches.splice(index, 1);
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- var valid = true;
- var validLapQty = 0;
- angular.forEach(item.replies, function (r, i) {
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- $scope.loading = true;
- if (!valid) { // 不合法时给出提示
- if (validLapQty) {
- toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('info', '提示', '分段数量不合法,不能保存!');
- }
- $scope.loading = false;
- } else {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- if (withSteps) {
- if(null != file) {
- $upload.upload({
- url: 'sale/pubInquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'reply'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- toaster.pop('success', '提示', '报价成功');
- loadData();
- }).error(function () {
- toaster.pop('error', '提示', '报价失败');
- });
- } else {
- publicInquiry.reply({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('success', '提示', '报价成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '询价失效', response.data);
- });
- }
- } else {
- if(null != file) {
- $upload.upload({
- url: 'sale/pubInquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'save'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- toaster.pop('success', '提示', '保存成功');
- loadData();
- }).error(function () {
- toaster.pop('error', '提示', '保存失败');
- });
- } else {
- publicInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- }]);
- /**
- * 针对买家,已转询价的公共询价单列表
- */
- app.controller('PurcPubInquiryCtrl', ['$scope', '$filter', 'PurcPubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PurcPubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', 'AccountEnterprise', '$http', function ($scope, $filter, PurcPubInquirySearchInfo, ngTableParams, toaster, BaseService, PurcPubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry, AccountEnterprise, $http) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'all';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcPubInquirySearchInfo : PurcPubInquiryNoSearchInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- var filter = {enUU: $scope.currentEn.uu, keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)};
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/public/quotation/list',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, filter: filter, _state: $scope.active}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- });
- }
- });
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- publicInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 采纳
- $scope.accept = function (id) {
- publicInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, function (response) {
- toaster.pop('error', '提示', '采纳失败');
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- publicInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, function (response) {
- toaster.pop('error', '提示', '操作失败');
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- })
- }
- // 导出
- $scope.exportXls = function () {
- PurcInquiry.exportXls({}, {}, function (data) {
- if (data.success) {
- window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- }]);
- /**
- * 针对买家,已转询价单的客户公共询价单明细
- */
- app.controller('PurcPubInquiryDetailCtrl', ['$scope', '$stateParams', 'publicInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', 'AccountEnterprise', '$http', function ($scope, $stateParams, publicInquiry, $filter, toaster, $upload, token, CurrentRole, AccountEnterprise, $http) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/buyer/detail',
- params: {id: $stateParams.id, enuu: $scope.currentEn.uu}
- }).success(function (response) {
- $scope.newinquiryItems = response;
- var inquiry = response;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- });
- });
- });
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.getHistory = function (item) {
- if (!item.history) {
- publicInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- // 采纳
- $scope.accept = function (id) {
- publicInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- publicInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- /**
- * 公共询价模态框(供应商报价)
- */
- app.controller('QuoteInquiryCtrl', ['$scope', '$stateParams', 'toaster', 'inquiryItem', '$modalInstance', '$upload', function ($scope, $stateParams, toaster, inquiryItem, $modalInstance, $upload) {
- $scope.inquiryItem = inquiryItem;
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- // 增加一列分段报价
- $scope.addStep = function (inquiryItem) {
- $scope.replyPrices.push(true);
- if (inquiryItem.replies.length >= 5) {
- toaster.pop('warning', '提示', '最多支持5个分段!');
- } else {
- inquiryItem.replies.push({});
- if (inquiryItem.replies.length != 1) {
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- }
- }
- };
- // 删除一列分段报价
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- $scope.replyPrices.splice(stepIndex, 1);
- $scope.replylapQtys.splice(stepIndex, 1);
- };
- // 取消,关闭弹出框
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- // 保存报价信息
- $scope.save = function(inquiryItem, method) {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'pubInquiry/turnToQuotation',
- file: file,
- method: 'POST',
- data: {
- item: inquiryItem,
- method: method
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '报价失败');
- });
- }
- }]);
- /**
- * 首页侧边栏询价列表
- */
- app.controller('InquiryMessageListCtrl', ['$scope', 'publicInquiry', 'AccountEnterprise', '$http', function($scope, publicInquiry, AccountEnterprise, $http) {
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function (data) {
- var url = data.url;
- $http({
- method: 'get',
- url: url + '/inquiry/public/messageList',
- params: {enuu: $scope.currentEn.uu, size: 7},
- dataType: 'json'
- }).success(function(data) {
- $scope.message = data;
- }).error(function(error) {
- });
- });
- });
- }]);
- /**
- * 针对卖家,询价推荐列表
- */
- app.controller('SaleInquiryRemindCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', 'publicInquiry', '$modal', 'AccountEnterprise', '$http', 'AuthenticationService', function ($scope, $filter, ngTableParams, toaster, BaseService, publicInquiry, $modal, AccountEnterprise, $http, AuthenticationService) {
- BaseService.scrollBackToTop();
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
-
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- $scope.url = data.url;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/sale/remind',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, useruu: $scope.thisUser.userUU, enuu: $scope.currentEn.uu,
- keyword: $scope.keyword, fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- });
- });
- }
- });
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- // 转客户询价
- $scope.qute = function (remind) {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/sale/quote',
- params: {id: remind.itemId, en_uu: $scope.currentEn.uu}
- }).success(function (response) {
- $scope.loading = false;
- if (response.inquiry != null) {
- toaster.pop('error', '该单据已报价');
- } else {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/public/findItemByItemId',
- params: {itemId: remind.itemId, enuu: $scope.currentEn.uu}
- }).success(function (response) {
- var inquiryItem = response;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }).error(function (error) {
- toaster.pop('error', '数据加载失败', error);
- });
- }
- }).error(function (err) {
- toaster.pop('error', '数据加载失败', err);
- });
- }
- // 跳转详情
- $scope.toDetail = function(remind) {
- if (remind.newId == null) {
- window.location.hash = '#/baseInfo/inquiryList/' + remind.itemId;
- } else {
- window.open("#/sale/pubinquiry/" + remind.newId);
- }
- }
- }]);
- /**
- * 采购变更单列表
- *
- * @author hejq
- * @date 2018-06-25 17:13
- */
- app.controller('PurcChangeListCtrl', ['$scope', '$filter', 'change', 'ngTableParams', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $filter, change, ngTableParams, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return change;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- change.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'purc/change/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 新增采购变更单
- *
- * @author hejq
- * @date 2018-06-25 16:38
- */
- app.controller('PurcChangeNewCtrl', ['$scope', 'toaster', 'BaseService', 'AuthenticationService', '$modal', '$filter', 'change',
- function ($scope, toaster, BaseService, AuthenticationService, $modal, $filter, change) {
- // 获取登录人员信息
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- initChange();
- });
- // 初始化变更单信息
- var initChange = function () {
- $scope.change = {
- date: new Date(),
- recorder: $scope.user.userName,
- orderCode: null,
- code: 'B2BPC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- orderId: null,
- orderChangeItems: []
- }
- }
- $scope.getEnableOrders = function() {
- initChange();
- var modalInstance = $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/enableOrderList.html',
- controller: 'EnableChangeListCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function (data) {
- $scope.change.orderCode = data.code;
- $scope.change.orderId = data.id;
- $scope.orderItems = data.orderItems;
- $scope.change.oldCurrency = data.currency;
- $scope.change.oldPayments = data.payments;
- $scope.change.oldRate = data.rate;
- $scope.change.vendUU = data.vendUU;
- $scope.change.apVendorName = data.receiveName;
- $scope.change.vendUserUU = data.vendUserUU;
- $scope.change.newCurrency = data.currency != null ? data.currency :null;
- $scope.change.newPayments = data.payments != null ? data.payments :null;
- angular.forEach($scope.orderItems, function (item, index) {
- $scope.change.orderChangeItems.push({
- oldProductId: item.productId,
- orderItemId: item.id,
- orderItemNumber: item.number,
- oldQty: item.qty,
- oldPrice: item.price,
- oldTaxrate: item.taxrate,
- oldDelivery: item.delivery,
- newQty: item.qty != null ? item.qty :null,
- newPrice: item.price != null ? item.price :null,
- newTaxrate: item.taxrate != null ? item.taxrate :null,
- newDelivery: item.delivery != null ? item.delivery :null,
- oldProduct: item.product,
- number: index + 1
- });
- });
- });
- }
- // 删除明细
- $scope.del = function (index) {
- $scope.change.orderChangeItems.splice(index, 1);
- }
- $scope.getMinDate = function () {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.change.orderChangeItems[index].$dateOpen = !openParam;
- };
- $scope.save = function() {
- if ($scope.change.unNeedReply == null) {
- toaster.pop('error', '请选择是否需要供应商确认');
- } else if ($scope.change.orderChangeItems.length == 0) {
- toaster.pop('error', '请至少选择一条采购明细')
- } else {
- change.save({}, $scope.change, function (data) {
- window.location.hash = "/purc/change/" + data.id;
- toaster.pop('success', '采购变更单保存成功');
- }, function(res) {
- toaster.pop('error','请输入正确的信息')
- });
- }
- }
- }]);
- /**
- * 获取可以作为采购变更单的采购单
- *
- * @author hejq
- * @date 2018-06-25 18:41
- */
- app.controller('EnableChangeListCtrl', ['$scope', 'change', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance',
- function ($scope, change, BaseService, ngTableParams, toaster, $modalInstance) {
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- change.getEnableOrderList.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.checkedOrder = null;
- var checkItems = [];
- // 单选
- $scope.checkOne = function (order) {
- var changeflag = false;
- order.checked = !order.checked;
- if ((order.checked) && ($scope.checkedOrder != null) && ($scope.checkedOrder != order)) {
- $scope.checkedOrder.checked = false;
- angular.forEach($scope.checkedOrder.orderItems, function (item) {
- item.checked = false;
- });
- $scope.checkedOrder = null;
- checkItems = [];
- }
- if (order.checked) {
- $scope.checkedOrder = order;
- angular.forEach(order.orderItems, function (item) {
- if (item.change) {
- item.checked = false;
- changeflag = true;
- } else {
- item.checked = true;
- checkItems.push(item);
- }
- });
- } else {
- $scope.checkedOrder = null;
- angular.forEach(order.orderItems, function (item) {
- item.checked = false;
- });
- checkItems = [];
- }
- if (checkItems.length == 0 && changeflag) {
- order.checked =false;
- toaster.pop('warning', '提示', "该采购单所有明细正在变更中,在供应商确认之前不可再次变更");
- }
- };
- // 明细
- $scope.checkItem = function (item, order) {
- // 先判断选中信息
- if (item.change) {
- toaster.pop('warning', '提示', "该明细正在变更中,在供应商确认之前不可再次变更");
- item.checked = null;
- return;
- }
- order.checked = true;
- if ($scope.checkedOrder != null && order.id != $scope.checkedOrder.id) {
- $scope.checkedOrder.checked = false;
- $scope.checkedOrder = order;
- order.checked = true;
- angular.forEach(checkItems, function (checkItem) {
- checkItem.checked = false;
- });
- checkItems = [];
- }
- item.checked = !item.checked;
- if (item.checked) {
- checkItems.push(item);
- if ($scope.checkedOrder == null) {
- $scope.checkedOrder = order;
- }
- order.checked = true;
- } else {
- angular.forEach(checkItems, function (checkItem, index) {
- if (checkItem.id == item.id) {
- checkItems.splice(index, 1);
- }
- });
- }
- if (checkItems.length == 0) {
- $scope.checkedOrder = null;
- order.checked = false;
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.getCartTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- // 选择
- $scope.choose = function () {
- if ($scope.checkedOrder == null || checkItems.length == 0) {
- toaster.pop('error', '请先选择采购单信息');
- } else {
- $scope.checkedOrder.orderItems = checkItems;
- $modalInstance.close($scope.checkedOrder);
- }
- }
- // 关闭
- $scope.close = function () {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 采购变更单详情
- */
- app.controller('PurcChangeDetailCtrl', ['$scope', '$stateParams', 'change', 'toaster', 'CurrentRole',
- function ($scope, $stateParams, change, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- change.getItem({id: $stateParams.id}, function (data) {
- $scope.change = data;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- /**
- * B2C搜索
- */
- app.controller('SearchCtrl', ['$scope', '$http', '$rootScope', 'SessionService', 'AccountEnterprise', function($scope, $http, $rootScope, SessionService, AccountEnterprise) {
- $scope.hotwords = new Array();
- var hasBrand = false;
- var hasComponent = false;
- // 热词搜索品牌
- var hotBrand = function () {
- $http.get($scope.toB2cLink + '/api/product/brand/mostSearchBrands'
- ).success(function(data){
- hasBrand = true;
- angular.forEach(data, function (value) {
- $scope.hotwords.push({name: value.nameEn, url: $scope.toB2cLink + '/search?w='+ value.nameEn +'&type=brand'})
- })
- if (hasBrand) {
- hotComponent();
- }
- }).error(function(response) {
- console.log(response)
- });
- };
- // 热词搜索器件
- var hotComponent = function () {
- $http.get($scope.toB2cLink + '/api/product/component/mostSearchComponent'
- ).success(function(data){
- hasComponent = true;
- if (hasBrand && hasComponent) {
- angular.forEach(data, function (value) {
- $scope.hotwords.push({name: value.code, url: $scope.toB2cLink + '/search?w='+ value.code +'&type=component'})
- })
- }
- }).error(function(response) {
- console.log(response)
- });
- };
- AccountEnterprise.getB2cUrl({}, function(data) {
- $scope.toB2cLink = data.url
- hotBrand();
- });
- // 默认搜索类型
- $scope.searchType = 'component';
- $scope.placeholderSearch = '请输入型号';
- // 选搜索类型
- $scope.setTypeClick = function (type) {
- $scope.keyword = '';
- $scope.searchType = type;
- if (type === 'kind') {
- $scope.placeholderSearch = '请输入物料名称';
- } else if (type === 'store') {
- $scope.placeholderSearch = '请输入卖家名称';
- } else if (type === 'brand') {
- $scope.placeholderSearch = '请输入品牌';
- } else {
- $scope.placeholderSearch = '请输入型号';
- }
- };
- // 搜索
- $scope.search = function() {
- if($scope.keyword) {
- SessionService.set('brand', true);
- SessionService.unset('component');
- window.location.href = $scope.toB2cLink + '/search?w=' + encodeURI($scope.keyword) + '&type=' + $scope.searchType;
- }
- };
- // 搜索框获得焦点,显示联想框
- $scope.onFocus = function() {
- $scope.associate = true;
- $scope.selectIndex = -1;
- if(!$scope.keyword) $scope.keyword = '';
- };
- // 搜索框失去焦点,关闭联想框
- $scope.onBlur = function() {
- $scope.associate = false;
- };
- // 搜索框通过按键选取想要的联想词
- $scope.onKeyup = function() {
- if($scope.associates && $scope.associates.length) {
- if(event.keyCode == 40) { //监听到按下键
- $scope.selectIndex ++;
- if($scope.selectIndex >= $scope.associates.length) $scope.selectIndex = 0;
- $scope.keyword = $scope.associates[$scope.selectIndex];
- } else if(event.keyCode == 38) { //监听到按上键
- $scope.selectIndex --;
- if($scope.selectIndex < 0) $scope.selectIndex = $scope.associates.length - 1;
- $scope.keyword = $scope.keyword = $scope.associates[$scope.selectIndex];
- } else if(event.keyCode == 13) { //确定键
- $scope.search();
- }
- }
- };
- // 输入框内容变化,获取新的联想词
- $scope.onChange = function() {
- if ($scope.keyword) {
- var params = {
- keyword: $scope.keyword,
- type: $scope.searchType
- };
- $http.get($scope.toB2cLink + '/search/similarKeywords', {
- params : params
- }).success(function(data){
- $scope.associates = data.result;// 联想词数组
- }).error(function(response) {
- console.log(response)
- });
- } else {
- $scope.associates = [];// 联想词数组
- }
- };
- // 点击联想词
- $scope.onAssociateClick = function(component) {
- $scope.keyword = component;
- $scope.search();
- };
- // 鼠标进入联想词框,不能关闭联想词框
- $scope.onAssociateEnter = function() {
- $scope.associateEnter = true;
- };
- // 鼠标离开联想词框,可以关闭联想词框
- $scope.onAssociateLeave = function() {
- $scope.associateEnter = false;
- };
- // 跳转到B2C
- $scope.b2cLink = function (url) {
- window.location.href = $scope.toB2cLink + url;
- };
- // 头部固定
- window.addEventListener('scroll', function () {
- var obj = document.getElementById('fixed-header');
- var scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
- $scope.$apply(function () {
- $scope.isFixed = scrolled >= obj.offsetTop;
- });
- }, false);
- }]);
- /**
- * 树结构
- */
- app.controller('treeController', ['$scope', '$location', function($scope, $location){
- $scope.roleList = [
- { "roleName" : "卖家中心(销售)", "roleId" : "role1", 'path': 'sale', level: 0, collapsed: true, "children" : [
- { "roleName" : "商机管理", "roleId" : "role1-1", collapsed: true, "children" : [
- { "roleName" : "客户采购询价", "roleId" : "role1-1-1", 'link' : '#/sale/inquiry', "children" : [] },
- { "roleName" : "客户公共询价", "roleId" : "role1-1-2", 'link' : '#/sale/pubinquiry', "children" : [] },
- { "roleName" : "客户模具询价", "roleId" : "role1-1-3", 'link' : '#/sale/mould', "children" : [] },
- { "roleName" : "主动报价", "roleId" : "role1-1-4", 'link' : '#/sale/quotation/list', "children" : [] },
- { "roleName" : "客户招标", "roleId" : "role1-1-5", 'link' : '#/sale/tender', "children" : [] }
- ] },
- { "roleName" : "订单管理", "roleId" : "role1-2", collapsed: true, "children" : [
- { "roleName" : "客户采购订单", "roleId" : "role1-2-1", 'link' : '#/sale/order', "children" : [] },
- { "roleName" : "客户采购变更单", "roleId" : "role1-2-2", 'link' : '#/sale/change', "children" : [] },
- { "roleName" : "客户委外单", "roleId" : "role1-2-3", 'link' : '#/sale/maketodo/makeorder', "children" : [] },
- { "roleName" : "委外变更单", "roleId" : "role1-2-4", 'link' : '#/sale/makechange', "children" : [] },
- { "roleName" : "客户发货提醒", "roleId" : "role1-2-5", 'link' : '#/sale/notice', "children" : [] },
- { "roleName" : "发货单", "roleId" : "role1-2-6", 'link' : '#/sale/send', "children" : [] }
- ]},
- { "roleName" : "客户出入库", "roleId" : "role1-3", collapsed: true, "children" : [
- { "roleName" : "MRB单", "roleId" : "role1211", 'link' : '#/sale/MRB', "children" : [] },
- { "roleName" : "不良品出库单", "roleId" : "role1-3-1", 'link' : '#/sale/badOut', "children" : [] },
- { "roleName" : "不良品入库单", "roleId" : "role1-3-2", 'link' : '#/sale/badIn', "children" : [] },
- { "roleName" : "客户采购验收单", "roleId" : "role1-3-3", 'link' : '#/sale/accept', "children" : [] },
- { "roleName" : "客户采购验退单", "roleId" : "role1-3-4", 'link' : '#/sale/returns', "children" : [] },
- { "roleName" : "客户委外验收单", "roleId" : "role1-3-5", 'link' : '#/sale/makeaccept', "children" : [] },
- { "roleName" : "客户委外验退单", "roleId" : "role1-3-6", 'link' : '#/sale/makereturns', "children" : [] }
- ] },
- { "roleName" : "样品管理", "roleId" : "role1-4", collapsed: true, "children" : [
- { "roleName" : "客户打样申请", "roleId" : "role1-4-1", 'link' : '#/sale/sample', "children" : [] },
- { "roleName" : "客户认定单", "roleId" : "role1-4-2", 'link' : '#/sale/approval', "children" : [] }
- ] },
- { "roleName" : "基础资料", "roleId" : "role1-5", collapsed: true, "children" : [
- { "roleName" : "客户资料", "roleId" : "role1-5-1", 'link' : '#/sale/customer', "children" : [] },
- { "roleName" : "绩效考核", "roleId" : "role1-5-2", 'link' : '#/sale/vendorPerformanceAssess', "children" : [] },
- { "roleName" : "产品导入", "roleId" : "role1-5-3", 'link' : '#/sale/prodList', "children" : [] }
- ] }
- ]},
- { "roleName" : "买家中心(采购)", "roleId" : "role2", 'path': 'purc', level: 0, collapsed: true, "children" : [
- { "roleName" : "供应商资料", "roleId" : "role2-1-1", 'link' : '#/purc/vendor', "children" : [] },
- { "roleName" : "供应商服务", "roleId" : "role2-1-2", 'link' : '#/purc/vendor/serve', "children" : [] },
- { "roleName" : "采购物料", "roleId" : "role2-1-3", 'link' : '#/purc/product', "children" : [] },
- { "roleName" : "采购招标", "roleId" : "role2-1-4", 'link' : '#/purc/tender', "children" : [] },
- { "roleName" : "采购询价", "roleId" : "role2-1-5", 'link' : '#/purc/purchaseinquiry', "children" : [] },
- { "roleName" : "公共询价", "roleId" : "role2-1-6", 'link' : '#/purc/publicInquiry', "children" : [] },
- { "roleName" : "采购订单", "roleId" : "role2-1-7", 'link' : '#/purc/order', "children" : [] },
- { "roleName" : "采购变更单", "roleId" : "role2-1-8", 'link' : '#/purc/change', "children" : [] },
- { "roleName" : "代采订单", "roleId" : "role2-1-9", 'link' : '#/purc/deputy', "children" : [] },
- { "roleName" : "委外订单", "roleId" : "role2-1-10", 'link' : '#/purc/makeoutorder', "children" : [] }
- ]},
- { "roleName" : "财务", "roleId" : "role3", 'path': 'fa', level: 0, collapsed: true, "children" : [
- { "roleName" : "应收", "roleId" : "role3-1", collapsed: true, "children" : [
- { "roleName" : "发票", "roleId" : "role3-1-1", 'link' : '#/fa/apBill', "children" : [] },
- { "roleName" : "应收对账单", "roleId" : "role3-1-2", 'link' : '#/fa/apCheck', "children" : [] }
- ] },
- { "roleName" : "应付", "roleId" : "role3-2", collapsed: true, "children" : [
- { "roleName" : "应付对账单", "roleId" : "role3-2-1", 'link' : '#/fa/arCheck', "children" : [] }
- ]}
- ]},
- { "roleName" : "企业圈", "roleId" : "role4", 'path': 'baseInfo', level: 0, collapsed: true, "children" : [
- { "roleName" : "我的合作伙伴", "roleId" : "role4-1-1", 'link' : '#/baseInfo/myRequest', "children" : [] },
- { "roleName" : "新的合作伙伴", "roleId" : "role4-1-2", 'link' : '#/baseInfo/newPartner', "children" : [] }
- ]},
- { "roleName" : "基础设置", "roleId" : "role5", 'path': 'approvalFlow', collapsed: true, level: 0, "children" : [
- { "roleName" : "企业信息", "roleId" : "role5-1-1", 'link' : '#/approvalFlow/enterprise', "children" : [] },
- { "roleName" : "物料信息", "roleId" : "role5-1-2", 'link' : '#/approvalFlow/product', "children" : [] },
- { "roleName" : "我的产品库", "roleId" : "role5-1-3", 'link' : '#/approvalFlow/userProduct', "children" : [] },
- { "roleName" : "人员信息", "roleId" : "role5-1-4", 'link' : '#/approvalFlow/user', "children" : [] },
- { "roleName" : "角色权限", "roleId" : "role5-1-5", 'link' : '#/approvalFlow/role', "children" : [] },
- { "roleName" : "审批流", "roleId" : "role5-1-6", 'link' : '#/approvalFlow/flow', "children" : [] },
- { "roleName" : "操作日志", "roleId" : "role5-1-7", 'link' : '#/approvalFlow/log', "children" : [] }
- ]}
- ];
- $scope.currentObj = {};
- var hasChildrenObj = function (target) {
- var flag = false;
- if ($scope.currentObj.roleId && target && target.children) {
- angular.forEach(target.children, function (item) {
- if (item.roleId == $scope.currentObj.roleId) {
- flag = true;
- }
- if (item.children.length && hasChildrenObj(item)) {
- flag = true;
- }
- });
- }
- return flag;
- }
- var roopCall = function (arr, callBack) {
- angular.forEach(arr, function (item) {
- if (item.children && item.children.length) {
- roopCall(item.children, callBack);
- }
- callBack(item);
- })
- }
- var initObj = function (arr, flag) {
- angular.forEach(arr, function (item) {
- if (flag) {
- item.collapsed = false;
- }
- if (item.children && item.children.length) {
- initObj(item.children, item.path && item.path == $location.$$path.split('/')[1]);
- } else {
- if (item.link && item.link.split('#')[1] == $location.$$path) {
- item.selected = 'selected';
- $scope.currentObj = item;
- }
- }
- })
- }
- initObj($scope.roleList);
- var initClose = function () {
- roopCall($scope.roleList, function (item) {
- item.collapsed = !hasChildrenObj(item);
- })
- }
- initClose();
- var closeRow = function (arr) {
- angular.forEach(arr, function (item) {
- item.selected = undefined;
- if (item.children) {
- closeRow(item.children);
- }
- })
- }
- $scope.$watch( 'myTree.currentNode', function( newObj, oldObj ) {
- if( $scope.myTree && angular.isObject($scope.myTree.currentNode) ) {
- $scope.currentObj = newObj;
- if (newObj.link) {
- window.location.href = newObj.link
- }
- roopCall($scope.roleList, function (item) {
- if (item.roleId == newObj.roleId) {
- $scope.currentObj = item;
- // item.collapsed = !item.collapsed;
- } else {
- item.collapsed = !hasChildrenObj(item) && (item.roleId != newObj.roleId);
- }
- })
- // 父级菜单不选择
- if ($scope.currentObj.link) {
- closeRow($scope.roleList);
- $scope.currentObj.selected = 'selected';
- } else {
- $scope.currentObj.selected = null;
- }
- }
- }, false);
- }])
- return app;
- });
|