| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042 |
- define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize'], function() {
- 'use strict';
- var app = angular.module('myApp', [ 'toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule']);
- 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
- AuthenticationService.redirectSignin();
- return $q.reject(response);
- }
- return $q.reject(response);
- }
- }
- return httpInterceptor;
- }]);
- app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
- $urlRouterProvider.otherwise('/index');
- $stateProvider.state('index', {
- url : "/index",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/home/left.html",
- controller: 'LeftCtrl'
- },
- "right-view" : {
- templateUrl : "static/tpl/index/home/right.html",
- controller: 'RightCtrl'
- }
- }
- }).state('home', {
- url : "/",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/home/left.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/sale/left.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/purc/left.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('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.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.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'
- }).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.returns', {
- url : "/returns",
- templateUrl : "static/tpl/index/sale/returns.html",
- controller: 'SaleReturnsCtrl'
- }).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('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('account.enterprise', {
- url : "/enterprise",
- templateUrl : "static/tpl/index/account/enterprise.html",
- controller: 'EnterpriseCtrl'
- }).state('account.user', {
- url : "/user",
- templateUrl : "static/tpl/index/account/user.html",
- controller: 'UserCtrl'
- }).state('account.log', {
- url : "/log",
- templateUrl : "static/tpl/index/account/log.html",
- controller: 'LogCtrl'
- }).state('account.resource', {
- url : "/resource",
- templateUrl : "static/tpl/index/account/resource.html",
- controller: 'ResourceCtrl'
- }).state('account.role', {
- url : "/role",
- templateUrl : "static/tpl/index/account/role.html",
- controller: 'RoleCtrl'
- }).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('qc.badIn', {
- url : "/badIn",
- templateUrl : "static/tpl/index/qc/badIn.html",
- controller: 'SaleBadInCtrl'
- }).state('qc.badOut', {
- url : "/badOut",
- templateUrl : "static/tpl/index/qc/badOut.html",
- controller: 'SaleBadOutCtrl'
- }).state('qc.MRB', {
- url : "/MRB",
- templateUrl : "static/tpl/index/qc/MRB.html",
- controller: 'SaleMRBCtrl'
- }).state('fa', {
- url : "/fa",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/fa/left.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.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('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('make.todo', {
- url : "/todo",
- templateUrl : "static/tpl/index/make/todo.html"
- }).state('make.todo.order', {
- url : "/order",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('make.order', {
- url : "/order",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('make.order_detail', {
- url : "/order/:id",
- templateUrl : "static/tpl/index/make/order_detail.html",
- controller: 'MakeOrderDetailCtrl'
- }).state('make.change', {
- url : "/change",
- templateUrl : "static/tpl/index/make/change.html",
- controller: 'MakeChangeCtrl'
- }).state('make.change_detail', {
- url : "/change/:id",
- templateUrl : "static/tpl/index/make/change_detail.html",
- controller: 'MakeChangeDetailCtrl'
- }).state('make.accept', {
- url : "/accept",
- templateUrl : "static/tpl/index/make/accept.html",
- controller: 'MakeAcceptCtrl'
- }).state('make.returns', {
- url : "/returns",
- templateUrl : "static/tpl/index/make/returns.html",
- controller: 'MakeReturnCtrl'
- }).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"
- });
- }]);
-
- /**
- * 表示符号
- */
- 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', function($scope, $rootScope) {
- $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';
- });
- }]);
- app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', 'toaster', 'BaseService', '$modal', function($scope, $window, AuthenticationService, toaster, BaseService, $modal) {
- $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
-
- //手机号码格式验证
- // var checkTel = function(data){
- // var userTel = data.userTel;
- // $scope.checkResult = false;
- // var telephone = /^1[3|4|5|7|8]\d{9}$/;
- // if(!(telephone).test(userTel)){
- // var modalInstance = $modal.open({
- // animation: true,
- // templateUrl: 'static/tpl/index/account/checkTel.html',
- // controller: 'CheckTelCtrl',
- // backdrop: 'static',
- // keyboard: false,
- // resolve: {
- // user: function(){
- // return data;
- // },
- // }
- // });
- // modalInstance.result.then(function(){
- // }, function(){
- //
- // });
- // } else {
- // $scope.checkResult = true;
- // }
- // };
- 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 {
- //跳转到手机号码验证
- // checkTel($scope.userInfo);
- }
- });
- $scope.logout = function() {
- AuthenticationService.logout().success(function() {
- AuthenticationService.redirectSignin();
- });
- };
- $scope.switchto = function(enUU) {// 切换企业
- AuthenticationService.reSignin(enUU).success(function(){
- $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('TodoCtrl', ['$scope', 'SnapshotService', function($scope, SnapshotService){
- SnapshotService.getTodo(function(data){
- $scope.todo = 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', function($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice, toaster, $state, $filter){
- $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.send = function() {// 发货
- if(!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
- toaster.pop('error', '错误', '请输入送货单号');
- 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) {
- toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致、采购员一致才能一起发货。');
- } else {
- var send = angular.extend(angular.copy($scope.saleSend), {
- currency: currency,
- custUU: custUU,
- payments: payments,
- sendItems: items
- });
- PurcNotice.sendByBatch({}, send, function(data){
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + send.code);
- $modalInstance.close(true);
- $state.go('sale.send_detail', {id: data.id});
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- }
- };
- }]);
- 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', function($scope, SnapshotService){
- SnapshotService.getNotice(5, function(data){ //5表示首页显示的公告条数
- $scope.notices = data;
- });
-
- $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', 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 : 10
- }, {
- 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.totalElements);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElements;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
- app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function($scope, $modalInstance, customer, AccountUser, toaster){
- $scope.checkboxes = {
- checked : false
- };
- $scope.loading = true;
- AccountUser.findUsers({uu:customer.myEnterprise.uu},null,function(data) {
- $scope.userinfos = data;
- $scope.loading = false;
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function() {
- angular.forEach($scope.userinfos, function(item) {
- item.distribute = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function(vendor){
- var result = true;
- angular.forEach($scope.userinfos, function(item) {
- if(item.distribute != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $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);
- }
- };
- }]);
- 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;
- }
- return fn;
- };
- /**
- * 改变单据日期范围
- */
- var getDateCondition = function(zone, condition) {
- var date = new Date();
- if(zone == -1) {
- condition.dateFrom = null;
- condition.dateTo = null;
- } else if(zone == 1) {
- date.setMonth(date.getMonth() - 1);
- 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.setMonth(date.getMonth() - 6);
- condition.dateFrom = null;
- condition.dateTo = date;
- }
- };
-
- /**
- * 改变单据交货日期范围
- */
- 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;
- }
- };
-
- app.controller('PurcOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService',
- function($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService){
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1, deliveryZone: -1};
- $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.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 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 : 5,
- 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)
- };
- console.log(getPurcStatus($scope.active));
- PurcOrderItem[getPurcStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
-
- $defer.resolve(page.content);
- params.total(page.totalElements);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $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.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() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PurcOrderItemHis',
- function($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis){
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1, deliveryZone: -1};
- $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.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);
- }
- };
-
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function() {
- return $scope.condition.dateZone ? PurcOrderItem : PurcOrderItemHis;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 5,
- 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);
- params.total(page.totalElements);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $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.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
-
- $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 ? '撤销成功':'回复成功'));
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- //打印
- $scope.print = function(order) {
- PurcOrder.printCount({id: order.id},{});//增加打印此次
- if(order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
- ReportService.print(order.enUU, 'purchase', '{purc_orders.pu_id}=' + order.id, '销售订单-' + order.code);
- };
-
- $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) {
- angular.forEach(order.orderItems, function(item){
- str += item.id;
- str += ',';
- });
- }
- });
- if(!(str == '')) {
- str = str.substr(0, str.length-1);
- PurcOrderItem.replyByBatch(str, function(){
- $scope.loading = false;
- $scope.tableParams.reload();
- toaster.pop('success', '提示', '批量回复成功');
- }, function(data){
- $scope.loading = false;
- toaster.pop('error', '批量回复失败', data);
- });
- } else {//没有勾选其中的明细
- $scope.loading = false;
- }
- };
- // 搜索框回车
- $scope.onSearch = function() {
- $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', '错误', "设置失败");
- });
- }
- }
- };
- }]);
- app.controller('SaleOrderDetailCtrl', ['$scope', '$stateParams', 'PurcOrder', 'PurcOrderItem', 'toaster', 'ReportService', function($scope, $stateParams, PurcOrder, PurcOrderItem, toaster, ReportService){
- 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;
- });
- $scope.order.total = sum;
- if($scope.order.display == 1) {//未查看的设为已查看
- $scope.setDisplay('setRead', $scope.order.id);
- }
- $scope.loading = false;
- });
- };
- 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.print = function(order) {
- PurcOrder.printCount({id: order.id},{});//增加打印此次
- ReportService.print(order.enUU, 'purchase', '{purc_orders.pu_id}=' + order.id, '销售订单-' + order.code);
- };
-
- //设置为已查看
- $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('SaleChangeCtrl', ['$scope', '$filter', 'PurcChange', 'ngTableParams', 'toaster', 'BaseService', 'PurcChangeHis', function($scope, $filter, PurcChange, ngTableParams, toaster, BaseService, PurcChangeHis){
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $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 $scope.condition.dateZone ? PurcChange : PurcChangeHis;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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;
- getService()[getState($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.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};
- $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() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- app.controller('SaleChangeDetailCtrl', ['$scope', '$stateParams', 'PurcChange', 'toaster', function($scope, $stateParams, PurcChange, toaster){
- var loadData = function() {
- PurcChange.get({id: $stateParams.id}, function(data){
- $scope.change = 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', 'PurcInquiryHis', function($scope, $filter, PurcInquiry, ngTableParams, toaster, BaseService, PurcInquiryHis){
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $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 $scope.condition.dateZone ? PurcInquiry : PurcInquiryHis;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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.keyword = $scope.keyword;
- 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.totalElements);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $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.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;
- $scope.loading = true;
- if(withSteps) {
- PurcInquiry.reply({itemId: item.id}, item, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '报价失败', response.data);
- });
- } else {
- PurcInquiry.saveItem({itemId: item.id}, item, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- $scope.verifylapQty = function(value,type) {
- var regex = /^\d+(.\d{1,5})?$/;
- $scope.replylapQtys[type] = regex.test(value);
- }
-
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function(value,type) {
- var regex = /^\d+(.\d{1,5})?$/;//
- 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() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- // 询价单明细
- app.controller('SaleInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry','$filter', 'toaster', function($scope, $stateParams, PurcInquiry,$filter, toaster){
- 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('SaleQuotationListCtrl', ['$scope', '$filter', 'Quotation', 'PurcInquiry', 'ngTableParams', 'toaster', 'BaseService', function($scope, $filter, Quotation, PurcInquiry, ngTableParams, toaster, BaseService){
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $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 Quotation;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- 'quotation.date': '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.totalElements);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $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() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- // Controller 主动报价 - 新增
- app.controller('SaleQuotationNewCtrl', ['$scope', '$stateParams', '$filter', 'ngTableParams', 'toaster', 'BaseService', '$modal', 'Quotation', function($scope, $stateParams, $filter, ngTableParams, toaster, BaseService, $modal, Quotation){
- var staticItem = null;
-
- if( ! angular.isUndefined($stateParams.id)) {// 查看模式
- $scope.loading = true;
- Quotation.getItem({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.item = data;
- staticItem = angular.copy(data);
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- } else {// 新增模式
- $scope.item = {
- quotation: {
- currency: 'RMB',
- taxrate: 17,
- date: new Date()
- },
- 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.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(){
-
- });
- }
- };
-
- // 查找客户物料
- $scope.dbfindCustProd = function(){
- if($scope.item.$editing) {
- if($scope.item.quotation.cust.uu) {
- 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', '错误', '请先选择客户');
- }
- }
- };
-
- // 保存
- $scope.save = function(){
- $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;
- $scope.item.quotation.custUserUU = $scope.item.quotation.custUser.userUU;
- $scope.item.productId = $scope.item.product.id;
- $scope.item.quotation.status = 100;//在录入
- 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.save({}, $scope.item, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- if($stateParams.id)
- window.location.reload();
- else
- window.location.hash = '#/sale/quotation/' + data.id;
- }, 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(){
- $scope.loading = true;
- $scope.item.quotation.status = 101;//在录入
- Quotation.save({}, $scope.item, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '提交成功');
- window.location.hash = '#/sale/quotation/' + data.id;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- }]);
-
- // 查找客户
- app.controller('DbfindCustCtrl', ['$scope', 'Customer', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function($scope, Customer, BaseService, ngTableParams, toaster, $modalInstance){
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- Customer.get(BaseService.parseParams(params.url()), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElements;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $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){
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- 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.totalElements);
- $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('SaleNoticeCtrl', ['$scope', '$rootScope', '$filter', 'PurcNotice', 'ngTableParams', 'toaster', 'BaseService', 'PurcNoticeHis', '$modal', 'SaleTruck', 'Symbol', '$state', function($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, PurcNoticeHis, $modal, SaleTruck, Symbol, $state){
- $scope.active = 'todo';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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.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 $scope.condition.dateZone ? PurcNotice : PurcNoticeHis;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- 'delivery': 'asc',
- 'orderItemOrderCode': 'asc',
- 'orderItemNumber': 'asc'
- }
- }, {
- 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.totalElements);
- $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.autoCode = function(notice){
- notice.send.code = $filter('date')(new Date(), 'yyMMddHHmmss-sss');
- };
-
- //可送货日期
- $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(25);
- } else if(stock >= 0) {
- de.setDate(de.getDate() - stock -1);
- }
- return de;
- };
-
- $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 {
- var send = {code: notice.send.code, remark: notice.send.remark, sendItems: [{qty: notice.send.qty}]};
- $scope.loading = true;
- PurcNotice.save({id: notice.id}, 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);
- });
- }
- };
-
- $scope.checkboxes = {
- checked : false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function(){
- angular.forEach($scope.tableParams.data, function(item) {
- if(!item.waiting)
- 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.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;}
- }
- });
-
- modalInstance.result.then(function(){
- $scope.tableParams.reload();
- }, function(){
-
- });
- };
-
- $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;
- });
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $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);
- }]);
- app.controller('SaleNoticeSendByBatchCtrl', ['$scope', '$modalInstance', 'Symbol', 'selectedNotices', 'PurcNotice', 'toaster', '$state', function($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster, $state){
- $scope.notices = angular.copy(selectedNotices);
- $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.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(item.$selected) {
- 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 {
- PurcNotice.sendByBatch({}, $scope.saleSend, function(data){
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + $scope.saleSend.code);
- $modalInstance.close('success');
- $state.go('sale.send_detail', {id: data.id});
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
-
- /**
- * 发货单
- */
- app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, SaleSend, ngTableParams, toaster, BaseService, Symbol){
- $scope.active = 'all';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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.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 : 5,
- 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.totalElements);
- $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.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 发货单(包括发货条码维护)
- */
- app.controller('SaleSendDetailCtrl', ['$scope', '$stateParams', 'SaleSend', 'toaster', 'ReportService','ngTableParams','Lodop','$modal', function($scope, $stateParams, SaleSend, toaster, ReportService,ngTableParams,Lodop,$modal){
- 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.get({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', 'ReportService', function($scope, $stateParams, PurcSample, toaster, ReportService){
- var loading = true;
- var loadData = function() {
- PurcSample.get({id: $stateParams.id}, function(data){
- $scope.sample = data;
- if(!$scope.sample.send){
- $scope.sample.getSendInfo = '加载中...';
- PurcSample.getSend({id: $stateParams.id}, function(sendData){
- if(sendData) {
- $scope.sample.getSendInfo = null;
- $scope.sample.send = sendData;
- } else {
- $scope.sample.getSendInfo = '无送样信息';
- $scope.sample.send = '无送样信息';
- }
- }, function(response){
- $scope.sample.getSendInfo = '加载失败!';
- });
- }
- $scope.loading = false;
- }, function(response){
- loading = false;
- toaster.pop('error', '获取数据失败', response.data);
- });
- };
- loadData();
- }]);
-
- /**
- * 客户打样申请
- */
- app.controller('SaleSampleCtrl', ['$scope', '$filter', 'PurcSample', 'ngTableParams', 'toaster', '$modal', 'BaseService','ReportService', 'Symbol', function($scope, $filter, PurcSample, ngTableParams, toaster, $modal, BaseService,ReportService, Symbol){
- $scope.active = 'todo';
- $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 PurcSample;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- proofingDate: '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.totalElements);
- $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.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) {
- PurcSample.printCount({id: sample.id},{});//增加打印此次
- ReportService.print(sample.proofing.enUU, 'proofing', '{purc_proofingitems.ppi_id}=' + sample.id, '客户打样申请-' + sample.proofing.code);
- };
-
- $scope.getSend = function(proofing){
- if( !proofing.send) {
- proofing.getSendInfo = '加载中...';
- PurcSample.getSend({id: proofing.id}, function(data){
- if(data) {
- proofing.getSendInfo = null;
- proofing.send = data;
- } else {
- proofing.getSendInfo = '无送样信息';
- proofing.send = '无送样信息';
- }
- }, function(response){
- proofing.getSendInfo = '加载失败!';
- });
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- app.controller('SampleSendCtrl', ['$scope', '$modalInstance', 'sampleItem', 'PurcSample', '$upload', 'toaster', function($scope, $modalInstance, sampleItem, PurcSample, $upload, toaster){
- $scope.sampleItem = sampleItem;
- $scope.sampleItem.sampleSend = $scope.sampleItem.sampleSend || {};
-
- //确认送样
- $scope.ok = function (form) {
- $scope.loading = true;
- 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('danger', '错误', data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss(sampleItem);
- };
- }]);
-
- /**
- * 客户认定单
- */
- app.controller('SaleApprovalCtrl', ['$scope', '$filter', 'PurcApproval', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcApproval, ngTableParams, toaster, BaseService, Symbol){
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $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 PurcApproval;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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.totalElements);
- $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.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();
- };
- }]);
-
- /**
- * 客户采购预测
- */
- app.controller('SaleForecastCtrl', ['$scope', '$filter', 'PurcForecast', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcForecast, ngTableParams, toaster, BaseService, Symbol){
- $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 : 5,
- 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.totalElements);
- $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', function($scope, $filter, PurcAccept, ngTableParams, toaster, BaseService, Symbol){
- $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 PurcAccept;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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;
- getService()[getState($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.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('SaleReturnsCtrl', ['$scope', '$filter', 'PurcReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcReturn, ngTableParams, toaster, BaseService, Symbol){
- $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 PurcReturn;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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;
- getService()[getState($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.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('SaleBadInCtrl', ['$scope', '$filter', 'PurcBadIn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcBadIn, ngTableParams, toaster, BaseService, Symbol){
- $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 PurcBadIn;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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;
- getService()[getState($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.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('SaleBadOutCtrl', ['$scope', '$filter', 'PurcBadOut', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcBadOut, ngTableParams, toaster, BaseService, Symbol){
- $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 PurcBadOut;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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;
- getService()[getState($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.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户MRB
- */
- app.controller('SaleMRBCtrl', ['$scope', '$filter', 'PurcMRB', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcMRB, ngTableParams, toaster, BaseService, Symbol){
- $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 PurcMRB;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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;
- getService()[getState($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.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('SaleApBillCtrl', ['$scope', '$filter', 'FaApBill', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, FaApBill, ngTableParams, toaster, BaseService, Symbol){
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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.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 : 5,
- 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.totalElements);
- $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.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 应付对账单
- */
- app.controller('SaleArCheckCtrl', ['$scope', '$filter', 'FaArCheck', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, FaArCheck, ngTableParams, toaster, BaseService, Symbol){
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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.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 : 5,
- 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.totalElements);
- $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.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', function($scope, $stateParams, FaArCheck, toaster, $state){
- 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', function($scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService , Symbol){
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'todo';
-
- //打印
- $scope.print = function(check) {
- console.log(check);
- FaApCheck.printCount({id: check.id},{});//增加打印此次
- ReportService.print(check.custUu, 'purcapcheck', '{purc_apcheck.pa_id}=' + check.id, '应收对账单-' + check.code);
- };
-
- //状态
- $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 = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- //获取应收对账单全部
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- recordDate: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.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;
- pageParams.searchFilter.keyword = pageParams.keyword;
- FaApCheck[getState($scope.active )](BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $scope.data = $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.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();
- };
- }]);
-
- //应收对账单详情
- app.controller('PurchaseApCheckDetailCtrl',['$scope','toaster','FaApCheck','$stateParams',function($scope,toaster,FaApCheck,$stateParams){
- $scope.haveSelected = true;
- $scope.data = {};
- //控制提交和删除按钮的显示
- $scope.ifShow = true;
- var loadData = function(){
- FaApCheck.get({id:$stateParams.id},function(data){
- $scope.data = data;
- if($scope.data.status){
-
- }else{
- $scope.ifShow = true;
- }
- })
- };
-
- 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(){
- $scope.loading = false;
- toaster.pop('error', '提示', '更新已转数失败');
- });
- }
-
- //删除应收对账单的同时更新来源表已转数
- 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(){
- toaster.pop('error','提示','删除失败');
- });
- $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(){
- $scope.loading = false;
- toaster.pop('error', '提示', '作废失败');
- });
-
- }
-
- }]);
-
- //未对账单据列表
- app.controller('PurchaseApCheckListCtrl',['$scope', 'FaApCheck', 'toaster', '$state','$filter', function($scope, FaApCheck, toaster, $state, $filter){
- $scope.data = {};// 列表数据
- $scope.loading = true;
- $scope.getData = function(){
- FaApCheck.getAll(function(data){
- $scope.data = data;
- angular.forEach($scope.data, function(item) {
- item:{
- $selected:true;
- }
- });
- $scope.loading = false;
- });
- }
-
- $scope.getData();
-
- $scope.condition = {
- $fromOpened:false
- }
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
-
- // 点击筛选根据条件选择数据
- $scope.suuorname = '';
- $scope.sdateFrom = '';
- $scope.sdateTo = '';
- $scope.vuuorname = '';
- $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) {
- angular.forEach($scope.data, function(item) {
- $scope.checkboxes.checked = false;
- item.$selected = false;
- });
- console.log($scope.data);
- $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() + 3600 * 12 * 1000) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- $scope.keywordXls = angular.copy(($scope.condition.uuorname == null ? "" : $scope.condition.uuorname) + "-" + ($scope.condition.venduuorname == null ? "" : $scope.condition.venduuorname));//保存当前取值的关键词
- $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.totalMoney = 0;
- $scope.checkboxes = {
- checked : false
- };
-
- // 点击勾选全部的复选框
- $scope.checkAll = function(){
- $scope.totalMoney = 0;
- $scope.filteredData = $filter('filter')($scope.data,$scope.condition.uuorname,$scope.condition.venduuorname);
- var uuorname = $scope.suuorname;
- var venduuorname = $scope.venduuorname;
- 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();
- };
-
- //获取已选单据总金额
- var total = true;
- $scope.getTotalMoney = function(){
- $scope.totalMoney = 0;
- angular.forEach($scope.data, function(check) {
- if(check.$selected){
- $scope.totalMoney += (check.thisCheckQty || 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.createApCheck = function(){
- //保存应收对账单主记录字段
- $scope.apCheck = {
- custUu: '',
- custName: '',
- enUu: '',
- apDate: '',
- beginDate: '',
- endDate: '',
- checkStatus: '未对账',
- checkAmount: 0,
- currency: '',
- rate: '',
- items: []
- };
- //保存来源单据相关信息
- 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:'',
- 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(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.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){
- toaster.pop('error', '失败', '生成对账失败,请刷新界面');
- })
- };
-
- //如果是同一家客户,生成对账单的同时,关闭模态框
- if($scope.sameCust && $scope.validQty) {
- $scope.saveApCheck();
- }
-
- }
- }]);
-
- app.controller('EnterpriseCtrl', ['$scope', 'AccountEnterprise', 'toaster', '$state', '$modal', function($scope, AccountEnterprise, toaster, $state, $modal){
- $scope.loading = true;
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.enterprise = data;
- });
- AccountEnterprise.growth({}, function(data){
- if(data != null && data.length > 0) {
- var growth = [], years = [];
- angular.forEach(data, function(d){
- var date = new Date(d.date), year = date.getFullYear();
- d.date = (date.getMonth() + 1) + '月' + (date.getDate()) + '日';
- if(years.indexOf(year) == -1) {
- years.push(year);
- growth.push({year: year});
- }
- growth.push(d);
- });
- $scope.growth = growth;
- }
- });
-
- // 更新企业信息
- $scope.updateDetailInfo = function(){
- $scope.loading = true;
- 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', '请完善信息', '申请SAAS服务请先完善企业详细信息');
- }
- };
- }]);
-
- // 申请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 = 'SAAS域名已被使用';
- }
- }).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;
- };
-
- // 设置Saas域名为官网网址一级域名
- 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', '申请成功', '已提交系统开通SAAS服务,开通后将会发送邮件至管理员邮箱');
- $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', function($scope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http, ngAlert){
- $scope.editing = false;
- $scope.loading = true;
- 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 = [];
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- userName: 'asc'
- }
- }, {
- total : 0,
- counts: [15, 25, 50, 100],
- getData : function($defer, params) {
- var orderedData = params.sorting ? $filter('orderBy')(users, params.orderBy()) : users;
- orderedData = params.filter ? $filter('filter')(orderedData, params.filter()) : orderedData;
- $scope.users = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
- params.total(orderedData.length);
- $defer.resolve($scope.users);
- }
- });
- var loadUsers = function() {
- AccountUser.query({}, function(data){
- users = data;
- $scope.tableParams.reload();
- $scope.loading = false;
- });
- };
- loadUsers();
- $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 modalInstance = $modal.open({
- animation: true,
- templateUrl: 'updatePassword.html',
- controller: 'PasswordCtrl',
- resolve: {
- user: function(){return $scope.user;}
- }
- });
-
- modalInstance.result.then(function(){
- }, function(){
- });
- };
-
- $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;
- }, function(){
-
- });
- };
-
-
-
- /**
- * 添加未注册用户
- */
- $scope.addUser = function() {
- $scope.adding = true;
- AccountUser.save({}, $scope.newUser, function(){
- toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
- $scope.newUser = {userSex: 'M'};
- loadUsers();
- $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){
- 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/account/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) {
- 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(!isIssy) {
- toaster.pop('error', '提示', '你不是管理员,无权限分配!请立即联系管理员');
- return;
- }
- var resultRole = true;
- angular.forEach(user.roles,function(role){
- if(role.issys == 1) {
- 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();
- }
- /*$scope.loading = false;
- $scope.btnState = false;
- $scope.clicks = 0;
- var storage = window.localStorage;
- //手机验证码定时器
- $scope.msgInfoError = false;
- var setBtnTimeDown = function(value) {
- if(value > 0) {
- $scope.btnState = true;
- $timeout(function() {
- $scope.$apply(function(){
- storage.setItem("btnTimes", $scope.btnTimes);
- $scope.btnTimes --;
- value --;
- setBtnTimeDown (value);
- });
- }, 500);
- }else{
- $scope.btnState = false;
- }
- };
- if(storage.btnTimes > 1){
- $scope.btnTimes = storage.btnTimes;
- setBtnTimeDown(storage.btnTimes)
- }else{
- storage.removeItem("btnTimes");
- }
- $scope.updateTel = function(phoneCode, userTel, uu){
- $scope.loading = true;
- $scope.msgInfoError = false;
- $scope.result = false;
- //更新联系方式
- AccountUser.updateWithCode({code: phoneCode, tel : userTel, uu: uu},{}, function(data){
- $scope.loading = false;
- $scope.msgInfoError2 = false;
- $scope.result = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $timeout(function(){
- $modalInstance.dismiss();
- window.location.reload();
- }, 1000);
- }).error(function(response) {
-
- });
- }, function(response){
- $scope.loading = false;
- $scope.msgInfoError2 = response;
- });
- };
- //获取验证码
- $scope.getPhoneCode = function(userTel){
- var timeInfo = 10;
- $scope.clicks ++;
- $scope.timeInfo = timeInfo;
- if($scope.clicks >= 5){
- $scope.errorloading = true;
- $scope.msgInfoSuccess = false;
- $scope.msgInfoError = false;
- }else{
- $scope.loading = true;
- SendCheckMsg.sendMsgInfos({userTel: userTel},function(data){
- $scope.loading = false;
- $scope.msgInfoSuccess = data.success;
- $scope.sendMsg = data;
- $scope.btnTimes = 60;
- setBtnTimeDown($scope.btnTimes);
- $scope.msgInfoError = false;
- },function(response){
- console.log(response);
- $scope.loading = false;
- $scope.msgInfoError = false;
- $scope.sendCheckMsg = false;
- $scope.msgInfoSuccess = true;
- });
- }
- }; */
- }]);
- 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;
- // angular.forEach($scope.enters, function(item) {
- // if(item.distribute) {
- // item:{
- // $selected:false;
- // }
- // } else {
- // item:{
- // $selected:true;
- // }
- // }
- // });
- })
- // 点击勾选全部的复选框
- $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) {
- // if(item.distribute) {
- 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) {
- $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.update({}, 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){
- toaster.pop('success', '成功', '修改密码成功,请牢记您的新密码。');
- $scope.user.password = null;
- $scope.user.newPassword = null;
- $scope.user.newPassword1 = null;
- $scope.checking = false;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- } else {
- toaster.pop('error', '错误', '重复密码不一致');
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
-
- /*
- * 绑定用户到企业
- */
- app.controller('AddExistUserCtrl', ['$scope', '$modalInstance', 'FuzzySearch', 'AuthenticationService', function($scope, $modalInstance, FuzzySearch,AuthenticationService){
- $scope.searching = false;
- //根据输入的内容查找用户
- $scope.searchUser = function(keyWord) {
- $scope.searching = true;
- $scope.searchSuccess = false;
- $scope.searchFailed = false;
- $scope.illegalError = false;
- $scope.reBindError = false;
- $scope.bindSuccess = 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.bindSuccess = true; //绑定成功
- $scope.okDisabled = 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.bindSuccess = true; //绑定成功
- $scope.okDisabled = 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 : 5,
- 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 : 5,
- 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/account/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', function($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, ngAlert){
- $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);
- });
- })
- };
- }]);
-
- /**
- * 委外订单
- */
- app.controller('MakeOrderCtrl', ['$scope', '$filter', 'MakeOrder', 'ngTableParams', 'toaster','ReportService', 'BaseService',
- function($scope, $filter, MakeOrder, ngTableParams, toaster,ReportService, BaseService){
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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.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 : 5,
- 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.totalElements);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $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.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', '{make_orders.ma_id}=' + order.id, ' 委外订单-' + order.code);
- };
-
- // 获取回复记录
- $scope.getReply = function(order) {
- if(!order.replies) {
- MakeOrder.getReply({orderId: order.id}, function(replies){
- order.replies = replies;
- });
- }
- };
- }]);
-
- /**
- * 委外加工单详细
- */
- app.controller('MakeOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOrder', 'toaster', 'ReportService', function($scope, $stateParams, MakeOrder, toaster, ReportService){
- var loadData = function() {
- MakeOrder.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- });
- };
- 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', '{make_orders.ma_id}=' + order.id, ' 委外订单-' + order.code);
- };
-
- }]);
- /**
- * 客户委外验收
- */
- app.controller('MakeAcceptCtrl', ['$scope', '$filter', 'MakeAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, MakeAccept, ngTableParams, toaster, BaseService, Symbol){
- $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 MakeAccept;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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.totalElements);
- $defer.resolve(page.content);
- $scope.keywordXls = 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.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户委外验退
- */
- app.controller('MakeReturnCtrl', ['$scope', '$filter', 'MakeReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, MakeReturn, ngTableParams, toaster, BaseService, Symbol){
- $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 MakeReturn;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- 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.totalElements);
- $defer.resolve(page.content);
- $scope.keywordXls = 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.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
- /**
- * 委外加工变更
- */
- app.controller('MakeChangeCtrl', ['$scope', '$filter', 'MakeChange', 'ngTableParams', 'toaster', 'BaseService', function($scope, $filter, MakeChange ,ngTableParams, toaster, BaseService){
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $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 MakeChange;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- orderChangeDate: '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.totalElements);
- $defer.resolve(page.content);
- $scope.keywordXls = 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.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();
- };
- }]);
- app.controller('MakeChangeDetailCtrl', ['$scope', '$stateParams', 'MakeChange', 'toaster', function($scope, $stateParams, MakeChange, toaster){
- var loadData = function() {
- MakeChange.get({id: $stateParams.id}, function(data){
- $scope.change = 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.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 '0天';
- if(d > 0)
- return d + '天';
- if(h > 0)
- return h + '小时';
- if(m > 0)
- return m + '分钟';
- return '0天';
- };
- });
- app.filter('firstchar', function(){
- return function(str) {
- if(str == null)
- return null;
- return str.substring(0, 1);
- };
- });
- /**
- * 搜索框,回车触发
- */
- 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', function($scope, AuthenticationService, toaster){
- $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";
- }
- });
- }
- }]);
- //客户服务
- app.controller('CustServeCtrl', ['$scope', 'Vendor', function($scope, Vendor){
- Vendor.getServe(function(datas){
- $scope.vendors = datas;
- console.log($scope.Vender);
- // 自动跳转
- if(datas && datas.length == 1)
- $scope.redirect(datas[0]);
- });
- $scope.redirect = function(vendor) {
- window.open('purc/vendor/serve/' + vendor.vendorEnterprise.uu);
- };
- }]);
-
- return app;
- });
|