| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222 |
- 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', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder'], 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', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService']);
- app.init = function() {
- angular.bootstrap(document, [ 'myApp' ]);
- };
- app.config([ '$httpProvider', function($httpProvider) {
- // http拦截
- $httpProvider.interceptors.push('httpInterceptor');
- }]);
- app.factory('httpInterceptor', ['$window', '$q', '$injector', 'BaseService', function($window, $q, $injector, BaseService) {
- var httpInterceptor = {
- 'responseError': function(response) {
- if (response.status == 401) {// UNAUTHORIZED
- window.location.href = response.data.loginUrl || 'index';
- return $q.reject(response);
- }
- return $q.reject(response);
- }
- }
- return httpInterceptor;
- }]);
- app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
- $stateProvider.state('index', {
- url : "/index",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/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('purc.order_detail', {
- url : "/order/:id",
- templateUrl : "static/tpl/index/purc/order_detail.html",
- controller: 'PurcOrderDetailCtrl'
- }).state('purc.newOrder', {
- url : "/addOrder",
- templateUrl : "static/tpl/index/purc/addOrder.html",
- controller : 'PurcNewOrderCtrl'
- }).state('purc.cart', {
- url : "/cart",
- templateUrl : "static/tpl/index/purc/cart.html",
- controller : 'CartController'
- }).state('purc.cartDetail', {
- url : "/cart/:id",
- templateUrl : "static/tpl/index/purc/cart_detail.html",
- controller : 'CartDetailController'
- }).state('purc.deputy', {
- url : "/deputy",
- templateUrl : "static/tpl/index/purc/deputyOrder.html",
- controller : 'DeputyOrderCtrl'
- }).state('purc.newdeputy', {
- url : "/deputy/add",
- templateUrl : "static/tpl/index/purc/deputyOrder_new.html",
- controller : 'NewDeputyOrderCtrl'
- }).state('purc.deputydetail', {
- url : "/deputy/:id",
- templateUrl : "static/tpl/index/purc/deputyOrder_detail.html",
- controller : 'DeputyOrderDetailCtrl'
- /* 招标列表 */
- }).state('purc.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/purc/tenderlist.html",
- controller : 'PurcTenderCtrl'
- }).state('purc.done.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/purc/tenderlist.html",
- controller : 'PurcTenderCtrl'
- /* 招标 */
- }).state('purc.tender', {
- url : "/addTender",
- templateUrl : "static/tpl/index/purc/tender.html",
- controller : 'PurcNewTenderCtrl'
- }).state('purc.savedtender', {
- url : "/tender/:id",
- templateUrl : "static/tpl/index/purc/saved_tender.html",
- controller : 'PurcNewTenderCtrl'
- /* 评标 */
- }).state('purc.evaluation', {
- url : "/evaluation/:id",
- templateUrl : "static/tpl/index/purc/tender_evaluation.html",
- controller : 'PurcEvaluationCtrl'
- /* 采购供应商资料 */
- }).state('purc.vendor', {
- url : "/vendor",
- templateUrl : "static/tpl/index/purc/vendor.html",
- controller : 'PurcVendorCtrl'
- /* 采购供应商资料 详情*/
- }).state('purc.vendordetail', {
- url : "/vendor/:id",
- templateUrl : "static/tpl/index/purc/vendor_detail.html",
- controller : 'PurcVendorDetailCtrl'
- /* 客户指定招标列表 */
- }).state('purc.makeoutorder', {
- url : "/makeoutorder",
- templateUrl : "static/tpl/index/make/outorder.html",
- controller: 'MakeOutOrderCtrl'
- }).state('purc.outorder_detail', {
- url : "/makeoutorder/:id",
- templateUrl : "static/tpl/index/make/outorder_detail.html",
- controller: 'MakeOutOrderDetailCtrl'
- /*平台新增询价单*/
- }).state('purc.inquiry_new', {
- url : "/purcinquiry",
- templateUrl : "static/tpl/index/purc/inquiry_new.html",
- controller: 'PurcInquiryCtrl'
- }).state('purc.inquiry', {
- url : "/purchaseinquiry",
- templateUrl : "static/tpl/index/purc/inquiry.html",
- controller: 'PurchaseInquiryCtrl'
- }).state('purc.inquiry_detail', {
- url : "/purcinquirydetail",
- templateUrl : "static/tpl/index/purc/inquiry_detail.html",
- controller: 'PurcInquiryDetailCtrl'
- }).state('purc.inquiry_unapply', {
- url : "/inquiry_unapply",
- templateUrl : "static/tpl/index/purc/inquiry_unapply.html",
- controller: 'UnapplyInquiryCtrl'
- }).state('sale.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/sale/tenderlist.html",
- controller : 'SaleTenderCtrl'
- }).state('sale.todo.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/sale/tenderlist.html",
- controller : 'SaleTenderCtrl'
- /* 平台公开招标列表 */
- }).state('baseInfo.openTenderList', {
- url : "/openTenderList",
- templateUrl : "static/tpl/index/sale/open_tender_list.html",
- controller: 'SaleOpenTenderCtrl'
- /* 查看公开招标详情 */
- }).state('baseInfo.open_tender_detail', {
- url : "/openTenderDetail/:id",
- templateUrl : "static/tpl/index/sale/open_tender_detail.html",
- controller : 'OpenSaleTenderDetailCtrl'
- /* 投标 */
- }).state('sale.tender', {
- url : "/tender/:id",
- templateUrl : "static/tpl/index/sale/tender.html",
- controller : 'SaleTenderDetailCtrl'
- /* 采购方查看供应商投标 */
- }).state('sale.vendortender', {
- url : "/tender/:vendUU/:id",
- templateUrl : "static/tpl/index/sale/vendor_tender.html",
- controller : 'SaleVendorTenderDetailCtrl'
- }).state('sale.todo', {
- url : "/todo",
- templateUrl : "static/tpl/index/sale/todo.html"
- }).state('sale.todo.inquiry', {
- url : "/inquiry",
- templateUrl : "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.todo.order', {
- url : "/order",
- templateUrl : "static/tpl/index/sale/order.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.todo.change', {
- url : "/change",
- templateUrl : "static/tpl/index/sale/change.html",
- controller: 'SaleChangeCtrl'
- }).state('sale.todo.notice', {
- url : "/notice",
- templateUrl : "static/tpl/index/sale/notice.html",
- controller: 'SaleNoticeCtrl'
- }).state('sale.customer', {
- url : "/customer",
- templateUrl : "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.customer_detail', {
- url : "/customer/:id",
- templateUrl : "static/tpl/index/sale/customer_detail.html",
- controller: 'CustomerDetailCtrl'
- }).state('sale.customerProduct', {
- url : "/customerProduct",
- templateUrl : "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.inquiry', {
- url : "/inquiry",
- templateUrl : "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.inquirymould', {
- url : "/mould",
- templateUrl : "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.todo.inquirymould', {
- url : "/mould",
- templateUrl : "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.inquiry_mould_detail', {
- url : "/mould/:id",
- templateUrl : "static/tpl/index/sale/inquiry_mould_detail.html",
- controller: 'SaleInquiryMouldDetailCtrl'
- }).state('sale.inquiry_detail', {
- url : "/inquiry/:id",
- templateUrl : "static/tpl/index/sale/inquiry_detail.html",
- controller: 'SaleInquiryDetailCtrl'
- }).state('sale.quotation', {
- url : "/quotation",
- templateUrl : "static/tpl/index/sale/quotation.html"
- }).state('sale.quotation.new', {
- url : "/new",
- templateUrl : "static/tpl/index/sale/quotation_new.html",
- controller: 'SaleQuotationNewCtrl'
- }).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('sale.prodList', {
- url : "/prodList",
- templateUrl : "static/tpl/index/baseInfo/prodList.html",
- controller : 'ProductListCtrl'
- }).state('sale.newProdInfo', {
- url : "/newProdInfo",
- templateUrl : "static/tpl/index/baseInfo/newProdInfo.html",
- controller : 'NewProdInfoCtrl'
- }).state('sale.uploadByBatch', {
- url : "/uploadByBatch",
- templateUrl : "static/tpl/index/baseInfo/uploadByBatch.html",
- controller : 'UploadByBatchCtrl'
- }).state('sale.productDetail', {
- url : "/prodList/:id",
- templateUrl : "static/tpl/index/baseInfo/productDetail.html",
- controller : 'ProductDetailCtrl'
- }).state('sale.maketodo', {
- url : "/maketodo",
- templateUrl : "static/tpl/index/make/todo.html"
- }).state('sale.maketodo.order', {
- url : "/makeorder",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder', {
- url : "/makeorder",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder_detail', {
- url : "/makeorder/:id",
- templateUrl : "static/tpl/index/make/order_detail.html",
- controller: 'MakeOrderDetailCtrl'
- }).state('sale.badOut', {
- url : "/badOut",
- templateUrl : "static/tpl/index/qc/badOut.html",
- controller: 'SaleBadOutCtrl'
- }).state('sale.MRB', {
- url : "/MRB",
- templateUrl : "static/tpl/index/qc/MRB.html",
- controller: 'SaleMRBCtrl'
- }).state('sale.badIn', {
- url : "/badIn",
- templateUrl : "static/tpl/index/qc/badIn.html",
- controller: 'SaleBadInCtrl'
- }).state('sale.makeaccept', {
- url : "/makeaccept",
- templateUrl : "static/tpl/index/make/accept.html",
- controller: 'MakeAcceptCtrl'
- }).state('sale.makereturns', {
- url : "/makereturns",
- templateUrl : "static/tpl/index/make/returns.html",
- controller: 'MakeReturnCtrl'
- }).state('sale.makechange', {
- url : "/makechange",
- templateUrl : "static/tpl/index/make/change.html",
- controller: 'MakeChangeCtrl'
- }).state('sale.makechange_detail', {
- url : "/makechange/:id",
- templateUrl : "static/tpl/index/make/change_detail.html",
- controller: 'MakeChangeDetailCtrl'
- }).state('account', {
- url : "/account",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/account/left.html",
- controller: 'LeftCtrl'
- },
- "right-view" : {
- templateUrl : "static/tpl/index/account/right.html"
- }
- }
- }).state('account.index', {
- url : "",
- templateUrl : "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('account.home', {
- url : "/",
- templateUrl : "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('baseInfo', {//基础资料
- url : "/baseInfo",
- views : {
- "left-view" : {
- },
- "right-view" : {
- templateUrl : "static/tpl/index/baseInfo/right.html"
- }
- }
- }).state('baseInfo.index', {
- url : "/enterpriseList",
- templateUrl : "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.home', {
- url : "/enterpriseList",
- templateUrl : "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.enterpriseList', {
- url : "/enterpriseList",
- templateUrl : "static/tpl/index/baseInfo/enterpriseList.html",
- controller : 'EnterpriseListCtrl'
- }).state('baseInfo.myClient', {
- url : "/myClient",
- templateUrl : "static/tpl/index/baseInfo/myClient.html",
- controller : 'MyClientCtrl'
- }).state('baseInfo.mySupplier', {
- url : "/mySupplier",
- templateUrl : "static/tpl/index/baseInfo/mySupplier.html",
- controller : 'MySupplierCtrl'
- }).state('baseInfo.myRequest', {
- url : "/myRquest",
- templateUrl : "static/tpl/index/baseInfo/myRequest.html",
- controller : 'AddPartnerRequestCtrl'
- }).state('baseInfo.myMessage', {
- url : "/myMessage",
- templateUrl : "static/tpl/index/baseInfo/myMessage.html",
- controller : 'AddPartnerMessageCtrl'
- }).state('baseInfo.myPartners', {
- url : '/myPartners',
- templateUrl : "static/tpl/index/baseInfo/myPartners.html",
- controller : 'MyPartnersCtrl'
- }).state('baseInfo.businessGroups', {
- url : '/businessGroups',
- controller : 'BusinessGroupsCtrl'
- }).state('qc', {
- url : "/qc",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/qc/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/qc/right.html"
- }
- }
- }).state('qc.index', {
- url : "",
- templateUrl : "static/tpl/index/qc/index.html"
- }).state('qc.home', {
- url : "/",
- templateUrl : "static/tpl/index/qc/index.html"
- }).state('fa', {
- url : "/fa",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/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('cs', {// 客户服务
- url : "/cs",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/cs/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/cs/right.html"
- }
- }
- }).state('cs.index', {
- url : "",
- templateUrl : "static/tpl/index/cs/index.html"
- }).state('cs.home', {
- url : "/",
- templateUrl : "static/tpl/index/cs/index.html"
- }).state('search', { //顶部搜索
- url: "/search?keyword=",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/search/left.html"
- },
- "right-view" : {
- templateUrl: "static/tpl/index/search/search_result.html",
- controller: 'TopSearchCtrl'
- }
- }
- }).state('approvalflow', { //审批流
- url: "/approvalFlow",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/approvalFlow/left.html"
- },
- "right-view" : {
- templateUrl: "static/tpl/index/approvalFlow/right.html",
- }
- }
- }).state('approvalflow.flow', {
- url : "/flow",
- templateUrl : "static/tpl/index/approvalFlow/home.html",
- controller: 'approvalFlowCtrl'
- }).state('approvalflow.enterprise', {
- url : "/enterprise",
- templateUrl : "static/tpl/index/approvalFlow/enterprise.html",
- controller: 'EnterpriseCtrl'
- }).state('approvalflow.user', {
- url : "/user",
- templateUrl : "static/tpl/index/approvalFlow/user.html",
- controller: 'UserCtrl'
- }).state('approvalflow.log', {
- url : "/log",
- templateUrl : "static/tpl/index/approvalFlow/log.html",
- controller: 'LogCtrl'
- }).state('approvalflow.resource', {
- url : "/resource",
- templateUrl : "static/tpl/index/approvalFlow/resource.html",
- controller: 'ResourceCtrl'
- }).state('approvalflow.role', {
- url : "/role",
- templateUrl : "static/tpl/index/approvalFlow/role.html",
- controller: 'RoleCtrl'
- });
- $urlRouterProvider.otherwise('/index');
- }]);
-
-
- /**
- * 表示符号
- */
- app.factory('Symbol', function(){
- return {
- currency: function(cur) {
- if(cur == 'RMB') return '¥';
- else if(cur == 'USD') return '$';
- else if(cur == 'EUR') return '€';
- else if(cur == null || cur == '') return '¥';
- else return cur;
- }
- };
- }).factory('Lodop',function(){
- return {
- getLodop:function(oOBJECT,oEMBED){
- var CreatedOKLodop7766=null;
- /**************************
- 本函数根据浏览器类型决定采用哪个页面元素作为Lodop对象:
- IE系列、IE内核系列的浏览器采用oOBJECT,
- 其它浏览器(Firefox系列、Chrome系列、Opera系列、Safari系列等)采用oEMBED,
- 如果页面没有相关对象元素,则新建一个或使用上次那个,避免重复生成。
- 64位浏览器指向64位的安装程序install_lodop64.exe。
- **************************/
- var strHtmInstall="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtmUpdate="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtm64_Install="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtm64_Update="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtmFireFox="<br><br><font color='#FF00FF'>(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)</font>";
- var strHtmChrome="<br><br><font color='#FF00FF'>(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)</font>";
- var LODOP;
- try{
- //=====判断浏览器类型:===============
- var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
- var is64IE = isIE && (navigator.userAgent.indexOf('x64')>=0);
- //=====如果页面有Lodop就直接使用,没有则新建:==========
- if (oOBJECT!=undefined || oEMBED!=undefined) {
- if (isIE)
- LODOP=oOBJECT;
- else
- LODOP=oEMBED;
- } else {
- if (CreatedOKLodop7766==null){
- LODOP=document.createElement("object");
- LODOP.setAttribute("width",0);
- LODOP.setAttribute("height",0);
- LODOP.setAttribute("style","position:absolute;left:0px;top:-100px;width:0px;height:0px;");
- if (isIE) LODOP.setAttribute("classid","clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
- else LODOP.setAttribute("type","application/x-print-lodop");
- document.documentElement.appendChild(LODOP);
- CreatedOKLodop7766=LODOP;
- } else
- LODOP=CreatedOKLodop7766;
- };
- //=====判断Lodop插件是否安装过,没有安装或版本过低就提示下载安装:==========
- if ((LODOP==null)||(typeof(LODOP.VERSION)=="undefined")) {
- if (navigator.userAgent.indexOf('Chrome')>=0)
- document.documentElement.innerHTML=strHtmChrome+document.documentElement.innerHTML;
- if (navigator.userAgent.indexOf('Firefox')>=0)
- document.documentElement.innerHTML=strHtmFireFox+document.documentElement.innerHTML;
- if (is64IE) document.write(strHtm64_Install); else
- if (isIE) document.write(strHtmInstall); else
- document.documentElement.innerHTML=strHtmInstall+document.documentElement.innerHTML;
- return LODOP;
- } else
- if (LODOP.VERSION<"6.1.9.8") {
- if (is64IE) document.write(strHtm64_Update); else
- if (isIE) document.write(strHtmUpdate); else
- document.documentElement.innerHTML=strHtmUpdate+document.documentElement.innerHTML;
- return LODOP;
- };
- //=====如下空白位置适合调用统一功能(如注册码、语言选择等):====
- LODOP.SET_LICENSES("深圳市优软科技有限公司","BBF53BD5AB0D522B3207D05CDE381F65","","");
-
- //============================================================
- return LODOP;
- } catch(err) {
- if (is64IE)
- document.documentElement.innerHTML="Error:"+strHtm64_Install+document.documentElement.innerHTML;else
- document.documentElement.innerHTML="Error:"+strHtmInstall+document.documentElement.innerHTML;
- return LODOP;
- };
- }
- }
- });
-
- app.controller('MyCtrl', ['$scope', '$rootScope', '$modal', function($scope, $rootScope, $modal) {
- $rootScope.$on('$locationChangeSuccess', function(evt, newUrl) {
- var routeState = newUrl.substr(newUrl.indexOf('#/') + 2);
- if (routeState.indexOf('/') > -1)
- routeState = routeState.substring(0, routeState.indexOf('/'));
- if (routeState.indexOf('.') > -1)
- routeState = routeState.substring(0, routeState.indexOf('.'));
- $scope.routeState = routeState || 'home';
- });
-
- $scope.search = function(keyword) {
- if(keyword != null ) {
- $rootScope.searchKeyword = keyword;
- window.location.hash = '#/search?keyword='+keyword;
- }
- };
- $scope.showMessage = function() {
- $rootScope.isOpen = true;
- var $modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/home/pagingRelease.html',
- controller: 'PagingReleaseCtrl'
- });
- };
- }]);
- app.controller('PagingReleaseCtrl', ['$scope', 'PagingRelease', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function($scope, PagingRelease, BaseService, ngTableParams, toaster, $modalInstance){
- BaseService.scrollBackToTop();
- $scope.active = "todo";
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- 'releaseDetail.release.date': 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- // fromDate: getDateTime($scope.condition.dateFrom),
- // endDate: getDateTime($scope.condition.dateTo)
- };
- // AccountEnterprise.get({}, function(data){
- // $scope.loading = false;
- // $scope.currentEn = data;
- // });
- PagingRelease[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.close = function() {
- $modalInstance.close();
- };
- $scope.checks = {
- checked : false
- };// 全选框
- $scope.checkAll = function() {
- angular.forEach($scope.tableParams.data, function(message) {
- message.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function(message) {
- message.checked = true;
- };
- // 标为已读
- $scope.setRead = function() {
- var selectedMessages = [];
- angular.forEach($scope.tableParams.data, function(message) {
- if(message.checked) {
- selectedMessages.push(message);
- }
- });
- console.log(selectedMessages);
- PagingRelease.setRead({}, selectedMessages , function(message) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- });
- };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- app.filter('getkey', ['$sce', '$rootScope', function($sce, $rootScope) {
- var search = $rootScope.searchKeyword;
- return function(content, search) {
- content = encodeURI(content);
- search = encodeURI(search);
- var reg = new RegExp(search, 'gim');
- var result = content.replace(reg,'<font color="red">$&</font>');
- result = decodeURI(result);
- return $sce.trustAsHtml(result);
- }
- }]);
-
- /**
- * 顶部搜索
- */
- app.controller('TopSearchCtrl', ['$scope', '$rootScope', 'getAccountUserSpace', 'ngTableParams', 'toaster', 'BaseService', 'AddPartner', '$filter', '$stateParams', 'SearchProd', '$sce', '$modal', 'InvitationRecord', function($scope, $rootScope, getAccountUserSpace, ngTableParams, toaster, BaseService, AddPartner, $filter, $stateParams, SearchProd, $sce, $modal, InvitationRecord) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.tip = $rootScope.searchKeyword;
-
- // 企业搜索
- var getService = function() {
- return getAccountUserSpace;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page) {
- $scope.loading = false;
- if(page) {
- $scope.total = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 添加合作关系
- $scope.addPartner = function(name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function(data) {
- if(data.success) {
- toaster.pop("success", '添加成功', data.success);
- }
- if(data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
-
- // 物料搜索
- var getProdService = function() {
- return SearchProd;
- };
- $scope.prodTableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getProdService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- $scope.prodtotal = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- /**
- * 向企业购买
- */
- $scope.PurcByEn = function(businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
-
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function(businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
-
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function(name) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function(){return name}
- }
- });
- modalInstance.result.then(function(data) {
- InvitationRecord.invite({formStore: data}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
-
- }]);
-
- app.controller('InviteCtrl', ['$scope', 'toaster', '$modalInstance', 'enname', function($scope, toaster, $modalInstance, enname) {
- $scope.enter = {
- vendname: enname
- };
-
- $scope.save = function(enter) {
- if(!enter.vendusertel && !enter.venduseremail) {
- toaster.pop('info', '提示', '手机号或邮箱至少填写一个才能通知到客户');
- } else {
- $modalInstance.close(enter);
- }
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- 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();
- };
- $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('ImageInsertCtrl', ['$scope', '$modalInstance', function($scope, $modalInstance) {
- $scope.image = {src: null};
- // 图片上传成功之后
- $scope.onUploadSuccess = function(data){
- var path = data.path;
- path = path.substring(0, path.lastIndexOf('.')) + "_150x90" + path.substr(path.lastIndexOf('.'));
- $scope.$apply(function(){
- $scope.image.src = data.path;
- $scope.image.thumb = path;
- });
- };
- $scope.close = function() {
- $modalInstance.dismiss();
- };
- $scope.confirm = function() {
- $modalInstance.close($scope.image);
- $scope.imageUrl = null;
- };
- }]);
-
- app.controller('TodoCtrl', ['$scope', 'SnapshotService', 'BaseService', function($scope, SnapshotService, BaseService){
- BaseService.scrollBackToTop();
- 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('TenderCtrl', ['$scope', 'SnapshotService', function($scope, SnapshotService){
- SnapshotService.getTender(250, function(data){
- $scope.tenders = data;
- console.log(data);
- var newDate = new Date();
- newDate = newDate.setDate(newDate.getDate() - 3);
- angular.forEach($scope.tenders, function(tender) {
- if (tender.date > newDate) {
- tender.isNew = true;
- } else {
- tender.isNew = false;
- }
- });
- });
- SnapshotService.getOpenTender(250, function(data){
- $scope.openTenders = data;
- var newDate = new Date();
- console.log(data);
- newDate = newDate.setDate(newDate.getDate() - 3);
- angular.forEach($scope.openTenders, function(tender) {
- if (tender.date > newDate) {
- tender.isNew = true;
- } else {
- tender.isNew = false;
- }
- });
- });
- $scope.dateTime = new Date();
- }]);
- app.controller('VendCountCtrl', ['$scope', 'VendorService', function($scope, VendorService){
- VendorService.getCount(function(date){
- $scope.count = date;
- });
- }]);
-
- // 客户
- app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
- BaseService.scrollBackToTop();
- $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;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get(BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
-
- // 查看详情
- $scope.viewDetail = function(id) {
- console.log(id);
- window.location.hash = "#/sale/customer/" + id;
- }
- }]);
-
- // 客户详情
- app.controller('CustomerDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', 'VendorService', 'AuthenticationService', function($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope, VendorService, AuthenticationService) {
- BaseService.scrollBackToTop();
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.vendorContacts = [];
- var loadData = function() {
- Vendor.getVendorDetail({id: $stateParams.id}, {}, function(data) {
- $scope.customer = data.myEnterprise;
- $scope.customerInfo = data;
- Vendor.custContacts({enuu: $scope.customer.uu}, {}, function(data) {
- $scope.Contacts = data;
- });
-
- // 查看已分配人员
- VendorService.userInfo.query({uu: $scope.customer.uu},null,function(data) {
- $scope.custInfos = data;
- var getPage = function(page, size){
- if($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1)*size, page * size);
- if($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- }else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1,4);
- $scope.first = function (){
- $scope.userdata = getPage($scope.userdata.pre,4);
- }
- $scope.last = function (){
- $scope.userdata = getPage($scope.userdata.next,4);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- });
- };
- loadData();
-
- // 新增客户联系人
- $scope.addContact = function(uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- $scope.contact.myenuu = uu;
- Vendor.saveCustContact({}, $scope.contact, function(data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.Contacts.push(data);
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- // 编辑客户联系人
- $scope.edit = function(contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function() {
- return contact;
- }
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- Vendor.saveContact({}, $scope.contact, function(data) {
- toaster.pop('success', '提示', '联系人修改成功');
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- // 删除客户联系人
- $scope.deleteById = function(id, index) {
- $scope.Contacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '供应商联系人删除成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 供应商物料信息
- $scope.viewProdList = function(uu){
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.addUserInfo = function() {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function() {
- return $scope.customerInfo;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
-
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
- }]);
-
- 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;
- case 'invalid':
- fn = 'getInvalid';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){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $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)
- };
- PurcOrderItem[getPurcStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- $defer.resolve(page.content);
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.getReply = function(item) {
- if(!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
-
- $scope.getOrderTotal = function(items) {
- var sum = 0;
- angular.forEach(items, function(item){
- sum += item.qty * item.price;
- });
- return sum;
- };
-
- $scope.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(keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.tip = keyword;
- };
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- app.controller('PurcOrderDetailCtrl', ['$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, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
- // };
-
- //设置为已查看
- $scope.setDisplay = function(state, orderId) {
- if(orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function(){
- // $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function(order) {
- if(order.$selected == true) {
- if(str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if(str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function(){
- $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- }]);
-
- app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PurcOrderItemHis',
- function($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis){
- BaseService.scrollBackToTop();
- $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',
- id: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 15, 25, 50],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- $defer.resolve(page.content);
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $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, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
- };
-
- $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, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
- };
-
- //设置为已查看
- $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){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.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){
- BaseService.scrollBackToTop();
- $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);
- }
- };
-
- // 得到消息
- PurcInquiry.getMessage({}, function(data){
- console.log(data);
- $scope.message = data;
- }, function(response) {
-
- });
- 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.totalElement);
- $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('PurcInquiryCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'GetProductInfo', '$timeout', function($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, GetProductInfo, $timeout) {
- BaseService.scrollBackToTop();
- $scope.status = 'InquiryNew';
- $scope.active = 'all';
- $rootScope.tenderVendor = null;// 清除掉已选择的
- var getService = function() {
- return GetProductInfo;
- };
- $scope.inquiry = {
- code: 'XJ' + $filter('date')(new Date(), 'yyMMddsss'),
- showdate: $filter('date')(new Date, 'yyyy-MM-dd')
- };
-
- $scope.currentDay = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
-
- $scope.vendors = [];
- // 查找供应商
- $scope.dbfindVendor = function(){
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {
- }
- });
- modalInstance.result.then(function(data){
- var ifPush = true;
- modalInstance.result.then(function(data){
- angular.forEach(data, function(vendor) {
- if (!$scope.vendors) {// 不存在就先创建
- $scope.vendors = [{}];
- $scope.vendors.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0;i<$scope.vendors.length; i++) {
- ifPush = true;
- if ($scope.vendors[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.vendors.push({enName: vendor.vendorEnterprise.enName, enuu: vendor.vendorEnterprise.uu});
- }
- }
- });
- $rootScope.tenderVendor = $scope.vendors;
- }, function(){
- });
- }, function(){
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function(index) {
- $scope.vendors.splice(index, 1);
- };
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $scope.inquiry.inquiryItems = [];
- //删除商品
- $scope.del = function(index) {
- $scope.inquiry.inquiryItems.splice(index, 1);
- };
-
- $scope.check = function(product) {
- $scope.inquiry.inquiryItems.push({prodCode: product.code, prodTitle: product.title, spec: product.spec, unit: product.unit,
- currency: null, toDate: null, productId: product.id});
- }
-
- $scope.getMinDate = function(item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
-
- $scope.openDatePicker = function($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.inquiry.inquiryItems[index].$toDateOpen = !openParam;
- };
-
- $scope.openEndDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 保存
- $scope.save = function() {
- // var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- // $upload.upload({
- // url: 'product/baseInfo/updateProdInfo',
- // file: file,
- // method: 'POST',
- // data: {
- // prodInfo: $scope.prodInfo
- // },
- // }).success(function(data) {
- // if(data.success) {
- // toaster.pop('success', '提示', data.success);
- // window.location.reload();
- // }
- // if(data.error) {
- // toaster.pop('error', '提示', data.error);
- // }
- // }).error(function(data) {
- // $scope.loadingShow = false;
- // toaster.pop('error', '操作失败', data.error);
- // });
- PurchaseInquiry.save({inquiry: $scope.inquiry}, $scope.vendors, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.loaction.hash = "#/purc/inquiry_unapply";
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 保存并提交
- $scope.submit = function() {
- PurchaseInquiry.submit({inquiry: $scope.inquiry}, $scope.vendors, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = "#/purc/inquiry_unapply";
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 平台询价单(已提交)
- app.controller('PurchaseInquiryCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', 'PurchaseInquiry', function($scope, $filter, ngTableParams, toaster, BaseService, PurchaseInquiry) {
- $scope.status = 'InquirySubmit';
- BaseService.scrollBackToTop();
- $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 PurchaseInquiry;
- };
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 采纳
- $scope.accept = function(id) {
- PurchaseInquiry.accept({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
-
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- };
-
- // 拒绝
- $scope.refuse = function(id) {
- PurchaseInquiry.refuse({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
-
- // 平台询价单(未提交)
- app.controller('UnapplyInquiryCtrl', ['$scope', 'PurchaseInquiry', 'ngTableParams', 'BaseService', 'toaster', function($scope, PurchaseInquiry, ngTableParams, BaseService, toaster) {
- BaseService.scrollBackToTop();
- $scope.status = 'InquiryUnSubmit';
- $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 = {};
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- PurchaseInquiry.getUnapply(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 删除明细
- $scope.deleteById = function(id) {
- PurchaseInquiry.deleteById({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 删除主表
- $scope.clearOrder = function(id) {
- PurchaseInquiry.clearOrder({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 提交
- $scope.submit = function(id) {
- PurchaseInquiry.submitUnapply({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '单据提交成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- // 询价单明细
- app.controller('PurcInquiryDetailCtrl', ['$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('SaleInquiryMouldCtrl',['$scope', '$filter', 'PurcInquiryMould', 'ngTableParams', 'toaster', 'BaseService', '$upload', function($scope, $filter, PurcInquiryMould, ngTableParams, toaster, BaseService, $upload){
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- var inquiryMould_copy = {};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = 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 PurcInquiryMould;
- };
-
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5
- },{
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.keyword = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- // 用来验证价格修改
- var mould = page.content;
- inquiryMould_copy = angular.copy(mould);
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- })
-
- $scope.getMinDate = function(item) {
- return $filter('date')(item.inquiryMould.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replyPrices.push(true);
-
- // 取消
- $scope.reload = function() {
- $scope.tableParams.reload();
- $scope.canSave = false;
- }
-
- // 能否保存设置
- $scope.canSave = false;
-
-
- // items价格验证
- $scope.verifyItems = function(price, reply) {
- var regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;// ^[0-9]+(\.[0-9]{1,6})?$
- if(regex.test(price) && price != 0) {
- if (price != reply) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
-
-
- // prod下prods价格验证
- $scope.verifyProds = function(price, reply) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if(regex.test(price) && price != 0) {
- if (price != reply) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
-
- //有价格为0或者不符合正则式,则不能报价
- $scope.notZero = function (mould) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- angular.forEach(mould.inquiryMouldItems, function(item){
- if (item.price == 0 || !regex.test(item.price)) {
- $scope.canSave = false;
- }
- angular.forEach(item.inquiryMouldDetails, function(detail){
- if (detail.price == 0 || !regex.test(detail.price)) {
- $scope.canSave = false;
- }
- })
-
- });
- }
-
- $scope.blurPrice = function (price) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (!regex.test(price)) {
- toaster.pop('warning','格式错误','请输入有效价格');
- }
- }
-
- // 获取历史报价
- $scope.getHistory = function(mould) {
- if(!mould.history) {
- PurcInquiryMould.getHistory({id: mould.id}, function(data){
- mould.history = data;
- console.log(mould.history);
- });
- }
- };
-
- $scope.uploadAttach = function(mould) {
- // var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
- var file = mould.attachs[0];
- $scope.mould = mould;
- $upload.upload({
- url: 'sale/mould/' + mould.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.mould
- }
- }).success(function(res){
- console.log("success");
- console.log(res);
- }).error(function(res){
- console.log("failure");
- console.log(res);
- });
- }
-
-
- // 保存并确认报价
- $scope.onReplyClick = function(mould, withSteps) {
- $scope.loading = true;
- //// var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
- // var file = mould.attachs[0];
- // $scope.mould = mould;
- // $upload.upload({
- // url: 'sale/mould/' + mould.id + '/send',
- // method: 'POST',
- // file: file,
- // data: {
- // json: $scope.mould
- // }
- // }).success(function(res){
- // console.log("success");
- // console.log(res);
- // }).error(function(res){
- // console.log("failure");
- // });
-
- if(withSteps) {
- PurcInquiryMould.reply({id: mould.id}, mould, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- $scope.canSave = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '报价失败', response.data);
- });
- PurcInquiryMould.saveHistory({id: mould.id}, mould, function(){
- }, function(response){
-
- });
- } else {
- PurcInquiryMould.saveItem({id: mould.id}, mould, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
-
-
- }]);
-
-
- // 模具询价单明细
- app.controller('SaleInquiryMouldDetailCtrl', ['$scope', '$stateParams', 'PurcInquiryMould','$filter', 'toaster','$upload', function($scope, $stateParams, PurcInquiryMould, $filter, toaster, $upload){
-
- var inquiryMould_copy = {};
- var loadData = function() {
- PurcInquiryMould.getAll({id: $stateParams.id}, function(data){
- // 用来验证价格修改
- inquiryMould_copy = angular.copy(data);
- $scope.inquiryMould_copy = inquiryMould_copy;
- $scope.newinquirymould = data;
- var mould = data;
- angular.forEach(mould.attachs, function(attach){
- attach.type = attach.name.substr(attach.name.lastIndexOf('.')+1);
- });
- $scope.inquiryMould = mould;
- });
- };
- loadData();
- $scope.getMinDate = function(item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
-
-
- // 取消
- $scope.reload = function() {
- loadData();
- $scope.canSave = false;
- }
-
- //有价格为0,则不能报价
- $scope.notZero = function (mould) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- angular.forEach(mould.inquiryMouldItems, function(item){
- if (item.price == 0 || !regex.test(item.price)) {
- $scope.canSave = false;
- }
- angular.forEach(item.inquiryMouldDetails, function(detail){
- if (detail.price == 0 || !regex.test(detail.price)) {
- $scope.canSave = false;
- }
- })
-
- });
- }
-
- $scope.blurPrice = function (price) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (!regex.test(price)) {
- toaster.pop('warning','格式错误','请输入有效价格');
- }
- }
-
- // 获取历史报价
- $scope.getHistory = function(mould) {
- if(!mould.history) {
- PurcInquiryMould.getHistory({id: mould.id}, function(data){
- mould.history = data;
- console.log(mould.history);
- });
- }
- };
-
-
- $scope.canSave = false;
-
- // items价格验证
- $scope.verifyItems = function(price, index) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if(regex.test(price) && price != 0) {
- var itemprice = $scope.inquiryMould.inquiryMouldItems[index].price;
- if (itemprice != inquiryMould_copy.inquiryMouldItems[index].price) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
-
- // prod下prods价格验证
- $scope.verifyProds = function(price, index, parentIndex) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if(regex.test(price) && price != 0) {
- var prodPrice = $scope.inquiryMould.inquiryMouldItems[parentIndex].inquiryMouldDetails[index].price;
- if (prodPrice != inquiryMould_copy.inquiryMouldItems[parentIndex].inquiryMouldDetails[index].price) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
-
- // // 上传附件
- // $scope.uploadAttach = function(mould) {
- //// var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
- // var file = mould.attachs[0];
- // $scope.mould = mould;
- // $upload.upload({
- // url: 'sale/mould/' + mould.id + '/send',
- // method: 'POST',
- // file: file,
- // data: {
- // json: $scope.mould
- // }
- // }).success(function(res){
- // console.log("success");
- // console.log(res);
- // }).error(function(res){
- // console.log("failure");
- // console.log(res);
- // });
- // }
-
-
- $scope.onReplyClick = function(mould, withSteps) {
- $scope.loading = true;
- // var file = mould.attachs[0];
- // $scope.mould = mould;
- // $upload.upload({
- // url: 'sale/mould/' + mould.id + '/send',
- // method: 'POST',
- // file: file,
- // data: {
- // json: $scope.mould
- // }
- // }).success(function(res){
- //
- // }).error(function(res){
- // console.log(res);
- // });
-
- if(withSteps) {
- PurcInquiryMould.reply({id: mould.id}, mould, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- loadData();
- $scope.canSave = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '报价失败', response.data);
- });
- PurcInquiryMould.saveHistory({id: mould.id}, mould, function(){
- }, function(response){
-
- });
- } else {
- PurcInquiryMould.saveItem({id: mould.id}, mould, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- }]);
-
-
- // 主动报价 - 列表
- app.controller('SaleQuotationListCtrl', ['$scope', '$filter', 'Quotation', 'PurcInquiry', 'ngTableParams', 'toaster', 'BaseService', function($scope, $filter, Quotation, PurcInquiry, ngTableParams, toaster, BaseService){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $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){
- BaseService.scrollBackToTop();
- 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){
- BaseService.scrollBackToTop();
- $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;
- Customer.get(BaseService.parseParams(pageParams), 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.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- $scope.check = function(cust){
- $modalInstance.close(cust);
- };
- }]);
-
- // 查找客户物料
- app.controller('DbfindCustProdCtrl', ['$scope', 'Product', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'custUU', function($scope, Product, BaseService, ngTableParams, toaster, $modalInstance, custUU){
- BaseService.scrollBackToTop();
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 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('DbfindVendorCtrl', ['$scope', 'Vendor', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance','$rootScope', function($scope, Vendor, BaseService, ngTableParams, toaster, $modalInstance, $rootScope){
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [10, 25, 50, 100],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // 添加供应商时,将已存在的选中
- if ($rootScope.tenderVendor) {
- angular.forEach(page.content, function(vendor) {
- for (var i = 0; i<$rootScope.tenderVendor.length; i++) {
- vendor.checked = false;
- if (vendor.vendorEnterprise.enName == $rootScope.tenderVendor[i].enName) {
- vendor.checked = true;
- break;
- }
- }
- });
- }
- }
- $scope.totalCount = page.totalElements;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- $scope.checks = {
- checked : false
- };// 全选框
- $scope.checkAll = function() {
- angular.forEach($scope.tableParams.data, function(vendor) {
- vendor.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function(vendor) {
- vendor.checked = true;
- };
- // 单反选
- $scope.unCheckOne = function(vendor) {
- vendor.checked = false;
- };
- $scope.close = function(){
- var vendors = [];
- angular.forEach($scope.tableParams.data, function(vendor) {
- if(vendor.checked) {
- vendors.push(vendor);
- $modalInstance.close(vendors);
- }
- });
- };
- }]);
-
- // 发货提醒
- app.controller('SaleNoticeCtrl', ['$scope', '$rootScope', '$filter', 'PurcNotice', 'ngTableParams', 'toaster', 'BaseService', 'PurcNoticeHis', '$modal', 'SaleTruck', 'Symbol', '$state', function($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, PurcNoticeHis, $modal, SaleTruck, Symbol, $state){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- //生成随机单号
- $scope.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){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.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){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.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) {
- console.log(sample);
- PurcSample.printCount({id: sample.id},{});//增加打印此次
- ReportService.print(sample.proofing.enUU, 'PURCPROOFING',"where purc$proofingitems.ppi_id =" + sample.id);
- };
-
- $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){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.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){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcForecast;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 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) {
- console.log(page);
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户采购验收
- */
- app.controller('SaleAcceptCtrl', ['$scope', '$filter', 'PurcAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcAccept, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $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 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.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户采购验退
- */
- app.controller('SaleReturnsCtrl', ['$scope', '$filter', 'PurcReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcReturn, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return 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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- angular.forEach(page.content, function(data) {
- if (!data.returnItems[0].orderItem) {
- PurcReturn.getEnterpriseName({id: data.id, enuu : data.enUU},function(enterprise) {
- data.enName = enterprise.enName;
- });
- }
- });
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.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){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return 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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户不良品出库
- */
- app.controller('SaleBadOutCtrl', ['$scope', '$filter', 'PurcBadOut', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcBadOut, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return 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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户MRB
- */
- app.controller('SaleMRBCtrl', ['$scope', '$filter', 'PurcMRB', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcMRB, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户应付发票
- */
- app.controller('SaleApBillCtrl', ['$scope', '$filter', 'FaApBill', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, FaApBill, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $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.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.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('SaleArCheckCtrl', ['$scope', '$filter', 'FaArCheck', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, FaArCheck, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
-
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 计算单据的商品总数
- $scope.getTotalProd = function(check) {
- var total = 0;
- if(check.items) {
- angular.forEach(check.items, function(value) {
- total += value.qty;
- });
- }
- return total;
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- // 应付对账单详情页
- app.controller('SaleArCheckDetailCtrl', ['$scope', '$stateParams', 'FaArCheck', 'toaster', '$state', 'BaseService', function($scope, $stateParams, FaArCheck, toaster, $state, BaseService){
- BaseService.scrollBackToTop();
- var loadData = function() {
- FaArCheck.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- $scope.loading = false;
- });
- };
- loadData(); // 初始获取单据数据
-
- $scope.onReplyClick = function(item, isAgreed) {
- if(isAgreed) {// 同意确认
- FaArCheck.agree({itemId: item.id}, {}, function(data){
- toaster.pop('success', '确认成功', '确认供应商对账数量成功');
- }, function(response){
- toaster.pop('danger', '确认失败', response.data);
- });
- } else {// 不同意回复
- FaArCheck.disagree({itemId: item.id}, {qty: item.$replyQty, remark: item.$replyRemark}, function(data) {
- toaster.pop('success', '确认成功', '您提交的数量将发送给供应商确认');
- }, function(response) {
- toaster.pop('danger', '确认失败', response.data);
- });
- }
- };
-
- // 获取明细的回复记录
- $scope.getReplies = function(item) {
- if(!item.replies) {
- FaArCheck.getReplies({itemId: item.id}, function(data) {
- item.replies = data;
- }, function(response) {
- toaster.pop('danger', '获取对账记录失败', response.data);
- });
- }
- };
-
- }]);
- //应收对账单列表
- app.controller('PurchaseApCheckCtrl',['$scope', 'FaApCheck', 'BaseService', 'ngTableParams', 'toaster','ReportService', 'Symbol', function($scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService , Symbol){
- BaseService.scrollBackToTop();
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'todo';
-
- //打印 对账单
- $scope.print = function(check) {
- FaApCheck.printCount({id: check.id},{});//增加打印此次
- ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id);
- };
-
- //状态
- $scope.setActive = function (state){
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = 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 = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- FaApCheck[getState($scope.active )](BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.data = $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $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', 'BaseService', function($scope, toaster, FaApCheck, $stateParams, BaseService) {
- BaseService.scrollBackToTop();
- $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', '$modal', function($scope, FaApCheck, toaster, $state, $filter, $modal){
- $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;
- // });
- //
- // }
-
- document.getElementById('suuorname').focus();//光标默认在客户
-
- // $scope.getData();
-
- $scope.condition = {
- $fromOpened:false
- }
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
-
- //查找客户
- $scope.searchCust = function(suuorname) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/fa/custInfo.html',
- controller: 'SearchCustInfoCtrl',
- resolve: {
- suuorname: function() {
- return suuorname;
- }
- }
- });
- modalInstance.result.then(function(suuorname){
- $scope.suuorname = suuorname;
- });
-
- }
-
- // 点击筛选根据条件选择数据
- $scope.suuorname = '';
- $scope.sdateFrom = '';
- $scope.sdateTo = '';
- $scope.vuuorname = '';
- $scope.factory = '';
- $scope.prodTitle = '';
- $scope.prodSpec = '';
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodTitle = '';
- $scope.condition.prodSpec = '';
-
- $scope.searchOrder = function(check) {
- angular.forEach($scope.data, function(item) {
- $scope.checkboxes.checked = false;
- item.$selected = false;
- });
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory
- $scope.condition.prodTitle = $scope.prodTitle;
- $scope.condition.prodSpec = $scope.prodSpec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf() + 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.condition.factory == null ? "" : $scope.condition.factory)
- // + "|"+ ($scope.condition.prodTitle == null ? "" : $scope.condition.prodTitle)
- // + "|"+ ($scope.condition.prodSpec == null ? "" : $scope.condition.prodSpec));//保存当前取值的关键词
- // $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- // $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
-
- $scope.fromDate =$scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.keywordXls = angular.copy(($scope.condition.uuorname == null ? "" : $scope.condition.uuorname)
- + "|"+ ($scope.condition.venduuorname == null ? "" : $scope.condition.venduuorname)
- + "|"+ ($scope.condition.factory == null ? "" : $scope.condition.factory)
- + "|"+ ($scope.condition.prodTitle == null ? "" : $scope.condition.prodTitle)
- + "|"+ ($scope.condition.prodSpec == null ? "" : $scope.condition.prodSpec));//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if($scope.suuorname == '') {
- toaster.pop('info','提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- FaApCheck.getAllByKeywords({fromDate: $scope.fromDate, endDate: $scope.endDate, keyword:$scope.keywordXls}, function(data) {
- $scope.data = data;
- angular.forEach($scope.data, function(item) {
- item:{
- $selected:true;
- }
- });
- $scope.loading = false;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }
-
- }
-
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.totalMoney = 0;
- $scope.checkboxes = {
- checked : false
- };
-
- // 点击勾选全部的复选框
- $scope.checkAll = function(){
- $scope.totalMoney = 0;
- $scope.filteredData = $filter('filter')($scope.data, $scope.condition.prodTitle || $scope.condition.uuorname || $scope.condition.venduuorname || $scope.condition.prodSpec || $scope.condition.factory);
- var uuorname = $scope.suuorname;
- var venduuorname = $scope.venduuorname;
- var dateFrom = $scope.condition.dateFrom;
- var dateTo = $scope.condition.dateTo;
- var prodTitle = $scope.condition.prodTitle;
- var prodSpec = $scope.condition.prodSpec;
- var factory = $scope.condition.factory;
- angular.forEach($scope.filteredData, function(item) {
- if((item.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', '生成对账单失败', response.data);
- })
- };
-
- //如果是同一家客户,生成对账单的同时,关闭模态框
- if($scope.sameCust && $scope.validQty) {
- $scope.saveApCheck();
- }
-
- }
- }]);
-
- app.controller('EnterpriseCtrl', ['$scope', 'AccountEnterprise', 'toaster', '$state', '$modal', 'BaseService', 'ShipAddress', '$http', function($scope, AccountEnterprise, toaster, $state, $modal, BaseService, ShipAddress, $http){
- BaseService.scrollBackToTop();
- $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', '请完善信息', '申请优企云服请先完善企业详细信息');
- }
- };
-
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- });
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
-
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- });
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
-
- // 删除收货地址
- $scope.removeShip = function(id, index) {
- ShipAddress.removeShipAddress({id: id}, {}, function(data) {
- $scope.ships.splice(index, 1);
- toaster.pop('success', '提示', '收货地址删除成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- // 编辑收货地址
- $scope.editShip = function(ship){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/shipaddress_modal.html',
- controller: 'ShipAddressCtrl',
- resolve: {
- ship: function(){return ship;}
- }
- });
-
- modalInstance.result.then(function() {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- });
- }, function(){
- });
- };
-
- // 设置logo
- $scope.showImageDialog = function(modal) {
- require([ 'jquery-uploadify' ], function() {
- $modal.open({
- templateUrl : 'static/tpl/index/home/insert.html',
- controller : 'ImageInsertCtrl',
- backdrop : 'static'
- }).result.then(function(image){
- $scope.imageUrl = image.thumb;
- User.postImageUrl(null, angular.toJson($scope.imageUrl), function(data){
- $scope.user = data;
- }, function(response) {
- toaster.pop('error', '设置图像失败,' + response.data);
- });
-
- });
- });
- }
- }]);
-
- // 编辑收货地址
- app.controller('ShipAddressCtrl', ['$scope', 'ShipAddress', 'ship', '$modalInstance', 'toaster', '$http', function($scope, ShipAddress, ship, $modalInstance, toaster, $http) {
- $scope.ship = ship;
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
-
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $modalInstance.close();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- // 申请Saas Controller
- app.controller('ApplySaasCtrl', ['$scope', '$modalInstance', 'enterprise', 'AccountEnterprise', 'toaster', '$http', function($scope, $modalInstance, enterprise, AccountEnterprise, toaster, $http){
- $scope.enterprise = enterprise;
- $scope.checking = false;
-
- $scope.$watch('enterprise.enSaasUrl', function(){
- if($scope.enterprise.enSaasUrl) {
- $http.get('signup/saasUrlEnable', {
- params: {
- enSaasUrl: $scope.enterprise.enSaasUrl
- }
- }).success(function(data){
- if(data && data == 'true') {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', true);
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '优企云服域名已被使用';
- }
- }).error(function(){
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '验证出错';
- });
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- }
- });
-
- var setSaasUrl = function(url) {
- var index = url.indexOf('www.');
- if(index != -1) {//包含www.
- var substr = url.substring(index+4, url.length);
- $scope.enterprise.enSaasUrl = substr.substring(0, substr.indexOf('.'));
- } else {
- $scope.enterprise.enSaasUrl = getHost(url);
- }
- };
-
- // 解析获取网址的一级域名
- var getHost = function(host){
- var newhost;
- var domain;
- var ArrDomain = new Array('.com.cn','.net.cn','.org.cn','.gov.cn','.com','.cn','.tel','.mobi','.net','.org','.asia','.me','.cc','.name','.info');//枚举所有后缀
- for(var k in ArrDomain){
- var re = eval('/\\' + ArrDomain[k] + '$/g');
- newhost = host.replace(re, '');
- if(newhost != host){
- domain = ArrDomain[k];
- break;
- }
- }
- var hostar = newhost.split('.');
- var s = hostar[hostar.length-1];
- return s;
- };
-
- // 设置优企云服域名为官网网址一级域名
- if($scope.enterprise.enUrl) setSaasUrl($scope.enterprise.enUrl);
-
- $scope.apply = function(){
- $scope.loading = true;
- AccountEnterprise.applySaas({
- enUU: $scope.enterprise.uu,
- enSaasUrl: $scope.enterprise.enSaasUrl,
- enAdminPassword: $scope.enterprise.enAdminPassword
- }, {}, function(){
- $scope.loading = false;
- toaster.pop('success', '申请成功', '已提交系统开通优企云服,开通后将会发送邮件至管理员邮箱');
- $modalInstance.close();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '申请失败', response.data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
-
- }]);
-
- app.controller('UserCtrl', ['$scope', '$filter', 'AuthenticationService', 'AccountUser', 'BaseService', 'ngTableParams', 'toaster', '$modal', '$http', 'ngAlert', 'AccountEnterprise', function($scope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http, ngAlert, AccountEnterprise){
- BaseService.scrollBackToTop();
- $scope.editing = false;
- $scope.loading = true;
- $scope.enterprise = null;
- AccountUser.findDistribute({},function(data) {
- $scope.distributes = data;
- },function(response) {
- toaster.pop('error', '系统错误', response.data);
- })
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- var users = [];
- $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());
- angular.forEach($scope.users,function(user){
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.enterprise = data;
- });
- });
- 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/approvalFlow/user_role.html',
- controller: 'UserRoleCtrl',
- resolve: {
- user: function() {
- return user;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- };
- // 为用户分配角色(删除企业)
- $scope.removeVendor = function(user) {
- var resultRole = true;
- angular.forEach(user.roles,function(role){
- if(role.issys == 1) {
- 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', '$timeout', function($scope, $modalInstance, FuzzySearch, AuthenticationService, $timeout){
- $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("绑定失败!");
- });
-
- }
- }
-
- });
- $timeout(function() {
- $modalInstance.close(true);
- }, 500);
- };
-
- $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/approvalFlow/role_detail.html',
- controller: 'RoleEditCtrl',
- resolve: {
- role: function() {
- return role;
- }
- }
- });
- modalInstance.result.then(function(added){
- added && (getData());
- });
- };
- }]);
-
- app.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'ngAlert', 'BaseService', function($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, ngAlert, BaseService){
- BaseService.scrollBackToTop();
- $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){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $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', 'where make$orders.ma_id=' + order.id);
- };
-
- // 获取回复记录
- $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', 'BaseService', function($scope, $stateParams, MakeOrder, toaster, ReportService, BaseService){
- BaseService.scrollBackToTop();
- 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', 'where make$orders.ma_id =' + order.id);
- };
-
- }]);
- /**
- * 客户委外验收
- */
- app.controller('MakeAcceptCtrl', ['$scope', '$filter', 'MakeAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, MakeAccept, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- 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.totalElement);
- $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){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return 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.totalElement);
- $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){
- BaseService.scrollBackToTop();
- $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.totalElement);
- $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', 'BaseService', function($scope, $stateParams, MakeChange, toaster, BaseService){
- BaseService.scrollBackToTop();
- 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.controller('MakeOutOrderCtrl', ['$scope', '$filter', 'MakeOutOrder', 'ngTableParams', 'toaster','ReportService', 'BaseService',
- function($scope, $filter, MakeOutOrder, ngTableParams, toaster,ReportService, BaseService) {
- BaseService.scrollBackToTop();
- $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 MakeOutOrder;
- };
- $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.totalElement);
- $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;
- MakeOutOrder.reply({itemId: change.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 委外加工详细
- */
- app.controller('MakeOutOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOutOrder', 'toaster', 'ReportService', 'BaseService', function($scope, $stateParams, MakeOutOrder, toaster, ReportService, BaseService) {
- BaseService.scrollBackToTop();
- var loadData = function() {
- MakeOutOrder.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) {
- MakeOutOrder.getReply({orderId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 点击回复
- $scope.onReplyClick = function(order, inverse) {
- if(order.reply) {
- if(!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOutOrder.reply({orderId: order.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 打开回复
- $scope.openReply = function(order) {
- if(!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
-
- // 关闭回复
- $scope.closeReply = function(order) {
- order.$editing = false;
- }
-
- // 自己委外加工订单
- $scope.print = function(order) {
- MakeOutOrder.printCount({id: order.id},{});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$outorders.ma_id =' + order.id);
- };
- }]);
-
- /**
- * 计算时间差
- */
- app.filter('timespan', function(){
- return function(time) {
- if(time == null)
- return '9999年';
- var now = new Date().getTime(), span = time - now,
- d = Math.ceil(span/86400000), h = Math.ceil(span/3600000),
- m = Math.ceil(span/60000);
- if(span < 0)
- return '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);
- };
- }]);
-
- /**
- * 物料资料
- */
- app.controller('ProductListCtrl', ['$scope', 'GetProductInfo', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', function($scope, GetProductInfo, ngTableParams, $filter, BaseService, toaster, $timeout) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return GetProductInfo;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- //删除
- $scope.deleteById = function(id) {
- GetProductInfo.deleteById({id: id}, function(data) {
- if(data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function() {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function(response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
-
- }]);
-
- /**
- * 物料批量上传
- */
- app.controller('UploadByBatchCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function($scope, $upload, toaster, BaseService) {
- BaseService.scrollBackToTop();
- // 通过excel批量上传物料
- $scope.upload = function() {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'product/baseInfo/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- $scope.infos = $scope.result.infos;
- }).error(function(response) {
- toaster.pop('error', response.data || response);
- });
- };
-
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
-
- // 下载模板
- $scope.download = function() {
- window.location.href = 'product/baseInfo/upload/template';
- };
- }]);
-
- /**
- * 物料详情
- */
- app.controller('ProductDetailCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', 'AuthenticationService', '$filter', 'BaseService', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, AuthenticationService, $filter, BaseService) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
-
- var loadData = function() {
- GetProductInfo.getOne({id: $stateParams.id}, function(data) {
- if(data.attach) {
- GetProductInfo.getAttach({id: data.attach.id}, function(data) {
- // 查看范例
- $scope.showImg = function() {
- var src = data.url, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
- })
- }
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.loading = false;
- });
- };
- loadData();
- // 更新
- $scope.update = function() {
- $scope.prodInfo.$editing = true;
- };
-
- // 取消
- $scope.cancel = function() {
- GetProductInfo.getOne({id: $stateParams.id}, function(data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.loading = false;
- });
- };
-
- $scope.submit = function(prodInfo) {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/updateProdInfo',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- window.location.reload();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- }
-
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function(){
- if($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if(file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else{
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else{//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var getObjectURL = function(file) {
- var url = null ;
- if (window.createObjectURL!=undefined) { // basic
- url = window.createObjectURL(file) ;
- } else if (window.URL!=undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file) ;
- } else if (window.webkitURL!=undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file) ;
- }
- return url ;
- };
-
- }]);
-
- /**
- * 新增物料
- */
- app.controller('NewProdInfoCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', '$modal', 'ComponentActive', 'KindAPI', '$timeout', '$filter', 'AuthenticationService', 'BaseService', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout, $filter, AuthenticationService, BaseService) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.prodInfo = {unit: 'PCS'};
- // 选择类目
- $scope.selectKind = function(uuids) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function(data){
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function() {
- return $scope.kindId;
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.cmpCode = data.code;
- $scope.prodInfo.brand = data.brand.nameEn;
- console.log($scope.prodInfo.brand);
- }, function(){
-
- });
- }, function(){
-
- });
- };
- //提交
- $scope.submit = function(prodInfo){
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/addNewProduct',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- //提交后跳转到详情页面,防止重复提交
- window.location.href="#/sale/prodList/"+data.id;
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function() {
- //提交后跳转到详情页面,防止重复提交
- window.location.href="#/sale/prodList/"+data.id;
- }, 500);
- }
-
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- // GetProductInfo.addNewProd({}, prodInfo, function(data) {
- // toaster.pop("success", "提示", "提交成功");
- //
- //
- // }, function(res) {
- // toaster.pop("error", "提示" + res);
- // });
- };
-
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function(){
- if($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if(file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else{
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else{//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var getObjectURL = function(file) {
- var url = null ;
- if (window.createObjectURL!=undefined) { // basic
- url = window.createObjectURL(file) ;
- } else if (window.URL!=undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file) ;
- } else if (window.webkitURL!=undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file) ;
- }
- return url ;
- };
- // 取消
- $scope.cancel = function(){
- $scope.prodInfo = angular.copy($scope.prodInfo);
- };
- }]);
-
-
- /**
- * 类目选择模态框
- */
- app.controller('KindChooseCtrl', ['$scope', 'KindAPI', 'toaster', '$modalInstance', '$modal', function($scope, KindAPI, toaster, $modalInstance, $modal) {
- $scope.kindId = null;
- $scope.kinds = [[], [], [], []];
- // 获取子类目
- var getChildren = function(pid, deep) {
- KindAPI.getChildren({parentId: pid}, function(data) {
- $scope.kinds[deep] = data;
- }, function(response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- };
-
- // 改变节点选中状态
- var changeStatus = function(item, deep) {
- var kindId = null, level = 0;
- angular.forEach($scope.kinds, function(ks, i) {
- if(i > deep) {
- $scope.kinds[i] = [];
- } else {
- angular.forEach(ks, function(k, j) {
- if(i == deep) {
- if(k.id == item.id) {
- $scope.kinds[i][j].$active = true;
- kindId = k.id;
- } else {
- k.$active = null;
- }
- }
- });
- }
- });
- // 选择的节点
- $scope.kindId = kindId;
- $scope.active = item;
- // 当前可操作的层级
- if(deep < 3) {
- $scope.activeDeep = deep + 1;
- }
- };
-
- // 节点点击后获取子类目,节点被选中
- $scope.onItemClick = function(item, deep) {
- changeStatus(item, deep);
- if (!item.isLeaf) {
- getChildren(item.id, deep + 1);
- }
- };
-
- // 重新加载数据
- function reload(deep) {
- var pid;
- if(deep) {
- pid = $scope.actives[deep - 1].id;
- } else {
- pid = 0;
- deep = 0;
- }
- getChildren(pid, deep);
- }
-
- // 初始加载数据,获取第一层的类目
- if($scope.actives) {
- angular.forEach($scope.actives, function(v, k) {
- KindAPI.getChildren({parentId: v.parentid}, function(data) {
- $scope.kinds[k] = data;
- angular.forEach($scope.kinds[k], function(kind, i){
- if(kind.id == v.id) {
- $scope.kinds[k][i].$active = true;
- $scope.actives[k] = $scope.kinds[k][i];
- }
- })
- }, function(response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- });
- } else {
- reload();
- }
-
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- // 确认选择
- $scope.check = function() {
- $modalInstance.close($scope.kindId);
- };
- }]);
-
- /**
- * 器件筛选
- */
- app.controller('FindComponentCtrl', ['$scope', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'ComponentActive', 'KindId', function($scope, BaseService, ngTableParams, toaster, $modalInstance, ComponentActive, KindId) {
- //状态
- $scope.setActive = function (state){
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.kindId = KindId;
- ComponentActive.getComponentsByKindid(BaseService.parseParams(pageParams), function(page) {
- console.log(page);
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- // 选择
- $scope.check = function(data){
- $modalInstance.close(data);
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 企业列表
- */
- app.controller('EnterpriseListCtrl', ['$scope', 'getAccountUserSpace', 'ngTableParams', '$filter', 'BaseService', 'toaster', 'AddPartner', '$rootScope', function($scope, getAccountUserSpace, ngTableParams, $filter, BaseService, toaster, AddPartner, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return getAccountUserSpace;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page) {
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 添加合作关系
- $scope.addPartner = function(name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function(data) {
- if(data.success) {
- toaster.pop("success", '添加成功', data.success);
- }
- if(data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
-
- $scope.status = 'enList';
- }]);
-
- /**
- * 新增采购单
- */
- app.controller('PurcNewOrderCtrl',['$scope', '$modal', 'toaster', '$filter', 'addtoCart', '$rootScope', 'VendorInfo', 'ngTableParams', 'BaseService', 'Product', 'newPurcOrder', 'cartOperation', 'ShipAddress', 'Vendor', '$http', function($scope, $modal, toaster, $filter, addtoCart, $rootScope, VendorInfo, ngTableParams, BaseService, Product, newPurcOrder, cartOperation, ShipAddress, Vendor, $http) {
- BaseService.scrollBackToTop();
- // 每次进入时先清除掉rootScope下的venuu
- $rootScope.venduu = null;
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
-
- $scope.order = {
- date : new Date(),
- cust : {
- uu : '',
- },
- custUser : {
-
- },
- code : $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- orderItems : {
- product : {},
- },
- };
-
- //商品信息
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- id: null,
- };
-
- // 获取供应商列表
- cartOperation.vendorInfo({}, function(data) {
- });
-
- if($rootScope.businessCode) {
- VendorInfo.getVendorInfo({businessCode: $rootScope.businessCode}, {}, function(data) {
- $scope.id = data.id;
- $scope.order.cust.enName = data.vendorEnterprise.enName;
- $scope.order.cust.enAddress = data.vendorEnterprise.enAddress;
- $scope.order.cust.uu = data.vendorEnterprise.uu;
- $rootScope.venduu = data.vendorEnterprise.uu;
- Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }, function(response) {
-
- });
- };
-
- // 查找客户
- $scope.dbfindCust = function(){
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
- controller: 'DbfindVendorInfoCtrl',
- size: 'lg',
- resolve: {
- orderItems: function() {
- return $scope.order.orderItems;
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $rootScope.venduu = data.vendorEnterprise.uu;
- $scope.id = data.id;
- $scope.order.cust = data.vendorEnterprise;
- $scope.order.custUser = data.vendorUser;
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- };
- // $scope.order.orderItems.push(item);
- Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
-
- }, function(){
-
- });
- };
-
-
- // $scope.order.orderItems.push(item);
- if($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function(data) {
- item.code = data.code;
- item.title = data.title;
- item.spec = data.spec;
- item.unit = data.unit;
- item.id = data.id;
- $scope.order.orderItems.push(item);
- }, function(response) {
-
- });
- }
- //增加商品
- $scope.addProduct = function(index) {
- if($scope.order.orderItems[index].code == null) {
- toaster.pop('info', '提示', '请先选择商品');
- } else {
- $scope.order.orderItems.push({code: null, title: null, spec: null, unit: null, qty: null, price: null, remark: null, delivery: null, $endDateOpen: false});
- }
- };
- //删除商品
- $scope.deleteProduct = function(index) {
- $scope.order.orderItems.splice(index, 1);
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.custUU = $scope.order.cust.uu;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
-
- // 选择
- $scope.check = function(data) {
- $scope.order.orderItems.push({code: data.code, title: data.title, spec: data.spec, unit: data.unit, qty: null, price: null, remark: null, delivery: null, id: data.id});
- };
-
- // 监听custuu发生变化,重新加载物料信息
- $scope.$watch('order.cust.uu', function(n, o) {
- if(n==o) {
- return;
- } else {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, true);
-
- // 查找客户物料
- $scope.dbfindCustProd = function(index){
- if($scope.order.cust.uu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_custProd.html',
- controller: 'DbfindCustProdCtrl',
- size: 'lg',
- resolve: {
- custUU: function() {
- return $scope.order.cust.uu
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.order.orderItems.push(data);
- for(var i = 0; i < $scope.order.orderItems.length; i++) {
- if($scope.order.orderItems[i].code == null || i == index) {
- $scope.order.orderItems.splice(i, 1);
- }
- }
- }, function() {
-
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- };
- $scope.getMinDate = function(item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
-
- $scope.openDatePicker = function($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.order.orderItems[index].$endDateOpen = !openParam;
- };
-
-
- // 添加到购物车
- $scope.addToCart = function(order) {
- $scope.loading = true;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.custUU = $scope.order.cust.uu;
- $scope.order.custUserUU = $scope.order.custUser.userUU;
- if($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for(var i = 0; i < $scope.order.orderItems.length; i++) {
- if($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- addtoCart.save({}, $scope.order, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/cart/'+data.id;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
-
- // 立即购买
- $scope.addToOrder = function(order) {
- $scope.loading = true;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.custUU = $scope.order.cust.uu;
- $scope.order.custUserUU = $scope.order.custUser.userUU;
- if($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for(var i = 0; i < $scope.order.orderItems.length; i++) {
- if($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- newPurcOrder.save({}, $scope.order, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/order/'+data.id;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
-
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
-
- // 新增供应商联系人
- $scope.addContact = function(uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function(data) {
- Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- }]);
-
- // 查找供应商
- app.controller('DbfindVendorInfoCtrl', ['$scope', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'Vendor', '$rootScope', 'orderItems', function($scope, BaseService, ngTableParams, toaster, $modalInstance, Vendor, $rootScope, orderItems){
- $scope.prod = false;
- if(orderItems.length != 0) {
- $scope.prod = true;
- }
- BaseService.scrollBackToTop();
- if($rootScope.venduu != null) {
- $scope.venduu = $rootScope.venduu;
- }
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
-
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.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.ensure = false;
- $scope.check = function(vendor) { // 需要进行判断的选择
- console.log(vendor);
- $scope.vendorInfo = vendor;
- $scope.ensure = true;
- };
-
- $scope.checkVendor = function(vendor) { // 直接选择
- $modalInstance.close(vendor);
- }
-
- }]);
-
- /**
- * 我的客户
- */
- app.controller('MyClientCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- var getCustInfos = function(custuu) {
- if(custuu) {
- VendorService.userInfo.query({uu:custuu},null,function(data) {
- console.log(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('PurcVendorCtrl', ['$scope', 'Vendor', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', '$rootScope', function($scope, Vendor, BaseService, AuthenticationService,ngTableParams,$modal, toaster, $rootScope){
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
-
- $scope.customerParams = 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;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElements;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 查看供应商详情
- $scope.VendorDetail = function(id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/"+$rootScope.vendorId;
- }
-
- // 向企业购买
- $scope.purcByEn = function(businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
-
- }]);
-
- /**
- * 供应商详情
- */
- app.controller('PurcVendorDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', function($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.vendorContacts = [];
- var loadData = function() {
- Vendor.getVendorDetail({id: $stateParams.id}, {}, function(data) {
- $scope.vendor = data.vendorEnterprise;
- Vendor.contacts({venduu: $scope.vendor.uu}, {}, function(data) {
- $scope.vendorContacts = data;
- });
- });
- };
- loadData();
-
- // 新增供应商联系人
- $scope.addContact = function(uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function(data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.vendorContacts.push(data);
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- // 编辑供应商联系人
- $scope.edit = function(contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function() {
- return contact;
- }
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- Vendor.saveContact({}, $scope.contact, function(data) {
- toaster.pop('success', '提示', '联系人修改成功');
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- // 删除供应商联系人
- $scope.deleteById = function(id, index) {
- $scope.vendorContacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '供应商联系人删除成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 供应商物料信息
- $scope.viewProdList = function(uu){
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function(businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
- }]);
-
- /**
- * 编辑供应商联系人
- */
- app.controller('EditContacCtrl', ['$scope', 'toaster', '$modalInstance', 'contact', function($scope, toaster, $modalInstance, contact) {
-
- $scope.contact = contact;
-
- $scope.save = function(contact) {
- $modalInstance.close(contact);
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- /**
- * 新增供应商联系人
- */
- app.controller('AddContacCtrl', ['$scope', 'toaster', '$modalInstance', function($scope, toaster, $modalInstance) {
- $scope.save = function(contact) {
- $modalInstance.close(contact);
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- /**
- * 建立合作关系申请
- */
- app.controller('AddPartnerRequestCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', function($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
-
- var getRequestStatus = function(active) {
- var fn = 'getAllRequest';
- switch(active) {
- case 'done':
- fn = 'getRequestDone';break;
- case 'todo':
- fn = 'getRequestTodo';break;
- case 'end':
- fn = 'getRequestEnd';break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function() {
- return AddPartnerMyRequest;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 15, 25, 50],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getRequestStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 再次申请
- $scope.reapply = function(id) {
- AddPartner.reapply({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
-
- // 添加为供应商
- $scope.addSupplier = function(vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error','提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- })
- };
-
- // 添加客户
- $scope.addCust = function(vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error','提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- })
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 同意申请
- $scope.agree = function(id) {
- AddPartner.agreeRequest({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $timeout(function() {
- window.location.reload();
- }, 500);
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 拒绝申请
- $scope.refuse = function(id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $timeout(function() {
- window.location.reload();
- }, 500);
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- $scope.status = 'send';
- }]);
-
-
- /**
- * 建立合作关系处理申请
- */
- app.controller('AddPartnerMessageCtrl', ['$scope', 'AddPartnerMyMessage', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', function($scope, AddPartnerMyMessage, toaster, BaseService, ngTableParams, AddPartner) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- var getMessagetStatus = function(active) {
- var fn = 'getAllMessage';
- switch(active) {
- case 'done':
- fn = 'getMessageDone';break;
- case 'todo':
- fn = 'getMessageTodo';break;
- case 'end':
- fn = 'getMessageEnd';break;
- }
- return fn;
- }
-
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- var getService = function() {
- return AddPartnerMyMessage;
- };
-
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 15, 25, 50],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- };
- getService()[getMessagetStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- console.log(page);
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 同意申请
- $scope.agree = function(id) {
- AddPartner.agreeRequest({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 拒绝申请
- $scope.refuse = function(id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- $scope.status = 'get';
- }]);
-
- /**
- * 我的合作伙伴
- */
- app.controller('MyPartnersCtrl', ['$scope', 'toaster', 'GetProductInfo', 'BaseService', function($scope, toaster, GetProductInfo, BaseService) {
- BaseService.scrollBackToTop();
- // 默认显示合作伙伴
- $scope.status = 'news';
-
- // 获取所有的合作伙伴
- GetProductInfo.getAllPartners({}, function(data) {
- console.log(data);
- $scope.partners = data;
- }, function(res) {
- toaster.pop('error', '获取列表失败', res.data);
- });
-
- // 添加为客户
- $scope.addCust = function(partner) {
- GetProductInfo.addCust({}, partner, function(data) {
- toaster.pop('success', '提示', '添加客户成功');
- }, function(response) {
- toaster.pop('error', '添加客户失败', response.data);
- });
- }
-
- // 添加为供应商
- $scope.addSupplier = function(partner) {
- GetProductInfo.addSupplier({}, partner, function(data) {
- toaster.pop('success', '提示', '添加供应商成功');
- }, function(response) {
- toaster.pop('error', '添加供应商失败', response.data);
- });
- }
- }]);
-
- /**
- * 财务对账时,企业进行筛选操作
- */
- app.controller('SearchCustInfoCtrl', ['$scope', '$modalInstance', 'suuorname', 'FaApCheck', function($scope, $modalInstance, suuorname, FaApCheck) {
- $scope.getData = function(){
- FaApCheck.getAllCustomers(function(data) {
- console.log(data);
- $scope.custs= data;
- angular.forEach($scope.data, function(item) {
- item:{
- $selected: true;
- }
- });
- $scope.loading = false;
- });
- }
-
- $scope.getData();
-
- $scope.CustName= function(suuorname) {
- $modalInstance.close(suuorname);
- }
-
- $scope.close = function() {
- $modalInstance.close();
- }
- }]);
-
- /**
- * 跳转到企业圈
- */
- app.controller('BusinessGroupsCtrl', ['$scope', 'GetProductInfo', 'toaster', function($scope, GetProductInfo, toaster) {
- GetProductInfo.businessGroups({}, function(data) {
- window.open(data.url);
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }]);
-
- /**
- * 购物车
- */
- app.controller('CartController', ['$scope', 'toaster', 'getCartList', 'ngTableParams', '$filter', 'BaseService', 'cartOperation', '$timeout', function($scope, toaster, getCartList, ngTableParams, $filter, BaseService, cartOperation, $timeout) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return getCartList;
- };
-
- $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(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.getCartTotal = function(items) {
- var sum = 0;
- angular.forEach(items, function(item){
- sum += item.qty * item.price;
- });
- return sum;
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 提交
- $scope.addtoOrder = function(id) {
- console.log(id);
- cartOperation.addToOrder({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = '#/purc/order/'+data.id;
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 删除一条主记录
- $scope.deleteCart = function(id) {
- cartOperation.deleteCart({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 删除一条明细
- $scope.deleteDetail = function(id) {
- cartOperation.deleteCartDetail({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 清空购物车
- $scope.clearCart = function() {
- cartOperation.deleteCarts({}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 购物车详情
- */
- app.controller('CartDetailController', ['$scope', 'cartOperation', '$stateParams', 'toaster', '$timeout', 'BaseService', function($scope, cartOperation, $stateParams, toaster, $timeout, BaseService) {
- BaseService.scrollBackToTop();
- var loadData = function() {
- cartOperation.getCartDetail({id: $stateParams.id}, function(data) {
- if(data.code) {
- $scope.cart = data;
- var sum = 0;
- angular.forEach($scope.cart.cartDetails, function(item) {
- sum += item.qty * item.price;
- });
- $scope.cart.total = sum;
- $scope.loading = false;
- } else {
- window.location.hash = '#/purc/cart';
- }
- });
- };
- loadData();
-
- // 删除一条明细
- $scope.deleteDetail = function(id) {
- cartOperation.deleteCartDetail({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 删除一条主记录
- $scope.deleteCart = function(id) {
- cartOperation.deleteCart({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 提交
- $scope.addtoOrder = function(id) {
- console.log(id);
- cartOperation.addToOrder({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = '#/purc/order/'+data.id;
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
- }]);
-
- /**
- * 审批流
- */
- app.controller('approvalFlowCtrl', ['$scope', 'toaster', '$modal', 'appFlow', 'BaseService', function($scope, toaster, $modal, appFlow, BaseService) {
- BaseService.scrollBackToTop();
- $scope.vacation = false;
- $scope.workovertime = false;
- $scope.workdaily = false;
- $scope.feeplease = false;
- $scope.signapp = false;
- appFlow.viewAppFlow({}, function(data) {// 获取已设置的列表
- $scope.nodes = data;
- angular.forEach($scope.nodes, function(node) {
- if(node.appname = '请假单') {
- $scope.vacation = true;
- }
- if(node.appname = '加班单') {
- $scope.workovertime = true;
- }
- if(node.appname = '工作日报') {
- $scope.workdaily = true;
- }
- if(node.appname = '出差单') {
- $scope.feeplease = true;
- }
- if(node.appname = '申诉单') {
- $scope.signapp = true;
- }
- });
- }, function(response) {
-
- });
-
- $scope.NoteSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '请假单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.overTimeSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '加班单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.feePleaseSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '出差单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.workDailySet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '工作日报';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.signAppSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '申诉单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
- }]);
-
- /**
- * 审核条件设置
- */
- app.controller('NoteStep1Ctrl', ['$scope', 'toaster', '$modalInstance', 'appFlow', 'AppName', '$filter', '$rootScope', function($scope, toaster, $modalInstance, appFlow, AppName, $filter, $rootScope) {
- $scope.appName = AppName;// 标题名称
- $scope.AppFlow = {appName: $scope.appName,
- appNodes:{}};
- $scope.AppFlow.appNodes = [];
- appFlow.getNodeByName({name: AppName}, {}, function(data) {// 通过单据名称查询单个审批流
- if(data.appNodes.length != 0) {
- $scope.node = data;
- $scope.AppFlow = data;
- }
- }, function() {
-
- });
-
- $scope.copy = function() {//复制
- $rootScope.flowcopy = angular.copy($scope.AppFlow);
- toaster.pop('info', '提示', '复制成功');
- $modalInstance.dismiss();
- }
-
- $scope.paste = function() {
- $scope.AppFlow = {appName: $scope.appName, appNodes:{}};
- $scope.AppFlow.appNodes = $rootScope.flowcopy.appNodes;
- }
-
- $scope.clear = function() {// 清空
- $scope.AppFlow = {appName: $scope.appName,
- appNodes:{}};
- $scope.AppFlow.appNodes = [];
- }
-
- appFlow.getPositions({}, function(data) {// 获取人员信息
- $scope.users = data;
- }, function(response) {
-
- });
-
- appFlow.getPositionInfo({}, function(data) { // 获取职位信息
- $scope.roles = data;
- },function(response) {
-
- });
-
- $scope.SelectUser = function(data) { // 添加人员
- var item = {
- useruu: null,
- username: null,
- level: null
- };
- item.useruu = data.useruu;
- item.username = data.username;
- // if($scope.AppFlow.appNodes.length != 0){
- // for(var i = 0;i < $scope.AppFlow.appNodes.length; i++) {
- // if($scope.AppFlow.appNodes[i] == item.useruu) {
- // toaster.pop('info', '提示', '不能重复添加');
- // } else {
- // $scope.AppFlow.appNodes.push(item);
- // }
- // }
- // } else {
- $scope.AppFlow.appNodes.push(item);
- // }
-
- }
-
- $scope.SelectRole = function(data) {// 添加职位
- var item = {
- position: null,
- level: null
- };
- item.position = data;
- $scope.AppFlow.appNodes.push(item);
- }
-
- $scope.deleteNode = function(index) {// 删除节点
- $scope.AppFlow.appNodes.splice(index, 1);
- };
-
- $scope.saveNode = function() { // 保存
- angular.forEach($scope.AppFlow.appNodes, function(value, key) {
- $scope.AppFlow.appNodes[key].level = key;
- });
- if($scope.AppFlow.appNodes.length == 0) {
- toaster.pop('info', '提示', '您还未设置审批人');
- } else {
- $modalInstance.close($scope.AppFlow);
- };
- };
-
- $scope.cancel = function() {// 取消
- $modalInstance.dismiss();
- }
-
- }]);
-
-
- /***
- * 代采定单
- */
- app.controller('DeputyOrderCtrl', ['$scope', 'toaster', 'getDeOrder', 'ngTableParams', 'BaseService', 'DeputyOrder', 'ReportService', function($scope, toaster, getDeOrder, ngTableParams, BaseService, DeputyOrder, ReportService) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.total = null;
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- getDeOrder[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page) {
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //打印
- $scope.print = function(deputyOrder) {
- DeputyOrder.printCount({id: deputyOrder.id},{});//增加打印此次
- // ReportService.print(deputyOrder.deputyuu, 'PURCNOTICE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 定向采购通知
- // ReportService.print(deputyOrder.deputyuu, 'PURCHASE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 采购订单
- // ReportService.print(deputyOrder.deputyuu, 'PAYCONFIRM', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 付款确认
- // ReportService.print(deputyOrder.deputyuu, 'TRADECONTRACT', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 买卖合同
- //TODO 目前只有信扬有代采业务,先写死之后再改
- ReportService.print(10044118, 'PURCNOTICE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 定向采购通知
- ReportService.print(10044118, 'PURCHASE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 采购订单
- ReportService.print(10044118, 'PAYCONFIRM', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 付款确认
- ReportService.print(10044118, 'TRADECONTRACT', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 买卖合同
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 新增代采订单
- */
- app.controller('NewDeputyOrderCtrl', ['$scope', 'toaster', '$modal', 'DeputyOrder', '$filter', 'ngTableParams', 'BaseService', function($scope, toaster, $modal, DeputyOrder, $filter, ngTableParams, BaseService) {
- BaseService.scrollBackToTop();
- // 费率
- DeputyOrder.vendorRate({}, function(data) {
- $scope.rate = data;
- }, function(response){
-
- });
- $scope.deOrder = {
- code: 'DC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- entrydate: new Date(),
- status: '在录入',
- goodspacking: '供应商原厂包装,如外包装完好视为货物完好',
- pickupdate: '我方自向贵公司支付货款之日起3个自然日内提货完毕',
- riskmethod: '甲方承担',
- taxpaymentmethod: '甲方承担',
- totalamount: 0,
- totalpayament: 0,
- orderamount: 0,
- usdpayment: 0
- };
- $scope.deOrder.deputyOrderItems = [];
- var item = {
- prodname: null,
- prodcode: null,
- prodspec: null,
- amount: null,
- unitprice: null,
- remark: null,
- orderprice: null,
- };
- $scope.deOrder.deputyOrderItems.push(item);
- //增加商品
- $scope.add = function(index) {
- if($scope.deOrder.deputyOrderItems[index].prodcode == null) {
- toaster.pop('info', '提示', '请先填写商品信息');
- }else {
- $scope.deOrder.deputyOrderItems.push(
- { prodname: null,
- prodcode: null,
- prodspec: null,
- amount: null,
- unitprice: null,
- remark: null,
- orderprice: null});
- }
- };
- //删除商品
- $scope.del = function(index) {
- $scope.deOrder.deputyOrderItems.splice(index, 1);
- };
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'DeputyOrderUploadCtrl',
- size: 'lg',
- resolve: {
- }
- });
-
- modalInstance.result.then(function(data) {
- angular.forEach(data, function(data) {
- $scope.deOrder.deputyOrderItems.push(data);
- for(var i = 0; i < $scope.deOrder.deputyOrderItems.length; i++) {
- if($scope.deOrder.deputyOrderItems[i].prodname == null) { // 如果没有填写就删除这行数据
- $scope.deOrder.deputyOrderItems.splice(i, 1);
- }
- }
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.usdpayment += item.amount * item.unitprice;
- $scope.deOrder.orderamount += item.amount * item.purcprice;
- });
- })
-
- }, function(){
-
- });
- }
-
- $scope.save = function() {
- $scope.deOrder.entrystatus = '保存';
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- });
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.id) {
- window.location.hash = "#/purc/deputy/"+data.id;
- }
- if(data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function(response) {
-
- });
- }
-
- $scope.submit = function() {
- $scope.deOrder.entrystatus = '已提交';
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- });
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.id) {
- window.location.hash = "#/purc/deputy/"+data.id;
- }
- if(data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function(response) {
-
- });
- }
-
- $scope.openDatePicker = function($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
-
- }]);
-
- /**
- * 代采订单批量导入
- */
- app.controller('DeputyOrderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function() {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'deputyOrder/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function(response) {
- toaster.pop('error', response.data || response);
- });
- };
-
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
-
- // 下载模板
- $scope.download = function() {
- window.location.href = 'deputyOrder/upload/template';
- };
-
- $scope.enSure = function() {
- $modalInstance.close($scope.result.items);
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 代采详情
- */
- app.controller('DeputyOrderDetailCtrl', ['$scope', 'toaster', 'DeputyOrder', '$stateParams', 'ngTableParams', 'BaseService', function($scope, toaster, DeputyOrder, $stateParams, ngTableParams, BaseService) {
- BaseService.scrollBackToTop();
- var loadData = function() {
- DeputyOrder.getOrderDetail({id: $stateParams.id}, {}, function(data) {
- $scope.deOrder = data;
- $scope.deOrder.$editing = false;
- });
- };
- loadData();
-
- var getService = function() {
- return DeputyOrder.getProdList;
- };
-
- $scope.update = function() {
- $scope.deOrder.$editing = true;
- }
-
- $scope.cancel = function() {
- $scope.deOrder.$editing = false;
- }
-
- $scope.submit = function() {
- $scope.deOrder.entrystatus = '已提交';
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.id) {
- window.location.hash = "#/purc/deputy/"+data.id;
- }
- if(data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function(response) {
-
- });
- }
-
- $scope.openDatePicker = function($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
-
- }]);
- /**
- * 招标单
- */
- app.controller('PurcTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.active = 'done';
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getTenderStatus = function(active) {
- var fn = 'getMyAll';
- switch(active) {
- case 'done':
- fn = 'getMyDone';break;
- case 'todo':
- fn = 'getMyTodo';break;
- // case 'end':
- // fn = 'getMyEnd';break;
- case 'waiting':
- fn = 'getMyWaiting';break;
- }
- return fn;
- }
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- 'tender.endDate': 'desc',
- 'tender.enterprise.enName': 'asc',
- 'tender.code': 'asc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- // fromDate: getDateTime($scope.condition.dateFrom),
- // endDate: getDateTime($scope.condition.dateTo)
- };
- PurcTender[getTenderStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 新增招标单
- */
- app.controller('PurcNewTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'ShipAddress', '$http', 'AuthenticationService', 'KindAPI', 'BrandActiveAPI', 'Search', 'ComponentActiveAPI',function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, ShipAddress, $http, AuthenticationService, KindAPI, BrandActiveAPI, Search, ComponentActiveAPI) {
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.loading = false;
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.tender.shipadd = $scope.ships[0];
- });
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset":"charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.tender.shipadd = $scope.ships[0];
- });
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- // 可选的证照要求
- $scope.certificates = [{name:'三/五证合一'}, {name:'营业执照'}, {name:'组织机构代码证'}, {name:'一般纳税人证明材料'},{name:'统计登记证'},{name:'社会保险登记证'}];
- // 处理证照要求
- var parseCertificate = function(a) {
- if (a) {
- var arr = a.split(',');
- angular.forEach(arr, function(app) {
- var contained = false;
- angular.forEach($scope.certificates, function($app) {
- if($app.name == app) {
- $app.checked = true;
- contained = true;
- }
- });
- if(!contained) {
- $scope.certificates.push({name: app, checked: true});
- }
- });
- }
- };
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function(value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword : value}).$promise.then(function(data) {
- return data.map(function(item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function(value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- // // 获取产品类目联想词
- // $scope.getSimilarKinds = function(value) {
- // if (value) {
- // // getSimilarLeafKinds 根据类目名获取末级联想词
- // // 获取类目联想词
- // return Search.getSimilarKinds({keyword : value}).$promise.then(function(data) {
- // return data.map(function(item) {
- // return item;
- // })
- // });
- // }
- // };
- // // 点击联想词获取类目信息
- // $scope.onAssociateKindClick = function(kind, submit) {
- // KindAPI.getParents({childId : kind.id}, {}, function(data) {
- // $scope.actives = data;
- // console.log(data);
- // var size = data.length;
- // if (size > 0) {
- // submit.gradeOneKiName = $scope.actives[0].nameCn;
- // submit.kiName = submit.gradeOneKiName;
- // if (size > 1) {
- // submit.gradeTwoKiName = $scope.actives[1].nameCn;
- // submit.kiName = submit.gradeTwoKiName;
- // if (kind.level < 3) {
- // submit.gradeThreeKiName = null;
- // } else if (size > 2) {
- // submit.gradeThreeKiName = $scope.actives[2].nameCn;
- // submit.kiName = submit.gradeThreeKiName;
- // }
- // }
- // }
- // console.log(submit);
- // })
- // };
- // 选择类目
- $scope.selectKind = function(prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function() {
- return $scope.actives;
- }
- }
- }).result.then(function(data){
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function(){
- });
- };
- // // 验证分类信息
- // $scope.checkKind = function() {
- // setTimeout(function() {
- // if($scope.activesString == null) {
- // $scope.component.kindid = null;
- // return;
- // }
- // KindAPI.getKindByName({name : encodeURIComponent($scope.activesString)}, function(kind) {
- // $scope.component.kind = kind;
- // $scope.component.kindid = kind.id;
- // $scope.activesString = $scope.component.kind.nameCn;
- // KindAPI.getPropertiesValues({kindId: $scope.component.kindid}, function(data) {
- // $scope.kindProperties = data;
- // angular.forEach($scope.kindProperties, function(kp) {
- // angular.forEach($scope.component.properties, function(pro) {
- // if (pro.value && (kp.propertyId == pro.propertyid)) {
- // kp.value = pro.value;
- // }
- // });
- // });
- // }, function(response) {
- // });
- // }, function (response) {
- // $scope.component.kindid = null;
- // toaster.pop('error', response.data);
- // });
- // }, 500);
- // };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function(brand, prod) {
- // $scope.component.brand = brand;
- // $scope.component.brandid = brand.id;
- prod.brand = brand;
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function(prod){ //打开模态
- var modalInstance = $modal.open({
- templateUrl : 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller : 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function(){// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function(brand){
- console.log(brand);
- prod.brand = brand.nameCn;
- }, function(reason){
- });
- };
- // // 验证品牌是否正确
- // $scope.checkBrand = function () {
- // setTimeout(function () {
- // BrandActiveAPI.findByName({name : encodeURIComponent($scope.component.brand.nameCn)}, function (data) {
- // // $scope.component.brand = brand;
- // // $scope.component.brandid = brand.id;
- // }, function (response) {
- // // $scope.component.brandid = null;
- // toaster.pop('error', response.data);
- // })
- // } , 500);
- // };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function(cmp, prod) {
- ComponentActiveAPI.get({uuid : cmp.uuid}, {}, function(data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.brand = data.brand.nameCn;
- }, function(res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- $scope.condition = {dateZone: 1};
- $scope.tenderProd = [];
- var prod = {
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- };
- $scope.tender = {
- date: new Date(),
- unit: 'PCS',
- currency: 'RMB',
- ifOpen: 0,
- ifTax: 1,
- invoiceType: 2,
- tenderAttachs:[{}]
- };
- //
- $scope.tenderProd.push(prod);
- //增加商品
- $scope.add = function(index) {
- $scope.tenderProd.push({
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- });
- };
- //删除商品
- $scope.del = function(index) {
- $scope.tenderProd.splice(index, 1);
- };
- // 批量导入
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcTenderUploadCtrl',
- size: 'lg',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- // 获取上传的产品明细,前台展示
- angular.forEach(data, function(data) {
- $scope.tenderProd.push(data);
- for(var i = 0; i < $scope.tenderProd.length; i++) {
- if($scope.tenderProd[i].prodTitle == null) { // 如果没有填写就删除这行数据
- $scope.tenderProd.splice(i, 1);
- console.log($scope.tenderProd);
- }
- }
- });
- }, function(){
- });
- };
- // 已存在id的为查看招标单(用于在录入的招标单的发布和删除)
- if( ! angular.isUndefined($stateParams.id)) {
- $scope.loading = true;
- PurcTender.getOne({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- parseCertificate($scope.tender.certificate);
- $scope.firstProd = data.purchaseTenderProds[0];
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function(item) {
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, item.saleTender.enterpriseBaseInfo);
- } else {
- $scope.tenderProd.enterpriseBaseInfo.push(item.saleTender.enterpriseBaseInfo);
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- console.log($scope.tenderProd.enterpriseBaseInfo);
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- if(angular.isUndefined($stateParams.id)) { // 发布招标单之后,再次新增招标单时,新增供应商时不会勾选上一个单据选择的供应商
- $rootScope.tenderVendor = [{}];
- }
- $scope.changeShipAddress = false;
- $scope.changeAddress = function() {
- if ($scope.changeShipAddress) {
- $scope.changeShipAddress = false;
- } else {
- $scope.changeShipAddress = true;
- }
- };
- // $scope.validateNumber = function (value) { // 采购数量 正整数
- // var regex = /^\+?[1-9][0-9]*$/;
- // if (!regex.test(value) || value === 0 || value === null) {
- // toaster.pop('warning', '警告', '采购数量不合法,请重新填写');
- // }
- // };
- $scope.removeChecked = function() {
- if ($scope.tenderProd.enterpriseBaseInfo.length > 0) {
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- }
- };
- // 查找供应商
- $scope.dbfindVendor = function(){
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {
- }
- });
- var ifPush = true;
- modalInstance.result.then(function(data){
- angular.forEach(data, function(vendor) {
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0;i<$scope.tenderProd.enterpriseBaseInfo.length; i++) {
- ifPush = true;
- if ($scope.tenderProd.enterpriseBaseInfo[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.tenderProd.enterpriseBaseInfo.push(vendor.vendorEnterprise);
- }
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- }, function(){
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function(index) {
- $scope.tenderProd.enterpriseBaseInfo.splice(index, 1);
- };
- // 删除供应商时,后台删除投标单
- $scope.removeSaleTender = function (tender, vendUU) {
- PurcTender.removeSaleTender ({}, {tender : tender, vendUU : vendUU}, function(data) {
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 删除产品明细时,后台删除产品明细
- $scope.deleteProd = function (tenderProdId) {
- PurcTender.deleteProd ({}, {tenderProdId : tenderProdId}, function(data) {
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // // 查找客户物料
- // $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', '错误', '请先选择客户');
- // }
- // }
- // };
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- $scope.upload = function(myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderAttach',
- file: file,
- method: 'POST'
- // data: {
- // tender: $scope.tender
- // }
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function(id, index) {
- $scope.attaches.splice(index, 1);
- PurcTender.removeAttach({attachId:id}, function() {
- });
- };
- var sleep = function (d){
- for(var t = Date.now();Date.now() - t <= d;);
- };
- // 保存和发布招标单
- $scope.save = function(isPublish){
- if (!$scope.tender.ifOpen && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info','提示','请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function(certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if(!$scope.tender.code) { //新增,设单号
- $scope.tender.code = 'ZB' + $filter('date')(new Date(), 'yyMMddHHmmss');
- }
- if($scope.tender.date instanceof Date) {
- $scope.tender.date = $scope.tender.date.getTime();
- }
- if($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- console.log($scope.tender.shipAddress);
- var vendorUUs = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function(enterpriseBaseInfo){
- vendorUUs.push(enterpriseBaseInfo.uu);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- PurcTender.publish({tender: $scope.tender, vendorUUs: vendorUUs}, {}, function(data){
- sleep(1500); //当前方法暂停1.5秒
- $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- PurcTender.save({tender: $scope.tender, vendorUUs: vendorUUs}, {}, function(data) {
- $scope.loading = false;
- sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- // 删除(在录入状态)
- $scope.deleteThis = function(id) {
- PurcTender.deleteOne({}, id, function() {
- toaster.pop('info', '提示', '删除成功');
- window.location.hash = '#/purc/tender';
- });
- };
- // 更新和发布(在录入状态)
- $scope.updateSaved = function(isPublish){
- if (!$scope.tender.ifOpen && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info','提示','请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function(certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- var vendorUUs = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function(enterpriseBaseInfo){
- vendorUUs.push(enterpriseBaseInfo.uu);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- PurcTender.publishSaved({tender: $scope.tender, vendorUUs: vendorUUs}, {}, function(data){
- sleep(1500); //当前方法暂停1.5秒
- $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- PurcTender.updateSaved({tender: $scope.tender, vendorUUs: vendorUUs}, {}, function(data) {
- $scope.loading = false;
- sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- $scope.publishSaved = function(tender) {
- var now = new Date() + 1; // 投标截止日为当天的均可以提交
- if (tender.endDate < now) {
- toaster.pop('warning', '警告', '单据已过期,请重新设置日期');
- } else {
- toaster.pop('info', '提示', '正在发布,请稍候');
- PurcTender.publishSaved({tender: tender}, function() {
- sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '提示', '发布成功');
- window.location.hash = '#/purc/tender';
- });
- }
- };
- // 更新(在录入状态)
- $scope.updateSaved = function(tender) {
- var now = new Date() + 1; // 投标截止日为当天的均可以提交
- if (tender.endDate < now) {
- toaster.pop('warning', '警告', '单据已过期,请重新设置日期');
- } else {
- toaster.pop('info', '提示', '正在保存更新,请稍候');
- PurcTender.updateSaved({tender: tender}, function() {
- sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '提示', '更新成功');
- window.location.hash = '#/purc/tender';
- });
- }
- };
- $scope.currentDay = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.getMinDate = function() {
- // var now = new Date();
- // now = now.setDate(now.getDate()+1);
- // var minDate = angular.copy($scope.tender.endDate);
- // minDate = minDate.setDate(minDate.getDate() + 1);
- if ($scope.tender.endDate instanceof Date) {
- var minDate = new Date($scope.tender.endDate.getTime() + 24*60*60*1000 + 1); // 不能选相同一天
- }
- return $scope.tender.endDate ? $filter('date')(minDate, 'yyyy-MM-dd'):$filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.getMaxDate = function() {
- // var maxDate = angular.copy($scope.tender.publishDate);
- // maxDate = maxDate.setDate(maxDate.getDate() - 1);
- if ($scope.tender.publishDate instanceof Date) {
- var maxDate = new Date($scope.tender.publishDate.getTime() - 1); // 不能选同一天
- }
- return $scope.tender.publishDate ? $filter('date')(maxDate, 'yyyy-MM-dd'):"";
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- //类目选择模态框(招标产品明细)
- app.controller('ProdKindChooseCtrl', ['$scope', 'KindAPI', 'actives', 'toaster', '$modalInstance', function($scope, KindAPI, actives, toaster, $modalInstance) {
- $scope.actives = actives;
- $scope.kinds = [[], [], [], []];
- // 获取子类目
- var getChildren = function(pid, deep) {
- KindAPI.getChildren({parentId: pid}, function(data) {
- $scope.kinds[deep] = data;
- }, function(response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- };
- // 改变节点选中状态
- var changeStatus = function(item, deep) {
- var actives = [], level = 0;
- angular.forEach($scope.kinds, function(ks, i) {
- if(i > deep) {
- $scope.kinds[i] = [];
- } else {
- angular.forEach(ks, function(k, j) {
- if(i == deep) {
- if(k.id == item.id) {
- $scope.kinds[i][j].$active = true;
- actives.push(k);
- } else {
- k.$active = null;
- }
- } else {
- if(k.$active) {
- actives.push(k);
- }
- }
- });
- }
- });
- // 选择的节点
- $scope.actives = actives;
- $scope.active = item;
- // 当前可操作的层级
- if(deep < 3) {
- $scope.activeDeep = deep + 1;
- }
- };
- // 节点点击后获取子类目,节点被选中
- $scope.onItemClick = function(item, deep) {
- changeStatus(item, deep);
- if (!item.isLeaf) {
- getChildren(item.id, deep + 1);
- }
- };
- // 重新加载数据
- function reload(deep) {
- var pid;
- if(deep) {
- pid = $scope.actives[deep - 1].id;
- } else {
- pid = 0;
- deep = 0;
- }
- getChildren(pid, deep);
- }
- // 初始加载数据,获取第一层的类目
- if($scope.actives) {
- angular.forEach($scope.actives, function(v, k) {
- KindAPI.getChildren({parentId: v.parentid}, function(data) {
- $scope.kinds[k] = data;
- angular.forEach($scope.kinds[k], function(kind, i){
- if(kind.id == v.id) {
- $scope.kinds[k][i].$active = true;
- $scope.actives[k] = $scope.kinds[k][i];
- }
- })
- }, function(response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- });
- } else {
- reload();
- }
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- // 确认选择
- $scope.check = function() {
- var a = {
- active: $scope.active,
- actives: $scope.actives
- };
- $modalInstance.close(a);
- };
- }]);
- //品牌选择模态框的controller
- app.controller('BrandModalInstanceCtrl', ['$scope', '$modalInstance', 'ngTableParams', 'BrandActiveAPI', 'BaseService', function($scope, $modalInstance, ngTableParams, BrandActiveAPI, BaseService) {
- $scope.filter = {};
- $scope.brandsTableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting : {
- nameCn: 'asc'
- }
- }, {
- total : 0,
- counts : [],
- getData : function($defer, params) {
- var param = BaseService.parseParams(params.url());
- param.keyword = $scope.filter.keyword;
- var keyword = $scope.filter.keyword;
- // param.keyword = $scope.filter.keyword;
- BrandActiveAPI.getSimpleInfoPage(param, {}, function(page) {
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function(){
- });
- }
- });
- // 搜索
- $scope.search = function() {
- // $scope.brandsTableParams.filter({$: $scope.filter.keyword});
- $scope.brandsTableParams.page(1);
- $scope.brandsTableParams.reload();
- };
- // 选择
- $scope.select = function(brand){
- $modalInstance.close(brand);
- };
- // 关闭
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 招标单批量导入
- */
- app.controller('PurcTenderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function() {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'tender/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- console.log(data);
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function(response) {
- toaster.pop('error', '提示', '上传失败,请检查填写格式');
- });
- };
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadTenderProducts_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function() {
- window.location.href = 'tender/upload/template';
- };
- $scope.enSure = function() {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 评标
- */
- app.controller('PurcEvaluationCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.tenderItems = [];
- // 采购方获取评标单
- var evaluation = function() {
- $scope.loading = true;
- PurcTender.getOne({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.tender = data;
- $scope.tableParams = new ngTableParams({}, { dataset: data});
- // $scope.tableParams.sorting($scope.sort.field, $scope.sort.desc);
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- evaluation();
- // 设置排序方式
- $scope.setSort = function(field, desc) {
- if(field == 'price' && $scope.sort.field != 'price') {// 切换到价格排序时先升序排序
- desc = 'asc';
- } else if( ! desc) {
- // if($scope.sort.desc == 'asc') {
- // desc = 'desc';
- // } else {
- // desc = 'asc';
- // }
- }
- $scope.sort = {field: field, desc: desc};
- $scope.tableParams.sorting($scope.sort.field, $scope.sort.desc);
- };
- $scope.orderType = 'price';
- // $scope.dir = '-';
- // 改变排序顺序
- $scope.changeOrder = function(type){
- $scope.orderType = type;
- // if(!$scope.dir || $scope.dir === '') {
- // $scope.dir = '-';
- // }else {
- // $scope.dir = '';
- // }
- };
- $scope.submit = function(tender) {
- PurcTender.decide(tender, function(){
- toaster.pop('success', '确认成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- toaster.pop('error', '确认失败', response.data);
- });
- }
- }]);
- /**
- * 客户指定招标
- *
- */
- app.controller('SaleTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.condition = {dateZone: 1};
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- 'tender.endDate': 'desc',
- 'tender.enterprise.enName': 'asc',
- 'tender.code': 'asc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- // fromDate: getDateTime($scope.condition.dateFrom),
- // endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.currentEn = data;
- });
- PurcTender[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- angular.forEach(page.content, function(purcTender) {
- angular.forEach(purcTender.purchaseTenderProds[0].saleTenderItems, function(saleTenderItem) {
- saleTenderItem.saleTender.vendorHasBid = false; // 未投标
- if ($scope.currentEn.uu === saleTenderItem.saleTender.vendUU && saleTenderItem.price !== null) { // 存在本企业投标明细,且价格已填,判定为已投标
- saleTenderItem.saleTender.vendorHasBid = true; // 已投标
- saleTenderItem.saleTender.applyVendor = false; // 未中标
- if (saleTenderItem.applyStatus === 1) {
- saleTenderItem.saleTender.applyVendor = true; // 是否中标
- }
- }
- });
- });
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- var stautsItem = [];
- $scope.getTenderStatus = function (tender) {
- angular.forEach(tender.purchaseTenderItems, function(thisItem){
- if ($scope.currentEn.uu == thisItem.enterpriseBaseInfo.uu) {
- stautsItem = thisItem;
- }
- });
- if (!stautsItem.price) {
- return "daitoubiao";
- } else if (!stautsItem.applystatus) {
- return "yitoubiao";
- } else if (stautsItem.applystatus == 1) {
- return "zhongbiao";
- } else if (stautsItem.applystatus == 0) {
- return "weizhongbiao";
- }
- };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 平台公开招标
- *
- */
- app.controller('SaleOpenTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.condition = {dateZone: 1};
- // $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 getOpenState = function(active) {
- var fn = 'getOpenAll';
- switch(active) {
- case 'all':
- fn = 'getOpenAll';break;
- // case 'done':
- // fn = 'getOpenDone';break;
- case 'todo':
- fn = 'getOpenTodo';break;
- case 'end':
- fn = 'getOpenEnd';break;
- // case 'waiting':
- // fn = 'getOpenWaiting';break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10,
- sorting: {
- 'tender.endDate': 'desc',
- 'tender.enterprise.enName': 'asc',
- 'tender.code': 'asc'
- }
- }, {
- total : 0,
- counts: [10, 25, 50, 100],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- // fromDate: getDateTime($scope.condition.dateFrom),
- // endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.currentEn = data;
- });
- PurcTender[getOpenState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.toDetail = function(id) {
- window.location.hash = '#/sale/openTenderDetail/' + id;
- };
- // var stautsItem = [];
- // $scope.getTenderStatus = function (tender) {
- // angular.forEach(tender.purchaseTenderItems, function(thisItem){
- // if ($scope.currentEn.uu == thisItem.enterpriseBaseInfo.uu) {
- // stautsItem = thisItem;
- // }
- // });
- // if (!stautsItem.price) {
- // return "daitoubiao";
- // } else if (!stautsItem.applystatus) {
- // return "yitoubiao";
- // } else if (stautsItem.applystatus == 1) {
- // return "zhongbiao";
- // } else if (stautsItem.applystatus == 0) {
- // return "weizhongbiao";
- // }
- // };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 采购方查看供应商投标单
- */
- app.controller('SaleVendorTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- // PurcTender.getVendorTenderItem({vendUU:$stateParams.vendUU, id: $stateParams.id}, function(data){
- // $scope.item = data; // 供应商查看
- // $scope.loading = false;
- // }, function(response){
- // $scope.loading = false;
- // toaster.pop('error', '数据加载失败', response.data);
- // });
- console.log($stateParams);
- PurcTender.getOne({id: $stateParams.id}, function(data){
- $scope.bid = data;
- angular.forEach(data.purchaseTenderProds, function(tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- if (saleTenderItem.saleTender.vendUU == $stateParams.vendUU) {// 与传出的参数venUU相等,即为查看企业对应的明细
- tenderProd.currentItem = saleTenderItem;
- $scope.saleTender = saleTenderItem.saleTender;
- $scope.currentEnBaseInfo = saleTenderItem.saleTender.enterpriseBaseInfo;
- }
- });
- });
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
- }]);
- /**
- * 查看投标单详情
- */
- app.controller('SaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise) {
- BaseService.scrollBackToTop();
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- // var staticItem = null;
- // $scope.loading = true;
- // PurcTender.getItem({id: $stateParams.id}, function(data){
- // $scope.item = data; // 用于投标
- // if ($scope.item.enterpriseBaseInfo != null) {
- // $scope.itemStatusTodo = $scope.item.enterpriseBaseInfo.uu + "待投标";
- // }
- // staticItem = angular.copy(data);
- // $scope.loading = false;
- // }, function(response){
- // $scope.loading = false;
- // toaster.pop('error', '数据加载失败', response.data);
- // });
- var sleep = function (d){
- for(var t = Date.now();Date.now() - t <= d;);
- }
- AccountEnterprise.get({}, function(data){
- $scope.currentEn = data;
- });
- PurcTender.getOne({id: $stateParams.id}, function(data){
- $scope.bid = data;
- angular.forEach(data.purchaseTenderProds, function(tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- if (!$scope.currentEn) {
- AccountEnterprise.get({}, function(data){
- $scope.currentEn = data;
- });
- }
- if (saleTenderItem.saleTender.vendUU === $scope.currentEn.uu) {
- tenderProd.currentItem = saleTenderItem;
- $scope.saleTender = saleTenderItem.saleTender;
- $scope.attaches = saleTenderItem.saleTender.bidAttaches;
- $scope.currentEnBaseInfo = saleTenderItem.saleTender.enterpriseBaseInfo;
- }
- });
- });
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
- $scope.upload = function(myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderItemAttach',
- file: file,
- method: 'POST'
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function(attachId, index) {
- $scope.attaches.splice(index, 1);
- // PurcTender.removeAttach({attachId : id}, {}, function() {
- //
- // });
- };
- var taxrateYes = false;
- var cycleYes = false;
- var priceYes = false;
- $scope.canSave = false;
- $scope.validateThis = function(value, type) {
- switch(type) {
- case 'taxrate':
- var regex = /^\+?[0-9][0-9]{0,1}$/;
- if (regex.test(value)) {
- taxrateYes = true;
- } else {
- if (value) {
- toaster.pop('warning', '警告', '税率不合法,请重新填写');
- }
- }
- break;
- case 'cycle':
- regex = /^\+?[1-9][0-9]*$/;
- if (regex.test(value)) {
- cycleYes = true;
- } else {
- if (value) {
- toaster.pop('warning', '警告', '周期不合法,请重新填写');
- }
- }
- break;
- case 'price':
- regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (regex.test(value) && value !== 0) {
- priceYes = true;
- } else {
- if (!(value instanceof Number) || value) {
- toaster.pop('warning', '警告', '单价不合法,请重新填写');
- }
- }
- break;
- }
- };
- $scope.emNumYes = true;
- $scope.validEmNum = function (value) {
- var regex = /^\+?[1-9][0-9]*$/;
- if (!regex.test(value) || value === 0 || value !== null) {
- $scope.emNumYes = false;
- toaster.pop('warning', '警告', '人数不合法,请重新填写');
- }
- };
- $scope.validateProds = function(tenderProd) {
- // angular.forEach(tenderProds, function (tenderProd) {
- var cycleRegex = /^\+?[1-9][0-9]*$/;
- var taxrateRegex = /^\+?[0-9][0-9]{0,1}$/;
- var priceRegex = /^(([0-9]+\.[0-9]{1,6})|([0-9]*[1-9][0-9]*\.[0-9]{1,6})|([0-9]*[1-9][0-9]*))$/; // 非零最多六位小数正实数
- // /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- // 判断填写过的有为0或不符合正则式的,设置不能保存
- console.log(tenderProd.currentItem.cycle);
- if (tenderProd.currentItem.cycle !== null && (!cycleRegex.test(tenderProd.currentItem.cycle)) || (tenderProd.currentItem.taxrate !== null && !taxrateRegex.test(tenderProd.currentItem.taxrate)) || (tenderProd.currentItem.price !== null && (!priceRegex.test(tenderProd.currentItem.price) && tenderProd.currentItem.price !== 0))) {
- $scope.canSave = false;
- } else {
- $scope.canSave = true;
- }
- // });
- };
- // 投标
- $scope.bidIt = function(tender, currentEnBaseInfo){
- $scope.loading = true;
- if(currentEnBaseInfo.enEstablishDate instanceof Date) {
- currentEnBaseInfo.enEstablishDate = currentEnBaseInfo.enEstablishDate.getTime();
- }
- var saleTenderItems = [];
- if (tender.ifOpen !== 1) { // 指定投标不把投标单主表设空会报header超长
- angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- if (tenderProd.currentItem) {
- tenderProd.currentItem.saleTender = {};
- saleTenderItems.push(tenderProd.currentItem);
- }
- });
- } else {
- angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- if (tenderProd.currentItem) {
- saleTenderItems.push(tenderProd.currentItem);
- }
- });
- }
- PurcTender.reply({tenderItems: saleTenderItems, enBaseInfo: currentEnBaseInfo, attaches:$scope.attaches}, {}, function(data){
- $scope.loading = false;
- toaster.pop('info', '成功', '投标成功');
- // $window.location.reload();
- // if (tender.ifOpen) { // 根据是否公开,选择跳转
- // window.location.hash = '#/sale/opentender';
- // } else {
- window.location.hash = '#/sale/tender';
- // }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '投标失败', '出现异常,投标失败');
- });
- };
- $scope.condition = {
- $fromOpened:false
- };
- $scope.getMaxDate = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- /**
- * 公开招标转投标单
- */
- app.controller('OpenSaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise) {
- BaseService.scrollBackToTop();
- $scope.attaches = []; // 存放上传了的附件
- var sleep = function (d){
- for(var t = Date.now();Date.now() - t <= d;);
- }
- AccountEnterprise.get({}, function(data){
- $scope.currentEn = data;
- });
- if( ! angular.isUndefined($stateParams.id)) { // 获取招标单详情
- $scope.loading = true;
- PurcTender.getOne({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- // parseCertificate($scope.tender.certificate);
- // $scope.firstProd = data.purchaseTenderProds[0];
- $scope.currentHasBid = false; // 默认当前企业未转投标单
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function(item) {
- if ($scope.currentEn.uu === item.saleTender.vendUU) { // 存在当前企业为供应商的投标单,判断已转
- $scope.currentHasBid = true;
- }
- });
- // $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- // console.log($scope.tenderProd.enterpriseBaseInfo);
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- $scope.iWantToBid = function(id) {
- PurcTender.addItems({id: id}, function(data){ // 添加明细
- // $scope.tender = data;
- // angular.forEach(data.purchaseTenderProds, function(tenderProd) {
- // angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- // if (!$scope.currentEn) {
- // AccountEnterprise.get({}, function(data){
- // $scope.currentEn = data;
- // });
- // }
- // if (saleTenderItem.saleTender.vendUU === $scope.currentEn.uu) {
- // tenderProd.currentItem = saleTenderItem;
- // $scope.saleTender = saleTenderItem.saleTender;
- // $scope.attaches = saleTenderItem.saleTender.bidAttaches;
- // $scope.currentEnBaseInfo = saleTenderItem.saleTender.enterpriseBaseInfo;
- // }
- // });
- // });
- if (data.success) {
- toaster.pop('success', '成功', '转投标单成功');
- window.location.hash = '#/sale/tender';
- }
- }, function(response){
- toaster.pop('error', '操作失败', response.data);
- });
- $scope.upload = function(myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderItemAttach',
- file: file,
- method: 'POST'
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- };
- $scope.removeAttach = function(id, index) {
- $scope.attaches.splice(index, 1);
- PurcTender.removeAttach({attachId:id}, function() {
- });
- };
- var taxrateYes = false;
- var cycleYes = false;
- var priceYes = false;
- $scope.canSave = false;
- $scope.validateThis = function(value, type) {
- switch(type) {
- case 'taxrate':
- var regex = /^\+?[0-9][0-9]{0,1}$/;
- if (regex.test(value)) {
- taxrateYes = true;
- } else {
- toaster.pop('warning', '警告', '税率不合法,请重新填写');
- }
- break;
- case 'cycle':
- regex = /^\+?[1-9][0-9]*$/;
- if (regex.test(value)) {
- cycleYes = true;
- } else {
- toaster.pop('warning', '警告', '周期不合法,请重新填写');
- }
- break;
- case 'price':
- regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (regex.test(value) && value !== 0) {
- priceYes = true;
- } else {
- if (!(value instanceof Number) || value) {
- toaster.pop('warning', '警告', '单价不合法,请重新填写');
- }
- }
- break;
- }
- };
- $scope.emNumYes = true;
- $scope.validEmNum = function (value) {
- var regex = /^\+?[1-9][0-9]*$/;
- if (!regex.test(value) || value == 0 || value !== null) {
- $scope.emNumYes = false;
- toaster.pop('warning', '警告', '人数不合法,请重新填写');
- }
- };
- $scope.validateProds = function(tenderProd) {
- // angular.forEach(tenderProds, function (tenderProd) {
- var cycleRegex = /^\+?[1-9][0-9]*$/;
- var taxrateRegex = /^\+?[0-9][0-9]{0,1}$/;
- var priceRegex = /^(([0-9]+\.[0-9]{1,6})|([0-9]*[1-9][0-9]*\.[0-9]{1,6})|([0-9]*[1-9][0-9]*))$/; // 非零最多六位小数正实数
- // /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- // 判断填写过的有为0或不符合正则式的,设置不能保存
- console.log(tenderProd.currentItem.cycle);
- if (tenderProd.currentItem.cycle !== null && (!cycleRegex.test(tenderProd.currentItem.cycle)) || (tenderProd.currentItem.taxrate !== null && !taxrateRegex.test(tenderProd.currentItem.taxrate)) || (tenderProd.currentItem.price !==null && (!priceRegex.test(tenderProd.currentItem.price) && tenderProd.currentItem.price !== 0))) {
- $scope.canSave = false;
- } else {
- $scope.canSave = true;
- }
- // });
- };
- // 投标
- $scope.bidIt = function(tender, currentEnBaseInfo){
- $scope.loading = true;
- if(currentEnBaseInfo.enEstablishDate instanceof Date) {
- currentEnBaseInfo.enEstablishDate = currentEnBaseInfo.enEstablishDate.getTime();
- }
- var saleTenderItems = [];
- if (tender.ifOpen !== 1) { // 指定投标不把投标单主表设空会报header超长
- angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- if (tenderProd.currentItem) {
- tenderProd.currentItem.saleTender = {};
- saleTenderItems.push(tenderProd.currentItem);
- }
- });
- } else {
- angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- if (tenderProd.currentItem) {
- saleTenderItems.push(tenderProd.currentItem);
- }
- });
- }
- PurcTender.reply({tenderItems: saleTenderItems, enBaseInfo: currentEnBaseInfo, attaches:$scope.attaches}, {}, function(data){
- $scope.loading = false;
- toaster.pop('info', '成功', '投标成功');
- // $window.location.reload();
- // if (tender.ifOpen) { // 根据是否公开,选择跳转
- // window.location.hash = '#/sale/opentender';
- // } else {
- window.location.hash = '#/sale/tender';
- // }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '投标失败', '出现异常,投标失败');
- });
- };
- $scope.condition = {
- $fromOpened:false
- };
- $scope.getMaxDate = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- return app;
- });
|