| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670 |
- 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_detail.html",
- controller : 'NewDeputyOrderCtrl'
- /* 招标列表 */
- }).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 : "/tender/:id",
- templateUrl : "static/tpl/index/purc/tender.html",
- controller : 'PurcNewTenderCtrl'
- /* 评标 */
- }).state('purc.evaluation', {
- url : "/evaluation/:id",
- templateUrl : "static/tpl/index/purc/tender_evaluation.html",
- controller : 'PurcEvaluationCtrl'
- /* 客户指定招标列表 */
- }).state('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('sale.opentenderlist', {
- url : "/opentender",
- templateUrl : "static/tpl/index/sale/opentenderlist.html",
- controller : 'SaleOpenTenderCtrl'
- }).state('sale.todo.opentenderlist', {
- url : "/opentender",
- templateUrl : "static/tpl/index/sale/opentenderlist.html",
- controller : 'SaleOpenTenderCtrl'
- /* 公开招标单转投标单 */
- }).state('sale.opentender', {
- url : "/opentender/:id",
- templateUrl : "static/tpl/index/sale/tender.html",
- controller : 'SaleTenderDetailCtrl'
- /* 投标 */
- }).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/tender_vendor.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.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('account', {
- url : "/account",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/account/left.html",
- controller: 'LeftCtrl'
- },
- "right-view" : {
- templateUrl : "static/tpl/index/account/right.html"
- }
- }
- }).state('account.index', {
- url : "",
- templateUrl : "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('account.home', {
- url : "/",
- templateUrl : "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('account.enterprise', {
- url : "/enterprise",
- templateUrl : "static/tpl/index/account/enterprise.html",
- controller: 'EnterpriseCtrl'
- }).state('account.user', {
- url : "/user",
- templateUrl : "static/tpl/index/account/user.html",
- controller: 'UserCtrl'
- }).state('account.log', {
- url : "/log",
- templateUrl : "static/tpl/index/account/log.html",
- controller: 'LogCtrl'
- }).state('account.resource', {
- url : "/resource",
- templateUrl : "static/tpl/index/account/resource.html",
- controller: 'ResourceCtrl'
- }).state('account.role', {
- url : "/role",
- templateUrl : "static/tpl/index/account/role.html",
- controller: 'RoleCtrl'
- }).state('baseInfo', {//基础资料
- url : "/baseInfo",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/baseInfo/left.html",
- controller: 'LeftCtrl'
- },
- "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.prodList', {
- url : "/prodList",
- templateUrl : "static/tpl/index/baseInfo/prodList.html",
- controller : 'ProductListCtrl'
- }).state('baseInfo.uploadByBatch', {
- url : "/uploadByBatch",
- templateUrl : "static/tpl/index/baseInfo/uploadByBatch.html",
- controller : 'UploadByBatchCtrl'
- }).state('baseInfo.productDetail', {
- url : "/prodList/:id",
- templateUrl : "static/tpl/index/baseInfo/productDetail.html",
- controller : 'ProductDetailCtrl'
- }).state('baseInfo.newProdInfo', {
- url : "/newProdInfo",
- templateUrl : "static/tpl/index/baseInfo/newProdInfo.html",
- controller : 'NewProdInfoCtrl'
- }).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('qc.badIn', {
- url : "/badIn",
- templateUrl : "static/tpl/index/qc/badIn.html",
- controller: 'SaleBadInCtrl'
- }).state('qc.badOut', {
- url : "/badOut",
- templateUrl : "static/tpl/index/qc/badOut.html",
- controller: 'SaleBadOutCtrl'
- }).state('qc.MRB', {
- url : "/MRB",
- templateUrl : "static/tpl/index/qc/MRB.html",
- controller: 'SaleMRBCtrl'
- }).state('fa', {
- url : "/fa",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/fa/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/fa/right.html"
- }
- }
- }).state('fa.index', {
- url : "",
- templateUrl : "static/tpl/index/fa/index.html"
- }).state('fa.home', {
- url : "/",
- templateUrl : "static/tpl/index/fa/index.html"
- }).state('fa.apBill', {
- url : "/apBill",
- templateUrl : "static/tpl/index/fa/apBill.html",
- controller: 'SaleApBillCtrl'
- }).state('fa.arCheck', {
- url : "/arCheck",
- templateUrl : "static/tpl/index/fa/arCheck.html",
- controller: 'SaleArCheckCtrl'
- }).state('fa.arCheck_detail', {
- url : "/arCheck/:id",
- templateUrl : "static/tpl/index/fa/arCheck_detail.html",
- controller: 'SaleArCheckDetailCtrl'
- }).state('fa.apCheck', {
- url : "/apCheck",
- params:{
- 'id':null
- },
- templateUrl : "static/tpl/index/fa/apCheck.html",
- controller: 'PurchaseApCheckCtrl'
- }).state('fa.apCheck_detail', {
- url : "/apCheck/:id",
- templateUrl : "static/tpl/index/fa/apCheck_detail.html",
- controller: 'PurchaseApCheckDetailCtrl'
- }).state('fa.apCheckList', {
- url : "/apCheckList",
- templateUrl : "static/tpl/index/fa/apCheckList.html",
- controller: 'PurchaseApCheckListCtrl'
- }).state('make', {
- url : "/make",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/make/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/make/right.html"
- }
- }
- }).state('make.index', {
- url : "",
- templateUrl : "static/tpl/index/make/index.html"
- }).state('make.home', {
- url : "/",
- templateUrl : "static/tpl/index/make/index.html"
- }).state('make.todo', {
- url : "/todo",
- templateUrl : "static/tpl/index/make/todo.html"
- }).state('make.todo.order', {
- url : "/order",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('make.order', {
- url : "/order",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('make.order_detail', {
- url : "/order/:id",
- templateUrl : "static/tpl/index/make/order_detail.html",
- controller: 'MakeOrderDetailCtrl'
- }).state('make.change', {
- url : "/change",
- templateUrl : "static/tpl/index/make/change.html",
- controller: 'MakeChangeCtrl'
- }).state('make.change_detail', {
- url : "/change/:id",
- templateUrl : "static/tpl/index/make/change_detail.html",
- controller: 'MakeChangeDetailCtrl'
- }).state('make.outorder', {
- url : "/outorder",
- templateUrl : "static/tpl/index/make/outorder.html",
- controller: 'MakeOutOrderCtrl'
- }).state('make.outorder_detail', {
- url : "/outorder/:id",
- templateUrl : "static/tpl/index/make/outorder_detail.html",
- controller: 'MakeOutOrderDetailCtrl'
- }).state('make.accept', {
- url : "/accept",
- templateUrl : "static/tpl/index/make/accept.html",
- controller: 'MakeAcceptCtrl'
- }).state('make.returns', {
- url : "/returns",
- templateUrl : "static/tpl/index/make/returns.html",
- controller: 'MakeReturnCtrl'
- }).state('cs', {// 客户服务
- url : "/cs",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/cs/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/cs/right.html"
- }
- }
- }).state('cs.index', {
- url : "",
- templateUrl : "static/tpl/index/cs/index.html"
- }).state('cs.home', {
- url : "/",
- templateUrl : "static/tpl/index/cs/index.html"
- }).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/home.html",
- controller: 'approvalFlowCtrl'
- }
- },
- });
- $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', function($scope, $rootScope) {
- $rootScope.$on('$locationChangeSuccess', function(evt, newUrl) {
- var routeState = newUrl.substr(newUrl.indexOf('#/') + 2);
- if (routeState.indexOf('/') > -1)
- routeState = routeState.substring(0, routeState.indexOf('/'));
- if (routeState.indexOf('.') > -1)
- routeState = routeState.substring(0, routeState.indexOf('.'));
- $scope.routeState = routeState || 'home';
- });
-
- $scope.search = function(keyword) {
- if(keyword != null ) {
- $rootScope.searchKeyword = keyword;
- window.location.hash = '#/search?keyword='+keyword;
- }
- };
- }]);
- // TODO
- app.controller('TopSearchCtrl', ['$scope', '$rootScope', 'getAccountUserSpace', 'ngTableParams', 'toaster', 'BaseService', 'AddPartner', '$filter', '$stateParams', 'SearchProd', '$sce', function($scope, $rootScope, getAccountUserSpace, ngTableParams, toaster, BaseService, AddPartner, $filter, $stateParams, SearchProd, $sce) {
- $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";
- }
- }]);
-
- 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.showImageDialog = function(modal) {
- require([ 'jquery-uploadify' ], function() {
- $modal.open({
- templateUrl : 'static/tpl/index/home/insert.html',
- controller : 'ImageInsertCtrl',
- backdrop : 'static'
- }).result.then(function(image){
- $scope.imageUrl = image.thumb;
- User.postImageUrl(null, angular.toJson($scope.imageUrl), function(data){
- $scope.user = data;
- }, function(response) {
- toaster.pop('error', '设置图像失败,' + response.data);
- });
-
- });
- });
- }
-
- $scope.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', function($scope, SnapshotService){
- SnapshotService.getTodo(function(data){
- $scope.todo = data;
- });
- }]);
-
- app.controller('TruckCtrl', ['$scope', '$rootScope', '$modal', 'SaleTruck', function($scope, $rootScope, $modal, SaleTruck){
- SaleTruck.query({}, function(data){
- $rootScope.truck = data;
- $scope.truckCount = data ? data.length : 0;
- });
- $scope.$watch(function(){
- return $rootScope.truck;
- }, function(data) {
- $scope.truckCount = data ? data.length : 0;
- }, true);
- $scope.clearAll = function() {
- SaleTruck.remove({}, function(){
- $rootScope.truck = [];
- });
- };
- $scope.openTrack = function() {
- $modal.open({
- templateUrl: 'static/tpl/index/sale/track.html',
- controller: 'TruckModalCtrl',
- size: 'lg'
- }).result.then(function(s){
- if(s) {
- $scope.clearAll();
- $rootScope.dataChanged = true;
- }
- });
- };
- }]);
-
- app.controller('TruckModalCtrl', ['$scope', '$rootScope', '$modalInstance', 'SaleTruck', 'PurcNotice', 'toaster', '$state', '$filter', function($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice, toaster, $state, $filter){
- $scope.saleSend = {sendItems: []};
- SaleTruck.detail({}, function(data){
- // 按物料编号排序
- $scope.notices = $filter('orderBy')(data, 'orderItem.product.code');
- });
- $scope.remove = function(index, notice) {
- SaleTruck.remove({noticeId: notice.id}, function(data){
- $rootScope.truck = data;
- $scope.notices.splice(index, 1);
- });
- };
- $scope.$watch(function(){
- return $scope.notices;
- }, function(data) {
- var q = 0, t = 0;
- if(data) {
- angular.forEach(data,function(d){
- q += d.thisSendQty;
- t += d.thisSendQty * d.orderItem.price;
- });
- }
- $scope.totalQty = q;
- $scope.total = t;
- }, true);
- $scope.cancel = function() {
- $modalInstance.close();
- };
- $scope.send = function() {// 发货
- if(!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
- toaster.pop('error', '错误', '请输入送货单号');
- return;
- }
- var currency = $scope.notices[0].orderItem.order.currency,
- custUU = $scope.notices[0].enUU,
- payments = $scope.notices[0].orderItem.order.payments, valid = true, items = [];
- var num = 1;
- for(var i in $scope.notices) {
- var item = $scope.notices[i];
- if(item.id) {
- if(item.orderItem.order.currency != currency || item.enUU != custUU || item.orderItem.order.payments != payments) {
- valid = false;
- break;
- }
- items[i] = {noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price, number: num ++};
- }
- }
- if(!valid) {
- toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致、采购员一致才能一起发货。');
- } else {
- var send = angular.extend(angular.copy($scope.saleSend), {
- currency: currency,
- custUU: custUU,
- payments: payments,
- sendItems: items
- });
- PurcNotice.sendByBatch({}, send, function(data){
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + send.code);
- $modalInstance.close(true);
- $state.go('sale.send_detail', {id: data.id});
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- }
- };
- }]);
- app.controller('PersonalSaleStatCtrl', ['$scope', 'SaleStat', function($scope, SaleStat) {
- SaleStat.cust({}, function(data){
- var p = [], q = [];
- angular.forEach(data.month, function(d){
- p.push({x: (d.enterprise.enShortname || d.enterprise.enName), y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function(d){
- q.push({x: (d.enterprise.enShortname || d.enterprise.enName), y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.custCharts = {
- month : {
- chartType : 'pie',
- datas : {
- data : p
- },
- config : {
- labels : false,
- title : "客户月采购量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- },
- year : {
- chartType : 'pie',
- datas : {
- data : q
- },
- config : {
- labels : false,
- title : "客户年采购量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- }
- };
- });
- SaleStat.seller({}, function(data){
- var p = [], q = [];
- angular.forEach(data.month, function(d){
- p.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function(d){
- q.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.sellerCharts = {
- month : {
- chartType : 'pie',
- datas : {
- data : p
- },
- config : {
- labels : false,
- title : "业务员月销量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- },
- year : {
- chartType : 'pie',
- datas : {
- data : q
- },
- config : {
- labels : false,
- title : "业务员年销量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- }
- };
- });
- }]);
- app.controller('SaleStatCtrl', ['$scope', 'SaleStat', function($scope, SaleStat){
- SaleStat.get({}, function(data){
- var p = [], q = [], r = [];
- angular.forEach(data.day, function(d){
- p.push({x: d.day, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.month, function(d){
- q.push({x: d.month, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function(d){
- r.push({x: d.year, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.charts = {
- day : {
- chartType : "line",
- datas: {
- series: ['销售额'],
- data: p
- },
- config : {
- "labels": false,
- "title": "销售额统计(近15日线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors : [ '#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- month: {
- chartType : "line",
- datas: {
- series: ['销售额'],
- data: q
- },
- config : {
- "labels": false,
- "title": "销售额统计(近12月线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors : [ '#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- year: {
- chartType : "line",
- datas: {
- series: ['销售额'],
- data: r
- },
- config : {
- "labels": false,
- "title": "销售额统计(近10年线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors : [ '#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- }
- };
- });
- }]);
- app.controller('NoticeCtrl', ['$scope', 'SnapshotService', function($scope, SnapshotService){
- SnapshotService.getNotice(5, function(data){ //5表示首页显示的公告条数
- $scope.notices = data;
- });
-
- $scope.dateTime = new Date();
- }]);
- app.controller('TenderCtrl', ['$scope', 'SnapshotService', function($scope, SnapshotService){
- SnapshotService.getTender(5, function(data){ //5表示首页显示的招标单条数
- $scope.tenders = data;
- });
- SnapshotService.getOpenTender(5, function(data){ //5表示首页显示的招标单条数
- $scope.openTenders = data;
- });
- $scope.dateTime = new Date();
- }]);
- app.controller('VendCountCtrl', ['$scope', 'VendorService', function($scope, VendorService){
- VendorService.getCount(function(date){
- $scope.count = date;
- });
- }]);
- app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- var getCustInfos = function(custuu) {
- if(custuu) {
- VendorService.userInfo.query({uu:custuu},null,function(data) {
- $scope.custInfos = data;
- var getPage = function(page, size){
- if($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1)*size, page * size);
- if($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- }else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1,4);
- $scope.first = function (){
- $scope.userdata = getPage($scope.userdata.pre,4);
- }
- $scope.last = function (){
- $scope.userdata = getPage($scope.userdata.next,4);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }
- $scope.addUserInfo = function(customer) {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function() {
- return customer;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
-
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
- $scope.showUserInfo = function(customer,boo) {
- $scope.custInfo = customer;
- if(boo) {
- getCustInfos(customer.myEnterprise.uu);
- $scope.userInfoResult = true;
- }
- }
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- VendorService.customer.get(BaseService.parseParams(params.url()), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElements;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
- app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function($scope, $modalInstance, customer, AccountUser, toaster){
- $scope.checkboxes = {
- checked : false
- };
- $scope.loading = true;
- AccountUser.findUsers({uu:customer.myEnterprise.uu},null,function(data) {
- $scope.userinfos = data;
- $scope.loading = false;
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function() {
- angular.forEach($scope.userinfos, function(item) {
- item.distribute = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function(vendor){
- var result = true;
- angular.forEach($scope.userinfos, function(item) {
- if(item.distribute != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function(save) {
- var chooseResult = [];
- if(save) {
- if(customer.myEnterprise.uu) {
- angular.forEach($scope.userinfos, function(item, i) {
- chooseResult.push(item);
- });
- if(chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.addUserToVendor({uu : customer.myEnterprise.uu }, chooseResult,function(data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
-
- /**
- * 页面状态按钮过滤
- */
- var getState = function(active) {
- var fn = 'get';
- switch(active) {
- case 'done':
- fn = 'getDone';break;
- case 'todo':
- fn = 'getTodo';break;
- case 'end':
- fn = 'getEnd';break;
- case 'waiting':
- fn = 'getWaiting';break;
- 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){
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1, deliveryZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function(zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
-
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- var getPurcStatus = function(active) {
- var fn = 'getPurcAll';
- switch(active) {
- case 'done':
- fn = 'getPurcDone';break;
- case 'todo':
- fn = 'getPurcTodo';break;
- case 'end':
- fn = 'getPurcEnd';break;
- case 'waiting':
- fn = 'getPurcWaiting';break;
- }
- return fn;
- }
-
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 5,
- sorting: {
- display: 'desc',
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 15, 25, 50],
- getData : function($defer, params) {// 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- 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() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $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){
- $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){
- $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){
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return $scope.condition.dateZone ? PurcInquiry : PurcInquiryHis;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.keyword = $scope.keyword;
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.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('SaleInquiryMouldCtrl',['$scope', '$filter', 'PurcInquiryMould', 'ngTableParams', 'toaster', 'BaseService', '$upload', function($scope, $filter, PurcInquiryMould, ngTableParams, toaster, BaseService, $upload){
- $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){
- $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){
- var staticItem = null;
-
- if( ! angular.isUndefined($stateParams.id)) {// 查看模式
- $scope.loading = true;
- Quotation.getItem({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.item = data;
- staticItem = angular.copy(data);
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- } else {// 新增模式
- $scope.item = {
- quotation: {
- currency: 'RMB',
- taxrate: 17,
- date: new Date()
- },
- product: {},
- prices: [{lapQty: 0}],
- minOrderQty: 1,
- minPackQty: 1,
- $endDateOpen: false,
- $editing: true
- };
- }
-
- $scope.getMinDate = function(item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
-
- $scope.openDatePicker = function($event, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.item.$endDateOpen = !openParam;
- };
-
- // 增加一个分段
- $scope.addPrice = function(){
- if($scope.item.prices.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- $scope.item.prices.push({});
- };
-
- // 删除一个分段
- $scope.removePrice = function(index) {
- $scope.item.prices.splice(index, 1);
- };
-
- // 查找客户
- $scope.dbfindCust = function(){
- if($scope.item.$editing) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/quotation_new_cust.html',
- controller: 'DbfindCustCtrl',
- size: 'lg',
- resolve: {
-
- }
- });
-
- modalInstance.result.then(function(data){
- $scope.item.quotation.cust = data.myEnterprise;
- $scope.item.quotation.custUser = data.myUser;
- $scope.item.product = null;
- }, function(){
-
- });
- }
- };
-
- // 查找客户物料
- $scope.dbfindCustProd = function(){
- if($scope.item.$editing) {
- if($scope.item.quotation.cust.uu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/quotation_new_custProd.html',
- controller: 'DbfindCustProdCtrl',
- size: 'lg',
- resolve: {
- custUU: function(){return $scope.item.quotation.cust.uu}
- }
- });
-
- modalInstance.result.then(function(data){
- $scope.item.product = data;
- }, function(){
-
- });
- } else {
- toaster.pop('error', '错误', '请先选择客户');
- }
- }
- };
-
- // 保存
- $scope.save = function(){
- $scope.loading = true;
- if(!$scope.item.quotation.code) //新增,设单号
- $scope.item.quotation.code = 'BJ' + $filter('date')(new Date(), 'yyMMddHHmmss_sss');
- $scope.item.quotation.custUU = $scope.item.quotation.cust.uu;
- $scope.item.quotation.custUserUU = $scope.item.quotation.custUser.userUU;
- $scope.item.productId = $scope.item.product.id;
- $scope.item.quotation.status = 100;//在录入
- if($scope.item.quotation.date instanceof Date) {
- $scope.item.quotation.date = $scope.item.quotation.date.getTime();
- }
- if($scope.item.quotation.endDate instanceof Date) {
- $scope.item.quotation.endDate = $scope.item.quotation.endDate.getTime();
- }
- Quotation.save({}, $scope.item, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- if($stateParams.id)
- window.location.reload();
- else
- window.location.hash = '#/sale/quotation/' + data.id;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
-
- // 更新
- $scope.update = function(){
- $scope.item.$editing = true;
- };
-
- // 取消
- $scope.cancel = function(){
- $scope.item.$editing = false;
- $scope.item = angular.copy(staticItem);
- };
-
- // 提交
- $scope.submit = function(){
- $scope.loading = true;
- $scope.item.quotation.status = 101;//在录入
- Quotation.save({}, $scope.item, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '提交成功');
- window.location.hash = '#/sale/quotation/' + data.id;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- }]);
-
- // 查找客户
- app.controller('DbfindCustCtrl', ['$scope', 'Customer', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function($scope, Customer, BaseService, ngTableParams, toaster, $modalInstance){
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- Customer.get(BaseService.parseParams(params.url()), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElements;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- $scope.check = function(cust){
- $modalInstance.close(cust);
- };
- }]);
-
- // 查找客户物料
- app.controller('DbfindCustProdCtrl', ['$scope', 'Product', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'custUU', function($scope, Product, BaseService, ngTableParams, toaster, $modalInstance, custUU){
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.custUU = custUU;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- // 选择
- $scope.check = function(cust){
- $modalInstance.close(cust);
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 查找供应商
- app.controller('DbfindVendorCtrl', ['$scope', 'Vendor', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance','$rootScope', function($scope, Vendor, BaseService, ngTableParams, toaster, $modalInstance, $rootScope){
- console.log($rootScope);
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 25
- }, {
- total : 0,
- counts: [10, 25, 50, 100],
- getData : function($defer, params) {
- $scope.loading = true;
- Vendor.getVendor(BaseService.parseParams(params.url()), 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.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){
- $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){
- $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){
- $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){
- $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){
- $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){
- $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) {
- console.log(pageParams.searchFilter);
- 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){
- $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){
- $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){
- $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){
- $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){
- $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){
- $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', function($scope, $stateParams, FaArCheck, toaster, $state){
- var loadData = function() {
- FaArCheck.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- $scope.loading = false;
- });
- };
- loadData(); // 初始获取单据数据
-
- $scope.onReplyClick = function(item, isAgreed) {
- if(isAgreed) {// 同意确认
- FaArCheck.agree({itemId: item.id}, {}, function(data){
- toaster.pop('success', '确认成功', '确认供应商对账数量成功');
- }, function(response){
- toaster.pop('danger', '确认失败', response.data);
- });
- } else {// 不同意回复
- FaArCheck.disagree({itemId: item.id}, {qty: item.$replyQty, remark: item.$replyRemark}, function(data) {
- toaster.pop('success', '确认成功', '您提交的数量将发送给供应商确认');
- }, function(response) {
- toaster.pop('danger', '确认失败', response.data);
- });
- }
- };
-
- // 获取明细的回复记录
- $scope.getReplies = function(item) {
- if(!item.replies) {
- FaArCheck.getReplies({itemId: item.id}, function(data) {
- item.replies = data;
- }, function(response) {
- toaster.pop('danger', '获取对账记录失败', response.data);
- });
- }
- };
-
- }]);
- //应收对账单列表
- app.controller('PurchaseApCheckCtrl',['$scope', 'FaApCheck', 'BaseService', 'ngTableParams', 'toaster','ReportService', 'Symbol', function($scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService , Symbol){
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'todo';
-
- //打印 对账单
- $scope.print = function(check) {
- 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',function($scope,toaster,FaApCheck,$stateParams){
- $scope.haveSelected = true;
- $scope.data = {};
- //控制提交和删除按钮的显示
- $scope.ifShow = true;
- var loadData = function(){
- FaApCheck.get({id:$stateParams.id},function(data){
- $scope.data = data;
- if($scope.data.status){
-
- }else{
- $scope.ifShow = true;
- }
- })
- };
-
- if($stateParams.id){
- loadData();
- }
-
-
- $scope.haveSource = false;
- //提交应收对账单
- $scope.submitApCheck = function(){
- FaApCheck.updateStatus({id:$stateParams.id},function(data){
- if(data.result) {
- toaster.pop('success', '提示', '提交成功');
- $scope.haveSelected = false;
- window.location.href = '#/fa/apCheck';
- }else {
- $scope.haveSource = true;
- loadData();
- toaster.pop('error', '提示', '单据被反过账,请立即作废本单据');
- $scope.haveSelected = true;
- }
- },function(){
- $scope.loading = false;
- toaster.pop('error', '提示', '更新已转数失败');
- });
- }
-
- //删除应收对账单的同时更新来源表已转数
- var updateYCheckQty = function(){
- var sourceInfos = [];
- angular.forEach($scope.data.items, function(item){
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newYCheckQty: ''
- };
- $scope.sourceInfo.sourceId = item.sourceId;
- $scope.sourceInfo.sourceTable = item.sourceTable;
- $scope.sourceInfo.newYCheckQty = item.oldYCheckQty;
- sourceInfos.push($scope.sourceInfo);
- });
- FaApCheck.update({}, sourceInfos, function(){
-
- },function(response){
- $scope.loading = false;
- toaster.pop('error', '更新已转数失败', response.data);
- });
-
- }
- //删除应收对账单
- $scope.deleteApCheck = function(){
- FaApCheck.deleteApCheck({id:$stateParams.id},function(data){
- updateYCheckQty();
- toaster.pop('success','提示','删除成功');
- },function(){
- toaster.pop('error','提示','删除失败');
- });
- $scope.haveSelected = false;
- }
- //作废应收对账单
- $scope.cancelApCheck = function(check) {
- FaApCheck.cancel({id:check.id},function(data){
- $scope.checkResult = false;
- if(data.result) {
- $scope.checkResult = true;
- toaster.pop('success', '提示', '作废成功');
- $scope.tableParams.reload();
- }else{
- toaster.pop('error', '提示', '作废失败');
- }
- },function(){
- $scope.loading = false;
- toaster.pop('error', '提示', '作废失败');
- });
-
- }
-
- }]);
-
- //未对账单据列表
- app.controller('PurchaseApCheckListCtrl',['$scope', 'FaApCheck', 'toaster', '$state','$filter', '$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', function($scope, AccountEnterprise, toaster, $state, $modal){
- $scope.loading = true;
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.enterprise = data;
- });
- AccountEnterprise.growth({}, function(data){
- if(data != null && data.length > 0) {
- var growth = [], years = [];
- angular.forEach(data, function(d){
- var date = new Date(d.date), year = date.getFullYear();
- d.date = (date.getMonth() + 1) + '月' + (date.getDate()) + '日';
- if(years.indexOf(year) == -1) {
- years.push(year);
- growth.push({year: year});
- }
- growth.push(d);
- });
- $scope.growth = growth;
- }
- });
-
- // 更新企业信息
- $scope.updateDetailInfo = function(){
- $scope.loading = true;
- AccountEnterprise.save($scope.enterprise, function(){
- $scope.loading = false;
- $scope.connectionEditing = false;
- toaster.pop('success', '提示', '修改企业信息成功');
- $state.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '修改信息失败', response.data);
- });
- };
-
- // 申请Saas
- $scope.applySaas = function(){
- if($scope.enterprise.enUrl && $scope.enterprise.enAddress && $scope.enterprise.enIndustry) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/applySaas.html',
- controller: 'ApplySaasCtrl',
- resolve: {
- enterprise: function(){return angular.copy($scope.enterprise);}
- }
- });
-
- modalInstance.result.then(function(){
- $state.reload();
- }, function(){
- });
- } else {
- toaster.pop('info', '请完善信息', '申请优企云服请先完善企业详细信息');
- }
- };
- }]);
-
- // 申请Saas 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){
- $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/account/user_role.html',
- controller: 'UserRoleCtrl',
- resolve: {
- user: function() {
- return user;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- };
- // 为用户分配角色(删除企业)
- $scope.removeVendor = function(user) {
- var resultRole = true;
- angular.forEach(user.roles,function(role){
- if(role.issys == 1) {
- toaster.pop('error', '提示', '管理员无需分配客户');
- resultRole = false;
- return;
- }
- })
- if(resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/remove_vendor.html',
- controller: 'RemoveVendorCtrl',
- resolve: {
- user: function() {
- return user;
- }
- }
- });
- }
- }
- // 为用户分配角色(添加企业)
- $scope.addVendor = function(user,isIssy) {
- if(!isIssy) {
- toaster.pop('error', '提示', '你不是管理员,无权限分配!请立即联系管理员');
- return;
- }
- var resultRole = true;
- angular.forEach(user.roles,function(role){
- if(role.issys == 1) {
- toaster.pop('error', '提示', '管理员无需分配客户');
- resultRole = false;
- return;
- }
- })
- if(resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_vendor.html',
- controller: 'AddVendorCtrl',
- resolve: {
- user: function() {
- return user;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- }
- };
- }]);
-
- // 登录手机号码验证
- app.controller('CheckTelCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'AuthenticationService', 'SendCheckMsg', 'SessionService', '$timeout', function($scope, $modalInstance, user, AccountUser, AuthenticationService, SendCheckMsg, SessionService, $timeout){
- $scope.user = user;
- $scope.cancel = function(){
- $modalInstance.close();
- }
- /*$scope.loading = false;
- $scope.btnState = false;
- $scope.clicks = 0;
- var storage = window.localStorage;
- //手机验证码定时器
- $scope.msgInfoError = false;
- var setBtnTimeDown = function(value) {
- if(value > 0) {
- $scope.btnState = true;
- $timeout(function() {
- $scope.$apply(function(){
- storage.setItem("btnTimes", $scope.btnTimes);
- $scope.btnTimes --;
- value --;
- setBtnTimeDown (value);
- });
- }, 500);
- }else{
- $scope.btnState = false;
- }
- };
- if(storage.btnTimes > 1){
- $scope.btnTimes = storage.btnTimes;
- setBtnTimeDown(storage.btnTimes)
- }else{
- storage.removeItem("btnTimes");
- }
- $scope.updateTel = function(phoneCode, userTel, uu){
- $scope.loading = true;
- $scope.msgInfoError = false;
- $scope.result = false;
- //更新联系方式
- AccountUser.updateWithCode({code: phoneCode, tel : userTel, uu: uu},{}, function(data){
- $scope.loading = false;
- $scope.msgInfoError2 = false;
- $scope.result = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $timeout(function(){
- $modalInstance.dismiss();
- window.location.reload();
- }, 1000);
- }).error(function(response) {
-
- });
- }, function(response){
- $scope.loading = false;
- $scope.msgInfoError2 = response;
- });
- };
- //获取验证码
- $scope.getPhoneCode = function(userTel){
- var timeInfo = 10;
- $scope.clicks ++;
- $scope.timeInfo = timeInfo;
- if($scope.clicks >= 5){
- $scope.errorloading = true;
- $scope.msgInfoSuccess = false;
- $scope.msgInfoError = false;
- }else{
- $scope.loading = true;
- SendCheckMsg.sendMsgInfos({userTel: userTel},function(data){
- $scope.loading = false;
- $scope.msgInfoSuccess = data.success;
- $scope.sendMsg = data;
- $scope.btnTimes = 60;
- setBtnTimeDown($scope.btnTimes);
- $scope.msgInfoError = false;
- },function(response){
- console.log(response);
- $scope.loading = false;
- $scope.msgInfoError = false;
- $scope.sendCheckMsg = false;
- $scope.msgInfoSuccess = true;
- });
- }
- }; */
- }]);
- app.controller('RemoveVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
- $scope.checkboxes = {
- checked : false
- };
- $scope.loading = true;
- AccountUser.findChooseVendor({uu : user.userUU},function(data) {
- $scope.enters = data;
- $scope.loading = false;
- angular.forEach($scope.enters, function(item) {
- item:{
- $selected:true;
- }
- });
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function() {
- angular.forEach($scope.enters, function(item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function(vendor){
- var result = true;
- angular.forEach($scope.enters, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function(save) {
- var chooseResult = [];
- if(save) {
- if(user.userUU) {
- angular.forEach($scope.enters, function(item, i) {
- if(item.$selected) {
- chooseResult.push(item.id);
- }
- });
- if(chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.removeChooseVendor({uu : user.userUU }, chooseResult,function(data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '删除成功');
- $modalInstance.close(false);
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '删除失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '删除失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
-
- app.controller('AddVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
- $scope.checkboxes = {
- checked : false
- };
- $scope.loading = true;
- AccountUser.findVendor({uu : user.userUU},function(data) {
- $scope.enters = data;
- $scope.loading = false;
- // angular.forEach($scope.enters, function(item) {
- // if(item.distribute) {
- // item:{
- // $selected:false;
- // }
- // } else {
- // item:{
- // $selected:true;
- // }
- // }
- // });
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function() {
- angular.forEach($scope.enters, function(item) {
- item.distribute = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function(vendor){
- var result = true;
- angular.forEach($scope.enters, function(item) {
- if(item.distribute != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function(save) {
- var chooseResult = [];
- if(save) {
- if(user.userUU) {
- angular.forEach($scope.enters, function(item, i) {
- // if(item.distribute) {
- chooseResult.push(item);
- // }
- });
- if(chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.addVendor({uu : user.userUU }, chooseResult,function(data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
-
- app.controller('UserRoleCtrl', ['$scope', '$modalInstance', 'user', 'AccountRole', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountRole, AccountUser, toaster){
- $scope.checked = [];
- $scope.master = [];
- AccountRole.query({}, function(data){
- if(user && data) {
- var rs = [], checked = [];
- angular.forEach(user.roles, function(r){
- rs.push(r.id);
- });
- angular.forEach(data, function(d){
- if(rs.indexOf(d.id) > -1) {
- d.$checked = true;
- checked.push(d);
- }
- });
- }
- $scope.roles = data;
- $scope.checked = checked;
- $scope.master = angular.copy($scope.checked);
- });
- $scope.select = function(role) {
- role.$checked = !role.$checked;
- if(role.$checked) {
- $scope.checked.push(role);
- } else {
- angular.forEach($scope.checked, function(c, i){
- if(c.id == role.id)
- $scope.checked.splice(i, 1);
- });
- }
- };
- $scope.isChanged = function() {
- return !angular.equals($scope.master, $scope.checked);
- };
- $scope.close = function(save) {
- if(save) {
- if(user.userUU) {
- user.roles = $scope.checked;
- AccountUser.update({}, user, function(){
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(true);
- }, function(response){
- toaster.pop('error', '保存失败', response.data);
- });
- } else {
- $modalInstance.close(true, $scope.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
-
- // 修改密码Controller
- app.controller('PasswordCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
- $scope.user = user;
- $scope.checking = false;
- //输入原密码后验证原密码是否正确
- $scope.checkPassword = function(password) {
- $scope.checking = true;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- AccountUser.checkPassword({password: password}, function(data){
- $scope.checkSuccess = true;
- $scope.checking = false;
- $scope.checkFailed = false;
- }, function(response){
- $scope.checkFailed = true;
- $scope.checking = false;
- $scope.checkSuccess = false;
- });
- };
-
- //修改密码
- $scope.ok = function () {
- if($scope.user.newPassword == $scope.user.newPassword1) {//验证重复密码相等
- AccountUser.updatePassword({password: $scope.user.password, newPassword: $scope.user.newPassword}, {}, function(data){
- toaster.pop('success', '成功', '修改密码成功,请牢记您的新密码。');
- $scope.user.password = null;
- $scope.user.newPassword = null;
- $scope.user.newPassword1 = null;
- $scope.checking = false;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- } else {
- toaster.pop('error', '错误', '重复密码不一致');
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
-
- /*
- * 绑定用户到企业
- */
- app.controller('AddExistUserCtrl', ['$scope', '$modalInstance', 'FuzzySearch', 'AuthenticationService', '$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/account/role_detail.html',
- controller: 'RoleEditCtrl',
- resolve: {
- role: function() {
- return role;
- }
- }
- });
- modalInstance.result.then(function(added){
- added && (getData());
- });
- };
- }]);
-
- app.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'ngAlert', function($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, ngAlert){
- $scope.role = role;
- $scope.master = angular.copy($scope.role);
- var isNew = role == null;
- $scope.cancel = function() {
- $modalInstance.close(false);
- };
- AccountResource.query({}, function(data){
- if(data && data.length > 0) {
- if(role && role.resourceItems) {
- var rs = [];// 已分配的资源的id
- angular.forEach(role.resourceItems, function(item){
- rs.push(item.id);
- });
- angular.forEach(data, function(resource){
- var c = 0;
- angular.forEach(resource.items, function(item){
- if(rs.indexOf(item.id) > -1) {
- item.$checked = true;
- c += 1;
- }
- });
- resource.$checked = c == resource.items.length;
- });
- }
- $scope.resourceItems = data[0].items;
- data[0].$active = true;
- }
- $scope.resources = data;
- $timeout(function(){
- angular.forEach($scope.resources, function(resource){
- var c = 0;
- angular.forEach(resource.items, function(item){
- item.$checked && (c+=1);
- });
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- });
- }, 100);
- });
- $scope.onItemClick = function(resource) {
- $scope.resourceItems = resource.items;
- angular.forEach($scope.resources, function(r){
- r.$active = false;
- });
- resource.$active = true;
- };
- var getChecked = function() {
- var items = [];
- angular.forEach($scope.resources, function(resource){
- angular.forEach(resource.items, function(item){
- item.$checked && (items.push(item));
- });
- });
- $scope.role.resourceItems = items;
- };
- $scope.onResourceChange = function(resource) {
- angular.forEach(resource.items, function(item){
- item.$checked = resource.$checked;
- });
- getChecked();
- };
- $scope.onItemChange = function() {
- angular.forEach($scope.resources, function(resource){
- if(resource.$active) {
- var c = 0;
- angular.forEach(resource.items, function(item){
- item.$checked && (c+=1);
- });
- resource.$checked = (c == resource.items.length);
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- }
- });
- getChecked();
- };
- $scope.isChanged = function(formData) {
- if(!$scope.master)
- return true;
- return !angular.equals(formData, $scope.master);
- };
- $scope.save = function() {
- $scope.master = angular.copy($scope.role);
- AccountRole.save($scope.master, function(){
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 资料' + (isNew ? '添加': '修改') + '成功');
- $modalInstance.close(true);
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- };
- $scope.del = function() {
- new ngAlert({
- title: '提示',
- content: '确定删除角色(' + $scope.role.desc + ')吗?'
- }, function(){
- AccountRole.remove({id: role.id}, function(){
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
- $modalInstance.close(true);
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- })
- };
- }]);
-
- /**
- * 委外订单
- */
- app.controller('MakeOrderCtrl', ['$scope', '$filter', 'MakeOrder', 'ngTableParams', 'toaster','ReportService', 'BaseService',
- function($scope, $filter, MakeOrder, ngTableParams, toaster,ReportService, BaseService){
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return MakeOrder;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 5,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.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', function($scope, $stateParams, MakeOrder, toaster, ReportService){
- var loadData = function() {
- MakeOrder.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- });
- };
- loadData();
- // 获取回复记录
- $scope.getReply = function(item) {
- if(!item.replies) {
- MakeOrder.getReply({orderId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 点击回复
- $scope.onReplyClick = function(order, inverse) {
- if(order.reply) {
- if(!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOrder.reply({orderId: order.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 打开回复
- $scope.openReply = function(order) {
- if(!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
-
- // 关闭回复
- $scope.closeReply = function(order) {
- order.$editing = false;
- }
-
- // 委外订单
- $scope.print = function(order) {
- MakeOrder.printCount({id: order.id},{});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', '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){
- $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){
- $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){
- $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', function($scope, $stateParams, MakeChange, toaster){
- var loadData = function() {
- MakeChange.get({id: $stateParams.id}, function(data){
- $scope.change = data;
- });
- };
- loadData();
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.onReplyClick = function(change) {
- if(change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- MakeChange.reply({itemId: change.id}, reply, function(){
- toaster.pop('info', '提示', '回复成功');
- loadData();
- }, function(response){
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- }]);
-
- /**
- * 委外加工
- */
- app.controller('MakeOutOrderCtrl', ['$scope', '$filter', 'MakeOutOrder', 'ngTableParams', 'toaster','ReportService', 'BaseService',
- function($scope, $filter, MakeOutOrder, ngTableParams, toaster,ReportService, BaseService) {
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return 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', function($scope, $stateParams, MakeOutOrder, toaster, ReportService) {
- 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) {
- $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;
- console.log(pageParams.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) {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function() {
- window.location.reload();
- }, 500);
- }), function(response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
-
- }]);
-
- /**
- * 物料批量上传
- */
- app.controller('UploadByBatchCtrl', ['$scope', '$upload', 'toaster', function($scope, $upload, toaster) {
-
- // 通过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;
- }).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', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster) {
- var loadData = function() {
- GetProductInfo.getOne({id: $stateParams.id}, function(data) {
- if(data.attach) {
- GetProductInfo.getAttach({id: data.attach.id}, function(data) {
- console.log(data.url);
- // 查看范例
- $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() {
- $scope.prodInfo.$editing = false;
- };
-
- $scope.submit = function(prodInfo) {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- console.log(file);
- $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', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout) {
- $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;
- }, 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="#/baseInfo/prodList/"+data.id;
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function() {
- //提交后跳转到详情页面,防止重复提交
- window.location.href="#/baseInfo/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) {
- $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 = $rootScope.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', function($scope, $modal, toaster, $filter, addtoCart, $rootScope, VendorInfo, ngTableParams, BaseService, Product, newPurcOrder) {
- $scope.order = {
- date : new Date(),
- cust : {
- uu : '',
- },
- custUser : {
-
- },
- code : $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- orderItems : {
- product : {},
- $endDateOpen: false
- },
- };
-
- if($rootScope.businessCode) {
- VendorInfo.getVendorInfo({businessCode: $rootScope.businessCode}, {}, function(data) {
- $scope.order.cust.enName = data.vendorEnterprise.enName;
- $scope.order.cust.enAddress = data.vendorEnterprise.enAddress;
- $scope.order.cust.uu = data.vendorEnterprise.uu;
- $scope.order.custUser.userName = data.vendorUser.userName;
- $scope.order.custUser.userTel = data.vendorUser.userTel;
- }, function(response) {
-
- });
- };
-
- // 查找客户
- $scope.dbfindCust = function(){
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_cust.html',
- controller: 'DbfindCustCtrl',
- size: 'lg',
- resolve: {
-
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.order.cust = data.myEnterprise;
- $scope.order.custUser = data.myUser;
- $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);
-
- }, function(){
-
- });
- };
-
- //商品信息
- $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);
- 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;
- $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});
- }
- };
- //删除商品
- $scope.deleteProduct = function(index) {
- $scope.order.orderItems.splice(index, 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;
- $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(data);
- for(var i = 0; i < $scope.order.orderItems.length; i++) {
- if($scope.order.orderItems[i].code == null) {
- $scope.order.orderItems.splice(i, 1);
- }
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $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.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();
- }
- }
- addtoCart.save({}, $scope.order, function(data){
- console.log($scope.order);
- $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.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();
- }
- }
- 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);
- });
- };
- }]);
-
- /**
- * 我的客户
- */
- 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('MySupplierCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- var getCustInfos = function(custuu) {
- if(custuu) {
- VendorService.userInfo.query({uu:custuu},null,function(data) {
- $scope.custInfos = data;
- var getPage = function(page, size){
- if($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1)*size, page * size);
- if($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- }else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1,4);
- $scope.first = function (){
- $scope.userdata = getPage($scope.userdata.pre,4);
- }
- $scope.last = function (){
- $scope.userdata = getPage($scope.userdata.next,4);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }
- $scope.addUserInfo = function(customer) {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function() {
- return customer;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
-
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
- $scope.showUserInfo = function(customer,boo) {
- $scope.custInfo = customer;
- if(boo) {
- getCustInfos(customer.myEnterprise.uu);
- $scope.userInfoResult = true;
- }
- }
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 10
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- VendorService.customer.get(BaseService.parseParams(params.url()), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElements;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
-
- /**
- * 建立合作关系申请
- */
- app.controller('AddPartnerRequestCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', function($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout) {
-
- $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;
- 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) {
- $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', function($scope, toaster, GetProductInfo) {
- // 默认显示合作伙伴
- $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) {
- $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: {
- }
- }, {
- 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/cartdetail/'+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', function($scope, cartOperation, $stateParams, toaster, $timeout) {
- 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);
- });
- };
- }]);
-
- /**
- * 审批流
- */
- app.controller('approvalFlowCtrl', ['$scope', 'toaster', '$modal', 'appFlow', function($scope, toaster, $modal, appFlow) {
- appFlow.viewAppFlow({}, function(data) {// 获取已设置的列表
- $scope.nodes = data;
- }, 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(){
-
- });
- }
- }]);
-
- app.controller('NoteStep1Ctrl', ['$scope', 'toaster', '$modalInstance', 'appFlow', 'AppName', '$filter', function($scope, toaster, $modalInstance, appFlow, AppName, $filter) {
- $scope.appName = AppName;// 标题名称
- appFlow.getNodeByName({name: AppName}, {}, function(data) {// 通过单据名称查询单个审批流
- if(data.appname) {
- $scope.node = data;
- }
- }, 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){
- // angular.forEach($scope.AppFlow.AppNodes, function(node) {
- // if(node) {
- // if(node.useruu == 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', function($scope, toaster, getDeOrder, ngTableParams, BaseService) {
- $scope.active = 'all';
- $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);
- }
- };
- $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);
- $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();
- };
- }]);
-
- /**
- * 新增代采订单
- */
- app.controller('NewDeputyOrderCtrl', ['$scope', 'toaster', '$modal', 'DeputyOrder', '$filter', function($scope, toaster, $modal, DeputyOrder, $filter) {
- $scope.deOrder = {
- code: 'DC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- entrydate: new Date(),
- status: '在录入',
- $dateOpen: false,
- };
- $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) {
- $scope.deOrder.deputyOrderItems = data;
- $scope.deOrder.totalamount = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- console.log($scope.deOrder.totalamount);
- });
- }, function(){
-
- });
- }
-
- $scope.save = function() {
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', '保存成功');
- }
- 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('PurcTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- $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', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload) {
- // if( ! angular.isUndefined($stateParams.id) && $stateParams.id != "") {
- // $scope.loading = true;
- // PurcTender.getOne({id: $stateParams.id}, function(data){
- // data.$editing = false;
- // $scope.tenderItem.tender = data;
- // staticItem = angular.copy(data);
- // $scope.loading = false;
- // }, function(response){
- // $scope.loading = false;
- // toaster.pop('error', '数据加载失败', response.data);
- // });
- // } else {//
- $scope.loading = false;
- $scope.condition = {dateZone: 1};
- $scope.tenderItem = {
- $editing: true,
- tender: {
- date: new Date(),
- unit: 'PCS',
- currency: 'RMB',
- ifOpen: 1,
- ifTax: 1,
- invoiceType: 2,
- tenderAttachs:[{}]
- }
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- };
- // 删除一个供应商
- $scope.removeVendor = function(index) {
- $scope.tenderItem.enterpriseBaseInfo.splice(index, 1);
- };
- // 可选的证照要求
- $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});
- }
- });
- }
- }
- // 查找客户
- $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.tenderItem.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderItem.enterpriseBaseInfo = [{}];
- $scope.tenderItem.enterpriseBaseInfo.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0;i<$scope.tenderItem.enterpriseBaseInfo.length; i++) {
- ifPush = true;
- if ($scope.tenderItem.enterpriseBaseInfo[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.tenderItem.enterpriseBaseInfo.push(vendor.vendorEnterprise);
- }
- }
- });
- $rootScope.tenderVendor = $scope.tenderItem.enterpriseBaseInfo;
- }, 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', '错误', '请先选择客户');
- // }
- // }
- // };
- var sleep = function (d){
- for(var t = Date.now();Date.now() - t <= d;);
- }
- // 保存和发布招标单
- $scope.save = function(isPublish){
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function(certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tenderItem.tender.certificate = myCertificate.join(',');
- if(!$scope.tenderItem.tender.code) { //新增,设单号
- $scope.tenderItem.tender.code = 'ZB' + $filter('date')(new Date(), 'yyMMddHHmmss_sss');
- }
- if($scope.tenderItem.tender.date instanceof Date) {
- $scope.tenderItem.tender.date = $scope.tenderItem.tender.date.getTime();
- }
- if($scope.tenderItem.tender.endDate instanceof Date) {
- $scope.tenderItem.tender.endDate = $scope.tenderItem.tender.endDate.getTime();
- }
- if($scope.tenderItem.tender.publishDate instanceof Date) {
- $scope.tenderItem.tender.publishDate = $scope.tenderItem.tender.publishDate.getTime();
- }
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- PurcTender.publish({tender: $scope.tenderItem.tender, enterpriseBaseInfo: $scope.tenderItem.enterpriseBaseInfo}, {}, function(tender,enterprise){
- // angular.forEach(tender.tenderAttaches, function(tenderAttach) {
- var file = $scope.MyFiles, file = file && file.length>0 ? file[0]: null;
- $upload.upload({
- url: 'tender/addTenderAttach',
- file: file,
- method: 'POST',
- data: {
- tender: $scope.tenderItem.tender
- }
- // });
- });
- parseCertificate(tender.certificate);
- 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.tenderItem.tender, enterpriseBaseInfo: $scope.tenderItem.enterpriseBaseInfo}, {}, function(tender,enterprise) {
- var file = $scope.MyFiles, file = file && file.length>0 ? file[0]: null;
- $upload.upload({
- url: 'tender/addTenderAttach',
- file: file,
- method: 'POST',
- data: {
- tender: $scope.tenderItem.tender
- }
- });
- $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.getMinDate = function() {
- if (!$scope.tenderItem.tender) {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- }
- return $scope.tenderItem.tender.endDate ? $filter('date')($scope.tenderItem.tender.endDate, 'yyyy-MM-dd'):$filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- /**
- * 评标
- */
- app.controller('PurcEvaluationCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- $scope.tenderItems = [];
- // 采购方获取评标单
- var evaluation = function() {
- $scope.loading = true;
- PurcTender.getOne({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.tender = data;
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- evaluation();
- $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) {
- $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); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, 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) {
- $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);
- }
- };
- var getOpenState = function(active) {
- var fn = 'getOpenAll';
- switch(active) {
- // 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 : 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[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);
- });
- }
- });
- 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);
- });
- PurcTender.getOne({id: $stateParams.id}, function(data){
- $scope.bid = data; // 用于展示
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
- }]);
- /**
- * 投标
- */
- app.controller('SaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload) {
- 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;);
- }
- PurcTender.getOne({id: $stateParams.id}, function(data){
- $scope.bid = data; // 用于展示
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
- // 投标
- $scope.bidIt = function(tender,item){
- $scope.loading = true;
- if(item.enterpriseBaseInfo.enEstablishDate instanceof Date) {
- item.enterpriseBaseInfo.enEstablishDate = item.enterpriseBaseInfo.enEstablishDate.getTime();
- }
- PurcTender.reply({bid:tender, tenderItem:item}, {}, function(tender, tenderItem){
- var file = $scope.MyFiles, file = file && file.length>0 ? file[0]: null;
- $upload.upload({
- url: 'tender/addTenderItemAttach',
- file: file,
- method: 'POST',
- data: {
- tenderItem: $scope.item
- }
- });
- $scope.loading = false;
- toaster.pop('info', '成功', '投标成功');
- // $window.location.reload();
- 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;
- });
|