| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128 |
- define([ 'toaster', 'charts', 'ngTable', 'common/services', 'common/directives', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder', 'service/Product'], function() {
- 'use strict';
- var app = angular.module('myApp', [ 'toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'common.directives', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService', 'ProductInfoServices']);
- 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.deputylog', {
- url : "/deputylog",
- templateUrl : "static/tpl/index/purc/deputyorders_log.html",
- controller : 'DeputyOrderLogCtrl'
- }).state('purc.newdeputy', {
- url : "/deputy/add",
- templateUrl : "static/tpl/index/purc/deputyOrder_new.html",
- controller : 'NewDeputyOrderCtrl'
- }).state('purc.deputydetail', {
- url : "/deputy/:id",
- templateUrl : "static/tpl/index/purc/deputyOrder_detail.html",
- controller : 'DeputyOrderDetailCtrl'
- /* 招标列表 */
- }).state('purc.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/purc/tenderlist.html",
- controller : 'PurcTenderCtrl'
- }).state('purc.waiting.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/purc/tenderlist.html",
- controller : 'PurcTenderCtrl'
- }).state('purc.todo.tenderlist', {
- url : "/tender/todo",
- templateUrl : "static/tpl/index/purc/tenderlist.html",
- controller : 'PurcTenderCtrl'
- /* 招标 */
- }).state('purc.tender', {
- url : "/addTender",
- templateUrl : "static/tpl/index/purc/tender.html",
- controller : 'PurcNewTenderCtrl'
- }).state('purc.savedtender', {
- url : "/tender/:id",
- templateUrl : "static/tpl/index/purc/tender.html",
- controller : 'PurcNewTenderCtrl'
- /* 评标 */
- }).state('purc.evaluation', {
- url : "/evaluation/:id",
- templateUrl : "static/tpl/index/purc/tender_evaluation.html",
- controller : 'PurcEvaluationCtrl'
- /* 采购供应商资料 */
- }).state('purc.vendor', {
- url : "/vendor",
- templateUrl : "static/tpl/index/purc/vendor.html",
- controller : 'PurcVendorCtrl'
- /* 采购供应商资料 详情*/
- }).state('purc.vendordetail', {
- url : "/vendor/:id",
- templateUrl : "static/tpl/index/purc/vendor_detail.html",
- controller : 'PurcVendorDetailCtrl'
- /* 客户指定招标列表 */
- }).state('purc.makeoutorder', {
- url : "/makeoutorder",
- templateUrl : "static/tpl/index/make/outorder.html",
- controller: 'MakeOutOrderCtrl'
- }).state('purc.outorder_detail', {
- url : "/makeoutorder/:id",
- templateUrl : "static/tpl/index/make/outorder_detail.html",
- controller: 'MakeOutOrderDetailCtrl'
- /*平台新增询价单*/
- }).state('purc.inquiry_new', {
- url : "/purcinquiry",
- templateUrl : "static/tpl/index/purc/inquiry_new.html",
- controller: 'PurcInquiryCtrl'
- }).state('purc.purcinquiry_new', {
- url : "/purcinquiry/:bussinessCode",
- templateUrl : "static/tpl/index/purc/purcinquiry_new.html",
- controller: 'PurcInquiryNewCtrl'
- }).state('purc.inquiry', {
- url : "/purchaseinquiry",
- templateUrl : "static/tpl/index/purc/inquiry.html",
- controller: 'PurchaseInquiryCtrl'
- }).state('purc.inquiry_detail', {
- url : "/purcinquirydetail",
- templateUrl : "static/tpl/index/purc/inquiry_detail.html",
- controller: 'PurcInquiryDetailCtrl'
- }).state('purc.inquiryInfo_detail', {
- url : "/purcinquirydetail/:id",
- templateUrl : "static/tpl/index/purc/inquiryInfo_detail.html",
- controller: 'PurcInquiryInfoDetailCtrl'
- }).state('purc.inquiry_unapply', {
- url : "/inquiry_unapply",
- templateUrl : "static/tpl/index/purc/inquiry_unapply.html",
- controller: 'UnapplyInquiryCtrl'
- }).state('purc.product', {
- url : "/product",
- templateUrl : "static/tpl/index/purc/prodList.html",
- controller: 'PurcProductCtrl'
- }).state('purc.newProduct', {
- url : "/newProduct",
- templateUrl : "static/tpl/index/purc/newProdInfo.html",
- controller : 'PurcNewProdInfoCtrl'
- }).state('purc.productDetail', {
- url : "/prodList/:id",
- templateUrl : "static/tpl/index/purc/productDetail.html",
- controller : 'PurcProdDetailCtrl'
- }).state('purc.productmatches', {
- url : "/productmatches",
- templateUrl : "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesForPurcCtrl'
- }).state('purc.uploadProduct', {
- url : "/uploadProduct",
- templateUrl : "static/tpl/index/purc/uploadByBatch.html",
- controller: 'UploadProductCtrl'
- }).state('sale.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/sale/tenderlist.html",
- controller : 'SaleTenderCtrl'
- }).state('sale.todo.tenderlist', {
- url : "/tender",
- templateUrl : "static/tpl/index/sale/tenderlist.html",
- controller : 'SaleTenderCtrl'
- /* 平台公开招标列表 */
- }).state('baseInfo.openTenderList', {
- url : "/openTenderList",
- templateUrl : "static/tpl/index/sale/open_tender_list.html",
- controller: 'SaleOpenTenderCtrl'
- /* 查看公开招标详情 */
- }).state('baseInfo.open_tender_detail', {
- url : "/openTenderDetail/:id",
- templateUrl : "static/tpl/index/sale/open_tender_detail.html",
- controller : 'OpenSaleTenderDetailCtrl'
- /* 投标 */
- }).state('sale.tender', {
- url : "/tender/:id",
- templateUrl : "static/tpl/index/sale/tender.html",
- controller : 'SaleTenderDetailCtrl'
- /* 采购方查看供应商投标 */
- }).state('sale.vendortender', {
- url : "/tender/:vendUU/:id",
- templateUrl : "static/tpl/index/sale/vendor_tender.html",
- controller : 'SaleVendorTenderDetailCtrl'
- }).state('sale.todo', {
- url : "/todo",
- templateUrl : "static/tpl/index/sale/todo.html"
- }).state('sale.todo.inquiry', {
- url : "/inquiry",
- templateUrl : "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.todo.order', {
- url : "/order",
- templateUrl : "static/tpl/index/sale/order.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.todo.change', {
- url : "/change",
- templateUrl : "static/tpl/index/sale/change.html",
- controller: 'SaleChangeCtrl'
- }).state('sale.todo.notice', {
- url : "/notice",
- templateUrl : "static/tpl/index/sale/notice.html",
- controller: 'SaleNoticeCtrl'
- }).state('sale.customer', {
- url : "/customer",
- templateUrl : "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.customer_detail', {
- url : "/customer/:id",
- templateUrl : "static/tpl/index/sale/customer_detail.html",
- controller: 'CustomerDetailCtrl'
- }).state('sale.customerProduct', {
- url : "/customerProduct",
- templateUrl : "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.inquiry', {
- url : "/inquiry",
- templateUrl : "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.inquirymould', {
- url : "/mould",
- templateUrl : "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.todo.inquirymould', {
- url : "/mould",
- templateUrl : "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.inquiry_mould_detail', {
- url : "/mould/:id",
- templateUrl : "static/tpl/index/sale/inquiry_mould_detail.html",
- controller: 'SaleInquiryMouldDetailCtrl'
- }).state('sale.inquiry_detail', {
- url : "/inquiry/:id",
- templateUrl : "static/tpl/index/sale/inquiry_detail.html",
- controller: 'SaleInquiryDetailCtrl'
- }).state('sale.quotation', {
- url : "/quotation",
- templateUrl : "static/tpl/index/sale/quotation.html"
- }).state('sale.quotation.new', {
- url : "/new",
- templateUrl : "static/tpl/index/sale/quotation_new.html",
- controller: 'SaleQuotationNewCtrl'
- }).state('sale.quotation.list', {
- url : "/list",
- templateUrl : "static/tpl/index/sale/quotation_list.html",
- controller: 'SaleQuotationListCtrl'
- }).state('sale.quotation.item', {
- url : "/:id",
- templateUrl : "static/tpl/index/sale/quotation_new.html",
- controller: 'SaleQuotationNewCtrl'
- }).state('sale.order', {
- url : "/order",
- templateUrl : "static/tpl/index/sale/order.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.order_detail', {
- url : "/order/:id",
- templateUrl : "static/tpl/index/sale/order_detail.html",
- controller: 'SaleOrderDetailCtrl'
- }).state('sale.change', {
- url : "/change",
- templateUrl : "static/tpl/index/sale/change.html",
- controller: 'SaleChangeCtrl'
- }).state('sale.change_detail', {
- url : "/change/:id",
- templateUrl : "static/tpl/index/sale/change_detail.html",
- controller: 'SaleChangeDetailCtrl'
- }).state('sale.notice', {
- url : "/notice",
- templateUrl : "static/tpl/index/sale/notice.html",
- controller: 'SaleNoticeCtrl'
- }).state('sale.send', {
- url : "/send",
- templateUrl : "static/tpl/index/sale/send.html",
- controller: 'SaleSendCtrl'
- }).state('sale.send_detail', {
- url : "/send/:id",
- templateUrl : "static/tpl/index/sale/send_detail.html",
- controller: 'SaleSendDetailCtrl'
- }).state('sale.forecast', {
- url : "/forecast",
- templateUrl : "static/tpl/index/sale/forecast.html",
- controller: 'SaleForecastCtrl'
- }).state('sale.accept', {
- url : "/accept",
- templateUrl : "static/tpl/index/sale/accept.html",
- controller: 'SaleAcceptCtrl'
- }).state('sale.accept_detail', {
- url : "/accept/:id",
- templateUrl : "static/tpl/index/sale/accept_detail.html",
- controller: 'SaleAcceptDetailCtrl'
- }).state('sale.returns', {
- url : "/returns",
- templateUrl : "static/tpl/index/sale/returns.html",
- controller: 'SaleReturnsCtrl'
- }).state('sale.return_detail', {
- url : "/return/:id",
- templateUrl : "static/tpl/index/sale/return_detail.html",
- controller: 'SaleReturnsDetailCtrl'
- }).state('sale.sample', {
- url : "/sample",
- templateUrl : "static/tpl/index/sale/sample.html",
- controller: 'SaleSampleCtrl'
- }).state('sale.sample_detail', {
- url : "/sample/:id",
- templateUrl : "static/tpl/index/sale/sample_detail.html",
- controller: 'SaleSampleDetailCtrl'
- }).state('sale.approval', {
- url : "/approval",
- templateUrl : "static/tpl/index/sale/approval.html",
- controller: 'SaleApprovalCtrl'
- }).state('sale.prodList', {
- url : "/prodList",
- templateUrl : "static/tpl/index/baseInfo/prodList.html",
- controller : 'ProductListCtrl'
- }).state('sale.newProdInfo', {
- url : "/newProdInfo",
- templateUrl : "static/tpl/index/baseInfo/newProdInfo.html",
- controller : 'NewProdInfoCtrl'
- }).state('sale.uploadByBatch', {
- url : "/uploadByBatch",
- templateUrl : "static/tpl/index/baseInfo/uploadByBatch.html",
- controller : 'UploadByBatchCtrl'
- }).state('sale.productDetail', {
- url : "/prodList/:id",
- templateUrl : "static/tpl/index/baseInfo/productDetail.html",
- controller : 'ProductDetailCtrl'
- }).state('sale.productmatches', {
- url : "/productmatches",
- templateUrl : "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesForSaleCtrl'
- }).state('sale.maketodo', {
- url : "/maketodo",
- templateUrl : "static/tpl/index/make/todo.html"
- }).state('sale.maketodo.order', {
- url : "/makeorder",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder', {
- url : "/makeorder",
- templateUrl : "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder_detail', {
- url : "/makeorder/:id",
- templateUrl : "static/tpl/index/make/order_detail.html",
- controller: 'MakeOrderDetailCtrl'
- }).state('sale.badOut', {
- url : "/badOut",
- templateUrl : "static/tpl/index/qc/badOut.html",
- controller: 'SaleBadOutCtrl'
- }).state('sale.MRB', {
- url : "/MRB",
- templateUrl : "static/tpl/index/qc/MRB.html",
- controller: 'SaleMRBCtrl'
- }).state('sale.badIn', {
- url : "/badIn",
- templateUrl : "static/tpl/index/qc/badIn.html",
- controller: 'SaleBadInCtrl'
- }).state('sale.makeaccept', {
- url : "/makeaccept",
- templateUrl : "static/tpl/index/make/accept.html",
- controller: 'MakeAcceptCtrl'
- }).state('sale.makereturns', {
- url : "/makereturns",
- templateUrl : "static/tpl/index/make/returns.html",
- controller: 'MakeReturnCtrl'
- }).state('sale.makechange', {
- url : "/makechange",
- templateUrl : "static/tpl/index/make/change.html",
- controller: 'MakeChangeCtrl'
- }).state('sale.makechange_detail', {
- url : "/makechange/:id",
- templateUrl : "static/tpl/index/make/change_detail.html",
- controller: 'MakeChangeDetailCtrl'
- }).state('account', {
- url : "/account",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/account/left.html",
- controller: 'LeftCtrl'
- },
- "right-view" : {
- templateUrl : "static/tpl/index/account/right.html"
- }
- }
- }).state('account.index', {
- url : "",
- templateUrl : "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('account.home', {
- url : "/",
- templateUrl : "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('baseInfo', {//基础资料
- url : "/baseInfo",
- views : {
- "left-view" : {
- },
- "right-view" : {
- templateUrl : "static/tpl/index/baseInfo/right.html"
- }
- }
- }).state('baseInfo.index', {
- url : "/enterpriseList",
- templateUrl : "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.home', {
- url : "/enterpriseList",
- templateUrl : "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.enterpriseList', {
- url : "/enterpriseList",
- templateUrl : "static/tpl/index/baseInfo/enterpriseList.html",
- controller : 'EnterpriseListCtrl'
- }).state('baseInfo.myClient', {
- url : "/myClient",
- templateUrl : "static/tpl/index/baseInfo/myClient.html",
- controller : 'MyClientCtrl'
- }).state('baseInfo.mySupplier', {
- url : "/mySupplier",
- templateUrl : "static/tpl/index/baseInfo/mySupplier.html",
- controller : 'MySupplierCtrl'
- }).state('baseInfo.myRequest', {
- url : "/myRequest",
- templateUrl : "static/tpl/index/baseInfo/myRequest.html",
- controller : 'AddPartnerRequestCtrl'
- }).state('baseInfo.newPartner', {
- url : "/newPartner",
- templateUrl : "static/tpl/index/baseInfo/newPartner.html",
- controller : 'NewPartnerCtrl'
- }).state('baseInfo.myMessage', {
- url : "/myMessage",
- templateUrl : "static/tpl/index/baseInfo/myMessage.html",
- controller : 'AddPartnerMessageCtrl'
- }).state('baseInfo.myPartners', {
- url : '/myPartners',
- templateUrl : "static/tpl/index/baseInfo/myPartners.html",
- controller : 'MyPartnersCtrl'
- }).state('baseInfo.businessGroups', {
- url : '/businessGroups',
- controller : 'BusinessGroupsCtrl'
- }).state('baseInfo.inquiryList', {
- url : '/inquiryList',
- templateUrl : "static/tpl/index/baseInfo/inquiry_list.html",
- controller : 'PublicInquiryListCtrl'
- }).state('baseInfo.inquiryListDetail', {
- url : '/inquiryList/:id',
- templateUrl : "static/tpl/index/baseInfo/inquiryItem_detail.html",
- controller : 'PublicInquiryListDetailCtrl'
- }).state('baseInfo.vendorInfo', {
- url : '/enume/vendorInfo',
- templateUrl : "static/tpl/index/baseInfo/vendorsInfo.html",
- controller : 'VendorsInfoCtrl'
- }).state('baseInfo.customerInfo', {
- url : '/enume/customerInfo',
- templateUrl : "static/tpl/index/baseInfo/customersInfo.html",
- controller : 'CustomersInfoCtrl'
- }).state('baseInfo.enume', {
- url : '/enume',
- templateUrl : "static/tpl/index/baseInfo/vendorAndCustomer.html",
- }).state('baseInfo.partner', {
- url : '/partner',
- templateUrl : "static/tpl/index/baseInfo/addPartners.html",
- controller : 'AddPartnersCtrl'
- }).state('baseInfo.partner_searchresult', {
- url : '/search',
- templateUrl : "static/tpl/index/baseInfo/searchresult.html",
- controller : 'EnterpriseSearchCtrl'
- }).state('baseInfo.invitation', {
- url : '/invitation',
- templateUrl : "static/tpl/index/baseInfo/invitation.html",
- controller : 'InvitationCtrl'
- // }).state('baseInfo.invitationforEn', {
- // url : '/invitationforEn',
- // templateUrl : "static/tpl/index/baseInfo/invitation.html",
- // controller : 'InvitationByEnCtrl'
- }).state('qc', {
- url : "/qc",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/qc/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/qc/right.html"
- }
- }
- }).state('qc.index', {
- url : "",
- templateUrl : "static/tpl/index/qc/index.html"
- }).state('qc.home', {
- url : "/",
- templateUrl : "static/tpl/index/qc/index.html"
- }).state('fa', {
- url : "/fa",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/fa/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/fa/right.html"
- }
- }
- }).state('fa.index', {
- url : "",
- templateUrl : "static/tpl/index/fa/index.html"
- }).state('fa.home', {
- url : "/",
- templateUrl : "static/tpl/index/fa/index.html"
- }).state('fa.apBill', {
- url : "/apBill",
- templateUrl : "static/tpl/index/fa/apBill.html",
- controller: 'SaleApBillCtrl'
- }).state('fa.apBill_detail', {
- url : "/apBill/:id",
- templateUrl : "static/tpl/index/fa/apBill_detail.html",
- controller: 'SaleApBillDetailCtrl'
- }).state('fa.arCheck', {
- url : "/arCheck",
- templateUrl : "static/tpl/index/fa/arCheck.html",
- controller: 'SaleArCheckCtrl'
- }).state('fa.arCheck_detail', {
- url : "/arCheck/:id",
- templateUrl : "static/tpl/index/fa/arCheck_detail.html",
- controller: 'SaleArCheckDetailCtrl'
- }).state('fa.apCheck', {
- url : "/apCheck",
- params:{
- 'id':null
- },
- templateUrl : "static/tpl/index/fa/apCheck.html",
- controller: 'PurchaseApCheckCtrl'
- }).state('fa.apCheck_detail', {
- url : "/apCheck/:id",
- templateUrl : "static/tpl/index/fa/apCheck_detail.html",
- controller: 'PurchaseApCheckDetailCtrl'
- }).state('fa.apCheckList', {
- url : "/apCheckList",
- templateUrl : "static/tpl/index/fa/apCheckList.html",
- controller: 'PurchaseApCheckListCtrl'
- }).state('fa.adjustList', {
- url : "/adjustList",
- templateUrl : "static/tpl/index/fa/adjustList.html",
- controller: 'PurchaseAdjustListCtrl'
- }).state('make', {
- url : "/make",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/make/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/make/right.html"
- }
- }
- }).state('make.index', {
- url : "",
- templateUrl : "static/tpl/index/make/index.html"
- }).state('make.home', {
- url : "/",
- templateUrl : "static/tpl/index/make/index.html"
- }).state('cs', {// 客户服务
- url : "/cs",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/cs/left.html"
- },
- "right-view" : {
- templateUrl : "static/tpl/index/cs/right.html"
- }
- }
- }).state('cs.index', {
- url : "",
- templateUrl : "static/tpl/index/cs/index.html"
- }).state('cs.home', {
- url : "/",
- templateUrl : "static/tpl/index/cs/index.html"
- }).state('search', { //顶部搜索
- url: "/search?keyword=",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/search/left.html"
- },
- "right-view" : {
- templateUrl: "static/tpl/index/search/search_result.html",
- controller: 'TopSearchCtrl'
- }
- }
- }).state('approvalflow', { //审批流
- url: "/approvalFlow",
- views : {
- "left-view" : {
- templateUrl : "static/tpl/index/approvalFlow/left.html"
- },
- "right-view" : {
- templateUrl: "static/tpl/index/approvalFlow/right.html",
- }
- }
- }).state('approvalflow.flow', {
- url : "/flow",
- templateUrl : "static/tpl/index/approvalFlow/home.html",
- controller: 'approvalFlowCtrl'
- }).state('approvalflow.enterprise', {
- url : "/enterprise",
- templateUrl : "static/tpl/index/approvalFlow/enterprise.html",
- controller: 'EnterpriseCtrl'
- }).state('approvalflow.user', {
- url : "/user",
- templateUrl : "static/tpl/index/approvalFlow/user.html",
- controller: 'UserCtrl'
- }).state('approvalflow.log', {
- url : "/log",
- templateUrl : "static/tpl/index/approvalFlow/log.html",
- controller: 'LogCtrl'
- }).state('approvalflow.resource', {
- url : "/resource",
- templateUrl : "static/tpl/index/approvalFlow/resource.html",
- controller: 'ResourceCtrl'
- }).state('approvalflow.role', {
- url : "/role",
- templateUrl : "static/tpl/index/approvalFlow/role.html",
- controller: 'RoleCtrl'
- }).state('approvalflow.product', {
- url : "/product",
- templateUrl : "static/tpl/index/approvalFlow/prodList.html",
- controller: 'ProductAllCtrl'
- }).state('approvalflow.productmatches', {
- url : "/productmatches",
- templateUrl : "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesCtrl'
- });
- $urlRouterProvider.otherwise('/index');
- }]);
-
-
- /**
- * 表示符号
- */
- app.factory('Symbol', function(){
- return {
- currency: function(cur) {
- if(cur == 'RMB') return '¥';
- else if(cur == 'USD') return '$';
- else if(cur == 'EUR') return '€';
- else if(cur == null || cur == '') return '¥';
- else return cur;
- }
- };
- }).factory('Lodop',function(){
- return {
- getLodop:function(oOBJECT,oEMBED){
- var CreatedOKLodop7766=null;
- /**************************
- 本函数根据浏览器类型决定采用哪个页面元素作为Lodop对象:
- IE系列、IE内核系列的浏览器采用oOBJECT,
- 其它浏览器(Firefox系列、Chrome系列、Opera系列、Safari系列等)采用oEMBED,
- 如果页面没有相关对象元素,则新建一个或使用上次那个,避免重复生成。
- 64位浏览器指向64位的安装程序install_lodop64.exe。
- **************************/
- var strHtmInstall="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtmUpdate="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtm64_Install="<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtm64_Update="<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtmFireFox="<br><br><font color='#FF00FF'>(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)</font>";
- var strHtmChrome="<br><br><font color='#FF00FF'>(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)</font>";
- var LODOP;
- try{
- //=====判断浏览器类型:===============
- var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
- var is64IE = isIE && (navigator.userAgent.indexOf('x64')>=0);
- //=====如果页面有Lodop就直接使用,没有则新建:==========
- if (oOBJECT!=undefined || oEMBED!=undefined) {
- if (isIE)
- LODOP=oOBJECT;
- else
- LODOP=oEMBED;
- } else {
- if (CreatedOKLodop7766==null){
- LODOP=document.createElement("object");
- LODOP.setAttribute("width",0);
- LODOP.setAttribute("height",0);
- LODOP.setAttribute("style","position:absolute;left:0px;top:-100px;width:0px;height:0px;");
- if (isIE) LODOP.setAttribute("classid","clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
- else LODOP.setAttribute("type","application/x-print-lodop");
- document.documentElement.appendChild(LODOP);
- CreatedOKLodop7766=LODOP;
- } else
- LODOP=CreatedOKLodop7766;
- };
- //=====判断Lodop插件是否安装过,没有安装或版本过低就提示下载安装:==========
- if ((LODOP==null)||(typeof(LODOP.VERSION)=="undefined")) {
- if (navigator.userAgent.indexOf('Chrome')>=0)
- document.documentElement.innerHTML=strHtmChrome+document.documentElement.innerHTML;
- if (navigator.userAgent.indexOf('Firefox')>=0)
- document.documentElement.innerHTML=strHtmFireFox+document.documentElement.innerHTML;
- if (is64IE) document.write(strHtm64_Install); else
- if (isIE) document.write(strHtmInstall); else
- document.documentElement.innerHTML=strHtmInstall+document.documentElement.innerHTML;
- return LODOP;
- } else
- if (LODOP.VERSION<"6.1.9.8") {
- if (is64IE) document.write(strHtm64_Update); else
- if (isIE) document.write(strHtmUpdate); else
- document.documentElement.innerHTML=strHtmUpdate+document.documentElement.innerHTML;
- return LODOP;
- };
- //=====如下空白位置适合调用统一功能(如注册码、语言选择等):====
- LODOP.SET_LICENSES("深圳市优软科技有限公司","BBF53BD5AB0D522B3207D05CDE381F65","","");
-
- //============================================================
- return LODOP;
- } catch(err) {
- if (is64IE)
- document.documentElement.innerHTML="Error:"+strHtm64_Install+document.documentElement.innerHTML;else
- document.documentElement.innerHTML="Error:"+strHtmInstall+document.documentElement.innerHTML;
- return LODOP;
- };
- }
- }
- });
-
- app.controller('MyCtrl', ['$scope', '$rootScope', '$modal', function($scope, $rootScope, $modal) {
- $rootScope.$on('$locationChangeSuccess', function(evt, newUrl) {
- var routeState = newUrl.substr(newUrl.indexOf('#/') + 2);
- if (routeState.indexOf('/') > -1)
- routeState = routeState.substring(0, routeState.indexOf('/'));
- if (routeState.indexOf('.') > -1)
- routeState = routeState.substring(0, routeState.indexOf('.'));
- $scope.routeState = routeState || 'home';
- });
-
- $scope.search = function(keyword) {
- // if(keyword != null && keyword != '') {
- $rootScope.searchKeyword = keyword;
- window.location.hash = '#/search?keyword='+keyword;
- // }
- };
- $scope.showMessage = function() {
- var $modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/home/pagingRelease.html',
- controller: 'PagingReleaseCtrl'
- });
- };
- // 连接到询价
- $scope.linktoInquiry = function(active) {
- $rootScope.active = active;
- window.location.href = "#/sale/inquiry";
- }
-
- // 连接到招标
- $scope.linktoSaleTender = function(active) {
- $rootScope.active = active;
- window.location.href = "#/sale/tender";
- }
-
- // 链接到打样申请
- $scope.linktoSample = function(active) {
- $rootScope.active = active;
- window.location.href = "#/sale/sample";
- }
-
- // 链接到采购招标
- $scope.linktoPurcTender = function(active) {
- $rootScope.tenderActive = active;
- window.location.href = "#/purc/tender";
- }
-
- $scope.linktoPurcInquiry = function(active) {
- $rootScope.active = active;
- window.location.href = "#/purc/purchaseinquiry";
- }
- }]);
- app.controller('PagingReleaseCtrl', ['$scope', 'PagingRelease', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function($scope, PagingRelease, BaseService, ngTableParams, toaster, $modalInstance){
- BaseService.scrollBackToTop();
- $scope.active = "todo";
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- 'releaseDetail.release.date': 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- // fromDate: getDateTime($scope.condition.dateFrom),
- // endDate: getDateTime($scope.condition.dateTo)
- };
- // AccountEnterprise.get({}, function(data){
- // $scope.loading = false;
- // $scope.currentEn = data;
- // });
- PagingRelease[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.close = function() {
- $modalInstance.close();
- };
- $scope.checks = {
- checked : false
- };// 全选框
- $scope.checkAll = function() {
- angular.forEach($scope.tableParams.data, function(message) {
- message.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function(vendor) {
- vendor.checked = true;
- var checked = true;
- angular.forEach($scope.tableParams.data, function(message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- // 单反选
- $scope.unCheckOne = function(vendor) {
- vendor.checked = false;
- $scope.checks.checked = false;
- };
- // 标为已读
- $scope.setRead = function() {
- var selectedMessages = [];
- angular.forEach($scope.tableParams.data, function(message) {
- if(message.checked) {
- selectedMessages.push(message);
- }
- });
- PagingRelease.setRead({}, selectedMessages , function(message) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- });
- };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- app.filter('getkey', ['$sce', '$rootScope', function($sce, $rootScope) {
- var search = $rootScope.searchKeyword;
- return function(content, search) {
- content = encodeURI(content);
- search = encodeURI(search);
- var reg = new RegExp(search, 'gim');
- var result = content.replace(reg,'<font color="red">$&</font>');
- result = decodeURI(result);
- return $sce.trustAsHtml(result);
- };
- $rootScope.searchKeyword = null;// 清除缓存的关键字
- }]);
- /**
- * 顶部搜索
- */
- app.controller('TopSearchCtrl', ['$scope', '$rootScope', 'getAccountUserSpace', 'ngTableParams', 'toaster', 'BaseService', 'AddPartner', '$filter', '$stateParams', 'SearchProd', '$sce', '$modal', 'InvitationRecord', function($scope, $rootScope, getAccountUserSpace, ngTableParams, toaster, BaseService, AddPartner, $filter, $stateParams, SearchProd, $sce, $modal, InvitationRecord) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.tip = $rootScope.searchKeyword;
- // 企业搜索
- var getService = function() {
- return getAccountUserSpace;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page) {
- $scope.loading = false;
- if(page) {
- $scope.total = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 添加合作关系
- $scope.addPartner = function(name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function(data) {
- if(data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
- // 物料搜索
- var getProdService = function() {
- return SearchProd;
- };
- $scope.prodTableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getProdService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- $scope.prodtotal = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- /**
- * 向企业购买
- */
- $scope.PurcByEn = function(businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function(businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 询价
- */
- $scope.PurcInquiry = function(businessCode, id){
- $rootScope.prodId = id;
- window.location.hash = "#/purc/purcinquiry/" + businessCode;
- }
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function(name) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function(){return name}
- }
- });
- modalInstance.result.then(function(data) {
- InvitationRecord.invite({formStore: data}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- /**
- * 立即查看
- */
- $scope.view = function(name) {
- $rootScope.vendName = name;
- window.location.hash = "#/baseInfo/newPartner";
- }
- }]);
- app.controller('InviteCtrl', ['$scope', 'toaster', '$modalInstance', 'enname', function($scope, toaster, $modalInstance, enname) {
- $scope.enter = {
- vendname: enname
- };
-
- $scope.save = function(enter) {
- if(!enter.vendusertel && !enter.venduseremail) {
- toaster.pop('info', '提示', '手机号或邮箱至少填写一个才能通知到客户');
- } else {
- $modalInstance.close(enter);
- }
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- app.controller('ReInviteCtrl', ['$scope', 'toaster', '$modalInstance', 'id', 'InvitationRecord', function($scope, toaster, $modalInstance, id, InvitationRecord) {
- var loadData = function (id) {
- InvitationRecord.getRecordById({id: id}, {}, function(data) {
- if (data.user !== null) {
- data.user = {};
- }
- $scope.enter = data;
- });
- };
- loadData(id);
- $scope.save = function(enter) {
- if(!enter.vendusertel && !enter.venduseremail) {
- toaster.pop('info', '提示', '手机号或邮箱至少填写一个才能通知到客户');
- } else {
- $modalInstance.close(enter);
- }
- };
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- /**
- * 邀请记录
- */
- app.controller('InvitationCtrl', ['$scope', 'toaster', 'InvitationRecord', 'BaseService', 'ngTableParams', '$modal', function($scope, toaster, InvitationRecord, BaseService, ngTableParams, $modal) {
- BaseService.scrollBackToTop();
- $scope.status = "invitation";
- $scope.active = "invitation";
- var getService = function() {
- if ($scope.active === "invitation") {
- return InvitationRecord.records;
- } else if ($scope.active === "invitationTeam") {
- return InvitationRecord.getActiveRecordsByEn; // 只获取已激活的
- }
- };
- $scope.setActive = function(state) {
- if($scope.active !== state) {
- $scope.active = state;
- if($scope.tableParams.page() === 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService().call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.onSearch = function(keyword){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.tip = keyword;
- }
-
- $scope.search = function(name) {
- $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/fuzzysearch_enterprise_modal.html',
- controller: 'FuzzySearchCtrl',
- resolve: {name: function() {return name}}
- }).result.then(function(data){
- });
- };
-
- // 再次邀请
- $scope.reInvite = function(id) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'ReInviteCtrl',
- resolve: {
- id: function(){return id}
- }
- });
- modalInstance.result.then(function(data) {
- InvitationRecord.invite({formStore: data}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- }]);
-
- /**
- * 模糊查询相似的企业名称
- */
- app.controller('FuzzySearchCtrl', ['$scope', 'name', 'InvitationRecord', 'toaster', 'BaseService', function($scope, name, InvitationRecord, toaster, BaseService) {
- $scope.name = name;
- if($scope.name != null) {
- InvitationRecord.enterpriseList({name: $scope.name}, {}, function(data) {
- $scope.enterprises = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', 'toaster', 'BaseService', '$modal', function($scope, $window, AuthenticationService, toaster, BaseService, $modal) {
- $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
-
- //手机号码格式验证
- // var checkTel = function(data){
- // var userTel = data.userTel;
- // $scope.checkResult = false;
- // var telephone = /^1[3|4|5|7|8]\d{9}$/;
- // if(!(telephone).test(userTel)){
- // var modalInstance = $modal.open({
- // animation: true,
- // templateUrl: 'static/tpl/index/account/checkTel.html',
- // controller: 'CheckTelCtrl',
- // backdrop: 'static',
- // keyboard: false,
- // resolve: {
- // user: function(){
- // return data;
- // },
- // }
- // });
- // modalInstance.result.then(function(){
- // }, function(){
- //
- // });
- // } else {
- // $scope.checkResult = true;
- // }
- // };
- AuthenticationService.getAuthentication().success(function(data) {
- if(data.enterprises) {
- data.enterprise = data.enterprises[data.enterprises.length - 1];
- if(data.enterprises.length > 1) {
- var enSelect = [];
- angular.forEach(data.enterprises, function(e){
- if(e.current)
- data.enterprise = e;
- else
- enSelect.push(e);
- });
- data.enSelect = enSelect;
- }
- }
- $scope.userInfo = data;
- if (data == null || !data.userUU) {
- $scope.isAuthed = false;
- AuthenticationService.redirectSignin();
- } else {
- //跳转到手机号码验证
- // checkTel($scope.userInfo);
- }
- });
- $scope.logout = function() {
- $modal.open({
- templateUrl: 'static/tpl/index/account/logout.html',
- controller: 'LogOutCtrl'
- }).result.then(function(s){
- if(s) {
- 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('LogOutCtrl', ['$scope', '$modalInstance', function($scope, $modalInstance) {
- $scope.close = function(confirm) {
- $modalInstance.close(confirm);
- };
- }]);
-
- app.controller('ImageInsertCtrl', ['$scope', '$modalInstance', function($scope, $modalInstance) {
- $scope.image = {src: null};
- // 图片上传成功之后
- $scope.onUploadSuccess = function(data){
- var path = data.path;
- path = path.substring(0, path.lastIndexOf('.')) + "_150x90" + path.substr(path.lastIndexOf('.'));
- $scope.$apply(function(){
- $scope.image.src = data.path;
- $scope.image.thumb = path;
- });
- };
- $scope.close = function() {
- $modalInstance.dismiss();
- };
- $scope.confirm = function() {
- $modalInstance.close($scope.image);
- $scope.imageUrl = null;
- };
- }]);
-
- app.controller('TodoCtrl', ['$scope', 'SnapshotService', 'BaseService', '$rootScope', function($scope, SnapshotService, BaseService, $rootScope){
- BaseService.scrollBackToTop();
- SnapshotService.getTodo(function(data){
- $scope.todo = data;
- });
- $scope.setTenderActive = function(active) {
- $rootScope.tenderActive = active;
- window.location.hash = '#/purc/tender';
- }
- }]);
- // header
- app.controller('HeaderCtrl', ['$scope', 'SnapshotService', function($scope, SnapshotService){
- SnapshotService.getMessage(function(data){
- $scope.message = data;
- });
- }]);
-
- app.controller('TruckCtrl', ['$scope', '$rootScope', '$modal', 'SaleTruck', function($scope, $rootScope, $modal, SaleTruck){
- SaleTruck.query({}, function(data){
- $rootScope.truck = data;
- $scope.truckCount = data ? data.length : 0;
- });
- $scope.$watch(function(){
- return $rootScope.truck;
- }, function(data) {
- $scope.truckCount = data ? data.length : 0;
- }, true);
- $scope.clearAll = function() {
- SaleTruck.remove({}, function(){
- $rootScope.truck = [];
- });
- };
- $scope.openTrack = function() {
- $modal.open({
- templateUrl: 'static/tpl/index/sale/track.html',
- controller: 'TruckModalCtrl',
- size: 'lg'
- }).result.then(function(s){
- if(s) {
- $scope.clearAll();
- $rootScope.dataChanged = true;
- }
- });
- };
- }]);
-
- app.controller('TruckModalCtrl', ['$scope', '$rootScope', '$modalInstance', 'SaleTruck', 'PurcNotice', 'toaster', '$state', '$filter', '$timeout', function($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice, toaster, $state, $filter, $timeout){
- $scope.saleSend = {sendItems: []};
- SaleTruck.detail({}, function(data){
- // 按物料编号排序
- $scope.notices = $filter('orderBy')(data, 'orderItem.product.code');
- });
- $scope.remove = function(index, notice) {
- SaleTruck.remove({noticeId: notice.id}, function(data){
- $rootScope.truck = data;
- $scope.notices.splice(index, 1);
- });
- };
- $scope.$watch(function(){
- return $scope.notices;
- }, function(data) {
- var q = 0, t = 0;
- if(data) {
- angular.forEach(data,function(d){
- q += d.thisSendQty;
- t += d.thisSendQty * d.orderItem.price;
- });
- }
- $scope.totalQty = q;
- $scope.total = t;
- }, true);
- $scope.cancel = function() {
- $modalInstance.close();
- };
-
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function() {
- $scope.lockstatus = true;
- $timeout(function() {
- $scope.lockstatus = false;
- }, 5000);
- }
- $scope.send = function() {// 发货
- if(!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
- toaster.pop('error', '错误', '请输入送货单号');
- return;
- }
- var currency = $scope.notices[0].orderItem.order.currency,
- custUU = $scope.notices[0].enUU,
- payments = $scope.notices[0].orderItem.order.payments, valid = true, items = [];
- var num = 1;
- for(var i in $scope.notices) {
- var item = $scope.notices[i];
- if(item.id) {
- if(item.orderItem.order.currency != currency || item.enUU != custUU || item.orderItem.order.payments != payments) {
- valid = false;
- break;
- }
- items[i] = {noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price, number: num ++};
- }
- }
- if(!valid) {
- toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致、采购员一致才能一起发货。');
- } else {
- var send = angular.extend(angular.copy($scope.saleSend), {
- currency: currency,
- custUU: custUU,
- payments: payments,
- sendItems: items
- });
- PurcNotice.sendByBatch({}, send, function(data){
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + send.code);
- $modalInstance.close(true);
- $state.go('sale.send_detail', {id: data.id});
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- }
- };
- }]);
- app.controller('PersonalSaleStatCtrl', ['$scope', 'SaleStat', function($scope, SaleStat) {
- SaleStat.cust({}, function(data){
- var p = [], q = [];
- angular.forEach(data.month, function(d){
- p.push({x: (d.enterprise.enShortname || d.enterprise.enName), y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function(d){
- q.push({x: (d.enterprise.enShortname || d.enterprise.enName), y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.custCharts = {
- month : {
- chartType : 'pie',
- datas : {
- data : p
- },
- config : {
- labels : false,
- title : "客户月采购量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- },
- year : {
- chartType : 'pie',
- datas : {
- data : q
- },
- config : {
- labels : false,
- title : "客户年采购量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- }
- };
- });
- SaleStat.seller({}, function(data){
- var p = [], q = [];
- angular.forEach(data.month, function(d){
- p.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function(d){
- q.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.sellerCharts = {
- month : {
- chartType : 'pie',
- datas : {
- data : p
- },
- config : {
- labels : false,
- title : "业务员月销量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- },
- year : {
- chartType : 'pie',
- datas : {
- data : q
- },
- config : {
- labels : false,
- title : "业务员年销量排行榜",
- legend : {
- display : true,
- position : 'right'
- },
- colors : [ '#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC' ],
- click : function(d) {
- },
- mouseover : function(d) {
- },
- mouseout : function(d) {
- },
- innerRadius : 0,
- lineLegend : 'lineEnd'
- }
- }
- };
- });
- }]);
- app.controller('SaleStatCtrl', ['$scope', 'SaleStat', function($scope, SaleStat){
- SaleStat.get({}, function(data){
- var p = [], q = [], r = [];
- angular.forEach(data.day, function(d){
- p.push({x: d.day, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.month, function(d){
- q.push({x: d.month, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function(d){
- r.push({x: d.year, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.charts = {
- day : {
- chartType : "line",
- datas: {
- series: ['销售额'],
- data: p
- },
- config : {
- "labels": false,
- "title": "销售额统计(近15日线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors : [ '#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- month: {
- chartType : "line",
- datas: {
- series: ['销售额'],
- data: q
- },
- config : {
- "labels": false,
- "title": "销售额统计(近12月线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors : [ '#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- year: {
- chartType : "line",
- datas: {
- series: ['销售额'],
- data: r
- },
- config : {
- "labels": false,
- "title": "销售额统计(近10年线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors : [ '#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- }
- };
- });
- }]);
- app.controller('NoticeCtrl', ['$scope', 'SnapshotService', function($scope, SnapshotService){
- SnapshotService.getNotice(5, function(data){ //5表示首页显示的公告条数
- $scope.notices = data;
- });
-
- $scope.dateTime = new Date();
- }]);
- app.controller('TenderCtrl', ['$scope', 'SnapshotService', function($scope, SnapshotService){
- // SnapshotService.getTender(250, function(data){
- // $scope.tenders = data;
- // console.log(data);
- // var newDate = new Date();
- // newDate = newDate.setDate(newDate.getDate() - 3);
- // angular.forEach($scope.tenders, function(tender) {
- // if (tender.date > newDate) {
- // tender.isNew = true;
- // } else {
- // tender.isNew = false;
- // }
- // });
- // });
- SnapshotService.getOpenTender(5, function(data){
- $scope.openTenders = data;
- var newDate = new Date();
- newDate = newDate.getTime() - 3*24*60*60*1000;
- angular.forEach($scope.openTenders, function(tender) {
- if (tender.date - newDate > 0) {
- tender.isNew = true;
- } else {
- tender.isNew = false;
- }
- });
- });
- $scope.dateTime = new Date();
- }]);
- app.controller('VendCountCtrl', ['$scope', 'VendorService', function($scope, VendorService){
- VendorService.getCount(function(date){
- $scope.count = date;
- });
- }]);
-
- // 客户
- app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
- BaseService.scrollBackToTop();
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- var getCustInfos = function(custuu) {
- if(custuu) {
- VendorService.userInfo.query({uu:custuu},null,function(data) {
- $scope.custInfos = data;
- var getPage = function(page, size){
- if($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1)*size, page * size);
- if($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- }else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1,4);
- $scope.first = function (){
- $scope.userdata = getPage($scope.userdata.pre,4);
- }
- $scope.last = function (){
- $scope.userdata = getPage($scope.userdata.next,4);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }
- $scope.addUserInfo = function(customer) {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function() {
- return customer;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
- $scope.showUserInfo = function(customer,boo) {
- $scope.custInfo = customer;
- if(boo) {
- getCustInfos(customer.myEnterprise.uu);
- $scope.userInfoResult = true;
- }
- }
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get(BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
-
- // 查看详情
- $scope.viewDetail = function(id) {
- window.location.hash = "#/sale/customer/" + id;
- }
- }]);
-
- // 客户详情
- app.controller('CustomerDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', 'VendorService', 'AuthenticationService', function($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope, VendorService, AuthenticationService) {
- BaseService.scrollBackToTop();
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.vendorContacts = [];
- var loadData = function() {
- Vendor.getVendorDetail({id: $stateParams.id}, {}, function(data) {
- $scope.customer = data.myEnterprise;
- $scope.customerInfo = data;
- Vendor.custContacts({enuu: $scope.customer.uu}, {}, function(data) {
- $scope.Contacts = data;
- });
-
- // 查看已分配人员
- VendorService.userInfo.query({uu: $scope.customer.uu},null,function(data) {
- $scope.custInfos = data;
- var getPage = function(page, size){
- if($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1)*size, page * size);
- if($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- }else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1,4);
- $scope.first = function (){
- $scope.userdata = getPage($scope.userdata.pre,4);
- }
- $scope.last = function (){
- $scope.userdata = getPage($scope.userdata.next,4);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- });
- };
- loadData();
-
- // 新增客户联系人
- $scope.addContact = function(uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- $scope.contact.myenuu = uu;
- Vendor.saveCustContact({}, $scope.contact, function(data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.Contacts.push(data);
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- // 编辑客户联系人
- $scope.edit = function(contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function() {
- return contact;
- }
- }
- });
- modalInstance.result.then(function(data) {
- Vendor.saveContact({}, data, function(data) {
- loadData();
- toaster.pop('success', '提示', '联系人修改成功');
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- // 删除客户联系人
- $scope.deleteById = function(id, index) {
- $scope.Contacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '客户联系人删除成功');
- loadData();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 供应商物料信息
- $scope.viewProdList = function(uu){
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.addUserInfo = function() {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function() {
- return $scope.customerInfo;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- loadData();
- if(changed) {
- if(checked) {
- $scope.newUser.roles = checked;
- } else {
- loadUsers();
- }
- }
- });
-
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
-
- $scope.Quotation = function(uu, id) {
- $rootScope.custuu = uu;
- $rootScope.prodId = id;
- window.location.hash = "#/sale/quotation/new";
- }
- }]);
-
- app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', function($scope, $modalInstance, customer, AccountUser, toaster){
- $scope.checkboxes = {
- checked : false
- };
- $scope.loading = true;
- 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;
- // 已采纳
- case 'agreed':
- fn = 'getAgreed';break;
- // 未采纳
- case 'refused':
- fn = 'getRefused';break;
- // 个人
- case 'personal':
- fn = 'getPersonal';break;
- // 集体
- case 'teams':
- fn = 'getTeams';break;
- // 非标准
- case 'nonstandard':
- fn = 'getNonstandard';break;
- // 标准
- case 'standard':
- fn = 'getStandard';break;
- }
- 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', '$rootScope',
- function($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, $rootScope){
- BaseService.scrollBackToTop();
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'all';
- }
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1, deliveryZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function(zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
-
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- var getPurcStatus = function(active) {
- var fn = 'getPurcAll';
- switch(active) {
- case 'done':
- fn = 'getPurcDone';break;
- case 'todo':
- fn = 'getPurcTodo';break;
- case 'end':
- fn = 'getPurcEnd';break;
- case 'waiting':
- fn = 'getPurcWaiting';break;
- }
- return fn;
- };
-
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 20,
- sorting: {
- display: 'desc',
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 15, 25, 50],
- getData : function($defer, params) {// 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- PurcOrderItem[getPurcStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- $defer.resolve(page.content);
- $scope.total = page.totalElement;
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.getReply = function(item) {
- if(!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
-
- $scope.getOrderTotal = function(items) {
- var sum = 0;
- angular.forEach(items, function(item){
- sum += item.qty * item.price;
- });
- return sum;
- };
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
-
- $scope.checkboxes = {
- checked : false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function(){
- angular.forEach($scope.tableParams.data, function(item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
-
- // 点击其中一个明细的复选框
- $scope.checkOne = function(order){
- var result = true;
- angular.forEach($scope.tableParams.data, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.tip = keyword;
- };
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- app.controller('PurcOrderDetailCtrl', ['$scope', '$stateParams', 'PurcOrder', 'PurcOrderItem', 'toaster', 'ReportService', function($scope, $stateParams, PurcOrder, PurcOrderItem, toaster, ReportService){
- var loadData = function() {
- PurcOrder.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function(item){
- sum += item.qty * item.price;
- });
- $scope.order.total = sum;
- if($scope.order.display == 1) {//未查看的设为已查看
- $scope.setDisplay('setRead', $scope.order.id);
- }
- $scope.loading = false;
- });
- };
- loadData();
- $scope.getReply = function(item) {
- if(!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.onReplyClick = function(item, inverse) {
- if(item.reply) {
- if(!item.reply.qty || item.reply.qty < 0 || item.reply.qty > item.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- PurcOrderItem.reply({orderItemId: item.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // // 采购单
- // $scope.print = function(order) {
- // PurcOrder.printCount({id: order.id},{});//增加打印此次
- // ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
- // };
-
- //设置为已查看
- $scope.setDisplay = function(state, orderId) {
- if(orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function(){
- // $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function(order) {
- if(order.$selected == true) {
- if(str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if(str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function(){
- $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- }]);
-
- app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PurcOrderItemHis',
- function($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis){
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1, deliveryZone: -1};
- $scope.changeDateZone = function(zone) {
- if(typeof zone == 'undefined'){
- $scope.condition.dateZone = -6;
- } else {
- $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.nowdate = new Date();
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function() {
- return $scope.condition.dateZone ? PurcOrderItem : PurcOrderItemHis;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 20,
- sorting: {
- display: 'desc',
- date: 'desc',
- id: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 15, 25, 50],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- $defer.resolve(page.content);
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.getOrderTotal = function(items) {
- var sum = 0;
- angular.forEach(items, function(item){
- sum += item.qty * item.price;
- });
- return sum;
- };
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
-
- $scope.onReplyClick = function(item, inverse) {
- if(item.reply) {
- if(!item.reply.qty || item.reply.qty < 0 || item.reply.qty > item.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- PurcOrderItem.reply({orderItemId: item.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- //打印 采购单
- $scope.print = function(order) {
- PurcOrder.printCount({id: order.id},{});//增加打印此次 // 在此方法内添加记录日志
- if(order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
- ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
- };
-
- $scope.getReply = function(item) {
- if(!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
-
- $scope.checkboxes = {
- checked : false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function(){
- angular.forEach($scope.tableParams.data, function(item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
-
- // 点击其中一个明细的复选框
- $scope.checkOne = function(order){
- var result = true;
- angular.forEach($scope.tableParams.data, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
-
- //批量回复采购订单
- $scope.replyByBatch = function() {
- $scope.loading = true;
- var str = '';
- angular.forEach($scope.tableParams.data, function(order) {
- if(order.$selected == true) {
- angular.forEach(order.orderItems, function(item){
- str += item.id;
- str += ',';
- });
- }
- });
- if(!(str == '')) {
- str = str.substr(0, str.length-1);
- PurcOrderItem.replyByBatch(str, function(){
- $scope.loading = false;
- $scope.tableParams.reload();
- toaster.pop('success', '提示', '批量回复成功');
- }, function(data){
- $scope.loading = false;
- toaster.pop('error', '批量回复失败', data);
- });
- } else {//没有勾选其中的明细
- $scope.loading = false;
- }
- };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //设置为已查看
- $scope.setDisplay = function(state, orderId) {
- if(orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function(){
- $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function(order) {
- if(order.$selected == true) {
- if(str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if(str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function(){
- $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- }]);
- app.controller('SaleOrderDetailCtrl', ['$scope', '$stateParams', 'PurcOrder', 'PurcOrderItem', 'toaster', 'ReportService', function($scope, $stateParams, PurcOrder, PurcOrderItem, toaster, ReportService){
- var loadData = function() {
- PurcOrder.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function(item){
- sum += item.qty * item.price;
- });
- $scope.order.total = sum;
- if($scope.order.display == 1) {//未查看的设为已查看
- $scope.setDisplay('setRead', $scope.order.id);
- }
- $scope.loading = false;
- });
- };
- loadData();
- $scope.getReply = function(item) {
- if(!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.onReplyClick = function(item, inverse) {
- if(item.reply) {
- if(!item.reply.qty || item.reply.qty < 0 || item.reply.qty > item.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- PurcOrderItem.reply({orderItemId: item.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 采购单
- $scope.print = function(order) {
- PurcOrder.printCount({id: order.id},{});//增加打印此次
- ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
- };
-
- //设置为已查看
- $scope.setDisplay = function(state, orderId) {
- if(orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function(){
- $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function(order) {
- if(order.$selected == true) {
- if(str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if(str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function(){
- $scope.tableParams.reload();
- }, function() {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- }]);
- app.controller('SaleChangeCtrl', ['$scope', '$filter', 'PurcChange', 'ngTableParams', 'toaster', 'BaseService', 'PurcChangeHis', function($scope, $filter, PurcChange, ngTableParams, toaster, BaseService, PurcChangeHis){
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return $scope.condition.dateZone ? PurcChange : PurcChangeHis;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- 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', '$upload', '$rootScope', function($scope, $filter, PurcInquiry, ngTableParams, toaster, BaseService, PurcInquiryHis, $upload, $rootScope){
- BaseService.scrollBackToTop();
- if($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- // 得到消息
- PurcInquiry.getMessage({}, function(data){
- $scope.message = data;
- }, function(response) {
-
- });
- var getService = function() {
- return $scope.condition.dateZone ? PurcInquiry : PurcInquiryHis;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.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) {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- itemId:item.id
- }
- }).success(function (attach) {
- console.log(attach);
- });
- 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();
- };
-
- // 取消
- $scope.cancel = function() {
- $scope.tableParams.reload();
- }
- }]);
-
- // 询价单明细
- app.controller('SaleInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry','$filter', 'toaster', '$upload', function($scope, $stateParams, PurcInquiry,$filter, toaster, $upload){
- 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) {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- itemId:item.id
- }
- }).success(function (attach) {
- console.log(attach);
- });
- PurcInquiry.reply({itemId: item.id}, item, function(){
- toaster.pop('info', '提示', '报价成功');
- loadData();
- }, function(response){
- toaster.pop('error', '报价失败', response.data);
- });
- } else {
- PurcInquiry.saveItem({itemId: item.id}, item, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- // 取消
- $scope.cancel = function() {
- $scope.tableParams.reload();
- }
- }]);
-
- // 平台新增的询价单
- app.controller('PurcInquiryCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'GetProductInfo', '$timeout', '$http', 'ShipAddress', 'Search', 'ComponentActiveAPI', function($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, GetProductInfo, $timeout, $http, ShipAddress, Search, ComponentActiveAPI) {
- $scope.status = 'InquiryNew';
- $scope.active = 'all';
- $rootScope.tenderVendor = null;// 清除掉已选择的
- var getService = function() {
- return GetProductInfo;
- };
- $scope.inquiry = {
- code: 'XJ' + $filter('date')(new Date(), 'yyMMddsss'),
- showdate: $filter('date')(new Date, 'yyyy-MM-dd'),
- priceType: '采购',
- isOpen: 1,
- invoice: 0,
- ifTax: 1,
- currency: 'RMB',
- inquirytype: '询价'
- };
-
- $scope.changeCurrency = function(inquiry) {
- if (inquiry.currency !== 'RMB') {
- $scope.notRMB = true;
- inquiry.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- inquiry.invoice = 0;
- } else {
- $scope.notRMB = false;
- }
- };
-
- // 获取收货地址列表
- var loadShipAddress = function() {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.inquiry.ship = $scope.ships[0].address + $scope.ships[0].addressdet + $scope.ships[0].receiver + $scope.ships[0].usertel;
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset":"charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
-
- $scope.currentDay = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
-
- $scope.vendors = [];
- // 查找供应商
- $scope.dbfindVendor = function(){
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {
- }
- });
- modalInstance.result.then(function(data){
- var ifPush = true;
- modalInstance.result.then(function(data){
- angular.forEach(data, function(vendor) {
- if (!$scope.vendors) {// 不存在就先创建
- $scope.vendors = [{}];
- $scope.vendors.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0;i<$scope.vendors.length; i++) {
- ifPush = true;
- if ($scope.vendors[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.vendors.push({enName: vendor.vendorEnterprise.enName, enuu: vendor.vendorEnterprise.uu});
- }
- }
- });
- $rootScope.tenderVendor = $scope.vendors;
- }, function(){
- });
- }, function(){
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function(index) {
- $scope.vendors.splice(index, 1);
- };
- $scope.removeChecked = function() {
- console.log($scope.vendors);
- if ( $scope.vendors.length > 0) {
- $scope.vendors = [];
- $rootScope.tenderVendor = '';
- }
- }
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $scope.inquiry.inquiryItems = [];
- var prod = {
- prodCode: null,
- prodTitle: null,
- inbrand: null,
- toDate: null,
- unit: 'PCS',
- needquantity: null
- };
- $scope.inquiry.inquiryItems.push(prod);
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function(value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword : value}).$promise.then(function(data) {
- return data.map(function(item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function(value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
-
- $scope.selectKind = function(prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function() {
- return $scope.actives;
- }
- }
- }).result.then(function(data){
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function(){
- });
- };
-
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function(brand, prod) {
- if (brand instanceof String) {
- prod.inbrand = brand;
- } else if (brand instanceof Object) {
- prod.inbrand = brand.brandCn;
- }
- };
-
- // 打开品牌选择的模态框
- $scope.selectBrand = function(prod){ //打开模态
- var modalInstance = $modal.open({
- templateUrl : 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller : 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function(){// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function(brand){
- prod.inbrand = brand.nameCn;
- }, function(reason){
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function(cmp, prod) {
- ComponentActiveAPI.get({uuid : cmp.uuid}, {}, function(data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.inbrand = data.brand.nameCn;
- }, function(res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
-
- // 导入商品信息
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcInquiryUploadCtrl',
- size: 'lg',
- resolve: {
- }
- });
-
- modalInstance.result.then(function(data) {
- angular.forEach(data, function(prod) {
- console.log(prod);
- $scope.inquiry.inquiryItems.push(prod);
- for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- })
-
- }, function(){
-
- });
- }
- //增加商品
- $scope.add = function() {
- $scope.inquiry.inquiryItems.push(
- { prodCode: null,
- prodTitle: null,
- unit: 'PCS',
- ibrand: null,
- toDate: null,
- needquantity: null});
- };
- //删除商品
- $scope.del = function(index) {
- $scope.inquiry.inquiryItems.splice(index, 1);
- };
-
- $scope.check = function(product) {
- for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- $scope.inquiry.inquiryItems.push({prodCode: product.code, prodTitle: product.title, spec: product.spec, unit: product.unit,
- currency: null, toDate: null, needquantity: null, productId: product.id, inbrand: product.brand});
- }
-
- $scope.getMinDate = function(item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
-
- $scope.openDatePicker = function($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.inquiry.inquiryItems[index].$toDateOpen = !openParam;
- };
-
- $scope.openEndDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.ifrepeat = false;
- // 保存
- $scope.save = function() {
- for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for(var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if(i != j) {
- if($scope.item.prodCode = $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- if(!$scope.ifrepeat) {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- if( $scope.inquiry.isOpen == 0) { // 指定询价
- if( $scope.vendors.length > 0) {
- $upload.upload({
- url: 'purc/inquiry/save',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- $rootScope.active = 'todo';
- window.location.hash = "#/purc/inquiry_unapply";
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- } else {
- $upload.upload({
- url: 'purc/inquiry/saveWithoutVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- $rootScope.active = 'done';
- window.location.hash = "#/purc/inquiry_unapply";
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- }
- } else {
- toaster.pop('error', '提示', '存在相同条件的物料信息');
- }
- }
-
- // 保存并提交
- $scope.submit = function() {
- for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for(var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if(i != j) {
- if($scope.item.prodCode = $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- if(!$scope.ifrepeat) {
- if( $scope.inquiry.isOpen == 0) { // 指定询价
- if($scope.vendors.length > 0) {
- $upload.upload({
- url: 'purc/inquiry/saveAndSubmit',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = "#/purc/purchaseinquiry";
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- } else {
- $upload.upload({
- url: 'purc/inquiry/saveAndSubmitWithoutVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = "#/purc/purchaseinquiry";
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- }
- } else {
- toaster.pop('error', '提示', '存在相同条件的物料信息');
- }
- }
-
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function(){
- if($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if(file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else{
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else{//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var getObjectURL = function(file) {
- var url = null ;
- if (window.createObjectURL!=undefined) { // basic
- url = window.createObjectURL(file) ;
- } else if (window.URL!=undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file) ;
- } else if (window.webkitURL!=undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file) ;
- }
- return url ;
- };
- }]);
-
- /**
- * 代采订单批量导入
- */
- app.controller('PurcInquiryUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function() {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'purc/inquiry/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function(response) {
- toaster.pop('error', response.data || response);
- });
- };
-
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
-
- // 下载模板
- $scope.download = function() {
- window.location.href = 'purc/inquiry/upload/template';
- };
-
- $scope.enSure = function() {
- $modalInstance.close($scope.result.items);
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- // 平台询价单(已提交)
- app.controller('PurchaseInquiryCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', 'PurchaseInquiry', '$rootScope', function($scope, $filter, ngTableParams, toaster, BaseService, PurchaseInquiry, $rootScope) {
- $scope.status = 'InquirySubmit';
- BaseService.scrollBackToTop();
- if($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
-
- $scope.setActive = function(state) {
- if($scope.active != state ) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- }
-
- var getService = function() {
- return PurchaseInquiry;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.keyword = $scope.keyword;
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 采纳
- $scope.accept = function(id) {
- PurchaseInquiry.accept({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
-
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- };
-
- // 拒绝
- $scope.refuse = function(id) {
- PurchaseInquiry.refuse({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
-
- // 平台询价单(未提交)
- app.controller('UnapplyInquiryCtrl', ['$scope', 'PurchaseInquiry', 'ngTableParams', 'BaseService', 'toaster', '$rootScope', function($scope, PurchaseInquiry, ngTableParams, BaseService, toaster, $rootScope) {
- BaseService.scrollBackToTop();
- if($rootScope.active = 'done') {
- $scope.active = 'done';
- $rootScope.active = '';
- }
- if($rootScope.active = 'todo') {
- $scope.active = 'todo';
- $rootScope.active = '';
- }
- var getService = function() {
- if($scope.active == 'todo') {
- return PurchaseInquiry.getUnapply;
- }
- if($scope.active == 'done') {
- return PurchaseInquiry.getSubmit;
- }
- }
-
- $scope.setActive = function(state) {
- if($scope.active != state ) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- }
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- 'date': 'desc',
- 'enterprise.enName': 'asc',
- 'code': 'asc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService().call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 删除明细
- $scope.deleteById = function(id) {
- PurchaseInquiry.deleteById({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 删除主表
- $scope.clearOrder = function(id) {
- PurchaseInquiry.clearOrder({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 提交
- $scope.submit = function(id) {
- PurchaseInquiry.submitUnapply({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '单据提交成功');
- $scope.active = 'done';
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 发布公共询价
- $scope.publish = function(id) {
- PurchaseInquiry.publishInquiry({id: id}, {}, function(data) {
- toaster.pop('success', '提示', data.success);
- $scope.active = 'done';
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
-
- // 公共询价列表
- app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry','$filter', 'toaster', 'BaseService', 'ngTableParams', function($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams) {
- BaseService.scrollBackToTop();
- /**
- * 改变单据日期范围
- */
- var getTenderDateCondition = function(zone, condition) {
- var date = new Date();
- if(zone == -1) {
- condition.dateFrom = null;
- condition.dateTo = null;
- } else if(zone == 7) { // 一星期内
- date.setDate(date.getDate() - 7);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if(zone == 1) { // 一个月内
- date.setMonth(date.getMonth() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if(zone == 3) { // 三个月内
- date.setMonth(date.getMonth() - 3);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 6) { // 半年内
- date.setMonth(date.getMonth() - 6);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else { // 一年内
- date.setYear(date.getYear() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- }
- };
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.condition.$dateZoneOpen = false;
- getTenderDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // $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.nowdate = new Date().getTime() - 24 * 3600 * 1000;
- console.log($scope.nowdate);
- var getOpenState = function(active) {
- var fn = 'getOpenAll';
- switch(active) {
- case 'all':
- fn = 'getOpenAll';break;
- case 'todo':
- fn = 'getOpenTodo';break;
- case 'end':
- fn = 'getOpenEnd';break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- // 'tender.endDate': 'desc',
- // 'tender.enterprise.enName': 'asc',
- // 'tender.code': 'asc'
- }
- }, {
- total : 0,
- counts: [10, 25, 50, 100],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- // var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- // AccountEnterprise.get({}, function(data){
- // $scope.loading = false;
- // $scope.currentEn = data;
- // });
- PurchaseInquiry.publicInquiryItem.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.toDetail = function(id) {
- window.location.hash = '#/baseInfo/inquiryList/' + id;
- };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 公共询价详情
- */
- app.controller('PublicInquiryListDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry','$filter', 'toaster', 'BaseService', 'ngTableParams', 'AccountEnterprise', function($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, AccountEnterprise) {
- BaseService.scrollBackToTop();
- $scope.currentHasBid = false;
- var loadData = function() {
- PurchaseInquiry.inquiryItemDetail({id: $stateParams.id}, function(data) {
- $scope.inquiryItem = data.inquiryItem;
- if(data.id) {
- $scope.id = data.id;
- console.log($scope.id);
- $scope.currentHasBid = true;
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- loadData();
-
- // 当前时间
- $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
-
- // 当前企业
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.enterprise = data;
- });
-
- // 转客户询价
- $scope.transtoInquiry = function(id) {
- PurchaseInquiry.transtoInquiry({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- window.location.hash = "sale/inquiry/" + data.id;
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.info) {
- toaster.pop('info', '提示', data.info);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 询价单明细
- app.controller('PurcInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry','$filter', 'toaster', function($scope, $stateParams, PurcInquiry,$filter, toaster){
- var loadData = function() {
- PurcInquiry.getAll({id: $stateParams.id}, function(data){
- $scope.newinquiryItems = data;
- var inquiry = data[0].inquiry;
- //inquiry.inquiryItems = data;
- angular.forEach(inquiry.attachs, function(attach){
- attach.type = attach.name.substr(attach.name.lastIndexOf('.')+1);
- });
- $scope.inquiry = inquiry;
- });
- };
- loadData();
- $scope.getMinDate = function(item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
-
- $scope.addStep = function(inquiryItem) {
- if(inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
-
- $scope.removeStep = function(inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.getHistory = function(item) {
- if(!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function(data){
- item.history = data;
- });
- }
- };
-
- $scope.isValid = function(item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if(!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function(r, i){
- bool = (i > 0 ? r.lapQty : 1) && r.price;
- });
- return bool;
- };
-
- $scope.onReplyClick = function(item, withSteps) {
- if(item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if(item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if(item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- angular.forEach(item.replies, function(r, i){
- if((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- if(withSteps) {
- PurcInquiry.reply({itemId: item.id}, item, function(){
- toaster.pop('info', '提示', '报价成功');
- loadData();
- }, function(response){
- toaster.pop('error', '报价失败', response.data);
- });
- }
- };
- }]);
-
- // 询价单明细(发出)
- app.controller('PurcInquiryInfoDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry','$filter', 'toaster', function($scope, $stateParams, PurchaseInquiry,$filter, toaster){
- var loadData = function() {
- PurchaseInquiry.detail({id: $stateParams.id}, function(data){
- $scope.inquiry = data;
- });
- };
- 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);
- });
- }
- };
-
- // 采纳
- $scope.accept = function(id) {
- PurchaseInquiry.accept({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
-
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- };
-
- // 拒绝
- $scope.refuse = function(id) {
- PurchaseInquiry.refuse({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
-
-
- // 模具询价管理
- app.controller('SaleInquiryMouldCtrl',['$scope', '$filter', 'PurcInquiryMould', 'ngTableParams', 'toaster', 'BaseService', '$upload', function($scope, $filter, PurcInquiryMould, ngTableParams, toaster, BaseService, $upload){
- BaseService.scrollBackToTop();
- /**
- * 改变单据日期范围
- */
- var getTenderDateCondition = 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 if (zone == -6) { // 半年前
- date.setMonth(date.getMonth() - 6);
- condition.dateFrom = null;
- condition.dateTo = date;
- } else { // 无效zone,转为查找全部
- condition.dateFrom = null;
- condition.dateTo = null;
- }
- };
- $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 = zone == -6 ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- $scope.condition.dateZone = zone;
- getTenderDateCondition(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 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.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- // 用来验证价格修改
- var mould = page.content;
- inquiryMould_copy = angular.copy(mould);
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.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;
- });
- }
- };
-
- $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){
- }).error(function(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();
- };
- $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();
- };
-
- }]);
-
-
- // 模具询价单明细
- 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;
- });
- }
- };
-
-
- $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', '$rootScope', function($scope, $filter, Quotation, PurcInquiry, ngTableParams, toaster, BaseService, $rootScope){
- BaseService.scrollBackToTop();
- $rootScope.enteryStatus = false;
- $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 : 20,
- 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', 'VendorInfo', '$rootScope', function($scope, $stateParams, $filter, ngTableParams, toaster, BaseService, $modal, Quotation, VendorInfo, $rootScope){
- BaseService.scrollBackToTop();
- var staticItem = null;
-
- if( ! angular.isUndefined($stateParams.id)) {// 查看模式
- $scope.loading = true;
- $rootScope.enteryStatus = true;
- Quotation.getItem({id: $stateParams.id}, function(data){
- // data.$editing = false;
- $scope.item = data;
- $scope.item.$editing = true; // 取消要点击修改才可以编辑的交互
- staticItem = angular.copy(data);
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- } else {// 新增模式
- $rootScope.enteryStatus = false;
- $scope.item = {
- quotation: {
- currency: 'RMB',
- taxrate: 17,
- 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(){
-
- });
- }
- };
-
- // 赋值客户信息
- if($rootScope.custuu) {
- VendorInfo.customerInfo({custuu: $rootScope.custuu}, {}, function(data) {
- $scope.item.quotation.cust = data.myEnterprise;
- $scope.item.quotation.custUser = data.myUser;
- })
- }
-
- // 赋值物料信息
- if($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function(data) {
- $scope.item.product.code = data.code;
- $scope.item.product.title = data.title;
- $scope.item.product.spec = data.spec;
- $scope.item.product.unit = data.unit;
- $scope.item.product.id = data.id;
- }, function(response) {
-
- });
- }
- // 查找客户物料
- $scope.dbfindCustProd = function(){
- if($scope.item.$editing) {
- if($scope.item.quotation.cust.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);
- });
- };
-
- $scope.deleteById = function(id) {
- Quotation.deleteById({id: id}, {}, function(data) {
- window.location.href = "#/sale/quotation/list";
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
-
- // 查找客户
- app.controller('DbfindCustCtrl', ['$scope', 'Customer', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function($scope, Customer, BaseService, ngTableParams, toaster, $modalInstance){
- BaseService.scrollBackToTop();
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Customer.get(BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- $scope.check = function(cust){
- $modalInstance.close(cust);
- };
- }]);
-
- // 查找客户物料
- app.controller('DbfindCustProdCtrl', ['$scope', 'Product', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'custUU', function($scope, Product, BaseService, ngTableParams, toaster, $modalInstance, custUU){
- BaseService.scrollBackToTop();
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.custUU = custUU;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- // 选择
- $scope.check = function(cust){
- $modalInstance.close(cust);
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 查找供应商
- app.controller('DbfindVendorCtrl', ['$scope', 'Vendor', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance','$rootScope', function($scope, Vendor, BaseService, ngTableParams, toaster, $modalInstance, $rootScope){
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [10, 25, 50, 100],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // 添加供应商时,将已存在的选中
- if ($rootScope.tenderVendor) {
- angular.forEach(page.content, function(vendor) {
- for (var i = 0; i<$rootScope.tenderVendor.length; i++) {
- vendor.checked = false;
- if (vendor.vendorEnterprise.enName == $rootScope.tenderVendor[i].enName) {
- vendor.checked = true;
- break;
- }
- }
- });
- }
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- $scope.checks = {
- checked : false
- };// 全选框
- $scope.checkAll = function() {
- angular.forEach($scope.tableParams.data, function(vendor) {
- vendor.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function(vendor) {
- vendor.checked = true;
- var checked = true;
- angular.forEach($scope.tableParams.data, function(message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- // 单反选
- $scope.unCheckOne = function(vendor) {
- vendor.checked = false;
- $scope.checks.checked = false;
- };
- $scope.close = function(){
- var vendors = [];
- angular.forEach($scope.tableParams.data, function(vendor) {
- if(vendor.checked) {
- vendors.push(vendor);
- $modalInstance.close(vendors);
- }
- });
- };
- }]);
-
- // 发货提醒
- app.controller('SaleNoticeCtrl', ['$scope', '$rootScope', '$filter', 'PurcNotice', 'ngTableParams', 'toaster', 'BaseService', 'PurcNoticeHis', '$modal', 'SaleTruck', 'Symbol', '$state', function($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, PurcNoticeHis, $modal, SaleTruck, Symbol, $state){
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return $scope.condition.dateZone ? PurcNotice : PurcNoticeHis;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- 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' , 'ReportService', function($scope, $filter, SaleSend, ngTableParams, toaster, BaseService, Symbol, ReportService){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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 : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //打印 发货单
- $scope.print = function(send) {
- SaleSend.printCount({id: send.id},{}); //增加打印此次
- ReportService.print(send.custUU, 'SALESEND', "where sale$send.ss_id=" + send.id);
- };
-
- $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', '$modal', 'BaseService', function($scope, $stateParams, PurcSample, toaster, $modal, BaseService){
- BaseService.scrollBackToTop();
- var loading = true;
- var loadData = function() {
- PurcSample.get({id: $stateParams.id}, function(data){
- $scope.sample = data;
- if(!$scope.sample.sends){
- $scope.sample.getSendInfo = '加载中...';
- PurcSample.getSend({id: $stateParams.id}, function(sendData){
- if(sendData) {
- $scope.sample.getSendInfo = null;
- $scope.sample.sends = sendData;
- } else {
- $scope.sample.getSendInfo = '无送样信息';
- $scope.sample.sends = '无送样信息';
- }
- }, function(response){
- $scope.sample.getSendInfo = '加载失败!';
- });
- }
- $scope.loading = false;
- }, function(response){
- loading = false;
- toaster.pop('error', '获取数据失败', response.data);
- });
- };
- loadData();
- $scope.openSend = function(index, sample) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sample_send.html',
- controller: 'SampleSendCtrl',
- resolve: {
- sampleItem: function(){return sample;}
- }
- });
- modalInstance.result.then(function(){
- toaster.pop('info', '提示', '送样成功');
- $scope.tableParams.reload();
- }, function(){
- });
- };
- }]);
-
- /**
- * 客户打样申请
- */
- app.controller('SaleSampleCtrl', ['$scope', '$filter', 'PurcSample', 'ngTableParams', 'toaster', '$modal', 'BaseService','ReportService', 'Symbol', '$rootScope', function($scope, $filter, PurcSample, ngTableParams, toaster, $modal, BaseService,ReportService, Symbol, $rootScope){
- BaseService.scrollBackToTop();
- if($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $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 : 20,
- 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);//保存当前取值的关键词
- // angular.forEach(page.content, 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 = '加载失败!';
- // });
- // }
- // });
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.openSend = function(index, sample) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sample_send.html',
- controller: 'SampleSendCtrl',
- resolve: {
- sampleItem: function(){return sample;}
- }
- });
-
- modalInstance.result.then(function(){
- toaster.pop('info', '提示', '送样成功');
- $scope.tableParams.reload();
- }, function(){
-
- });
- };
- //打印 样品采购单
- $scope.print = function(sample) {
- PurcSample.printCount({id: sample.id},{});//增加打印此次
- ReportService.print(sample.proofing.enUU, 'PURCPROOFING',"where purc$proofingitems.ppi_id =" + sample.id);
- };
-
- $scope.getSend = function(proofing){
- if( !proofing.sends) {
- proofing.getSendInfo = '加载中...';
- PurcSample.getSend({id: proofing.id}, function(data){
- if(data) {
- proofing.getSendInfo = null;
- proofing.sends = data;
- } else {
- proofing.getSendInfo = '无送样信息';
- proofing.sends = '无送样信息';
- }
- }, function(response){
- proofing.getSendInfo = '加载失败!';
- });
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- app.controller('SampleSendCtrl', ['$scope', '$modalInstance', 'sampleItem', 'PurcSample', '$upload', 'toaster', function($scope, $modalInstance, sampleItem, PurcSample, $upload, toaster){
- if( !sampleItem.sends) {
- PurcSample.getSend({id: sampleItem.id}, function(data){
- if(data) {
- sampleItem.sends = data; // 获取送样信息
- angular.forEach(data, function(send) {
- sampleItem.sendQty = send.sendQty + (sampleItem.sendQty || 0);
- });
- }
- }, function(response){
- });
- }
- $scope.sampleItem = sampleItem;
- $scope.sampleItem.sampleSend = $scope.sampleItem.sampleSend || {};
-
- //确认送样
- $scope.ok = function (form) {
- $scope.loading = true;
- // 多次送样时,由于ng-model是sendQty,所以需要加上送样历史中的数量
- $scope.sampleItem.sampleSend.sendQty = $scope.sampleItem.sampleSend.sendQty + ($scope.sampleItem.sendQty || 0);
- $scope.sampleItem.sendQty = $scope.sampleItem.sampleSend.sendQty; // 判断是否需要多次送样
- var files = form.attachFile.$viewValue, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'sale/sample/' + $scope.sampleItem.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.sampleItem.sampleSend
- }
- }).success(function(data){
- $scope.loading = false;
- $modalInstance.close('success');
- }).error(function(data){
- $scope.loading = false;
- toaster.pop('danger', '错误', data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss(sampleItem);
- };
- }]);
-
- /**
- * 客户认定单
- */
- app.controller('SaleApprovalCtrl', ['$scope', '$filter', 'PurcApproval', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcApproval, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcApproval;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- inDate: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 客户采购预测
- */
- app.controller('SaleForecastCtrl', ['$scope', '$filter', 'PurcForecast', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcForecast, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcForecast;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- orderDate: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户采购验收
- */
- app.controller('SaleAcceptCtrl', ['$scope', '$filter', 'PurcAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcAccept, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1, deliveryZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function(zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
-
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcAccept;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.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('SaleAcceptDetailCtrl', ['$scope', 'PurcAccept', 'toaster', 'BaseService', '$stateParams', function($scope, PurcAccept, toaster, BaseService, $stateParams){
- BaseService.scrollBackToTop();
- if($stateParams.id) {
- PurcAccept.getDetail({id: $stateParams.id}, {}, function(data) {
- $scope.accept= data;
- if($scope.accept.acceptItems != null) {
- var sum = 0;
- angular.forEach($scope.accept.acceptItems, function(item) {
- sum += item.orderPrice * item.qty;
- });
- $scope.totalPrice = sum;
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 客户采购验退
- */
- app.controller('SaleReturnsCtrl', ['$scope', '$filter', 'PurcReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcReturn, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcReturn;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- 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('SaleReturnsDetailCtrl', ['$scope', 'PurcReturn', 'toaster', 'BaseService', '$stateParams', function($scope, PurcReturn, toaster, BaseService, $stateParams){
- BaseService.scrollBackToTop();
- if($stateParams.id != null) {
- PurcReturn.getDetail({id: $stateParams.id}, {}, function(data) {
- $scope.returns = data;
- if($scope.returns.returnItems != null) {
- var sum = 0;
- angular.forEach($scope.returns.returnItems, function(item) {
- sum += item.orderPrice * item.qty;
- });
- $scope.totalPrice = sum;
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 客户不良品入库
- */
- app.controller('SaleBadInCtrl', ['$scope', '$filter', 'PurcBadIn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcBadIn, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcBadIn;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户不良品出库
- */
- app.controller('SaleBadOutCtrl', ['$scope', '$filter', 'PurcBadOut', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcBadOut, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcBadOut;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户MRB
- */
- app.controller('SaleMRBCtrl', ['$scope', '$filter', 'PurcMRB', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, PurcMRB, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcMRB;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户应付发票
- */
- app.controller('SaleApBillCtrl', ['$scope', '$filter', 'FaApBill', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, FaApBill, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return FaApBill;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.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('SaleApBillDetailCtrl', ['$scope', '$filter', 'FaApBill', 'toaster', '$stateParams', 'BaseService', function($scope, $filter, FaApBill, toaster, $stateParams, BaseService){
- BaseService.scrollBackToTop();
- var loadData = function() {
- FaApBill.get({id: $stateParams.id}, function(data){
- $scope.bill = data;
- console.log(data);
- $scope.loading = false;
- });
- };
- loadData(); // 初始获取单据数据
- }]);
-
- /**
- * 应付对账单
- */
- app.controller('SaleArCheckCtrl', ['$scope', '$filter', 'FaArCheck', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, FaArCheck, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $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 : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
-
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 计算单据的商品总数
- $scope.getTotalProd = function(check) {
- var total = 0;
- if(check.items) {
- angular.forEach(check.items, function(value) {
- total += value.qty;
- });
- }
- return total;
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- // 应付对账单详情页
- app.controller('SaleArCheckDetailCtrl', ['$scope', '$stateParams', 'FaArCheck', 'toaster', '$state', 'BaseService', function($scope, $stateParams, FaArCheck, toaster, $state, BaseService){
- BaseService.scrollBackToTop();
- var loadData = function() {
- FaArCheck.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- $scope.loading = false;
- });
- };
- loadData(); // 初始获取单据数据
-
- $scope.onReplyClick = function(item, isAgreed) {
- if(isAgreed) {// 同意确认
- FaArCheck.agree({itemId: item.id}, {}, function(data){
- toaster.pop('success', '确认成功', '确认供应商对账数量成功');
- }, function(response){
- toaster.pop('danger', '确认失败', response.data);
- });
- } else {// 不同意回复
- FaArCheck.disagree({itemId: item.id}, {qty: item.$replyQty, remark: item.$replyRemark}, function(data) {
- toaster.pop('success', '确认成功', '您提交的数量将发送给供应商确认');
- }, function(response) {
- toaster.pop('danger', '确认失败', response.data);
- });
- }
- };
-
- // 获取明细的回复记录
- $scope.getReplies = function(item) {
- if(!item.replies) {
- FaArCheck.getReplies({itemId: item.id}, function(data) {
- item.replies = data;
- }, function(response) {
- toaster.pop('danger', '获取对账记录失败', response.data);
- });
- }
- };
-
- }]);
- //应收对账单列表
- app.controller('PurchaseApCheckCtrl',['$scope', 'FaApCheck', 'BaseService', 'ngTableParams', 'toaster','ReportService', 'Symbol', function($scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService , Symbol){
- BaseService.scrollBackToTop();
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'todo';
-
- //打印 对账单
- $scope.print = function(check) {
- FaApCheck.printCount({id: check.id},{});//增加打印此次
- ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id);
- };
-
- //状态
- $scope.setActive = function (state){
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- //获取应收对账单全部
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- recordDate: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- FaApCheck[getState($scope.active )](BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.data = $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 计算单据的商品总数
- $scope.getTotalProd = function(check) {
- var total = 0;
- if(check.items) {
- angular.forEach(check.items, function(value) {
- total += value.checkQty;
- });
- }
- return total;
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- //应收对账单详情
- app.controller('PurchaseApCheckDetailCtrl',['$scope','toaster','FaApCheck','$stateParams', 'BaseService', function($scope, toaster, FaApCheck, $stateParams, BaseService) {
- BaseService.scrollBackToTop();
- $scope.haveSelected = true;
- $scope.data = {};
- //控制提交和删除按钮的显示
- $scope.ifShow = true;
- var loadData = function(){
- FaApCheck.get({id:$stateParams.id},function(data){
- $scope.data = data;
- if($scope.data.status){
-
- }else{
- $scope.ifShow = true;
- }
- })
- };
-
- if($stateParams.id){
- loadData();
- }
-
-
- $scope.haveSource = false;
- //提交应收对账单
- $scope.submitApCheck = function(){
- FaApCheck.updateStatus({id:$stateParams.id},function(data){
- if(data.result) {
- toaster.pop('success', '提示', '提交成功');
- $scope.haveSelected = false;
- window.location.href = '#/fa/apCheck';
- }else {
- $scope.haveSource = true;
- loadData();
- toaster.pop('error', '提示', '单据被反过账,请立即作废本单据');
- $scope.haveSelected = true;
- }
- },function(){
- $scope.loading = false;
- toaster.pop('error', '提示', '更新已转数失败');
- });
- }
-
- //删除应收对账单的同时更新来源表已转数
- var updateYCheckQty = function(){
- var sourceInfos = [];
- angular.forEach($scope.data.items, function(item){
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newYCheckQty: ''
- };
- $scope.sourceInfo.sourceId = item.sourceId;
- $scope.sourceInfo.sourceTable = item.sourceTable;
- $scope.sourceInfo.newYCheckQty = item.oldYCheckQty;
- sourceInfos.push($scope.sourceInfo);
- });
- FaApCheck.update({}, sourceInfos, function(){
-
- },function(response){
- $scope.loading = false;
- toaster.pop('error', '更新已转数失败', response.data);
- });
-
- }
- //删除应收对账单
- $scope.deleteApCheck = function(){
- FaApCheck.deleteApCheck({id:$stateParams.id},function(data){
- updateYCheckQty();
- toaster.pop('success','提示','删除成功');
- },function(){
- toaster.pop('error','提示','删除失败');
- });
- $scope.haveSelected = false;
- }
- //作废应收对账单
- $scope.cancelApCheck = function(check) {
- FaApCheck.cancel({id:check.id},function(data){
- $scope.checkResult = false;
- if(data.result) {
- $scope.checkResult = true;
- toaster.pop('success', '提示', '作废成功');
- $scope.tableParams.reload();
- }else{
- toaster.pop('error', '提示', '作废失败');
- }
- },function(){
- $scope.loading = false;
- toaster.pop('error', '提示', '作废失败');
- });
-
- }
-
- }]);
-
- //未对账单据列表
- app.controller('PurchaseApCheckListCtrl',['$scope', 'FaApCheck', 'toaster', '$state','$filter', '$modal', function($scope, FaApCheck, toaster, $state, $filter, $modal){
- $scope.data = [];// 列表数据
-
- $scope.condition = {
- $fromOpened: false
- }
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
-
- //查找客户
- $scope.searchCust = function(suuorname) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/fa/custInfo.html',
- controller: 'SearchCustInfoCtrl',
- resolve: {
- suuorname: function() {
- return suuorname;
- }
- }
- });
- modalInstance.result.then(function(suuorname){
- $scope.suuorname = suuorname;
- });
-
- }
-
- // 点击筛选根据条件选择数据
- $scope.suuorname = '';
- // 默认本月
- $scope.sdateTo = new Date();
- $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
- $scope.vuuorname = '';
- $scope.factory = '';
- $scope.prodTitle = '';
- $scope.prodSpec = '';
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodTitle = '';
- $scope.condition.prodSpec = '';
-
- $scope.searchOrder = function(check) {
- $scope.data = [];
- $scope.checkboxes.checked = false;
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory
- $scope.condition.prodTitle = $scope.prodTitle;
- $scope.condition.prodSpec = $scope.prodSpec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf() + 3600 * 12 * 1000) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- if($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
-
- $scope.fromDate =$scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.keywordXls = angular.copy(($scope.condition.uuorname == null ? "" : $scope.condition.uuorname)
- + "|"+ ($scope.condition.venduuorname == null ? "" : $scope.condition.venduuorname)
- + "|"+ ($scope.condition.factory == null ? "" : $scope.condition.factory)
- + "|"+ ($scope.condition.prodTitle == null ? "" : $scope.condition.prodTitle)
- + "|"+ ($scope.condition.prodSpec == null ? "" : $scope.condition.prodSpec));//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if(!$scope.suuorname) {
- toaster.pop('warning','提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- $scope.loading = true;
- FaApCheck.getAllByKeywords({fromDate: $scope.fromDate, endDate: $scope.endDate, keyword:$scope.keywordXls}, function(data) {
- if(data.length > 0) {
- angular.forEach(data, function(item) {
- item.$selected = true;
- });
- $scope.data = data;
- $scope.checkboxes.checked = true;
- $scope.getTotalMoney();
- } else {
- toaster.pop('info', '提示', '当前没有需要对账记录');
- }
- $scope.loading = false;
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
-
- }
-
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.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('PurchaseAdjustListCtrl',['$scope', 'FaApCheck', 'toaster', '$state','$filter', '$modal', 'ApbillAdjustment', function($scope, FaApCheck, toaster, $state, $filter, $modal, ApbillAdjustment){
- $scope.data = [];// 列表数据
-
- $scope.condition = {
- $fromOpened: false
- }
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
-
- //查找客户
- $scope.searchCust = function(suuorname) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/fa/custInfo.html',
- controller: 'SearchCustInfoCtrl',
- resolve: {
- suuorname: function() {
- return suuorname;
- }
- }
- });
- modalInstance.result.then(function(suuorname){
- $scope.suuorname = suuorname;
- });
-
- }
-
- // 点击筛选根据条件选择数据
- $scope.suuorname = '';
- // 默认本月
- $scope.sdateTo = new Date();
- $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
- $scope.vuuorname = '';
- $scope.factory = '';
- $scope.prodTitle = '';
- $scope.prodSpec = '';
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodTitle = '';
- $scope.condition.prodSpec = '';
-
- $scope.searchOrder = function(check) {
- $scope.data = [];
- $scope.checkboxes.checked = false;
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory
- $scope.condition.prodTitle = $scope.prodTitle;
- $scope.condition.prodSpec = $scope.prodSpec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf() + 3600 * 12 * 1000) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- if($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
-
- $scope.fromDate =$scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.keywordXls = angular.copy(($scope.condition.uuorname == null ? "" : $scope.condition.uuorname)
- + "|"+ ($scope.condition.venduuorname == null ? "" : $scope.condition.venduuorname)
- + "|"+ ($scope.condition.factory == null ? "" : $scope.condition.factory)
- + "|"+ ($scope.condition.prodTitle == null ? "" : $scope.condition.prodTitle)
- + "|"+ ($scope.condition.prodSpec == null ? "" : $scope.condition.prodSpec));//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if(!$scope.suuorname) {
- toaster.pop('warning','提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- $scope.loading = true;
- ApbillAdjustment.adjustList({fromDate: $scope.fromDate, endDate: $scope.endDate, keyword:$scope.keywordXls}, function(data) {
- if(data.length > 0) {
- angular.forEach(data, function(item) {
- item.$selected = true;
- });
- $scope.data = data;
- $scope.checkboxes.checked = true;
- $scope.getTotalMoney();
- } else {
- toaster.pop('info', '提示', '当前没有需要对账记录');
- }
- $scope.loading = false;
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
-
- }
-
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.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.orderdate >= dateFrom || dateFrom == '') && (item.orderdate < 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.date;
- $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.date;
- }else{
- $scope.apCheck.beginDate = $scope.apCheck.beginDate>check.piDate? check.orderdate : $scope.apCheck.beginDate;
- }
-
- //获取最大时间作为对账区间的截止时间
- if($scope.apCheck.endDate == ''){
- $scope.apCheck.endDate = check.date;
- }else{
- $scope.apCheck.endDate = $scope.apCheck.endDate<check.piDate? check.orderdate : $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.id;
- $scope.item.sourceTable = 'purc$apbilladjustment';
- $scope.item.orderClass = '货款调账';
- $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.id;
- $scope.sourceInfo.sourceTable = 'purc$apbilladjustment';
- $scope.sourceInfo.newYCheckQty = ((check.ycheckqty || 0) + check.thischeckqty);
-
- sourceInfos.push($scope.sourceInfo);
- $scope.apCheck.items.push($scope.item);
- $scope.haveSelected = true;
- }
- });
-
- //保存生成的应收对账单
- $scope.saveApCheck = function(){
- FaApCheck.saveApCheck({}, $scope.apCheck, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '生成应收对账成功');
- $state.go('fa.apCheck_detail', {id: data.id}, {reload:true});
- }, function(response){
- toaster.pop('error', '生成对账单失败', response.data);
- })
- };
-
- //如果是同一家客户,生成对账单的同时,关闭模态框
- if($scope.sameCust && $scope.validQty) {
- $scope.saveApCheck();
- }
-
- }
- }]);
- // 企业信息设置
- app.controller('EnterpriseCtrl', ['$scope', 'AccountEnterprise', 'toaster', '$state', '$modal', 'BaseService', 'ShipAddress', '$http', 'DeputyOrder', function($scope, AccountEnterprise, toaster, $state, $modal, BaseService, ShipAddress, $http, DeputyOrder){
- BaseService.scrollBackToTop();
- $scope.loading = true;
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.enterprise = data;
-
- // 获取付款企业信息
- DeputyOrder.paycompanies({enuu: $scope.enterprise.uu}, {}, function(data) {
- $scope.pays = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- AccountEnterprise.growth({}, function(data){
- if(data != null && data.length > 0) {
- var growth = [], years = [];
- angular.forEach(data, function(d){
- var date = new Date(d.date), year = date.getFullYear();
- d.date = (date.getMonth() + 1) + '月' + (date.getDate()) + '日';
- if(years.indexOf(year) == -1) {
- years.push(year);
- growth.push({year: year});
- }
- growth.push(d);
- });
- $scope.growth = growth;
- }
- });
-
- // 更新企业信息
- $scope.updateDetailInfo = function(){
- $scope.loading = true;
- AccountEnterprise.save($scope.enterprise, function(){
- $scope.loading = false;
- $scope.connectionEditing = false;
- toaster.pop('success', '提示', '修改企业信息成功');
- $state.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '修改信息失败', response.data);
- });
- };
-
- // 申请Saas
- $scope.applySaas = function(){
- if($scope.enterprise.enUrl && $scope.enterprise.enAddress && $scope.enterprise.enIndustry) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/applySaas.html',
- controller: 'ApplySaasCtrl',
- resolve: {
- enterprise: function(){return angular.copy($scope.enterprise);}
- }
- });
-
- modalInstance.result.then(function(){
- $state.reload();
- }, function(){
- });
- } else {
- toaster.pop('info', '请完善信息', '申请优企云服请先完善企业详细信息');
- }
- };
-
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- });
-
- // 判断是否是代采企业
- DeputyOrder.isDeputyEnterprise({}, function(data) {
- $scope.deputyEnter = data;
- });
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
-
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- });
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
-
- // 删除收货地址
- $scope.removeShip = function(id, index) {
- ShipAddress.removeShipAddress({id: id}, {}, function(data) {
- $scope.ships.splice(index, 1);
- toaster.pop('success', '提示', '收货地址删除成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- // 编辑收货地址
- $scope.editShip = function(ship){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/shipaddress_modal.html',
- controller: 'ShipAddressCtrl',
- resolve: {
- ship: function(){return ship;}
- }
- });
-
- modalInstance.result.then(function() {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- });
- }, function(){
- });
- };
-
- // 新增付款企业
- $scope.addPayCompany = function() {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/paycompany_modal.html',
- controller: 'PayCompanyCtrl',
- resolve: {
- pay: function(){return null;}
- }
- });
-
- modalInstance.result.then(function() {
- DeputyOrder.paycompanies({enuu: uu}, {}, function(data) {
- $scope.pays = data;
- // 获取付款企业信息
- DeputyOrder.paycompanies({enuu: $scope.enterprise.uu}, {}, function(data) {
- $scope.pays = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function(){
- });
- }
-
- // 删除付款企业
- $scope.removePay = function(id, index) {
- DeputyOrder.removePayCompany({id: id}, {}, function(data) {
- $scope.pays.splice(index, 1);
- toaster.pop('success', '提示', '付款企业信息删除成功');
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- // 编辑付款企业
- $scope.editPay = function(pay, uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/paycompany_modal.html',
- controller: 'PayCompanyCtrl',
- resolve: {
- pay: function(){return pay;}
- }
- });
-
- modalInstance.result.then(function() {
- DeputyOrder.paycompanies({enuu: uu}, {}, function(data) {
- $scope.pays = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function(){
- });
- };
-
- // 设置logo
- $scope.showImageDialog = function(modal) {
- require([ 'jquery-uploadify' ], function() {
- $modal.open({
- templateUrl : 'static/tpl/index/home/insert.html',
- controller : 'ImageInsertCtrl',
- backdrop : 'static'
- }).result.then(function(image){
- $scope.imageUrl = image.thumb;
- User.postImageUrl(null, angular.toJson($scope.imageUrl), function(data){
- $scope.user = data;
- }, function(response) {
- toaster.pop('error', '设置图像失败,' + response.data);
- });
-
- });
- });
- }
-
- }]);
-
- // 编辑收货地址
- app.controller('ShipAddressCtrl', ['$scope', 'ShipAddress', 'ship', '$modalInstance', 'toaster', '$http', function($scope, ShipAddress, ship, $modalInstance, toaster, $http) {
- $scope.ship = ship;
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
-
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $modalInstance.close();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- // 编辑付款企业信息
- app.controller('PayCompanyCtrl', ['$scope', 'DeputyOrder', 'pay', '$modalInstance', 'toaster', '$http', function($scope, DeputyOrder, pay, $modalInstance, toaster, $http) {
- $scope.pay = pay;
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
-
- // 新增收货地址保存
- $scope.savePayCompany = function(pay) {
- pay.address = pay.province + pay.city + pay.district + pay.addressdet;
- DeputyOrder.savePaycompany( {}, pay, function(data) {
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.dismiss();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- // 申请Saas Controller
- app.controller('ApplySaasCtrl', ['$scope', '$modalInstance', 'enterprise', 'AccountEnterprise', 'toaster', '$http', function($scope, $modalInstance, enterprise, AccountEnterprise, toaster, $http){
- $scope.enterprise = enterprise;
- $scope.checking = false;
-
- $scope.$watch('enterprise.enSaasUrl', function(){
- if($scope.enterprise.enSaasUrl) {
- $http.get('signup/saasUrlEnable', {
- params: {
- enSaasUrl: $scope.enterprise.enSaasUrl
- }
- }).success(function(data){
- if(data && data == 'true') {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', true);
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '优企云服域名已被使用';
- }
- }).error(function(){
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '验证出错';
- });
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- }
- });
-
- var setSaasUrl = function(url) {
- var index = url.indexOf('www.');
- if(index != -1) {//包含www.
- var substr = url.substring(index+4, url.length);
- $scope.enterprise.enSaasUrl = substr.substring(0, substr.indexOf('.'));
- } else {
- $scope.enterprise.enSaasUrl = getHost(url);
- }
- };
-
- // 解析获取网址的一级域名
- var getHost = function(host){
- var newhost;
- var domain;
- var ArrDomain = new Array('.com.cn','.net.cn','.org.cn','.gov.cn','.com','.cn','.tel','.mobi','.net','.org','.asia','.me','.cc','.name','.info');//枚举所有后缀
- for(var k in ArrDomain){
- var re = eval('/\\' + ArrDomain[k] + '$/g');
- newhost = host.replace(re, '');
- if(newhost != host){
- domain = ArrDomain[k];
- break;
- }
- }
- var hostar = newhost.split('.');
- var s = hostar[hostar.length-1];
- return s;
- };
-
- // 设置优企云服域名为官网网址一级域名
- if($scope.enterprise.enUrl) setSaasUrl($scope.enterprise.enUrl);
-
- $scope.apply = function(){
- $scope.loading = true;
- AccountEnterprise.applySaas({
- enUU: $scope.enterprise.uu,
- enSaasUrl: $scope.enterprise.enSaasUrl,
- enAdminPassword: $scope.enterprise.enAdminPassword
- }, {}, function(){
- $scope.loading = false;
- toaster.pop('success', '申请成功', '已提交系统开通优企云服,开通后将会发送邮件至管理员邮箱');
- $modalInstance.close();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '申请失败', response.data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
-
- }]);
-
- app.controller('UserCtrl', ['$scope', '$filter', 'AuthenticationService', 'AccountUser', 'BaseService', 'ngTableParams', 'toaster', '$modal', '$http', 'ngAlert', 'AccountEnterprise', function($scope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http, ngAlert, AccountEnterprise){
- BaseService.scrollBackToTop();
- $scope.editing = false;
- $scope.loading = true;
- $scope.enterprise = null;
- AccountUser.findDistribute({},function(data) {
- $scope.distributes = data;
- },function(response) {
- toaster.pop('error', '系统错误', response.data);
- });
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- var users = [];
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- 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;
- angular.forEach(users, function(user) { // 从验证中获取到的用户信息,不包含身份证号。在这里赋值
- if (user.userTel === $scope.user.userTel && user.userUU === $scope.user.userUU) {
- $scope.user.userIdcode = user.userIdcode;
- }
- });
- $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;
- loadUsers();
- }, function(){
-
- });
- };
-
-
-
- /**
- * 添加未注册用户
- */
- $scope.addUser = function() {
- $scope.adding = true;
- AccountUser.save({}, $scope.newUser, function(){
- toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
- $scope.newUser = {userSex: 'M'};
- loadUsers();
- $scope.adding = false;
- $scope.newUserForm.newUserTel.$setValidity('available', false);
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- $scope.userEmailSuccess = false;
- $scope.userEmailError = false;
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- };
-
- /**
- * 验证手机号是否可用
- */
- $scope.telValid = function(tel) {
- if(tel) {
- $http.get('account/user/telEnable', {
- params: {
- tel: tel
- }
- }).success(function(data){
- data = eval(data);
- if(data == true) {
- $scope.newUserForm.newUserTel.$setValidity('available', true);
- $scope.userTelSuccess = true;
- $scope.userTelError = false;
- }else{
- $scope.newUserForm.newUserTel.$setValidity('available', false);
- $scope.userTelError = true;
- $scope.userTelSuccess = false;
- if(tel.length == 11)
- toaster.pop('error', '错误', '手机号 ' + tel + ' 已被注册');
- }
- }).error(function(){
- $scope.userTelSuccess = false;
- $scope.userTelError = true;
- });
- } else {
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- }
- };
-
- /**
- * 验证邮箱是否可用
- */
- $scope.emailValid = function(email) {
- if(email) {
- $http.get('account/user/emailEnable', {
- params: {
- email: email
- }
- }).success(function(data){
- data = eval(data);
- if(data == true) {
- $scope.newUserForm.newUserEmail.$setValidity('available', true);
- $scope.userEmailSuccess = true;
- $scope.userEmailError = false;
- } else {
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
- $scope.userEmailError = true;
- $scope.userEmailSuccess = false;
- }
- }).error(function(){
- $scope.userEmailError = true;
- $scope.userEmailSuccess = false;
- });
- } else {
- $scope.userEmailError = false;
- $scope.userEmailSuccess = false;
- }
- };
-
- /**
- * 删除用户
- */
- $scope.removeUser = function(user) {
- new ngAlert({
- title: '提示',
- content: '确定删除用户(' + user.userName + ')吗?'
- }, function(){
- AccountUser.remove({uu: user.userUU}, function(){
- toaster.pop('success', '提示', '用户删除成功。');
- loadUsers();
- }, function(response){
- toaster.pop('error', '删除失败', response.data);
- });
- });
- };
- // 编辑用户的角色
- $scope.editUserRole = function(user) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/user_role.html',
- controller: 'UserRoleCtrl',
- resolve: {
- user: function() {
- return user;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- };
- // 为用户分配角色(删除企业)
- $scope.removeVendor = function(user) {
- var resultRole = true;
- angular.forEach(user.roles,function(role){
- if(role.issys == 1) {
- toaster.pop('error', '提示', '管理员无需分配客户');
- resultRole = false;
- return;
- }
- })
- if(resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/remove_vendor.html',
- controller: 'RemoveVendorCtrl',
- resolve: {
- user: function() {
- return user;
- }
- }
- });
- }
- }
- // 为用户分配角色(添加企业)
- $scope.addVendor = function(user,isIssy) {
- if(!isIssy) {
- toaster.pop('error', '提示', '你不是管理员,无权限分配!请立即联系管理员');
- return;
- }
- var resultRole = true;
- angular.forEach(user.roles,function(role){
- if(role.issys == 1) {
- toaster.pop('error', '提示', '管理员无需分配客户');
- resultRole = false;
- return;
- }
- })
- if(resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_vendor.html',
- controller: 'AddVendorCtrl',
- resolve: {
- user: function() {
- return user;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- }
- };
- }]);
-
- // 登录手机号码验证
- app.controller('CheckTelCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'AuthenticationService', 'SendCheckMsg', 'SessionService', '$timeout', function($scope, $modalInstance, user, AccountUser, AuthenticationService, SendCheckMsg, SessionService, $timeout){
- $scope.user = user;
- $scope.cancel = function(){
- $modalInstance.close();
- }
- /*$scope.loading = false;
- $scope.btnState = false;
- $scope.clicks = 0;
- var storage = window.localStorage;
- //手机验证码定时器
- $scope.msgInfoError = false;
- var setBtnTimeDown = function(value) {
- if(value > 0) {
- $scope.btnState = true;
- $timeout(function() {
- $scope.$apply(function(){
- storage.setItem("btnTimes", $scope.btnTimes);
- $scope.btnTimes --;
- value --;
- setBtnTimeDown (value);
- });
- }, 500);
- }else{
- $scope.btnState = false;
- }
- };
- if(storage.btnTimes > 1){
- $scope.btnTimes = storage.btnTimes;
- setBtnTimeDown(storage.btnTimes)
- }else{
- storage.removeItem("btnTimes");
- }
- $scope.updateTel = function(phoneCode, userTel, uu){
- $scope.loading = true;
- $scope.msgInfoError = false;
- $scope.result = false;
- //更新联系方式
- AccountUser.updateWithCode({code: phoneCode, tel : userTel, uu: uu},{}, function(data){
- $scope.loading = false;
- $scope.msgInfoError2 = false;
- $scope.result = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $timeout(function(){
- $modalInstance.dismiss();
- window.location.reload();
- }, 1000);
- }).error(function(response) {
-
- });
- }, function(response){
- $scope.loading = false;
- $scope.msgInfoError2 = response;
- });
- };
- //获取验证码
- $scope.getPhoneCode = function(userTel){
- var timeInfo = 10;
- $scope.clicks ++;
- $scope.timeInfo = timeInfo;
- if($scope.clicks >= 5){
- $scope.errorloading = true;
- $scope.msgInfoSuccess = false;
- $scope.msgInfoError = false;
- }else{
- $scope.loading = true;
- SendCheckMsg.sendMsgInfos({userTel: userTel},function(data){
- $scope.loading = false;
- $scope.msgInfoSuccess = data.success;
- $scope.sendMsg = data;
- $scope.btnTimes = 60;
- setBtnTimeDown($scope.btnTimes);
- $scope.msgInfoError = false;
- },function(response){
- console.log(response);
- $scope.loading = false;
- $scope.msgInfoError = false;
- $scope.sendCheckMsg = false;
- $scope.msgInfoSuccess = true;
- });
- }
- }; */
- }]);
- app.controller('RemoveVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
- $scope.checkboxes = {
- checked : false
- };
- $scope.loading = true;
- AccountUser.findChooseVendor({uu : user.userUU},function(data) {
- $scope.enters = data;
- $scope.loading = false;
- angular.forEach($scope.enters, function(item) {
- item:{
- $selected:true;
- }
- });
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function() {
- angular.forEach($scope.enters, function(item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function(vendor){
- var result = true;
- angular.forEach($scope.enters, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function(save) {
- var chooseResult = [];
- if(save) {
- if(user.userUU) {
- angular.forEach($scope.enters, function(item, i) {
- if(item.$selected) {
- chooseResult.push(item.id);
- }
- });
- if(chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.removeChooseVendor({uu : user.userUU }, chooseResult,function(data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '删除成功');
- $modalInstance.close(false);
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '删除失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '删除失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
-
- app.controller('AddVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
- $scope.checkboxes = {
- checked : false
- };
- $scope.loading = true;
- AccountUser.findVendor({uu : user.userUU},function(data) {
- $scope.enters = data;
- $scope.loading = false;
- // angular.forEach($scope.enters, function(item) {
- // if(item.distribute) {
- // item:{
- // $selected:false;
- // }
- // } else {
- // item:{
- // $selected:true;
- // }
- // }
- // });
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function() {
- angular.forEach($scope.enters, function(item) {
- item.distribute = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function(vendor){
- var result = true;
- angular.forEach($scope.enters, function(item) {
- if(item.distribute != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function(save) {
- var chooseResult = [];
- if(save) {
- if(user.userUU) {
- angular.forEach($scope.enters, function(item, i) {
- // if(item.distribute) {
- chooseResult.push(item);
- // }
- });
- if(chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.addVendor({uu : user.userUU }, chooseResult,function(data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
-
- app.controller('UserRoleCtrl', ['$scope', '$modalInstance', 'user', 'AccountRole', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountRole, AccountUser, toaster){
- $scope.checked = [];
- $scope.master = [];
- AccountRole.query({}, function(data){
- if(user && data) {
- var rs = [], checked = [];
- angular.forEach(user.roles, function(r){
- rs.push(r.id);
- });
- angular.forEach(data, function(d){
- if(rs.indexOf(d.id) > -1) {
- d.$checked = true;
- checked.push(d);
- }
- });
- }
- $scope.roles = data;
- $scope.checked = checked;
- $scope.master = angular.copy($scope.checked);
- });
- $scope.select = function(role) {
- role.$checked = !role.$checked;
- if(role.$checked) {
- $scope.checked.push(role);
- } else {
- angular.forEach($scope.checked, function(c, i){
- if(c.id == role.id)
- $scope.checked.splice(i, 1);
- });
- }
- };
- $scope.isChanged = function() {
- return !angular.equals($scope.master, $scope.checked);
- };
- $scope.close = function(save) {
- if(save) {
- if(user.userUU) {
- user.roles = $scope.checked;
- AccountUser.update({}, user, function(){
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(true);
- }, function(response){
- toaster.pop('error', '保存失败', response.data);
- });
- } else {
- $modalInstance.close(true, $scope.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
-
- // 修改密码Controller
- app.controller('PasswordCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function($scope, $modalInstance, user, AccountUser, toaster){
- $scope.user = user;
- $scope.checking = false;
- //输入原密码后验证原密码是否正确
- $scope.checkPassword = function(password) {
- $scope.checking = true;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- AccountUser.checkPassword({password: password}, function(data){
- $scope.checkSuccess = true;
- $scope.checking = false;
- $scope.checkFailed = false;
- }, function(response){
- $scope.checkFailed = true;
- $scope.checking = false;
- $scope.checkSuccess = false;
- });
- };
-
- //修改密码
- $scope.ok = function () {
- if($scope.user.newPassword == $scope.user.newPassword1) {//验证重复密码相等
- AccountUser.updatePassword({password: $scope.user.password, newPassword: $scope.user.newPassword}, {}, function(data){
- var tip = '修改成功,请牢记您的新密码:' + $scope.user.newPassword;
- toaster.pop('success', '成功', tip);
- $scope.user.password = null;
- $scope.user.newPassword = null;
- $scope.user.newPassword1 = null;
- $scope.checking = false;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- $modalInstance.close();
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- } else {
- toaster.pop('error', '错误', '重复密码不一致');
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
-
- /*
- * 绑定用户到企业
- */
- app.controller('AddExistUserCtrl', ['$scope', '$modalInstance', 'FuzzySearch', 'AuthenticationService', '$timeout', 'toaster', function($scope, $modalInstance, FuzzySearch, AuthenticationService, $timeout, toaster){
- $scope.searching = false;
- //根据输入的内容查找用户
- $scope.searchUser = function(keyWord) {
- $scope.searching = true;
- $scope.searchSuccess = false;
- $scope.searchFailed = false;
- $scope.illegalError = false;
- $scope.reBindError = false;
- $scope.okDisabled = false;
- FuzzySearch.searchUser({keyWord : keyWord}, function(data){
- $scope.searchSuccess = true;
- $scope.searchFailed = false;
- $scope.user = data; //查询到的用户
- }, function(response){
- $scope.searchSuccess = false;
- $scope.searchFailed = true;
- });
- };
-
- //确认绑定
- $scope.ok = function (keyWord) {
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.currentUser = data; //当前登录的用户(管理员)
- //不可自己绑定自己
- if($scope.currentUser.userUU == $scope.user.userUU){
- $scope.illegalError = true;
- $scope.okDisabled = true;
- return false;
- }
-
- //用户未绑定到任何企业时
- if(!$scope.user.enterprises){
- //正常绑定
- FuzzySearch.bindUserToMyEnterprise({userUU : $scope.user.userUU}, function(data){
- $scope.okDisabled = true;
- toaster.pop("success", "提示", "用户绑定成功");
- $modalInstance.close(true);
- }, function(response){
- });
- return true;
- }
-
- //用户已绑定到某些企业时
- for(var i = 0; i < $scope.currentUser.enterprises.length; i++){
- if($scope.currentUser.enterprises[i].current){
- for(var j = 0; j < $scope.user.enterprises.length; j++){
- //该用户已绑定到当前企业,不可重复绑定
- if($scope.currentUser.enterprises[i].uu == $scope.user.enterprises[j].uu){
- $scope.reBindError = true;
- $scope.okDisabled = true;
- return false;
- }
- }
- //该用户未绑定到当前企业,可以进行绑定
- FuzzySearch.bindUserToMyEnterprise({userUU : $scope.user.userUU}, function(data){
- $scope.okDisabled = true;
- toaster.pop("success", "提示", "用户绑定成功");
- $modalInstance.close(true);
- }, function(response){
- console.log("绑定失败!");
- });
-
- }
- }
-
- });
- };
-
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
-
- app.controller('LogCtrl', ['$scope', 'BaseService', 'ngTableParams', 'ErpLog', 'UsageLog', function($scope, BaseService, ngTableParams, ErpLog, UsageLog){
- $scope.erpParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- time: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- ErpLog.get(BaseService.parseParams(params.url()), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.usageParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- time: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- UsageLog.get(BaseService.parseParams(params.url()), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
-
- app.controller('ResourceCtrl', ['$scope', 'AccountResource', function($scope, AccountResource){
- AccountResource.query({}, function(data){
- if(data && data.length > 0) {
- data[0].$open = true;
- }
- $scope.resources = data;
- });
- }]);
-
- app.controller('RoleCtrl', ['$scope', '$modal', 'AccountRole', function($scope, $modal, AccountRole){
- $scope.roles = {};
- var getData = function() {
- AccountRole.query({}, function(data){
- var defaults = [], custom = [];
- angular.forEach(data, function(d){
- if(d.isdefault == 1)
- defaults.push(d);
- else
- custom.push(d);
- });
- $scope.roles = {defaults: defaults, custom: custom};
- });
- };
- getData();
- $scope.editRole = function(role){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/role_detail.html',
- controller: 'RoleEditCtrl',
- resolve: {
- role: function() {
- return role;
- }
- }
- });
- modalInstance.result.then(function(added){
- added && (getData());
- });
- };
- }]);
-
- app.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'ngAlert', 'BaseService', function($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, ngAlert, BaseService){
- BaseService.scrollBackToTop();
- $scope.role = role;
- $scope.master = angular.copy($scope.role);
- var isNew = role == null;
- $scope.cancel = function() {
- $modalInstance.close(false);
- };
- AccountResource.query({}, function(data){
- if(data && data.length > 0) {
- if(role && role.resourceItems) {
- var rs = [];// 已分配的资源的id
- angular.forEach(role.resourceItems, function(item){
- rs.push(item.id);
- });
- angular.forEach(data, function(resource){
- var c = 0;
- angular.forEach(resource.items, function(item){
- if(rs.indexOf(item.id) > -1) {
- item.$checked = true;
- c += 1;
- }
- });
- resource.$checked = c == resource.items.length;
- });
- }
- $scope.resourceItems = data[0].items;
- data[0].$active = true;
- }
- $scope.resources = data;
- $timeout(function(){
- angular.forEach($scope.resources, function(resource){
- var c = 0;
- angular.forEach(resource.items, function(item){
- item.$checked && (c+=1);
- });
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- });
- }, 100);
- });
- $scope.onItemClick = function(resource) {
- $scope.resourceItems = resource.items;
- angular.forEach($scope.resources, function(r){
- r.$active = false;
- });
- resource.$active = true;
- };
- var getChecked = function() {
- var items = [];
- angular.forEach($scope.resources, function(resource){
- angular.forEach(resource.items, function(item){
- item.$checked && (items.push(item));
- });
- });
- $scope.role.resourceItems = items;
- };
- $scope.onResourceChange = function(resource) {
- angular.forEach(resource.items, function(item){
- item.$checked = resource.$checked;
- });
- getChecked();
- };
- $scope.onItemChange = function() {
- angular.forEach($scope.resources, function(resource){
- if(resource.$active) {
- var c = 0;
- angular.forEach(resource.items, function(item){
- item.$checked && (c+=1);
- });
- resource.$checked = (c == resource.items.length);
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- }
- });
- getChecked();
- };
- $scope.isChanged = function(formData) {
- if(!$scope.master)
- return true;
- return !angular.equals(formData, $scope.master);
- };
- $scope.save = function() {
- $scope.master = angular.copy($scope.role);
- AccountRole.save($scope.master, function(){
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 资料' + (isNew ? '添加': '修改') + '成功');
- $modalInstance.close(true);
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- };
- $scope.del = function() {
- new ngAlert({
- title: '提示',
- content: '确定删除角色(' + $scope.role.desc + ')吗?'
- }, function(){
- AccountRole.remove({id: role.id}, function(){
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
- $modalInstance.close(true);
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- })
- };
- }]);
-
- /**
- * 委外订单
- */
- app.controller('MakeOrderCtrl', ['$scope', '$filter', 'MakeOrder', 'ngTableParams', 'toaster','ReportService', 'BaseService',
- function($scope, $filter, MakeOrder, ngTableParams, toaster,ReportService, BaseService){
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.nowdate = new Date();
- $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 : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.getOrderTotal = function(items) {
- var sum = 0;
- angular.forEach(items, function(item){
- sum += item.qty * item.price;
- });
- return sum;
- };
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
-
- // 打开回复
- $scope.openReply = function(order) {
- if(!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
-
- // 关闭回复
- $scope.closeReply = function(order) {
- order.$editing = false;
- }
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 点击回复
- $scope.onReplyClick = function(order, inverse) {
- if(order.reply) {
- if(!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOrder.reply({orderId: order.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- //委外加工单
- $scope.print = function(order) {
- MakeOrder.printCount({id: order.id},{});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$orders.ma_id=' + order.id);
- };
-
- // 获取回复记录
- $scope.getReply = function(order) {
- if(!order.replies) {
- MakeOrder.getReply({orderId: order.id}, function(replies){
- order.replies = replies;
- });
- }
- };
- }]);
-
- /**
- * 委外加工单详细
- */
- app.controller('MakeOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOrder', 'toaster', 'ReportService', 'BaseService', function($scope, $stateParams, MakeOrder, toaster, ReportService, BaseService){
- BaseService.scrollBackToTop();
- var loadData = function() {
- MakeOrder.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- });
- };
- loadData();
- // 获取回复记录
- $scope.getReply = function(item) {
- if(!item.replies) {
- MakeOrder.getReply({orderId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 点击回复
- $scope.onReplyClick = function(order, inverse) {
- if(order.reply) {
- if(!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOrder.reply({orderId: order.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 打开回复
- $scope.openReply = function(order) {
- if(!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
-
- // 关闭回复
- $scope.closeReply = function(order) {
- order.$editing = false;
- }
-
- // 委外订单
- $scope.print = function(order) {
- MakeOrder.printCount({id: order.id},{});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$orders.ma_id =' + order.id);
- };
-
- }]);
- /**
- * 客户委外验收
- */
- app.controller('MakeAcceptCtrl', ['$scope', '$filter', 'MakeAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, MakeAccept, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return MakeAccept;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
-
- /**
- * 客户委外验退
- */
- app.controller('MakeReturnCtrl', ['$scope', '$filter', 'MakeReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function($scope, $filter, MakeReturn, ngTableParams, toaster, BaseService, Symbol){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return MakeReturn;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- }]);
- /**
- * 委外加工变更
- */
- app.controller('MakeChangeCtrl', ['$scope', '$filter', 'MakeChange', 'ngTableParams', 'toaster', 'BaseService', function($scope, $filter, MakeChange ,ngTableParams, toaster, BaseService){
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return MakeChange;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- orderChangeDate: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 打开回复
- $scope.openReply = function(change) {
- change.$editing = true;
- };
-
- // 关闭回复
- $scope.closeReply = function(change) {
- change.$editing = false;
- }
-
- // 确定回复
- $scope.onReplyClick = function(change) {
- if(change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- MakeChange.reply({itemId: change.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- app.controller('MakeChangeDetailCtrl', ['$scope', '$stateParams', 'MakeChange', 'toaster', 'BaseService', function($scope, $stateParams, MakeChange, toaster, BaseService){
- BaseService.scrollBackToTop();
- var loadData = function() {
- MakeChange.get({id: $stateParams.id}, function(data){
- $scope.change = data;
- });
- };
- loadData();
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.onReplyClick = function(change) {
- if(change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- MakeChange.reply({itemId: change.id}, reply, function(){
- toaster.pop('info', '提示', '回复成功');
- loadData();
- }, function(response){
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- }]);
-
- /**
- * 委外加工
- */
- app.controller('MakeOutOrderCtrl', ['$scope', '$filter', 'MakeOutOrder', 'ngTableParams', 'toaster','ReportService', 'BaseService',
- function($scope, $filter, MakeOutOrder, ngTableParams, toaster,ReportService, BaseService) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return MakeOutOrder;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 打开回复
- $scope.openReply = function(change) {
- change.$editing = true;
- };
-
- // 关闭回复
- $scope.closeReply = function(change) {
- change.$editing = false;
- }
-
- // 确定回复
- $scope.onReplyClick = function(change) {
- if(change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- MakeOutOrder.reply({itemId: change.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 委外加工详细
- */
- app.controller('MakeOutOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOutOrder', 'toaster', 'ReportService', 'BaseService', function($scope, $stateParams, MakeOutOrder, toaster, ReportService, BaseService) {
- BaseService.scrollBackToTop();
- var loadData = function() {
- MakeOutOrder.get({id: $stateParams.id}, function(data){
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- });
- };
- loadData();
- // 获取回复记录
- $scope.getReply = function(item) {
- if(!item.replies) {
- MakeOutOrder.getReply({orderId: item.id}, function(replies){
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- // 点击回复
- $scope.onReplyClick = function(order, inverse) {
- if(order.reply) {
- if(!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if(reply.delivery) {
- if(typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if(inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOutOrder.reply({orderId: order.id}, reply, function(){
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功':'回复成功'));
- loadData();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
-
- // 打开回复
- $scope.openReply = function(order) {
- if(!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
-
- // 关闭回复
- $scope.closeReply = function(order) {
- order.$editing = false;
- }
-
- // 自己委外加工订单
- $scope.print = function(order) {
- MakeOutOrder.printCount({id: order.id},{});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$outorders.ma_id =' + order.id);
- };
- }]);
-
- /**
- * 计算时间差
- */
- app.filter('timespan', function(){
- return function(time) {
- if(time == null)
- return '9999年';
- var now = new Date().getTime(), span = time - now,
- d = Math.ceil(span/86400000), h = Math.ceil(span/3600000),
- m = Math.ceil(span/60000);
- if(span < 0)
- return '1天';
- if(d > 0)
- return d+1 + '天';
- 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.filter('summary', function(){
- return function(data, field) {
- var sum = 0;
- if (data) {
- angular.forEach(data, function(d){
- sum += d[field];
- });
- }
- return sum;
- };
- });
- /**
- * 搜索框,回车触发
- */
- app.directive('ngSearch', ['$parse', function($parse) {
- return {
- require : '?ngModel',
- restrict : 'A',
- link : function(scope, element, attrs, ngModel) {
- var searchFn = $parse(attrs.ngSearch);
- element.bind('keypress', function(event) {
- if (event.keyCode == '13') {
- event.preventDefault();
- event.stopPropagation();
- searchFn(scope, {$data: ngModel.$modelValue, $event: event});
- }
- });
- }
- };
- }]);
-
- /**
- * 状态码 -> 描述
- */
- app.filter('status', function(){
- return function(data) {
- var statusConfig = {
- '101': '已提交',
- '102': '已审核',
- '103': '未通过',
- '200': '未回复',
- '201': '已回复',
- '313': '已激活',
- '316': '已过账',
- '311': '申请中',
- '312': '未激活'
- };
- return statusConfig[data];
- }
- });
-
- //弹出问题反馈模态框
- app.controller('LeftCtrl', ['$scope', '$modal', 'AuthenticationService', function($scope, $modal, AuthenticationService){
- //获取当前用户
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.user = data;
- });
- $scope.showModal = function(){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/serve/feedback.html',
- controller: 'FeedbackCtrl',
- resolve: {
- user: function(){return $scope.user;} //传递当前用户到模态框Controller
- }
- });
- modalInstance.result.then(function(){
-
- }, function(){
-
- })
- }
- }]);
-
- /*
- * 提交我的反馈
- */
- app.controller('FeedbackCtrl', ['$scope', '$modalInstance', 'FeedBackService', 'toaster', 'AuthenticationService', 'user', function($scope, $modalInstance, FeedBackService, toaster, AuthenticationService, user){
- $scope.isPublic = 1; //默认公开
- $scope.classId = 1; //默认类别
- $scope.user = user;
- $scope.ok = function(){
- if(!$scope.user){ //用户未登录
- $scope.uu = null;
- }else{ //用户已登录
- $scope.uu = $scope.user.userUU;
- }
- //FeedBackService定义于common/service.js里,供不同页面的问题反馈功能使用
- FeedBackService.feedBackQuestion({classId: $scope.classId, isPublic: $scope.isPublic, title: $scope.title, userUU: $scope.uu}, {},
- function(data){
- toaster.pop('success', '成功', '您的问题反馈成功!');
- $scope.cancel();
- }, function(response){
- toaster.pop('error', '错误', response.data);
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
-
- //“我的问题反馈”跳转控制
- app.controller('RightCtrl', ['$scope', 'AuthenticationService', 'toaster', '$rootScope', function($scope, AuthenticationService, toaster, $rootScope){
- $scope.myFeedback = function(){
- AuthenticationService.getAuthentication().success(function(data){
- $scope.user = data;
- if(!$scope.user){
- toaster.pop('warning', '提示', '您还未登录,请登录后再查看!');
- return false;
- }else{
- window.location.href = "./serve#/question/myFeedback";
- }
- });
- };
- $scope.setActive = function(active) {
- $rootScope.active = active;
- }
- }]);
- //客户服务
- app.controller('CustServeCtrl', ['$scope', 'Vendor', function($scope, Vendor){
- Vendor.getServe(function(datas){
- $scope.vendors = datas;
- // 自动跳转
- if(datas && datas.length == 1)
- $scope.redirect(datas[0]);
- });
- $scope.redirect = function(vendor) {
- window.open('purc/vendor/serve/' + vendor.vendorEnterprise.uu);
- };
- }]);
-
- /**
- * 物料资料
- */
- app.controller('ProductListCtrl', ['$scope', 'GetProductInfo', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', '$rootScope', '$modal', 'Products', function($scope, GetProductInfo, ngTableParams, $filter, BaseService, toaster, $timeout, $rootScope, $modal, Products) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return GetProductInfo;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- //删除
- $scope.deleteById = function(id) {
- GetProductInfo.deleteById({id: id}, function(data) {
- if(data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function() {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function(response) {
- toaster.pop("error", "删除失败", response.data);
- };
- };
- $rootScope.isProductEdit = false;
- // 编辑
- $scope.isProductEdit = function () {
- $rootScope.isProductEdit = true;
- };
-
- // 一键开启关闭
- $scope.toggle = function(status) {
- GetProductInfo.toggle({status: status}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- var products = [];
- $scope.checks = {
- checked: false
- };
-
- // 全选框
- $scope.checkAll = function() {
- products = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.cmpUuId == null) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function(product) {
- products = [];// 每次选择时先清空,防止重复
- var result = true;
- angular.forEach($scope.tableParams.data, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function(message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.updateByBatch = function(updatetype) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/updateByBatch_modal.html',
- controller: 'UpdateByBatchCtrl',
- size: 'md',
- resolve: {
- updatetype: function() {
- return updatetype;
- },
- active: function() {
- return $scope.active;
- },
- type: function() {
- return 'sale';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }, function(){
-
- });
-
- }
-
- // 一键匹配
- $scope.matchall = function() {
- $scope.loading = true;
- $scope.type = "sale";
- Products.matchbytype({type: $scope.type}, {}, function(data) {
- toaster.pop('info', '提示', '匹配成功'+data.size+'个标准器件');
- window.location.href = "#/sale/productmatches";
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 批量修改
- */
- app.controller('UpdateByBatchCtrl', ['$scope', '$modalInstance', 'toaster', 'BaseService', 'updatetype', 'Products', 'active', 'type', function($scope, $modalInstance, toaster, BaseService, updatetype, Products, active, type) {
- $scope.updatetype = updatetype;
- $scope.changed = false;
- $scope.parameter = {
- updatetype: updatetype,
- standard: active,
- type: type,
- oldvalue: null,
- newvalue: null
- };
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- if(updatetype === '品牌')
- var loadData = function() {
- Products.getBrands({parameter: $scope.parameter}, {}, function(data) {
- $scope.products = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- if(updatetype === '名称(类目)')
- var loadData = function() {
- Products.getTitles({parameter: $scope.parameter}, {}, function(data) {
- $scope.products = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- loadData();
-
- $scope.okay = function() {
- Products.alterByBatch({parameter: $scope.parameter}, {}, function(data) {
- $modalInstance.close(data);
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 物料批量上传
- */
- app.controller('UploadByBatchCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function($scope, $upload, toaster, BaseService) {
- BaseService.scrollBackToTop();
- $scope.$watch('myFiles', function(){
- if($scope.myFiles) {
- var file = $scope.myFiles[0];
- $scope.fileName = file.name;
- }
- })
- // 通过excel批量上传物料
- $scope.upload = function() {
- $scope.loading = true;
- if($scope.myFiles) {
- var file = $scope.myFiles[0];
- if(file.name) {
- $upload.upload({
- url: 'product/baseInfo/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- $scope.loading = false;
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- $scope.products = $scope.result.products;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- $scope.infos = $scope.result.infos;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function(response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
-
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadByBatch_prod_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
-
- // 下载模板
- $scope.download = function() {
- window.location.href = 'product/baseInfo/upload/template';
- };
- }]);
-
- /**
- * 物料详情
- */
- app.controller('ProductDetailCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', 'AuthenticationService', '$filter', 'BaseService', '$rootScope', '$modal', 'Products', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, AuthenticationService, $filter, BaseService, $rootScope, $modal, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
-
- var loadData = function() {
- GetProductInfo.getOne({id: $stateParams.id}, function(data) {
- if(data.attach) {
- GetProductInfo.getAttach({id: data.attach.id}, function(data) {
- // 查看范例
- $scope.showImg = function() {
- var src = data.url, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
- })
- }
- $scope.prodInfo = data;
- if($scope.prodInfo.standard != 1 ) {// 非标准的先进行匹配
- Products.matchone({id: $scope.prodInfo.id}, {}, function(data) {
- $scope.matchresults = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- if ($rootScope.isProductEdit) { // 是否点击编辑
- $scope.prodInfo.$editing = true;
- } else {
- $scope.prodInfo.$editing = false;
- }
- $rootScope.isProductEdit = false; // 第一次进入判断,后续不用
- $scope.loading = false;
- });
- };
- loadData();
- //更新为标准器件
- $scope.updateone = function(id) {
- Products.updateone({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 选择类目
- $scope.selectKind = function(cmpcode) {
- if(cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function(data){
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function() {
- return $scope.kindId;
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function(){
-
- });
- }, function(){
-
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function() {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
-
- // 取消
- $scope.cancel = function() {
- GetProductInfo.getOne({id: $stateParams.id}, function(data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
-
- // 删除
- $scope.clearfile = function() {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
-
- //删除
- $scope.deleteById = function(id) {
- GetProductInfo.deleteById({id: id}, function(data) {
- if(data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- window.location.href = "#/sale/prodList";
- }
- }), function(response) {
- toaster.pop("error", "删除失败", response.data);
- };
- };
-
- $scope.submit = function(prodInfo) {
- $scope.prodInfo.isSale = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/updateProdInfo',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $rootScope.isProductEdit = false;
- loadData();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- }
-
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function(){
- if($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if(file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else{
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else{//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var getObjectURL = function(file) {
- var url = null ;
- if (window.createObjectURL!=undefined) { // basic
- url = window.createObjectURL(file) ;
- } else if (window.URL!=undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file) ;
- } else if (window.webkitURL!=undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file) ;
- }
- return url ;
- };
-
- }]);
-
- /**
- * 新增物料(销售)
- */
- app.controller('NewProdInfoCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', '$modal', 'ComponentActive', 'KindAPI', '$timeout', '$filter', 'AuthenticationService', 'BaseService', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout, $filter, AuthenticationService, BaseService) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.prodInfo = {};
- // 选择类目
- $scope.selectKind = function() {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function(data){
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function() {
- return $scope.kindId;
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function(){
-
- });
- }, function(){
-
- });
- };
- // 删除
- $scope.clearfile = function() {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //提交
- $scope.submit = function(prodInfo){
- $scope.prodInfo.isSale = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/addNewProduct',
- file: file,
- method: 'POST',
- data: {
- prodInfo: prodInfo
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- //提交后跳转到详情页面,防止重复提交
- window.location.href="#/sale/prodList/"+data.id;
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function() {
- //提交后跳转到详情页面,防止重复提交
- window.location.href="#/sale/prodList/"+data.id;
- }, 500);
- }
-
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- };
-
- $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 : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.kindId = KindId;
- ComponentActive.getComponentsByKindid(BaseService.parseParams(pageParams), function(page) {
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- // 选择
- $scope.check = function(data){
- $modalInstance.close(data);
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 企业列表
- */
- app.controller('EnterpriseListCtrl', ['$scope', 'getAccountUserSpace', 'ngTableParams', '$filter', 'BaseService', 'toaster', 'AddPartner', '$rootScope', function($scope, getAccountUserSpace, ngTableParams, $filter, BaseService, toaster, AddPartner, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return getAccountUserSpace;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page) {
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 添加合作关系
- $scope.addPartner = function(name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function(data) {
- if(data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
-
- $scope.status = 'enList';
- }]);
-
- /**
- * 新增采购单
- */
- app.controller('PurcNewOrderCtrl',['$scope', '$modal', 'toaster', '$filter', 'addtoCart', '$rootScope', 'VendorInfo', 'ngTableParams', 'BaseService', 'Product', 'newPurcOrder', 'cartOperation', 'ShipAddress', 'Vendor', '$http', function($scope, $modal, toaster, $filter, addtoCart, $rootScope, VendorInfo, ngTableParams, BaseService, Product, newPurcOrder, cartOperation, ShipAddress, Vendor, $http) {
- BaseService.scrollBackToTop();
- // 每次进入时先清除掉rootScope下的venuu
- $rootScope.venduu = null;
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
-
- $scope.order = {
- date : new Date(),
- cust : {
- uu : '',
- },
- custUser : {
-
- },
- code : $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- orderItems : {
- product : {},
- },
- rate: 17
- };
-
- //商品信息
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- id: null,
- };
-
-
- if($rootScope.businessCode) {
- VendorInfo.getVendorInfo({businessCode: $rootScope.businessCode}, {}, function(data) {
- $scope.id = data.id;
- $scope.order.cust.enName = data.vendorEnterprise.enName;
- $scope.order.cust.enAddress = data.vendorEnterprise.enAddress;
- $scope.order.cust.uu = data.vendorEnterprise.uu;
- $scope.order.paymethods = data.paymethod;
- $rootScope.venduu = data.vendorEnterprise.uu;
- Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }, function(response) {
-
- });
- };
-
- // 查找供应商
- $scope.dbfindCust = function(){
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
- controller: 'DbfindVendorInfoCtrl',
- size: 'lg',
- resolve: {
- orderItems: function() {
- return $scope.order.orderItems;
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $rootScope.venduu = data.vendorEnterprise.uu;
- $scope.id = data.id;
- $scope.order.cust = data.vendorEnterprise;
- $scope.order.custUser = data.vendorUser;
- $scope.order.payments = data.paymethod;
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- };
- // $scope.order.orderItems.push(item);
- Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
-
- }, function(){
-
- });
- };
-
- // 联想词 start
- // 获取供应商
- $scope.getSimilarVendors = function(value) {
- if (value) {
- return Vendor.getSimilarVendors({keyword : value}).$promise.then(function(data) {
- return data.map(function(item) {
- return item;
- });
- });
- }
- };
-
- $scope.onAssociateCmpClick = function(vendor, order) {
- $scope.order.cust.uu = vendor.venduu;
- $scope.id = vendor.id;
- $scope.order.payments = vendor.paymethod;
- $rootScope.venduu = $scope.order.cust.uu;
- Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }
- // 联想词 end
-
- // $scope.order.orderItems.push(item);
- if($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function(data) {
- item.code = data.code;
- item.title = data.title;
- item.spec = data.spec;
- item.unit = data.unit;
- item.id = data.id;
- $scope.order.orderItems.push(item);
- $rootScope.prodId = null;// 清除掉prodId
- }, function(response) {
-
- });
- }
- //增加商品
- $scope.addProduct = function(index) {
- if($scope.order.orderItems[index].code == null) {
- toaster.pop('info', '提示', '请先选择商品');
- } else {
- $scope.order.orderItems.push({code: null, title: null, spec: null, unit: null, qty: null, price: null, remark: null, delivery: null, $endDateOpen: false, rate: $scope.order.rate});
- }
- };
- //删除商品
- $scope.deleteProduct = function(index) {
- $scope.order.orderItems.splice(index, 1);
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.custUU = $scope.order.cust.uu;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
-
- // 选择
- $scope.check = function(data) {
- $scope.order.orderItems.push({code: data.code, title: data.title, spec: data.spec, unit: data.unit, qty: null, price: null, remark: null, delivery: null, id: data.id, rate: $scope.order.rate});
- };
-
- // 导入商品信息
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_uplodaByBatch.html',
- controller: 'PurcUploadByBatchCtrl',
- size: 'lg',
- resolve: {
- }
- });
-
- modalInstance.result.then(function(data) {
- angular.forEach(data, function(prod) {
- $scope.order.orderItems.push({code: prod.code, title: data.title, unit: 'PCS', spec: prod.spec, qty: prod.amount, price: prod.price, remark: prod.remark, delivery: prod.date, id: prod.id, rate: prod.rate});
- // for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- // if($scope.order.orderItems[i].qty == null && $scope.order.orderItems[i].price == null && $scope.order.orderItems[i].qty == null && $scope.order.orderItems[i].delivery == null && $scope.order.orderItems[i].remark == null) { // 如果没有填写就删除这行数据
- // $scope.inquiry.inquiryItems.splice(i, 1);
- // }
- // }
- })
-
- }, function(){
-
- });
- }
- // 监听custuu发生变化,重新加载物料信息
- $scope.$watch('order.cust.uu', function(n, o) {
- if(n==o) {
- return;
- } else {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, true);
-
- // 查找客户物料
- $scope.dbfindCustProd = function(index){
- if($scope.order.cust.uu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_custProd.html',
- controller: 'DbfindCustProdCtrl',
- size: 'lg',
- resolve: {
- custUU: function() {
- return $scope.order.cust.uu
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.order.orderItems.push(data);
- for(var i = 0; i < $scope.order.orderItems.length; i++) {
- if($scope.order.orderItems[i].code == null || i == index) {
- $scope.order.orderItems.splice(i, 1);
- }
- }
- }, function() {
-
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- };
- $scope.getMinDate = function(item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
-
- $scope.openDatePicker = function($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.order.orderItems[index].$endDateOpen = !openParam;
- };
-
-
- // 添加到购物车
- $scope.addToCart = function(order) {
- $scope.loading = true;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.custUU = $scope.order.cust.uu;
- $scope.order.custUserUU = $scope.order.custUser.userUU;
- if($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for(var i = 0; i < $scope.order.orderItems.length; i++) {
- if($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- addtoCart.save({}, $scope.order, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/cart/'+data.id;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
-
- // 立即购买
- $scope.addToOrder = function(order) {
- $scope.loading = true;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.custUU = $scope.order.cust.uu;
- $scope.order.custUserUU = $scope.order.custUser.userUU;
- if($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for(var i = 0; i < $scope.order.orderItems.length; i++) {
- if($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- newPurcOrder.save({}, $scope.order, function(data){
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/order/'+data.id;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
-
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
-
- // 新增供应商联系人
- $scope.addContact = function(uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function(data) {
- Vendor.contacts({venduu: $scope.order.cust.uu}, {}, function(data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- }]);
-
- /**
- * 采购批量导入
- */
- app.controller('PurcUploadByBatchCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function() {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'purchase/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.download = function() {
- window.location.href = 'purchase/upload/template';
- };
-
- $scope.enSure = function() {
- $modalInstance.close($scope.result.products);
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- // 查找供应商
- app.controller('DbfindVendorInfoCtrl', ['$scope', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'Vendor', '$rootScope', 'orderItems', function($scope, BaseService, ngTableParams, toaster, $modalInstance, Vendor, $rootScope, orderItems){
- $scope.prod = false;
- if(orderItems.length != 0) {
- $scope.prod = true;
- }
- BaseService.scrollBackToTop();
- if($rootScope.venduu != null) {
- $scope.venduu = $rootScope.venduu;
- }
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
-
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- $scope.ensure = false;
- $scope.check = function(vendor) { // 需要进行判断的选择
- $scope.vendorInfo = vendor;
- $scope.ensure = true;
- };
-
- $scope.checkVendor = function(vendor) { // 直接选择
- $modalInstance.close(vendor);
- }
-
- }]);
-
- /**
- * 我的客户
- */
- app.controller('MyClientCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster){
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- var getCustInfos = function(custuu) {
- if(custuu) {
- VendorService.userInfo.query({uu:custuu},null,function(data) {
- $scope.custInfos = data;
- var getPage = function(page, size){
- if($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1)*size, page * size);
- if($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- }else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1,4);
- $scope.first = function (){
- $scope.userdata = getPage($scope.userdata.pre,4);
- }
- $scope.last = function (){
- $scope.userdata = getPage($scope.userdata.next,4);
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }
- $scope.addUserInfo = function(customer) {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function() {
- return customer;
- }
- }
- });
- modalInstance.result.then(function(changed, checked){
- if(changed) {
- if(checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
-
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
- $scope.showUserInfo = function(customer,boo) {
- $scope.custInfo = customer;
- if(boo) {
- getCustInfos(customer.myEnterprise.uu);
- $scope.userInfoResult = true;
- }
- }
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- VendorService.customer.get(BaseService.parseParams(params.url()), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
-
- /**
- * 我的供应商
- */
- app.controller('PurcVendorCtrl', ['$scope', 'Vendor', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', '$rootScope', 'VendorInfo', function($scope, Vendor, BaseService, AuthenticationService,ngTableParams,$modal, toaster, $rootScope, VendorInfo){
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
-
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 查看供应商详情
- $scope.VendorDetail = function(id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/"+$rootScope.vendorId;
- }
-
- // 向企业购买
- $scope.purcByEn = function(businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
-
- }]);
-
- /**
- * 供应商详情
- */
- app.controller('PurcVendorDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', function($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.vendorContacts = [];
- var loadData = function() {
- Vendor.getVendorDetail({id: $stateParams.id}, {}, function(data) {
- $scope.vendor = data.vendorEnterprise;
- Vendor.contacts({venduu: $scope.vendor.uu}, {}, function(data) {
- $scope.vendorContacts = data;
- });
- });
- };
- loadData();
-
- // 新增供应商联系人
- $scope.addContact = function(uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function(data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.vendorContacts.push(data);
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- };
-
- // 编辑供应商联系人
- $scope.edit = function(contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function() {
- return contact;
- }
- }
- });
- modalInstance.result.then(function(data) {
- Vendor.saveContact({}, data, function(data) {
- loadData();
- toaster.pop('success', '提示', '联系人修改成功');
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
-
- // 删除供应商联系人
- $scope.deleteById = function(id, index) {
- $scope.vendorContacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '供应商联系人删除成功');
- loadData();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 供应商物料信息
- $scope.viewProdList = function(uu){
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function(businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
-
- /**
- * 询价
- */
- $scope.PurcInquiry = function(businessCode, id){
- $rootScope.prodId = id;
- window.location.hash = "#/purc/purcinquiry/" + businessCode;
- }
- }]);
- /**
- * 编辑供应商联系人
- */
- app.controller('EditContacCtrl', ['$scope', 'toaster', '$modalInstance', 'contact', function($scope, toaster, $modalInstance, contact) {
- $scope.contact = angular.copy(contact);
- $scope.save = function(contact) {
- $modalInstance.close(contact);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 新增供应商联系人
- */
- app.controller('AddContacCtrl', ['$scope', 'toaster', '$modalInstance', function($scope, toaster, $modalInstance) {
- $scope.save = function(contact) {
- $modalInstance.close(contact);
- };
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
-
- /**
- * 建立合作关系申请 (我的合作伙伴)
- */
- app.controller('AddPartnerRequestCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', '$rootScope', 'VendorInfo', function($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout, $rootScope, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = "partner";
- $scope.active = 'done';
-
- var getRequestStatus = function(active) {
- var fn = 'getAllRequest';
- switch(active) {
- case 'done':
- fn = 'getRequestDone';break;
- case 'todo':
- fn = 'getRequestTodo';break;
- case 'end':
- fn = 'getRequestEnd';break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function() {
- return AddPartnerMyRequest;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- if($rootScope.vendName) {
- pageParams.keyword = $rootScope.vendName;
- $scope.keyword = $rootScope.vendName;
- $rootScope.vendName = null;
- }
- $scope.tip = $scope.keyword;
- getService()[getRequestStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 再次申请
- $scope.addAgain = function(name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function(data) {
- if(data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
-
- // 添加为供应商
- $scope.addSupplier = function(vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error','提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- })
- };
-
- // 添加客户
- $scope.addCust = function(vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error','提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- })
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- // 同意申请
- $scope.agree = function(id) {
- AddPartner.agreeRequest({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- // 拒绝申请
- $scope.refuse = function(id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- // 取消供应商关系
- $scope.relieve = function(id) {
- VendorInfo.relieve({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- // 建立供应商关系
- $scope.activeVend = function(id) {
- VendorInfo.activeVend({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 取消客户关系
- $scope.disableCust = function(id) {
- VendorInfo.disableCust({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 激活客户关系
- $scope.activeCust = function(id) {
- VendorInfo.activeCust({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 建立合作关系申请 (新的合作伙伴)
- */
- app.controller('NewPartnerCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', '$rootScope', 'VendorInfo', function($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout, $rootScope, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = "partner";
- $scope.active = 'all'; // 所有申请记录
- var getRequestStatus = function(active) {
- var fn = 'getAllRequest';
- switch(active) {
- case 'done':
- fn = 'getRequestDone';break;
- case 'todo':
- fn = 'getRequestTodo';break;
- case 'end':
- fn = 'getRequestEnd';break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function() {
- return AddPartnerMyRequest;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- if($rootScope.vendName) {
- pageParams.keyword = $rootScope.vendName;
- $scope.keyword = $rootScope.vendName;
- $rootScope.vendName = null;
- }
- $scope.tip = $scope.keyword;
- getService()[getRequestStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 再次申请
- $scope.addAgain = function(name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function(data) {
- if(data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
- // 添加为供应商
- $scope.addSupplier = function(vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error','提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加客户
- $scope.addCust = function(vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error','提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 同意申请
- $scope.agree = function(id) {
- AddPartner.agreeRequest({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- AddPartnerMyRequest.requestAmount({}, function(data) {
- $scope.requestTodo = data;
- });
- // 拒绝申请
- $scope.refuse = function(id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消供应商关系
- $scope.relieve = function(id) {
- VendorInfo.relieve({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 建立供应商关系
- $scope.activeVend = function(id) {
- VendorInfo.activeVend({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 取消客户关系
- $scope.disableCust = function(id) {
- VendorInfo.disableCust({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 激活客户关系
- $scope.activeCust = function(id) {
- VendorInfo.activeCust({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 建立合作关系处理申请
- */
- app.controller('AddPartnerMessageCtrl', ['$scope', 'AddPartnerMyMessage', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', 'AddPartnerMyRequest', function($scope, AddPartnerMyMessage, toaster, BaseService, ngTableParams, AddPartner, AddPartnerMyRequest) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- var getMessagetStatus = function(active) {
- var fn = 'getAllMessage';
- switch(active) {
- case 'done':
- fn = 'getMessageDone';break;
- case 'todo':
- fn = 'getMessageTodo';break;
- case 'end':
- fn = 'getMessageEnd';break;
- }
- return fn;
- }
-
- // 切换单据类型
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- var getService = function() {
- return AddPartnerMyMessage;
- };
-
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 15, 25, 50],
- getData : function($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- };
- getService()[getMessagetStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 同意申请
- $scope.agree = function(id) {
- AddPartner.agreeRequest({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- // 拒绝申请
- $scope.refuse = function(id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
-
- $scope.status = 'get';
- }]);
-
- /**
- * 我的合作伙伴
- */
- app.controller('MyPartnersCtrl', ['$scope', 'toaster', 'GetProductInfo', 'BaseService', function($scope, toaster, GetProductInfo, BaseService) {
- BaseService.scrollBackToTop();
- // 默认显示合作伙伴
- $scope.status = 'news';
-
- // 获取所有的合作伙伴
- GetProductInfo.getAllPartners({}, function(data) {
- $scope.partners = data;
- }, function(res) {
- toaster.pop('error', '获取列表失败', res.data);
- });
-
- // 添加为客户
- $scope.addCust = function(partner) {
- GetProductInfo.addCust({}, partner, function(data) {
- toaster.pop('success', '提示', '添加客户成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '添加客户失败', response.data);
- });
- }
-
- // 添加为供应商
- $scope.addSupplier = function(partner) {
- GetProductInfo.addSupplier({}, partner, function(data) {
- toaster.pop('success', '提示', '添加供应商成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '添加供应商失败', response.data);
- });
- }
- }]);
-
- /**
- * 财务对账时,企业进行筛选操作
- */
- app.controller('SearchCustInfoCtrl', ['$scope', '$modalInstance', 'suuorname', 'FaApCheck', function($scope, $modalInstance, suuorname, FaApCheck) {
- var getData = function(){
- $scope.loading = true;
- FaApCheck.getAllCustomers(function(data) {
- $scope.custs = data;
- $scope.loading = false;
- });
- };
-
- getData();
-
- $scope.select = function(suuorname) {
- $modalInstance.close(suuorname);
- }
-
- $scope.close = function() {
- $modalInstance.close();
- }
- }]);
-
- /**
- * 跳转到企业圈
- */
- app.controller('BusinessGroupsCtrl', ['$scope', 'GetProductInfo', 'toaster', function($scope, GetProductInfo, toaster) {
- GetProductInfo.businessGroups({}, function(data) {
- window.open(data.url);
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }]);
-
- /**
- * 购物车
- */
- app.controller('CartController', ['$scope', 'toaster', 'getCartList', 'ngTableParams', '$filter', 'BaseService', 'cartOperation', '$timeout', function($scope, toaster, getCartList, ngTableParams, $filter, BaseService, cartOperation, $timeout) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return getCartList;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- 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) {
- cartOperation.addToOrder({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = '#/purc/order/'+data.id;
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 删除一条主记录
- $scope.deleteCart = function(id) {
- cartOperation.deleteCart({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 删除一条明细
- $scope.deleteDetail = function(id) {
- cartOperation.deleteCartDetail({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 清空购物车
- $scope.clearCart = function() {
- cartOperation.deleteCarts({}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 购物车详情
- */
- app.controller('CartDetailController', ['$scope', 'cartOperation', '$stateParams', 'toaster', '$timeout', 'BaseService', function($scope, cartOperation, $stateParams, toaster, $timeout, BaseService) {
- BaseService.scrollBackToTop();
- var loadData = function() {
- cartOperation.getCartDetail({id: $stateParams.id}, function(data) {
- if(data.code) {
- $scope.cart = data;
- var sum = 0;
- angular.forEach($scope.cart.cartDetails, function(item) {
- sum += item.qty * item.price;
- });
- $scope.cart.total = sum;
- $scope.loading = false;
- } else {
- window.location.hash = '#/purc/cart';
- }
- });
- };
- loadData();
-
- // 删除一条明细
- $scope.deleteDetail = function(id) {
- cartOperation.deleteCartDetail({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 删除一条主记录
- $scope.deleteCart = function(id) {
- cartOperation.deleteCart({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.reload();
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
-
- // 提交
- $scope.addtoOrder = function(id) {
- cartOperation.addToOrder({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = '#/purc/order/'+data.id;
- },500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
- }]);
-
- /**
- * 审批流
- */
- app.controller('approvalFlowCtrl', ['$scope', 'toaster', '$modal', 'appFlow', 'BaseService', function($scope, toaster, $modal, appFlow, BaseService) {
- BaseService.scrollBackToTop();
- $scope.vacation = false;
- $scope.workovertime = false;
- $scope.workdaily = false;
- $scope.feeplease = false;
- $scope.signapp = false;
- appFlow.viewAppFlow({}, function(data) {// 获取已设置的列表
- $scope.nodes = data;
- angular.forEach($scope.nodes, function(node) {
- if(node.appname = '请假单') {
- $scope.vacation = true;
- }
- if(node.appname = '加班单') {
- $scope.workovertime = true;
- }
- if(node.appname = '工作日报') {
- $scope.workdaily = true;
- }
- if(node.appname = '出差单') {
- $scope.feeplease = true;
- }
- if(node.appname = '申诉单') {
- $scope.signapp = true;
- }
- });
- }, function(response) {
-
- });
-
- $scope.NoteSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '请假单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.overTimeSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '加班单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.feePleaseSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '出差单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.workDailySet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '工作日报';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
-
- $scope.signAppSet = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function() {
- return '申诉单';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- appFlow.saveAppFlowSet({json: data}, {}, function(data) {
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
-
- });
- }, function(){
-
- });
- }
- }]);
-
- /**
- * 审核条件设置
- */
- app.controller('NoteStep1Ctrl', ['$scope', 'toaster', '$modalInstance', 'appFlow', 'AppName', '$filter', '$rootScope', function($scope, toaster, $modalInstance, appFlow, AppName, $filter, $rootScope) {
- $scope.appName = AppName;// 标题名称
- $scope.AppFlow = {appName: $scope.appName,
- appNodes:{}};
- $scope.AppFlow.appNodes = [];
- appFlow.getNodeByName({name: AppName}, {}, function(data) {// 通过单据名称查询单个审批流
- if(data.appNodes.length != 0) {
- $scope.node = data;
- $scope.AppFlow = data;
- }
- }, function() {
-
- });
-
- $scope.copy = function() {//复制
- $rootScope.flowcopy = angular.copy($scope.AppFlow);
- toaster.pop('info', '提示', '复制成功');
- $modalInstance.dismiss();
- }
-
- $scope.paste = function() {
- $scope.AppFlow = {appName: $scope.appName, appNodes:{}};
- $scope.AppFlow.appNodes = $rootScope.flowcopy.appNodes;
- }
-
- $scope.clear = function() {// 清空
- $scope.AppFlow = {appName: $scope.appName,
- appNodes:{}};
- $scope.AppFlow.appNodes = [];
- }
-
- appFlow.getPositions({}, function(data) {// 获取人员信息
- $scope.users = data;
- }, function(response) {
-
- });
-
- appFlow.getPositionInfo({}, function(data) { // 获取职位信息
- $scope.roles = data;
- },function(response) {
-
- });
-
- $scope.SelectUser = function(data) { // 添加人员
- var item = {
- useruu: null,
- username: null,
- level: null
- };
- item.useruu = data.useruu;
- item.username = data.username;
- // if($scope.AppFlow.appNodes.length != 0){
- // for(var i = 0;i < $scope.AppFlow.appNodes.length; i++) {
- // if($scope.AppFlow.appNodes[i] == item.useruu) {
- // toaster.pop('info', '提示', '不能重复添加');
- // } else {
- // $scope.AppFlow.appNodes.push(item);
- // }
- // }
- // } else {
- $scope.AppFlow.appNodes.push(item);
- // }
-
- }
-
- $scope.SelectRole = function(data) {// 添加职位
- var item = {
- position: null,
- level: null
- };
- item.position = data;
- $scope.AppFlow.appNodes.push(item);
- }
-
- $scope.deleteNode = function(index) {// 删除节点
- $scope.AppFlow.appNodes.splice(index, 1);
- };
-
- $scope.saveNode = function() { // 保存
- angular.forEach($scope.AppFlow.appNodes, function(value, key) {
- $scope.AppFlow.appNodes[key].level = key;
- });
- if($scope.AppFlow.appNodes.length == 0) {
- toaster.pop('info', '提示', '您还未设置审批人');
- } else {
- $modalInstance.close($scope.AppFlow);
- };
- };
-
- $scope.cancel = function() {// 取消
- $modalInstance.dismiss();
- }
-
- }]);
-
-
- /***
- * 代采定单
- */
- app.controller('DeputyOrderCtrl', ['$scope', 'toaster', 'getDeOrder', 'ngTableParams', 'BaseService', 'DeputyOrder', 'ReportService', function($scope, toaster, getDeOrder, ngTableParams, BaseService, DeputyOrder, ReportService) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.total = null;
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- 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.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //打印
- $scope.print = function(deputyOrder) {
- DeputyOrder.printCount({id: deputyOrder.id},{});//增加打印此次
- // ReportService.print(deputyOrder.deputyuu, 'PURCNOTICE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 定向采购通知
- // ReportService.print(deputyOrder.deputyuu, 'PURCHASE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 采购订单
- // ReportService.print(deputyOrder.deputyuu, 'PAYCONFIRM', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 付款确认
- // ReportService.print(deputyOrder.deputyuu, 'TRADECONTRACT', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 买卖合同
- //TODO 目前只有信扬有代采业务,先写死之后再改
- ReportService.print(10044118, 'PURCNOTICE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 定向采购通知
- ReportService.print(10044118, 'PURCHASE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 采购订单
- ReportService.print(10044118, 'PAYCONFIRM', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 付款确认
- ReportService.print(10044118, 'TRADECONTRACT', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 买卖合同
- };
-
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
-
- /**
- * 新增代采订单
- */
- app.controller('NewDeputyOrderCtrl', ['$scope', 'toaster', '$modal', 'DeputyOrder', '$filter', 'ngTableParams', 'BaseService', function($scope, toaster, $modal, DeputyOrder, $filter, ngTableParams, BaseService) {
- BaseService.scrollBackToTop();
- $scope.deOrder = {
- code: 'DC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- entrydate: new Date(),
- status: '在录入',
- goodspacking: '供应商原厂包装,如外包装完好视为货物完好',
- pickupdate: '我方自向贵公司支付货款之日起3个自然日内提货完毕',
- riskmethod: '甲方承担',
- taxpaymentmethod: '甲方承担',
- totalamount: 0,
- totalpayament: 0,
- orderamount: 0,
- usdpayment: 0
- };
-
- $scope.deOrder.deputyOrderItems = [];
- var item = {
- prodname: null,
- prodcode: null,
- prodspec: null,
- amount: null,
- unitprice: null,
- purcprice: null,
- remark: null,
- orderprice: null,
- };
- $scope.deOrder.deputyOrderItems.push(item);
-
- // 代采企业列表
- DeputyOrder.deputyEnterprise({}, function(data) {
- $scope.deputyEnterprises = data;
- $scope.deOrder.deputyuu = $scope.deputyEnterprises[0].deputyenuu;
- // 费率
- DeputyOrder.vendorRate( {enuu: $scope.deOrder.deputyuu}, {}, function(data) {
- $scope.rate = data;
- }, function(response){
-
- });
- });
-
- // 更新代采企业时更新费率
- $scope.change = function(deputyuu) {
- // 费率
- DeputyOrder.vendorRate( {enuu: deputyuu}, {}, function(data) {
- $scope.rate = data;
- }, function(response){
-
- });
- }
-
- // 查找付款企业
- $scope.dbfindPayCompany = function(deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/payCompany.html',
- controller: 'DbfindDeputyPayCompanyCtrl',
- resolve: {
- deputyuu: function() {return deputyuu}
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.deOrder.paycomname = data.enname;
- $scope.deOrder.paycomaddress = data.address;
- })
- }
-
- // 查询上次的关键词记录
- $scope.getHisKeyword = function(tervendor) {
- DeputyOrder.hisKeywords({tervendor: tervendor}, {}, function(data) {
- $scope.deOrder.vendtel = data.vendtel;
- $scope.deOrder.venduser = data.venduser;
- $scope.deOrder.otherdata = data.otherdata;
- $scope.deOrder.companyname = data.companyname;
- $scope.deOrder.bankaccount = data.bankaccount;
- $scope.deOrder.bankaddress = data.bankaddress;
- $scope.deOrder.bankcode = data.bankcode;
- $scope.deOrder.bankname = data.bankname;
- $scope.deOrder.legalrepresent = data.legalrepresent;
- $scope.deOrder.tervendaddress = data.tervendaddress;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 查询历史供应商
- DeputyOrder.hisvendors({}, function(data) {
- $scope.hisvendors = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
-
- //增加商品
- $scope.add = function(index) {
- if($scope.deOrder.deputyOrderItems[index].prodcode == null) {
- toaster.pop('info', '提示', '请先填写商品信息');
- }else {
- $scope.deOrder.deputyOrderItems.push(
- { prodname: null,
- prodcode: null,
- prodspec: null,
- prodbrand: null,
- amount: null,
- unitprice: null,
- purcprice: null,
- remark: null,
- orderprice: null});
- }
- };
- //删除商品
- $scope.del = function(index) {
- $scope.deOrder.deputyOrderItems.splice(index, 1);
- };
- // 导入商品信息
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'DeputyOrderUploadCtrl',
- size: 'lg',
- resolve: {
- }
- });
-
- modalInstance.result.then(function(data) {
- angular.forEach(data, function(data) {
- $scope.deOrder.deputyOrderItems.push(data);
- for(var i = 0; i < $scope.deOrder.deputyOrderItems.length; i++) {
- if($scope.deOrder.deputyOrderItems[i].prodname == null) { // 如果没有填写就删除这行数据
- $scope.deOrder.deputyOrderItems.splice(i, 1);
- }
- }
- })
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.usdpayment += item.amount * item.unitprice;
- $scope.deOrder.orderamount += item.amount * item.unitprice * (1 + $scope.rate.rate/100);
- });
-
- }, function(){
-
- });
- }
-
- // 查找供应商
- $scope.dbfindVendor = function(deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
- controller: 'DbfindDeputyVendorInfoCtrl',
- size: 'lg',
- resolve: {
- deputyuu: function() {return deputyuu}
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.deOrder.customer = data.vendorEnterprise.enName;
- $scope.deOrder.legalrepresent = data.vendorUser.userName;
- $scope.deOrder.enaddress = data.vendorEnterprise.enAddress;
- $scope.deOrder.usertel = data.vendorUser.userTel;
- })
- }
-
- // 检验订单编号是否存在
- $scope.checkOrder = function(salecode, deputyuu) {
- DeputyOrder.checkOrders({salecode: salecode, deputyuu: deputyuu}, {}, function(data) {
- if(data.info) {
- toaster.pop('error', '提示', data.info);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- //计算采购单价
- $scope.checkPrice = function(rate) {
- if(rate == null) {
- toaster.pop('info', '提示', '请先填入税率');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- item.purcprice = item.unitprice * (1 + rate/100);
- });
- }
- }
- // 保存
- $scope.save = function() {
- $scope.deOrder.entrystatus = '保存';
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- });
- if($scope.deOrder.deputyOrderItems[0].prodcode == null) {
- toaster.pop('info', '提示', '您还未填写任何商品信息');
- } else {
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.id) {
- toaster.pop('success', '提示', '保存成功');
- window.location.hash = "#/purc/deputy/"+data.id;
- }
- if(data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function(response) {
-
- });
- }
- }
-
- // 提交
- $scope.submit = function() {
- $scope.deOrder.entrystatus = '已提交';
- $scope.deOrder.totalpayament = 0;
- $scope.deOrder.totalamount = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- });
- if($scope.deOrder.deputyOrderItems[0].prodcode == null) {
- toaster.pop('info', '提示', '您还未填写任何商品信息');
- } else {
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.id) {
- toaster.pop('success', '提示', '提交成功');
- window.location.hash = "#/purc/deputy/"+data.id;
- }
- if(data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function(response) {
-
- });
- }
- }
-
- $scope.openDatePicker = function($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
-
- }]);
-
- // 代采企业供应商
- app.controller('DbfindDeputyVendorInfoCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', 'deputyuu', 'DeputyOrder', 'BaseService', 'ngTableParams', function($scope, toaster, $upload, $modalInstance, deputyuu, DeputyOrder, BaseService, ngTableParams) {
- $scope.prod = false;
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
-
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.enuu = deputyuu;
- DeputyOrder.vendors.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- $scope.checkVendor = function(vendor) { // 直接选择
- $modalInstance.close(vendor);
- }
- }]);
-
- // 代采企业付款企业
- app.controller('DbfindDeputyPayCompanyCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', 'deputyuu', 'DeputyOrder', 'BaseService', 'ngTableParams', function($scope, toaster, $upload, $modalInstance, deputyuu, DeputyOrder, BaseService, ngTableParams) {
- DeputyOrder.paycompanies({enuu: deputyuu}, {}, function(data) {
- $scope.paycompanies = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
-
- $scope.select = function(company) { // 直接选择
- $modalInstance.close(company);
- }
- }]);
-
- /**
- * 代采订单批量导入
- */
- app.controller('DeputyOrderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function() {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'deputyOrder/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function(response) {
- toaster.pop('error', response.data || response);
- });
- };
-
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
-
- // 下载模板
- $scope.download = function() {
- window.location.href = 'deputyOrder/upload/template';
- };
-
- $scope.enSure = function() {
- $modalInstance.close($scope.result.items);
- }
-
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 代采详情
- */
- app.controller('DeputyOrderDetailCtrl', ['$scope', 'toaster', 'DeputyOrder', '$stateParams', 'ngTableParams', 'BaseService', '$modal', function($scope, toaster, DeputyOrder, $stateParams, ngTableParams, BaseService, $modal) {
- BaseService.scrollBackToTop();
- var loadData = function() {
- DeputyOrder.getOrderDetail({id: $stateParams.id}, {}, function(data) {
- $scope.deOrder = data;
- $scope.deOrder.$editing = false;
- });
- };
- loadData();
-
- // 查询历史供应商
- DeputyOrder.hisvendors({}, function(data) {
- $scope.hisvendors = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
-
- // 代采企业列表
- DeputyOrder.deputyEnterprise({}, function(data) {
- $scope.deputyEnterprises = data;
- $scope.deOrder.deputyuu = $scope.deputyEnterprises[0].deputyenuu;
- // 费率
- DeputyOrder.vendorRate( {enuu: $scope.deOrder.deputyuu}, {}, function(data) {
- $scope.rate = data;
- }, function(response){
-
- });
- });
-
- // 更新代采企业时更新费率
- $scope.change = function(deputyuu) {
- // 费率
- DeputyOrder.vendorRate( {enuu: deputyuu}, {}, function(data) {
- $scope.rate = data;
- }, function(response){
-
- });
- }
-
- // 查找付款企业
- $scope.dbfindPayCompany = function(deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/payCompany.html',
- controller: 'DbfindDeputyPayCompanyCtrl',
- resolve: {
- deputyuu: function() {return deputyuu}
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.deOrder.paycomname = data.enname;
- $scope.deOrder.paycomaddress = data.address;
- })
- }
-
- // 删除明细
- $scope.del = function(index, id) {
- DeputyOrder.deleteProdById({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.deOrder.deputyOrderItems.splice(index, 1)
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.usdpayment += item.amount * item.unitprice;
- $scope.deOrder.orderamount += item.amount * item.unitprice * (1 + $scope.rate.rate/100);
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- });
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- //增加商品
- $scope.add = function(index) {
- if($scope.deOrder.deputyOrderItems[index].prodcode == null) {
- toaster.pop('info', '提示', '请先填写商品信息');
- }else {
- $scope.deOrder.deputyOrderItems.push(
- { prodname: null,
- prodcode: null,
- prodspec: null,
- prodbrand: null,
- amount: null,
- unitprice: null,
- remark: null,
- orderprice: null});
- }
- };
-
- // 导入商品信息
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'DeputyOrderUploadCtrl',
- size: 'lg',
- resolve: {
- }
- });
-
- modalInstance.result.then(function(data) {
- angular.forEach(data, function(data) {
- $scope.deOrder.deputyOrderItems.push(data);
- for(var i = 0; i < $scope.deOrder.deputyOrderItems.length; i++) {
- if($scope.deOrder.deputyOrderItems[i].prodname == null) { // 如果没有填写就删除这行数据
- $scope.deOrder.deputyOrderItems.splice(i, 1);
- }
- }
- })
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.usdpayment += item.amount * item.unitprice;
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- $scope.deOrder.orderamount += item.amount * item.unitprice * (1 + $scope.rate.rate/100);
- });
-
- }, function(){
-
- });
- }
-
- //删除商品
- $scope.delItem = function(index) {
- $scope.deOrder.deputyOrderItems.splice(index, 1);
- };
- var getService = function() {
- return DeputyOrder.getProdList;
- };
-
- $scope.update = function() {
- $scope.deOrder.$editing = true;
- }
-
- $scope.cancel = function() {
- $scope.deOrder.$editing = false;
- }
-
- // 检验订单编号是否存在
- $scope.checkOrder = function(salecode, deputyuu) {
- DeputyOrder.checkOrders({salecode: salecode, deputyuu: deputyuu}, {}, function(data) {
- if(data.info) {
- toaster.pop('error', '提示', data.info);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- //计算采购单价
- $scope.checkPrice = function(rate) {
- if(rate == null) {
- toaster.pop('info', '提示', '请先填入税率');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- item.purcprice = item.unitprice * (1 + rate/100);
- });
- }
- }
-
- // 保存
- $scope.save = function() {
- $scope.deOrder.entrystatus = '保存';
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.usdpayment += item.amount * item.unitprice;
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- $scope.deOrder.orderamount += item.amount * item.unitprice * (1 + $scope.rate.rate/100);
- });
- if($scope.deOrder.deputyOrderItems[0].prodcode == null) {
- toaster.pop('info', '提示', '您还未填写任何商品信息');
- } else {
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.id) {
- toaster.pop('success', '提示', '保存成功');
- loadData();
- }
- if(data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function(response) {
-
- });
- }
- }
-
- // 提交
- $scope.submit = function() {
- $scope.deOrder.entrystatus = '已提交';
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function(item) {
- $scope.deOrder.totalamount += item.amount * item.unitprice;
- $scope.deOrder.usdpayment += item.amount * item.unitprice;
- $scope.deOrder.totalpayament += item.amount * item.unitprice;
- $scope.deOrder.orderamount += item.amount * item.unitprice * (1 + $scope.rate.rate/100);
- });
- DeputyOrder.saveDeOrder({deOrder: $scope.deOrder}, {}, function(data) {
- if(data.id) {
- toaster.pop('success', '提示', '提交成功');
- window.location.hash = "#/purc/deputy/"+data.id;
- }
- if(data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function(response) {
-
- });
- }
-
- $scope.openDatePicker = function($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
-
- }]);
- /**
- * 代采错误日志
- */
- app.controller('DeputyOrderLogCtrl', ['$scope', 'DeputyOrder', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', function($scope, DeputyOrder, ngTableParams, $filter, BaseService, toaster, $timeout) {
- BaseService.scrollBackToTop();
- var getService = function() {
- return DeputyOrder.getRepetitions;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- //删除
- $scope.deleteById = function(id) {
- GetProductInfo.deleteById({id: id}, function(data) {
- if(data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function() {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function(response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
-
- }]);
-
- /**
- * 招标单
- */
- app.controller('PurcTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- BaseService.scrollBackToTop();
- if ($rootScope.tenderActive) {
- $scope.active = $rootScope.tenderActive;
- $rootScope.tenderActive = null;
- } else {
- $scope.active = 'done';
- }
- $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 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 : 20,
- 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.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('PurcNewTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'ShipAddress', '$http', 'AuthenticationService', 'KindAPI', 'BrandActiveAPI', 'Search', 'ComponentActiveAPI', 'GetProductInfo', 'Vendor',function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, ShipAddress, $http, AuthenticationService, KindAPI, BrandActiveAPI, Search, ComponentActiveAPI, GetProductInfo, Vendor) {
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- var getService = function() {
- return GetProductInfo;
- };
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //在产品列表添加商品
- $scope.check = function(product) {
- $scope.tenderProd.push({
- prodTitle: product.title,
- prodCode: product.code,
- brand: product.brand,
- unit: product.unit,
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- });
- for(var i = 0; i < $scope.tenderProd.length; i++) {
- if($scope.tenderProd[i].prodCode === null && $scope.tenderProd[i].prodTitle === null) { // 如果没有填写就删除这行数据
- $scope.tenderProd.splice(i, 1);
- }
- }
- };
- $scope.loading = false;
- // 获取收货地址列表
- var loadShipAddress = function() {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.tender.shipadd = $scope.ships[0];
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset":"charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- // 可选的证照要求
- $scope.certificates = [{name:'三/五证合一'}, {name:'营业执照'}, {name:'组织机构代码证'}, {name:'一般纳税人证明材料'},{name:'统计登记证'},{name:'社会保险登记证'}];
- // 处理证照要求
- var parseCertificate = function(a) {
- if (a) {
- var arr = a.split(',');
- angular.forEach(arr, function(app) {
- var contained = false;
- angular.forEach($scope.certificates, function($app) {
- if($app.name == app) {
- $app.checked = true;
- contained = true;
- }
- });
- if(!contained) {
- $scope.certificates.push({name: app, checked: true});
- }
- });
- }
- };
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function(value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword : value}).$promise.then(function(data) {
- return data.map(function(item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function(value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- // // 获取产品类目联想词
- // $scope.getSimilarKinds = function(value) {
- // if (value) {
- // // getSimilarLeafKinds 根据类目名获取末级联想词
- // // 获取类目联想词
- // return Search.getSimilarKinds({keyword : value}).$promise.then(function(data) {
- // return data.map(function(item) {
- // return item;
- // })
- // });
- // }
- // };
- // // 点击联想词获取类目信息
- // $scope.onAssociateKindClick = function(kind, submit) {
- // KindAPI.getParents({childId : kind.id}, {}, function(data) {
- // $scope.actives = data;
- // console.log(data);
- // var size = data.length;
- // if (size > 0) {
- // submit.gradeOneKiName = $scope.actives[0].nameCn;
- // submit.kiName = submit.gradeOneKiName;
- // if (size > 1) {
- // submit.gradeTwoKiName = $scope.actives[1].nameCn;
- // submit.kiName = submit.gradeTwoKiName;
- // if (kind.level < 3) {
- // submit.gradeThreeKiName = null;
- // } else if (size > 2) {
- // submit.gradeThreeKiName = $scope.actives[2].nameCn;
- // submit.kiName = submit.gradeThreeKiName;
- // }
- // }
- // }
- // console.log(submit);
- // })
- // };
- // 选择类目
- $scope.selectKind = function(prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function() {
- return $scope.actives;
- }
- }
- }).result.then(function(data){
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function(){
- });
- };
- // // 验证分类信息
- // $scope.checkKind = function() {
- // setTimeout(function() {
- // if($scope.activesString == null) {
- // $scope.component.kindid = null;
- // return;
- // }
- // KindAPI.getKindByName({name : encodeURIComponent($scope.activesString)}, function(kind) {
- // $scope.component.kind = kind;
- // $scope.component.kindid = kind.id;
- // $scope.activesString = $scope.component.kind.nameCn;
- // KindAPI.getPropertiesValues({kindId: $scope.component.kindid}, function(data) {
- // $scope.kindProperties = data;
- // angular.forEach($scope.kindProperties, function(kp) {
- // angular.forEach($scope.component.properties, function(pro) {
- // if (pro.value && (kp.propertyId == pro.propertyid)) {
- // kp.value = pro.value;
- // }
- // });
- // });
- // }, function(response) {
- // });
- // }, function (response) {
- // $scope.component.kindid = null;
- // toaster.pop('error', response.data);
- // });
- // }, 500);
- // };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function(brand, prod) {
- if (brand instanceof String) {
- prod.brand = brand;
- } else if (brand instanceof Object) {
- prod.brand = brand.brandCn;
- }
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function(prod){ //打开模态
- var modalInstance = $modal.open({
- templateUrl : 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller : 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function(){// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function(brand){
- prod.brand = brand.nameCn;
- }, function(reason){
- });
- };
- // // 验证品牌是否正确
- // $scope.checkBrand = function () {
- // setTimeout(function () {
- // BrandActiveAPI.findByName({name : encodeURIComponent($scope.component.brand.nameCn)}, function (data) {
- // // $scope.component.brand = brand;
- // // $scope.component.brandid = brand.id;
- // }, function (response) {
- // // $scope.component.brandid = null;
- // toaster.pop('error', response.data);
- // })
- // } , 500);
- // };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function(cmp, prod) {
- ComponentActiveAPI.get({uuid : cmp.uuid}, {}, function(data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.brand = data.brand.nameCn;
- }, function(res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- $scope.condition = {dateZone: 1};
- $scope.tenderProd = [];
- var prod = {
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- };
- $scope.tender = {
- date: new Date(),
- unit: 'PCS',
- currency: 'RMB',
- ifOpen: 1,
- ifTax: 1,
- invoiceType: 2,
- tenderAttachs:[{}]
- };
- //
- $scope.tenderProd.push(prod);
- //增加商品
- $scope.add = function(index) {
- $scope.tenderProd.push({
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- });
- };
- //删除商品
- $scope.del = function(index) {
- $scope.tenderProd.splice(index, 1);
- };
- // 批量导入
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcTenderUploadCtrl',
- size: 'lg',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- // 获取上传的产品明细,前台展示
- angular.forEach(data, function(data) {
- $scope.tenderProd.push(data);
- for(var i = 0; i < $scope.tenderProd.length; i++) {
- if($scope.tenderProd[i].prodTitle == null) { // 如果没有填写就删除这行数据
- $scope.tenderProd.splice(i, 1);
- }
- }
- });
- }, function(){
- });
- };
- $scope.isSave = false;
- // 已存在id的为查看招标单(用于在录入的招标单的发布和删除)
- if( ! angular.isUndefined($stateParams.id)) {
- $scope.isSave = true; // 用于判断是新增还是已保存
- $scope.loading = true;
- PurcTender.getOne({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- parseCertificate($scope.tender.certificate);
- $scope.firstProd = data.purchaseTenderProds[0];
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function(item) {
- // 获取供应商联系人
- Vendor.contacts({venduu: item.saleTender.vendUU}, {}, function(data) {
- item.saleTender.enterpriseBaseInfo.contacts = data;
- // item.saleTender.enterpriseBaseInfo.contact = data[0];
- angular.forEach(item.saleTender.enterpriseBaseInfo.contacts, function(contact) {
- if (item.saleTender.userTel === contact.tel) {
- item.saleTender.enterpriseBaseInfo.contact = contact;
- }
- });
- });
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, item.saleTender.enterpriseBaseInfo);
- } else {
- $scope.tenderProd.enterpriseBaseInfo.push(item.saleTender.enterpriseBaseInfo);
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- if(angular.isUndefined($stateParams.id)) { // 发布招标单之后,再次新增招标单时,新增供应商时不会勾选上一个单据选择的供应商
- $rootScope.tenderVendor = [{}];
- }
- $scope.changeShipAddress = false;
- $scope.changeAddress = function() {
- if ($scope.changeShipAddress) {
- $scope.changeShipAddress = false;
- } else {
- $scope.changeShipAddress = true;
- }
- };
- $scope.changeContactInfo = function(en) {
- if (en.changeContact) {
- en.changeContact = false;
- } else {
- en.changeContact = true;
- }
- };
- $scope.changeCurrency = function(tender) {
- if (tender.currency !== 'RMB') {
- $scope.notRMB = true;
- tender.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- tender.invoiceType = 0;
- } else {
- $scope.notRMB = false;
- }
- };
- // $scope.validateNumber = function (value) { // 采购数量 正整数
- // var regex = /^\+?[1-9][0-9]*$/;
- // if (!regex.test(value) || value === 0 || value === null) {
- // toaster.pop('warning', '警告', '采购数量不合法,请重新填写');
- // }
- // };
- // 查找供应商
- $scope.dbfindVendor = function(){
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {
- }
- });
- var ifPush = true;
- modalInstance.result.then(function(data){
- angular.forEach(data, function(vendor) {
- // 获取供应商联系人
- Vendor.contacts({venduu: vendor.vendorEnterprise.uu}, {}, function(data) {
- vendor.vendorEnterprise.contacts = data;
- $scope.tenderProd.enterpriseBaseInfo.contact = vendor.vendorEnterprise.contacts[0];
- });
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- // 获取供应商联系人
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0;i<$scope.tenderProd.enterpriseBaseInfo.length; i++) {
- ifPush = true;
- if ($scope.tenderProd.enterpriseBaseInfo[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.tenderProd.enterpriseBaseInfo.push(vendor.vendorEnterprise);
- }
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- }, function(){
- });
- };
- // 新增供应商联系人
- $scope.addContact = function(en) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function(data) {
- en.contact = data;
- en.contact.venduu = en.uu;
- Vendor.saveContact({}, en.contact, function(data) {
- Vendor.contacts({venduu: en.uu}, {}, function(data) {
- en.contacts = data;
- en.contact = data[0]; // 新增的作为联系人
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function(response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function(index) {
- $scope.tenderProd.enterpriseBaseInfo.splice(index, 1);
- };
- // 删除供应商时,后台删除投标单
- $scope.removeSaleTender = function (id, vendUU) {
- var hasSaved = false;
- angular.forEach($scope.tender.purchaseTenderProds[0].saleTenderItems, function(saleTenderItem) {
- if (saleTenderItem.saleTender.vendUU === vendUU) { //有相等的说明是之前保存过的供应商
- hasSaved = true;
- }
- });
- if (hasSaved) {
- PurcTender.removeSaleTender ({id : id, vendUU : vendUU}, {}, function(data) {
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- };
- // 删除产品明细时,后台删除产品明细
- $scope.deleteProd = function (tenderProd) {
- if (tenderProd.id) {
- PurcTender.deleteProd ({tenderProdId : tenderProd.id}, {}, function(data) {
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- };
- // // 查找客户物料
- // $scope.dbfindCustProd = function(){
- // if($scope.item.$editing) {
- // if($scope.item.quotation.cust.uu) {
- // var modalInstance = $modal.open({
- // templateUrl: 'static/tpl/index/sale/quotation_new_custProd.html',
- // controller: 'DbfindCustProdCtrl',
- // size: 'lg',
- // resolve: {
- // custUU: function(){return $scope.item.quotation.cust.uu}
- // }
- // });
- //
- // modalInstance.result.then(function(data){
- // $scope.item.product = data;
- // }, function(){
- //
- // });
- // } else {
- // toaster.pop('error', '错误', '请先选择客户');
- // }
- // }
- // };
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- $scope.upload = function(myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderAttach',
- file: file,
- method: 'POST'
- // data: {
- // tender: $scope.tender
- // }
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function(id, index) {
- $scope.attaches.splice(index, 1);
- // PurcTender.removeAttach({attachId:id}, function() {
- //
- // });
- };
- var sleep = function (d){
- for(var t = Date.now();Date.now() - t <= d;);
- };
- // 保存和发布招标单
- $scope.save = function(isPublish){
- if ($scope.tender.ifOpen == 0 && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info','提示','请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function(certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if(!$scope.tender.code) { //新增,设单号
- $scope.tender.code = 'ZB' + $filter('date')(new Date(), 'yyMMddHHmmss');
- }
- if($scope.tender.date instanceof Date) {
- $scope.tender.date = $scope.tender.date.getTime();
- }
- if($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- var enInfos = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function(enterpriseBaseInfo){
- var enInfo = {
- uu: null,
- contact: null,
- contactTel: null
- };
- enInfo.uu = enterpriseBaseInfo.uu;
- if (typeof enterpriseBaseInfo.contact !== 'undefined') {
- enInfo.contact = enterpriseBaseInfo.contact.venduser;
- enInfo.contactTel = enterpriseBaseInfo.contact.tel;
- }
- enInfos.push(enInfo);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- $scope.tender.isPublish = 1;
- PurcTender.publish({tender: $scope.tender, enInfos: enInfos}, {}, function(data){
- // sleep(1500); //当前方法暂停1.5秒
- $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- $scope.tender.isPublish = 0;
- PurcTender.save({tender: $scope.tender, enInfos: enInfos}, {}, function(data) {
- $scope.loading = false;
- // sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- // 切换为在平台公开招标时,清除掉已添加的供应商信息
- $scope.removeChecked = function() {
- if ($scope.tenderProd.enterpriseBaseInfo.size > 0) {
- $scope.tenderProd.enterpriseBaseInfo = [];
- }
- };
- // 删除(在录入状态)
- $scope.deleteThis = function(id) {
- PurcTender.deleteOne({id:id}, {}, function(data) {
- toaster.pop('info', '提示', '删除成功');
- window.location.hash = '#/purc/tender';
- });
- };
- // 更新和发布(在录入状态)
- $scope.updateSaved = function(isPublish){
- if (Number($scope.tender.ifOpen) === 0 && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info','提示','请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function(certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- if ($scope.tender.shipadd) {
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- }
- angular.forEach($scope.tender.purchaseTenderProds, function(tenderProd){
- tenderProd.saleTenderItems = []; // 投标相关不用传参,否则会超长
- });
- var enInfos = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function(enterpriseBaseInfo){
- var enInfo = {
- uu: null,
- contact: null,
- contactTel: null
- };
- enInfo.uu = enterpriseBaseInfo.uu;
- if (typeof enterpriseBaseInfo.contact !== 'undefined') {
- enInfo.contact = enterpriseBaseInfo.contact.venduser;
- enInfo.contactTel = enterpriseBaseInfo.contact.tel;
- }
- enInfos.push(enInfo);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- PurcTender.publishSaved({tender: $scope.tender, enInfos: enInfos}, {}, function(data){
- sleep(1500); //当前方法暂停1.5秒
- // $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- PurcTender.updateSaved({tender: $scope.tender, enInfos: enInfos}, {}, function(data) {
- $scope.loading = false;
- // sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '成功', '保存成功');
- window.location.reload();
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- $scope.currentDay = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.getMinDate = function() {
- // var now = new Date();
- // now = now.setDate(now.getDate()+1);
- // var minDate = angular.copy($scope.tender.endDate);
- // minDate = minDate.setDate(minDate.getDate() + 1);
- if ($scope.tender.endDate instanceof Date) {
- var minDate = new Date($scope.tender.endDate.getTime() + 24*60*60*1000 + 1); // 不能选相同一天
- }
- return $scope.tender.endDate ? $filter('date')(minDate, 'yyyy-MM-dd'):$filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.getMaxDate = function() {
- // var maxDate = angular.copy($scope.tender.publishDate);
- // maxDate = maxDate.setDate(maxDate.getDate() - 1);
- if ($scope.tender.publishDate instanceof Date) {
- var maxDate = new Date($scope.tender.publishDate.getTime() - 1); // 不能选同一天
- }
- return $scope.tender.publishDate ? $filter('date')(maxDate, 'yyyy-MM-dd'):"";
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- //类目选择模态框(招标产品明细)
- app.controller('ProdKindChooseCtrl', ['$scope', 'KindAPI', 'actives', 'toaster', '$modalInstance', function($scope, KindAPI, actives, toaster, $modalInstance) {
- $scope.actives = actives;
- $scope.kinds = [[], [], [], []];
- // 获取子类目
- var getChildren = function(pid, deep) {
- KindAPI.getChildren({parentId: pid}, function(data) {
- $scope.kinds[deep] = data;
- }, function(response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- };
- // 改变节点选中状态
- var changeStatus = function(item, deep) {
- var actives = [], level = 0;
- angular.forEach($scope.kinds, function(ks, i) {
- if(i > deep) {
- $scope.kinds[i] = [];
- } else {
- angular.forEach(ks, function(k, j) {
- if(i == deep) {
- if(k.id == item.id) {
- $scope.kinds[i][j].$active = true;
- actives.push(k);
- } else {
- k.$active = null;
- }
- } else {
- if(k.$active) {
- actives.push(k);
- }
- }
- });
- }
- });
- // 选择的节点
- $scope.actives = actives;
- $scope.active = item;
- // 当前可操作的层级
- if(deep < 3) {
- $scope.activeDeep = deep + 1;
- }
- };
- // 节点点击后获取子类目,节点被选中
- $scope.onItemClick = function(item, deep) {
- changeStatus(item, deep);
- if (!item.isLeaf) {
- getChildren(item.id, deep + 1);
- }
- };
- // 重新加载数据
- function reload(deep) {
- var pid;
- if(deep) {
- pid = $scope.actives[deep - 1].id;
- } else {
- pid = 0;
- deep = 0;
- }
- getChildren(pid, deep);
- }
- // 初始加载数据,获取第一层的类目
- if($scope.actives) {
- angular.forEach($scope.actives, function(v, k) {
- KindAPI.getChildren({parentId: v.parentid}, function(data) {
- $scope.kinds[k] = data;
- angular.forEach($scope.kinds[k], function(kind, i){
- if(kind.id == v.id) {
- $scope.kinds[k][i].$active = true;
- $scope.actives[k] = $scope.kinds[k][i];
- }
- })
- }, function(response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- });
- } else {
- reload();
- }
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- // 确认选择
- $scope.check = function() {
- var a = {
- active: $scope.active,
- actives: $scope.actives
- };
- $modalInstance.close(a);
- };
- }]);
- //品牌选择模态框的controller
- app.controller('BrandModalInstanceCtrl', ['$scope', '$modalInstance', 'ngTableParams', 'BrandActiveAPI', 'BaseService', function($scope, $modalInstance, ngTableParams, BrandActiveAPI, BaseService) {
- $scope.filter = {};
- $scope.brandsTableParams = new ngTableParams({
- page : 1,
- count : 6,
- sorting : {
- nameCn: 'asc'
- }
- }, {
- total : 0,
- counts : [],
- getData : function($defer, params) {
- var param = BaseService.parseParams(params.url());
- param.keyword = $scope.filter.keyword;
- var keyword = $scope.filter.keyword;
- // param.keyword = $scope.filter.keyword;
- BrandActiveAPI.getSimpleInfoPage(param, {}, function(page) {
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function(){
- });
- }
- });
- // 搜索
- $scope.search = function() {
- // $scope.brandsTableParams.filter({$: $scope.filter.keyword});
- $scope.brandsTableParams.page(1);
- $scope.brandsTableParams.reload();
- };
- // 选择
- $scope.select = function(brand){
- $modalInstance.close(brand);
- };
- // 关闭
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 招标单批量导入
- */
- app.controller('PurcTenderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function() {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'tender/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function(response) {
- toaster.pop('error', '提示', '上传失败,请检查填写格式');
- });
- };
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadTenderProducts_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function() {
- window.location.href = 'tender/upload/template';
- };
- $scope.enSure = function() {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 评标
- */
- app.controller('PurcEvaluationCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.tenderItems = [];
- // 采购方获取评标单
- var evaluation = function() {
- $scope.loading = true;
- PurcTender.getOne({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.tender = data;
- $scope.tableParams = new ngTableParams({}, { dataset: data});
- // $scope.tableParams.sorting($scope.sort.field, $scope.sort.desc);
- $scope.loading = false;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- evaluation();
- $scope.orderType = '';
- // $scope.dir = '-';
- // 改变排序顺序
- $scope.changeOrder = function(type){
- $scope.orderType = type;
- // if(!$scope.dir || $scope.dir === '') {
- // $scope.dir = '-';
- // }else {
- // $scope.dir = '';
- // }
- };
- $scope.submit = function(tender) {
- var canSubmit = false;
- var hasDecide = false;
- angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- if (saleTenderItem.price && 0 !== saleTenderItem.saleTender.auditStatus && typeof saleTenderItem.applyStatus !== 'undefined') { // 只要存在报价的行,就需要对其中一个定标
- hasDecide = true;
- }
- });
- if (hasDecide) {
- canSubmit = true;
- }
- });
- if (!canSubmit) {
- toaster.pop('info', '提示', '您还有已投标未选定的产品!');
- } else {
- PurcTender.decide(tender, function(){
- toaster.pop('success', '确认成功');
- window.location.hash = '#/purc/tender';
- }, function(response){
- toaster.pop('error', '确认失败', response.data);
- });
- }
- }
- }]);
- /**
- * 客户招标
- *
- */
- app.controller('SaleTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- if($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- /**
- * 改变类型
- */
- var getTypeCondition = function(zone, condition) {
- if(zone == -1) {
- condition.ifOpen = null;
- } else if(zone == 1) {
- condition.ifOpen = 1;
- } else {
- condition.ifOpen = 0;
- }
- };
- $scope.dateZoneText = '不限';
- $scope.typeText = '全部';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1, deliveryZone: -1, type: -1};
- $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.changeType = function(type) {
- $scope.condition.type = type;
- $scope.typeText = typeof type == 'undefined' ? '全部' : (type == -1 ? '全部' : (type == 1 ? '公开' : '指定'));
- getTypeCondition(type, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- 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,
- pt_ifopen: $scope.condition.ifOpen,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.currentEn = data;
- });
- PurcTender[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- angular.forEach(page.content, function(purcTender) {
- purcTender.vendorHasBid = false;
- angular.forEach(purcTender.purchaseTenderProds, function(tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- if ($scope.currentEn.uu === saleTenderItem.saleTender.vendUU) {
- tenderProd.currentItem = saleTenderItem;
- if (saleTenderItem.price && saleTenderItem.saleTender.auditStatus != 0) { //TODO 如果存在当前企业的投标明细已投标且不在已提交状态,即判断为已投标
- purcTender.vendorHasBid = true;
- }
- }
- });
- });
- });
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $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('SaleOpenTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- /**
- * 改变单据日期范围
- */
- var getTenderDateCondition = function(zone, condition) {
- var date = new Date();
- if(zone == -1) {
- condition.dateFrom = null;
- condition.dateTo = null;
- } else if(zone == 7) { // 一星期内
- date.setDate(date.getDate() - 7);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if(zone == 1) { // 一个月内
- date.setMonth(date.getMonth() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if(zone == 3) { // 三个月内
- date.setMonth(date.getMonth() - 3);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 6) { // 半年内
- date.setMonth(date.getMonth() - 6);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else { // 一年内
- date.setYear(date.getYear() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- }
- };
-
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.condition.$dateZoneOpen = false;
- getTenderDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.parseDate = function(dateStr) {
- if(dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function(){
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // $scope.setActive = function(state) {
- // if($scope.active != state) {
- // $scope.active = state;
- // if($scope.tableParams.page() == 1)
- // $scope.tableParams.reload();
- // else
- // $scope.tableParams.page(1);
- // }
- // };
- var getOpenState = function(active) {
- var fn = 'getOpenAll';
- switch(active) {
- case 'all':
- fn = 'getOpenAll';break;
- // case 'done':
- // fn = 'getOpenDone';break;
- case 'todo':
- fn = 'getOpenTodo';break;
- case 'end':
- fn = 'getOpenEnd';break;
- // case 'waiting':
- // fn = 'getOpenWaiting';break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- 'tender.endDate': 'desc',
- 'tender.enterprise.enName': 'asc',
- 'tender.code': 'asc'
- }
- }, {
- total : 0,
- counts: [],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function(data){
- $scope.loading = false;
- $scope.currentEn = data;
- });
- PurcTender[getOpenState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.toDetail = function(id) {
- window.location.hash = '#/baseInfo/openTenderDetail/' + id;
- };
- // var stautsItem = [];
- // $scope.getTenderStatus = function (tender) {
- // angular.forEach(tender.purchaseTenderItems, function(thisItem){
- // if ($scope.currentEn.uu == thisItem.enterpriseBaseInfo.uu) {
- // stautsItem = thisItem;
- // }
- // });
- // if (!stautsItem.price) {
- // return "daitoubiao";
- // } else if (!stautsItem.applystatus) {
- // return "yitoubiao";
- // } else if (stautsItem.applystatus == 1) {
- // return "zhongbiao";
- // } else if (stautsItem.applystatus == 0) {
- // return "weizhongbiao";
- // }
- // };
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 采购方查看供应商投标单
- */
- app.controller('SaleVendorTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- // PurcTender.getVendorTenderItem({vendUU:$stateParams.vendUU, id: $stateParams.id}, function(data){
- // $scope.item = data; // 供应商查看
- // $scope.loading = false;
- // }, function(response){
- // $scope.loading = false;
- // toaster.pop('error', '数据加载失败', response.data);
- // });
- PurcTender.getOne({id: $stateParams.id}, function(data){
- $scope.bid = data;
- var vendUU = Number($stateParams.vendUU);
- angular.forEach(data.purchaseTenderProds, function(tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- if (saleTenderItem.saleTender.vendUU === vendUU) {// 与传出的参数venUU相等,即为查看企业对应的明细
- tenderProd.currentItem = saleTenderItem;
- $scope.saleTender = saleTenderItem.saleTender;
- $scope.currentEnBaseInfo = saleTenderItem.saleTender.enterpriseBaseInfo;
- }
- });
- });
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
- }]);
- /**
- * 查看投标单详情
- */
- app.controller('SaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise) {
- BaseService.scrollBackToTop();
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- // var staticItem = null;
- // $scope.loading = true;
- // PurcTender.getItem({id: $stateParams.id}, function(data){
- // $scope.item = data; // 用于投标
- // if ($scope.item.enterpriseBaseInfo != null) {
- // $scope.itemStatusTodo = $scope.item.enterpriseBaseInfo.uu + "待投标";
- // }
- // staticItem = angular.copy(data);
- // $scope.loading = false;
- // }, function(response){
- // $scope.loading = false;
- // toaster.pop('error', '数据加载失败', response.data);
- // });
- var sleep = function (d){
- for(var t = Date.now();Date.now() - t <= d;);
- };
- AccountEnterprise.get({}, function(data){
- $scope.currentEn = data;
- });
- PurcTender.getOne({id: $stateParams.id}, function(data){
- $scope.bid = data;
- angular.forEach(data.purchaseTenderProds, function(tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- if (!$scope.currentEn) {
- AccountEnterprise.get({}, function(data){
- $scope.currentEn = data;
- });
- }
- if (saleTenderItem.saleTender.vendUU === $scope.currentEn.uu) {
- tenderProd.currentItem = saleTenderItem;
- $scope.saleTender = saleTenderItem.saleTender;
- $scope.attaches = saleTenderItem.saleTender.bidAttaches;
- $scope.currentEnBaseInfo = saleTenderItem.saleTender.enterpriseBaseInfo;
- }
- });
- });
- }, function(response){
- toaster.pop('error', '数据加载失败', response.data);
- });
- $scope.upload = function(myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderItemAttach',
- file: file,
- method: 'POST'
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function(attachId, index) {
- $scope.attaches.splice(index, 1);
- // PurcTender.removeAttach({attachId : id}, {}, function() {
- //
- // });
- };
- var taxrateYes = false;
- var cycleYes = false;
- var priceYes = false;
- $scope.canSave = false;
- $scope.validateThis = function(value, type) {
- switch(type) {
- case 'taxrate':
- var regex = /^\+?[0-9][0-9]{0,1}$/;
- if (regex.test(value)) {
- taxrateYes = true;
- } else {
- if (value) {
- toaster.pop('warning', '警告', '税率不合法,请重新填写');
- }
- }
- break;
- case 'cycle':
- regex = /^\+?[1-9][0-9]*$/;
- if (regex.test(value)) {
- cycleYes = true;
- } else {
- if (value) {
- toaster.pop('warning', '警告', '周期不合法,请重新填写');
- }
- }
- break;
- case 'price':
- regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (regex.test(value) && value !== 0) {
- priceYes = true;
- } else {
- if (value) {
- toaster.pop('warning', '警告', '请确认单价是否填写正确');
- }
- }
- break;
- }
- };
- $scope.emNumYes = true;
- $scope.validEmNum = function (value) {
- var regex = /^\+?[1-9][0-9]*$/;
- if (!regex.test(value) || value === 0 || value !== null) {
- $scope.emNumYes = false;
- toaster.pop('warning', '警告', '人数不合法,请重新填写');
- }
- };
- $scope.validateProds = function(tenderProd) {
- $scope.canSave = true;
- if (tenderProd.currentItem.cycle || tenderProd.currentItem.taxrate || tenderProd.currentItem.price) {
- var cycleRegex = /^\+?[1-9][0-9]*$/;
- var taxrateRegex = /^\+?[0-9][0-9]{0,1}$/;
- var priceRegex = /^(([0-9]+\.[0-9]{1,6})|([0-9]*[1-9][0-9]*\.[0-9]{1,6})|([0-9]*[1-9][0-9]*))$/; // 非零最多六位小数正实数
- // /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- // 判断填写过的有为0或不符合正则式的,设置不能保存
- if (!cycleRegex.test(tenderProd.currentItem.cycle) || !taxrateRegex.test(tenderProd.currentItem.taxrate) || !priceRegex.test(tenderProd.currentItem.price)) {
- $scope.canSave = false;
- } else {
- $scope.canSave = true;
- }
- }
- };
- // 投标
- $scope.bidIt = function(tender, currentEnBaseInfo){
- $scope.loading = true;
- if(currentEnBaseInfo.enEstablishDate instanceof Date) {
- currentEnBaseInfo.enEstablishDate = currentEnBaseInfo.enEstablishDate.getTime();
- }
- var saleTenderItems = [];
- angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- if (tenderProd.currentItem) {
- if ("" !== tenderProd.currentItem.price && "" !== tenderProd.currentItem.taxrate && "" !== tenderProd.currentItem.cycle) {
- tenderProd.currentItem.saleTender = {};
- saleTenderItems.push(tenderProd.currentItem);
- }
- }
- });
- PurcTender.reply({tenderItems: saleTenderItems, enBaseInfo: currentEnBaseInfo, attaches:$scope.attaches}, {}, function(data){
- $scope.loading = false;
- toaster.pop('info', '成功', '投标成功');
- // $window.location.reload();
- // if (tender.ifOpen) { // 根据是否公开,选择跳转
- // window.location.hash = '#/sale/opentender';
- // } else {
- window.location.hash = '#/sale/tender';
- // }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '投标失败', '出现异常,投标失败');
- });
- };
- $scope.condition = {
- $fromOpened:false
- };
- $scope.getMaxDate = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- /**
- * 公开招标转投标单
- */
- app.controller('OpenSaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', function($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise) {
- BaseService.scrollBackToTop();
- $scope.attaches = []; // 存放上传了的附件
- var sleep = function (d){
- for(var t = Date.now();Date.now() - t <= d;);
- }
- var getCurrentEn = function() {
- AccountEnterprise.get({}, function(data){
- $scope.currentEn = data;
- });
- }
- if( ! angular.isUndefined($stateParams.id)) { // 获取招标单详情
- $scope.loading = true;
- getCurrentEn();
- PurcTender.getOne({id: $stateParams.id}, function(data){
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- // parseCertificate($scope.tender.certificate);
- // $scope.firstProd = data.purchaseTenderProds[0];
- $scope.currentHasBid = false; // 默认当前企业未转投标单
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function(item) {
- if ($scope.currentEn.uu === item.saleTender.vendUU) { // 存在当前企业为供应商的投标单,判断已转
- $scope.currentHasBid = true;
- }
- });
- // $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- // console.log($scope.tenderProd.enterpriseBaseInfo);
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- $scope.hasClick = false;
- $scope.iWantToBid = function(id) {
- $scope.hasClick = true;
- PurcTender.addItems({id: id}, {}, function(data){ // 添加明细
- // $scope.tender = data;
- // angular.forEach(data.purchaseTenderProds, function(tenderProd) {
- // angular.forEach(tenderProd.saleTenderItems, function(saleTenderItem) {
- // if (!$scope.currentEn) {
- // AccountEnterprise.get({}, function(data){
- // $scope.currentEn = data;
- // });
- // }
- // if (saleTenderItem.saleTender.vendUU === $scope.currentEn.uu) {
- // tenderProd.currentItem = saleTenderItem;
- // $scope.saleTender = saleTenderItem.saleTender;
- // $scope.attaches = saleTenderItem.saleTender.bidAttaches;
- // $scope.currentEnBaseInfo = saleTenderItem.saleTender.enterpriseBaseInfo;
- // }
- // });
- // });
- toaster.pop('success', '成功', '转投标单成功');
- window.location.hash = "#/sale/tender/" + id;
- }, function(response){
- toaster.pop('error', '操作失败', response.data);
- });
- // $scope.upload = function(myFile) { // 上传附件
- // var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- // $upload.upload({
- // url: 'tender/addTenderItemAttach',
- // file: file,
- // method: 'POST'
- // }).success(function (attach) {
- // $scope.attaches.push(attach);
- // });
- // };
- };
- // $scope.removeAttach = function(id, index) {
- // $scope.attaches.splice(index, 1);
- // PurcTender.removeAttach({attachId:id}, function() {
- //
- // });
- // };
- // var taxrateYes = false;
- // var cycleYes = false;
- // var priceYes = false;
- // $scope.canSave = false;
- // $scope.validateThis = function(value, type) {
- // switch(type) {
- // case 'taxrate':
- // var regex = /^\+?[0-9][0-9]{0,1}$/;
- // if (regex.test(value)) {
- // taxrateYes = true;
- // } else {
- // toaster.pop('warning', '警告', '税率不合法,请重新填写');
- // }
- // break;
- // case 'cycle':
- // regex = /^\+?[1-9][0-9]*$/;
- // if (regex.test(value)) {
- // cycleYes = true;
- // } else {
- // toaster.pop('warning', '警告', '周期不合法,请重新填写');
- // }
- // break;
- // case 'price':
- // regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- // if (regex.test(value) && value !== 0) {
- // priceYes = true;
- // } else {
- // if (!(value instanceof Number) || value) {
- // toaster.pop('warning', '警告', '单价不合法,请重新填写');
- // }
- // }
- // break;
- // }
- // };
- //
- // $scope.emNumYes = true;
- //
- // $scope.validEmNum = function (value) {
- // var regex = /^\+?[1-9][0-9]*$/;
- // if (!regex.test(value) || value == 0 || value !== null) {
- // $scope.emNumYes = false;
- // toaster.pop('warning', '警告', '人数不合法,请重新填写');
- // }
- // };
- //
- // $scope.validateProds = function(tenderProd) {
- // // angular.forEach(tenderProds, function (tenderProd) {
- // var cycleRegex = /^\+?[1-9][0-9]*$/;
- // var taxrateRegex = /^\+?[0-9][0-9]{0,1}$/;
- // var priceRegex = /^(([0-9]+\.[0-9]{1,6})|([0-9]*[1-9][0-9]*\.[0-9]{1,6})|([0-9]*[1-9][0-9]*))$/; // 非零最多六位小数正实数
- // // /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- // // 判断填写过的有为0或不符合正则式的,设置不能保存
- // console.log(tenderProd.currentItem.cycle);
- // if (tenderProd.currentItem.cycle !== null && (!cycleRegex.test(tenderProd.currentItem.cycle)) || (tenderProd.currentItem.taxrate !== null && !taxrateRegex.test(tenderProd.currentItem.taxrate)) || (tenderProd.currentItem.price !==null && (!priceRegex.test(tenderProd.currentItem.price) && tenderProd.currentItem.price !== 0))) {
- // $scope.canSave = false;
- // } else {
- // $scope.canSave = true;
- // }
- // // });
- // };
- //
- // // 投标
- // $scope.bidIt = function(tender, currentEnBaseInfo){
- // $scope.loading = true;
- // if(currentEnBaseInfo.enEstablishDate instanceof Date) {
- // currentEnBaseInfo.enEstablishDate = currentEnBaseInfo.enEstablishDate.getTime();
- // }
- // var saleTenderItems = [];
- // if (tender.ifOpen !== 1) { // 指定投标不把投标单主表设空会报header超长
- // angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- // if (tenderProd.currentItem) {
- // tenderProd.currentItem.saleTender = {};
- // saleTenderItems.push(tenderProd.currentItem);
- // }
- // });
- // } else {
- // angular.forEach(tender.purchaseTenderProds, function(tenderProd) {
- // if (tenderProd.currentItem) {
- // saleTenderItems.push(tenderProd.currentItem);
- // }
- // });
- // }
- // PurcTender.reply({tenderItems: saleTenderItems, enBaseInfo: currentEnBaseInfo, attaches:$scope.attaches}, {}, function(data){
- // $scope.loading = false;
- // toaster.pop('info', '成功', '投标成功');
- // // $window.location.reload();
- // // if (tender.ifOpen) { // 根据是否公开,选择跳转
- // // window.location.hash = '#/sale/opentender';
- // // } else {
- // window.location.hash = '#/sale/tender';
- // // }
- // }, function(response){
- // $scope.loading = false;
- // toaster.pop('error', '投标失败', '出现异常,投标失败');
- // });
- //
- // };
- //
- // $scope.condition = {
- // $fromOpened:false
- // };
- //
- // $scope.getMaxDate = function() {
- // return $filter('date')(new Date(), 'yyyy-MM-dd');
- // };
- //
- // $scope.openDatePicker = function($event, item, openParam) {
- // $event.preventDefault();
- // $event.stopPropagation();
- // item[openParam] = !item[openParam];
- // };
- }]);
- // 基础资料客户详情
- app.controller('CustomersInfoCtrl', ['$scope', 'VendorService', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', 'VendorInfo', function($scope, VendorService, BaseService, AuthenticationService,ngTableParams,$modal, toaster, VendorInfo){
- BaseService.scrollBackToTop();
- $scope.status = 'customer';
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
-
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
-
- // 查看详情
- $scope.viewDetail = function(id) {
- window.location.hash = "#/sale/customer/" + id;
- }
- // 取消合作关系
- $scope.disableCust = function(id) {
- VendorInfo.disableCust({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 解除禁用
- $scope.activeCust = function(id) {
- VendorInfo.activeCust({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- }]);
-
- // 基础资料供应商
- app.controller('VendorsInfoCtrl', ['$scope', 'Vendor', 'BaseService','AuthenticationService', 'ngTableParams', '$modal','toaster', '$rootScope', 'VendorInfo', function($scope, Vendor, BaseService, AuthenticationService,ngTableParams,$modal, toaster, $rootScope, VendorInfo){
- BaseService.scrollBackToTop();
- $scope.status = 'vendor';
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
-
- $scope.customerParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- // 查看供应商详情
- $scope.VendorDetail = function(id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/"+$rootScope.vendorId;
- }
-
- // 向企业购买
- $scope.purcByEn = function(businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
-
- // 取消合作关系
- $scope.relieve = function(id) {
- VendorInfo.relieve({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 建立合作关系
- $scope.activeVend = function(id) {
- VendorInfo.activeVend({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- }]);
- // 企业圈搜索界面
- app.controller('AddPartnersCtrl', ['$scope', '$rootScope', function($scope, $rootScope) {
- $scope.onSearch = function(keyword) {
- $rootScope.enterpriseKeyword = keyword;
- window.location.hash = "#/baseInfo/search?keyword=" + $rootScope.enterpriseKeyword;
- }
- }]);
-
- // 企业圈搜索结果
- app.controller('EnterpriseSearchCtrl', ['$scope', 'getAccountUserSpace', 'ngTableParams', '$filter', 'BaseService', 'toaster', 'AddPartner', '$rootScope', '$modal', 'InvitationRecord', function($scope, getAccountUserSpace, ngTableParams, $filter, BaseService, toaster, AddPartner, $rootScope, $modal, InvitationRecord) {
- $scope.status = 'add';
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return getAccountUserSpace;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page) {
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- if($scope.keyword != null && $scope.keyword != '') {
- $rootScope.searchKeyword = keyword;
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- };
-
- // 添加合作关系
- $scope.addPartner = function(name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function(data) {
- if(data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function(response) {
- toaster.pop('error','失败',response.data);
- });
- }
-
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function(name) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function(){return name}
- }
- });
- modalInstance.result.then(function(data) {
- InvitationRecord.invite({formStore: data}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- /**
- * 立即查看
- */
- $scope.view = function(name) {
- $rootScope.vendName = name;
- window.location.hash = "#/baseInfo/newPartner";
- }
- }]);
-
- // 平台新增的询价单(指定一个供应商)
- app.controller('PurcInquiryNewCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'GetProductInfo', '$timeout', '$http', 'ShipAddress', '$stateParams', 'Vendor', 'Product', 'Search', 'ComponentActiveAPI', 'VendorInfo', function($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, GetProductInfo, $timeout, $http, ShipAddress, $stateParams, Vendor, Product, Search, ComponentActiveAPI, VendorInfo) {
- $scope.active = 'all';
-
- // 供应商信息
- var loadData = function() {
- Vendor.enterpriseInfo({bussinessCode: $stateParams.bussinessCode}, {}, function(data) {
- $scope.vendor = data;
- Vendor.contacts({venduu: $scope.vendor.uu}, {}, function(data) {
- $scope.vendorContacts = data;
- });
-
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.custUU = $scope.vendor.uu;
- Product.get.call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function(response){
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- });
- };
- loadData();
-
- $rootScope.tenderVendor = null;// 清除掉已选择的
- var getService = function() {
- return GetProductInfo;
- };
- $scope.inquiry = {
- code: 'XJ' + $filter('date')(new Date(), 'yyMMddsss'),
- showdate: $filter('date')(new Date, 'yyyy-MM-dd'),
- priceType: '采购',
- isOpen: 1,
- invoice: 0,
- ifTax: 1,
- currency: 'RMB'
- };
-
- $scope.changeCurrency = function(inquiry) {
- if (inquiry.currency !== 'RMB') {
- $scope.notRMB = true;
- inquiry.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- inquiry.invoice = 0;
- } else {
- $scope.notRMB = false;
- }
- };
-
- // 获取收货地址列表
- var loadShipAddress = function() {
- ShipAddress.shipAddList({}, function(data) {
- $scope.ships = data;
- $scope.inquiry.ship = $scope.ships[0].address + $scope.ships[0].addressdet + $scope.ships[0].receiver + $scope.ships[0].usertel;
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {"Accept": "application/json;charset=utf-8", "Accept-Charset":"charset=utf-8"
- }).then(function(response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function(ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress( {}, ship, function(data) {
- if(data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
-
- $scope.currentDay = function() {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
-
- // 搜索框回车
- $scope.onSearch = function(keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- $scope.inquiry.inquiryItems = [];
- var prod = {
- prodCode: null,
- prodTitle: null,
- inbrand: null,
- currency: 'RMB',
- toDate: null,
- unit: 'PCS'
- };
- $scope.inquiry.inquiryItems.push(prod);
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function(value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword : value}).$promise.then(function(data) {
- return data.map(function(item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function(value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
-
- $scope.selectKind = function(prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function() {
- return $scope.actives;
- }
- }
- }).result.then(function(data){
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function(){
- });
- };
-
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function(brand, prod) {
- if (brand instanceof String) {
- prod.inbrand = brand;
- } else if (brand instanceof Object) {
- prod.inbrand = brand.brandCn;
- }
- };
-
- // 打开品牌选择的模态框
- $scope.selectBrand = function(prod){ //打开模态
- var modalInstance = $modal.open({
- templateUrl : 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller : 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function(){// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function(brand){
- prod.inbrand = brand.nameCn;
- }, function(reason){
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function(cmp, prod) {
- ComponentActiveAPI.get({uuid : cmp.uuid}, {}, function(data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.inbrand = data.brand.nameCn;
- }, function(res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
-
- // 导入商品信息
- $scope.uplodaByBatch = function() {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcInquiryUploadCtrl',
- size: 'lg',
- resolve: {
- }
- });
-
- modalInstance.result.then(function(data) {
- angular.forEach(data, function(prod) {
- console.log(prod);
- $scope.inquiry.inquiryItems.push(prod);
- for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- })
-
- }, function(){
-
- });
- }
- //增加商品
- $scope.add = function() {
- $scope.inquiry.inquiryItems.push(
- { prodCode: null,
- prodTitle: null,
- unit: 'PCS',
- ibrand: null,
- currency: 'RMB',
- toDate: null});
- };
- //删除商品
- $scope.del = function(index) {
- $scope.inquiry.inquiryItems.splice(index, 1);
- };
-
- // 搜索结果询价
- if($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function(data) {
- prod.prodCode = data.code;
- prod.prodTitle = data.title;
- prod.spec = data.spec;
- prod.unit = data.unit;
- prod.productId = data.id;
- prod.inbrand = data.brand;
- $scope.inquiry.inquiryItems.push(prod);
- $rootScope.prodId = null;// 清除掉prodId
- }, function(response) {
-
- });
- }
-
- $scope.check = function(product) {
- for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- $scope.inquiry.inquiryItems.push({prodCode: product.code, prodTitle: product.title, spec: product.spec, unit: product.unit,
- currency: null, toDate: null, productId: product.id, inbrand: product.brand});
- }
-
- $scope.getMinDate = function(item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
-
- $scope.openDatePicker = function($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.inquiry.inquiryItems[index].$toDateOpen = !openParam;
- };
-
- $scope.openEndDatePicker = function($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
-
- $scope.ifrepeat = false;
- // 保存并提交
- $scope.submit = function() {
- for(var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for(var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if(i != j) {
- if($scope.item.prodCode = $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $scope.vendors = [];
- $scope.vendors.push({enName: $scope.vendor.enName, enuu: $scope.vendor.uu, currency: $scope.vendor.currency, rate: $scope.vendor.rate});
- if(!$scope.ifrepeat) {
- $upload.upload({
- url: 'purc/inquiry/saveAndSubmit',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- window.location.hash = "#/purc/purchaseinquiry";
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- } else {
- toaster.pop('error', '提示', '存在条件相同的物料');
- }
- }
- }]);
-
- // 企业圈查询收到待处理的数目
- app.controller('RequestAmountCtrl', ['$scope', 'AddPartnerMyRequest', function($scope, AddPartnerMyRequest) {
- AddPartnerMyRequest.requestAmount({}, function(data) {
- $scope.requestTodo = data;
- });
- }]);
-
- // 当前企业所有的物料信息
- app.controller('ProductAllCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', function($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return ProductAll;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[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.unlock = function(id) {
- Products.unlock({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- // 关闭销售
- $scope.lock = function(id) {
- Products.lock({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- // 开启购买
- $scope.unlockPurc = function(id) {
- Products.unlockPurc({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- // 关闭购买
- $scope.lockPurc = function(id) {
- Products.lockPurc({id: id}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- // 一键匹配
- $scope.matchall = function() {
- $scope.type = "all";
- $scope.loading = true;
- Products.matchbytype({type: $scope.type}, {}, function(data) {
- toaster.pop('info', '提示', '匹配成功'+data.size+'个标准器件');
- window.location.href = "#/approvalFlow/productmatches";
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- // 当前企业匹配的标准物料信息
- app.controller('ProductmatchesCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- var getService = function() {
- if($rootScope.productMatchStatus === 'sale') {
- return Products.matchResultforSale;
- } else if($rootScope.productMatchStatus === 'purc') {
- return Products.matchResultforPurc;
- } else {
- return Products.matchResult;
- }
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function(product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if(product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- $scope.total = page.totalElement;
- Products.matchsize({type: 'all'}, {}, function(data) {
- $scope.size = data.size;
- if($scope.total < $scope.size) {
- $scope.tableParams.reload();
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- var ids = [];
- $scope.checks = {
- checked: false
- };
-
- // 全选框
- $scope.checkAll = function() {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function(product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function(message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
-
- $scope.product = {
- checked: false
- };
-
- var checkResults = function(result) {
- angular.forEach($scope.tableParams.data, function(product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function(item) {
- if(result.id == item.id) {
- if(item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
-
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function(product) {
- if(!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
-
- // 单选明细
- $scope.checkItem = function(result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
-
- // 一键更新
- $scope.updateAll = function() {
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.checked) {
- if(product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function(item) {
- if(item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall( {}, ids, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- // 当前企业匹配的标准物料信息(销售)
- app.controller('ProductmatchesForSaleCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- var getService = function() {
- return Products.matchResultforSale;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function(product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if(product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- $scope.total = page.totalElement;
- Products.matchsize({type: 'sale'}, {}, function(data) {
- $scope.size = data.size;
- if($scope.total < $scope.size) {
- $scope.tableParams.reload();
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- var ids = [];
- $scope.checks = {
- checked: false
- };
-
- // 全选框
- $scope.checkAll = function() {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function(product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function(message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
-
- $scope.product = {
- checked: false
- };
-
- var checkResults = function(result) {
- angular.forEach($scope.tableParams.data, function(product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function(item) {
- if(result.id == item.id) {
- if(item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
-
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function(product) {
- if(!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
-
- // 单选明细
- $scope.checkItem = function(result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
-
- // 一键更新
- $scope.updateAll = function() {
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.checked) {
- if(product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function(item) {
- if(item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall( {}, ids, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- // 当前企业匹配的标准物料信息(采购)
- app.controller('ProductmatchesForPurcCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
-
- var getService = function() {
- return Products.matchResultforPurc;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function(product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if(product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- $scope.total = page.totalElement;
- Products.matchsize({type: 'purc'}, {}, function(data) {
- $scope.size = data.size;
- if($scope.total < $scope.size) {
- $scope.tableParams.reload();
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- var ids = [];
- $scope.checks = {
- checked: false
- };
-
- // 全选框
- $scope.checkAll = function() {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function(product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function(message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
-
- $scope.product = {
- checked: false
- };
-
- var checkResults = function(result) {
- angular.forEach($scope.tableParams.data, function(product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function(item) {
- if(result.id == item.id) {
- if(item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
-
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function(product) {
- if(!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
-
- // 单选明细
- $scope.checkItem = function(result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
-
- // 一键更新
- $scope.updateAll = function() {
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.checked) {
- if(product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function(item) {
- if(item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall( {}, ids, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 采购物料资料
- */
- app.controller('PurcProductCtrl', ['$scope', 'PurcProduct', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$modal', 'GetProductInfo', '$rootScope', function($scope, PurcProduct, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $modal, GetProductInfo, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function(agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function(zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function(state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function() {
- return PurcProduct;
- };
-
- $scope.tableParams = new ngTableParams({
- page : 1,
- count : 20,
- sorting: {
- }
- }, {
- total : 0,
- counts: [5, 10, 25, 50],
- getData : function($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function(page){
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function(response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function() {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
-
- //删除
- $scope.deleteById = function(id) {
- GetProductInfo.deleteById({id: id}, function(data) {
- if(data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function() {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function(response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
-
- // 一键开启关闭
- $scope.toggle = function(status) {
- console.log(status);
- Products.toggle({status: status}, {}, function(data) {
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- })
- }
-
- var products = [];
- $scope.checks = {
- checked: false
- };
-
- // 全选框
- $scope.checkAll = function() {
- products = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function(product) {
- if(product.cmpUuId == null) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function(product) {
- products = [];// 每次选择时先清空,防止重复
- var result = true;
- angular.forEach($scope.tableParams.data, function(item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function(message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.updateByBatch = function(updatetype) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/updateByBatch_modal.html',
- controller: 'UpdateByBatchCtrl',
- size: 'md',
- resolve: {
- updatetype: function() {
- return updatetype;
- },
- active: function() {
- return $scope.active;
- },
- type: function() {
- return 'purchase';
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }, function(){
-
- });
- }
-
- // 一键匹配
- $scope.matchall = function() {
- $scope.type = "purc";
- $scope.loading = true;
- Products.matchbytype({type: $scope.type}, {}, function(data) {
- toaster.pop('info', '提示', '匹配成功'+data.size+'个标准器件');
- window.location.href = "#/purc/productmatches";
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
-
- /**
- * 采购物料批量上传
- */
- app.controller('UploadProductCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function($scope, $upload, toaster, BaseService) {
- BaseService.scrollBackToTop();
- $scope.$watch('myFiles', function(){
- if($scope.myFiles) {
- var file = $scope.myFiles[0];
- $scope.fileName = file.name;
- }
- })
- // 通过excel批量上传物料
- $scope.upload = function() {
- $scope.loading = true;
- if($scope.myFiles) {
- var file = $scope.myFiles[0];
- if(file.name) {
- $scope.loading = true;
- $upload.upload({
- url: 'purcProduct/release/excel',
- file: file,
- method: 'POST'
- }).success(function(data) {
- $scope.loading = false;
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- $scope.products = $scope.result.products;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- $scope.infos = $scope.result.infos;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function(response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
-
- // 查看范例
- $scope.showImg = function() {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
-
- // 下载模板
- $scope.download = function() {
- window.location.href = 'product/baseInfo/upload/template';
- };
- }]);
-
- /**
- * 新增物料(采购)
- */
- app.controller('PurcNewProdInfoCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', '$modal', 'ComponentActive', 'KindAPI', '$timeout', '$filter', 'AuthenticationService', 'BaseService', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout, $filter, AuthenticationService, BaseService) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.prodInfo = {};
- // 选择类目
- $scope.selectKind = function() {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function(data){
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function() {
- return $scope.kindId;
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function(){
-
- });
- }, function(){
-
- });
- };
- // 删除
- $scope.clearfile = function() {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //提交
- $scope.submit = function(prodInfo){
- $scope.prodInfo.isPurchase = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/addNewProduct',
- file: file,
- method: 'POST',
- data: {
- prodInfo: prodInfo
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function() {
- //提交后跳转到详情页面,防止重复提交
- window.location.href="#/sale/prodList/"+data.id;
- }, 500);
- }
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function() {
- //提交后跳转到详情页面,防止重复提交
- window.location.href="#/sale/prodList/"+data.id;
- }, 500);
- }
-
- }).error(function(data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- };
-
- $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('PurcProdDetailCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', 'AuthenticationService', '$filter', 'BaseService', '$modal', 'Products', function($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, AuthenticationService, $filter, BaseService, $modal, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
-
- var loadData = function() {
- GetProductInfo.getOne({id: $stateParams.id}, function(data) {
- if(data.attach) {
- GetProductInfo.getAttach({id: data.attach.id}, function(data) {
- // 查看范例
- $scope.showImg = function() {
- var src = data.url, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function(){
- box.hide();
- });
- box.dblclick(function(){
- box.hide();
- });
- };
- })
- }
- $scope.prodInfo = data;
- if($scope.prodInfo.standard != 1 ) {// 非标准的先进行匹配
- Products.matchone({id: $scope.prodInfo.id}, {}, function(data) {
- $scope.matchresults = data;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.prodInfo.$editing = false;
- $scope.loading = false;
- });
- };
- loadData();
- //更新为标准器件
- $scope.updateone = function(id) {
- Products.updateone({id: id}, {}, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- // 选择类目
- $scope.selectKind = function(cmpcode) {
- if(cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function(data){
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function() {
- return $scope.kindId;
- }
- }
- });
-
- modalInstance.result.then(function(data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function(){
-
- });
- }, function(){
-
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function() {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
-
- // 取消
- $scope.cancel = function() {
- GetProductInfo.getOne({id: $stateParams.id}, function(data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
-
- // 删除
- $scope.clearfile = function() {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
-
- //删除
- $scope.deleteById = function(id) {
- GetProductInfo.deleteById({id: id}, function(data) {
- if(data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- window.location.href = "#/purc/prodList";
- }
- }), function(response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
-
- $scope.submit = function(prodInfo) {
- $scope.prodInfo.isPurchase = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/updateProdInfo',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- 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 ;
- };
-
- }]);
-
- return app;
- });
|