| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868 |
- define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder', 'service/Product', 'service/Token', 'service/ProductUsers', 'service/File', 'service/PublicInquiry', 'service/Customer', 'service/PurcChange', 'angularTreeview'], function () {
- 'use strict';
- var app = angular.module('myApp', ['toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'common.directives', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService', 'ProductInfoServices', 'TokenService', 'ProductUserService', 'ui.tour', 'FileService', 'publicInquiryService', 'CustomerService', 'changeService', 'angularTreeview']);
- app.init = function () {
- angular.bootstrap(document, ['myApp']);
- };
- app.config(['$httpProvider', function ($httpProvider) {
- // http拦截
- $httpProvider.interceptors.push('httpInterceptor');
- }]);
- app.factory('httpInterceptor', ['$window', '$q', function ($window, $q) {
- var httpInterceptor = {
- responseError: function (response) {
- console.log('res' + response);
- console.log('status' + response.status);
- if (response.status == 401) {// UNAUTHORIZED
- // window.location.href = window.location.origin + window.location.pathname + '/login';
- // window.location.reload();
- 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/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/home/right.html",
- controller: 'RightCtrl'
- }
- }
- }).state('home', {
- url: "/",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/home/right.html",
- controller: 'RightCtrl'
- }
- }
- }).state('sale', {
- url: "/sale",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/sale/right.html"
- }
- },
- controller: function ($scope) {
- $scope.truck = [];
- $scope.dataChanged = false;
- }
- }).state('sale.index', {
- url: "",
- templateUrl: "static/tpl/index/sale/index.html"
- }).state('sale.home', {
- url: "/",
- templateUrl: "static/tpl/index/sale/index.html"
- }).state('purc', {
- url: "/purc",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/purc/right.html"
- }
- },
- controller: function ($scope) {
- $scope.truck = [];
- $scope.dataChanged = false;
- }
- }).state('purc.index', {
- url: "",
- templateUrl: "static/tpl/index/purc/index.html"
- }).state('purc.home', {
- url: "/",
- templateUrl: "static/tpl/index/purc/index.html"
- }).state('purc.introduce', {
- url: "/introduce",
- templateUrl: "static/tpl/index/purc/introduce.html"
- }).state('purc.order', {
- url: "/order",
- templateUrl: "static/tpl/index/purc/order.html",
- controller: 'PurcOrderCtrl'
- }).state('purc.order_detail', {
- url: "/order/:id",
- templateUrl: "static/tpl/index/purc/order_detail.html",
- controller: 'PurcOrderDetailCtrl'
- }).state('purc.newOrder', {
- url: "/addOrder",
- templateUrl: "static/tpl/index/purc/addOrder.html",
- controller: 'PurcNewOrderCtrl'
- }).state('purc.cart', {
- url: "/cart",
- templateUrl: "static/tpl/index/purc/cart.html",
- controller: 'CartController'
- }).state('purc.cartDetail', {
- url: "/cart/:id",
- templateUrl: "static/tpl/index/purc/cart_detail.html",
- controller: 'CartDetailController'
- }).state('purc.deputy', {
- url: "/deputy",
- templateUrl: "static/tpl/index/purc/deputyOrder.html",
- controller: 'DeputyOrderCtrl'
- }).state('purc.deputylog', {
- url: "/deputylog",
- templateUrl: "static/tpl/index/purc/deputyorders_log.html",
- controller: 'DeputyOrderLogCtrl'
- }).state('purc.newdeputy', {
- url: "/deputy/add",
- templateUrl: "static/tpl/index/purc/deputyOrder_new.html",
- controller: 'NewDeputyOrderCtrl'
- }).state('purc.deputydetail', {
- url: "/deputy/:id",
- templateUrl: "static/tpl/index/purc/deputyOrder_detail.html",
- controller: 'DeputyOrderDetailCtrl'
- }).state('purc.changeList', {// 新增采购变更单
- url: "/change",
- templateUrl: "static/tpl/index/purc/changeList.html",
- controller: 'PurcChangeListCtrl'
- /* 采购变更单详情 */
- }).state('purc.change_detail', {
- url: "/change/:id",
- templateUrl: "static/tpl/index/purc/change_detail.html",
- controller: 'PurcChangeDetailCtrl'
- }).state('purc.changeNew', {// 新增采购变更单
- url: "/change_new",
- templateUrl: "static/tpl/index/purc/change_new.html",
- controller: 'PurcChangeNewCtrl'
- /* 招标列表 */
- }).state('purc.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/purc/tenderlist.html",
- controller: 'PurcTenderCtrl'
- /* 招标答疑列表 */
- }).state('purc.tenderanswerlist', {
- url: "/tender/answer",
- templateUrl: "static/tpl/index/purc/tender_answer_list.html",
- controller: 'PurcTenderAnswerListCtrl'
- /* 招标答疑详情 */
- }).state('purc.tenderanswerdetail', {
- url: "/tender/answer/:id",
- templateUrl: "static/tpl/index/purc/tender_answer_detail.html",
- controller: 'PurcTenderAnswerDetailCtrl'
- }).state('purc.waiting.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/purc/tenderlist.html",
- controller: 'PurcTenderCtrl'
- }).state('purc.todo.tenderlist', {
- url: "/tender/todo",
- templateUrl: "static/tpl/index/purc/tenderlist.html",
- controller: 'PurcTenderCtrl'
- /* 招标 */
- }).state('purc.tender', {
- url: "/addTender",
- templateUrl: "static/tpl/index/purc/tender.html",
- controller: 'PurcNewTenderCtrl'
- }).state('purc.savedtender', {
- url: "/tender/:id",
- templateUrl: "static/tpl/index/purc/tender.html",
- controller: 'PurcNewTenderCtrl'
- /* 评标 */
- }).state('purc.evaluation', {
- url: "/evaluation/:id",
- templateUrl: "static/tpl/index/purc/tender_evaluation.html",
- controller: 'PurcEvaluationCtrl'
- /* 采购供应商资料 */
- }).state('purc.vendor', {
- url: "/vendor",
- templateUrl: "static/tpl/index/purc/vendor.html",
- controller: 'PurcVendorCtrl'
- /* 采购供应商资料 详情*/
- }).state('purc.vendorserve', {
- url: "/vendor/serve",
- templateUrl: "static/tpl/index/cs/right.html",
- controller: 'CustServeCtrl'
- }).state('purc.vendordetail', {
- url: "/vendor/:id",
- templateUrl: "static/tpl/index/purc/vendor_detail.html",
- controller: 'PurcVendorDetailCtrl'
- /* 客户指定招标列表 */
- }).state('purc.makeoutorder', {
- url: "/makeoutorder",
- templateUrl: "static/tpl/index/make/outorder.html",
- controller: 'MakeOutOrderCtrl'
- }).state('purc.outorder_detail', {
- url: "/makeoutorder/:id",
- templateUrl: "static/tpl/index/make/outorder_detail.html",
- controller: 'MakeOutOrderDetailCtrl'
- /*平台新增询价单*/
- }).state('purc.inquiry_new', {
- url: "/purcinquiry",
- templateUrl: "static/tpl/index/purc/inquiry_new.html",
- controller: 'PurcInquiryCtrl'
- /*新增公共询价*/
- }).state('purc.pubinquiry_new', {
- url: "/pubinquiry/new",
- templateUrl: "static/tpl/index/purc/pubInquiry_new.html",
- controller: 'PurcInquiryCtrl'
- }).state('purc.purcinquiry_new', {
- url: "/purcinquiry/:bussinessCode",
- templateUrl: "static/tpl/index/purc/purcinquiry_new.html",
- controller: 'PurcInquiryNewCtrl'
- }).state('purc.inquiry', {
- url: "/purchaseinquiry",
- templateUrl: "static/tpl/index/purc/inquiry.html",
- controller: 'PurchaseInquiryCtrl'
- }).state('purc.inquiry_detail', {
- url: "/purcinquirydetail",
- templateUrl: "static/tpl/index/purc/inquiry_detail.html",
- controller: 'PurcInquiryDetailCtrl'
- }).state('purc.inquiryInfo_detail', {
- url: "/purcinquirydetail/:id",
- templateUrl: "static/tpl/index/purc/inquiryInfo_detail.html",
- controller: 'PurcInquiryInfoDetailCtrl'
- }).state('purc.inquiry_unapply', {
- url: "/inquiry_unapply",
- templateUrl: "static/tpl/index/purc/inquiry_unapply.html",
- controller: 'UnapplyInquiryCtrl'
- }).state('purc.pubInquiry', {
- /**
- * 针对客户,查询已转报价的公共询价单列表
- */
- url: "/publicInquiry",
- templateUrl: "static/tpl/index/purc/pubInquiry.html",
- controller: 'PurcPubInquiryCtrl'
- }).state('purc.pubInquiry_detail', {
- /**
- * 针对客户,查询已转报价单的公共询价详情
- */
- url: "/publicInquiry/:id",
- templateUrl: "static/tpl/index/purc/pubInquiry_detail.html",
- controller: 'PurcPubInquiryDetailCtrl'
- }).state('purc.product', {
- url: "/product",
- templateUrl: "static/tpl/index/purc/prodList.html",
- controller: 'PurcProductCtrl'
- }).state('purc.newProduct', {
- url: "/newProduct",
- templateUrl: "static/tpl/index/purc/newProdInfo.html",
- controller: 'PurcNewProdInfoCtrl'
- }).state('purc.productDetail', {
- url: "/prodList/:id",
- templateUrl: "static/tpl/index/purc/productDetail.html",
- controller: 'PurcProdDetailCtrl'
- }).state('purc.productmatches', {
- url: "/productmatches",
- templateUrl: "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesForPurcCtrl'
- }).state('purc.uploadProduct', {
- url: "/uploadProduct",
- templateUrl: "static/tpl/index/purc/uploadByBatch.html",
- controller: 'UploadProductCtrl'
- }).state('sale.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/sale/tenderlist.html",
- controller: 'SaleTenderCtrl'
- /* 招标提问列表 */
- }).state('sale.tenderquestionlist', {
- url: "/tender/question",
- templateUrl: "static/tpl/index/sale/tender_question_list.html",
- controller: 'SaleTenderQuestionListCtrl'
- /* 招标提问详情 */
- }).state('sale.tenderquestiondetail', {
- url: "/tender/question/:id",
- templateUrl: "static/tpl/index/sale/tender_question_detail.html",
- controller: 'SaleTenderQuestionDetailCtrl'
- }).state('sale.todo.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/sale/tenderlist.html",
- controller: 'SaleTenderCtrl'
- /* 平台公开招标列表 */
- }).state('baseInfo.openTenderList', {
- url: "/openTenderList",
- templateUrl: "static/tpl/index/sale/open_tender_list.html",
- controller: 'SaleOpenTenderCtrl'
- /* 查看公开招标详情 */
- }).state('baseInfo.open_tender_detail', {
- url: "/openTenderDetail/:id",
- templateUrl: "static/tpl/index/sale/open_tender_detail.html",
- controller: 'OpenSaleTenderDetailCtrl'
- /* 投标 */
- }).state('sale.tender', {
- url: "/tender/:id",
- templateUrl: "static/tpl/index/sale/tender.html",
- controller: 'SaleTenderDetailCtrl'
- /* 采购方查看供应商投标 */
- }).state('sale.vendortender', {
- url: "/tender/:vendUU/:id",
- templateUrl: "static/tpl/index/sale/vendor_tender.html",
- controller: 'SaleVendorTenderDetailCtrl'
- }).state('sale.todo', {
- url: "/todo",
- templateUrl: "static/tpl/index/sale/todo.html"
- }).state('sale.todo.inquiry', {
- url: "/inquiry",
- templateUrl: "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.todo.order', {
- url: "/order",
- templateUrl: "static/tpl/index/sale/order.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.todo.change', {
- url: "/change",
- templateUrl: "static/tpl/index/sale/change.html",
- controller: 'SaleChangeCtrl'
- }).state('sale.todo.notice', {
- url: "/notice",
- templateUrl: "static/tpl/index/sale/notice.html",
- controller: 'SaleNoticeCtrl'
- }).state('sale.customer', {
- url: "/customer",
- templateUrl: "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.customer_detail', {
- url: "/customer/:id",
- templateUrl: "static/tpl/index/sale/customer_detail.html",
- controller: 'CustomerDetailCtrl'
- }).state('sale.customerProduct', {
- url: "/customerProduct",
- templateUrl: "static/tpl/index/sale/customer.html",
- controller: 'CustomerCtrl'
- }).state('sale.inquiry', {
- url: "/inquiry",
- templateUrl: "static/tpl/index/sale/inquiry.html",
- controller: 'SaleInquiryCtrl'
- }).state('sale.pubinquiry', {
- /**
- * 针对卖家,展示已转询价报价的公共询价单列表
- */
- url: "/pubinquiry",
- templateUrl: "static/tpl/index/sale/pubinquiry.html",
- controller: 'SalePubInquiryCtrl',
- params: {
- 'saleInquiryActive': null
- }
- }).state('sale.pubinquiry_detail', {
- /**
- * 针对卖家,已转询价报价单的公共询价单详情
- */
- url: "/pubinquiry/:id",
- templateUrl: "static/tpl/index/sale/pubinquiry_detail.html",
- controller: 'SalePubInquiryDetailCtrl'
- }).state('sale.inquiryRemind', {
- /**
- * 针对卖家,查询推荐的询价列表
- */
- url: "/inquiryRemind",
- templateUrl: "static/tpl/index/sale/inquiryRemind.html",
- controller: 'SaleInquiryRemindCtrl'
- }).state('sale.inquirymould', {
- url: "/mould",
- templateUrl: "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.todo.inquirymould', {
- url: "/mould",
- templateUrl: "static/tpl/index/sale/inquiry_mould.html",
- controller: 'SaleInquiryMouldCtrl'
- }).state('sale.inquiry_mould_detail', {
- url: "/mould/:id",
- templateUrl: "static/tpl/index/sale/inquiry_mould_detail.html",
- controller: 'SaleInquiryMouldDetailCtrl'
- }).state('sale.inquiry_detail', {
- url: "/inquiry/:id",
- templateUrl: "static/tpl/index/sale/inquiry_detail.html",
- controller: 'SaleInquiryDetailCtrl'
- }).state('sale.quotation', {
- url: "/quotation",
- templateUrl: "static/tpl/index/sale/quotation.html"
- }).state('sale.quotation.new', {
- url: "/new",
- templateUrl: "static/tpl/index/sale/quotation_new.html",
- controller: 'SaleQuotationNewCtrl',
- params: {
- 'inquiryItem': null
- }
- }).state('sale.quotation.list', {
- url: "/list",
- templateUrl: "static/tpl/index/sale/quotation_list.html",
- controller: 'SaleQuotationListCtrl'
- }).state('sale.quotation.item', {
- url: "/:id",
- templateUrl: "static/tpl/index/sale/quotation_new.html",
- controller: 'SaleQuotationNewCtrl'
- }).state('sale.order', {
- url: "/order",
- templateUrl: "static/tpl/index/sale/order.html",
- controller: 'SaleOrderCtrl'
- }).state('sale.order_detail', {
- url: "/order/:id",
- templateUrl: "static/tpl/index/sale/order_detail.html",
- controller: 'SaleOrderDetailCtrl'
- }).state('sale.change', {
- url: "/change",
- templateUrl: "static/tpl/index/sale/change.html",
- controller: 'SaleChangeCtrl'
- }).state('sale.change_detail', {
- url: "/change/:id",
- templateUrl: "static/tpl/index/sale/change_detail.html",
- controller: 'SaleChangeDetailCtrl'
- }).state('sale.notice', {
- url: "/notice",
- templateUrl: "static/tpl/index/sale/notice.html",
- controller: 'SaleNoticeCtrl'
- }).state('sale.send', {
- url: "/send",
- templateUrl: "static/tpl/index/sale/send.html",
- controller: 'SaleSendCtrl'
- }).state('sale.send_detail', {
- url: "/send/:id",
- templateUrl: "static/tpl/index/sale/send_detail.html",
- controller: 'SaleSendDetailCtrl'
- }).state('sale.forecast', {
- url: "/forecast",
- templateUrl: "static/tpl/index/sale/forecast.html",
- controller: 'SaleForecastCtrl'
- }).state('sale.accept', {
- url: "/accept",
- templateUrl: "static/tpl/index/sale/accept.html",
- controller: 'SaleAcceptCtrl'
- }).state('sale.accept_detail', {
- url: "/accept/:id",
- templateUrl: "static/tpl/index/sale/accept_detail.html",
- controller: 'SaleAcceptDetailCtrl'
- }).state('sale.returns', {
- url: "/returns",
- templateUrl: "static/tpl/index/sale/returns.html",
- controller: 'SaleReturnsCtrl'
- }).state('sale.return_detail', {
- url: "/return/:id",
- templateUrl: "static/tpl/index/sale/return_detail.html",
- controller: 'SaleReturnsDetailCtrl'
- }).state('sale.sample', {
- url: "/sample",
- templateUrl: "static/tpl/index/sale/sample.html",
- controller: 'SaleSampleCtrl'
- }).state('sale.sample_detail', {
- url: "/sample/:id",
- templateUrl: "static/tpl/index/sale/sample_detail.html",
- controller: 'SaleSampleDetailCtrl'
- }).state('sale.approval', {
- url: "/approval",
- templateUrl: "static/tpl/index/sale/approval.html",
- controller: 'SaleApprovalCtrl'
- }).state('sale.prodList', {
- url: "/prodList",
- templateUrl: "static/tpl/index/baseInfo/prodList.html",
- controller: 'ProductListCtrl'
- }).state('sale.newProdInfo', {
- url: "/newProdInfo",
- templateUrl: "static/tpl/index/baseInfo/newProdInfo.html",
- controller: 'NewProdInfoCtrl'
- }).state('sale.uploadByBatch', {
- url: "/uploadByBatch",
- templateUrl: "static/tpl/index/baseInfo/uploadByBatch.html",
- controller: 'UploadByBatchCtrl'
- }).state('sale.productDetail', {
- url: "/prodList/:id",
- templateUrl: "static/tpl/index/baseInfo/productDetail.html",
- controller: 'ProductDetailCtrl'
- }).state('sale.productmatches', {
- url: "/productmatches",
- templateUrl: "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesForSaleCtrl'
- }).state('sale.maketodo', {
- url: "/maketodo",
- templateUrl: "static/tpl/index/make/todo.html"
- }).state('sale.maketodo.order', {
- url: "/makeorder",
- templateUrl: "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder', {
- url: "/makeorder",
- templateUrl: "static/tpl/index/make/order.html",
- controller: 'MakeOrderCtrl'
- }).state('sale.makeorder_detail', {
- url: "/makeorder/:id",
- templateUrl: "static/tpl/index/make/order_detail.html",
- controller: 'MakeOrderDetailCtrl'
- }).state('sale.badOut', {
- url: "/badOut",
- templateUrl: "static/tpl/index/qc/badOut.html",
- controller: 'SaleBadOutCtrl'
- }).state('sale.MRB', {
- url: "/MRB",
- templateUrl: "static/tpl/index/qc/MRB.html",
- controller: 'SaleMRBCtrl'
- }).state('sale.badIn', {
- url: "/badIn",
- templateUrl: "static/tpl/index/qc/badIn.html",
- controller: 'SaleBadInCtrl'
- }).state('sale.makeaccept', {
- url: "/makeaccept",
- templateUrl: "static/tpl/index/make/accept.html",
- controller: 'MakeAcceptCtrl'
- }).state('sale.makereturns', {
- url: "/makereturns",
- templateUrl: "static/tpl/index/make/returns.html",
- controller: 'MakeReturnCtrl'
- }).state('sale.makechange', {
- url: "/makechange",
- templateUrl: "static/tpl/index/make/change.html",
- controller: 'MakeChangeCtrl'
- }).state('sale.makechange_detail', {
- url: "/makechange/:id",
- templateUrl: "static/tpl/index/make/change_detail.html",
- controller: 'MakeChangeDetailCtrl'
- }).state('account', {
- url: "/account",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/account/left.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/account/right.html"
- }
- }
- }).state('account.index', {
- url: "",
- templateUrl: "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('account.home', {
- url: "/",
- templateUrl: "static/tpl/index/account/index.html",
- controller: 'RightCtrl'
- }).state('baseInfo', {//基础资料
- url: "/baseInfo",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/baseInfo/right.html"
- }
- }
- }).state('baseInfo.index', {
- url: "/enterpriseList",
- templateUrl: "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.home', {
- url: "/enterpriseList",
- templateUrl: "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.enterpriseList', {
- url: "/enterpriseList",
- templateUrl: "static/tpl/index/baseInfo/enterpriseList.html",
- controller: 'EnterpriseListCtrl'
- }).state('baseInfo.myClient', {
- url: "/myClient",
- templateUrl: "static/tpl/index/baseInfo/myClient.html",
- controller: 'MyClientCtrl'
- }).state('baseInfo.mySupplier', {
- url: "/mySupplier",
- templateUrl: "static/tpl/index/baseInfo/mySupplier.html",
- controller: 'MySupplierCtrl'
- }).state('baseInfo.myRequest', {
- url: "/myRequest",
- templateUrl: "static/tpl/index/baseInfo/myRequest.html",
- controller: 'AddPartnerRequestCtrl'
- }).state('baseInfo.newPartner', {
- url: "/newPartner",
- templateUrl: "static/tpl/index/baseInfo/newPartner.html",
- controller: 'NewPartnerCtrl'
- }).state('baseInfo.myMessage', {
- url: "/myMessage",
- templateUrl: "static/tpl/index/baseInfo/myMessage.html",
- controller: 'AddPartnerMessageCtrl'
- }).state('baseInfo.myPartners', {
- url: '/myPartners',
- templateUrl: "static/tpl/index/baseInfo/myPartners.html",
- controller: 'MyPartnersCtrl'
- }).state('baseInfo.businessGroups', {
- url: '/businessGroups',
- controller: 'BusinessGroupsCtrl'
- }).state('baseInfo.inquiryList', {
- url: '/inquiryList',
- templateUrl: "static/tpl/index/baseInfo/inquiry_list.html",
- controller: 'PublicInquiryListCtrl'
- }).state('baseInfo.inquiryListDetail', {
- url: '/inquiryList/:id',
- templateUrl: "static/tpl/index/baseInfo/inquiryItem_detail.html",
- controller: 'PublicInquiryListDetailCtrl'
- }).state('baseInfo.vendorInfo', {
- url: '/enume/vendorInfo',
- templateUrl: "static/tpl/index/baseInfo/vendorsInfo.html",
- controller: 'VendorsInfoCtrl'
- }).state('baseInfo.servicerInfo', {
- url: '/enume/servicerInfo',
- templateUrl: "static/tpl/index/baseInfo/servicerInfo.html",
- controller: 'ServicerInfoCtrl'
- }).state('baseInfo.customerInfo', {
- url: '/enume/customerInfo',
- templateUrl: "static/tpl/index/baseInfo/customersInfo.html",
- controller: 'CustomersInfoCtrl'
- }).state('baseInfo.enume', {
- url: '/enume',
- templateUrl: "static/tpl/index/baseInfo/vendorAndCustomer.html"
- }).state('baseInfo.partner', {
- url: '/partner',
- templateUrl: "static/tpl/index/baseInfo/addPartners.html",
- controller: 'AddPartnersCtrl'
- }).state('baseInfo.partner_searchresult', {
- url: '/search',
- templateUrl: "static/tpl/index/baseInfo/searchresult.html",
- controller: 'EnterpriseSearchCtrl'
- }).state('baseInfo.invitation', {
- url: '/invitation',
- templateUrl: "static/tpl/index/baseInfo/invitation.html",
- controller: 'InvitationCtrl'
- }).state('qc', {
- url: "/qc",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/qc/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/qc/right.html"
- }
- }
- }).state('qc.index', {
- url: "",
- templateUrl: "static/tpl/index/qc/index.html"
- }).state('qc.home', {
- url: "/",
- templateUrl: "static/tpl/index/qc/index.html"
- }).state('fa', {
- url: "/fa",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/fa/right.html"
- }
- }
- }).state('fa.index', {
- url: "",
- templateUrl: "static/tpl/index/fa/index.html"
- }).state('fa.home', {
- url: "/",
- templateUrl: "static/tpl/index/fa/index.html"
- }).state('fa.apBill', {
- url: "/apBill",
- templateUrl: "static/tpl/index/fa/apBill.html",
- controller: 'SaleApBillCtrl'
- }).state('fa.apBill_detail', {
- url: "/apBill/:id",
- templateUrl: "static/tpl/index/fa/apBill_detail.html",
- controller: 'SaleApBillDetailCtrl'
- }).state('fa.arCheck', {
- url: "/arCheck",
- templateUrl: "static/tpl/index/fa/arCheck.html",
- controller: 'SaleArCheckCtrl'
- }).state('fa.arCheck_detail', {
- url: "/arCheck/:id",
- templateUrl: "static/tpl/index/fa/arCheck_detail.html",
- controller: 'SaleArCheckDetailCtrl'
- }).state('fa.apCheck', {
- url: "/apCheck",
- params: {
- 'id': null
- },
- templateUrl: "static/tpl/index/fa/apCheck.html",
- controller: 'PurchaseApCheckCtrl'
- }).state('fa.apCheck_detail', {
- url: "/apCheck/:id",
- templateUrl: "static/tpl/index/fa/apCheck_detail.html",
- controller: 'PurchaseApCheckDetailCtrl'
- }).state('fa.apCheckList', {
- url: "/apCheckList",
- templateUrl: "static/tpl/index/fa/apCheckList.html",
- controller: 'PurchaseApCheckListCtrl'
- }).state('fa.apBillOut', {
- url: "/apBillOut",
- params:{
- 'id':null
- },
- templateUrl: "static/tpl/index/fa/apBillOut.html",
- controller: 'PurchaseApBillOutCtrl'
- }).state('fa.apBillOut_detail', {
- url: "/apBillOut/:id",
- templateUrl: "static/tpl/index/fa/apBillOut_detail.html",
- controller: 'PurchaseApBillOutDetailCtrl'
- }).state('fa.apBillOutList', {
- url: "/apBillOutList",
- templateUrl: "static/tpl/index/fa/apBillOutList.html",
- controller: 'PurchaseApBillOutListCtrl'
- }).state('fa.adjustList', {
- url: "/adjustList",
- templateUrl: "static/tpl/index/fa/adjustList.html",
- controller: 'PurchaseAdjustListCtrl'
- }).state('make', {
- url: "/make",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/make/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/make/right.html"
- }
- }
- }).state('make.index', {
- url: "",
- templateUrl: "static/tpl/index/make/index.html"
- }).state('make.home', {
- url: "/",
- templateUrl: "static/tpl/index/make/index.html"
- }).state('cs', {// 客户服务
- url: "/cs",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/cs/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/cs/right.html"
- }
- }
- }).state('cs.index', {
- url: "",
- templateUrl: "static/tpl/index/cs/index.html"
- }).state('cs.home', {
- url: "/",
- templateUrl: "static/tpl/index/cs/index.html"
- }).state('search', { //顶部搜索
- url: "/search?keyword=",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/search/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/search/search_result.html",
- controller: 'TopSearchCtrl'
- }
- }
- }).state('approvalflow', { //审批流
- url: "/approvalFlow",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/common/leftAll.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/approvalFlow/right.html",
- }
- }
- }).state('approvalflow.flow', {
- url: "/flow",
- templateUrl: "static/tpl/index/approvalFlow/home.html",
- controller: 'approvalFlowCtrl'
- }).state('approvalflow.enterprise', {
- url: "/enterprise",
- templateUrl: "static/tpl/index/approvalFlow/enterprise.html",
- controller: 'EnterpriseCtrl'
- }).state('approvalflow.user', {
- url: "/user",
- templateUrl: "static/tpl/index/approvalFlow/user.html",
- controller: 'UserCtrl'
- }).state('approvalflow.log', {
- url: "/log",
- templateUrl: "static/tpl/index/approvalFlow/log.html",
- controller: 'LogCtrl'
- }).state('approvalflow.resource', {
- url: "/resource",
- templateUrl: "static/tpl/index/approvalFlow/resource.html",
- controller: 'ResourceCtrl'
- }).state('approvalflow.role', {
- url: "/role",
- templateUrl: "static/tpl/index/approvalFlow/role.html",
- controller: 'RoleCtrl'
- }).state('approvalflow.product', {
- url: "/product",
- templateUrl: "static/tpl/index/approvalFlow/prodList.html",
- controller: 'ProductAllCtrl'
- }).state('approvalflow.userProduct', {
- url: "/userProduct",
- templateUrl: "static/tpl/index/approvalFlow/userProduct.html",
- controller: 'UserProductCtrl'
- }).state('approvalflow.productmatches', {
- url: "/productmatches",
- templateUrl: "static/tpl/index/approvalFlow/productmatches.html",
- controller: 'ProductmatchesCtrl'
- }).state('sale.vendorPerformanceAssess', {
- url: "/vendorPerformanceAssess",
- templateUrl: "static/tpl/index/sale/vendorPerformanceAssess.html",
- controller: 'VendorPerformanceAssessCtrl'
- }).state('sale.vendorPerformanceAssess_detail', {
- url: "/vendorPerformanceAssess/:id",
- templateUrl: "static/tpl/index/sale/vendorPerformanceAssess_detail.html",
- controller: 'VendorPerformanceAssessDetailCtrl'
- });
- $urlRouterProvider.otherwise('/index');
- }]);
- /**
- * 表示符号
- */
- app.factory('Symbol', function () {
- return {
- currency: function (cur) {
- if (cur == 'RMB') return '¥';
- else if (cur == 'USD') return '$';
- else if (cur == 'EUR') return '€';
- else if (cur == null || cur == '') return '¥';
- else return cur;
- }
- };
- }).factory('Lodop', function () {
- return {
- getLodop: function (oOBJECT, oEMBED) {
- var CreatedOKLodop7766 = null;
- /**************************
- 本函数根据浏览器类型决定采用哪个页面元素作为Lodop对象:
- IE系列、IE内核系列的浏览器采用oOBJECT,
- 其它浏览器(Firefox系列、Chrome系列、Opera系列、Safari系列等)采用oEMBED,
- 如果页面没有相关对象元素,则新建一个或使用上次那个,避免重复生成。
- 64位浏览器指向64位的安装程序install_lodop64.exe。
- **************************/
- var strHtmInstall = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtmUpdate = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop32.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtm64_Install = "<br><font color='#FF00FF'>打印控件未安装!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
- var strHtm64_Update = "<br><font color='#FF00FF'>打印控件需要升级!点击这里<a href='static/lib/lodopActivex/install_lodop64.exe' target='_self'>执行升级</a>,升级后请重新进入。</font>";
- var strHtmFireFox = "<br><br><font color='#FF00FF'>(注意:如曾安装过Lodop旧版附件npActiveXPLugin,请在【工具】->【附加组件】->【扩展】中先卸它)</font>";
- var strHtmChrome = "<br><br><font color='#FF00FF'>(如果此前正常,仅因浏览器升级或重安装而出问题,需重新执行以上安装)</font>";
- var LODOP;
- try {
- //=====判断浏览器类型:===============
- var isIE = (navigator.userAgent.indexOf('MSIE') >= 0) || (navigator.userAgent.indexOf('Trident') >= 0);
- var is64IE = isIE && (navigator.userAgent.indexOf('x64') >= 0);
- //=====如果页面有Lodop就直接使用,没有则新建:==========
- if (oOBJECT != undefined || oEMBED != undefined) {
- if (isIE)
- LODOP = oOBJECT;
- else
- LODOP = oEMBED;
- } else {
- if (CreatedOKLodop7766 == null) {
- LODOP = document.createElement("object");
- LODOP.setAttribute("width", 0);
- LODOP.setAttribute("height", 0);
- LODOP.setAttribute("style", "position:absolute;left:0px;top:-100px;width:0px;height:0px;");
- if (isIE) LODOP.setAttribute("classid", "clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
- else LODOP.setAttribute("type", "application/x-print-lodop");
- document.documentElement.appendChild(LODOP);
- CreatedOKLodop7766 = LODOP;
- } else
- LODOP = CreatedOKLodop7766;
- }
- ;
- //=====判断Lodop插件是否安装过,没有安装或版本过低就提示下载安装:==========
- if ((LODOP == null) || (typeof(LODOP.VERSION) == "undefined")) {
- if (navigator.userAgent.indexOf('Chrome') >= 0)
- document.documentElement.innerHTML = strHtmChrome + document.documentElement.innerHTML;
- if (navigator.userAgent.indexOf('Firefox') >= 0)
- document.documentElement.innerHTML = strHtmFireFox + document.documentElement.innerHTML;
- if (is64IE) document.write(strHtm64_Install); else if (isIE) document.write(strHtmInstall); else
- document.documentElement.innerHTML = strHtmInstall + document.documentElement.innerHTML;
- return LODOP;
- } else if (LODOP.VERSION < "6.1.9.8") {
- if (is64IE) document.write(strHtm64_Update); else if (isIE) document.write(strHtmUpdate); else
- document.documentElement.innerHTML = strHtmUpdate + document.documentElement.innerHTML;
- return LODOP;
- }
- ;
- //=====如下空白位置适合调用统一功能(如注册码、语言选择等):====
- LODOP.SET_LICENSES("深圳市优软科技有限公司", "BBF53BD5AB0D522B3207D05CDE381F65", "", "");
- //============================================================
- return LODOP;
- } catch (err) {
- if (is64IE)
- document.documentElement.innerHTML = "Error:" + strHtm64_Install + document.documentElement.innerHTML; else
- document.documentElement.innerHTML = "Error:" + strHtmInstall + document.documentElement.innerHTML;
- return LODOP;
- }
- ;
- }
- }
- });
- app.controller('MyCtrl', ['$scope', '$rootScope', '$modal', 'toaster', 'AccountEnterprise', function ($scope, $rootScope, $modal, toaster, AccountEnterprise) {
- $rootScope.$on('$locationChangeSuccess', function (evt, newUrl) {
- var routeState = newUrl.substr(newUrl.indexOf('#/') + 2);
- if (routeState.indexOf('/') > -1)
- routeState = routeState.substring(0, routeState.indexOf('/'));
- if (routeState.indexOf('.') > -1)
- routeState = routeState.substring(0, routeState.indexOf('.'));
- $scope.routeState = routeState || 'home';
- });
- $scope.search = function (keyword) {
- if (keyword != null && keyword != '') {
- $rootScope.searchKeyword = keyword;
- window.location.hash = '#/search?keyword=' + keyword;
- } else {
- $rootScope.searchKeyword = null;
- window.location.hash = '#/search';
- }
- };
- $scope.showMessage = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/home/pagingRelease.html',
- controller: 'PagingReleaseCtrl'
- });
- };
- // 连接到询价
- $scope.linktoInquiry = function (active) {
- $rootScope.active = active;
- window.location.href = "#/sale/inquiry";
- }
- // 连接到招标
- $scope.linktoSaleTender = function (active) {
- $rootScope.active = active;
- window.location.href = "#/sale/tender";
- }
- // 链接到打样申请
- $scope.linktoSample = function (active) {
- $rootScope.active = active;
- window.location.href = "#/sale/sample";
- }
- // 链接到采购招标
- $scope.linktoPurcTender = function (active) {
- $rootScope.tenderActive = active;
- window.location.href = "#/purc/tender";
- }
- $scope.linktoPurcInquiry = function (active) {
- $rootScope.active = active;
- window.location.href = "#/purc/purchaseinquiry";
- }
- // 跳转到B2C
- $scope.b2cLink = function (url) {
- AccountEnterprise.getB2cUrl({}, function(data) {
- if (url == '/help/home') {
- window.open(data.url + url, '_target')
- } else {
- window.location.href = data.url + url;
- }
- });
- }
- }]);
- app.controller('AdController', ['$scope', '$modal', '$interval', function($scope, $modal, $interval) {
- // 广告操作
- $scope.count = 5;
- $scope.bannerShow = true;
- $scope.imgAnmiation = false;
- $scope.jingKongAnmiation = true;
- $scope.imgShow = true;
- $scope.Times = $interval(function () {
- $scope.count--;
- if ($scope.count <= 0) {
- $scope.count = 5;
- $scope.jingKongAnmiation = false;
- $interval.cancel($scope.Times);
- $scope.closeClick();
- }
- }, 1000);
- // 金控广告动画设置
- $scope.closeClick = function () {
- $scope.jingKongAnmiation = false;
- if ($scope.bannerShow === false) {
- $scope.imgAnmiation = false;
- $scope.imgShow = false;
- } else {
- $scope.bannerShow = false;
- $scope.imgAnmiation = true;
- }
- }
- }]);
- /**
- * 新消息提醒(调用公共服务接口) -2018-01-22 19:36:50
- * @author dongbw
- */
- app.controller('PagingReleaseCtrl', ['$scope', 'PagingRelease', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'PagingReleaseInfo',
- function ($scope, PagingRelease, BaseService, ngTableParams, toaster, $modalInstance, PagingReleaseInfo) {
- $scope.active = "todo";
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- /**
- * 页面状态按钮过滤
- */
- var getMessageState = function (active) {
- var fn = 'get';
- switch (active) {
- case 'done':
- fn = 'getDone';
- break;
- case 'todo':
- fn = 'getTodo';
- break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'createTime': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- // fromDate: getDateTime($scope.condition.dateFrom),
- // endDate: getDateTime($scope.condition.dateTo)
- };
- PagingRelease[getMessageState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.close = function () {
- $modalInstance.close();
- window.location.reload();
- };
- $scope.checks = {
- checked: false
- };// 全选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (message) {
- message.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function (vendor) {
- vendor.checked = true;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- // 单反选
- $scope.unCheckOne = function (vendor) {
- vendor.checked = false;
- $scope.checks.checked = false;
- };
- /**
- * 当前页标为已读
- */
- $scope.setRead = function () {
- $scope.loading = true;
- var messageIds = [];
- angular.forEach($scope.tableParams.data, function(message) {
- messageIds.push(message.id);
- });
- PagingRelease.setPageRead({}, messageIds, function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop("success", "设置已读成功");
- }
- if (data.error) {
- toaster.pop("error", "设置已读失败");
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- });
- };
- // 点击内容连接之后,信息标为已读
- $scope.setOneRead = function (id) {
- $scope.loading = true;
- $modalInstance.close();
- PagingRelease.setMessageRead({id: id}, {}, function (data) {
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 高亮显示关键词
- app.filter('getkey', ['$sce', '$rootScope', function ($sce, $rootScope) {
- var search = $rootScope.searchKeyword;
- return function (content, search) {
- content = encodeURI(content);
- search = encodeURI(search);
- var reg = new RegExp(search, 'gim');
- var result = content.replace(reg, '<font color="red">$&</font>');
- result = decodeURIComponent(result);
- return $sce.trustAsHtml(result);
- };
- $rootScope.searchKeyword = null;// 清除缓存的关键字
- }]);
- /**
- * 顶部搜索
- */
- app.controller('TopSearchCtrl', ['$scope', '$rootScope', 'getAccountUserSpace', 'ngTableParams', 'toaster', 'BaseService', 'AddPartner', '$filter', '$stateParams', 'SearchProd', '$sce', '$modal', 'InvitationRecord', function ($scope, $rootScope, getAccountUserSpace, ngTableParams, toaster, BaseService, AddPartner, $filter, $stateParams, SearchProd, $sce, $modal, InvitationRecord) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.tip = $rootScope.searchKeyword;
- // 企业搜索
- var getService = function () {
- return getAccountUserSpace;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $scope.total = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 添加合作关系
- $scope.addPartner = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- // 物料搜索
- var getProdService = function () {
- return SearchProd;
- };
- $scope.prodTableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $rootScope.searchKeyword;
- getProdService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $scope.prodtotal = page.totalElement;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- /**
- * 向企业购买
- */
- $scope.PurcByEn = function (businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function (businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 询价
- */
- $scope.PurcInquiry = function (businessCode, id) {
- $rootScope.prodId = id;
- window.location.hash = "#/purc/purcinquiry/" + businessCode;
- }
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function (name) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function () {
- return name
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- /**
- * 立即查看
- */
- $scope.view = function (name) {
- $rootScope.vendName = name;
- window.location.hash = "#/baseInfo/newPartner";
- }
- }]);
- app.controller('InviteCtrl', ['$scope', 'toaster', '$modalInstance', 'enname', 'InvitationRecord', '$modal', function ($scope, toaster, $modalInstance, enname, InvitationRecord, $modal) {
- $scope.enter = {
- vendname: enname
- };
- $scope.save = function (enter) {
- // 先检验是否已注册
- InvitationRecord.enterpriseList({name: enter.vendname}, {}, function(data) {
- $scope.existEn = data;
- if ($scope.existEn.length == 0) {
- $modalInstance.close(enter);
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/baseInfo/modal/QQshare_modal.html',
- controller: 'QQShareCtrl',
- });
- } else {
- $scope.enterprise = $scope.existEn[0];
- }
- });
- }
- $scope.viewDetail = function() {
- $scope.exist = 1;
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- $scope.closeDetail = function() {
- $scope.exist = 0;
- }
- /**
- * 添加合作伙伴
- * @param enterprise
- */
- $scope.addPartner = function(en) {
- InvitationRecord.addPart({inviteEnUU: $scope.enterprise.uu, inviteUserName: en.vendusername, inviteUserTel: en.vendusertel}, {}, function(data) {
- if (data.success) {
- toaster.pop('success', data.success);
- $modalInstance.dismiss();
- } else if (data.error) {
- toaster.pop('error', data.error);
- }
- }, function(response) {
- toaster.pop('error', response.data);
- });
- }
- }]);
- /**
- * QQ分享
- */
- app.controller('QQShareCtrl', ['$scope', 'InvitationRecord', '$modalInstance', function($scope, InvitationRecord, $modalInstance) {
- InvitationRecord.getInviteUrl({}, function(data) {
- $scope.inviteUrl = data.url;
- var p = {
- url: $scope.inviteUrl, /*获取URL,可加上来自分享到QQ标识,方便统计*/
- // desc: 'hejq', /*分享理由(风格应模拟用户对话),支持多分享语随机展现(使用|分隔)*/
- // title: '', /*分享标题(可选)*/
- // summary: '', /*分享摘要(可选)*/
- // pics: '', /*分享图片(可选)*/
- // flash: '', /*视频地址(可选)*/
- // site: '', /*分享来源(可选) 如:QQ分享*/
- // style: '201',
- // width: 32,
- // height: 32
- };
- var s = [];
- for(var i in p){
- s.push(i + '=' + encodeURIComponent(p[i]||''));
- }
- s.join('&');
- $scope.QQshare = function() {
- window.open("http://connect.qq.com/widget/shareqq/index.html?" + s)
- }
- });
- $scope.close = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 再次邀请
- */
- app.controller('ReInviteCtrl', ['$scope', 'toaster', '$modalInstance', 'id', 'InvitationRecord', function ($scope, toaster, $modalInstance, id, InvitationRecord) {
- var loadData = function (id) {
- InvitationRecord.getRecordById({id: id}, {}, function (data) {
- if (data.user !== null) {
- data.user = {};
- }
- $scope.enter = data;
- });
- };
- loadData(id);
- $scope.save = function (enter) {
- if (!enter.vendusertel && !enter.venduseremail) {
- toaster.pop('info', '提示', '手机号或邮箱至少填写一个才能通知到客户');
- } else {
- $modalInstance.close(enter);
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 邀请记录
- */
- app.controller('InvitationCtrl', ['$scope', 'toaster', 'InvitationRecord', 'BaseService', 'ngTableParams', '$modal', function ($scope, toaster, InvitationRecord, BaseService, ngTableParams, $modal) {
- BaseService.scrollBackToTop();
- $scope.status = "invitation";
- $scope.active = "invitation";
- var getService = function () {
- if ($scope.active === "invitation") {
- return InvitationRecord.records;
- } else if ($scope.active === "invitationTeam") {
- return InvitationRecord.getActiveRecordsByEn; // 只获取已激活的
- }
- };
- $scope.setActive = function (state) {
- if ($scope.active !== state) {
- $scope.active = state;
- if ($scope.tableParams.page() === 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.tip = keyword;
- }
- $scope.search = function (name) {
- $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/fuzzysearch_enterprise_modal.html',
- controller: 'FuzzySearchCtrl',
- resolve: {
- name: function () {
- return name
- }
- }
- }).result.then(function (data) {
- });
- };
- // 再次邀请
- $scope.reInvite = function (id) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'ReInviteCtrl',
- resolve: {
- id: function () {
- return id
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- }]);
- /**
- * 模糊查询相似的企业名称
- */
- app.controller('FuzzySearchCtrl', ['$scope', 'name', 'InvitationRecord', 'toaster', 'BaseService', function ($scope, name, InvitationRecord, toaster, BaseService) {
- $scope.name = name;
- if ($scope.name != null) {
- InvitationRecord.enterpriseList({name: $scope.name}, {}, function (data) {
- $scope.enterprises = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', 'toaster', 'BaseService', '$modal', function ($scope, $window, AuthenticationService, toaster, BaseService, $modal) {
- $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
- AuthenticationService.getAuthentication().success(function (data) {
- if (data.enterprises) {
- data.enterprise = data.enterprises[data.enterprises.length - 1];
- if (data.enterprises.length > 1) {
- var enSelect = [];
- angular.forEach(data.enterprises, function (e) {
- if (e.current)
- data.enterprise = e;
- else
- enSelect.push(e);
- });
- data.enSelect = enSelect;
- }
- }
- $scope.userInfo = data;
- if (data == null || !data.userUU) {
- $scope.isAuthed = false;
- AuthenticationService.redirectSignin();
- } else {
- }
- });
- $scope.logout = function () {
- $modal.open({
- templateUrl: 'static/tpl/index/account/logout.html',
- controller: 'LogOutCtrl'
- }).result.then(function (s) {
- if (s) {
- AuthenticationService.logout();
- }
- });
- };
- // 打开登录模态框
- $scope.signinModal = function() {
- // 跳转账户中心
- AuthenticationService.redirectSignin();
- };
- // 注册
- $scope.registerModal = function() {
- // 跳转账户中心
- AuthenticationService.redirectRegister();
- };
- $scope.switchto = function (enUU) {// 切换企业
- AuthenticationService.reSignin(enUU).success(function (response) {
- console.log(response);
- if (!response) $window.location.reload();
- $.ajax({
- url:response.url,
- data:response.data,
- type:"get",
- cache:false,
- dataType:"jsonp",
- jsonp:"callback",
- jsonpCallback:"successCallback",
- success:function(data){
- console.log(data);
- $window.location.reload();
- },
- error:function(data){
- console.log(data);
- $window.location.reload();
- }
- });
- });
- };
- $scope.addFavorite = function () {
- var url = encodeURI(window.location.href);
- try {
- //ie浏览器收藏方式
- window.external.addFavorite(url, "优软商务平台");
- } catch (e) {
- try {
- //火狐浏览器收藏方式
- window.sidebar.addPanel("优软商务平台", url);
- } catch (e) {
- toaster.pop('warning', '提示', "您的浏览器不支持自动添加收藏夹,请使用Ctrl+D进行添加," +
- "或手动在浏览器里进行设置。");
- }
- }
- };
- }]);
- app.controller('LogOutCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
- $scope.close = function (confirm) {
- $modalInstance.close(confirm);
- };
- }]);
- app.controller('ImageInsertCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
- $scope.image = {src: null};
- // 图片上传成功之后
- $scope.onUploadSuccess = function (data) {
- var path = data.path;
- path = path.substring(0, path.lastIndexOf('.')) + "_150x90" + path.substr(path.lastIndexOf('.'));
- $scope.$apply(function () {
- $scope.image.src = data.path;
- $scope.image.thumb = path;
- });
- };
- $scope.close = function () {
- $modalInstance.dismiss();
- };
- $scope.confirm = function () {
- $modalInstance.close($scope.image);
- $scope.imageUrl = null;
- };
- }]);
- app.controller('TodoCtrl', ['$scope', 'SnapshotService', 'BaseService', '$rootScope', '$modal',
- function ($scope, SnapshotService, BaseService, $rootScope, $modal) {
- BaseService.scrollBackToTop();
- SnapshotService.getTodo(function (data) {
- $scope.todo = data;
- });
- var getUnread = function () {
- SnapshotService.getUnread('all', function (data) {
- $scope.unread = data;
- });
- };
- getUnread();
- //去除红点
- $scope.setOrdersRead = function (type) {
- switch (type){
- case 'product':
- $scope.unread.product = 0;
- break;
- case 'vendorPerformanceAssess':
- $scope.unread.vendorPerformanceAssess = 0;
- break;
- case 'customer':
- $scope.unread.customer = 0;
- break;
- case 'purcProduct':
- $scope.unread.purcProduct = 0;
- break;
- case 'vendor':
- $scope.unread.purcVendor = 0;
- break;
- }
- };
- $scope.setTenderActive = function (active) {
- $rootScope.tenderActive = active;
- window.location.hash = '#/purc/tender';
- }
- }]);
- // header
- app.controller('HeaderCtrl', ['$scope', 'SnapshotService', function ($scope, SnapshotService) {
- SnapshotService.getMessage(function (data) {
- $scope.message = data;
- });
- }]);
- app.controller('TruckCtrl', ['$scope', '$rootScope', '$modal', 'SaleTruck', function ($scope, $rootScope, $modal, SaleTruck) {
- SaleTruck.query({}, function (data) {
- $rootScope.truck = data;
- $scope.truckCount = data ? data.length : 0;
- });
- $scope.$watch(function () {
- return $rootScope.truck;
- }, function (data) {
- $scope.truckCount = data ? data.length : 0;
- }, true);
- $scope.clearAll = function () {
- SaleTruck.remove({}, function () {
- $rootScope.truck = [];
- });
- };
-
- $scope.openTrack = function () {
- $modal.open({
- templateUrl: 'static/tpl/index/sale/track.html',
- controller: 'TruckModalCtrl',
- size: 'lg'
- }).result.then(function (s) {
- if (s) {
- $scope.clearAll();
- $rootScope.dataChanged = true;
- }
- });
- };
- }]);
- app.controller('TruckModalCtrl', ['$scope', '$rootScope', '$modalInstance', 'SaleTruck', 'PurcNotice', 'toaster', '$state', '$filter', '$timeout', 'token', function ($scope, $rootScope, $modalInstance, SaleTruck, PurcNotice, toaster, $state, $filter, $timeout, token) {
- $scope.loading = false;
- $scope.saleSend = {sendItems: []};
- SaleTruck.detail({}, function (data) {
- // 按物料编号排序
- $scope.notices = $filter('orderBy')(data, 'orderItem.product.code');
- });
- $scope.remove = function (index, notice) {
- SaleTruck.remove({noticeId: notice.id}, function (data) {
- $rootScope.truck = data;
- $scope.notices.splice(index, 1);
- });
- };
- $scope.$watch(function () {
- return $scope.notices;
- }, function (data) {
- var q = 0, t = 0;
- if (data) {
- angular.forEach(data, function (d) {
- q += d.thisSendQty;
- t += d.thisSendQty * d.orderItem.price;
- });
- }
- $scope.totalQty = q;
- $scope.total = t;
- }, true);
- $scope.cancel = function () {
- $modalInstance.close();
- };
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function () {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- var getToken = function() {
- token.info({userType: 'salenotice'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- getToken();
- $scope.send = function () {// 发货
- $scope.loading = true;
- if (!$scope.saleSend.code || $scope.saleSend.code == '') {//送货单号为空
- toaster.pop('error', '错误', '请输入送货单号');
- $scope.loading = false;
- return;
- }
- var currency = $scope.notices[0].orderItem.order.currency,
- custUU = $scope.notices[0].enUU,
- payments = $scope.notices[0].orderItem.order.payments, valid = true, items = [];
- var num = 1;
- for (var i in $scope.notices) {
- var item = $scope.notices[i];
- if (item.id) {
- if (item.orderItem.order.currency != currency || item.enUU != custUU || item.orderItem.order.payments != payments) {
- valid = false;
- break;
- }
- items[i] = {noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price, number: num++};
- }
- }
- if (!valid) {
- $scope.loading = false;
- toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致才能一起发货。');
- } else {
- var send = angular.extend(angular.copy($scope.saleSend), {
- currency: currency,
- custUU: custUU,
- payments: payments,
- sendItems: items
- });
- if($scope.token != null) {
- PurcNotice.sendByBatch({token: $scope.token}, send, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + send.code);
- $modalInstance.close(true);
- $state.go('sale.send_detail', {id: data.id});
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '错误', response.data);
- });
- }
- }
- $scope.setCheckedNoticeRead = function () {
- var ids = [];
- for (var i in $scope.notices) {
- var item = $scope.notices[i];
- if (item.id) {
- ids.push(item.id);
- }
- }
- PurcNotice.setRead({}, ids, function (message) {
-
- });
- }
- };
- }]);
- app.controller('PersonalSaleStatCtrl', ['$scope', 'SaleStat', function ($scope, SaleStat) {
- SaleStat.cust({}, function (data) {
- var p = [], q = [];
- angular.forEach(data.month, function (d) {
- p.push({
- x: (d.enterprise.enShortname || d.enterprise.enName),
- y: [(d.total || 0)],
- tooltip: (d.total || 0)
- });
- });
- angular.forEach(data.year, function (d) {
- q.push({
- x: (d.enterprise.enShortname || d.enterprise.enName),
- y: [(d.total || 0)],
- tooltip: (d.total || 0)
- });
- });
- $scope.custCharts = {
- month: {
- chartType: 'pie',
- datas: {
- data: p
- },
- config: {
- labels: false,
- title: "客户月采购量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- },
- year: {
- chartType: 'pie',
- datas: {
- data: q
- },
- config: {
- labels: false,
- title: "客户年采购量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- }
- };
- });
- SaleStat.seller({}, function (data) {
- var p = [], q = [];
- angular.forEach(data.month, function (d) {
- p.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function (d) {
- q.push({x: d.seller.userName, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.sellerCharts = {
- month: {
- chartType: 'pie',
- datas: {
- data: p
- },
- config: {
- labels: false,
- title: "业务员月销量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- },
- year: {
- chartType: 'pie',
- datas: {
- data: q
- },
- config: {
- labels: false,
- title: "业务员年销量排行榜",
- legend: {
- display: true,
- position: 'right'
- },
- colors: ['#4D9934', '#33D6EA', '#98E1CC', '#8060E4', '#9999CC'],
- click: function (d) {
- },
- mouseover: function (d) {
- },
- mouseout: function (d) {
- },
- innerRadius: 0,
- lineLegend: 'lineEnd'
- }
- }
- };
- });
- }]);
- app.controller('SaleStatCtrl', ['$scope', 'SaleStat', function ($scope, SaleStat) {
- SaleStat.get({}, function (data) {
- var p = [], q = [], r = [];
- angular.forEach(data.day, function (d) {
- p.push({x: d.day, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.month, function (d) {
- q.push({x: d.month, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- angular.forEach(data.year, function (d) {
- r.push({x: d.year, y: [(d.total || 0)], tooltip: (d.total || 0)});
- });
- $scope.charts = {
- day: {
- chartType: "line",
- datas: {
- series: ['销售额'],
- data: p
- },
- config: {
- "labels": false,
- "title": "销售额统计(近15日线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors: ['#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- month: {
- chartType: "line",
- datas: {
- series: ['销售额'],
- data: q
- },
- config: {
- "labels": false,
- "title": "销售额统计(近12月线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors: ['#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- },
- year: {
- chartType: "line",
- datas: {
- series: ['销售额'],
- data: r
- },
- config: {
- "labels": false,
- "title": "销售额统计(近10年线)",
- "legend": {
- "display": true,
- "position": "right"
- },
- colors: ['#4D9934'],
- "innerRadius": 0,
- "lineLegend": "lineEnd"
- }
- }
- };
- });
- }]);
- app.controller('NoticeCtrl', ['$scope', 'SnapshotService', 'AuthenticationService', function ($scope, SnapshotService, AuthenticationService) {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.useruu = data.userUU;
- SnapshotService.getNotice(7, $scope.useruu, function (data) { //5表示首页显示的公告条数
- $scope.notices = data;
- });
- /**
- * 设置单据阅读状态
- * @param id
- */
- $scope.setReadStatus = function(id) {
- SnapshotService.setNoticeStatusAfterRead(id, $scope.useruu);
- }
- /**
- * 判断是否当天时间
- * @param date
- * @param time
- * @returns {boolean}
- */
- $scope.isCurrentTime = function(date, time) {
- var date1 = date.getFullYear() + '-' + date.getMonth() + 1 + '-' + date.getDate();
- var date2 = new Date(time).getFullYear() + '-' + new Date(time).getMonth() + 1 + '-' + new Date(time).getDate();
- return date1 == date2;
- }
-
- });
- $scope.dateTime = new Date();
- $scope.time = new Date().getTime();
- /**
- * 收起展开公告
- */
- $scope.show = false;
- $scope.showGongGao = function () {
- $scope.show = !$scope.show
- }
- }]);
- app.controller('TenderCtrl', ['$scope', 'SnapshotService', function ($scope, SnapshotService) {
- SnapshotService.getOpenTender(5, function (data) {
- $scope.openTenders = data;
- var newDate = new Date();
- newDate = newDate.getTime() - 3 * 24 * 60 * 60 * 1000;
- angular.forEach($scope.openTenders, function (tender) {
- if (tender.date - newDate > 0) {
- tender.isNew = true;
- } else {
- tender.isNew = false;
- }
- });
- });
- $scope.dateTime = new Date();
- }]);
- app.controller('VendCountCtrl', ['$scope', 'VendorService', function ($scope, VendorService) {
- VendorService.getCount(function (date) {
- $scope.count = date;
- });
- }]);
- // 客户
- app.controller('CustomerCtrl', ['$scope', 'VendorService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', 'Vendor', 'AccountUser', 'CurrentRole', function ($scope, VendorService, BaseService, AuthenticationService, ngTableParams, $modal, toaster, Vendor, AccountUser, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- // 获取当前用户分配客户的操作权限
- CurrentRole.roles({}, function (data) {
- // 存在权限或者user表sys字段为1时
- $scope.enabled = data.count > 0 || $scope.thisUser.sys;
- }, function (response) {
- });
- var getCustInfos = function (custuu) {
- if (custuu) {
- VendorService.userInfo.query({uu: custuu}, null, function (data) {
- $scope.custInfos = data;
- var getPage = function (page, size) {
- if ($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1) * size, page * size);
- if ($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- } else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1, 4);
- $scope.first = function () {
- $scope.userdata = getPage($scope.userdata.pre, 4);
- }
- $scope.last = function () {
- $scope.userdata = getPage($scope.userdata.next, 4);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }
- // 分配用户
- $scope.addUserInfo = function (customer) {
- // if (!$scope.enabled) {
- // toaster.pop('error', '您没有为当前客户分配用户的权限!');
- // return;
- // }
- // 获取当前用户在当前企业是否被转移权限
- AccountUser.getEnTransfer ({custUU: customer.myEnterprise.uu}, function(data) {
- customer.enTransfer = data.result;
- //是管理员,或者被转移了权限时
- if ($scope.enabled || customer.enTransfer) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function () {
- return customer;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- $scope.customerParams.reload();
- });
- } else {
- toaster.pop('error', '您没有为当前客户分配用户的权限!');
- }
- });
- };
- // 转移权限
- $scope.transferUserInfo = function (customer) {
- customer.enDistribute = null;
- // if (!$scope.enabled) {
- // toaster.pop('error', '您没有转移当前客户权限的权限!');
- // return;
- // }
- // 获取当前用户在当前企业是否被转移权限
- AccountUser.getDistribute ({custUU: customer.myEnterprise.uu}, function(data) {
- customer.enDistribute = data.result;
- //是管理员,或者被分配时
- if ($scope.enabled || customer.enDistribute) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/transfer_userInfo.html',
- controller: 'TransferUserInfoCtrl',
- resolve: {
- customer: function () {
- return customer;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- $scope.customerParams.reload();
- });
- } else {
- toaster.pop('error', '您没有转移当前客户权限的权限!');
- }
- });
- };
- $scope.showUserInfo = function (customer, boo) {
- $scope.custInfo = customer;
- if (boo) {
- getCustInfos(customer.myEnterprise.uu);
- $scope.userInfoResult = true;
- }
- };
- var getService = function () {
- return VendorService;
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = pageParams.keyword;
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //设置消息已读
- var setOrdersRead = function () {
- var sourceId = [];
- Vendor.setRead({}, sourceId, function (message) {
- });
- };
- setOrdersRead();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
- // 查看详情
- $scope.viewDetail = function (id) {
- window.location.hash = "#/sale/customer/" + id;
- }
- // 导出客户资料列表
- $scope.exportXls = function () {
- VendorService.exportXls.get({}, {}, function (data) {
- if (data.success){
- window.location.href = 'vendor/customer/xls?keyword='+ ($scope.keywordXls || '');
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // 客户详情
- app.controller('CustomerDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', 'VendorService', 'AuthenticationService', function ($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope, VendorService, AuthenticationService) {
- BaseService.scrollBackToTop();
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.vendorContacts = [];
- var loadData = function () {
- Vendor.getCustomerDetail({id: $stateParams.id}, {}, function (data) {
- $scope.customer = data.myEnterprise;
- $scope.customerInfo = data;
- Vendor.custContacts({enuu: $scope.customer.uu}, {}, function (data) {
- $scope.Contacts = data;
- });
- // 查看已分配人员
- VendorService.userInfo.query({uu: $scope.customer.uu}, null, function (data) {
- $scope.custInfos = data;
- var getPage = function (page, size) {
- if ($scope.custInfos) {
- var result = {};
- result.totalCount = $scope.custInfos.length;
- result.content = $scope.custInfos.slice((page - 1) * size, page * size);
- if ($scope.custInfos.length % size == 0) {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size;
- } else {
- result.totalPage = ($scope.custInfos.length - $scope.custInfos.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.userdata = getPage(1, 4);
- $scope.first = function () {
- $scope.userdata = getPage($scope.userdata.pre, 4);
- }
- $scope.last = function () {
- $scope.userdata = getPage($scope.userdata.next, 4);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- // 新增客户联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.myenuu = uu;
- Vendor.saveCustContact({}, $scope.contact, function (data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.Contacts.push(data);
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- // 编辑客户联系人
- $scope.edit = function (contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function () {
- return contact;
- }
- }
- });
- modalInstance.result.then(function (data) {
- Vendor.saveContact({}, data, function (data) {
- loadData();
- toaster.pop('success', '提示', '联系人修改成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- // 删除客户联系人
- $scope.deleteById = function (id, index) {
- $scope.Contacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '客户联系人删除成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 供应商物料信息
- $scope.viewProdList = function (uu) {
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.addUserInfo = function () {
- //TODO
- if ($scope.thisUser.sys) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_userInfo.html',
- controller: 'AddUserInfoCtrl',
- resolve: {
- customer: function () {
- return $scope.customerInfo;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- loadData();
- if (changed) {
- if (checked) {
- $scope.newUser.roles = checked;
- } else {
- loadUsers();
- }
- }
- });
- } else {
- toaster.pop('error', '您不是管理员,无权限分配用户!');
- }
- }
- $scope.Quotation = function (uu, id) {
- $rootScope.custuu = uu;
- $rootScope.prodId = id;
- window.location.hash = "#/sale/quotation/new";
- }
- }]);
- app.controller('AddUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService',
- function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.thisUser = data;
- });
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- $scope.distribute = [];
- AccountUser.findUsers({uu: customer.myEnterprise.uu}, null, function (data) {
- $scope.userinfos = data;
- var distribute = [];
- angular.forEach($scope.userinfos, function (user, index) {
- if (user.distribute) {
- distribute.push({num: index});
- }
- });
- $scope.distribute = distribute;
- $scope.havedone = angular.copy($scope.distribute);
- $scope.loading = false;
- });
- var checkStatus = function (userinfos) {
- var distribute = [];
- angular.forEach(userinfos, function (user, index) {
- if (user.distribute) {
- distribute.push({num: index});
- }
- });
- $scope.distribute = distribute;
- $scope.isChanged = !angular.equals($scope.havedone, $scope.distribute);
- };
- $scope.isChanged = false;
- $scope.isChangedAll = false;
- $scope.changes = [];
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.userinfos, function (item, index) {
- item.distribute = $scope.checkboxes.checked;
- });
- checkStatus($scope.userinfos);
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function () {
- var result = true;
- angular.forEach($scope.userinfos, function (item) {
- if (item.distribute != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- checkStatus($scope.userinfos);
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (customer.myEnterprise.uu) {
- angular.forEach($scope.userinfos, function (item, i) {
- chooseResult.push(item);
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.addUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- // 转移权限
- app.controller('TransferUserInfoCtrl', ['$scope', '$modalInstance', 'customer', 'AccountUser', 'toaster', 'AuthenticationService', function ($scope, $modalInstance, customer, AccountUser, toaster, AuthenticationService) {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- $scope.transfer = [];
- AccountUser.findUsers({uu: customer.myEnterprise.uu}, {}, function (data) {
- $scope.userinfos = data;
- var transfer = [];
- angular.forEach($scope.userinfos, function (user, index) {
- // 当前用户是被管理员转移权限时,转移的是被管理员转移的权限。
- if ($scope.thisUser.userUU === user.userUU && user.transfer) {
- $scope.thisUser.transfer = true;
- }
- });
- angular.forEach($scope.userinfos, function (user, index) {
- if ($scope.thisUser.sys || $scope.thisUser.transfer) {
- if (user.transfer) {
- transfer.push({num: index});
- user.checked = true;
- }
- } else {
- if (user.distribute) {
- transfer.push({num: index});
- user.checked = true;
- }
- }
- });
- $scope.transfer = transfer;
- $scope.havedone = angular.copy($scope.transfer);
- $scope.loading = false;
- });
- var checkStatus = function (userinfos) {
- var transfer = [];
- angular.forEach(userinfos, function (user, index) {
- if (user.transfer) {
- transfer.push({num: index});
- }
- });
- $scope.transfer = transfer;
- $scope.isChanged = !angular.equals($scope.havedone, $scope.transfer);
- };
- $scope.isChanged = false;
- $scope.isChangedAll = false;
- $scope.changes = [];
- // 点击其中一个明细的复选框
- $scope.checkOne = function (user) {
- $scope.changes = [];
- if ($scope.thisUser.sys) { // 管理员操作
- user.$checked = !user.$checked;
- angular.forEach($scope.userinfos, function (userInfo) {
- if ($scope.thisUser.userUU === user.userUU && user.transfer) {
- $scope.thisUser.transfer = true;
- }
- if (user.userUU !== userInfo.userUU) {
- userInfo.transfer = false;
- }
- });
- } else if ($scope.thisUser.transfer) { // 被管理员转移权限的非管理员操作
- user.$checked = !user.$checked;
- angular.forEach($scope.userinfos, function (userInfo) {
- if (user.userUU !== userInfo.userUU) {
- userInfo.transfer = false;
- } else {
- userInfo.transfer = true;
- }
- });
- } else { // 被分配客户的用户
- user.$checked = !user.$checked;
- angular.forEach($scope.userinfos, function (userInfo) {
- if (user.userUU !== userInfo.userUU) {
- userInfo.transfer = false;
- } else {
- userInfo.transfer = true;
- }
- });
- }
- checkStatus($scope.userinfos);
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (customer.myEnterprise.uu) {
- // 当前用户是管理员时
- if ($scope.thisUser.sys) {
- angular.forEach($scope.userinfos, function (item, i) {
- chooseResult.push(item);
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.transferUserToVendor({uu: customer.myEnterprise.uu}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- // 非管理员转移自己的权限时
- angular.forEach($scope.userinfos, function (item, i) {
- if (item.transfer && item.userUU !== $scope.thisUser.userUU) {
- $scope.target = item;
- }
- });
- if (!$scope.target) {
- toaster.pop('error', '保存失败', "您未选择权限转移对象");
- } else {
- $scope.loading = true;
- AccountUser.transferMyDistribute({custUU: customer.myEnterprise.uu, userUU: $scope.target.userUU}, {} ,function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- });
- }
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- /**
- * 页面状态按钮过滤
- */
- var getState = function (active) {
- var fn = 'get';
- switch (active) {
- case 'done':
- fn = 'getDone';
- break;
- case 'todo':
- fn = 'getTodo';
- break;
- case 'end':
- fn = 'getEnd';
- break;
- case 'waiting':
- fn = 'getWaiting';
- break;
- case 'received':
- fn = 'getReceived';
- break;
- case 'invalid':
- fn = 'getInvalid';
- break;
- // 已采纳
- case 'agreed':
- fn = 'getAgreed';
- break;
- // 未采纳
- case 'refused':
- fn = 'getRefused';
- break;
- // 个人
- case 'personal':
- fn = 'getPersonal';
- break;
- // 集体
- case 'teams':
- fn = 'getTeams';
- break;
- // 非标准
- case 'nonstandard':
- fn = 'getNonstandard';
- break;
- // 标准
- case 'standard':
- fn = 'getStandard';
- break;
- // 变更单无需确认
- case 'unread':
- fn = 'getUnread';
- break;
- }
- return fn;
- };
- /**
- * 改变单据日期范围
- */
- var getDateCondition = function (zone, condition) {
- var fromDate = new Date();
- var toDate = new Date();
- //去除时分秒限制,dateFrom设置成0时0分0秒,dateTo设置成23时59分59秒
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- if (zone == -1) { // 自定义时间,什么都不做
- } else if (zone == 1) {
- fromDate.setMonth(fromDate.getMonth() - 1);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else if (zone == 3) {
- fromDate.setMonth(fromDate.getMonth() - 3);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else if (zone == 6) {
- fromDate.setMonth(fromDate.getMonth() - 6);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else {
- condition.dateFrom = null;
- condition.dateTo = null;
- }
- };
- /**
- * 改变单据交货日期范围
- */
- var getDelveryCondition = function (zone, condition) {
- var date = new Date();
- if (zone == -1) {
- condition.deliveryFrom = null;
- condition.deliveryTo = null;
- } else if (zone == 1) {
- date.setMonth(date.getMonth() + 1);
- condition.deliveryTo = date;
- condition.deliveryFrom = new Date();
- } else if (zone == 2) {
- date.setMonth(date.getMonth() + 2);
- condition.deliveryTo = date;
- condition.deliveryFrom = new Date();
- }
- };
- /**
- * 将日期转化为整数日期
- */
- var getDateTime = function (date) {
- if (angular.isDate(date)) {
- return date.getTime();
- } else {
- return null;
- }
- };
- /**
- * 删除数组里某个特定的值
- */
- var removeByValue = function (arr, val) {
- for(var i=0; i<arr.length; i++) {
- if(arr[i] == val) {
- arr.splice(i, 1);
- break;
- }
- }
- };
- app.controller('PurcOrderCtrl', ['$scope', '$filter', 'PurcOrders', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', '$rootScope', 'PurchaseOrder', 'PurcOrdersInfo', 'PurcOrderItem', 'CurrentRole',
- function ($scope, $filter, PurcOrders, PurcOrder, ngTableParams, toaster, ReportService, BaseService, $rootScope, PurchaseOrder, PurcOrdersInfo, PurcOrderItem, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'all';
- }
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcOrders : PurcOrdersInfo;
- };
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getPurcStatus = function (active) {
- var fn = 'getPurcAll';
- switch (active) {
- case 'done':
- fn = 'getPurcDone';
- break;
- case 'todo':
- fn = 'getPurcTodo';
- break;
- case 'end':
- fn = 'getPurcEnd';
- break;
- case 'waiting':
- fn = 'getPurcWaiting';
- break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {
- display: 'desc',
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 15, 25, 50],
- getData: function ($defer, params) {// 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $defer.resolve(page.content);
- $scope.total = page.totalElement;
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcOrders.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcOrders.setRead({}, function () {
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function () {
- PurcOrders.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.getOrderTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- // 需方 打印 采购单
- $scope.custPrint = function (order) {
- var newPage = window.open("about:blank");
- PurcOrder.printPermission({}, function () {
- PurcOrder.custPrintCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'PURCLIST_CUST', "where purc$orders.pu_id=" + order.id, newPage);
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (order) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.tip = keyword;
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 复制订单
- $scope.copyorder = function (id) {
- PurchaseOrder.copyorder({id: id}, {}, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '单据复制成功');
- window.location.hash = "#purc/cart/" + data.id;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 导出
- $scope.exportXls = function () {
- PurcOrders.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/orders/purc/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('PurcOrderDetailCtrl', ['$scope', '$stateParams', 'PurcOrder', 'PurcOrderItem', 'toaster', 'ReportService', 'PurcOrdersInfo', 'CurrentRole', function ($scope, $stateParams, PurcOrder, PurcOrderItem, toaster, ReportService, PurcOrdersInfo, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- $scope.loading = true;
- PurcOrdersInfo.getAll({id: $stateParams.id},{}, function (data) {
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function (item) {
- sum += item.qty * item.price;
- });
- $scope.order.total = sum;
- // if($scope.order.display == 1) {//未查看的设为已查看
- // $scope.setDisplay('setRead', $scope.order.id);
- // }
- //$scope.loading = false;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.onReplyClick = function (item, inverse) {
- if (item.reply) {
- if (!item.reply.qty || item.reply.qty < 0 || item.reply.qty > item.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- PurcOrderItem.reply({orderItemId: item.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- //设置为已查看
- $scope.setDisplay = function (state, orderId) {
- if (orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function () {
- // $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- if (str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if (str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- }]);
- app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PagingRelease', 'SnapshotService', 'PurcOrderItemInfo', 'token', 'CurrentRole', '$timeout', '$modal', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PagingRelease, SnapshotService, PurcOrderItemInfo, token, CurrentRole, $timeout, $modal) {
- BaseService.scrollBackToTop();
- // 判断是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.nowdate = new Date();
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function () {
- return $scope.searchMethod ? PurcOrderItem : PurcOrderItemInfo;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {
- date: 'desc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 15, 25, 50],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- $defer.resolve(page.content);
- params.total(page.totalElement);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcOrderItem.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcOrderItem.setRead({}, sourceId, function (message) {
- getUnreadCount();
- });
- };
- //批量设置单据已读
- $scope.setOrdersReadByBatch = function () {
- var sourceId = [];
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- sourceId.push(order.id);
- }
- });
- PurcOrderItem.setRead({}, sourceId, function (message) {
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcOrderItem.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcOrderItem.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getOrderTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 获取token信息
- $scope.getToken = function() {
- token.info({userType: 'sale'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- $scope.onReplyClick = function (item, inverse) {
- if (item.reply) {
- if (!item.reply.qty || item.reply.qty < 0 /*|| item.reply.qty > item.qty*/) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- if($scope.token != null) {
- PurcOrderItem.reply({orderItemId: item.id, token: $scope.token}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- }
- };
- //打印 采购单
- $scope.print = function (order) {
- var newPage = window.open("about:blank");
- PurcOrder.printPermission({}, function () {
- PurcOrder.printCount({id: order.id}, {});//增加打印此次 // 在此方法内添加记录日志
- if (order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
- ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id , newPage);
- $scope.tableParams.reload();
- },function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (order) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- //批量回复采购订单
- $scope.replyByBatch = function () {
- $scope.loading = true;
- var str = '';
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- str += order.id;
- str += ',';
- }
- });
- if (!(str == '')) {
- $scope.loading = false;
- str = str.substr(0, str.length - 1);
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/modal/reply_bybatch.html',
- controller: 'ReplyByBatchCtrl',
- resolve: {}
- });
- modalInstance.result.then(function(data) {
- $scope.loading = true;
- var reply = data;
- var date = null;
- if (reply.date && reply.method == 1) {
- date = reply.date.getTime();
- }
- PurcOrderItem.replyByBatch({date: date}, str, function () {
- $scope.loading = false;
- $scope.tableParams.reload();
- toaster.pop('success', '提示', '批量回复成功');
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', '批量回复失败');
- });
- });
- } else {//没有勾选其中的明细
- toaster.pop('error', '提示', '请先选择需要回复的单据');
- $scope.loading = false;
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //设置为已查看
- $scope.setDisplay = function (state, orderId) {
- if (orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- if (str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if (str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- // 导出
- $scope.exportXls = function () {
- PurcOrderItem.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/orders/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 批量回复模态框
- */
- app.controller('ReplyByBatchCtrl', ['$scope', '$modalInstance', '$filter', 'toaster', function($scope, $modalInstance, $filter, toaster) {
- $scope.activeTab = 'custom';
- $scope.reply = {
- method: 1
- };
- $scope.getMinDate = function () {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.$dateOpen = !openParam;
- };
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- // 提交
- $scope.submit = function () {
- if ($scope.reply.method == 0) {
- $modalInstance.close($scope.reply);
- } else if ($scope.reply.method == 1) {
- if (angular.isUndefined($scope.reply.date)) {
- toaster.pop('error', '提示', '请先选择日期')
- } else {
- $modalInstance.close($scope.reply);
- }
- }
- }
- }]);
- app.controller('SaleOrderDetailCtrl', ['$scope', '$stateParams', 'PurcOrder', 'PurcOrderItem', 'toaster', 'ReportService', 'CurrentRole', 'token', 'file', function ($scope, $stateParams, PurcOrder, PurcOrderItem, toaster, ReportService, CurrentRole, token, file) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var existFile = false;
- var loadData = function () {
- PurcOrder.get({id: $stateParams.id}, function (data) {
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function (item) {
- sum += item.qty * item.price;
- if (item.attachs.length > 0) {
- existFile = true;
- }
- });
- $scope.order.total = sum;
- if ($scope.order.display == 1) {//未查看的设为已查看
- $scope.setDisplay('setRead', $scope.order.id);
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.getReply = function (item) {
- if (!item.replies) {
- PurcOrderItem.getReply({orderItemId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 获取token信息
- var getToken = function() {
- token.info({userType: 'sale'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- getToken();
- $scope.onReplyClick = function (item, inverse) {
- if (item.reply) {
- if (!item.reply.qty || item.reply.qty < 0 /*|| item.reply.qty > item.qty*/) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(item.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = item.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- if($scope.token != null) {
- PurcOrderItem.reply({orderItemId: item.id, token: $scope.token}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- }
- };
- // 采购单
- $scope.print = function (order) {
- var newPage = window.open("about:blank");
- PurcOrder.printPermission({}, function () {
- PurcOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id, newPage);
- },function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- //设置为已查看
- $scope.setDisplay = function (state, orderId) {
- if (orderId) {//设置单个
- PurcOrder[state].call({}, {ids: '' + orderId}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- } else {//设置已勾选的
- var str = null;
- angular.forEach($scope.tableParams.data, function (order) {
- if (order.$selected == true) {
- if (str != null && str != '') str += ',';
- str += order.id;
- }
- });
- if (str != null && str != '') {
- PurcOrder[state].call({}, {ids: '' + str}, function () {
- $scope.tableParams.reload();
- }, function () {
- toaster.pop('error', '错误', "设置失败");
- });
- }
- }
- };
- // 下载附件
- $scope.fileDownload = function (id) {
- if (!existFile) {
- toaster.pop('error', '提示', "当前采购单不存在附件信息");
- } else {
- window.open("file/batch/" + id);
- }
- }
- }]);
- app.controller('SaleChangeCtrl', ['$scope', '$filter', 'PurcChange', 'PurcChanges', 'ngTableParams', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $filter, PurcChange, PurcChanges, ngTableParams, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcChange : PurcChanges;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcChange.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcChange.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcChange.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcChange.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- PurcChange.reply({changeId: change.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcChange.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/changes/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('SaleChangeDetailCtrl', ['$scope', '$stateParams', 'PurcChange', 'toaster', 'CurrentRole', function ($scope, $stateParams, PurcChange, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- PurcChange.getItem({id: $stateParams.id}, function (data) {
- $scope.change = data;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- PurcChange.reply({changeId: change.id}, reply, function () {
- toaster.pop('info', '提示', '回复成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- }]);
- //客户采购询价
- app.controller('SaleInquiryCtrl', ['$scope', '$filter', 'PurcInquiry', 'ngTableParams', 'toaster', 'BaseService', 'PurcInquiryInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', function ($scope, $filter, PurcInquiry, ngTableParams, toaster, BaseService, PurcInquiryInfo, $upload, $rootScope, token, $timeout, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- // 设置阅读状态
- $scope.setReadStatus = function(msg) {
- if(!msg.read) {
- PurcInquiry.setStatus({id: msg.inid}, {}, function(data) {
- });
- }
- }
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcInquiry : PurcInquiryInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcInquiry.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcInquiry.setRead({}, sourceId, function (message) {
- getUnreadCount();
- removeByValue($scope.unreadCode, id);
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcInquiry.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcInquiry.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.addStep = function (inquiryItem) {
- $scope.replyPrices.push(true);
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else {
- inquiryItem.replies.push({});
- if (inquiryItem.replies.length != 1) {
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- }
- }
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- $scope.replyPrices.splice(stepIndex, 1);
- $scope.replylapQtys.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id},function (data) {
- $scope.historyShow = true;
- item.history = data;
- }, function (response) {
- $scope.historyShow = false;
- //toaster.pop('error', '数据加载失败', response.data);
- });
- }
- };
- // 获取token信息
- $scope.getToken = function() {
- token.info({userType: 'saleinquiry'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- $scope.deleteAttach = function (attaches, index) {
- attaches.splice(index, 1);
- };
-
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- // 判断分段数是否合法
- var valid = true;
- var validLapQty = 0;
- angular.forEach(item.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price) {
- replies.push(r);
- }
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- });
- item.replies = replies;
- $scope.loading = true;
- if (!valid) {
- if (validLapQty) {
- toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('info', '提示', '分段数量不合法,不能保存!');
- }
- $scope.loading = false;
- } else {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- if (withSteps) { // 保存并报价
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'reply'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '附件上传失败');
- });
- } else {
- PurcInquiry.reply({itemId: item.id, token: $scope.token}, item, function (data) {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '询价失效', response.data);
- });
- }
- } else { // 保存
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'save'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '附件上传失败');
- });
- } else {
- PurcInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function (data) {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- $scope.verifylapQty(r.lapQty, i, item);
- bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
- });
- return bool;
- };
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,6})?$/;
- var valid = true;
- angular.forEach(inquiryItem.replies, function(reply, $index) {
- if ($index < index && reply.lapQty >= value) {
- valid = false;
- }
- });
- $scope.replylapQtys[index] = regex.test(value) && valid;
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- // 导出
- $scope.exportXls = function () {
- PurcInquiry.exportXls({}, {}, function (data) {
- if (data.success) {
- window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- }]);
- // 询价单明细
- app.controller('SaleInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', function ($scope, $stateParams, PurcInquiry, $filter, toaster, $upload, token, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- PurcInquiry.getAll({id: $stateParams.id}, function (data) {
- $scope.newinquiryItems = data;
- var inquiry = data[0].inquiry;
- //inquiry.inquiryItems = data;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,6})?$/;
- var valid = true;
- angular.forEach(inquiryItem.replies, function(reply, $index) {
- if ($index < index && reply.lapQty >= value) {
- valid = false;
- }
- });
- $scope.replylapQtys[index] = regex.test(value) && valid;
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- $scope.verifylapQty(r.lapQty, i, item);
- bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
- });
- return bool;
- };
- // 获取token信息
- $scope.getToken = function() {
- token.info({userType: 'saleinquiry'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- $scope.deleteAttach = function (attaches, index) {
- attaches.splice(index, 1);
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- var valid = true;
- var validLapQty = 0;
- angular.forEach(item.replies, function (r, i) {
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- $scope.loading = true;
- if (!valid) { // 不合法时给出提示
- if (validLapQty) {
- toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('info', '提示', '分段数量不合法,不能保存!');
- }
- $scope.loading = false;
- } else {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- if (withSteps) {
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'reply'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- window.location.reload();
- });
- } else {
- PurcInquiry.reply({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- // loadData();
- window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '询价失效', response.data);
- });
- }
- } else {
- if(null != file) {
- $upload.upload({
- url: 'sale/inquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'save'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- window.location.reload();
- });
- } else {
- PurcInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- // loadData();
- window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- }]);
- // 平台新增的询价单
- app.controller('PurcInquiryCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'PurcProduct', 'PurcProductNewest', '$timeout', '$http', 'ShipAddress', 'Search', 'ComponentActiveAPI', '$state',
- function ($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, PurcProduct, PurcProductNewest, $timeout, $http, ShipAddress, Search, ComponentActiveAPI, $state) {
- $scope.status = 'InquiryNew';
- $scope.active = 'all';
- $rootScope.tenderVendor = null;// 清除掉已选择的
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcProduct : PurcProductNewest;
- };
- $scope.inquiry = {
- code: 'XJ' + $filter('date')(new Date(), 'yyMMddsss'),
- showdate: $filter('date')(new Date, 'yyyy-MM-dd'),
- priceType: '采购',
- isOpen: 1,
- invoice: 0,
- ifTax: 1,
- currency: 'RMB',
- inquirytype: '询价'
- };
- $scope.changeCurrency = function (inquiry) {
- if (inquiry.currency !== 'RMB') {
- $scope.notRMB = true;
- inquiry.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- inquiry.invoice = 0;
- } else {
- $scope.notRMB = false;
- }
- };
- // 获取收货地址列表
- var loadShipAddress = function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- if (angular.isDefined($scope.ships)) {
- $scope.inquiry.ship = $scope.ships[0].address + $scope.ships[0].addressdet + $scope.ships[0].receiver + $scope.ships[0].usertel;
- }
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- $scope.currentDay = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.vendors = [];
- // 查找供应商
- $scope.dbfindVendor = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- var ifPush = true;
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (vendor) {
- if (!$scope.vendors) {// 不存在就先创建
- $scope.vendors = [{}];
- $scope.vendors.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0; i < $scope.vendors.length; i++) {
- ifPush = true;
- if ($scope.vendors[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.vendors.push({
- enName: vendor.vendorEnterprise.enName,
- enuu: vendor.vendorEnterprise.uu
- });
- }
- }
- });
- $rootScope.tenderVendor = $scope.vendors;
- }, function () {
- });
- }, function () {
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function (index) {
- $scope.vendors.splice(index, 1);
- };
- $scope.removeChecked = function () {
- if ($scope.vendors.length > 0) {
- $scope.vendors = [];
- $rootScope.tenderVendor = '';
- }
- }
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.inquiry.inquiryItems = [];
- var prod = {
- cmpCode: null,
- prodTitle: null,
- inbrand: null,
- toDate: null,
- unit: 'PCS',
- needquantity: null
- };
- $scope.inquiry.inquiryItems.push(prod);
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function (value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function (value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- $scope.selectKind = function (prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function () {
- return $scope.actives;
- }
- }
- }).result.then(function (data) {
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function () {
- });
- };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function (brand, prod) {
- if (brand instanceof String) {
- prod.inbrand = brand;
- } else if (brand instanceof Object) {
- prod.inbrand = brand.brandCn;
- }
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function (prod) { //打开模态
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller: 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function () {// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function (brand) {
- prod.inbrand = brand.nameCn;
- }, function (reason) {
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function (cmp, prod) {
- ComponentActiveAPI.get({uuid: cmp.uuid}, {}, function (data) {
- $scope.component = data;
- prod.cmpCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.inbrand = data.brand.nameCn;
- }, function (res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcInquiryUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.inquiry.inquiryItems.push(prod);
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- })
- }, function () {
- });
- }
- //增加商品
- $scope.add = function () {
- $scope.inquiry.inquiryItems.push(
- {
- cmpCode: null,
- prodTitle: null,
- unit: 'PCS',
- ibrand: null,
- toDate: null,
- needquantity: null
- });
- };
- //删除商品
- $scope.del = function (index) {
- $scope.inquiry.inquiryItems.splice(index, 1);
- };
- $scope.check = function (product) {
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- $scope.inquiry.inquiryItems.push({
- cmpCode: product.cmpCode, prodTitle: product.title, spec: product.spec, unit: product.unit,
- currency: null, toDate: null, needquantity: null, productId: product.id, inbrand: product.brand
- });
- }
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.inquiry.inquiryItems[index].$toDateOpen = !openParam;
- };
- $scope.openEndDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.ifrepeat = false;
- // 保存
- $scope.save = function () {
- $scope.loading = true;
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for (var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if (i != j) {
- if ($scope.item.prodCode == $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- if (!$scope.ifrepeat) {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- if ($scope.inquiry.isOpen == 0) { // 指定询价
- if ($scope.vendors.length > 0) {
- $upload.upload({
- url: 'purc/inquiry/save/withVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $rootScope.active = 'todo';
- window.location.hash = "#/purc/inquiry_unapply";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- } else {
- $upload.upload({
- url: 'purc/inquiry/save/withoutVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', '存在相同条件的物料信息');
- }
- }
- // 保存并提交
- $scope.submit = function () {
- $scope.loading = true;
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for (var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if (i != j) {
- if ($scope.item.prodCode == $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- if (!$scope.ifrepeat) {
- if ($scope.inquiry.isOpen == 0) { // 指定询价
- if ($scope.vendors.length > 0) {
- $upload.upload({
- url: 'purc/inquiry/submit/withVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- window.location.hash = "#/purc/purchaseinquiry";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- } else {
- toaster.pop('info', '提示', '请先选择供应商');
- }
- } else {
- $upload.upload({
- url: 'purc/inquiry/submit/withoutVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status, headers, config) {
- $scope.loadingShow = false;
- if (status == 403) { // 抛异常专用
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', '存在相同条件的物料信息');
- }
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- }]);
- /**
- * 代采订单批量导入
- */
- app.controller('PurcInquiryUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function () {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'purc/inquiry/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- toaster.pop('error', response.data || response);
- });
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'purc/inquiry/upload/template';
- };
- $scope.enSure = function () {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- // 平台询价单(已提交)
- app.controller('PurchaseInquiryCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', 'PurchaseInquiry', '$rootScope', 'CurrentRole', function ($scope, $filter, ngTableParams, toaster, BaseService, PurchaseInquiry, $rootScope, CurrentRole) {
- $scope.status = 'InquirySubmit';
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- }
- var getService = function () {
- return PurchaseInquiry;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurchaseInquiry.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurchaseInquiry.setRead({}, sourceId, function (message) {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获得未读单据id
- var getUnreadIds = function (){
- PurchaseInquiry.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 采纳
- $scope.accept = function (id) {
- PurchaseInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- PurchaseInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 导出
- $scope.exportXls = function () {
- PurchaseInquiry.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'purc/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // 平台询价单(未提交)
- app.controller('UnapplyInquiryCtrl', ['$scope', 'PurchaseInquiry', 'ngTableParams', 'BaseService', 'toaster', '$rootScope', function ($scope, PurchaseInquiry, ngTableParams, BaseService, toaster, $rootScope) {
- BaseService.scrollBackToTop();
- if ($rootScope.active = 'done') {
- $scope.active = 'done';
- $rootScope.active = '';
- }
- if ($rootScope.active = 'todo') {
- $scope.active = 'todo';
- $rootScope.active = '';
- }
- var getService = function () {
- if ($scope.active == 'todo') {
- return PurchaseInquiry.getUnapply;
- }
- if ($scope.active == 'done') {
- return PurchaseInquiry.getSubmit;
- }
- }
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- }
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc',
- 'enterprise.enName': 'asc',
- 'code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 删除明细
- $scope.deleteById = function (id) {
- PurchaseInquiry.deleteById({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 删除主表
- $scope.clearOrder = function (id) {
- PurchaseInquiry.clearOrder({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 提交
- $scope.submit = function (id) {
- PurchaseInquiry.submitUnapply({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '单据提交成功');
- $scope.active = 'done';
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 发布公共询价
- $scope.publish = function (id) {
- PurchaseInquiry.publishInquiry({id: id}, {}, function (data) {
- toaster.pop('success', '提示', data.success);
- $scope.active = 'done';
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- // 公共询价列表
- app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', 'publicInquiryList', '$modal', '$http', 'AccountEnterprise', 'customer', 'AuthenticationService', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry, publicInquiryList, $modal, $http, AccountEnterprise, customer, AuthenticationService) {
- BaseService.scrollBackToTop();
- }]);
- /**
- * 报价操作
- */
- app.controller('QuoteCtrl', ['$scope', 'inquiryItem', 'toaster', 'publicInquiry', '$modalInstance', '$upload', function($scope, inquiryItem, toaster, publicInquiry, $modalInstance, $upload) {
- $scope.inquiryItem = inquiryItem;
- if ($scope.inquiryItem.replies == null || $scope.inquiryItem.replies.length == 0) {
- $scope.inquiryItem.replies = [];
- var reply = {
- lapQty: 0,
- price: null
- };
- $scope.inquiryItem.replies.push(reply);
- }
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- // 获取默认币别
- publicInquiry.getCurrency({}, function(data) {
- $scope.currencies = data;
- });
- // 增加一列分段报价
- $scope.addStep = function (inquiryItem) {
- var check = true;
- angular.forEach(inquiryItem.replies, function(reply) {
- if (reply.lapQty == null) {
- toaster.pop('error', '提示', '存在未填写分段数量的分段,请先填写分段数量');
- check = false;
- }
- if (check && reply.price == null) {
- toaster.pop('error', '提示', '存在未填写价格的分段,请先填写价格');
- check = false;
- }
- });
- if (check) {
- $scope.replyPrices.push(true);
- if (inquiryItem.replies.length >= 5) {
- toaster.pop('warning', '提示', '最多支持5个分段!');
- } else {
- inquiryItem.replies.push({});
- if (inquiryItem.replies.length != 1) {
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- }
- }
- }
- };
- // 删除一列分段报价
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- $scope.replyPrices.splice(stepIndex, 1);
- $scope.replylapQtys.splice(stepIndex, 1);
- };
- // 取消,关闭弹出框
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- // 保存报价信息
- $scope.save = function(inquiryItem, method) {
- var replies = [];
- // 判断分段数是否合法
- var valid = true;
- var validLapQty = 0;
- angular.forEach(inquiryItem.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price) {
- replies.push(r);
- }
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(inquiryItem.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- });
- inquiryItem.replies = replies;
- $scope.loading = true;
- if (!valid) {
- if (validLapQty) {
- toaster.pop('error', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('error', '提示', '分段数量不合法,不能报价!');
- }
- } else {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'pubInquiry/turnToQuotation',
- file: file,
- method: 'POST',
- data: {
- item: inquiryItem,
- method: method
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $modalInstance.close();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '报价失败');
- });
- }
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- }]);
- /**
- * 公共询价详情
- */
- app.controller('PublicInquiryListDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'AccountEnterprise', 'publicInquiry', 'publicInquiryList', '$modal', '$http', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, AccountEnterprise, publicInquiry, publicInquiryList, $modal, $http) {
- BaseService.scrollBackToTop();
- $scope.currentHasBid = false;
- var loadData = function () {
- // 当前企业
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/sale/publicInquiry/detail',
- params: {id: $stateParams.id, enuu: $scope.enterprise.uu}
- }).success(function (response) {
- if (response) {
- $scope.inquiryItem = response.inquiryItem;
- }
- }).error(function (err) {
- toaster.pop('error', '数据加载失败', err);
- });
- });
- });
- };
- loadData();
- // 当前时间
- $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
- // 当前企业
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data;
- });
- $scope.isOverDue = function (date) {
- if (date) {
- var ndate = new Date();
- ndate.setHours(23, 59, 59 ,999);
- ndate.setDate(ndate.getDate());
- var timestamp = Date.parse(ndate);
- if (date > timestamp) {
- return true;
- } else {
- return false;
- }
- } else {
- return true;
- }
- }
- // 转客户询价
- $scope.transtoInquiry = function (inquiryItem) {
- publicInquiry.quotationInfo({id: inquiryItem.id}, function(data) {
- if (data.inquiryItem) { //存在已报价的就不进行报价操作
- toaster.pop('error', '该询价单已已经报价');
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }
- });
- }
- }]);
- // 询价单明细
- app.controller('PurcInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', 'CurrentRole', function ($scope, $stateParams, PurcInquiry, $filter, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = !data.isUser;
- });
- var loadData = function () {
- PurcInquiry.getAll({id: $stateParams.id}, function (data) {
- $scope.newinquiryItems = data;
- var inquiry = data[0].inquiry;
- //inquiry.inquiryItems = data;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- bool = (i > 0 ? r.lapQty : 1) && r.price;
- });
- return bool;
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- angular.forEach(item.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- if (withSteps) {
- PurcInquiry.reply({itemId: item.id}, item, function () {
- toaster.pop('info', '提示', '报价成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '报价失败', response.data);
- });
- }
- };
- }]);
- // 询价单明细(发出)
- app.controller('PurcInquiryInfoDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'CurrentRole', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- PurchaseInquiry.detail({id: $stateParams.id}, {},function (data) {
- $scope.inquiry = data;
- },function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.nowDate = new Date().getTime();
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- bool = (i > 0 ? r.lapQty : 1) && r.price;
- });
- return bool;
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- angular.forEach(item.replies, function (r, i) {
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- if (withSteps) {
- PurcInquiry.reply({itemId: item.id}, item, function () {
- toaster.pop('info', '提示', '报价成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '报价失败', response.data);
- });
- }
- };
- // 采纳
- $scope.accept = function (id) {
- PurchaseInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- PurchaseInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- // 模具询价管理
- app.controller('SaleInquiryMouldCtrl', ['$scope', '$filter', 'PurcInquiryMould', 'ngTableParams', 'toaster', 'BaseService', '$upload', 'PurcInquiryMouldSql', 'CurrentRole', function ($scope, $filter, PurcInquiryMould, ngTableParams, toaster, BaseService, $upload, PurcInquiryMouldSql, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- var inquiryMould_copy = {};
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- };
- var getService = function () {
- if ($scope.keyword) {
- return PurcInquiryMould;
- } else {
- return PurcInquiryMouldSql;
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- // 用来验证价格修改
- var mould = page.content;
- inquiryMould_copy = angular.copy(mould);
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词 $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcInquiryMould.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcInquiryMould.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcInquiryMould.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcInquiryMould.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiryMould.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replyPrices.push(true);
- // 取消
- $scope.reload = function () {
- $scope.tableParams.reload();
- $scope.canSave = false;
- }
- // 能否保存设置
- $scope.canSave = false;
- // items价格验证
- $scope.verifyItems = function (price, reply) {
- var regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;// ^[0-9]+(\.[0-9]{1,6})?$
- if (regex.test(price) && price != 0) {
- if (price != reply) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- // prod下prods价格验证
- $scope.verifyProds = function (price, reply) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if (regex.test(price) && price != 0) {
- if (price != reply) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- //有价格为0或者不符合正则式,则不能报价
- $scope.notZero = function (mould) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- angular.forEach(mould.inquiryMouldItems, function (item) {
- if (item.price == 0 || !regex.test(item.price)) {
- $scope.canSave = false;
- }
- angular.forEach(item.inquiryMouldDetails, function (detail) {
- if (detail.price == 0 || !regex.test(detail.price)) {
- $scope.canSave = false;
- }
- })
- });
- }
- $scope.blurPrice = function (price) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (!regex.test(price)) {
- toaster.pop('warning', '格式错误', '请输入有效价格');
- }
- }
- // 获取历史报价
- $scope.getHistory = function (mould) {
- if (!mould.history) {
- PurcInquiryMould.getHistory({id: mould.id},{}, function (data) {
- $scope.historyShow = true;
- mould.history = data;
- },function (response) {
- $scope.historyShow = false;
- });
- }
- };
- var uploadAttach = function (mould, file) {
- // var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
- $scope.mould = mould;
- $upload.upload({
- url: 'sale/mould/' + mould.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.mould
- }
- }).success(function (res) {
- $scope.mould.sellAttachs.push(res);
- }).error(function (res) {
- });
- }
- $scope.pushFile = function(mould, file) {
- // var file = $scope.myFiles;
- if (file.length > 0) {
- for (var i = 0; i < file.length; i++) {
- console.log(file[i].name);
- var flag = true;
- if (mould.sellAttachs.length > 0) {
- for (var j = 0; j < mould.sellAttachs.length; j++) {
- if (mould.sellAttachs[j].name == file[i].name
- && mould.sellAttachs[j].size == file[i].size) {
- flag = false;
- break;
- }
- }
- }
- if (flag) {
- uploadAttach(mould, file[i]);
- $scope.canSave = true;
- }
- }
- }
- document.getElementById("inquiryMould.sellAttachs").value = "";
- };
- $scope.removeFile = function(mould, file) {
- $scope.inquiryMould = mould;
- if ($scope.inquiryMould.sellAttachs != null && $scope.inquiryMould.sellAttachs.length > 0) {
- for (var i = 0; i < $scope.inquiryMould.sellAttachs.length; i++) {
- if ($scope.inquiryMould.sellAttachs[i].name == file.name
- && $scope.inquiryMould.sellAttachs[i].size == file.size) {
- $scope.inquiryMould.sellAttachs.splice(i, 1);
- }
- }
- }
- };
- // 保存并确认报价
- $scope.onReplyClick = function (mould, withSteps) {
- $scope.loading = true;
- if (withSteps) {
- PurcInquiryMould.reply({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- $scope.canSave = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '报价失败', response.data);
- });
- PurcInquiryMould.saveHistory({id: mould.id}, mould, function () {
- }, function (response) {
- });
- } else {
- PurcInquiryMould.saveItem({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 导出客户资料列表
- $scope.exportXls = function () {
- PurcInquiryMould.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/mould/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // 模具询价单明细
- app.controller('SaleInquiryMouldDetailCtrl', ['$scope', '$stateParams', 'PurcInquiryMould', '$filter', 'toaster', '$upload', 'CurrentRole', function ($scope, $stateParams, PurcInquiryMould, $filter, toaster, $upload, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var inquiryMould_copy = {};
- var loadData = function () {
- PurcInquiryMould.getAll({id: $stateParams.id}, function (data) {
- // 用来验证价格修改
- inquiryMould_copy = angular.copy(data);
- $scope.inquiryMould_copy = inquiryMould_copy;
- $scope.newinquirymould = data;
- var mould = data;
- angular.forEach(mould.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiryMould = mould;
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- // 取消
- $scope.reload = function () {
- loadData();
- $scope.canSave = false;
- }
- //有价格为0,则不能报价
- $scope.notZero = function (mould) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- angular.forEach(mould.inquiryMouldItems, function (item) {
- if (item.price == 0 || !regex.test(item.price)) {
- $scope.canSave = false;
- }
- angular.forEach(item.inquiryMouldDetails, function (detail) {
- if (detail.price == 0 || !regex.test(detail.price)) {
- $scope.canSave = false;
- }
- })
- });
- }
- $scope.blurPrice = function (price) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (!regex.test(price)) {
- toaster.pop('warning', '格式错误', '请输入有效价格');
- }
- }
- // 获取历史报价
- $scope.getHistory = function (mould) {
- if (!mould.history) {
- PurcInquiryMould.getHistory({id: mould.id},{}, function (data) {
- $scope.historyShow = true;
- mould.history = data;
- },function (response) {
- $scope.historyShow = false;
- //toaster.pop('error', '提示', response.data);
- });
- }
- };
- $scope.canSave = false;
- // items价格验证
- $scope.verifyItems = function (price, index) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if (regex.test(price) && price != 0) {
- var itemprice = $scope.inquiryMould.inquiryMouldItems[index].price;
- if (itemprice != inquiryMould_copy.inquiryMouldItems[index].price) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- // prod下prods价格验证
- $scope.verifyProds = function (price, index, parentIndex) {
- var regex = /^(0|[1-9][0-9]{0,9})(\.[0-9]{1,6})?$/;//
- if (regex.test(price) && price != 0) {
- var prodPrice = $scope.inquiryMould.inquiryMouldItems[parentIndex].inquiryMouldDetails[index].price;
- if (prodPrice != inquiryMould_copy.inquiryMouldItems[parentIndex].inquiryMouldDetails[index].price) {
- $scope.canSave = true;
- } else {
- $scope.canSave = false;
- }
- } else {
- $scope.canSave = false;
- }
- }
- // 上传附件
- var uploadAttach = function(file) {
- // var file = mould.attachFile.$viewValue, file = file && file.length > 0 ? file[0] : null;
- $scope.mould = $scope.inquiryMould;
- $upload.upload({
- url: 'sale/mould/' + $scope.mould.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.mould
- }
- }).success(function(attach){
- if (attach){
- $scope.inquiryMould.sellAttachs.push(attach);
- }
- }).error(function(res){
- console.log("failure");
- console.log(res);
- });
- }
- $scope.pushFile = function(file) {
- // var file = $scope.myFiles;
- if (file.length > 0) {
- for (var i = 0; i < file.length; i++) {
- console.log(file[i].name);
- var flag = true;
- if ($scope.inquiryMould.sellAttachs.length > 0) {
- for (var j = 0; j < $scope.inquiryMould.sellAttachs.length; j++) {
- if ($scope.inquiryMould.sellAttachs[j].name == file[i].name
- && $scope.inquiryMould.sellAttachs[j].size == file[i].size) {
- flag = false;
- break;
- }
- }
- }
- if (flag) {
- uploadAttach(file[i]);
- }
- }
- }
- };
- $scope.removeFile = function(file) {
- if ($scope.inquiryMould.sellAttachs != null && $scope.inquiryMould.sellAttachs.length > 0) {
- for (var i = 0; i < $scope.inquiryMould.sellAttachs.length; i++) {
- if ($scope.inquiryMould.sellAttachs[i].name == file.name
- && $scope.inquiryMould.sellAttachs[i].size == file.size) {
- $scope.inquiryMould.sellAttachs.splice(i, 1);
- document.getElementById("file").value = "";
- }
- }
- }
- };
- $scope.onReplyClick = function (mould, withSteps) {
- $scope.loading = true;
- if (withSteps) {
- PurcInquiryMould.reply({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- loadData();
- $scope.canSave = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '报价失败', response.data);
- });
- PurcInquiryMould.saveHistory({id: mould.id}, mould, function () {
- }, function (response) {
- });
- } else {
- PurcInquiryMould.saveItem({id: mould.id}, mould, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- }]);
- // 主动报价 - 列表
- app.controller('SaleQuotationListCtrl', ['$scope', '$filter', 'Quotation', 'PurcInquiry', 'ngTableParams', 'toaster', 'BaseService', '$rootScope', 'QuotationInfo', 'CurrentRole', function ($scope, $filter, Quotation, PurcInquiry, ngTableParams, toaster, BaseService, $rootScope, QuotationInfo, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $rootScope.enteryStatus = false;
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? Quotation : QuotationInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- PurcInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- bool = (i > 0 ? r.lapQty : 1) && r.price;
- });
- return bool;
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- Quotation.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/quotation/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- // Controller 主动报价 - 新增
- app.controller('SaleQuotationNewCtrl', ['$scope', '$stateParams', '$filter', 'ngTableParams', 'toaster', 'BaseService', '$modal', 'Quotation', 'VendorInfo', '$rootScope', 'CurrentRole', function ($scope, $stateParams, $filter, ngTableParams, toaster, BaseService, $modal, Quotation, VendorInfo, $rootScope, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var staticItem = null;
- if (!angular.isUndefined($stateParams.id)) {// 查看模式
- $scope.loading = true;
- $rootScope.enteryStatus = true;
- Quotation.getItem({id: $stateParams.id}, function (data) {
- // data.$editing = false;
- $scope.item = data;
- $scope.item.$editing = true; // 取消要点击修改才可以编辑的交互
- staticItem = angular.copy(data);
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- } else {// 新增模式
- $rootScope.enteryStatus = false;
- $scope.item = {
- quotation: {
- currency: 'RMB',
- taxrate: 17,
- },
- product: {},
- prices: [{lapQty: 0}],
- minOrderQty: 1,
- minPackQty: 1,
- $endDateOpen: false,
- $editing: true
- };
- }
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- //是否不能被点击
- $scope.isDisabled = function () {
- return $scope.item.quotation.status == 101 && $scope.item.agreed == null;
- }
- $scope.openDatePicker = function ($event, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.item.$endDateOpen = !openParam;
- };
- // 增加一个分段
- $scope.addPrice = function () {
- if ($scope.item.prices.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- $scope.item.prices.push({});
- };
- // 删除一个分段
- $scope.removePrice = function (index) {
- $scope.item.prices.splice(index, 1);
- };
- // 查找客户
- $scope.dbfindCust = function () {
- if ($scope.item.$editing) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/quotation_new_cust.html',
- controller: 'DbfindCustCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.item.quotation.cust = data.myEnterprise;
- $scope.item.quotation.custUser = data.myUser;
- $scope.item.product = null;
- }, function () {
- });
- }
- };
- // 赋值客户信息
- if ($rootScope.custuu) {
- VendorInfo.customerInfo({custuu: $rootScope.custuu}, {}, function (data) {
- $scope.item.quotation.cust = data.myEnterprise;
- $scope.item.quotation.custUser = data.myUser;
- })
- }
- // 赋值物料信息
- if ($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function (data) {
- $scope.item.product.code = data.code;
- $scope.item.product.title = data.title;
- $scope.item.product.spec = data.spec;
- $scope.item.product.unit = data.unit;
- $scope.item.product.id = data.id;
- }, function (response) {
- });
- }
- // 查找客户物料
- $scope.dbfindCustProd = function () {
- if ($scope.item.$editing) {
- if ($scope.item.quotation.cust) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/quotation_new_custProd.html',
- controller: 'DbfindCustProdCtrl',
- size: 'lg',
- resolve: {
- custUU: function () {
- return $scope.item.quotation.cust.uu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.item.product = data;
- }, function () {
- });
- } else {
- toaster.pop('error', '错误', '请先选择客户');
- }
- }
- };
- // 根据传入的询价相关的信息封装成报价需要的信息
- if ($stateParams.inquiryItem != null) {
- var item = $stateParams.inquiryItem;
- $scope.item.quotation.cust = item.inquiry.enterprise;
- $scope.item.quotation.custUser = item.inquiry.recorderUser;
- $scope.item.quotation.custUserUU = item.inquiry.recorderUU;
- if (item.product == null || item.product.id == null) {
- toaster.pop('info', '暂未匹配到物料信息,请手动选择');
- } else {
- $scope.item.product = item.product;
- if (item.replies.length > 0) {
- $scope.item.prices = item.replies;
- angular.forEach($scope.item.prices, function(price) {
- price.id = null;
- });
- }
- $scope.item.quotation.taxrate = item.taxrate;
- $scope.item.minPackQty = item.minPackQty;
- $scope.item.minOrderQty = item.minOrderQty;
- $scope.item.leadtime = item.leadtime;
- $scope.item.quotation.currency = item.currency;
- }
- }
- // 保存
- $scope.save = function () {
- var valid = true;
- angular.forEach($scope.item.prices, function(price, $index) {
- if ($index > 0 && price.lapQty <= $scope.item.prices[$index - 1].lapQty) {
- valid = false;
- }
- });
- if (!valid) {
- toaster.pop('info', '提示', '分段数量请保持递增!');
- } else {
- $scope.loading = true;
- if (!$scope.item.quotation.code) //新增,设单号
- $scope.item.quotation.code = 'BJ' + $filter('date')(new Date(), 'yyMMddHHmmss_sss');
- $scope.item.quotation.custUU = $scope.item.quotation.cust.uu;
- if ($scope.item.quotation.custUserUU == null) {
- $scope.item.quotation.custUserUU = $scope.item.quotation.custUser.userUU;
- }
- $scope.item.productId = $scope.item.product.id;
- Quotation.save({}, $scope.item, function (data) {
- $scope.loading = false;
- $scope.item = data;
- toaster.pop('success', '成功', '保存成功');
- if ($stateParams.id)
- window.location.reload();
- else
- window.location.hash = '#/sale/quotation/list';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- // 更新
- $scope.update = function () {
- $scope.item.$editing = true;
- };
- // 取消
- $scope.cancel = function () {
- $scope.item.$editing = false;
- $scope.item = angular.copy(staticItem);
- };
- // 提交
- $scope.submit = function () {
- var valid = true;
- angular.forEach($scope.item.prices, function(price, $index) {
- if ($index > 0 && price.lapQty <= $scope.item.prices[$index - 1].lapQty) {
- valid = false;
- }
- });
- if (!valid) {
- toaster.pop('info', '提示', '分段数量请保持递增!');
- } else {
- $scope.loading = true;
- if (!$scope.item.quotation.code) //新增,设单号
- $scope.item.quotation.code = 'BJ' + $filter('date')(new Date(), 'yyMMddHHmmss_sss');
- $scope.item.quotation.custUU = $scope.item.quotation.cust.uu;
- if ($scope.item.quotation.custUserUU == null) {
- $scope.item.quotation.custUserUU = $scope.item.quotation.custUser.userUU;
- }
- $scope.item.productId = $scope.item.product.id;
- // $scope.item.quotation.status = 101;//已提交
- if ($scope.item.quotation.date instanceof Date) {
- $scope.item.quotation.date = $scope.item.quotation.date.getTime();
- }
- if ($scope.item.quotation.endDate instanceof Date) {
- $scope.item.quotation.endDate = $scope.item.quotation.endDate.getTime();
- }
- Quotation.submit({}, $scope.item, function (data) {
- $scope.loading = false;
- $scope.item = data;
- toaster.pop('success', '成功', '提交成功');
- // window.location.hash = '#/sale/quotation/' + data.id;
- window.location.hash = '#/sale/quotation/list';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- };
- $scope.deleteById = function (id) {
- Quotation.deleteById({id: id}, {}, function (data) {
- window.location.href = "#/sale/quotation/list";
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- // 查找客户
- app.controller('DbfindCustCtrl', ['$scope', 'Customer', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', function ($scope, Customer, BaseService, ngTableParams, toaster, $modalInstance) {
- BaseService.scrollBackToTop();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Customer.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.check = function (cust) {
- $modalInstance.close(cust);
- };
- }]);
- // 查找客户物料
- app.controller('DbfindCustProdCtrl', ['$scope', 'Product', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'custUU', function ($scope, Product, BaseService, ngTableParams, toaster, $modalInstance, custUU) {
- BaseService.scrollBackToTop();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.custUU = custUU;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 选择
- $scope.check = function (cust) {
- $modalInstance.close(cust);
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 查找供应商
- app.controller('DbfindVendorCtrl', ['$scope', 'Vendor', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', '$rootScope', function ($scope, Vendor, BaseService, ngTableParams, toaster, $modalInstance, $rootScope) {
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [10, 25, 50, 100],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // 添加供应商时,将已存在的选中
- if ($rootScope.tenderVendor) {
- angular.forEach(page.content, function (vendor) {
- for (var i = 0; i < $rootScope.tenderVendor.length; i++) {
- vendor.checked = false;
- if (vendor.vendorEnterprise.enName == $rootScope.tenderVendor[i].enName) {
- vendor.checked = true;
- break;
- }
- }
- });
- }
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.checks = {
- checked: false
- };// 全选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (vendor) {
- vendor.checked = $scope.checks.checked;
- });
- };
- // 单选
- $scope.checkOne = function (vendor) {
- vendor.checked = true;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- // 单反选
- $scope.unCheckOne = function (vendor) {
- vendor.checked = false;
- $scope.checks.checked = false;
- };
- $scope.close = function () {
- var vendors = [];
- angular.forEach($scope.tableParams.data, function (vendor) {
- if (vendor.checked) {
- vendors.push(vendor);
- $modalInstance.close(vendors);
- }
- });
- };
- }]);
- // 发货提醒
- app.controller('SaleNoticeCtrl', ['$scope', '$rootScope', '$filter', 'PurcNotice', 'ngTableParams', 'toaster', 'BaseService', '$modal', 'SaleTruck', 'Symbol', '$state', '$timeout', 'PurcNoticeInfo', 'token', 'CurrentRole', function ($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, $modal, SaleTruck, Symbol, $state, $timeout, PurcNoticeInfo, token, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- // 用来记录已经选择的id
- $rootScope.ids = [];
- $scope.active = 'todo';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 6};
- $scope.searchStatus = false;
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 6);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- if ($scope.searchStatus) {
- return PurcNotice;
- }
- return PurcNoticeInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- $scope.checkall = true;
- angular.forEach(page.content, function (notice) {
- if ($rootScope.ids.indexOf(notice.id) > -1) {
- notice.$selected = true;
- } else {
- $scope.checkall = false;
- }
- });
- $scope.checkboxes = {
- checked: $scope.checkall
- };
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcNotice.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcNotice.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- PurcNotice.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcNotice.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- //生成随机单号
- $scope.autoCode = function (notice) {
- notice.send.code = $filter('date')(new Date(), 'yyMMddHHmmss-sss');
- };
-
- // 获取token信息 并打开询价模态框
- $scope.getToken = function() {
- token.info({userType: 'salenotice'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
-
- //可送货日期
- $scope.sendDate = function (notice) {
- var stock = notice.orderItem.product.ltinstock || 0;
- var de = new Date(notice.delivery);
- if (stock == -1) {
- de.setMonth(de.getMonth() - 1);
- de.setDate(26);
- } else if (stock >= 0) {
- de.setDate(de.getDate() - stock - 1);
- }
- return de;
- };
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function (notice) {
- if (!notice.send || !notice.send.qty || notice.send.qty > notice.qty - (notice.endQty || 0)) {
-
- } else if (!notice.send.code) {
-
- } else {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- };
- var isSumbit = false;
- $scope.onReplyClick = function (notice) {
- if (!notice.send || !notice.send.qty || notice.send.qty > notice.qty - (notice.endQty || 0)) {
- toaster.pop('warning', '警告', '数量填写错误!');
- } else if (!notice.send.code) {
- toaster.pop('warning', '警告', '请填写发货单号!');
- } else {
- if (!isSumbit) {
- var send = {
- code: notice.send.code,
- remark: notice.send.remark,
- sendItems: [{qty: notice.send.qty}]
- };
- $scope.loading = true;
- PurcNotice.save({id: notice.id, token: $scope.token}, send, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + notice.send.code);
- $state.go('sale.send_detail', {id: data.id});
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '发货失败', response.data);
- });
- isSumbit = true;
- return true;
- } else {
- toaster.pop('error', '提示', '为防止重复发货,请刷新页面后重新填写');
- return false;
- }
- }
- }
- $scope.checkboxes = {
- checked: false
- };
- angular.forEach($scope.tableParams.data, function (item) {
- $scope.checkboxes.checked = false;
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- $scope.checkboxes.checked = true;
- }
- });
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- if (!item.waiting) {
- item.$selected = $scope.checkboxes.checked;
- if(item.$selected) {
- if(!$rootScope.ids.in_array(item.id)) {
- $rootScope.ids.push(item.id);
- }
- } else {
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- }
- }
- }
- });
- };
- // 判断数组中是否存在某个对象
- Array.prototype.S = String.fromCharCode(2);
- Array.prototype.in_array = function(e) {
- var r = new RegExp(this.S + e + this.S);
- return (r.test(this.S + this.join(this.S) + this.S));
- }
- // 从数组中移除某个对象
- Array.prototype.remove = function(val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (order) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- if(order.$selected) {
- if(!$rootScope.ids.in_array(order.id)) {
- $rootScope.ids.push(order.id);
- }
- } else {
- if($rootScope.ids.in_array(order.id)) {
- $rootScope.ids.remove(order.id);
- }
- }
- $scope.checkboxes = {
- checked: result
- };
- };
- // 打开批量发货模态框
- var sendByBatch = function() {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sendByBatch.html',
- controller: 'SaleNoticeSendByBatchCtrl',
- size: 'lg',
- resolve: {
- selectedNotices: function () {
- return $scope.tableParams.data;
- },
- token: function() {
- return $scope.token;
- },
- ids: function() {
- return $rootScope.ids;
- }
- }
- });
- modalInstance.result.then(function () {
- $scope.tableParams.reload();
- }, function () {
- });
- }
- $scope.sendByBatch = function () {
- if($scope.token == null) {
- token.info({userType: 'salenotice'}, {}, function(data) {
- $scope.token = data.token;
- sendByBatch();
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- } else {
- sendByBatch();
- }
- };
- $scope.getSends = function (notice) {
- if (!notice.sends && notice.endQty > 0) {
- notice.getSendsing = true;
- notice.getSendsError = false;
- PurcNotice.getSends({id: notice.id}, function (data) {
- notice.getSendsing = false;
- notice.getSendsError = false;
- notice.sends = data;
- }, function (response) {
- notice.getSendsing = false;
- notice.getSendsError = true;
- notice.getErrorMessage = response.data;
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.searchStatus = true;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //货车功能
- var truck = $rootScope.truck;
- if (!truck) {
- SaleTruck.query({}, function (data) {
- $rootScope.truck = data;
- });
- }
- $scope.isInTruck = function (noticeId) {
- return truck.indexOf(noticeId) > -1;
- };
- $scope.addtoTruck = function (notice) {
- SaleTruck.save({noticeId: notice.id}, {}, function (data) {
- $rootScope.truck = data;
- });
- };
- $scope.delFromTruck = function (notice) {
- SaleTruck.remove({noticeId: notice.id}, {}, function (data) {
- $rootScope.truck = data;
- });
- };
- $scope.$watch(function () {
- return $rootScope.truck;
- }, function (data) {
- truck = $rootScope.truck;
- }, true);
- $scope.$watch(function () {
- return $rootScope.dataChanged;
- }, function (data) {
- data && ($scope.tableParams.reload());
- }, true);
- // 导出
- $scope.exportXls = function () {
- PurcNotice.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/notice/xls?_state='+$scope.active+
- '&keyword='+($scope.keywordXls || '')+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('SaleNoticeSendByBatchCtrl', ['$scope', '$modalInstance', 'Symbol', 'selectedNotices', 'PurcNotice', 'toaster', '$state', '$timeout', 'token', 'ids', '$rootScope', function ($scope, $modalInstance, Symbol, selectedNotices, PurcNotice, toaster, $state, $timeout, token, ids, $rootScope) {
- // $scope.notices = angular.copy(selectedNotices);
- PurcNotice.findByIds({ids : angular.toJson(ids)}, function(data) {
- $scope.notices = angular.copy(data);
- }, function(res) {
- toaster.pop('error', '提示', '发货提醒查询失败');
- });
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.saleSend = {
- code: '',
- payments: '',
- currency: '',
- custUU: null,
- custUserUU: null,
- remark: '批量发货',
- sendItems: []
- };
- // 计算总数、总额
- $scope.$watch(function () {
- return $scope.notices;
- }, function (data) {
- var q = 0, t = 0;
- if (data) {
- angular.forEach(data, function (d) {
- q += (d.thisSendQty || 0);
- t += (d.thisSendQty || 0) * (d.orderItem.price || 0);
- });
- }
- $scope.totalQty = q;
- $scope.total = t;
- }, true);
- /**
- * 删除一个已选中的送货提醒
- */
- $scope.removeOne = function (index) {
- $scope.notices.splice(index, 1);
- };
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function () {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- $scope.lockstatus = false;
- // 锁定时间按钮5秒
- $scope.lockClick = function (notice) {
- if ($scope.saleSend.code == '') {//送货单号为空
- return;
- } else {
- $scope.lockstatus = true;
- $timeout(function () {
- $scope.lockstatus = false;
- }, 5000);
- }
- };
- var isSumbit = false;
- //确认送货
- $scope.sendByBatch = function () {
- $scope.saleSend.sendItems = [];
- if ($scope.saleSend.code == '') {//送货单号为空
- toaster.pop('error', '错误', '请输入送货单号');
- return;
- }
- var a = 0;
- var num = 1;
- var valid = true;
- angular.forEach($scope.notices, function (item, key) {
- if (a == 0) {//第一次
- $scope.saleSend.currency = item.orderItem.order.currency;
- $scope.saleSend.custUU = item.enUU;
- $scope.saleSend.payments = item.orderItem.order.payments;
- a = 1;
- } else {//其他
- if ($scope.saleSend.currency != item.orderItem.order.currency) valid = false;
- if ($scope.saleSend.custUU != item.enUU) valid = false;
- if ($scope.saleSend.payments != item.orderItem.order.payments) valid = false;
- }
- $scope.saleSend.sendItems.push({
- noticeId: item.id, qty: item.thisSendQty, price: item.orderItem.price, number: num++
- });
- });
- if (!valid) {
- toaster.pop('error', '错误', '只有客户一致、币别一致、付款方式一致才能一起发货。');
- } else {
- if (!isSumbit) {
- PurcNotice.sendByBatch({token: token}, $scope.saleSend, function (data) {
- if(data.id) {
- toaster.pop('success', '提示', '发货成功,跳转至发货单:' + $scope.saleSend.code);
- $modalInstance.close('success');
- $state.go('sale.send_detail', {id: data.id});
- } else {
- toaster.pop('error', '提示', '发货失败,请刷新页面重试');
- }
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- isSumbit = true;
- return true;
- } else {
- toaster.pop('error', '提示', '为防止重复发货,请刷新页面后重新填写');
- return false;
- }
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 发货单
- */
- app.controller('SaleSendCtrl', ['$scope', '$filter', 'SaleSend', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'ReportService', function ($scope, $filter, SaleSend, ngTableParams, toaster, BaseService, Symbol, ReportService) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.currency = Symbol.currency;
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '半年内'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return SaleSend;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //打印 发货单
- $scope.print = function (send) {
- var newPage = window.open("about:blank");
- SaleSend.printPermission({}, function () {
- SaleSend.printCount({id: send.id}, {}); //增加打印此次
- ReportService.print(send.custUU, 'SALESEND', "where sale$send.ss_id=" + send.id, newPage);
- $scope.tableParams.reload();
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.exportXls = function () {
- SaleSend.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/notice/sends/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || '')+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 发货单(包括发货条码维护)
- */
- app.controller('SaleSendDetailCtrl', ['$scope', '$stateParams', 'SaleSend', 'toaster', 'ReportService', 'ngTableParams', 'Lodop', '$modal', 'CurrentRole', function ($scope, $stateParams, SaleSend, toaster, ReportService, ngTableParams, Lodop, $modal, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loading = true;
- $scope.checkBarCode = [];
- $scope.checkBoxCode = [];
- var vm = $scope.vm = {};
- $scope.getCheckedItems = {};
- vm.editBar = false;
- vm.showBarCode = [];
- $scope.barCode = function () {
- vm.editBar = !vm.editBar;
- }
- $scope.checkboxes = {
- checked: false
- };
- $scope.checkbars = {
- checked: false
- };
- // 点击勾选barCode全部的复选框
- $scope.checkBarAll = function () {
- angular.forEach($scope.checkBarCode, function (item, key) {
- $scope.checkBarCode[key] = $scope.checkbars.checked;
- });
- };
- //点击barCode单选
- $scope.checkBarOne = function () {
- var result = true;
- angular.forEach($scope.checkBarCode, function (item, key) {
- if (item != true) {
- result = false;
- return;
- }
- });
- $scope.checkbars.checked = result;
- }
- // 点击boxCode全部的复选框
- $scope.checkBoxAll = function () {
- angular.forEach($scope.checkBoxCode, function (item, key) {
- $scope.checkBoxCode[key] = $scope.checkboxes.checked;
- });
- };
- //点击boxCode单选
- $scope.checkBoxOne = function () {
- var result = true;
- angular.forEach($scope.checkBoxCode, function (item) {
- if (item != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- }
- /**
- * 生成条码和箱号
- */
- $scope.generateBarCode = function (item) {
- //获取勾选了生成条码的明细行,只勾选生成箱号的明细行不会生成条码和箱号
- $scope.getCheckedItems = [];
- var warningdata = '';
- angular.forEach($scope.checkBarCode, function (item, key) {
- $scope.getCheckedItem = {};
- if (item == true) {
- $scope.getCheckedItem.id = $scope.order.sendItems[key].id;
- $scope.getCheckedItem.isOutboxChecked = $scope.checkBoxCode[key];
- $scope.getCheckedItems.push($scope.getCheckedItem);
- //判断是否生成过条码
- if ($scope.order.sendItems[key].barSendNotify.length > 0) {
- warningdata += $scope.order.sendItems[key].number + ","
- }
- }
- });
- if ($scope.getCheckedItems.length == 0) {
- toaster.pop('warning', '提示', '请勾选需要生成条码的明细行!');
- return;
- }
- if (warningdata != '') {
- if (!confirm('明细行序号:' + warningdata + "已经生成了条码,继续生成将清空原有条码?")) {
- return;
- }
- }
- SaleSend.generateBarcodes({id: $scope.order.id}, angular.fromJson($scope.getCheckedItems), function (data) {
- toaster.pop('success', '提示', '生成成功!');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '生成失败', response.data);
- });
- }
- /**
- * 打印条码和箱号
- */
- $scope.printCode = function (type) {
- var LODOP = Lodop.getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
- //勾选需要打印的行
- $scope.getCheckedItems = [];
- var warningdata = ''
- angular.forEach($scope.checkBarCode, function (item, key) {
- $scope.getCheckedItem = {};
- if (item == true) {
- $scope.getCheckedItem.id = $scope.order.sendItems[key].id;
- $scope.getCheckedItems.push($scope.getCheckedItem);
- //判断是否生成过条码
- if ($scope.order.sendItems[key].barSendNotify.length > 0) {
- warningdata += $scope.order.sendItems[key].number + ","
- }
- }
- });
- if ($scope.getCheckedItems.length == 0) {
- toaster.pop('warning', '提示', '请勾选需要打印的明细行!');
- return;
- }
- if (warningdata == '') {
- toaster.pop('warning', '提示', '明细行序号:' + warningdata + '未生成条码无法打印');
- return;
- }
- //选择打印模板
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/bar_print_template.html',
- controller: 'BarPrintModalCtrl',
- resolve: {
- typeItem: function () {
- return {'type': type, 'id': $scope.order.id};
- }
- }
- });
- modalInstance.result.then(function (s) {
- if (s) {
- //获取打印数据
- SaleSend.getPrintBarcodes({lpsId: s.tp_id}, angular.fromJson($scope.getCheckedItems), function (data) {
- if (s.type == 'print') {//判断选择是打印还是打印预览
- lodopPrint(data.message, LODOP, type);
- } else if (s.type == 'printPreview') {
- lodopPrintPreview(data.message, LODOP, type);
- }
- }, function (response) {
- toaster.pop('error', '获取打印数据失败', response.data);
- });
- }
- });
- };
- //打印单个条码
- $scope.printSingleCode = function (id) {
- var LODOP = Lodop.getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
- //选择打印模板
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/sale/bar_print_template.html',
- controller: 'BarPrintModalCtrl',
- resolve: {
- typeItem: function () {
- return {'type': 'Bar', 'id': $scope.order.id};
- }
- }
- });
- modalInstance.result.then(function (s) {
- if (s) {
- //获取打印数据
- SaleSend.getSPrintBarcode({lpsId: s.tp_id, bsnId: id}, function (data) {
- if (s.type == 'print') {//判断选择是打印还是打印预览
- lodopSPrint(data.message, LODOP);
- } else if (s.type == 'printPreview') {
- lodopSPrintPreview(data.message, LODOP);
- }
- }, function (response) {
- toaster.pop('error', '获取打印数据失败', response.data);
- });
- }
- });
- }
- var lodopSPrint = function (printStore, LODOP) {//单个条码打印
- var selectOrNot = LODOP.SELECT_PRINTER();//选择打印机,未-1就是取消,如果是其他数字就是设置打印机序号
- if (selectOrNot != -1) {
- LODOP.PRINT_INIT("标签打印");//设定纸张大小
- var pagesize = printStore[0]['LA_PAGESIZE'];//获取标签的大小
- var strs = pagesize.split("*"); //字符分割
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- angular.forEach(printStore, function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- //“ShowBarText” :(一维)条码的码值是否显示 0/1
- //“AlignJustify”:设置“text文本”是否两端对齐或“barcode条码文字”靠齐方式
- //设置“barcode条码文字”时,0-两端对齐(默认) 1-左靠齐 2-居中 3-右靠齐
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- LODOP.SET_PRINT_STYLEA(0, "NotOnlyHighPrecision", true);//设置打印的精度
- LODOP.PRINT();
- }
- };
- var lodopSPrintPreview = function (printStore, LODOP) {//单个条码打印预览
- LODOP.PRINT_INIT("标签打印");//设定纸张大小
- var pagesize = printStore[0]['LA_PAGESIZE'];//获取标签的大小
- var strs = pagesize.split("*"); //字符分割
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- angular.forEach(printStore, function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, "");
- LODOP.SET_SHOW_MODE("HIDE_SBUTTIN_PREVIEW", 1);
- LODOP.PREVIEW();//打印预览
- };
- var lodopPrint = function (printStore, LODOP, type) {//勾选发货单明细进行打印
- var selectOrNot = LODOP.SELECT_PRINTER();//选择打印机,未-1就是取消,如果是其他数字就是设置打印机序号
- if (selectOrNot != -1) {
- LODOP.PRINT_INIT("标签打印");//设定纸张大小
- var pagesize = printStore[0]['pagesize'];//获取标签的大小
- var strs = new Array(); //定义一数组
- strs = pagesize.split("*"); //字符分割
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- var ids = new Array();
- angular.forEach(printStore, function (value, key) {
- //LODOP.NewPage();
- angular.forEach(value['data'], function (record, key) {
- angular.forEach(record['store'], function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- //“ShowBarText” :(一维)条码的码值是否显示 0/1
- //“AlignJustify”:设置“text文本”是否两端对齐或“barcode条码文字”靠齐方式
- //设置“barcode条码文字”时,0-两端对齐(默认) 1-左靠齐 2-居中 3-右靠齐
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- });
- var o = new Object();
- o['id'] = record['si_id']
- ids.push(o);
- LODOP.SET_PRINT_STYLEA(0, "NotOnlyHighPrecision", true);//设置打印的精度
- LODOP.PRINT();
- });
- //如果打印的是条码则更新打印状态,如果是箱号则不不要打印
- if (type == 'Bar') {
- //更新打印状态
- SaleSend.updatePrintStatus({}, ids, function (data) {
- }, function (res) {
- });
- }
- }
- };
- var lodopPrintPreview = function (printData, LODOP, type) {//打印预览
- var ids = new Array();
- angular.forEach(printData, function (record, index) {
- angular.forEach(record['data'], function (value, index) {
- LODOP.NewPage();
- angular.forEach(value['store'], function (data, index) {
- LODOP.SET_PRINT_STYLE("FontSize", data['LP_SIZE']);
- if (data['LP_VALUETYPE'] == 'barcode') {
- LODOP.ADD_PRINT_BARCODE(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['LP_ENCODE'], data['value']);
- LODOP.SET_PRINT_STYLEA(0, "ShowBarText", data['LP_IFSHOWNOTE']);
- LODOP.SET_PRINT_STYLEA(0, "AlignJustify", data['LP_NOTEALIGNJUSTIFY']);
- } else if (data['LP_VALUETYPE'] == 'text') {
- LODOP.SET_PRINT_STYLE("FontName", data['LP_FONT']);
- LODOP.ADD_PRINT_TEXT(data['LP_TOPRATE'] + "mm", data['LP_LEFTRATE'] + "mm", data['LP_WIDTH'] + "mm", data['LP_HEIGHT'] + "mm", data['value']);
- }
- });
- });
- var o = new Object();
- o['id'] = record['si_id']
- ids.push(o);
- });
- var pagesize = printData[0]['pagesize'];//获取标签的大小
- var strs = new Array(); //定义一数组
- strs = pagesize.split("*"); //字符分割
- LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, "");
- LODOP.SET_SHOW_MODE("HIDE_SBUTTIN_PREVIEW", 1);
- LODOP.SET_PRINT_PAGESIZE(1, strs[0] * 10, strs[1] * 10, "");
- var times = LODOP.PREVIEW();//打印预览
- if (times > 0) {//点击了打印预览内的打印按钮
- //如果打印的是条码则更新打印状态,如果是箱号则不不要打印
- if (type == 'Bar') {
- //更新打印状态
- SaleSend.updatePrintStatus({}, ids, function (data) {
- loadData();
- }, function (res) {
- });
- }
- }
- };
- /**
- * 查看条码按钮
- */
- $scope.showBarCode = function (number) {
- $scope.keys = number;
- for (var i = 0; i < vm.showBarCode.length; i++) {
- if (i != number) {
- vm.showBarCode[i] = false;
- }
- }
- vm.showBarCode[number] = !vm.showBarCode[number];
- $scope.barcodes = [];
- $scope.barcodes = $scope.order.sendItems[number].barSendNotify;
- var getPage = function (page, size) {
- if ($scope.barcodes) {
- var result = {};
- result.totalCount = $scope.barcodes.length;
- result.content = $scope.barcodes.slice((page - 1) * size, page * size);
- if ($scope.barcodes.length % size == 0) {
- result.totalPage = ($scope.barcodes.length - $scope.barcodes.length % size) / size;
- } else {
- result.totalPage = ($scope.barcodes.length - $scope.barcodes.length % size) / size + 1;
- }
- result.first = page == 1;
- result.last = page == result.totalPage;
- result.page = page;
- result.next = page - 0 + 1;
- result.pre = page - 1;
- return result;
- }
- }
- $scope.barData = getPage(1, 5);
- $scope.first = function () {
- $scope.barData = getPage($scope.barData.pre, 5);
- }
- $scope.last = function () {
- $scope.barData = getPage($scope.barData.next, 5);
- }
- };
- /**
- * 更新外箱号
- */
- $scope.updateOutBox = function (item, number) {
- if ($scope.oldoutBoxQty[number] == item.outBoxQty) {
- } else {
- if (item.outBoxQty > 0) {
- if (!(item.outBoxQty % item.packageQty)) {
- SaleSend.update({id: item.id}, item, function () {
- toaster.pop('success', '提示', '保存成功!');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- })
- } else {
- toaster.pop('warning', '提示', '请输入最小包数的整数倍!(' + item.packageQty + '的整数倍)');
- }
- } else {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- }
- }
- loadData();
- };
- /**
- * 更新最小包数
- */
- $scope.updatePackage = function (item, number) {
- if (item.packageQty == $scope.oldpackageQty[number]) {
- } else {
- if (item.orderItem.product.minPack != 0) {
- if (item.packageQty > 0 && item.packageQty <= item.qty) {
- if (!(item.packageQty % item.orderItem.product.minPack)) {
- SaleSend.update({id: item.id}, item, function () {
- toaster.pop('success', '提示', '保存成功!');
- if (item.outBoxQty && item.outBoxQty % item.packageQty) {
- toaster.pop('warning', '提示', '外箱容量必须是最小包数的整数倍,请及时修改(' + item.packageQty + '的整数倍)');
- }
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- })
- } else {
- toaster.pop('warning', '提示', '请输入最小物料包装的整数倍!(' + item.orderItem.product.minPack + '的整数倍)');
- }
- } else {
- toaster.pop('warning', '提示', '请填写有效的数量!');
- }
- } else {
- if (item.packageQty > 0 && item.packageQty <= item.qty) {
- SaleSend.update({id: item.id}, item, function () {
- toaster.pop('success', '提示', '保存成功!');
- if (item.outBoxQty && item.outBoxQty % item.packageQty) {
- toaster.pop('warning', '提示', '外箱容量必须是最小包数的整数倍,请及时修改(' + item.packageQty + '的整数倍)');
- }
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- })
- } else {
- toaster.pop('warning', '提示', '请填写有效的数量!');
- }
- }
- }
- loadData();
- };
- var loadData = function () {
- SaleSend.getItem({id: $stateParams.id}, function (data) {
- $scope.order = data;
- var orderCount = $scope.order.sendItems.length;
- $scope.oldpackageQty = [];
- $scope.oldoutBoxQty = [];
- var sum = 0;
- vm.oldpackageQty = [];
- angular.forEach(data.sendItems, function (value, key) {
- //给showBarCode数组赋初值
- if (vm.showBarCode.length < orderCount) {
- vm.showBarCode.push(false);
- }
- if ($scope.checkBarCode.length < orderCount) {
- $scope.checkBarCode.push(false);
- }
- if ($scope.checkBoxCode.length < orderCount) {
- $scope.checkBoxCode.push(false);
- }
- //给个初值
- if (!value.packageQty) {
- value.packageQty = value.orderItem.product.minPack;
- }
- $scope.oldpackageQty.push(value.packageQty);
- if (value.outBoxQty) {
- $scope.oldoutBoxQty.push(value.outBoxQty);
- }
- sum += value.price * value.qty;
- });
- data.total = sum;
- $scope.loading = false;
- }, function (response) {
- loading = false;
- toaster.pop('error', '获取数据失败', response.data);
- });
- };
- loadData();
- }]);
- app.controller('BarPrintModalCtrl', ['$scope', 'typeItem', 'SaleSend', 'toaster', '$modalInstance', function ($scope, typeItem, SaleSend, toaster, $modalInstance) {
- $scope.typeItem = typeItem;
- $scope.template = [];
- $scope.choose = {};
- //获取打印模板
- SaleSend.getPrintTemplate({id: $scope.typeItem.id, type: $scope.typeItem.type}, function (data) {
- if (data.message) {
- $scope.template = data.message;
- $scope.choose.tp_id = $scope.template[0].id;
- }
- }, function (res) {
- toaster.pop('error', '获取模板错误', res.data);
- });
- $scope.print = function () {
- $scope.choose.type = 'print';
- $modalInstance.close($scope.choose);
- };
- $scope.printPreview = function () {
- $scope.choose.type = 'printPreview';
- $modalInstance.close($scope.choose);
- }
- $scope.cancel = function () {
- $modalInstance.close();
- }
- }]);
- app.controller('SaleSampleDetailCtrl', ['$scope', '$stateParams', 'PurcSample', 'toaster', '$modal', 'BaseService', 'CurrentRole', function ($scope, $stateParams, PurcSample, toaster, $modal, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loading = true;
- var loadData = function () {
- PurcSample.getItem({id: $stateParams.id}, function (data) {
- $scope.sample = data;
- if (!$scope.sample.sends) {
- $scope.sample.getSendInfo = '加载中...';
- PurcSample.getSend({id: $stateParams.id}, function (sendData) {
- if (sendData) {
- $scope.sample.getSendInfo = null;
- $scope.sample.sends = sendData;
- } else {
- $scope.sample.getSendInfo = '无送样信息';
- $scope.sample.sends = '无送样信息';
- }
- }, function (response) {
- $scope.sample.getSendInfo = '加载失败!';
- toaster.pop('error', '', response.data);
- });
- }
- $scope.loading = false;
- }, function (response) {
- loading = false;
- toaster.pop('error', '获取数据失败', response.data);
- });
- };
- loadData();
- $scope.openSend = function (index, sample) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sample_send.html',
- controller: 'SampleSendCtrl',
- resolve: {
- sampleItem: function () {
- return sample;
- }
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('info', '提示', '送样成功');
- $scope.tableParams.reload();
- }, function () {
- });
- };
- }]);
- /**
- * 客户打样申请
- */
- app.controller('SaleSampleCtrl', ['$scope', '$filter', 'PurcSample', 'ngTableParams', 'toaster', '$modal', 'BaseService', 'ReportService', 'Symbol', '$rootScope', 'PurcSampleInfo', 'CurrentRole', function ($scope, $filter, PurcSample, ngTableParams, toaster, $modal, BaseService, ReportService, Symbol, $rootScope, PurcSampleInfo, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /*初始化筛选时间*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcSample : PurcSampleInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- proofingDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- getUnreadCount();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcSample.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单个单据已读
- $scope.setOrdersRead = function (id) {
- if (!$scope.isUnread(id)) {
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcSample.setRead({}, sourceId, function (message) {
- getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcSample.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.openSend = function (index, sample) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/sample_send.html',
- controller: 'SampleSendCtrl',
- resolve: {
- sampleItem: function () {
- return sample;
- }
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('info', '提示', '送样成功');
- $scope.tableParams.reload();
- }, function () {
- });
- };
- //打印 样品采购单
- $scope.print = function (sample) {
- var newPage = window.open("about:blank");
- PurcSample.printPermission({}, function () {
- PurcSample.printCount({id: sample.id}, {});//增加打印此次
- ReportService.print(sample.proofing.enUU, 'PURCPROOFING', "where purc$proofingitems.ppi_id =" + sample.id, newPage);
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- $scope.getSend = function (proofing) {
- if (!proofing.sends) {
- proofing.getSendInfo = '加载中...';
- PurcSample.getSend({id: proofing.id}, function (data) {
- if (data) {
- proofing.getSendInfo = null;
- proofing.sends = data;
- } else {
- proofing.getSendInfo = '无送样信息';
- proofing.sends = '无送样信息';
- }
- }, function (response) {
- proofing.getSendInfo = '加载失败!';
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcSample.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/sample/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('SampleSendCtrl', ['$scope', '$modalInstance', 'sampleItem', 'PurcSample', '$upload', 'toaster', function ($scope, $modalInstance, sampleItem, PurcSample, $upload, toaster) {
- if (!sampleItem.sends) {
- PurcSample.getSend({id: sampleItem.id}, function (data) {
- if (data) {
- sampleItem.sends = data; // 获取送样信息
- angular.forEach(data, function (send) {
- sampleItem.sendQty = send.sendQty + (sampleItem.sendQty || 0);
- });
- }
- }, function (response) {
- });
- }
- $scope.sampleItem = sampleItem;
- $scope.sampleItem.sampleSend = $scope.sampleItem.sampleSend || {};
- //确认送样
- $scope.ok = function (form) {
- $scope.loading = true;
- // 多次送样时,由于ng-model是sendQty,所以需要加上送样历史中的数量
- $scope.sampleItem.sampleSend.sendQty = $scope.sampleItem.sampleSend.sendQty + ($scope.sampleItem.sendQty || 0);
- $scope.sampleItem.sendQty = $scope.sampleItem.sampleSend.sendQty; // 判断是否需要多次送样
- var files = form.attachFile.$viewValue, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'sale/sample/' + $scope.sampleItem.id + '/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.sampleItem.sampleSend
- }
- }).success(function (data) {
- $scope.loading = false;
- $modalInstance.close('success');
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '错误', data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss(sampleItem);
- };
- //设置单个单据已读
- $scope.setOrdersRead = function (id) {
- var sourceId = [];
- sourceId.push(id);
- PurcSample.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- });
- };
- }]);
- /**
- * 客户认定单
- */
- app.controller('SaleApprovalCtrl', ['$scope', '$filter', 'PurcApproval', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, PurcApproval, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcApproval;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- inDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcApproval.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/sample/approval/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户采购预测
- */
- app.controller('SaleForecastCtrl', ['$scope', '$filter', 'PurcForecast', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, PurcForecast, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcForecast;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- orderDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 客户采购验收
- */
- app.controller('SaleAcceptCtrl', ['$scope', '$filter', 'PurcAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcAccept, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcAccept;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcAccept.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/accept/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户采购验收详情
- */
- app.controller('SaleAcceptDetailCtrl', ['$scope', 'PurcAccept', 'toaster', 'BaseService', '$stateParams', 'CurrentRole', function ($scope, PurcAccept, toaster, BaseService, $stateParams, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($stateParams.id) {
- PurcAccept.getDetail({id: $stateParams.id}, {}, function (data) {
- $scope.accept = data;
- if ($scope.accept.acceptItems != null) {
- var sum = 0;
- angular.forEach($scope.accept.acceptItems, function (item) {
- if (item.orderPrice == null) {
- item.orderPrice = 0;
- }
- sum += item.orderPrice * item.qty;
- });
- $scope.totalPrice = sum;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 客户采购验退
- */
- app.controller('SaleReturnsCtrl', ['$scope', '$filter', 'PurcReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcReturn, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcReturn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- angular.forEach(page.content, function (data) {
- if (!data.returnItems[0].orderItem) {
- PurcReturn.getEnterpriseName({id: data.id, enuu: data.enUU}, function (enterprise) {
- data.enName = enterprise.enName;
- });
- }
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcReturn.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/return/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户采购验退详情
- */
- app.controller('SaleReturnsDetailCtrl', ['$scope', 'PurcReturn', 'toaster', 'BaseService', '$stateParams', 'CurrentRole', function ($scope, PurcReturn, toaster, BaseService, $stateParams, CurrentRole) {
- BaseService.scrollBackToTop();'' +
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($stateParams.id != null) {
- PurcReturn.getDetail({id: $stateParams.id}, {}, function (data) {
- $scope.returns = data;
- if ($scope.returns.returnItems != null) {
- var sum = 0;
- angular.forEach($scope.returns.returnItems, function (item) {
- if (null != item.orderPrice) {
- sum += item.orderPrice * item.qty;
- }
- });
- $scope.totalPrice = sum;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 客户不良品入库
- */
- app.controller('SaleBadInCtrl', ['$scope', '$filter', 'PurcBadIn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcBadIn, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcBadIn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcBadIn.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/badIn/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户不良品出库
- */
- app.controller('SaleBadOutCtrl', ['$scope', '$filter', 'PurcBadOut', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, PurcBadOut, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcBadOut;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcBadOut.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/badOut/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户MRB
- */
- app.controller('SaleMRBCtrl', ['$scope', '$filter', 'PurcMRB', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, PurcMRB, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return PurcMRB;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- PurcMRB.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/MRB/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户应付发票
- */
- app.controller('SaleApBillCtrl', ['$scope', '$filter', 'FaApBill', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, FaApBill, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return FaApBill;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- FaApBill.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/apBill/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户应付发票详情
- */
- app.controller('SaleApBillDetailCtrl', ['$scope', '$filter', 'FaApBill', 'toaster', '$stateParams', 'BaseService', 'CurrentRole', function ($scope, $filter, FaApBill, toaster, $stateParams, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- FaApBill.getAll({id: $stateParams.id}, function (data) {
- $scope.bill = data;
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData(); // 初始获取单据数据
- }]);
- /**
- * 应付对账单
- */
- app.controller('SaleArCheckCtrl', ['$scope', '$filter', 'FaArCheck', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', function ($scope, $filter, FaArCheck, ngTableParams, toaster, BaseService, Symbol) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return FaArCheck;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 计算单据的商品总数
- $scope.getTotalProd = function (check) {
- var total = 0;
- if (check.items) {
- angular.forEach(check.items, function (value) {
- total += value.qty;
- });
- }
- return total;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- // 应付对账单详情页
- app.controller('SaleArCheckDetailCtrl', ['$scope', '$stateParams', 'FaArCheck', 'toaster', '$state', 'BaseService', function ($scope, $stateParams, FaArCheck, toaster, $state, BaseService) {
- BaseService.scrollBackToTop();
- var loadData = function () {
- FaArCheck.get({id: $stateParams.id}, function (data) {
- $scope.order = data;
- $scope.loading = false;
- });
- };
- loadData(); // 初始获取单据数据
- $scope.onReplyClick = function (item, isAgreed) {
- if (isAgreed) {// 同意确认
- FaArCheck.agree({itemId: item.id}, {}, function (data) {
- toaster.pop('success', '确认成功', '确认供应商对账数量成功');
- }, function (response) {
- toaster.pop('danger', '确认失败', response.data);
- });
- } else {// 不同意回复
- FaArCheck.disagree({itemId: item.id}, {
- qty: item.$replyQty,
- remark: item.$replyRemark
- }, function (data) {
- toaster.pop('success', '确认成功', '您提交的数量将发送给供应商确认');
- }, function (response) {
- toaster.pop('danger', '确认失败', response.data);
- });
- }
- };
- // 获取明细的回复记录
- $scope.getReplies = function (item) {
- if (!item.replies) {
- FaArCheck.getReplies({itemId: item.id}, function (data) {
- item.replies = data;
- }, function (response) {
- toaster.pop('danger', '获取对账记录失败', response.data);
- });
- }
- };
- }]);
- //应收对账单列表
- app.controller('PurchaseApCheckCtrl', ['$scope', 'FaApCheck', 'BaseService', 'ngTableParams', 'toaster', 'ReportService', 'Symbol', 'CurrentRole', function ($scope, FaApCheck, BaseService, ngTableParams, toaster, ReportService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'todo';
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- //打印 对账单
- $scope.print = function (check) {
- var newPage = window.open("about:blank");
- FaApCheck.printPermission({}, function () {
- FaApCheck.printCount({id: check.id}, {});//增加打印此次
- ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id, newPage);
- }, function (response) {
- newPage.close();
- toaster.pop('error', '打印失败', response.data);
- });
- };
- //状态
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //获取应收对账单全部
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- recordDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- FaApCheck[getState($scope.active)](BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.data = $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- FaApCheck.getUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- FaApCheck.setRead({}, sourceId, function (message) {
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- FaApCheck.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (id){
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 计算单据的商品总数
- $scope.getTotalProd = function (check) {
- var total = 0;
- if (check.items) {
- angular.forEach(check.items, function (value) {
- total += value.checkQty;
- });
- }
- return total;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- FaApCheck.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'sale/apCheck/xls/list?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- //应收对账单详情
- app.controller('PurchaseApCheckDetailCtrl', ['$scope', 'toaster', 'FaApCheck', '$stateParams', 'BaseService', 'CurrentRole', function ($scope, toaster, FaApCheck, $stateParams, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.haveSelected = true;
- $scope.data = {};
- //控制提交和删除按钮的显示
- $scope.ifShow = true;
- var loadData = function () {
- FaApCheck.getItem({id: $stateParams.id}, function (data) {
- $scope.data = data;
- if ($scope.data.status) {
- } else {
- $scope.ifShow = true;
- }
- }, function (response) {
- toaster.pop('error', '', response.data);
- })
- };
- if ($stateParams.id) {
- loadData();
- }
- $scope.haveSource = false;
- //提交应收对账单
- $scope.submitApCheck = function () {
- FaApCheck.updateStatus({id: $stateParams.id}, {}, function (data) {
- if (data.result) {
- toaster.pop('success', '提示', '提交成功');
- $scope.haveSelected = false;
- window.location.href = '#/fa/apCheck';
- } else {
- $scope.haveSource = true;
- loadData();
- toaster.pop('error', '提示', '单据被反过账,请立即作废本单据');
- $scope.haveSelected = true;
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '更新已转数失败', response.data);
- });
- }
- //删除应收对账单的同时更新来源表已转数
- var updateYCheckQty = function () {
- var sourceInfos = [];
- angular.forEach($scope.data.items, function (item) {
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newYCheckQty: ''
- };
- $scope.sourceInfo.sourceId = item.sourceId;
- $scope.sourceInfo.sourceTable = item.sourceTable;
- $scope.sourceInfo.newYCheckQty = item.oldYCheckQty;
- sourceInfos.push($scope.sourceInfo);
- });
- FaApCheck.update({}, sourceInfos, function () {
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '更新已转数失败', response.data);
- });
- }
- //删除应收对账单
- $scope.deleteApCheck = function () {
- FaApCheck.deleteApCheck({id: $stateParams.id}, {}, function (data) {
- updateYCheckQty();
- toaster.pop('success', '提示', '删除成功');
- }, function (response) {
- toaster.pop('error', '删除失败', response.data);
- });
- $scope.haveSelected = false;
- }
- //作废应收对账单
- $scope.cancelApCheck = function (check) {
- FaApCheck.cancel({id: check.id}, {}, function (data) {
- $scope.checkResult = false;
- if (data.result) {
- $scope.checkResult = true;
- toaster.pop('success', '提示', '作废成功');
- $scope.tableParams.reload();
- } else {
- toaster.pop('error', '提示', '作废失败');
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '作废失败', response.data);
- });
- }
- }]);
- //未对账单据列表
- app.controller('PurchaseApCheckListCtrl', ['$scope', 'FaApCheck', 'toaster', '$state', '$filter', '$modal', 'Vendor', 'DecimalNumber', function ($scope, FaApCheck, toaster, $state, $filter, $modal, Vendor, DecimalNumber) {
- $scope.data = [];// 列表数据
- $scope.condition = {
- $fromOpened: false
- }
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
- // 客户联想词
- $scope.getSimilarCustomers = function (value) {
- if (value) {
- return Vendor.getSimilarCustomers({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateCustomerClick = function (vendor) {
- if (vendor.apcheck == 0) {
- toaster.pop('info', '提示', '该客户暂未启用平台对账功能');
- $scope.suuorname = '';
- } else {
- $scope.suuorname = vendor.custName;
- }
- }
- //查找客户
- $scope.searchCust = function (suuorname) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/fa/apcheck_customer.html',
- controller: 'SearchCustInfoCtrl',
- size: 'lg',
- resolve: {
- suuorname: function () {
- return suuorname;
- }
- }
- });
- modalInstance.result.then(function (customer) {
- $scope.suuorname = customer.myEnterprise.enName;
- });
- }
- // 点击筛选根据条件选择数据
- // 默认本月
- $scope.sdateTo = new Date();
- $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodtitle = '';
- $scope.condition.prodspec = '';
- $scope.searchOrder = function (check) {
- $scope.data = [];
- $scope.checkboxes.checked = false;
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory
- $scope.condition.prodtitle = $scope.prodtitle;
- $scope.condition.prodspec = $scope.prodspec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if ($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf()) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- if ($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
- $scope.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.searchKeyWord = {
- receiveName: $scope.receiveName,
- factory: $scope.factory,
- prodTitle: $scope.prodTitle,
- prodSpec: $scope.prodSpec,
- taxRate: $scope.taxRate,
- suuorname: $scope.suuorname
- }
- $scope.exportKeywords = encodeURIComponent($scope.searchKeyWord);
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if (!$scope.suuorname) {
- toaster.pop('warning', '提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- $scope.loading = true;
- FaApCheck.getAllByKeywords({
- fromDate: $scope.fromDate,
- endDate: $scope.endDate,
- receiveName: $scope.receiveName,
- factory: $scope.factory,
- prodTitle: $scope.prodTitle,
- prodSpec: $scope.prodSpec,
- taxRate: $scope.taxRate,
- suuorname: $scope.suuorname
- }, function (data) {
- if (data.length > 0) {
- angular.forEach(data, function (item) {
- item.$selected = true;
- });
- $scope.data = data;
- $scope.checkboxes.checked = true;
- $scope.getTotalMoney();
- } else {
- toaster.pop('info', '提示', '当前没有需要对账记录');
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- }
- $scope.exportApcheckList = function() {
- var url = 'sale/apCheck/xls?fromDate=' + $scope.fromDate + '&endDate=' + $scope.endDate;
- if (angular.isDefined($scope.receiveName)) {
- url = url + '&receiveName=' + $scope.receiveName;
- }
- if (angular.isDefined($scope.factory)) {
- url = url + '&factory=' + $scope.factory;
- }
- if (angular.isDefined($scope.prodTitle)) {
- url = url + '&prodTitle=' + $scope.prodTitle;
- }
- if (angular.isDefined($scope.prodSpec)) {
- url = url + '&prodSpec=' + $scope.prodSpec;
- }
- if (angular.isDefined($scope.suuorname)) {
- url = url + '&suuorname=' + $scope.suuorname;
- }
- if (angular.isDefined($scope.taxRate)) {
- url = url + '&receiveName=' + $scope.taxRate;
- }
- window.location.href = url;
- }
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.totalMoney = 0;
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- $scope.totalMoney = 0;
- $scope.filteredData = $filter('filter')($scope.data, $scope.condition.prodtitle || $scope.condition.uuorname || $scope.condition.venduuorname || $scope.condition.prodspec || $scope.condition.factory);
- var dateFrom = $scope.condition.dateFrom;
- var dateTo = $scope.condition.dateTo;
- angular.forEach($scope.filteredData, function (item) {
- if ((item.pidate >= dateFrom || dateFrom == '') && (item.pidate < dateTo || dateTo == '')) {
- item.$selected = $scope.checkboxes.checked;
- }
- });
- $scope.getTotalMoney();
- };
- //获取已选单据总金额
- $scope.getTotalMoney = function () {
- $scope.totalMoney = 0;
- angular.forEach($scope.data, function (check) {
- if (check.$selected) {
- var price = DecimalNumber.accMul((check.thischeckqty || 0), (check.orderprice || 0));
- $scope.totalMoney += Math.round(price * 100) / 100;
- } else {
- $scope.totalMoney += 0;
- }
- });
- }
- // 点击其中一个明细的复选框
- $scope.checkOne = function (check) {
- var result = true;
- angular.forEach($scope.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.haveSelected = false;
- //生成应收对账单
- $scope.createApCheck = function () {
- //保存应收对账单主记录字段
- $scope.apCheck = {
- custUu: '',
- custName: '',
- enUu: '',
- apDate: '',
- beginDate: '',
- endDate: '',
- checkStatus: '未对账',
- checkAmount: 0,
- currency: '',
- rate: '',
- items: [],
- taxrate: ''
- };
- //保存来源单据相关信息
- var sourceInfos = [];
- //所允许的本次对账最大最小数量
- $scope.data.maxThisCheckQty = 0;
- $scope.data.minThisCheckQty = 0;
- $scope.sameCust = true;
- $scope.validQty = true;
- $scope.loading = true;
- angular.forEach($scope.data, function (check) {
- //保存应收对账单明细行数据
- $scope.item = {
- inoutno: '',
- inoutnodetno: '',
- orderCode: '',
- orderClass: '',
- orderDetno: '',
- price: '',
- checkQty: '',
- amount: '',
- sourceId: '',
- sourceTable: '',
- oldYCheckQty: '',
- status: 0,
- receiveCode: '',
- receiveName: '',
- prodCode: '',
- prodTitle: '',
- prodUnit: '',
- prodSpec: '',
- taxrate: '',
- sendcode: '',
- whname: '',
- custUserUU: ''
- };
- //应收对账单明细行来源表信息
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newYCheckQty: ''
- };
- //此次对账后新的已转数
- $scope.newYCheckQty = 0;
- if (check.$selected == true) {
- $scope.apCheck.custName = check.custname;
- $scope.apCheck.enUu = check.enuu;
- $scope.apCheck.checkAmount += (check.thischeckqty || 0) * (check.orderprice || 0);
- $scope.apCheck.apDate = check.pidate;
- $scope.apCheck.rate = check.rate;
- //必须是同一家客户才能生成对账单,否则提示错误
- if ($scope.apCheck.custUu == '') {
- $scope.apCheck.custUu = check.custuu;
- } else if ($scope.apCheck.custUu !== check.custuu) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一家客户');
- }
- //必须是相同币别才能生成对账单,否则提示错误
- if ($scope.apCheck.currency == '') {
- $scope.apCheck.currency = check.currency;
- } else if ($scope.apCheck.currency !== check.currency) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一种币别');
- }
- //必须是相同税率才能生成对账单,否则提示错误
- if (!angular.isNumber($scope.apCheck.taxrate)) {
- $scope.apCheck.taxrate = check.taxrate;
- } else if ($scope.apCheck.taxrate != check.taxrate) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择相同的税率');
- }
- //本次对账数量必须小于总对账数量
- if (check.qty > 0) {
- $scope.data.maxThisCheckQty = check.qty;
- $scope.data.minThisCheckQty = 0;
- if (check.qty - (check.ycheckqty || 0) < check.thischeckqty || check.thischeckqty < 0 || check.thischeckqty == 0) {
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error', '本次对账数量,填写有误!');
- }
- } else if (check.qty < 0) {
- $scope.data.maxThisCheckQty = 0;
- $scope.data.minThisCheckQty = check.qty;
- if (((-check.qty) - (-check.ycheckqty) < (-check.thischeckqty)) || check.thischeckqty > 0 || check.thischeckqty == 0) {
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error', '本次对账数量,填写有误!');
- }
- }
- //获取筛选时间的开始时间为对账的开始时间
- $scope.apCheck.beginDate = $scope.fromDate;
- //获取筛选的截止时间为对账的截止时间
- $scope.apCheck.endDate = $scope.endDate;
- //应收对账单明细行数据
- $scope.item.orderCode = check.ordercode;
- $scope.item.orderClass = check.piclass;
- $scope.item.orderDetno = check.orderdetno;
- $scope.item.price = check.orderprice;
- $scope.item.checkQty = check.thischeckqty;
- $scope.item.amount = (check.thischeckqty || 0) * (check.orderprice || 0);
- $scope.item.sourceId = check.sourceid;
- $scope.item.sourceTable = check.sourcetable;
- $scope.item.oldYCheckQty = check.ycheckqty;
- $scope.item.prodCode = check.prodcode;
- $scope.item.prodTitle = check.prodtitle;
- $scope.item.prodSpec = check.prodspec;
- $scope.item.prodUnit = check.produnit;
- $scope.item.inoutno = check.inoutno;
- $scope.item.inoutnodetno = check.detno;
- $scope.item.taxrate = check.taxrate;
- $scope.item.receiveCode = check.receivecode;
- $scope.item.receiveName = check.receivename;
- $scope.item.sendcode = check.sendcode;
- $scope.item.whname = check.whname;
- $scope.item.custUserUU = check.custuseruu;
- //来源表相关信息
- $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 () {
- if ($scope.apCheck.items.length == 0) {
- $scope.loading = false;
- toaster.pop('error', '请先选择需要对账的数据');
- } else {
- FaApCheck.saveApCheck({}, $scope.apCheck, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '生成应收对账成功');
- $state.go('fa.apCheck_detail', {id: data.id}, {reload: true});
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '生成对账单失败', response.data);
- })
- }
- };
- //如果是同一家客户,生成对账单的同时,关闭模态框
- if ($scope.sameCust && $scope.validQty) {
- $scope.saveApCheck();
- }
- }
- }]);
- // 企业信息设置
- app.controller('EnterpriseCtrl', ['$scope', 'AccountEnterprise', 'toaster', '$state', '$modal', 'BaseService', 'ShipAddress', '$http', 'DeputyOrder', function ($scope, AccountEnterprise, toaster, $state, $modal, BaseService, ShipAddress, $http, DeputyOrder) {
- BaseService.scrollBackToTop();
- $scope.loading = true;
- AccountEnterprise.get({}, function (data) {
- $scope.loading = false;
- $scope.enterprise = data;
- if (data.tags) {
- $scope.tags = data.tags.split(','); // 将逗号分隔的标签字符串转换成数组,便于操作
- } else {
- $scope.tags = [];
- }
- // 获取付款企业信息
- DeputyOrder.paycompanies({enuu: $scope.enterprise.uu}, {}, function (data) {
- $scope.pays = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- // 更新企业信息
- $scope.updateDetailInfo = function () {
- $scope.loading = true;
- $scope.enterprise = $scope.copyEnterprise;
- $scope.enterprise.tags = $scope.tags.join(','); // 将标签数组转换成逗号分隔的字符串,便于储存
- AccountEnterprise.save($scope.enterprise, function () {
- $scope.loading = false;
- $scope.connectionEditing = false;
- toaster.pop('success', '提示', '修改企业信息成功');
- $state.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '修改信息失败', response.data);
- });
- };
- // 申请Saas
- $scope.applySaas = function () {
- if ($scope.enterprise.enUrl && $scope.enterprise.enAddress && $scope.enterprise.enIndustry) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/applySaas.html',
- controller: 'ApplySaasCtrl',
- resolve: {
- enterprise: function () {
- return angular.copy($scope.enterprise);
- }
- }
- });
- modalInstance.result.then(function () {
- $state.reload();
- }, function () {
- });
- } else {
- toaster.pop('info', '请完善信息', '申请优企云服请先完善企业详细信息');
- }
- };
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- });
- // 判断是否是代采企业
- DeputyOrder.isDeputyEnterprise({}, function (data) {
- $scope.deputyEnter = data;
- });
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- });
- toaster.pop('success', '提示', data.success);
- $scope.ship = {receiver: null, usertel: null, phone: null, email: null, province: null, city: null, district: null, addressdet: null, addalias: null, address: null};
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- // 删除收货地址
- $scope.removeShip = function (id, index) {
- ShipAddress.removeShipAddress({id: id}, {}, function (data) {
- $scope.ships.splice(index, 1);
- toaster.pop('success', '提示', '收货地址删除成功');
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 编辑收货地址
- $scope.editShip = function (ship) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/shipaddress_modal.html',
- controller: 'ShipAddressCtrl',
- resolve: {
- ship: function () {
- return ship;
- }
- }
- });
- modalInstance.result.then(function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- });
- }, function () {
- });
- };
- // 新增付款企业
- $scope.addPayCompany = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/paycompany_modal.html',
- controller: 'PayCompanyCtrl',
- resolve: {
- pay: function () {
- return null;
- }
- }
- });
- modalInstance.result.then(function () {
- DeputyOrder.paycompanies({enuu: uu}, {}, function (data) {
- $scope.pays = data;
- // 获取付款企业信息
- DeputyOrder.paycompanies({enuu: $scope.enterprise.uu}, {}, function (data) {
- $scope.pays = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function () {
- });
- }
- // 删除付款企业
- $scope.removePay = function (id, index) {
- DeputyOrder.removePayCompany({id: id}, {}, function (data) {
- $scope.pays.splice(index, 1);
- toaster.pop('success', '提示', '付款企业信息删除成功');
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 编辑付款企业
- $scope.editPay = function (pay, uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/paycompany_modal.html',
- controller: 'PayCompanyCtrl',
- resolve: {
- pay: function () {
- return pay;
- }
- }
- });
- modalInstance.result.then(function () {
- DeputyOrder.paycompanies({enuu: uu}, {}, function (data) {
- $scope.pays = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }, function () {
- });
- };
- // 设置logo
- $scope.showImageDialog = function (modal) {
- require(['jquery-uploadify'], function () {
- $modal.open({
- templateUrl: 'static/tpl/index/home/insert.html',
- controller: 'ImageInsertCtrl',
- backdrop: 'static'
- }).result.then(function (image) {
- $scope.imageUrl = image.thumb;
- User.postImageUrl(null, angular.toJson($scope.imageUrl), function (data) {
- $scope.user = data;
- }, function (response) {
- toaster.pop('error', '设置图像失败,' + response.data);
- });
- });
- });
- }
- // 添加经营范围标签
- $scope.addTag = function () {
- if ($scope.tags.indexOf($scope.tag) == -1){
- if (null != $scope.tag && '' != $scope.tag) {
- $scope.tags.push($scope.tag);
- }
- }
- $scope.tag = '';
- }
- // 移除经营范围标签
- $scope.removeTag = function (tag) {
- removeByValue($scope.tags, tag);
- }
- // 获取行业信息
- $http.get('static/data/profession.json').success(function (data) {
- $scope.list = data;
- });
- // 选择行业
- $scope.profession = new Array();
- $scope.showProfession = false;
- $scope.selectProfession = function () {
- $scope.professionArray = [];
- $scope.active = [];
- $scope.showProfession = !$scope.showProfession;
- $scope.profession[0] = $scope.list;
- }
- $scope.isInList = false;
- $scope.isInInput = false;
- $scope.hideList = function () {
- if (!$scope.isInList && !$scope.isInInput && $scope.showProfession) {
- $scope.showProfession = false;
- }
- }
- // 行业子菜单点击
- $scope.onItemClick = function (key, index, value) {
- $scope.active[index] = key;
- if (angular.isString(value)){ // 值为字符串说明点击的是最后一级
- $scope.copyEnterprise.profession = value;
- $scope.showProfession = false;
- return;
- }
- $scope.professionArray = [];
- $scope.profession.splice(index+1);
- if (angular.isArray(value)){ // 值为数组说明下一级是最后一级
- $scope.professionArray = value;
- } else if (angular.isObject(value)) {
- $scope.profession[index+1] = value;
- }
- }
- // 判断值是否为字符串
- $scope.isString = function (value) {
- return angular.isString(value);
- }
- // 拷贝企业数据,在编辑企业数据是使用拷贝数据
- $scope.copyData = function () {
- $scope.copyEnterprise = angular.copy($scope.enterprise);
- if ($scope.enterprise.tags) {
- $scope.tags = $scope.enterprise.tags.split(','); // 将逗号分隔的标签字符串转换成数组,便于操作
- } else {
- $scope.tags = [];
- }
- }
- }]);
- // 编辑收货地址
- app.controller('ShipAddressCtrl', ['$scope', 'ShipAddress', 'ship', '$modalInstance', 'toaster', '$http', function ($scope, ShipAddress, ship, $modalInstance, toaster, $http) {
- $scope.ship = ship;
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $modalInstance.close();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- // 编辑付款企业信息
- app.controller('PayCompanyCtrl', ['$scope', 'DeputyOrder', 'pay', '$modalInstance', 'toaster', '$http', function ($scope, DeputyOrder, pay, $modalInstance, toaster, $http) {
- $scope.pay = pay;
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.savePayCompany = function (pay) {
- pay.address = pay.province + pay.city + pay.district + pay.addressdet;
- DeputyOrder.savePaycompany({}, pay, function (data) {
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.dismiss();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- // 申请Saas Controller
- app.controller('ApplySaasCtrl', ['$scope', '$modalInstance', 'enterprise', 'AccountEnterprise', 'toaster', '$http', function ($scope, $modalInstance, enterprise, AccountEnterprise, toaster, $http) {
- $scope.enterprise = enterprise;
- $scope.checking = false;
- $scope.$watch('enterprise.enSaasUrl', function () {
- if ($scope.enterprise.enSaasUrl) {
- $http.get('signup/saasUrlEnable', {
- params: {
- enSaasUrl: $scope.enterprise.enSaasUrl
- }
- }).success(function (data) {
- if (data && data == 'true') {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', true);
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '优企云服域名已被使用';
- }
- }).error(function () {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- $scope.enSaasUrlErrorInfo = '验证出错';
- });
- } else {
- $scope.applySaasForm.enSaasUrl.$setValidity('available', false);
- }
- });
- var setSaasUrl = function (url) {
- var index = url.indexOf('www.');
- if (index != -1) {//包含www.
- var substr = url.substring(index + 4, url.length);
- $scope.enterprise.enSaasUrl = substr.substring(0, substr.indexOf('.'));
- } else {
- $scope.enterprise.enSaasUrl = getHost(url);
- }
- };
- // 解析获取网址的一级域名
- var getHost = function (host) {
- var newhost;
- var domain;
- var ArrDomain = new Array('.com.cn', '.net.cn', '.org.cn', '.gov.cn', '.com', '.cn', '.tel', '.mobi', '.net', '.org', '.asia', '.me', '.cc', '.name', '.info');//枚举所有后缀
- for (var k in ArrDomain) {
- var re = eval('/\\' + ArrDomain[k] + '$/g');
- newhost = host.replace(re, '');
- if (newhost != host) {
- domain = ArrDomain[k];
- break;
- }
- }
- var hostar = newhost.split('.');
- var s = hostar[hostar.length - 1];
- return s;
- };
- // 设置优企云服域名为官网网址一级域名
- if ($scope.enterprise.enUrl) setSaasUrl($scope.enterprise.enUrl);
- $scope.apply = function () {
- $scope.loading = true;
- AccountEnterprise.applySaas({
- enUU: $scope.enterprise.uu,
- enSaasUrl: $scope.enterprise.enSaasUrl,
- enAdminPassword: $scope.enterprise.enAdminPassword
- }, {}, function () {
- $scope.loading = false;
- toaster.pop('success', '申请成功', '已提交系统开通优企云服,开通后将会发送邮件至管理员邮箱');
- $modalInstance.close();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '申请失败', response.data);
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- app.controller('UserCtrl', ['$scope', '$filter', 'AuthenticationService', 'AccountUser', 'BaseService', 'ngTableParams', 'toaster', '$modal', '$http', 'ngAlert', 'AccountEnterprise', 'CurrentRole', function ($scope, $filter, AuthenticationService, AccountUser, BaseService, ngTableParams, toaster, $modal, $http, ngAlert, AccountEnterprise, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.editing = false;
- $scope.loading = true;
- $scope.enterprise = null;
- $scope.searchMthod = false;
- $scope.keyword = null;
- AccountUser.findDistribute({}, function (data) {
- $scope.distributes = data;
- }, function (response) {
- toaster.pop('error', '系统错误', response.data);
- });
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- var users = [];
- var getMangagerInfo = function() {
- CurrentRole.isManager({}, function(data) {
- $scope.isManager = data.isManager || $scope.user.sys;
- });
- CurrentRole.roles({}, function(data) {
- $scope.roles = data.count || $scope.user.sys;
- });
- };
- getMangagerInfo();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- userName: 'asc'
- }
- }, {
- total: 0,
- counts: [15, 25, 50, 100],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- AccountUser.getAll.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- users = page.content;
- if(users.length > 0) {
- if(users.length > 0) {
- angular.forEach(users, function (user) { // 从验证中获取到的用户信息,不包含身份证号。在这里赋值
- if (user.userTel === $scope.user.userTel && user.userUU === $scope.user.userUU) {
- $scope.user.userIdcode = user.userIdcode;
- }
- });
- }
- }
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
-
- $scope.onSearch = function(keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.reload();
- $scope.tableParams.page(1);
- }
- $scope.saveUser = function () {
- $scope.loading = true;
- AccountUser.update({}, $scope.user, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '修改用户信息成功');
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- });
- loadUsers();
- $scope.editing = false;
- }, function (reponse) {
- $scope.loading = false;
- toaster.pop('error', '失败', reponse.data);
- });
- };
- $scope.updatePassword = function () {
- var newPage = window.open("about:black");
- AccountUser.getUpdatePasswordUrl({returnUrl: window.location.href}, function (data) {
- newPage.location.href = data.url;
- });
- };
- $scope.updateDetail = function () {
- var newPage = window.open("about:black");
- AccountUser.getCloudCenterUrl({}, function (data) {
- newPage.location.href = data.url;
- });
- }
- $scope.newUser = {};
- //弹出添加用户模态框
- $scope.addExistUser = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/addExistUser.html',
- controller: 'AddExistUserCtrl'
- });
- modalInstance.result.then(function () {
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- $scope.tableParams.reload();
- }, function () {
- });
- };
- /**
- * 添加未注册用户
- */
- $scope.submit = false;
- $scope.addUser = function () {
- $scope.submit = true;
- $scope.adding = true;
- $scope.loading = true;
- AccountUser.save({}, $scope.newUser, function (data) {
- $scope.loading = false;
- $scope.submit = false;
- toaster.pop('success', '提示', '增加用户成功:' + $scope.newUser.userName);
- $scope.newUser = {userSex: 'M'};
- $scope.tableParams.reload();
- $scope.adding = false;
- $scope.newUserForm.newUserTel.$setValidity('available', false);
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- $scope.userEmailSuccess = false;
- $scope.userEmailError = false;
- }, function (response) {
- $scope.submit = false;
- $scope.loading = false;
- toaster.pop('error', '错误', response.data);
- });
- };
- /**
- * 验证手机号是否可用
- */
- $scope.telValid = function (tel) {
- if (tel) {
- $http.get('account/user/telEnable', {
- params: {
- tel: tel
- }
- }).success(function (data) {
- data = eval(data);
- if (data == true) {
- $scope.newUserForm.newUserTel.$setValidity('available', true);
- $scope.userTelSuccess = true;
- $scope.userTelError = false;
- } else {
- $scope.newUserForm.newUserTel.$setValidity('available', false);
- $scope.userTelError = true;
- $scope.userTelSuccess = false;
- if (tel.length == 11)
- toaster.pop('error', '错误', '手机号 ' + tel + ' 已被注册');
- }
- }).error(function () {
- $scope.userTelSuccess = false;
- $scope.userTelError = true;
- });
- } else {
- $scope.userTelSuccess = false;
- $scope.userTelError = false;
- }
- };
- /**
- * 验证邮箱是否可用
- */
- $scope.emailValid = function (email) {
- if (email) {
- $http.get('account/user/emailEnable', {
- params: {
- email: email
- }
- }).success(function (data) {
- data = eval(data);
- if (data == true) {
- $scope.newUserForm.newUserEmail.$setValidity('available', true);
- $scope.userEmailSuccess = true;
- $scope.userEmailError = false;
- } else {
- $scope.newUserForm.newUserEmail.$setValidity('available', false);
- $scope.userEmailError = true;
- $scope.userEmailSuccess = false;
- }
- }).error(function () {
- $scope.userEmailError = true;
- $scope.userEmailSuccess = false;
- });
- } else {
- $scope.userEmailError = false;
- $scope.userEmailSuccess = false;
- }
- };
- /**
- * 删除用户
- */
- $scope.removeUser = function (user) {
- new ngAlert({
- title: '提示',
- content: '确定删除用户(' + user.userName + ')吗?'
- }, function () {
- AccountUser.remove({uu: user.userUU}, function () {
- toaster.pop('success', '提示', '用户删除成功。');
- loadUsers();
- }, function (response) {
- toaster.pop('error', '删除失败', response.data);
- });
- });
- };
- // 编辑用户的角色
- $scope.editUserRole = function (user) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/user_role.html',
- controller: 'UserRoleCtrl',
- resolve: {
- user: function () {
- return user;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- };
- // 为用户分配角色(删除企业)
- $scope.removeVendor = function (user) {
- var resultRole = true;
- angular.forEach(user.roles, function (role) {
- if (role.issys == 1 || role.name == 'ROLE_SALEMANAGER') {
- toaster.pop('error', '提示', '管理员和销售经理无需分配客户');
- resultRole = false;
- return;
- }
- });
- if (resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/remove_vendor.html',
- controller: 'RemoveVendorCtrl',
- resolve: {
- user: function () {
- return user;
- }
- }
- });
- }
- };
- // 为用户分配角色(添加企业)
- $scope.addVendor = function (user, isIssy) {
- if (!$scope.roles) {
- toaster.pop('error', '提示', '你不是管理员或销售经理,无权限分配!请立即联系管理员');
- return;
- }
- var resultRole = true;
- angular.forEach(user.roles, function (role) {
- if (role.issys == 1 || role.name == 'ROLE_SALEMANAGER') {
- toaster.pop('error', '提示', '管理员和销售经理无需分配客户');
- resultRole = false;
- return;
- }
- })
- if (resultRole) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/account/add_vendor.html',
- controller: 'AddVendorCtrl',
- resolve: {
- user: function () {
- return user;
- }
- }
- });
- modalInstance.result.then(function (changed, checked) {
- if (changed) {
- if (checked)
- $scope.newUser.roles = checked;
- else
- loadUsers();
- }
- });
- }
- };
- }]);
- // 登录手机号码验证
- app.controller('CheckTelCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'AuthenticationService', 'SendCheckMsg', 'SessionService', '$timeout', function ($scope, $modalInstance, user, AccountUser, AuthenticationService, SendCheckMsg, SessionService, $timeout) {
- $scope.user = user;
- $scope.cancel = function () {
- $modalInstance.close();
- }
- }]);
- app.controller('RemoveVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountUser, toaster) {
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- AccountUser.findChooseVendor({uu: user.userUU}, function (data) {
- $scope.enters = data;
- $scope.loading = false;
- angular.forEach($scope.enters, function (item) {
- item:{
- $selected:true;
- }
- });
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.enters, function (item) {
- item.$selected = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (vendor) {
- var result = true;
- angular.forEach($scope.enters, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (user.userUU) {
- angular.forEach($scope.enters, function (item, i) {
- if (item.$selected) {
- chooseResult.push(item.id);
- }
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.removeChooseVendor({uu: user.userUU}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '删除成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '删除失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '删除失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- app.controller('AddVendorCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountUser, toaster) {
- $scope.checkboxes = {
- checked: false
- };
- $scope.loading = true;
- AccountUser.findVendor({uu: user.userUU}, function (data) {
- $scope.enters = data;
- $scope.loading = false;
- })
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.enters, function (item) {
- item.distribute = $scope.checkboxes.checked;
- });
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (vendor) {
- var result = true;
- angular.forEach($scope.enters, function (item) {
- if (item.distribute != true) {
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.close = function (save) {
- var chooseResult = [];
- if (save) {
- if (user.userUU) {
- angular.forEach($scope.enters, function (item, i) {
- chooseResult.push(item);
- });
- if (chooseResult.length > 0) {
- $scope.loading = true;
- AccountUser.addVendor({uu: user.userUU}, chooseResult, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(false);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- $modalInstance.close(false);
- })
- } else {
- toaster.pop('error', '保存失败', "您未勾选任何记录");
- }
- } else {
- $modalInstance.close(true, $scope.checkboxes.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- app.controller('UserRoleCtrl', ['$scope', '$modalInstance', 'user', 'AccountRole', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountRole, AccountUser, toaster) {
- $scope.checked = [];
- $scope.master = [];
- AccountRole.query({}, function (data) {
- if (user && data) {
- var rs = [], checked = [];
- angular.forEach(user.roles, function (r) {
- rs.push(r.id);
- });
- angular.forEach(data, function (d) {
- if (rs.indexOf(d.id) > -1) {
- d.$checked = true;
- checked.push(d);
- }
- });
- }
- $scope.roles = data;
- $scope.checked = checked;
- $scope.master = angular.copy($scope.checked);
- });
- $scope.select = function (role) {
- role.$checked = !role.$checked;
- if (role.$checked) {
- if (role.desc === '管理员' || role.desc === '普通用户') {
- $scope.checked = [];
- angular.forEach($scope.roles, function (r) {
- r.$checked = false;
- });
- role.$checked = true;
- $scope.checked.push(role);
- } else {
- angular.forEach( $scope.checked, function (r, i) {
- if (r.desc === '管理员' || r.desc === '普通用户') {
- $scope.checked.splice(i, 1);
- }
- });
- angular.forEach($scope.roles, function (r) {
- if (r.desc === '管理员' || r.desc === '普通用户') {
- r.$checked = false;
- }
- });
- $scope.checked.push(role);
- }
- } else {
- angular.forEach($scope.checked, function (c, i) {
- if (c.id == role.id)
- $scope.checked.splice(i, 1);
- });
- }
- };
- $scope.isChanged = function () {
- return !angular.equals($scope.master, $scope.checked);
- };
- $scope.close = function (save) {
- if (save) {
- if (user.userUU) {
- user.roles = $scope.checked;
- AccountUser.updateRole({}, user, function () {
- toaster.pop('success', '提示', '保存成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '保存失败', response.data);
- });
- } else {
- $modalInstance.close(true, $scope.checked);
- }
- } else {
- $modalInstance.close(false);
- }
- };
- }]);
- // 修改密码Controller
- app.controller('PasswordCtrl', ['$scope', '$modalInstance', 'user', 'AccountUser', 'toaster', function ($scope, $modalInstance, user, AccountUser, toaster) {
- $scope.user = user;
- $scope.checking = false;
- //输入原密码后验证原密码是否正确
- $scope.checkPassword = function (password) {
- $scope.checking = true;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- AccountUser.checkPassword({password: password}, function (data) {
- $scope.checkSuccess = true;
- $scope.checking = false;
- $scope.checkFailed = false;
- }, function (response) {
- $scope.checkFailed = true;
- $scope.checking = false;
- $scope.checkSuccess = false;
- });
- };
- //修改密码
- $scope.ok = function () {
- if ($scope.user.newPassword == $scope.user.newPassword1) {//验证重复密码相等
- AccountUser.updatePassword({
- password: $scope.user.password,
- newPassword: $scope.user.newPassword
- }, {}, function (data) {
- var tip = '修改成功,请牢记您的新密码:' + $scope.user.newPassword;
- toaster.pop('success', '成功', tip);
- $scope.user.password = null;
- $scope.user.newPassword = null;
- $scope.user.newPassword1 = null;
- $scope.checking = false;
- $scope.checkSuccess = false;
- $scope.checkFailed = false;
- $modalInstance.close();
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- } else {
- toaster.pop('error', '错误', '重复密码不一致');
- }
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- /*
- * 绑定用户到企业
- */
- app.controller('AddExistUserCtrl', ['$scope', '$modalInstance', 'FuzzySearch', 'AuthenticationService', '$timeout', 'toaster', function ($scope, $modalInstance, FuzzySearch, AuthenticationService, $timeout, toaster) {
- $scope.searching = false;
- //根据输入的内容查找用户
- $scope.searchUser = function (keyWord) {
- $scope.searching = true;
- $scope.searchSuccess = false;
- $scope.searchFailed = false;
- $scope.illegalError = false;
- $scope.reBindError = false;
- $scope.okDisabled = false;
- FuzzySearch.searchUser({keyWord: keyWord}, function (data) {
- $scope.searchSuccess = true;
- $scope.searchFailed = false;
- $scope.user = data; //查询到的用户
- }, function (response) {
- $scope.searchSuccess = false;
- $scope.searchFailed = true;
- });
- };
- //确认绑定
- $scope.ok = function (keyWord) {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.currentUser = data; //当前登录的用户(管理员)
- //不可自己绑定自己
- if ($scope.currentUser.userUU == $scope.user.userUU) {
- $scope.illegalError = true;
- $scope.okDisabled = true;
- return false;
- }
- //用户未绑定到任何企业时
- if (!$scope.user.enterprises) {
- //正常绑定
- FuzzySearch.bindUserToMyEnterprise({userUU: $scope.user.userUU}, function (data) {
- $scope.okDisabled = true;
- toaster.pop("success", "提示", "用户绑定成功");
- $modalInstance.close(true);
- }, function (response) {
- });
- return true;
- }
- //用户已绑定到某些企业时
- for (var i = 0; i < $scope.currentUser.enterprises.length; i++) {
- if ($scope.currentUser.enterprises[i].current) {
- for (var j = 0; j < $scope.user.enterprises.length; j++) {
- //该用户已绑定到当前企业,不可重复绑定
- if ($scope.currentUser.enterprises[i].uu == $scope.user.enterprises[j].uu) {
- $scope.reBindError = true;
- $scope.okDisabled = true;
- return false;
- }
- }
- //该用户未绑定到当前企业,可以进行绑定
- FuzzySearch.bindUserToMyEnterprise({userUU: $scope.user.userUU}, function (data) {
- $scope.okDisabled = true;
- toaster.pop("success", "提示", "用户绑定成功");
- $modalInstance.close(true);
- }, function (response) {
- console.log("绑定失败!");
- });
- }
- }
- });
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- app.controller('LogCtrl', ['$scope', 'BaseService', 'ngTableParams', 'ErpLog', 'UsageLog', function ($scope, BaseService, ngTableParams, ErpLog, UsageLog) {
- $scope.erpParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- time: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- ErpLog.get(BaseService.parseParams(params.url()), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.usageParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- time: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- UsageLog.get(BaseService.parseParams(params.url()), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- }]);
- app.controller('ResourceCtrl', ['$scope', 'AccountResource', function ($scope, AccountResource) {
- AccountResource.query({}, function (data) {
- if (data && data.length > 0) {
- data[0].$open = true;
- }
- $scope.resources = data;
- });
- }]);
- app.controller('RoleCtrl', ['$scope', '$modal', 'AccountRole', function ($scope, $modal, AccountRole) {
- $scope.roles = {};
- var getData = function () {
- AccountRole.query({}, function (data) {
- var defaults = [], custom = [];
- angular.forEach(data, function (d) {
- if (d.isdefault == 1)
- defaults.push(d);
- else
- custom.push(d);
- });
- $scope.roles = {defaults: defaults, custom: custom};
- });
- };
- getData();
- $scope.editRole = function (role) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/approvalFlow/role_detail.html',
- controller: 'RoleEditCtrl',
- resolve: {
- role: function () {
- return role;
- }
- }
- });
- modalInstance.result.then(function (added) {
- added && (getData());
- });
- };
- }]);
- app.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'ngAlert', 'BaseService', 'CurrentRole', 'AuthenticationService', function ($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, ngAlert, BaseService, CurrentRole, AuthenticationService) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为管理员
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- CurrentRole.isManager({}, {}, function (data) {
- $scope.isManager = data.isManager || $scope.user.sys;
- });
- $scope.role = role;
- $scope.master = angular.copy($scope.role);
- var isNew = role == null;
- $scope.cancel = function () {
- $modalInstance.close(false);
- };
- AccountResource.query({}, function (data) {
- if (data && data.length > 0) {
- if (role && role.resourceItems) {
- var rs = [];// 已分配的资源的id
- angular.forEach(role.resourceItems, function (item) {
- rs.push(item.id);
- });
- angular.forEach(data, function (resource) {
- var c = 0;
- angular.forEach(resource.items, function (item) {
- if (rs.indexOf(item.id) > -1) {
- item.$checked = true;
- c += 1;
- }
- });
- resource.$checked = c == resource.items.length;
- });
- }
- $scope.resourceItems = data[0].items;
- data[0].$active = true;
- }
- $scope.resources = data;
- $timeout(function () {
- angular.forEach($scope.resources, function (resource) {
- var c = 0;
- angular.forEach(resource.items, function (item) {
- item.$checked && (c += 1);
- });
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- });
- }, 100);
- });
- $scope.onItemClick = function (resource) {
- $scope.resourceItems = resource.items;
- angular.forEach($scope.resources, function (r) {
- r.$active = false;
- });
- resource.$active = true;
- };
- var getChecked = function () {
- var items = [];
- angular.forEach($scope.resources, function (resource) {
- angular.forEach(resource.items, function (item) {
- item.$checked && (items.push(item));
- });
- });
- $scope.role.resourceItems = items;
- };
- $scope.onResourceChange = function (resource) {
- angular.forEach(resource.items, function (item) {
- item.$checked = resource.$checked;
- });
- getChecked();
- };
- $scope.onItemChange = function () {
- angular.forEach($scope.resources, function (resource) {
- if (resource.$active) {
- var c = 0;
- angular.forEach(resource.items, function (item) {
- item.$checked && (c += 1);
- });
- resource.$checked = (c == resource.items.length);
- angular.element(document.getElementById('check_' + resource.id)).prop('indeterminate', (c > 0 && !resource.$checked));
- }
- });
- getChecked();
- };
- $scope.isChanged = function (formData) {
- if (!$scope.master)
- return true;
- return !angular.equals(formData, $scope.master);
- };
- $scope.save = function () {
- $scope.master = angular.copy($scope.role);
- AccountRole.save($scope.master, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 资料' + (isNew ? '添加' : '修改') + '成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- };
- $scope.del = function () {
- new ngAlert({
- title: '提示',
- content: '确定删除角色(' + $scope.role.desc + ')吗?'
- }, function () {
- AccountRole.remove({id: role.id}, {}, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- })
- };
- $scope.updateDefault = function () {
- new ngAlert({
- title: '提示',
- content: '确定把(' + $scope.role.desc + ')信息更新到标准库吗?'
- }, function () {
- AccountRole.updateDefault({desc: $scope.role.desc}, $scope.role.resourceItems, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 更新成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- })
- }
- $scope.recover = function () {
- new ngAlert({
- title: '提示',
- content: '确定将“' + $scope.role.desc + '”恢复默认权限吗?'
- }, function () {
- AccountRole.recover({roleId: role.id}, {}, function () {
- toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 恢复默认权限成功');
- $modalInstance.close(true);
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- })
- };
- }]);
- /**
- * 委外订单
- */
- app.controller('MakeOrderCtrl', ['$scope', '$filter', 'MakeOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'CurrentRole',
- function ($scope, $filter, MakeOrder, ngTableParams, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'todo';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeOrder;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- MakeOrder.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- MakeOrder.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- $scope.setOrdersReadByState = function () {
- if (!$scope.unread.replied || $scope.unread.replied == 0) {
- return;
- }
- MakeOrder.setReadByState({}, function () {
- getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- MakeOrder.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getOrderTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 打开回复
- $scope.openReply = function (order) {
- if (!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (order) {
- order.$editing = false;
- }
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 点击回复
- $scope.onReplyClick = function (order, inverse) {
- if (order.reply) {
- if (!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOrder.reply({orderId: order.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- //委外加工单
- $scope.print = function (order) {
- MakeOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$orders.ma_id=' + order.id);
- };
- // 获取回复记录
- $scope.getReply = function (order) {
- if (!order.replies) {
- MakeOrder.getReply({orderId: order.id}, function (replies) {
- order.replies = replies;
- });
- }
- };
- // 导出
- $scope.exportXls = function () {
- MakeOrder.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/orders/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 委外加工单详细
- */
- app.controller('MakeOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOrder', 'toaster', 'ReportService', 'BaseService', 'CurrentRole', function ($scope, $stateParams, MakeOrder, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- MakeOrder.getItem({id: $stateParams.id}, function (data) {
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- // 获取回复记录
- $scope.getReply = function (item) {
- if (!item.replies) {
- MakeOrder.getReply({orderId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 点击回复
- $scope.onReplyClick = function (order, inverse) {
- if (order.reply) {
- if (!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOrder.reply({orderId: order.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 打开回复
- $scope.openReply = function (order) {
- if (!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (order) {
- order.$editing = false;
- }
- // 委外订单
- $scope.print = function (order) {
- MakeOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$orders.ma_id =' + order.id);
- };
- }]);
- /**
- * 客户委外验收
- */
- app.controller('MakeAcceptCtrl', ['$scope', '$filter', 'MakeAccept', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, MakeAccept, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeAccept;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy(pageParams.searchFilter.fromDate);//保存当前取值的关键词
- $scope.endDateXls = angular.copy(pageParams.searchFilter.endDate);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeAccept.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/accept/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 客户委外验退
- */
- app.controller('MakeReturnCtrl', ['$scope', '$filter', 'MakeReturn', 'ngTableParams', 'toaster', 'BaseService', 'Symbol', 'CurrentRole', function ($scope, $filter, MakeReturn, ngTableParams, toaster, BaseService, Symbol, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeReturn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter.keyword);//保存当前取值的关键词
- $scope.fromDateXls = angular.copy(pageParams.searchFilter.fromDate);//保存当前取值的关键词
- $scope.endDateXls = angular.copy(pageParams.searchFilter.endDate);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeReturn.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/return/xls?_state='+$scope.active+'&keyword='+($scope.keywordXls || "")+'&fromDate='+$scope.fromDateXls+'&endDate='+$scope.endDateXls;
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 委外加工变更
- */
- app.controller('MakeChangeCtrl', ['$scope', '$filter', 'MakeChange', 'ngTableParams', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $filter, MakeChange, ngTableParams, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeChange;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- orderChangeDate: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 打开回复
- $scope.openReply = function (change) {
- change.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (change) {
- change.$editing = false;
- }
- // 确定回复
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- MakeChange.reply({itemId: change.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeChange.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/changes/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- app.controller('MakeChangeDetailCtrl', ['$scope', '$stateParams', 'MakeChange', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $stateParams, MakeChange, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- MakeChange.getItem({id: $stateParams.id}, function (data) {
- $scope.change = data;
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- MakeChange.reply({itemId: change.id}, reply, function () {
- toaster.pop('info', '提示', '回复成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- }]);
- /**
- * 委外加工
- */
- app.controller('MakeOutOrderCtrl', ['$scope', '$filter', 'MakeOutOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'CurrentRole', function ($scope, $filter, MakeOutOrder, ngTableParams, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return MakeOutOrder;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {};
- pageParams.searchFilter.keyword = $scope.keyword;
- pageParams.searchFilter.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- pageParams.searchFilter.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 获取回复记录
- $scope.getReply = function (item) {
- if (!item.replies) {
- MakeOutOrder.getReply({orderId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- // 打开回复
- $scope.openReply = function (change) {
- change.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (change) {
- change.$editing = false;
- }
- // 确定回复
- $scope.onReplyClick = function (change) {
- if (change.$agreed) {
- var reply = {id: change.id, agreed: Number(change.$agreed), replyRemark: change.replyRemark};
- $scope.loading = true;
- MakeOutOrder.reply({itemId: change.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '回复成功');
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- MakeOutOrder.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'make/outorders/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 委外加工详细
- */
- app.controller('MakeOutOrderDetailCtrl', ['$scope', '$stateParams', 'MakeOutOrder', 'toaster', 'ReportService', 'BaseService', 'CurrentRole', function ($scope, $stateParams, MakeOutOrder, toaster, ReportService, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- MakeOutOrder.getItem({id: $stateParams.id},{}, function (data) {
- $scope.order = data;
- var sum = $scope.order.qty * $scope.order.price;
- $scope.order.total = sum;
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- // 获取回复记录
- $scope.getReply = function (item) {
- if (!item.replies) {
- MakeOutOrder.getReply({orderId: item.id}, function (replies) {
- item.replies = replies;
- });
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 点击回复
- $scope.onReplyClick = function (order, inverse) {
- if (order.reply) {
- if (!order.reply.qty || order.reply.qty < 0 || order.reply.qty > order.qty) {
- toaster.pop('warning', '提示', '请填写有效的回复数量!');
- return;
- }
- var reply = angular.copy(order.reply);
- if (reply.delivery) {
- if (typeof reply.delivery == 'object')
- reply.delivery = reply.delivery.getTime();
- } else {
- reply.delivery = order.delivery;
- }
- if (inverse && inverse == -1) reply.qty = -1 * reply.qty;// 取相反
- $scope.loading = true;
- MakeOutOrder.reply({orderId: order.id}, reply, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', (inverse == -1 ? '撤销成功' : '回复成功'));
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '回复失败', response.data);
- });
- }
- };
- // 打开回复
- $scope.openReply = function (order) {
- if (!order.reply) {
- order.reply = {
- qty: order.qty - (order.replyQty ? order.replyQty : 0),
- delivery: order.delivery
- }
- }
- order.$editing = true;
- };
- // 关闭回复
- $scope.closeReply = function (order) {
- order.$editing = false;
- }
- // 自己委外加工订单
- $scope.print = function (order) {
- MakeOutOrder.printCount({id: order.id}, {});//增加打印此次
- ReportService.print(order.enUU, 'MAKE', 'where make$outorders.ma_id =' + order.id);
- };
- }]);
- /**
- * 计算时间差
- */
- app.filter('timespan', function () {
- return function (time) {
- if (time == null)
- return '9999年';
- var now = new Date().getTime(), span = time - now,
- d = Math.ceil(span / 86400000), h = Math.ceil(span / 3600000),
- m = Math.ceil(span / 60000);
- if (span < 0)
- return '1天';
- if (d > 0)
- return d + 1 + '天';
- if (h > 0)
- return h + '小时';
- if (m > 0)
- return m + '分钟';
- return '0天';
- };
- });
- /**
- * 公共询价计算时间差
- */
- app.filter('datespan', function () {
- return function (time) {
- if (time == null) {
- return '剩余9999年';
- }
- var now = new Date().getTime(), span = time - now,
- d = Math.floor(span / 86400000), h = Math.floor(span / 3600000),
- m = Math.floor(span / 60000);
- if (d > 0) {
- var day = d + 1;
- return '剩余' + day + '天';
- }
- if (h > 0) {
- return '<span class="text-inverse">剩余' + h + '小时</span>';
- }
- if (m > 0) {
- return '<span class="text-inverse">剩余' + m + '分钟</span>';
- }
- return '已结束';
- };
- });
- app.filter('firstchar', function () {
- return function (str) {
- if (str == null)
- return null;
- return str.substring(0, 1);
- };
- });
- app.filter('summary', function () {
- return function (data, field) {
- var sum = 0;
- if (data) {
- angular.forEach(data, function (d) {
- sum += d[field];
- });
- }
- return sum;
- };
- });
- /**
- * 搜索框,回车触发
- */
- app.directive('ngSearch', ['$parse', function ($parse) {
- return {
- require: '?ngModel',
- restrict: 'A',
- link: function (scope, element, attrs, ngModel) {
- var searchFn = $parse(attrs.ngSearch);
- element.bind('keypress', function (event) {
- if (event.keyCode == '13') {
- event.preventDefault();
- event.stopPropagation();
- searchFn(scope, {$data: ngModel.$modelValue, $event: event});
- }
- });
- }
- };
- }]);
- /**
- * 状态码 -> 描述
- */
- app.filter('status', function () {
- return function (data) {
- var statusConfig = {
- '101': '已提交',
- '102': '已审核',
- '103': '未通过',
- '200': '未回复',
- '201': '已回复',
- '313': '已激活',
- '316': '已过账',
- '311': '申请中',
- '312': '未激活'
- };
- return statusConfig[data];
- }
- });
- //弹出问题反馈模态框
- app.controller('LeftCtrl', ['$scope', '$modal', 'AuthenticationService', function ($scope, $modal, AuthenticationService) {
- //获取当前用户
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- });
- $scope.showModal = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/serve/feedback.html',
- controller: 'FeedbackCtrl',
- resolve: {
- user: function () {
- return $scope.user;
- } //传递当前用户到模态框Controller
- }
- });
- modalInstance.result.then(function () {
- }, function () {
- });
- }
- }]);
- /*
- * 提交我的反馈
- */
- app.controller('FeedbackCtrl', ['$scope', '$modalInstance', 'FeedBackService', 'toaster', 'AuthenticationService', 'user', function ($scope, $modalInstance, FeedBackService, toaster, AuthenticationService, user) {
- $scope.isPublic = 1; //默认公开
- $scope.classId = 1; //默认类别
- $scope.user = user;
- $scope.ok = function () {
- if (!$scope.user) { //用户未登录
- $scope.uu = null;
- } else { //用户已登录
- $scope.uu = $scope.user.userUU;
- }
- //FeedBackService定义于common/service.js里,供不同页面的问题反馈功能使用
- FeedBackService.feedBackQuestion({
- classId: $scope.classId,
- isPublic: $scope.isPublic,
- title: $scope.title,
- userUU: $scope.uu
- }, {},
- function (data) {
- toaster.pop('success', '成功', '您的问题反馈成功!');
- $scope.cancel();
- }, function (response) {
- toaster.pop('error', '错误', response.data);
- });
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- //“我的问题反馈”跳转控制
- app.controller('RightCtrl', ['$scope', 'AuthenticationService', 'toaster', '$rootScope', function ($scope, AuthenticationService, toaster, $rootScope) {
- $scope.myFeedback = function () {
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- if (!$scope.user) {
- toaster.pop('warning', '提示', '您还未登录,请登录后再查看!');
- return false;
- } else {
- window.location.href = "./serve#/question/myFeedback";
- }
- });
- };
- $scope.getSaleOrderCount = function (unread) {
- if (unread != undefined) {
- return unread.order;
- }
- };
- $scope.getSaleInquiryCount = function (unread) {
- if (unread != undefined) {
- return unread.inquiry;
- }
- };
- $scope.setActive = function (active) {
- $rootScope.active = active;
- }
- }]);
- //客户服务
- app.controller('CustServeCtrl', ['$scope', 'Vendor', function ($scope, Vendor) {
- Vendor.getServe(function (datas) {
- $scope.vendors = datas;
- // 自动跳转
- if (datas && datas.length == 1)
- $scope.redirect(datas[0]);
- });
- $scope.redirect = function (vendor) {
- window.open('purc/vendor/serve/' + vendor.vendorEnterprise.uu);
- };
- }]);
- /**
- * 物料资料
- */
- app.controller('ProductListCtrl', ['$scope', 'GetProductInfo', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', '$rootScope', '$modal', 'Products', 'GetProductInfoNewest', 'AccountEnterprise', function ($scope, GetProductInfo, ngTableParams, $filter, BaseService, toaster, $timeout, $rootScope, $modal, Products, GetProductInfoNewest, AccountEnterprise) {
- BaseService.scrollBackToTop();
- var loadAccount = function () {
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data;
- $scope.saleStatus = $scope.enterprise.prodsale;
- });
- }
- loadAccount();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? GetProductInfo : GetProductInfoNewest;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- id: 'desc',
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //删除
- $scope.deleteById = function (id) {
- $scope.loading = true;
- GetProductInfo.deleteById({}, id, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop("error", "删除失败", response.data);
- });
- };
- $rootScope.isProductEdit = false;
- // 编辑
- $scope.isProductEdit = function () {
- $rootScope.isProductEdit = true;
- };
- // 一键开启关闭
- $scope.toggle = function (status) {
- if ($scope.saleStatus == 0) {
- $scope.saleStatus = 1;
- } else {
- $scope.saleStatus = 0;
- }
- $scope.loading = true;
- GetProductInfo.toggle({status: status}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- loadAccount();
- $scope.tableParams.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- })
- }
- var products = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- products = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.cmpUuId == null) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- products = [];// 每次选择时先清空,防止重复
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.updateByBatch = function (updatetype) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/updateByBatch_modal.html',
- controller: 'UpdateByBatchCtrl',
- size: 'md',
- resolve: {
- updatetype: function () {
- return updatetype;
- },
- active: function () {
- return $scope.active;
- },
- type: function () {
- return 'sale';
- }
- }
- });
- modalInstance.result.then(function (data) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 一键匹配
- $scope.matchall = function () {
- $scope.loading = true;
- $scope.type = "sale";
- GetProductInfo.matchbytype({type: $scope.type}, {}, function (data) {
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- } else {
- toaster.pop('info', '提示', '匹配成功' + data.size + '个标准器件');
- window.location.href = "#/sale/productmatches";
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.exportXls = function () {
- GetProductInfo.exportXls({},{}, function (data) {
- if (data.success) {
- window.location.href = 'product/baseInfo/xls?_state='+$scope.active+'&keyword='+ ($scope.keywordXls || "");
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- }]);
- /**
- * 批量修改
- */
- app.controller('UpdateByBatchCtrl', ['$scope', '$modalInstance', 'toaster', 'BaseService', 'updatetype', 'Products', 'active', 'type', function ($scope, $modalInstance, toaster, BaseService, updatetype, Products, active, type) {
- $scope.updatetype = updatetype;
- $scope.changed = false;
- $scope.parameter = {
- updatetype: updatetype,
- standard: active,
- type: type,
- oldvalue: null,
- newvalue: null
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- if (updatetype === '品牌')
- var loadData = function () {
- Products.getBrands({parameter: $scope.parameter}, {}, function (data) {
- $scope.products = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- if (updatetype === '名称(类目)')
- var loadData = function () {
- Products.getTitles({parameter: $scope.parameter}, {}, function (data) {
- $scope.products = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- loadData();
- $scope.okay = function (newvalue) {
- if (newvalue == '' || newvalue == null) {
- toaster.pop('error', '提示', '修改的值不能为空');
- } else {
- $scope.loading = true;
- Products.alterByBatch({parameter: $scope.parameter}, {}, function (data) {
- $scope.loading = false;
- $modalInstance.close(data);
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- }]);
- /**
- * 物料批量上传
- */
- app.controller('UploadByBatchCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function ($scope, $upload, toaster, BaseService) {
- BaseService.scrollBackToTop();
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- $scope.fileName = file.name;
- }
- })
- // 通过excel批量上传物料
- $scope.upload = function () {
- $scope.loading = true;
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- if (file.name) {
- $upload.upload({
- url: 'product/baseInfo/edit/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- // $scope.products = $scope.result.products;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- $scope.infos = $scope.result.infos;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_prod_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'product/baseInfo/upload/template';
- };
- }]);
- /**
- * 物料详情
- */
- app.controller('ProductDetailCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', 'AuthenticationService', '$filter', 'BaseService', '$rootScope', '$modal', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, AuthenticationService, $filter, BaseService, $rootScope, $modal, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.editstatus = false;
- var loadData = function () {
- GetProductInfo.getSaleProduct({id: $stateParams.id}, function (data) {
- if (data.attachment) {
- $scope.imgPreview = data.attachment;
- $scope.previewShow = true;
- }
- $scope.prodInfo = data;
- if ($scope.prodInfo.isbusiness == 0) {
- $scope.editstatus = true;
- }
- if ($scope.prodInfo.standard != 1) {// 非标准的先进行匹配
- Products.matchone({id: $scope.prodInfo.id}, {}, function (data) {
- $scope.matchresults = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 设置类目
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.kind = kind.kindName;
- }
- // 设置名称
- $scope.onAssociateTitleClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置导入品牌
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- // 设置标准品牌
- $scope.onAssociatePBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.pbranden = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置标准型号
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.pcmpcode = cmp.code;
- }
- // 设置导入的型号
- $scope.onAssociateCmpClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 选择类目
- $scope.selectKind = function (cmpcode) {
- if (cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function () {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
- // 取消
- $scope.cancel = function () {
- GetProductInfo.getOne({id: $stateParams.id}, function (data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
- // 删除
- $scope.clearfile = function () {
- $scope.prodInfo.attachment = null;
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //删除
- $scope.deleteById = function (id) {
- $scope.loading = true;
- GetProductInfo.deleteById({}, id, function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- window.location.href = "#/sale/prodList";
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop("error", "删除失败", response.data);
- });
- };
- $scope.submit = function (prodInfo) {
- $scope.prodInfo.isSale = 1;
- $scope.loading = true;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/edit/updateProdInfo',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $rootScope.isProductEdit = false;
- loadData();
- // window.location.href="#/sale/prodList";
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loading = false;
- $scope.loadingShow = false;
- if (status == 403){
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- // 查看范例
- $scope.showImg = function () {
- if ($scope.prodInfo.attachment) {
- $scope.imgPreview = $scope.prodInfo.attachment;
- var src = $scope.prodInfo.attachment, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- $scope.previewShow = true;
- } else if (imgurl != null) {
- var src = imgurl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- }]);
- /**
- * 新增物料(销售)
- */
- app.controller('NewProdInfoCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', '$modal', 'ComponentActive', 'KindAPI', '$timeout', '$filter', 'AuthenticationService', 'BaseService', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout, $filter, AuthenticationService, BaseService, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.prodInfo = {};
- // 选择类目
- $scope.selectKind = function () {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- };
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 删除
- $scope.clearfile = function () {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //提交
- $scope.submit = function (prodInfo) {
- $scope.loading = true;
- $scope.prodInfo.isSale = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'product/baseInfo/edit/addNewProduct',
- file: file,
- method: 'POST',
- data: {
- prodInfo: prodInfo
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', '产品添加成功');
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/sale/prodList/" + data.id;
- // window.location.href="#/sale/prodList";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/sale/prodList/" + data.id;
- // window.location.href="#/sale/prodList";
- }, 500);
- }
- }).error(function (data, status) {
- $scope.loading = false;
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- };
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgUrl = null
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgUrl = url;
- return url;
- };
- // 查看范例
- $scope.showImg = function () {
- var src = imgUrl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 取消
- $scope.cancel = function () {
- $scope.prodInfo = angular.copy($scope.prodInfo);
- };
- }]);
- /**
- * 类目选择模态框
- */
- app.controller('KindChooseCtrl', ['$scope', 'KindAPI', 'toaster', '$modalInstance', '$modal', function ($scope, KindAPI, toaster, $modalInstance, $modal) {
- $scope.kindId = null;
- $scope.kinds = [[], [], [], []];
- // 获取子类目
- var getChildren = function (pid, deep) {
- KindAPI.getChildren({parentId: pid}, function (data) {
- $scope.kinds[deep] = data;
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- };
- // 改变节点选中状态
- var changeStatus = function (item, deep) {
- var kindId = null, level = 0;
- angular.forEach($scope.kinds, function (ks, i) {
- if (i > deep) {
- $scope.kinds[i] = [];
- } else {
- angular.forEach(ks, function (k, j) {
- if (i == deep) {
- if (k.id == item.id) {
- $scope.kinds[i][j].$active = true;
- kindId = k.id;
- } else {
- k.$active = null;
- }
- }
- });
- }
- });
- // 选择的节点
- $scope.kindId = kindId;
- $scope.active = item;
- // 当前可操作的层级
- if (deep < 3) {
- $scope.activeDeep = deep + 1;
- }
- };
- // 节点点击后获取子类目,节点被选中
- $scope.onItemClick = function (item, deep) {
- changeStatus(item, deep);
- if (!item.isLeaf) {
- getChildren(item.id, deep + 1);
- }
- };
- // 重新加载数据
- function reload(deep) {
- var pid;
- if (deep) {
- pid = $scope.actives[deep - 1].id;
- } else {
- pid = 0;
- deep = 0;
- }
- getChildren(pid, deep);
- }
- // 初始加载数据,获取第一层的类目
- if ($scope.actives) {
- angular.forEach($scope.actives, function (v, k) {
- KindAPI.getChildren({parentId: v.parentid}, function (data) {
- $scope.kinds[k] = data;
- angular.forEach($scope.kinds[k], function (kind, i) {
- if (kind.id == v.id) {
- $scope.kinds[k][i].$active = true;
- $scope.actives[k] = $scope.kinds[k][i];
- }
- })
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- });
- } else {
- reload();
- }
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 确认选择
- $scope.check = function () {
- $modalInstance.close($scope.kindId);
- };
- }]);
- /**
- * 器件筛选
- */
- app.controller('FindComponentCtrl', ['$scope', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'ComponentActive', 'KindId', function ($scope, BaseService, ngTableParams, toaster, $modalInstance, ComponentActive, KindId) {
- //状态
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.kindId = KindId;
- ComponentActive.getComponentsByKindid(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 选择
- $scope.check = function (data) {
- $modalInstance.close(data);
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 企业列表
- */
- app.controller('EnterpriseListCtrl', ['$scope', 'getAccountUserSpace', 'ngTableParams', '$filter', 'BaseService', 'toaster', 'AddPartner', '$rootScope', function ($scope, getAccountUserSpace, ngTableParams, $filter, BaseService, toaster, AddPartner, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return getAccountUserSpace;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 添加合作关系
- $scope.addPartner = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- $scope.status = 'enList';
- }]);
- /**
- * 新增采购单
- */
- app.controller('PurcNewOrderCtrl', ['$scope', '$modal', 'toaster', '$filter', 'addtoCart', '$rootScope', 'VendorInfo', 'ngTableParams', 'BaseService', 'Product', 'newPurcOrder', 'cartOperation', 'ShipAddress', 'Vendor', '$http', '$window', 'token', 'recentPrice',
- function ($scope, $modal, toaster, $filter, addtoCart, $rootScope, VendorInfo, ngTableParams, BaseService, Product, newPurcOrder, cartOperation, ShipAddress, Vendor, $http, $window, token, recentPrice) {
- BaseService.scrollBackToTop();
- // 每次进入时先清除掉rootScope下的venduu
- $rootScope.venduu = null;
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- var getToken = function() {
- if($scope.token == null) {
- token.info({userType: 'purcorder'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- getToken();
-
- $scope.order = {
- date: new Date(),
- vend: {
- uu: '',
- },
- vendUser: {},
- code: $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- orderItems: {
- product: {},
- },
- rate: 17
- };
- //商品信息
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- prid: null,
- taxrate: null
- };
- if ($rootScope.businessCode) {
- VendorInfo.getVendorInfo({businessCode: $rootScope.businessCode}, {}, function (data) {
- $scope.id = data.id;
- $scope.order.vend.enName = data.vendorEnterprise.enName;
- $scope.order.vend.enAddress = data.vendorEnterprise.enAddress;
- $scope.order.vend.uu = data.vendorEnterprise.uu;
- $scope.order.paymethods = data.paymethod;
- $rootScope.venduu = data.vendorEnterprise.uu;
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }, function (response) {
- });
- }
- ;
- // 查找供应商
- $scope.dbfindVend = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
- controller: 'DbfindVendorInfoCtrl',
- size: 'lg',
- resolve: {
- orderItems: function () {
- return $scope.order.orderItems;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $rootScope.venduu = data.vendorEnterprise.uu;
- $scope.id = data.id;
- $scope.order.vend = data.vendorEnterprise;
- $scope.order.vend.enName = data.vendorEnterprise.enName;
- $scope.order.vendUser = data.vendorUser;
- $scope.order.payments = data.paymethod;
- $scope.order.orderItems = [];
- var item = {
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- taxrate: null
- };
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }, function () {
- });
- };
- // 联想词 start
- // 获取供应商
- $scope.getSimilarVendors = function (value) {
- if (value) {
- return Vendor.getSimilarVendors({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateCmpClick = function (vendor, order) {
- $scope.order.vend.uu = vendor.venduu;
- $scope.id = vendor.id;
- $scope.order.payments = vendor.paymethod;
- $rootScope.venduu = $scope.order.vend.uu;
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- }
- // 联想词 end
- // $scope.order.orderItems.push(item);
- if ($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function (data) {
- item.code = data.code;
- item.title = data.title;
- item.spec = data.spec;
- item.unit = data.unit;
- item.id = data.id;
- $scope.order.orderItems.push(item);
- $rootScope.prodId = null;// 清除掉prodId
- }, function (response) {
- });
- }
- //增加商品
- $scope.addProduct = function (index) {
- if ($scope.order.orderItems[index].code == null) {
- toaster.pop('info', '提示', '请先选择商品');
- } else {
- $scope.order.orderItems.push({
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- $endDateOpen: false,
- taxrate: $scope.order.rate,
- prodsource: 'seller'
- });
- }
- };
- //删除商品
- $scope.deleteProduct = function (index) {
- $scope.order.orderItems.splice(index, 1);
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.vendUU = $scope.order.vend.uu;
- Product.vendPord.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 选择
- $scope.check = function (data) {
- var price = null;
- var qty = null;
- var taxRate = null;
- if (data.id) {
- recentPrice.agreed({prId: data.id}, {}, function(response) {
- price = response.price;
- qty = response.qty;
- taxRate = response.taxRate;
- $scope.order.orderItems.push({
- code: data.code,
- title: data.title,
- spec: data.spec,
- unit: data.unit,
- qty: qty,
- price: price,
- remark: null,
- delivery: null,
- prid: data.id,
- taxrate: taxRate,
- prodsource: 'seller',
- });
- });
- }
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_uplodaByBatch.html',
- controller: 'PurcUploadByBatchCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.order.orderItems.push({
- code: prod.code,
- title: prod.title,
- unit: 'PCS',
- spec: prod.spec,
- qty: prod.amount,
- price: prod.rateprice,
- remark: prod.remark,
- delivery: prod.date,
- prid: prod.id,
- taxrate: prod.rate,
- prodsource: 'purchaser'
- });
- })
- }, function () {
- });
- };
- // 监听venduu发生变化,重新加载物料信息
- $scope.$watch('order.vend.uu', function (n, o) {
- if (n == o) {
- return;
- } else {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, true);
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.order.orderItems[index].$endDateOpen = !openParam;
- };
- // 添加到购物车
- $scope.addToCart = function (order) {
- $scope.loading = true;
- $scope.order.status = 311;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.vendUU = $scope.order.vend.uu;
- $scope.order.vendUserUU = $scope.order.vendUser.userUU;
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/cart/' + data.id;
- $window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 立即购买
- $scope.addToOrder = function (order) {
- $scope.loading = true;
- $scope.order.status = 200;
- $scope.order.vendusertel = order.vendor.tel;
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- $scope.order.vendUU = $scope.order.vend.uu;
- $scope.order.vendUserUU = $scope.order.vendUser.userUU;
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/order/' + data.id;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- // 新增供应商联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function (data) {
- Vendor.contacts({venduu: $scope.order.vend.uu}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.contacts[0];
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- }]);
- /**
- * 采购批量导入
- */
- app.controller('PurcUploadByBatchCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.loading = false;
- $scope.upload = function () {
- $scope.loading = true;
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'purchase/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'purchase/upload/template';
- };
- $scope.enSure = function () {
- $scope.loading = true;
- $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);
- });
- }
- });
- //设置消息已读
- var setOrdersRead = function () {
- var ids=[];
- Vendor.setVendorRead({}, ids, function (message) {
- });
- };
- setOrdersRead();
- // 查看供应商详情
- $scope.VendorDetail = function (id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/" + $rootScope.vendorId;
- }
- // 向企业购买
- $scope.purcByEn = function (businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
- }]);
- /**
- * 供应商详情
- */
- app.controller('PurcVendorDetailCtrl', ['$scope', 'toaster', '$stateParams', 'Vendor', '$modal', 'Product', 'ngTableParams', 'BaseService', '$rootScope', function ($scope, toaster, $stateParams, Vendor, $modal, Product, ngTableParams, BaseService, $rootScope) {
- BaseService.scrollBackToTop();
- $scope.vendorContacts = [];
- var loadData = function () {
- Vendor.getVendorDetail({id: $stateParams.id}, {}, function (data) {
- $scope.vendor = data.vendorEnterprise;
- Vendor.contacts({venduu: $scope.vendor.uu}, {}, function (data) {
- $scope.vendorContacts = data;
- });
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- // 新增供应商联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.venduu = uu;
- Vendor.saveContact({}, $scope.contact, function (data) {
- toaster.pop('success', '提示', '联系人保存成功');
- $scope.vendorContacts.push(data);
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- };
- // 编辑供应商联系人
- $scope.edit = function (contact) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'EditContacCtrl',
- resolve: {
- contact: function () {
- return contact;
- }
- }
- });
- modalInstance.result.then(function (data) {
- Vendor.saveContact({}, data, function (data) {
- loadData();
- toaster.pop('success', '提示', '联系人修改成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- // 删除供应商联系人
- $scope.deleteById = function (id, index) {
- $scope.vendorContacts.splice(index, 1);
- Vendor.deleteContact({id: id}, {}, function (data) {
- toaster.pop('success', '提示', '供应商联系人删除成功');
- loadData();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 供应商物料信息
- $scope.viewProdList = function (uu) {
- $scope.uu = uu;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 供应商物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.custUU = $scope.uu;
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- /**
- * 选中单个物料购买
- * @param businessCode
- * @param id
- */
- $scope.PurcByEnAndProd = function (businessCode, id) {
- $rootScope.businessCode = businessCode;
- $rootScope.prodId = id;
- window.location.hash = "#/purc/addOrder";
- }
- /**
- * 询价
- */
- $scope.PurcInquiry = function (businessCode, id) {
- $rootScope.prodId = id;
- window.location.hash = "#/purc/purcinquiry/" + businessCode;
- }
- }]);
- /**
- * 编辑供应商联系人
- */
- app.controller('EditContacCtrl', ['$scope', 'toaster', '$modalInstance', 'contact', function ($scope, toaster, $modalInstance, contact) {
- $scope.contact = angular.copy(contact);
- $scope.save = function (contact) {
- $modalInstance.close(contact);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 新增供应商联系人
- */
- app.controller('AddContacCtrl', ['$scope', 'toaster', '$modalInstance', function ($scope, toaster, $modalInstance) {
- $scope.save = function (contact) {
- $modalInstance.close(contact);
- };
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 建立合作关系申请 (我的合作伙伴)
- */
- app.controller('AddPartnerRequestCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', '$rootScope', 'VendorInfo', '$window', function ($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout, $rootScope, VendorInfo, $window) {
- BaseService.scrollBackToTop();
- $scope.status = "partner";
- $scope.active = 'done';
- var getRequestStatus = function (active) {
- var fn = 'getAllRequest';
- switch (active) {
- case 'done':
- fn = 'getRequestDone';
- break;
- case 'todo':
- fn = 'getRequestTodo';
- break;
- case 'end':
- fn = 'getRequestEnd';
- break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function () {
- return AddPartnerMyRequest;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- if ($rootScope.vendName) {
- pageParams.keyword = $rootScope.vendName;
- $scope.keyword = $rootScope.vendName;
- $rootScope.vendName = null;
- }
- $scope.tip = $scope.keyword;
- getService()[getRequestStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 再次申请
- $scope.addAgain = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- // 添加为供应商
- $scope.addSupplier = function (vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加为供应商
- $scope.addServicer = function (vendUID) {
- AddPartner.addServicer({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加客户
- $scope.addCust = function (vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 同意申请
- $scope.agree = function (id) {
- AddPartner.agreeRequest({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 拒绝申请
- $scope.refuse = function (id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消供应商关系
- $scope.relieve = function (id) {
- VendorInfo.relieve({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 建立供应商关系
- $scope.activeVend = function (id) {
- VendorInfo.activeVend({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消服务商
- $scope.relieveServicer = function (id) {
- VendorInfo.relieveServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 启用服务商
- $scope.activeServicer = function (id) {
- VendorInfo.activeServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消客户关系
- $scope.disableCust = function (id) {
- VendorInfo.disableCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 激活客户关系
- $scope.activeCust = function (id) {
- VendorInfo.activeCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 建立合作关系申请 (新的合作伙伴)
- */
- app.controller('NewPartnerCtrl', ['$scope', 'AddPartnerMyRequest', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', '$timeout', '$rootScope', 'VendorInfo', '$window', '$modal',
- function ($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout, $rootScope, VendorInfo, $window, $modal) {
- BaseService.scrollBackToTop();
- $scope.status = "partner";
- $scope.active = 'all'; // 所有申请记录
- var getRequestStatus = function (active) {
- var fn = 'getAllRequest';
- switch (active) {
- case 'done':
- fn = 'getRequestDone';
- break;
- case 'todo':
- fn = 'getRequestTodo';
- break;
- case 'end':
- fn = 'getRequestEnd';
- break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- // 切换数据来源(正常数据 or 历史数据)
- var getService = function () {
- return AddPartnerMyRequest;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- if ($rootScope.vendName) {
- pageParams.keyword = $rootScope.vendName;
- $scope.keyword = $rootScope.vendName;
- $rootScope.vendName = null;
- }
- $scope.tip = $scope.keyword;
- getService()[getRequestStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 再次申请
- $scope.addAgain = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- // 添加为供应商
- $scope.addSupplier = function (vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加为供应商
- $scope.addServicer = function (vendUID) {
- AddPartner.addServicer({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加客户
- $scope.addCust = function (vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 同意申请
- $scope.agree = function (id) {
- AddPartner.agreeRequest({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- if (data.result) {
- //选择打印模板
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/partnership_modal.html',
- controller: 'PartnerShipCtrl',
- resolve: {
- PartnerShipInfo: function () {
- return data.result;
- }
- }
- });
- modalInstance.result.then(function () {
- window.location.reload();
- });
- }
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- AddPartnerMyRequest.requestAmount({}, function (data) {
- $scope.requestTodo = data;
- });
- // 拒绝申请
- $scope.refuse = function (id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 取消供应商关系
- $scope.relieve = function (id) {
- VendorInfo.relieve({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 建立供应商关系
- $scope.activeVend = function (id) {
- VendorInfo.activeVend({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 取消服务商
- $scope.relieveServicer = function (id) {
- VendorInfo.relieveServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 启用服务商
- $scope.activeServicer = function (id) {
- VendorInfo.activeServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 取消客户关系
- $scope.disableCust = function (id) {
- VendorInfo.disableCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 激活客户关系
- $scope.activeCust = function (id) {
- VendorInfo.activeCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 同意申请后续操作
- */
- app.controller('PartnerShipCtrl', ['$scope', 'PartnerShipInfo', '$modalInstance', 'AddPartner', 'toaster',
- function($scope, PartnerShipInfo, $modalInstance, AddPartner, toaster) {
- $scope.partInfo = PartnerShipInfo;
- // 添加为服务商
- $scope.addServicer = function (vendUID) {
- AddPartner.addServicer({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加客户
- $scope.addCust = function (vendUID) {
- AddPartner.addCust({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 添加为供应商
- $scope.addSupplier = function (vendUID) {
- AddPartner.addSupplier({businessCode: vendUID}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- })
- };
- // 关闭
- $scope.close = function() {
- $modalInstance.close();
- }
- }]);
- /**
- * 建立合作关系处理申请
- */
- app.controller('AddPartnerMessageCtrl', ['$scope', 'AddPartnerMyMessage', 'toaster', 'BaseService', 'ngTableParams', 'AddPartner', 'AddPartnerMyRequest', '$window', function ($scope, AddPartnerMyMessage, toaster, BaseService, ngTableParams, AddPartner, AddPartnerMyRequest, $window) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- var getMessagetStatus = function (active) {
- var fn = 'getAllMessage';
- switch (active) {
- case 'done':
- fn = 'getMessageDone';
- break;
- case 'todo':
- fn = 'getMessageTodo';
- break;
- case 'end':
- fn = 'getMessageEnd';
- break;
- }
- return fn;
- }
- // 切换单据类型
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return AddPartnerMyMessage;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 15, 25, 50],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- };
- getService()[getMessagetStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 同意申请
- $scope.agree = function (id) {
- AddPartner.agreeReq
- uest({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- // 拒绝申请
- $scope.refuse = function (id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', '操作成功');
- }
- if (data.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- $scope.status = 'get';
- }]);
- /**
- * 我的合作伙伴
- */
- app.controller('MyPartnersCtrl', ['$scope', 'toaster', 'GetProductInfo', 'BaseService', function ($scope, toaster, GetProductInfo, BaseService) {
- BaseService.scrollBackToTop();
- // 默认显示合作伙伴
- $scope.status = 'news';
- // 获取所有的合作伙伴
- GetProductInfo.getAllPartners({}, function (data) {
- $scope.partners = data;
- }, function (res) {
- toaster.pop('error', '获取列表失败', res.data);
- });
- // 添加为客户
- $scope.addCust = function (partner) {
- GetProductInfo.addCust({}, partner, function (data) {
- toaster.pop('success', '提示', '添加客户成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '添加客户失败', response.data);
- });
- }
- // 添加为供应商
- $scope.addSupplier = function (partner) {
- GetProductInfo.addSupplier({}, partner, function (data) {
- toaster.pop('success', '提示', '添加供应商成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '添加供应商失败', response.data);
- });
- }
- }]);
- /**
- * 财务对账时,企业进行筛选操作
- */
- app.controller('SearchCustInfoCtrl', ['$scope', '$modalInstance', 'suuorname', 'FaApCheck', 'VendorService', 'ngTableParams', 'BaseService', function ($scope, $modalInstance, suuorname, FaApCheck, VendorService, ngTableParams, BaseService) {
- var getData = function () {
- $scope.loading = true;
- FaApCheck.getAllCustomers(function (data) {
- $scope.custs = data;
- $scope.loading = false;
- });
- };
- getData();
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
- $scope.select = function (customer) {
- if (customer.apcheck != 0) {
- $modalInstance.close(customer);
- }
- }
- $scope.close = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 跳转到企业圈
- */
- app.controller('BusinessGroupsCtrl', ['$scope', 'GetProductInfo', 'toaster', function ($scope, GetProductInfo, toaster) {
- GetProductInfo.businessGroups({}, function (data) {
- window.open(data.url);
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }]);
- /**
- * 购物车
- */
- app.controller('CartController', ['$scope', 'toaster', 'getCartList', 'ngTableParams', '$filter', 'BaseService', 'cartOperation', '$timeout', 'cartList', 'PurchaseOrder', function ($scope, toaster, getCartList, ngTableParams, $filter, BaseService, cartOperation, $timeout, cartList, PurchaseOrder) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.hasClick = false;
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? cartList : getCartList;
- };
- var getTodoCartCount = function () {
- cartOperation.getTodoCartCount({}, function (data) {
- $scope.countTodo = data.cartTodo;
- });
- };
- getTodoCartCount();
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.getCartTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var changeClickStatus = function () {
- $scope.hasClick = true;
- $timeout(function () {
- $scope.hasClick = false;
- }, 500);
- }
- // 提交
- $scope.addtoOrder = function (id) {
- cartOperation.addToOrder({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- getTodoCartCount();
- $timeout(function () {
- window.location.hash = '#/purc/order/' + data.id;
- window.location.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
- // 删除一条主记录
- $scope.deleteCart = function (id) {
- changeClickStatus();
- $scope.loading = true;
- cartOperation.deleteCart({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- getTodoCartCount();
- getTodoCartCount();
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('erroer', '提示', response.data);
- });
- };
- // 删除一条明细
- $scope.deleteDetail = function (id) {
- changeClickStatus();
- $scope.loading = true;
- cartOperation.deleteCartDetail({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- $scope.loading = false;
- });
- };
- // 清空购物车
- $scope.clearCart = function () {
- changeClickStatus();
- $scope.loading = true;
- cartOperation.deleteCarts({}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- getTodoCartCount();
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- $scope.loading = false;
- });
- }
- // 复制订单
- $scope.copyorder = function (id) {
- changeClickStatus();
- $scope.loading = true;
- PurchaseOrder.copyorder({id: id}, {}, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '单据复制成功');
- getTodoCartCount();
- $scope.loading = false;
- window.location.hash = "#purc/cart/" + data.id;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- $scope.loading = false;
- });
- }
- }]);
- /**
- * 购物车详情
- */
- app.controller('CartDetailController', ['$scope', 'cartOperation', '$stateParams', 'toaster', '$timeout', 'BaseService', 'ngTableParams', '$filter', 'Product', 'Vendor', 'ShipAddress', '$modal', 'newPurcOrder', 'addtoCart', '$http', 'token', 'recentPrice',
- function ($scope, cartOperation, $stateParams, toaster, $timeout, BaseService, ngTableParams, $filter, Product, Vendor, ShipAddress, $modal, newPurcOrder, addtoCart, $http, token, recentPrice) {
- BaseService.scrollBackToTop();
- $scope.loading = true;
- var loadData = function () {
- cartOperation.getCartDetail({id: $stateParams.id}, function (data) {
- if (data.code) {
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function (item) {
- sum += item.qty * item.price;
- });
- $scope.order.total = sum;
- Vendor.contacts({venduu: $scope.order.receiveCode}, {}, function (data) {
- $scope.contacts = data;
- $scope.order.vendor = $scope.order.venduser;
- });
- $scope.loading = false;
- } else {
- window.location.hash = '#/purc/cart';
- }
- });
- };
- loadData();
- var getToken = function() {
- token.info({userType: 'cart'}, {}, function(data) {
- $scope.token = data.token;
- }, function(response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- getToken();
-
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 获取收货地址列表
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- //增加商品
- $scope.addProduct = function (index) {
- if ($scope.order.orderItems[index].code == null) {
- toaster.pop('info', '提示', '请先选择商品');
- } else {
- $scope.order.orderItems.push({
- code: null,
- title: null,
- spec: null,
- unit: null,
- qty: null,
- price: null,
- remark: null,
- delivery: null,
- $endDateOpen: false,
- taxrate: $scope.order.rate
- });
- }
- };
- //删除商品
- $scope.deleteProduct = function (index, id) {
- $scope.order.orderItems.splice(index, 1);
- if (id != null) {
- cartOperation.deleteCartDetail({id: id}, {}, function (data) {
- if (data.success) {
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.vendUU = $scope.order.receiveCode;
- Product.vendPord.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 选择
- $scope.check = function (data) {
- var price = null;
- var qty = null;
- var taxRate = null;
- if (data.id) {
- recentPrice.agreed({prId: data.id}, {}, function(response) {
- price = response.price;
- qty = response.qty;
- taxRate = response.taxRate;
- $scope.order.orderItems.push({
- code: data.code,
- title: data.title,
- spec: data.spec,
- unit: data.unit,
- qty: qty,
- price: price,
- remark: null,
- delivery: null,
- prid: data.id,
- taxrate: taxRate,
- prodsource: 'seller',
- });
- });
- }
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_uplodaByBatch.html',
- controller: 'PurcUploadByBatchCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.order.orderItems.push({
- code: prod.code,
- title: data.title,
- unit: 'PCS',
- spec: prod.spec,
- qty: prod.amount,
- price: prod.rateprice,
- remark: prod.remark,
- delivery: prod.date,
- prid: prod.id,
- taxrate: prod.rate
- });
- })
- }, function () {
- });
- }
- // 删除一条主记录
- $scope.deleteCart = function (id) {
- cartOperation.deleteCart({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- window.location.reload();
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('erroer', '提示', response.data);
- });
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.order.orderItems[index].$endDateOpen = !openParam;
- };
- // 添加到购物车
- $scope.addToCart = function (order) {
- $scope.loading = true;
- if (order.vendor.tel != null) {
- $scope.order.vendusertel = order.vendor.tel;
- }
- if (order.vendor.venduser != null && order.vendor.tel != null) {
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- }
- if (order.shipadd != null) {
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- }
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- $scope.order.status = 311;
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 立即购买
- $scope.addToOrder = function (order) {
- $scope.loading = true;
- if (order.vendor.tel != null) {
- $scope.order.vendusertel = order.vendor.tel;
- }
- if (order.vendor.venduser != null && order.vendor.tel != null) {
- $scope.order.venduser = order.vendor.venduser + '' + order.vendor.tel;
- }
- if (order.shipadd != null) {
- $scope.order.shipaddress = order.shipadd.address + order.shipadd.addressdet + '' + order.shipadd.receiver + '' + order.shipadd.usertel;
- }
- if ($scope.order.date instanceof Date) {
- $scope.order.date = $scope.order.date.getTime();
- }
- for (var i = 0; i < $scope.order.orderItems.length; i++) {
- if ($scope.order.orderItems[i].delivery instanceof Date) {
- $scope.order.orderItems[i].delivery = $scope.order.orderItems[i].delivery.getTime();
- }
- if ($scope.order.currency != 'RMB') {
- $scope.order.orderItems[i].rate = 0;
- }
- }
- $scope.order.status = 200;
- addtoCart.save({token: $scope.token}, $scope.order, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/order/' + data.id;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- };
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.order.shipadd = $scope.ships[0];
- });
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- }
- // 新增供应商联系人
- $scope.addContact = function (uu) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.contact = data;
- $scope.contact.venduu = $scope.order.receiveCode;
- Vendor.saveContact({}, $scope.contact, function (data) {
- Vendor.contacts({venduu: $scope.order.receiveCode}, {}, function (data) {
- $scope.contacts = data;
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- }
- }]);
- /**
- * 审批流
- */
- app.controller('approvalFlowCtrl', ['$scope', 'toaster', '$modal', 'appFlow', 'BaseService', function ($scope, toaster, $modal, appFlow, BaseService) {
- BaseService.scrollBackToTop();
- $scope.vacation = false;
- $scope.workovertime = false;
- $scope.workdaily = false;
- $scope.feeplease = false;
- $scope.signapp = false;
- appFlow.viewAppFlow({}, function (data) {// 获取已设置的列表
- $scope.nodes = data;
- angular.forEach($scope.nodes, function (node) {
- if (node.appname = '请假单') {
- $scope.vacation = true;
- }
- if (node.appname = '加班单') {
- $scope.workovertime = true;
- }
- if (node.appname = '工作日报') {
- $scope.workdaily = true;
- }
- if (node.appname = '出差单') {
- $scope.feeplease = true;
- }
- if (node.appname = '申诉单') {
- $scope.signapp = true;
- }
- });
- }, function (response) {
- });
- $scope.NoteSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '请假单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.overTimeSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '加班单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.feePleaseSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '出差单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.workDailySet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '工作日报';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- $scope.signAppSet = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/step1.html',
- controller: 'NoteStep1Ctrl',
- size: 'lg',
- resolve: {
- AppName: function () {
- return '申诉单';
- }
- }
- });
- modalInstance.result.then(function (data) {
- appFlow.saveAppFlowSet({json: data}, {}, function (data) {
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- }, function (response) {
- });
- }, function () {
- });
- }
- }]);
- /**
- * 审核条件设置
- */
- app.controller('NoteStep1Ctrl', ['$scope', 'toaster', '$modalInstance', 'appFlow', 'AppName', '$filter', '$rootScope', function ($scope, toaster, $modalInstance, appFlow, AppName, $filter, $rootScope) {
- $scope.appName = AppName;// 标题名称
- $scope.AppFlow = {
- appName: $scope.appName,
- appNodes: {}
- };
- $scope.AppFlow.appNodes = [];
- appFlow.getNodeByName({name: AppName}, {}, function (data) {// 通过单据名称查询单个审批流
- if (data.appNodes.length != 0) {
- $scope.node = data;
- $scope.AppFlow = data;
- }
- }, function () {
- });
- $scope.copy = function () {//复制
- $rootScope.flowcopy = angular.copy($scope.AppFlow);
- toaster.pop('info', '提示', '复制成功');
- $modalInstance.dismiss();
- }
- $scope.paste = function () {
- $scope.AppFlow = {appName: $scope.appName, appNodes: {}};
- $scope.AppFlow.appNodes = $rootScope.flowcopy.appNodes;
- }
- $scope.clear = function () {// 清空
- $scope.AppFlow = {
- appName: $scope.appName,
- appNodes: {}
- };
- $scope.AppFlow.appNodes = [];
- }
- appFlow.getPositions({}, function (data) {// 获取人员信息
- $scope.users = data;
- }, function (response) {
- });
- appFlow.getPositionInfo({}, function (data) { // 获取职位信息
- $scope.roles = data;
- }, function (response) {
- });
- $scope.SelectUser = function (data) { // 添加人员
- var item = {
- useruu: null,
- username: null,
- level: null
- };
- item.useruu = data.useruu;
- item.username = data.username;
- $scope.AppFlow.appNodes.push(item);
- }
- $scope.SelectRole = function (data) {// 添加职位
- var item = {
- position: null,
- level: null
- };
- item.position = data;
- $scope.AppFlow.appNodes.push(item);
- }
- $scope.deleteNode = function (index) {// 删除节点
- $scope.AppFlow.appNodes.splice(index, 1);
- };
- $scope.saveNode = function () { // 保存
- angular.forEach($scope.AppFlow.appNodes, function (value, key) {
- $scope.AppFlow.appNodes[key].level = key;
- });
- if ($scope.AppFlow.appNodes.length == 0) {
- toaster.pop('info', '提示', '您还未设置审批人');
- } else {
- $modalInstance.close($scope.AppFlow);
- }
- ;
- };
- $scope.cancel = function () {// 取消
- $modalInstance.dismiss();
- }
- }]);
- /***
- * 代采定单
- */
- app.controller('DeputyOrderCtrl', ['$scope', 'toaster', 'getDeOrder', 'ngTableParams', 'BaseService', 'DeputyOrder', 'ReportService', 'getOrderInfo', '$modal', 'CurrentRole', function ($scope, toaster, getDeOrder, ngTableParams, BaseService, DeputyOrder, ReportService, getOrderInfo, $modal, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.active = 'all';
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.total = null;
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.agreedText = '全部';
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.searchMethod = false;
- var getSerivce = function() {
- return $scope.searchMethod ? getDeOrder : getOrderInfo;
- }
- getSerivce();
-
- // 获取订单总金额
- var getOrdersAmount = function() {
- DeputyOrder.odersAmount({}, function(data) {
- $scope.odersAmount = data.amount;
- });
- }
-
- getOrdersAmount();
-
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {'date': 'desc', 'id': 'desc'}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getSerivce()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.searchFilter.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //打印
- $scope.print = function (deputyOrder) {
- DeputyOrder.printCount({id: deputyOrder.id}, {});//增加打印此次
- $scope.tableParams.reload();
- ReportService.print(deputyOrder.deputyuu, 'PURCNOTICE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 定向采购通知
- ReportService.print(deputyOrder.deputyuu, 'PURCHASE', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 采购订单
- ReportService.print(deputyOrder.deputyuu, 'PAYCONFIRM', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 付款确认
- ReportService.print(deputyOrder.deputyuu, 'TRADECONTRACT', "where purc$deputyorders.deo_id=" + deputyOrder.id); // 买卖合同
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 复制采购单
- $scope.copyorder = function (id) {
- $scope.loading = true;
- DeputyOrder.copyOrder({id: id}, {}, function (data) {
- $scope.loading = false;
- if (data.id) {
- toaster.pop('success', '提示', '复制生成单据成功');
- window.location.hash = "#/purc/deputy/" + data.id;
- }
- if (data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- // 删除代采订单
- $scope.clear = function (id) {
- $scope.loading = true;
- DeputyOrder.clearOrder({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
-
- $scope.viewApprove = function(salecode, uu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/approval_detail.html',
- controller: 'ViewApprovalDetailCtrl',
- resolve: {
- uu: function () {
- return uu
- },
- salecode: function () {
- return salecode
- }
- }
- });
- }
- }]);
- // 查询代采定单在信扬中的审批情况
- app.controller('ViewApprovalDetailCtrl', ['$scope', 'toaster', '$modalInstance', 'DeputyOrder', 'BaseService', 'ngTableParams', 'uu', 'salecode', function ($scope, toaster, $modalInstance, DeputyOrder, BaseService, ngTableParams, uu, salecode) {
- DeputyOrder.approve({uu: uu, code: salecode}, {}, function (data) {
- $scope.nodes = data.nodes;
- $scope.process = data.process;
- if(data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', '暂未获取到相关单据的信息');
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.select = function (company) { // 直接选择
- $modalInstance.close(company);
- }
- }]);
- /**
- * 新增代采订单
- */
- app.controller('NewDeputyOrderCtrl', ['$scope', 'toaster', '$modal', 'DeputyOrder', '$filter', 'ngTableParams', 'BaseService', 'DecimalNumber', 'DekeyValue', function ($scope, toaster, $modal, DeputyOrder, $filter, ngTableParams, BaseService, DecimalNumber, DekeyValue) {
- BaseService.scrollBackToTop();
- //默认采购单号不重复
- $scope.orderCodeEnable = true;
- $scope.deOrder = {
- code: 'DC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- entrydate: new Date(),
- status: '在录入',
- goodspacking: '供应商原厂包装,如外包装完好视为货物完好',
- pickupdate: '我方自向贵公司支付货款之日起3个自然日内提货完毕',
- riskmethod: '甲方承担',
- taxpaymentmethod: '甲方承担',
- deliverymethod: '供应商送货到付款采购方指定仓库',
- totalamount: 0,
- totalpayament: 0,
- orderamount: 0,
- usdpayment: 0
- };
- $scope.deOrder.deputyOrderItems = [];
- var item = {
- prodname: null,
- prodcode: null,
- prodspec: null,
- amount: null,
- unitprice: null,
- purcprice: null,
- remark: null,
- orderprice: null,
- };
- $scope.deOrder.deputyOrderItems.push(item);
- // 代采企业列表
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEnterprises = data;
- $scope.deOrder.deputyname = $scope.deputyEnterprises[0].deputyenname;
- $scope.deOrder.deputyuu = $scope.deputyEnterprises[0].deputyenuu;
- getPayMethod($scope.deOrder.deputyuu, 'paymentmethod');
- });
- var getPayMethod = function(enuu, key) {
- // 获取我方付款支付方式默认值
- DekeyValue.getValue({enuu: enuu, key: key}, function(data) {
- $scope.methods = data.content;
- });
- }
- // 更新名称时后台更改uu号
- $scope.change = function (deputyname) {
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEn = data;
- angular.forEach($scope.deputyEn, function (en) {
- if (deputyname == en.deputyenname) {
- $scope.deputyuu = en.deputyenuu;
- getPayMethod($scope.deputyuu, 'paymentmethod');
- }
- });
- });
- }
- // 设置付款企业信息
- $scope.setPayComName = function() {
- // 针对信扬客户,如果是RMB赋值默认值
- if ($scope.deOrder.currency == 'RMB' && $scope.deOrder.deputyuu == 10044118) {
- $scope.deOrder.paycomname = '深圳信扬国际经贸股份有限公司';
- $scope.deOrder.paycomaddress= '深圳市前海深港合作区前湾一路1号A栋201室(入驻深圳市前海商务秘书有限公司)';
- }
- }
- // 查找付款企业
- $scope.dbfindPayCompany = function (deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/payCompany.html',
- controller: 'DbfindDeputyPayCompanyCtrl',
- resolve: {
- deputyuu: function () {
- return deputyuu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.deOrder.paycomname = data.enname;
- $scope.deOrder.paycomaddress = data.address;
- })
- }
- // 查询上次的关键词记录
- $scope.getHisKeyword = function (tervendor) {
- DeputyOrder.hisKeywords({tervendor: tervendor}, {}, function (data) {
- $scope.deOrder.vendtel = data.vendtel;
- $scope.deOrder.venduser = data.venduser;
- $scope.deOrder.otherdata = data.otherdata;
- $scope.deOrder.companyname = data.companyname;
- $scope.deOrder.bankaccount = data.bankaccount;
- $scope.deOrder.bankaddress = data.bankaddress;
- $scope.deOrder.bankcode = data.bankcode;
- $scope.deOrder.bankname = data.bankname;
- $scope.deOrder.legalrepresent = data.legalrepresent;
- $scope.deOrder.tervendaddress = data.tervendaddress;
- $scope.deOrder.enfax = data.enfax;
- $scope.deOrder.deliverymethod = data.deliverymethod;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 查询历史供应商
- DeputyOrder.hisvendors({}, function (data) {
- $scope.hisvendors = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- // 上次填写记录(不关联供应商)
- DeputyOrder.lastKeywords({}, function (data) {
- $scope.lastkeyowrds = data;
- $scope.deOrder.madealdate = $scope.lastkeyowrds.madealdate;
- $scope.deOrder.madealcode = $scope.lastkeyowrds.madealcode;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- //增加商品
- $scope.add = function (index) {
- if ($scope.deOrder.deputyOrderItems[index].prodcode == null) {
- toaster.pop('info', '提示', '请先填写商品信息');
- } else {
- $scope.deOrder.deputyOrderItems.push(
- {
- prodname: null,
- prodcode: null,
- prodspec: null,
- prodbrand: null,
- amount: null,
- unitprice: null,
- purcprice: null,
- remark: null,
- orderprice: null
- });
- }
- };
- //删除商品
- $scope.del = function (index) {
- $scope.deOrder.deputyOrderItems.splice(index, 1);
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'DeputyOrderUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (data) {
- $scope.deOrder.deputyOrderItems.push(data);
- for (var i = 0; i < $scope.deOrder.deputyOrderItems.length; i++) {
- if ($scope.deOrder.deputyOrderItems[i].prodname == null) { // 如果没有填写就删除这行数据
- $scope.deOrder.deputyOrderItems.splice(i, 1);
- }
- }
- })
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }, function () {
- });
- }
- // 查找供应商
- $scope.dbfindVendor = function (deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/purc_order_vendor.html',
- controller: 'DbfindDeputyVendorInfoCtrl',
- size: 'lg',
- resolve: {
- deputyuu: function () {
- return deputyuu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.deOrder.customer = data.vendorEnterprise.enName;
- $scope.deOrder.legalrepresent = data.vendorUser.userName;
- $scope.deOrder.enaddress = data.vendorEnterprise.enAddress;
- $scope.deOrder.usertel = data.vendorUser.userTel;
- })
- }
- // 检验订单编号是否存在
- $scope.checkOrder = function (salecode, deputyuu) {
- DeputyOrder.checkOrders({salecode: salecode, deputyuu: deputyuu}, {}, function (data) {
- $scope.orderCodeEnable = true;
- if (data.info) {
- toaster.pop('error', '提示', data.info);
- $scope.orderCodeEnable = false;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- //计算采购单价
- $scope.checkPrice = function (rate) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- if (rate == null) {
- toaster.pop('info', '提示', '请先填入税率');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- item.purcprice = DecimalNumber.accMul(item.unitprice, (1 + rate / 100));
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }
- }
- // 获取订单总价
- $scope.totalPrice = function () {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- if(item.amount != null && item.unitprice != null && item.purcprice != null) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- }
- });
- }
-
- $scope.checkresult = false;
- var checkKeyword = function () {
- if ($scope.deOrder.madealdate == null) {
- toaster.pop('info', '提示', '主协议签订日期未选择');
- } else if ($scope.deOrder.madealcode == null) {
- toaster.pop('info', '提示', '主协议签订编号未填写');
- } else if ($scope.deOrder.tervendor == null) {
- toaster.pop('info', '提示', '终端供应商名称未填写');
- } else if ($scope.deOrder.vendtel == null) {
- toaster.pop('info', '提示', '电话号码未填写');
- } else if ($scope.deOrder.venduser == null) {
- toaster.pop('info', '提示', '联系人未填写');
- } else if ($scope.deOrder.shipdate == null) {
- toaster.pop('info', '提示', '供应商发货时间未选择');
- } else if ($scope.deOrder.goodspacking == null) {
- toaster.pop('info', '提示', '货物包装要求未填写');
- } else if ($scope.deOrder.deliverymethod == null) {
- toaster.pop('info', '提示', '供应商交货方式未填写');
- } else if ($scope.deOrder.pickupmethod == null) {
- toaster.pop('info', '提示', '我方提货方式未填写');
- } else if ($scope.deOrder.paymentmethod == null) {
- toaster.pop('info', '提示', '我方付款方式未填写');
- } else if ($scope.deOrder.pickupdate == null) {
- toaster.pop('info', '提示', '我方提货时间未选择');
- } else if ($scope.deOrder.currency == null) {
- toaster.pop('info', '提示', '交易币别未选择');
- } else if ($scope.deOrder.deputyuu == null) {
- toaster.pop('info', '提示', '代采企业未选择');
- } else if ($scope.deOrder.salecode == null) {
- toaster.pop('info', '提示', '订单编号未填写');
- } else if ($scope.deOrder.paydeldate == null) {
- toaster.pop('info', '提示', '我方付款提货时间未选择');
- } else if ($scope.deOrder.riskmethod == null) {
- toaster.pop('info', '提示', '风险承担方式未填写');
- } else if ($scope.deOrder.taxpaymentmethod == null) {
- toaster.pop('info', '提示', '运、税费承担方式');
- } else if ($scope.deOrder.tervendaddress == null) {
- toaster.pop('info', '提示', '终端供应商地址未填写');
- } else if ($scope.deOrder.companyname == null) {
- toaster.pop('info', '提示', '公司全称(英文)未填写');
- } else if ($scope.deOrder.requirepaydate == null) {
- toaster.pop('info', '提示', '要求付汇日期未选择');
- } else if ($scope.deOrder.bankname == null) {
- toaster.pop('info', '提示', '银行名称(英文)未填写');
- } else if ($scope.deOrder.bankaccount == null) {
- toaster.pop('info', '提示', '银行账号未填写');
- } else if ($scope.deOrder.bankaddress == null) {
- toaster.pop('info', '提示', '银行地址未填写');
- } else if ($scope.deOrder.bankcode == null) {
- toaster.pop('info', '提示', '银行代码未填写');
- } else if ($scope.deOrder.salepocode == null) {
- toaster.pop('info', '提示', '合同编号未填写');
- } else if ($scope.deOrder.legalrepresent == null) {
- toaster.pop('info', '提示', '供应商方法定代表人未填写');
- } else if ($scope.deOrder.paycomname == null) {
- toaster.pop('info', '提示', '付款公司未填写');
- } else if ($scope.deOrder.paycomaddress == null) {
- toaster.pop('info', '提示', '付款公司地址未填写');
- } else if ($scope.deOrder.enfax == null) {
- toaster.pop('info', '提示', '供应商方法人电话未填写');
- } else if ($scope.deOrder.paydate == null) {
- toaster.pop('info', '提示', '货款支付时间未选择');
- } else if ($scope.deOrder.paymethod == null) {
- toaster.pop('info', '提示', '货款支付方式未填写');
- } else if ($scope.deOrder.deliverydate == null) {
- toaster.pop('info', '提示', '交货时间未选择');
- } else if (!$scope.orderCodeEnable) {
- toaster.pop('info', '提示', '采购单号重复');
- } else if ($scope.deOrder.currency == 'USD' && $scope.deOrder.totalpayament >= 300 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过300万美金');
- } else if ($scope.deOrder.currency == 'RMB' && $scope.deOrder.totalpayament >= 1000 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过1000万人民币');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (orderitem, index) {
- if (orderitem.prodname == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品名称未填写');
- } else if (orderitem.prodcode == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品编号未填写');
- } else if (orderitem.prodspec == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品规格未填写');
- } else if (orderitem.prodbrand == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品品牌未填写');
- } else if (orderitem.amount == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行数量未填写');
- } else if (orderitem.unitprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行单价未填写');
- } else if (orderitem.purcprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行订单单价未填写');
- } else {
- $scope.checkresult = true;
- $scope.isSave = true;
- }
- })
- };
- }
- // 保存
- $scope.isSave = false;
- $scope.save = function (status) {
- $scope.deOrder.entrystatus = status;
- checkKeyword();
- if ($scope.checkresult) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- if ($scope.deOrder.deputyOrderItems[0].prodcode == null) {
- toaster.pop('info', '提示', '您还未填写任何商品信息');
- } else {
- DeputyOrder.saveDeOrder({}, $scope.deOrder, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', status + '成功');
- window.location.hash = "#/purc/deputy/" + data.id;
- }
- if (data.error) {
- toaster.pop('error', '提示', status + '失败');
- }
- }, function (response) {
- });
- }
- }
- }
- $scope.openDatePicker = function ($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
- }]);
- // 代采企业供应商
- app.controller('DbfindDeputyVendorInfoCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', 'deputyuu', 'DeputyOrder', 'BaseService', 'ngTableParams', function ($scope, toaster, $upload, $modalInstance, deputyuu, DeputyOrder, BaseService, ngTableParams) {
- $scope.prod = false;
- BaseService.scrollBackToTop();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.keyword = keyword;
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.enuu = deputyuu;
- DeputyOrder.vendors.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.checkVendor = function (vendor) { // 直接选择
- $modalInstance.close(vendor);
- }
- }]);
- // 代采企业付款企业
- app.controller('DbfindDeputyPayCompanyCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', 'deputyuu', 'DeputyOrder', 'BaseService', 'ngTableParams', function ($scope, toaster, $upload, $modalInstance, deputyuu, DeputyOrder, BaseService, ngTableParams) {
- DeputyOrder.paycompanies({enuu: deputyuu}, {}, function (data) {
- $scope.paycompanies = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- $scope.select = function (company) { // 直接选择
- $modalInstance.close(company);
- }
- }]);
- /**
- * 代采订单批量导入
- */
- app.controller('DeputyOrderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function () {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'deputyOrder/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- toaster.pop('error', response.data || response);
- });
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'deputyOrder/upload/template';
- };
- $scope.enSure = function () {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 代采详情
- */
- app.controller('DeputyOrderDetailCtrl', ['$scope', 'toaster', 'DeputyOrder', '$stateParams', 'ngTableParams', 'BaseService', '$modal', 'DecimalNumber', 'CurrentRole', 'DekeyValue', function ($scope, toaster, DeputyOrder, $stateParams, ngTableParams, BaseService, $modal, DecimalNumber, CurrentRole, DekeyValue) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- DeputyOrder.getOrderDetail({id: $stateParams.id}, {}, function (data) {
- $scope.deOrder = data;
- $scope.deOrder.$editing = true;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- loadData();
- //默认采购单号不重复
- $scope.orderCodeEnable = true;
- // 查询历史供应商
- DeputyOrder.hisvendors({}, function (data) {
- $scope.hisvendors = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- // 代采企业列表
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEnterprises = data;
- $scope.deOrder.deputyname = $scope.deputyEnterprises[0].deputyenname;
- $scope.deOrder.deputyuu = $scope.deputyEnterprises[0].deputyenuu;
- getPayMethod($scope.deOrder.deputyuu, 'paymentmethod');
- });
- var getPayMethod = function(enuu, key) {
- // 获取我方付款支付方式默认值
- DekeyValue.getValue({enuu: enuu, key: key}, function(data) {
- $scope.methods = data.content;
- });
- }
- // 更新代采企业时更新费率
- $scope.change = function (deputyname) {
- DeputyOrder.deputyEnterprise({}, function (data) {
- $scope.deputyEn = data;
- angular.forEach($scope.deputyEn, function (en) {
- if (deputyname == en.deputyenname) {
- $scope.deputyuu = en.deputyenuu;
- getPayMethod($scope.deputyuu, 'paymentmethod');
- }
- });
- });
- }
- // 设置付款企业信息
- $scope.setPayComName = function() {
- // 针对信扬客户,如果是RMB赋值默认值
- if ($scope.deOrder.currency == 'RMB' && $scope.deOrder.deputyuu == 10044118) {
- $scope.deOrder.paycomname = '深圳信扬国际经贸股份有限公司';
- $scope.deOrder.paycomaddress= '深圳市前海深港合作区前湾一路1号A栋201室(入驻深圳市前海商务秘书有限公司)';
- }
- }
- // 查找付款企业
- $scope.dbfindPayCompany = function (deputyuu) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/payCompany.html',
- controller: 'DbfindDeputyPayCompanyCtrl',
- resolve: {
- deputyuu: function () {
- return deputyuu
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.deOrder.paycomname = data.enname;
- $scope.deOrder.paycomaddress = data.address;
- })
- }
- // 删除明细
- $scope.del = function (index, id) {
- DeputyOrder.deleteProdById({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.deOrder.deputyOrderItems.splice(index, 1)
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- //增加商品
- $scope.add = function (index) {
- if ($scope.deOrder.deputyOrderItems[index].prodcode == null) {
- toaster.pop('info', '提示', '请先填写商品信息');
- } else {
- $scope.deOrder.deputyOrderItems.push(
- {
- prodname: null,
- prodcode: null,
- prodspec: null,
- prodbrand: null,
- amount: null,
- unitprice: null,
- remark: null,
- orderprice: null
- });
- }
- };
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'DeputyOrderUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (data) {
- $scope.deOrder.deputyOrderItems.push(data);
- for (var i = 0; i < $scope.deOrder.deputyOrderItems.length; i++) {
- if ($scope.deOrder.deputyOrderItems[i].prodname == null) { // 如果没有填写就删除这行数据
- $scope.deOrder.deputyOrderItems.splice(i, 1);
- }
- }
- })
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }, function () {
- });
- }
- //删除商品
- $scope.delItem = function (index) {
- $scope.deOrder.deputyOrderItems.splice(index, 1);
- };
- var getService = function () {
- return DeputyOrder.getProdList;
- };
- $scope.update = function () {
- $scope.deOrder.$editing = true;
- }
- $scope.cancel = function () {
- $scope.deOrder.$editing = false;
- }
- // 检验订单编号是否存在
- $scope.checkOrder = function (salecode, deputyuu) {
- DeputyOrder.checkOrders({salecode: salecode, deputyuu: deputyuu}, {}, function (data) {
- $scope.orderCodeEnable = true;
- if (data.info) {
- toaster.pop('error', '提示', data.info);
- $scope.orderCodeEnable = false;
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- //计算采购单价
- $scope.checkPrice = function (rate) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- if (rate == null) {
- toaster.pop('info', '提示', '请先填入税率');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- item.purcprice = DecimalNumber.accMul(item.unitprice, (1 + rate / 100));
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- }
- }
- // 获取订单总价
- $scope.totalPrice = function () {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- if(item.amount != null && item.unitprice != null && item.purcprice != null) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- }
- });
- }
- $scope.checkresult = false;
- var checkKeyword = function () {
- if ($scope.deOrder.madealdate == null) {
- toaster.pop('info', '提示', '主协议签订日期未选择');
- } else if ($scope.deOrder.madealcode == null) {
- toaster.pop('info', '提示', '主协议签订编号未填写');
- } else if ($scope.deOrder.tervendor == null) {
- toaster.pop('info', '提示', '终端供应商名称未填写');
- } else if ($scope.deOrder.vendtel == null) {
- toaster.pop('info', '提示', '电话号码未填写');
- } else if ($scope.deOrder.venduser == null) {
- toaster.pop('info', '提示', '联系人未填写');
- } else if ($scope.deOrder.shipdate == null) {
- toaster.pop('info', '提示', '供应商发货时间未选择');
- } else if ($scope.deOrder.goodspacking == null) {
- toaster.pop('info', '提示', '货物包装要求未填写');
- } else if ($scope.deOrder.deliverymethod == null) {
- toaster.pop('info', '提示', '供应商交货方式未填写');
- } else if ($scope.deOrder.pickupmethod == null) {
- toaster.pop('info', '提示', '我方提货方式未填写');
- } else if ($scope.deOrder.paymentmethod == null) {
- toaster.pop('info', '提示', '我方付款方式未填写');
- } else if ($scope.deOrder.pickupdate == null) {
- toaster.pop('info', '提示', '我方提货时间未选择');
- } else if ($scope.deOrder.currency == null) {
- toaster.pop('info', '提示', '交易币别未选择');
- } else if ($scope.deOrder.deputyuu == null) {
- toaster.pop('info', '提示', '代采企业未选择');
- } else if ($scope.deOrder.salecode == null) {
- toaster.pop('info', '提示', '订单编号未填写');
- } else if ($scope.deOrder.paydeldate == null) {
- toaster.pop('info', '提示', '我方付款提货时间未选择');
- } else if ($scope.deOrder.riskmethod == null) {
- toaster.pop('info', '提示', '风险承担方式未填写');
- } else if ($scope.deOrder.taxpaymentmethod == null) {
- toaster.pop('info', '提示', '运、税费承担方式');
- } else if ($scope.deOrder.tervendaddress == null) {
- toaster.pop('info', '提示', '终端供应商地址未填写');
- } else if ($scope.deOrder.companyname == null) {
- toaster.pop('info', '提示', '公司全称(英文)未填写');
- } else if ($scope.deOrder.requirepaydate == null) {
- toaster.pop('info', '提示', '要求付汇日期未选择');
- } else if ($scope.deOrder.bankname == null) {
- toaster.pop('info', '提示', '银行名称(英文)未填写');
- } else if ($scope.deOrder.bankaccount == null) {
- toaster.pop('info', '提示', '银行账号未填写');
- } else if ($scope.deOrder.bankaddress == null) {
- toaster.pop('info', '提示', '银行地址未填写');
- } else if ($scope.deOrder.bankcode == null) {
- toaster.pop('info', '提示', '银行代码未填写');
- } else if ($scope.deOrder.salepocode == null) {
- toaster.pop('info', '提示', '合同编号未填写');
- } else if ($scope.deOrder.legalrepresent == null) {
- toaster.pop('info', '提示', '供应商方法定代表人未填写');
- } else if ($scope.deOrder.paycomname == null) {
- toaster.pop('info', '提示', '付款公司未填写');
- } else if ($scope.deOrder.paycomaddress == null) {
- toaster.pop('info', '提示', '付款公司地址未填写');
- } else if ($scope.deOrder.enfax == null) {
- toaster.pop('info', '提示', '供应商方法人电话未填写');
- } else if ($scope.deOrder.paydate == null) {
- toaster.pop('info', '提示', '货款支付时间未选择');
- } else if ($scope.deOrder.paymethod == null) {
- toaster.pop('info', '提示', '货款支付方式未填写');
- } else if ($scope.deOrder.deliverydate == null) {
- toaster.pop('info', '提示', '交货时间未选择');
- } else if (!$scope.orderCodeEnable) {
- toaster.pop('info', '提示', '采购单号重复');
- } else if ($scope.deOrder.currency == 'USD' && $scope.deOrder.totalpayament >= 300 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过300万美金');
- } else if ($scope.deOrder.currency == 'RMB' && $scope.deOrder.totalpayament >= 1000 * 10000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过1000万人民币');
- } else {
- angular.forEach($scope.deOrder.deputyOrderItems, function (orderitem, index) {
- if (orderitem.prodname == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品名称未填写');
- } else if (orderitem.prodcode == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品编号未填写');
- } else if (orderitem.prodspec == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品规格未填写');
- } else if (orderitem.prodbrand == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行产品品牌未填写');
- } else if (orderitem.amount == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行数量未填写');
- } else if (orderitem.unitprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行单价未填写');
- } else if (orderitem.purcprice == null) {
- toaster.pop('info', '提示', '订单明细第' + (index + 1) + '行订单单价未填写');
- } else {
- $scope.checkresult = true;
- $scope.isSave = true;
- }
- });
- }
- }
- // 保存
- $scope.isSave = false;
- $scope.save = function (status) {
- checkKeyword();
- if ($scope.checkresult) {
- $scope.deOrder.totalamount = 0;
- $scope.deOrder.usdpayment = 0;
- $scope.deOrder.orderamount = 0;
- $scope.deOrder.totalpayament = 0;
- angular.forEach($scope.deOrder.deputyOrderItems, function (item) {
- $scope.deOrder.totalamount += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.usdpayment += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.totalpayament += DecimalNumber.accMul(item.amount, item.unitprice);
- $scope.deOrder.orderamount += DecimalNumber.accMul(item.amount, item.purcprice);
- });
- if ($scope.deOrder.deputyOrderItems[0].prodcode == null) {
- toaster.pop('info', '提示', '您还未填写任何商品信息');
- } else {
- $scope.deOrder.entrystatus = status;
- DeputyOrder.saveDeOrder({}, $scope.deOrder, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '保存成功');
- loadData();
- window.location.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function (response) {
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- $scope.openDatePicker = function ($event, deOrder, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- deOrder[openParam] = !deOrder[openParam];
- };
- //复制采购单
- $scope.copyorder = function (id) {
- DeputyOrder.copyOrder({id: id}, {}, function (data) {
- if (data.id) {
- toaster.pop('success', '提示', '复制生成单据成功');
- window.location.hash = "#/purc/deputy/" + data.id;
- }
- if (data.error) {
- toaster.pop('error', '提示', '保存失败');
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 删除代采订单
- $scope.clear = function (id) {
- DeputyOrder.clearOrder({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- window.location.hash = "#/purc/deputy";
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 代采错误日志
- */
- app.controller('DeputyOrderLogCtrl', ['$scope', 'DeputyOrder', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', function ($scope, DeputyOrder, ngTableParams, $filter, BaseService, toaster, $timeout) {
- BaseService.scrollBackToTop();
- var getService = function () {
- return DeputyOrder.getRepetitions;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //删除
- $scope.deleteById = function (id) {
- GetProductInfo.deleteById({id: id}, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function (response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
- }]);
- /**
- * 招标单
- */
- app.controller('PurcTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams',
- '$modal', '$rootScope', 'PurcTenderInfo', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, PurcTenderInfo) {
- BaseService.scrollBackToTop();
- $scope.searchStatus = false;
- if ($rootScope.tenderActive) {
- $scope.active = $rootScope.tenderActive;
- $rootScope.tenderActive = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getTenderStatus = function (active) {
- var fn = 'getMyAll';
- switch (active) {
- case 'done':
- fn = 'getMyDone';
- break;
- case 'todo':
- fn = 'getMyTodo';
- break;
- // case 'end':
- // fn = 'getMyEnd';break;
- case 'waiting':
- fn = 'getMyWaiting';
- break;
- }
- return fn;
- };
- var getService = function () {
- if ($scope.searchStatus) {
- return PurcTender;
- }
- return PurcTenderInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getTenderStatus($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcTender.getPurcUnreadCount(null, function(data){
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcTender.setPurcRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- //获取未读单据id
- var getUnreadIds = function (){
- PurcTender.getPurcUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- //判断单据是否未读
- $scope.isUnread = function (tender){
- for (var i in $scope.unreadCode) {
- if (tender.id == $scope.unreadCode[i]) {
- var flag = tender.status == '待评标' && tender.overdue == 1 && tender.result != 1;
- if (!flag) {
- $scope.unreadCode.splice(i,1);
- return false;
- }
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.searchStatus = true;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 新增招标单
- */
- app.controller('PurcNewTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'ShipAddress', '$http', 'AuthenticationService', 'KindAPI', 'BrandActiveAPI', 'Search', 'ComponentActiveAPI', 'GetProductInfo', 'Vendor', 'PurcProduct', 'PurcProductNewest', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, ShipAddress, $http, AuthenticationService, KindAPI, BrandActiveAPI, Search, ComponentActiveAPI, GetProductInfo, Vendor, PurcProduct, PurcProductNewest) {
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcProduct : PurcProductNewest;
- };
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //在产品列表添加商品
- $scope.check = function (product) {
- $scope.tenderProd.push({
- prodTitle: product.title,
- prodCode: product.code,
- brand: product.brand,
- unit: product.unit,
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- });
- for (var i = 0; i < $scope.tenderProd.length; i++) {
- if ($scope.tenderProd[i].prodCode === null && $scope.tenderProd[i].prodTitle === null) { // 如果没有填写就删除这行数据
- $scope.tenderProd.splice(i, 1);
- }
- }
- };
- $scope.loading = false;
- // 获取收货地址列表
- var loadShipAddress = function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.tender.shipadd = $scope.ships[0];
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- // 可选的证照要求
- $scope.certificates = [{name: '三/五证合一'}, {name: '营业执照'}, {name: '组织机构代码证'}, {name: '一般纳税人证明材料'}, {name: '统计登记证'}, {name: '社会保险登记证'}];
- // 处理证照要求
- var parseCertificate = function (a) {
- if (a) {
- var arr = a.split(',');
- angular.forEach(arr, function (app) {
- var contained = false;
- angular.forEach($scope.certificates, function ($app) {
- if ($app.name == app) {
- $app.checked = true;
- contained = true;
- }
- });
- if (!contained) {
- $scope.certificates.push({name: app, checked: true});
- }
- });
- }
- };
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function (value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function (value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- // 选择类目
- $scope.selectKind = function (prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function () {
- return $scope.actives;
- }
- }
- }).result.then(function (data) {
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function () {
- });
- };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function (brand, prod) {
- if (brand instanceof String) {
- prod.brand = brand;
- } else if (brand instanceof Object) {
- prod.brand = brand.brandCn;
- }
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function (prod) { //打开模态
- var modalInstance = $modal.open({
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller: 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function () {// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function (brand) {
- prod.brand = brand.nameCn;
- }, function (reason) {
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function (cmp, prod) {
- ComponentActiveAPI.get({uuid: cmp.uuid}, {}, function (data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.brand = data.brand.nameCn;
- }, function (res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- $scope.condition = {dateZone: 1};
- $scope.tenderProd = [];
- var prod = {
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- };
- $scope.tender = {
- date: new Date(),
- unit: 'PCS',
- currency: 'RMB',
- ifOpen: 1,
- ifTax: 1,
- invoiceType: 2,
- tenderAttachs: [{}]
- };
- //
- $scope.tenderProd.push(prod);
- //增加商品
- $scope.add = function (index) {
- $scope.tenderProd.push({
- prodTitle: null,
- prodCode: null,
- brand: null,
- unit: 'PCS',
- qty: null
- // 供应商企业信息
- // enterpriseBaseInfo: [{}]
- });
- };
- //删除商品
- $scope.del = function (index) {
- $scope.tenderProd.splice(index, 1);
- };
- // 批量导入
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcTenderUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- // 获取上传的产品明细,前台展示
- angular.forEach(data, function (data) {
- $scope.tenderProd.push(data);
- for (var i = 0; i < $scope.tenderProd.length; i++) {
- if ($scope.tenderProd[i].prodTitle == null) { // 如果没有填写就删除这行数据
- $scope.tenderProd.splice(i, 1);
- }
- }
- });
- }, function () {
- });
- };
- $scope.isSave = false;
- // 已存在id的为查看招标单(用于在录入的招标单的发布和删除)
- if (!angular.isUndefined($stateParams.id)) {
- $scope.isSave = true; // 用于判断是新增还是已保存
- $scope.loading = true;
- PurcTender.getPurcTenderDetail({id: $stateParams.id}, function (data) {
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- parseCertificate($scope.tender.certificate);
- $scope.firstProd = data.purchaseTenderProds[0];
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function (item) {
- // 获取供应商联系人
- Vendor.contacts({venduu: item.saleTender.vendUU}, {}, function (data) {
- item.saleTender.enterpriseBaseInfo.contacts = data;
- // item.saleTender.enterpriseBaseInfo.contact = data[0];
- angular.forEach(item.saleTender.enterpriseBaseInfo.contacts, function (contact) {
- if (item.saleTender.userTel === contact.tel) {
- item.saleTender.enterpriseBaseInfo.contact = contact;
- }
- });
- });
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, item.saleTender.enterpriseBaseInfo);
- } else {
- $scope.tenderProd.enterpriseBaseInfo.push(item.saleTender.enterpriseBaseInfo);
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- if (angular.isUndefined($stateParams.id)) { // 发布招标单之后,再次新增招标单时,新增供应商时不会勾选上一个单据选择的供应商
- $rootScope.tenderVendor = [{}];
- }
- $scope.changeShipAddress = false;
- $scope.changeAddress = function () {
- if ($scope.changeShipAddress) {
- $scope.changeShipAddress = false;
- } else {
- $scope.changeShipAddress = true;
- }
- };
- $scope.changeContactInfo = function (en) {
- if (en.changeContact) {
- en.changeContact = false;
- } else {
- en.changeContact = true;
- }
- };
- $scope.changeCurrency = function (tender) {
- if (tender.currency !== 'RMB') {
- $scope.notRMB = true;
- tender.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- tender.invoiceType = 0;
- } else {
- $scope.notRMB = false;
- }
- };
- // 查找供应商
- $scope.dbfindVendor = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/tender_vendor.html',
- controller: 'DbfindVendorCtrl',
- size: 'lg',
- resolve: {}
- });
- var ifPush = true;
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (vendor) {
- // 获取供应商联系人
- Vendor.contacts({venduu: vendor.vendorEnterprise.uu}, {}, function (data) {
- vendor.vendorEnterprise.contacts = data;
- $scope.tenderProd.enterpriseBaseInfo.contact = vendor.vendorEnterprise.contacts[0];
- });
- if (!$scope.tenderProd.enterpriseBaseInfo) {// 不存在就先创建
- $scope.tenderProd.enterpriseBaseInfo = [{}];
- // 获取供应商联系人
- $scope.tenderProd.enterpriseBaseInfo.splice(0, 1, vendor.vendorEnterprise);
- } else {
- for (var i = 0; i < $scope.tenderProd.enterpriseBaseInfo.length; i++) {
- ifPush = true;
- if ($scope.tenderProd.enterpriseBaseInfo[i].enName == vendor.vendorEnterprise.enName) {
- ifPush = false;
- break; // 判定到已存在供应商,就终止循环。
- }
- }
- if (ifPush) {
- $scope.tenderProd.enterpriseBaseInfo.push(vendor.vendorEnterprise);
- }
- }
- });
- $rootScope.tenderVendor = $scope.tenderProd.enterpriseBaseInfo;
- }, function () {
- });
- };
- // 新增供应商联系人
- $scope.addContact = function (en) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/modal/contact_person_modal.html',
- controller: 'AddContacCtrl',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- en.contact = data;
- en.contact.venduu = en.uu;
- Vendor.saveContact({}, en.contact, function (data) {
- Vendor.contacts({venduu: en.uu}, {}, function (data) {
- en.contacts = data;
- en.contact = data[0]; // 新增的作为联系人
- });
- toaster.pop('success', '提示', '联系人保存成功');
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- });
- };
- // 删除一个供应商
- $scope.removeVendor = function (index) {
- $scope.tenderProd.enterpriseBaseInfo.splice(index, 1);
- };
- // 删除供应商时,后台删除投标单
- $scope.removeSaleTender = function (id, vendUU) {
- var hasSaved = false;
- angular.forEach($scope.tender.purchaseTenderProds[0].saleTenderItems, function (saleTenderItem) {
- if (saleTenderItem.saleTender.vendUU === vendUU) { //有相等的说明是之前保存过的供应商
- hasSaved = true;
- }
- });
- if (hasSaved) {
- PurcTender.removeSaleTender({id: id, vendUU: vendUU}, {}, function (data) {
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- };
- // 删除产品明细时,后台删除产品明细
- $scope.deleteProd = function (tenderProd) {
- if (tenderProd.id) {
- PurcTender.deleteProd({tenderProdId: tenderProd.id}, {}, function (data) {
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- };
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- $scope.upload = function (myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderAttach',
- file: file,
- method: 'POST'
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function (id, index) {
- $scope.attaches.splice(index, 1);
- };
- var sleep = function (d) {
- for (var t = Date.now(); Date.now() - t <= d;);
- };
- // 保存和发布招标单
- $scope.save = function (isPublish) {
- if ($scope.tender.ifOpen == 0 && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info', '提示', '请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function (certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if (!$scope.tender.code) { //新增,设单号
- $scope.tender.code = 'ZB' + $filter('date')(new Date(), 'yyMMddHHmmss');
- }
- if ($scope.tender.date instanceof Date) {
- $scope.tender.date = $scope.tender.date.getTime();
- }
- if ($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if ($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- if ($scope.tender.questionEndDate instanceof Date) {
- $scope.tender.questionEndDate = $scope.tender.questionEndDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- var enInfos = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function (enterpriseBaseInfo) {
- var enInfo = {
- uu: null,
- contact: null,
- contactTel: null
- };
- enInfo.uu = enterpriseBaseInfo.uu;
- if (typeof enterpriseBaseInfo.contact !== 'undefined') {
- enInfo.contact = enterpriseBaseInfo.contact.venduser;
- enInfo.contactTel = enterpriseBaseInfo.contact.tel;
- }
- enInfos.push(enInfo);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- $scope.tender.isPublish = 1;
- PurcTender.publish({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- // sleep(1500); //当前方法暂停1.5秒
- $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- $scope.tender.isPublish = 0;
- PurcTender.save({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- $scope.loading = false;
- // sleep(1500); //当前方法暂停1.5秒 给更新索引留点时间
- toaster.pop('success', '成功', '保存成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- // 切换为在平台公开招标时,清除掉已添加的供应商信息
- $scope.removeChecked = function () {
- if ($scope.tenderProd.enterpriseBaseInfo.size > 0) {
- $scope.tenderProd.enterpriseBaseInfo = [];
- }
- };
- // 删除(在录入状态)
- $scope.deleteThis = function (id) {
- PurcTender.deleteOne({id: id}, {}, function (data) {
- toaster.pop('info', '提示', '删除成功');
- window.location.hash = '#/purc/tender';
- });
- };
- // 更新和发布(在录入状态)
- $scope.updateSaved = function (isPublish) {
- if (Number($scope.tender.ifOpen) === 0 && (!$scope.tenderProd.enterpriseBaseInfo || $scope.tenderProd.enterpriseBaseInfo.length === 0)) { // 指定供应商招标,而未选择供应商时
- toaster.pop('info', '提示', '请先指定供应商');
- } else {
- $scope.loading = true;
- // --组装证照要求
- var myCertificate = [];
- angular.forEach($scope.certificates, function (certificate) {
- if (certificate.checked) {
- myCertificate.push(certificate.name);
- }
- });
- $scope.tender.certificate = myCertificate.join(',');
- if ($scope.tender.endDate instanceof Date) {
- $scope.tender.endDate = $scope.tender.endDate.getTime();
- }
- if ($scope.tender.publishDate instanceof Date) {
- $scope.tender.publishDate = $scope.tender.publishDate.getTime();
- }
- $scope.tender.purchaseTenderProds = $scope.tenderProd;
- for (var i = 0; i < $scope.tender.purchaseTenderProds.length; i++) {
- $scope.tender.purchaseTenderProds[i].index = i + 1;
- }
- $scope.tender.tenderAttaches = $scope.attaches;
- if ($scope.tender.shipadd) {
- $scope.tender.shipAddress = $scope.tender.shipadd.address + $scope.tender.shipadd.addressdet + ' ' + $scope.tender.shipadd.receiver + ' ' + $scope.tender.shipadd.usertel;
- }
- angular.forEach($scope.tender.purchaseTenderProds, function (tenderProd) {
- tenderProd.saleTenderItems = []; // 投标相关不用传参,否则会超长
- });
- var enInfos = [];
- angular.forEach($scope.tenderProd.enterpriseBaseInfo, function (enterpriseBaseInfo) {
- var enInfo = {
- uu: null,
- contact: null,
- contactTel: null
- };
- enInfo.uu = enterpriseBaseInfo.uu;
- if (typeof enterpriseBaseInfo.contact !== 'undefined') {
- enInfo.contact = enterpriseBaseInfo.contact.venduser;
- enInfo.contactTel = enterpriseBaseInfo.contact.tel;
- }
- enInfos.push(enInfo);
- });
- if (isPublish) { // 发布
- toaster.pop('info', '提示', '正在发布,请稍候');
- PurcTender.publishSaved({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '发布成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '发布失败', response.data);
- });
- } else { // 保存
- toaster.pop('info', '提示', '正在保存,请稍候');
- PurcTender.updateSaved({tender: $scope.tender, enInfos: enInfos}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '保存成功');
- window.location.reload();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- };
- $scope.currentDay = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.getMinDate = function () {
- if ($scope.tender.endDate instanceof Date) {
- var minDate = new Date($scope.tender.endDate.getTime() + 2 * 24 * 60 * 60 * 1000 + 1); // 公布结果日期与截止报价日期至少隔一天
- }
- return $scope.tender.endDate ? $filter('date')(minDate, 'yyyy-MM-dd') : $filter('date')(new Date(new Date().getTime() + 24 * 60 * 60 * 1000 + 1), 'yyyy-MM-dd');
- };
- $scope.getMaxDate = function () {
- // var maxDate = angular.copy($scope.tender.publishDate);
- // maxDate = maxDate.setDate(maxDate.getDate() - 1);
- if ($scope.tender.publishDate instanceof Date) {
- var maxDate = new Date($scope.tender.publishDate.getTime() - 24 * 60 * 60 * 1000 - 1); // 至少提前两天
- }
- return $scope.tender.publishDate ? $filter('date')(maxDate, 'yyyy-MM-dd') : "";
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- //类目选择模态框(招标产品明细)
- app.controller('ProdKindChooseCtrl', ['$scope', 'KindAPI', 'actives', 'toaster', '$modalInstance', function ($scope, KindAPI, actives, toaster, $modalInstance) {
- $scope.actives = actives;
- $scope.kinds = [[], [], [], []];
- // 获取子类目
- var getChildren = function (pid, deep) {
- KindAPI.getChildren({parentId: pid}, function (data) {
- $scope.kinds[deep] = data;
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- };
- // 改变节点选中状态
- var changeStatus = function (item, deep) {
- var actives = [], level = 0;
- angular.forEach($scope.kinds, function (ks, i) {
- if (i > deep) {
- $scope.kinds[i] = [];
- } else {
- angular.forEach(ks, function (k, j) {
- if (i == deep) {
- if (k.id == item.id) {
- $scope.kinds[i][j].$active = true;
- actives.push(k);
- } else {
- k.$active = null;
- }
- } else {
- if (k.$active) {
- actives.push(k);
- }
- }
- });
- }
- });
- // 选择的节点
- $scope.actives = actives;
- $scope.active = item;
- // 当前可操作的层级
- if (deep < 3) {
- $scope.activeDeep = deep + 1;
- }
- };
- // 节点点击后获取子类目,节点被选中
- $scope.onItemClick = function (item, deep) {
- changeStatus(item, deep);
- if (!item.isLeaf) {
- getChildren(item.id, deep + 1);
- }
- };
- // 重新加载数据
- function reload(deep) {
- var pid;
- if (deep) {
- pid = $scope.actives[deep - 1].id;
- } else {
- pid = 0;
- deep = 0;
- }
- getChildren(pid, deep);
- }
- // 初始加载数据,获取第一层的类目
- if ($scope.actives) {
- angular.forEach($scope.actives, function (v, k) {
- KindAPI.getChildren({parentId: v.parentid}, function (data) {
- $scope.kinds[k] = data;
- angular.forEach($scope.kinds[k], function (kind, i) {
- if (kind.id == v.id) {
- $scope.kinds[k][i].$active = true;
- $scope.actives[k] = $scope.kinds[k][i];
- }
- })
- }, function (response) {
- toaster.pop('error', '获取子类目失败', response.data);
- });
- });
- } else {
- reload();
- }
- // 取消
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- // 确认选择
- $scope.check = function () {
- var a = {
- active: $scope.active,
- actives: $scope.actives
- };
- $modalInstance.close(a);
- };
- }]);
- //品牌选择模态框的controller
- app.controller('BrandModalInstanceCtrl', ['$scope', '$modalInstance', 'ngTableParams', 'BrandActiveAPI', 'BaseService', function ($scope, $modalInstance, ngTableParams, BrandActiveAPI, BaseService) {
- $scope.filter = {};
- $scope.brandsTableParams = new ngTableParams({
- page: 1,
- count: 6,
- sorting: {
- nameCn: 'asc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- var param = BaseService.parseParams(params.url());
- param.keyword = $scope.filter.keyword;
- var keyword = $scope.filter.keyword;
- // param.keyword = $scope.filter.keyword;
- BrandActiveAPI.getSimpleInfoPage(param, {}, function (page) {
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- }
- }, function () {
- });
- }
- });
- // 搜索
- $scope.search = function () {
- // $scope.brandsTableParams.filter({$: $scope.filter.keyword});
- $scope.brandsTableParams.page(1);
- $scope.brandsTableParams.reload();
- };
- // 选择
- $scope.select = function (brand) {
- $modalInstance.close(brand);
- };
- // 关闭
- $scope.cancel = function () {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 招标单批量导入
- */
- app.controller('PurcTenderUploadCtrl', ['$scope', 'toaster', '$upload', '$modalInstance', function ($scope, toaster, $upload, $modalInstance) {
- // 通过excel批量上传物料
- $scope.result = null;
- $scope.upload = function () {
- var file = $scope.myFiles[0];
- $upload.upload({
- url: 'tender/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- }).error(function (response) {
- toaster.pop('error', '提示', '上传失败,请检查填写格式');
- });
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadTenderProducts_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'tender/upload/template';
- };
- $scope.enSure = function () {
- $modalInstance.close($scope.result.items);
- }
- $scope.cancel = function () {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 评标
- */
- app.controller('PurcEvaluationCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'CurrentRole', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, CurrentRole) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.tenderItems = [];
- // 采购方获取评标单
- var evaluation = function () {
- $scope.loading = true;
- PurcTender.getPurcTenderDetail({id: $stateParams.id}, function (data) {
- data.$editing = false;
- $scope.tender = data;
- $scope.tableParams = new ngTableParams({}, {dataset: data});
- // $scope.tableParams.sorting($scope.sort.field, $scope.sort.desc);
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- evaluation();
- $scope.orderType = '';
- // $scope.dir = '-';
- // 改变排序顺序
- $scope.changeOrder = function (type) {
- $scope.orderType = type;
- };
- $scope.submit = function (tender) {
- var canSubmit = false;
- var hasDecide = false;
- angular.forEach(tender.purchaseTenderProds, function (tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function (saleTenderItem) {
- if (saleTenderItem.price && 0 !== saleTenderItem.saleTender.auditStatus && typeof saleTenderItem.applyStatus !== 'undefined') { // 只要存在报价的行,就需要对其中一个定标
- hasDecide = true;
- }
- });
- if (hasDecide) {
- canSubmit = true;
- }
- });
- if (!canSubmit) {
- toaster.pop('info', '提示', '您还有已投标未选定的产品!');
- } else {
- PurcTender.decide(tender, function () {
- toaster.pop('success', '确认成功');
- window.location.hash = '#/purc/tender';
- }, function (response) {
- toaster.pop('error', '确认失败', response.data);
- });
- }
- }
- }]);
- /**
- * 客户招标
- *
- */
- app.controller('SaleTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', 'PurcTenderInfo',
- function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise, PurcTenderInfo) {
- BaseService.scrollBackToTop();
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.searchStatus = false;
- /**
- * 改变类型
- */
- var getTypeCondition = function (zone, condition) {
- if (zone == -1) {
- condition.ifOpen = null;
- } else if (zone == 1) {
- condition.ifOpen = 1;
- } else {
- condition.ifOpen = 0;
- }
- };
- $scope.dateZoneText = '不限';
- $scope.typeText = '全部';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1, type: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeType = function (type) {
- $scope.condition.type = type;
- $scope.typeText = typeof type == 'undefined' ? '全部' : (type == -1 ? '全部' : (type == 1 ? '公开' : '指定'));
- getTypeCondition(type, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- if ($scope.searchStatus) {
- return PurcTender;
- }
- return PurcTenderInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- pt_ifopen: $scope.condition.ifOpen,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- angular.forEach(page.content, function (purcTender) {
- purcTender.vendorHasBid = false;
- angular.forEach(purcTender.purchaseTenderProds, function (tenderProd) {
- angular.forEach(tenderProd.saleTenderItems, function (saleTenderItem) {
- if ($scope.currentEn.uu === saleTenderItem.saleTender.vendUU) {
- tenderProd.currentItem = saleTenderItem;
- if (saleTenderItem.price && saleTenderItem.saleTender.auditStatus != 0) { //TODO 如果存在当前企业的投标明细已投标且不在已提交状态,即判断为已投标
- purcTender.vendorHasBid = true;
- }
- }
- });
- });
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //获得各分类未阅读数量
- var getUnreadCount = function () {
- PurcTender.getUnreadCount(null, function (data) {
- $scope.unread = data;
- });
- };
- getUnreadCount();
- //设置单据已读
- $scope.setOrdersRead = function (id) {
- // 如果单据本身已读,则不发送请求修改数据
- if (!$scope.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcTender.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- getUnreadCount();
- });
- };
- var getUnreadIds = function () {
- PurcTender.getUnreadIds({}, "", function (message) {
- $scope.unreadCode = message.content;
- });
- };
- getUnreadIds();
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.searchStatus = true;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 招标提问列表
- *
- */
- app.controller('SaleTenderQuestionListCtrl', ['$scope', '$filter', 'SaleTenderQuestion', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise',
- function ($scope, $filter, SaleTenderQuestion, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.searchStatus = false;
- /**
- * 改变类型
- */
- var getTypeCondition = function (zone, condition) {
- if (zone == -1) {
- condition.ifOpen = null;
- } else if (zone == 1) {
- condition.ifOpen = 1;
- } else {
- condition.ifOpen = 0;
- }
- };
- $scope.dateZoneText = '不限';
- $scope.typeText = '全部';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1, type: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeType = function (type) {
- $scope.condition.type = type;
- $scope.typeText = typeof type == 'undefined' ? '全部' : (type == -1 ? '全部' : (type == 1 ? '公开' : '指定'));
- getTypeCondition(type, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- //TODO 增加直接从数据库取方法之后修改
- var getService = function () {
- if ($scope.searchStatus) {
- return SaleTenderQuestion;
- }
- return SaleTenderQuestion;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //TODO 获得各分类未阅读数量
- //TODO 设置单据已读
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 投标单提问单详情
- */
- app.controller('SaleTenderQuestionDetailCtrl', ['$scope', 'toaster', 'BaseService', 'SaleTenderQuestion', '$stateParams'
- , function($scope, toaster, BaseService, SaleTenderQuestion, $stateParams){
- BaseService.scrollBackToTop();
- $scope.loading = true;
- var loadData = function () {
- SaleTenderQuestion.getDetail({id: $stateParams.id}, function(data){
- $scope.loading = false;
- $scope.question = data;
- } , function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败');
- });
- };
- loadData();
- }]);
- /**
- * 招标答疑列表
- *
- */
- app.controller('PurcTenderAnswerListCtrl', ['$scope', '$filter', 'SaleTenderQuestion', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise',
- function ($scope, $filter, SaleTenderQuestion, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todo';
- }
- $scope.searchStatus = false;
- /**
- * 改变类型
- */
- var getTypeCondition = function (zone, condition) {
- if (zone == -1) {
- condition.ifOpen = null;
- } else if (zone == 1) {
- condition.ifOpen = 1;
- } else {
- condition.ifOpen = 0;
- }
- };
- /**
- * 当前页面状态按钮过滤
- */
- var getAnswer = function (active) {
- var fn = 'getAllAnswer';
- switch (active) {
- case 'done':
- fn = 'getDoneAnswer';
- break;
- case 'todo':
- fn = 'getTodoAnswer';
- break;
- }
- return fn;
- };
- $scope.dateZoneText = '不限';
- $scope.typeText = '全部';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: 1, deliveryZone: -1, type: -1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeDeliveryZone = function (zone) {
- $scope.condition.deliveryZoneText = zone;
- $scope.deliveryZoneText = typeof zone == 'undefined' ? '不限' : (zone == -1 ? '不限' : (zone == 1 ? '一个月内' : '两个月内'));
- $scope.condition.$delievryZoneOpen = false;
- getDelveryCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.changeType = function (type) {
- $scope.condition.type = type;
- $scope.typeText = typeof type == 'undefined' ? '全部' : (type == -1 ? '全部' : (type == 1 ? '公开' : '指定'));
- getTypeCondition(type, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- //TODO 增加直接从数据库取方法之后修改
- var getService = function () {
- if ($scope.searchStatus) {
- return SaleTenderQuestion;
- }
- return SaleTenderQuestion;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- getService()[getAnswer($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //TODO 获得各分类未阅读数量
- //TODO 设置单据已读
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 招标答疑单详情
- */
- app.controller('PurcTenderAnswerDetailCtrl', ['$scope', 'toaster', 'BaseService', 'SaleTenderQuestion', '$stateParams', '$modal'
- , function($scope, toaster, BaseService, SaleTenderQuestion, $stateParams, $modal){
- BaseService.scrollBackToTop();
- $scope.loading = true;
- var loadData = function () {
- SaleTenderQuestion.getAnswerDetail({id: $stateParams.id}, function(data){
- $scope.loading = false;
- $scope.answer = data;
- var now = new Date();
- if ($scope.answer.questionEndDate < now.getTime()) {
- $scope.answer.questionEnd = 1;
- } else {
- $scope.answer.questionEnd = 0;
- }
- } , function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败');
- });
- };
- loadData();
- // 回答
- $scope.sendAnswer = function (){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/purc/tender_answer.html',
- controller: 'PurcTenderAnswerCtrl',
- size: 'lg',
- resolve: {
- answer: function () {
- return $scope.answer;
- } //传递当前答疑单到模态框Controller
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('success', '答疑成功');
- }, function () {
- });
- };
- }]);
- /**
- * 招标单答疑
- */
- app.controller('PurcTenderAnswerCtrl', ['$scope', 'answer','$modalInstance', '$upload', 'toaster', function($scope, answer, $modalInstance, $upload ,toaster){
- $scope.answer = answer;
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- //确认回答
- $scope.ok = function (form) {
- $scope.loading = true;
- var files = form.attachFile.$viewValue, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'tender/question/answer/send',
- method: 'POST',
- file: file,
- data: {
- json: $scope.answer
- }
- }).success(function (data) {
- $scope.loading = false;
- $modalInstance.close('success');
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '错误', '出现异常,答疑失败');
- });
- };
- }]);
- /**
- * 平台公开招标
- *
- */
- app.controller('SaleOpenTenderCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', 'AccountEnterprise', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, AccountEnterprise) {
- BaseService.scrollBackToTop();
- /**
- * 改变单据日期范围
- */
- var getTenderDateCondition = function (zone, condition) {
- var date = new Date();
- if (zone == -1) {
- condition.dateFrom = null;
- condition.dateTo = null;
- } else if (zone == 7) { // 一星期内
- date.setDate(date.getDate() - 7);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 1) { // 一个月内
- date.setMonth(date.getMonth() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 3) { // 三个月内
- date.setMonth(date.getMonth() - 3);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else if (zone == 6) { // 半年内
- date.setMonth(date.getMonth() - 6);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- } else { // 一年内
- date.setYear(date.getYear() - 1);
- condition.dateFrom = date;
- condition.dateTo = new Date();
- }
- };
- $scope.active = 'all';
- $scope.dateZoneText = '不限';
- $scope.deliveryZoneText = '不限';
- $scope.condition = {dateZone: -1};
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.condition.$dateZoneOpen = false;
- getTenderDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.parseDate = function (dateStr) {
- if (dateStr)
- return Date.parse(dateStr, 'yyyy-MM-dd');
- return new Date();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var getOpenState = function (active) {
- var fn = 'getOpenAll';
- switch (active) {
- case 'all':
- fn = 'getOpenAll';
- break;
- // case 'done':
- // fn = 'getOpenDone';break;
- case 'todo':
- fn = 'getOpenTodo';
- break;
- case 'end':
- fn = 'getOpenEnd';
- break;
- // case 'waiting':
- // fn = 'getOpenWaiting';break;
- }
- return fn;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'tender.endDate': 'desc',
- 'tender.enterprise.enName': 'asc',
- 'tender.code': 'asc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- PurcTender[getOpenState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.toDetail = function (id) {
- window.location.hash = '#/baseInfo/openTenderDetail/' + id;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- /**
- * 采购方查看供应商投标单
- */
- app.controller('SaleVendorTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope) {
- $scope.loading = true;
- PurcTender.getVendorSaleTenderDetail({tenderId: $stateParams.id, vendUU:$stateParams.vendUU}, function (data) {
- $scope.saleTender = data.saleTender;
- $scope.tender = data.tender;
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }]);
- /**
- * 查看投标单详情
- */
- app.controller('SaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', 'CurrentRole', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise, CurrentRole) {
- BaseService.scrollBackToTop();
- if (!$scope.attaches) {
- $scope.attaches = []; // 存放上传了的附件
- }
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- $scope.loading = true;
- PurcTender.getSaleTenderDetail({tenderId: $stateParams.id}, function (data) {
- $scope.saleTender = data.saleTender;
- $scope.tender = data.tender;
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- // 提问
- $scope.sendQuestion = function (){
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/tender_question.html',
- controller: 'SaleTenderQuestionCtrl',
- size: 'lg',
- resolve: {
- saleTender: function () {
- return $scope.saleTender;
- } //传递当前投标单到模态框Controller
- }
- });
- modalInstance.result.then(function () {
- toaster.pop('success', '提问成功');
- }, function () {
- });
- };
- $scope.upload = function (myFile) { // 上传附件
- var file = $scope.myFile, file = file && file.length > 0 ? file : null;
- $upload.upload({
- url: 'tender/addTenderItemAttach',
- file: file,
- method: 'POST'
- }).success(function (attach) {
- $scope.attaches.push(attach);
- });
- };
- $scope.removeAttach = function (attachId, index) {
- $scope.attaches.splice(index, 1);
- };
- var taxrateYes = false;
- var cycleYes = false;
- var priceYes = false;
- $scope.canSave = false;
- $scope.validateThis = function (value, type) {
- if ("" != value) {
- switch (type) {
- case 'taxrate':
- var regex = /^\+?[0-9][0-9]{0,1}$/;
- if (regex.test(value)) {
- taxrateYes = true;
- } else {
- toaster.pop('warning', '警告', '税率不合法,请重新填写');
- }
- break;
- case 'cycle':
- regex = /^\+?[1-9][0-9]*$/;
- if (regex.test(value)) {
- cycleYes = true;
- } else {
- toaster.pop('warning', '警告', '周期不合法,请重新填写');
- }
- break;
- case 'price':
- regex = /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- if (regex.test(value) && value !== 0) {
- priceYes = true;
- } else {
- toaster.pop('warning', '警告', '请确认单价是否填写正确');
- }
- break;
- }
- }
- };
- $scope.emNumYes = true;
- $scope.validEmNum = function (value) {
- var regex = /^\+?[1-9][0-9]*$/;
- if (!regex.test(value) || value === 0 || value !== null) {
- $scope.emNumYes = false;
- toaster.pop('warning', '警告', '人数不合法,请重新填写');
- }
- };
- $scope.validateProds = function (saleTender) {
- $scope.canSave = true;
- var cycleRegex = /^\+?[1-9][0-9]*$/;
- var taxrateRegex = /^\+?[0-9][0-9]{0,1}$/;
- var priceRegex = /^(([0-9]+\.[0-9]{1,6})|([0-9]*[1-9][0-9]*\.[0-9]{1,6})|([0-9]*[1-9][0-9]*))$/; // 非零最多六位小数正实数
- if ($scope.tender.ifAll == 1) { // 全包时需要所有信息都填写并合法才可以投标
- // 全包全部需要填写,且需要符合正则式
- angular.forEach(saleTender.saleTenderItems, function(item) {
- if ((!item.cycle || !item.price) || (!cycleRegex.test(item.cycle) || !priceRegex.test(item.price))) {
- $scope.canSave = false;
- }
- });
- if (!saleTender.cycle || !saleTender.taxrate || !cycleRegex.test(saleTender.cycle) || !taxrateRegex.test(saleTender.taxrate)) {
- $scope.canSave = false;
- }
- } else { // 非全包模式
- angular.forEach(saleTender.saleTenderItems, function(item) {
- if (item.cycle || item.taxrate || item.price) {
- // /^(0|[0-9][0-9]{0,9})(\.[0-9]{1,6})?$/;
- // 判断填写过的有为0或不符合正则式的,设置不能保存
- if (!cycleRegex.test(item.cycle) || !taxrateRegex.test(item.taxrate) || !priceRegex.test(item.price)) {
- $scope.canSave = false;
- } else {
- $scope.canSave = true;
- }
- }
- });
- }
- };
- // 投标
- $scope.bidIt = function (saleTender) {
- $scope.loading = true;
- if (saleTender.enterpriseBaseInfo.enEstablishDate instanceof Date) {
- saleTender.enterpriseBaseInfo.enEstablishDate = saleTender.enterpriseBaseInfo.enEstablishDate.getTime();
- }
- saleTender.bidAttaches.push.apply(saleTender.bidAttaches, $scope.attaches);
- angular.forEach(saleTender.saleTenderItems, function (item) {
- item.tenderProd = {};
- if ("" == item.price && "" == item.taxrate && "" == item.cycle) {
- item.price = 0;
- item.cycle = 0;
- item.taxrate = 0;
- }
- });
- PurcTender.reply({}, saleTender, function (data) {
- $scope.loading = false;
- toaster.pop('info', '成功', '投标成功');
- window.location.hash = '#/sale/tender';
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '投标失败', response.data);
- });
- };
- $scope.condition = {
- $fromOpened: false
- };
- $scope.getMaxDate = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- /**
- * 投标单提问
- */
- app.controller('SaleTenderQuestionCtrl', ['$scope', 'saleTender','$modalInstance', '$upload', 'toaster', function($scope, saleTender, $modalInstance, $upload ,toaster){
- $scope.saleTender = saleTender;
- // 当前日期,用作新增提问
- $scope.currentDay = new Date();
- $scope.question = {
- inDate : null,
- replyDate : null,
- topic : null,
- status : null,
- content : null,
- questionAttaches : []
- };
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- //确认提问
- $scope.ok = function (form) {
- $scope.loading = true;
- var files = form.attachFile.$viewValue, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'tender/question/send/' + $scope.saleTender.id,
- method: 'POST',
- file: file,
- data: {
- json: $scope.question
- }
- }).success(function (data) {
- $scope.loading = false;
- $modalInstance.close('success');
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '错误', '出现异常,提问失败');
- });
- };
- }]);
- /**
- * 公开招标转投标单
- */
- app.controller('OpenSaleTenderDetailCtrl', ['$scope', '$filter', 'PurcTender', 'ngTableParams', 'toaster', 'BaseService', '$stateParams', '$modal', '$rootScope', '$upload', 'AccountEnterprise', function ($scope, $filter, PurcTender, ngTableParams, toaster, BaseService, $stateParams, $modal, $rootScope, $upload, AccountEnterprise) {
- BaseService.scrollBackToTop();
- $scope.attaches = []; // 存放上传了的附件
- var sleep = function (d) {
- for (var t = Date.now(); Date.now() - t <= d;);
- }
- var getCurrentEn = function () {
- AccountEnterprise.get({}, function (data) {
- $scope.currentEn = data;
- });
- }
- if (!angular.isUndefined($stateParams.id)) { // 获取招标单详情
- $scope.loading = true;
- getCurrentEn();
- PurcTender.getPurcTenderDetail({id: $stateParams.id}, function (data) {
- data.$editing = false;
- $scope.tender = data;
- $scope.tenderProd = data.purchaseTenderProds;
- $scope.currentHasBid = false; // 默认当前企业未转投标单
- angular.forEach(data.purchaseTenderProds[0].saleTenderItems, function (item) {
- if ($scope.currentEn.uu === item.saleTender.vendUU) { // 存在当前企业为供应商的投标单,判断已转
- $scope.currentHasBid = true;
- }
- });
- $scope.loading = false;
- $scope.attaches = $scope.tender.tenderAttaches;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- $scope.hasClick = false;
- $scope.iWantToBid = function (id) {
- $scope.hasClick = true;
- PurcTender.addItems({id: id}, {}, function (data) { // 添加明细
- toaster.pop('success', '成功', '转投标单成功');
- window.location.hash = "#/sale/tender/" + id;
- }, function (response) {
- toaster.pop('error', '操作失败', response.data);
- });
- };
- }]);
- // 基础资料客户详情
- app.controller('CustomersInfoCtrl', ['$scope', 'VendorService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', 'VendorInfo', function ($scope, VendorService, BaseService, AuthenticationService, ngTableParams, $modal, toaster, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = 'customer';
- $scope.userInfoResult = true;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- });
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorService.customer.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- $scope.tip = keyword;
- };
- // 查看详情
- $scope.viewDetail = function (id) {
- window.location.hash = "#/sale/customer/" + id;
- }
- // 取消合作关系
- $scope.disableCust = function (id) {
- VendorInfo.disableCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 解除禁用
- $scope.activeCust = function (id) {
- VendorInfo.activeCust({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 基础资料供应商
- app.controller('VendorsInfoCtrl', ['$scope', 'Vendor', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', '$rootScope', 'VendorInfo', function ($scope, Vendor, BaseService, AuthenticationService, ngTableParams, $modal, toaster, $rootScope, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = 'vendor';
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getVendor.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 查看供应商详情
- $scope.VendorDetail = function (id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/" + $rootScope.vendorId;
- }
- // 向企业购买
- $scope.purcByEn = function (businessCode) {
- $rootScope.businessCode = businessCode;
- window.location.hash = "#/purc/addOrder";
- }
- // 取消合作关系
- $scope.relieve = function (id) {
- VendorInfo.relieve({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 建立合作关系
- $scope.activeVend = function (id) {
- VendorInfo.activeVend({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 基础资料服务商
- app.controller('ServicerInfoCtrl', ['$scope', 'Vendor', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', '$rootScope', 'VendorInfo', function ($scope, Vendor, BaseService, AuthenticationService, ngTableParams, $modal, toaster, $rootScope, VendorInfo) {
- BaseService.scrollBackToTop();
- $scope.status = 'servicer';
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.customerParams.page(1);
- $scope.customerParams.reload();
- };
- $scope.customerParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- Vendor.getServicer.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 查看服务商详情
- $scope.VendorDetail = function (id, uu) {
- $rootScope.vendorId = id;
- $rootScope.vendoruu = uu;
- window.location.hash = "#/purc/vendor/" + $rootScope.vendorId;
- };
- // 取消合作关系
- $scope.relieveServicer = function (id) {
- VendorInfo.relieveServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 建立合作关系
- $scope.activeServicer = function (id) {
- VendorInfo.activeServicer({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- }
- // $scope.customerParams.page(1);
- $scope.customerParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 企业圈搜索界面
- app.controller('AddPartnersCtrl', ['$scope', '$rootScope', function ($scope, $rootScope) {
- $scope.onSearch = function (keyword) {
- $rootScope.enterpriseKeyword = keyword;
- window.location.hash = "#/baseInfo/search?keyword=" + $rootScope.enterpriseKeyword;
- }
- }]);
- // 企业圈搜索结果
- app.controller('EnterpriseSearchCtrl', ['$scope', 'getAccountUserSpace', 'ngTableParams', '$filter', 'BaseService', 'toaster', 'AddPartner', '$rootScope', '$modal', 'InvitationRecord', function ($scope, getAccountUserSpace, ngTableParams, $filter, BaseService, toaster, AddPartner, $rootScope, $modal, InvitationRecord) {
- $scope.status = 'add';
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return getAccountUserSpace;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {}
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- if (keyword === '') {
- keyword = null;
- $rootScope.searchKeyword = keyword;
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- } else {
- $rootScope.searchKeyword = keyword;
- $scope.keyword = keyword;
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- };
- // 添加合作关系
- $scope.addPartner = function (name, businessCode) {
- AddPartner.addPartner({name: name, businessCode: businessCode}, {}, function (data) {
- if (data.success) {
- toaster.pop("success", '添加成功', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop("error", '添加失败', data.error);
- }
- }, function (response) {
- toaster.pop('error', '失败', response.data);
- });
- }
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function (name) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function () {
- return name
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- /**
- * 立即查看
- */
- $scope.view = function (name) {
- $rootScope.vendName = name;
- window.location.hash = "#/baseInfo/newPartner";
- }
- }]);
- // 平台新增的询价单(指定一个供应商)
- app.controller('PurcInquiryNewCtrl', ['$scope', 'PurchaseInquiry', 'toaster', 'BaseService', '$upload', '$filter', '$modal', '$rootScope', 'ngTableParams', 'GetProductInfo', '$timeout', '$http', 'ShipAddress', '$stateParams', 'Vendor', 'Product', 'Search', 'ComponentActiveAPI', 'VendorInfo', function ($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, GetProductInfo, $timeout, $http, ShipAddress, $stateParams, Vendor, Product, Search, ComponentActiveAPI, VendorInfo) {
- $scope.active = 'all';
- // 供应商信息
- var loadData = function () {
- Vendor.enterpriseInfo({bussinessCode: $stateParams.bussinessCode}, {}, function (data) {
- $scope.vendor = data;
- Vendor.contacts({venduu: $scope.vendor.uu}, {}, function (data) {
- $scope.vendorContacts = data;
- });
- // 物料信息
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- pageParams.custUU = $scope.vendor.uu;
- Product.get.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $scope.total = page.totalElement;
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy($scope.keyword);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- });
- };
- loadData();
- $rootScope.tenderVendor = null;// 清除掉已选择的
- var getService = function () {
- return GetProductInfo;
- };
- $scope.inquiry = {
- code: 'XJ' + $filter('date')(new Date(), 'yyMMddsss'),
- showdate: $filter('date')(new Date, 'yyyy-MM-dd'),
- priceType: '采购',
- isOpen: 0,
- invoice: 0,
- ifTax: 1,
- currency: 'RMB'
- };
- $scope.changeCurrency = function (inquiry) {
- if (inquiry.currency !== 'RMB') {
- $scope.notRMB = true;
- inquiry.ifTax = 0; // 非RMB时,默认不含税和不需要发票,且不可更改
- inquiry.invoice = 0;
- } else {
- $scope.notRMB = false;
- }
- };
- // 获取收货地址列表
- var loadShipAddress = function () {
- ShipAddress.shipAddList({}, function (data) {
- $scope.ships = data;
- $scope.inquiry.ship = $scope.ships[0].address + $scope.ships[0].addressdet + $scope.ships[0].receiver + $scope.ships[0].usertel;
- });
- };
- loadShipAddress();
- // 获取地址信息
- $http.get('resources/citydata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 新增收货地址保存
- $scope.saveShipAddress = function (ship) {
- ship.address = ship.province + ship.city + ship.district;
- ShipAddress.saveAddress({}, ship, function (data) {
- if (data.success) {
- // 获取收货地址列表
- loadShipAddress();
- toaster.pop('success', '提示', data.success);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- });
- };
- $scope.currentDay = function () {
- return $filter('date')(new Date(), 'yyyy-MM-dd');
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.inquiry.inquiryItems = [];
- var prod = {
- prodCode: null,
- prodTitle: null,
- inbrand: null,
- currency: 'RMB',
- toDate: null,
- unit: 'PCS'
- };
- $scope.inquiry.inquiryItems.push(prod);
- // 联想词start
- // 获取品牌联想词
- $scope.getSimilarBrands = function (value) {
- if (value) {
- // 获取品牌联想词
- return Search.getSimilarBrands({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 获取产品型号联想词
- $scope.getSimilarCodes = function (value) {
- if (value) {
- // 获取产品型号联想词
- return Search.getSimilarComponents({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- })
- });
- }
- };
- $scope.selectKind = function (prod) {
- var submit = [];
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/product_kindChoose_modal.html',
- controller: 'ProdKindChooseCtrl',
- resolve: {
- actives: function () {
- return $scope.actives;
- }
- }
- }).result.then(function (data) {
- $scope.actives = data.actives;
- var size = data.actives.length;
- submit.gradeOneKiName = '';
- submit.gradeTwoKiName = '';
- submit.gradeThreeKiName = '';
- if (size > 0) {
- submit.gradeOneKiName = $scope.actives[0].nameCn;
- prod.prodTitle = submit.gradeOneKiName;
- if (size > 1) {
- submit.gradeTwoKiName = $scope.actives[1].nameCn;
- prod.prodTitle = submit.gradeTwoKiName;
- if (size > 2) {
- submit.gradeThreeKiName = $scope.actives[2].nameCn;
- prod.prodTitle = submit.gradeThreeKiName;
- }
- }
- }
- }, function () {
- });
- };
- // 点击联想词获取品牌信息
- $scope.onAssociateBrandClick = function (brand, prod) {
- if (brand instanceof String) {
- prod.inbrand = brand;
- } else if (brand instanceof Object) {
- prod.inbrand = brand.brandCn;
- }
- };
- // 打开品牌选择的模态框
- $scope.selectBrand = function (prod) { //打开模态
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/product_brandChoose_modal.html', //指向上面创建的视图
- controller: 'BrandModalInstanceCtrl' // 初始化模态范围
- });
- modalInstance.opened.then(function () {// 模态窗口打开之后执行的函数
- });
- modalInstance.result.then(function (brand) {
- prod.inbrand = brand.nameCn;
- }, function (reason) {
- });
- };
- // 点击联想词获取器件信息 带入产品分类和品牌
- $scope.onAssociateCmpClick = function (cmp, prod) {
- ComponentActiveAPI.get({uuid: cmp.uuid}, {}, function (data) {
- $scope.component = data;
- prod.prodCode = data.code;
- prod.prodTitle = data.kind.nameCn;
- prod.inbrand = data.brand.nameCn;
- }, function (res) {
- toaster.pop('error', '提示', '产品信息加载失败,请刷新页面');
- })
- };
- //联想词end
- // 导入商品信息
- $scope.uplodaByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/purc/modal/uplodaByBatch.html',
- controller: 'PurcInquiryUploadCtrl',
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- angular.forEach(data, function (prod) {
- $scope.inquiry.inquiryItems.push(prod);
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- })
- }, function () {
- });
- }
- //增加商品
- $scope.add = function () {
- $scope.inquiry.inquiryItems.push(
- {
- prodCode: null,
- prodTitle: null,
- unit: 'PCS',
- ibrand: null,
- currency: 'RMB',
- toDate: null
- });
- };
- //删除商品
- $scope.del = function (index) {
- $scope.inquiry.inquiryItems.splice(index, 1);
- };
- // 搜索结果询价
- if ($rootScope.prodId) {
- VendorInfo.getProdInfo({id: $rootScope.prodId}, {}, function (data) {
- prod.prodCode = data.code;
- prod.prodTitle = data.title;
- prod.spec = data.spec;
- prod.unit = data.unit;
- prod.productId = data.id;
- prod.inbrand = data.brand;
- $scope.inquiry.inquiryItems.push(prod);
- $rootScope.prodId = null;// 清除掉prodId
- }, function (response) {
- });
- }
- $scope.check = function (product) {
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- if ($scope.inquiry.inquiryItems[i].prodCode == null) { // 如果没有填写就删除这行数据
- $scope.inquiry.inquiryItems.splice(i, 1);
- }
- }
- $scope.inquiry.inquiryItems.push({
- prodCode: product.code, prodTitle: product.title, spec: product.spec, unit: product.unit,
- currency: null, toDate: null, productId: product.id, inbrand: product.brand
- });
- }
- $scope.getMinDate = function (item) {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.inquiry.inquiryItems[index].$toDateOpen = !openParam;
- };
- $scope.openEndDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.ifrepeat = false;
- // 保存并提交
- $scope.submit = function () {
- $scope.loading = true;
- for (var i = 0; i < $scope.inquiry.inquiryItems.length; i++) {
- $scope.item = $scope.inquiry.inquiryItems[i];
- for (var j = 0; j < $scope.inquiry.inquiryItems.length; j++) {
- $scope.otheritem = $scope.inquiry.inquiryItems[j];
- if (i != j) {
- if ($scope.item.prodCode = $scope.otheritem.prodCode && $scope.item.prodTitle == $scope.otheritem.prodTitle
- && $scope.item.inbrand == $scope.otheritem.inbrand && $scope.item.needquantity == $scope.otheritem.needquantity
- && $scope.item.toDate.getTime() == $scope.otheritem.toDate.getTime()) {
- $scope.ifrepeat = true;
- }
- }
- }
- }
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $scope.vendors = [];
- $scope.vendors.push({
- enName: $scope.vendor.enName,
- enuu: $scope.vendor.uu,
- currency: $scope.vendor.currency,
- rate: $scope.vendor.rate
- });
- if (!$scope.ifrepeat) {
- $upload.upload({
- url: 'purc/inquiry/submit/withVendor',
- file: file,
- method: 'POST',
- data: {
- inquiry: $scope.inquiry,
- contacts: $scope.vendors
- },
- }).success(function (data) {
- if (data.success) {
- $scope.loading = false;
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- window.location.hash = "#/purc/purchaseinquiry";
- }, 500);
- }
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data) {
- $scope.loadingShow = false;
- toaster.pop('error', '操作失败', data.error);
- });
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', '存在条件相同的物料');
- }
- }
- }]);
- // 企业圈查询收到待处理的数目
- app.controller('RequestAmountCtrl', ['$scope', 'AddPartnerMyRequest', '$modal', 'InvitationRecord', 'toaster', function ($scope, AddPartnerMyRequest, $modal, InvitationRecord, toaster) {
- AddPartnerMyRequest.requestAmount({}, function (data) {
- $scope.requestTodo = data;
- });
- /**
- * 邀请注册商务平台
- */
- $scope.invite = function () {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/search/enterpirseInfo.html',
- controller: 'InviteCtrl',
- resolve: {
- enname: function () {
- return null
- }
- }
- });
- modalInstance.result.then(function (data) {
- InvitationRecord.invite({formStore: data}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- });
- }
- }]);
- // 当前企业所有的物料信息
- app.controller('ProductAllCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', 'ProductAllNewest', '$rootScope', 'prodUser', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, ProductAllNewest, $rootScope, prodUser) {
- BaseService.scrollBackToTop();
- $rootScope.ids = [];// 用来记录已经选择的物料
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? ProductAll : ProductAllNewest;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- standard: 'desc',
- id: 'desc',
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- $scope.checkall = true;
- if(page.content.length <= 2) {
- $scope.checkall = false;
- } else {
- angular.forEach(page.content, function (prod) {
- if ($rootScope.ids.indexOf(prod.id) > -1) {
- prod.$selected = true;
- } else {
- $scope.checkall = false;
- }
- });
- }
- $scope.checkboxes = {
- checked: $scope.checkall
- };
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 开启销售
- $scope.unlock = function (id) {
- $scope.loading = true;
- Products.unlock({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 关闭销售
- $scope.lock = function (id) {
- $scope.loading = true;
- Products.lock({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 开启购买
- $scope.unlockPurc = function (id) {
- $scope.loading = true;
- Products.unlockPurc({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 关闭购买
- $scope.lockPurc = function (id) {
- $scope.loading = true;
- Products.lockPurc({id: id}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- $scope.tableParams.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- // 一键匹配
- $scope.matchall = function () {
- $scope.type = "all";
- $scope.loading = true;
- Products.matchbytype({type: $scope.type}, {}, function (data) {
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- } else {
- toaster.pop('info', '提示', '匹配成功' + data.size + '个标准器件');
- window.location.href = "#/approvalFlow/productmatches";
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.checkboxes = {
- checked: false
- };
- angular.forEach($scope.tableParams.data, function (item) {
- $scope.checkboxes.checked = false;
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- $scope.checkboxes.checked = true;
- }
- });
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- if (!item.waiting) {
- item.$selected = $scope.checkboxes.checked;
- if(item.$selected) {
- if(!$rootScope.ids.in_array(item.id)) {
- $rootScope.ids.push(item.id);
- }
- } else {
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- }
- }
- }
- });
- };
- // 判断数组中是否存在某个对象
- Array.prototype.S = String.fromCharCode(2);
- Array.prototype.in_array = function(e) {
- var r = new RegExp(this.S + e + this.S);
- return (r.test(this.S + this.join(this.S) + this.S));
- }
- // 从数组中移除某个对象
- Array.prototype.remove = function(val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (product) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- if(product.$selected) {
- if(!$rootScope.ids.in_array(product.id)) {
- $rootScope.ids.push(product.id);
- }
- } else {
- if($rootScope.ids.in_array(product.id)) {
- $rootScope.ids.remove(product.id);
- }
- }
- $scope.checkboxes = {
- checked: result
- };
- };
- // 批量转入我的产品库
- $scope.addtoUserByCheck = function() {
- var ids = angular.copy($rootScope.ids);
- if($rootScope.ids.length == 0) {
- toaster.pop('error', '提示', '请先选择产品');
- } else {
- prodUser.coverToUserByIds({}, ids, function(data) {
- toaster.pop('success', '提示', '选择' + $rootScope.ids.length + '个产品,成功转入' + data.count + '个产品');
- $rootScope.ids = [];
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(res) {
- toaster.pop('error', '提示', '转入失败');
- });
- }
- }
- // 转入我的产品库
- $scope.addtoUser = function(id) {
- $scope.loading = true;
- prodUser.coverToUser({id: id}, {}, function(data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '转入成功');
- }, function(res) {
- $scope.loading = false;
- toaster.pop('error', '提示', '转入失败');
- });
- }
- }]);
- // 当前企业匹配的标准物料信息
- app.controller('ProductmatchesCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- if ($rootScope.productMatchStatus === 'sale') {
- return $scope.searchMethod ? Products.matchResultforSale : Products.newestMatchResultforSale;
- } else if ($rootScope.productMatchStatus === 'purc') {
- return $scope.searchMethod ? Products.matchResultforPurc : Products.newestMatchResultforPurc;
- } else {
- return $scope.searchMethod ? Products.matchResult : Products.newestMatchResult;
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- matchsize: 'asc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- if (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function (product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var ids = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.product = {
- checked: false
- };
- var checkResults = function (result) {
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function (item) {
- if (result.id == item.id) {
- if (item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
- // 单选明细
- $scope.checkItem = function (result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
- // 一键更新
- $scope.updateAll = function () {
- $scope.loading = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.checked) {
- if (product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function (item) {
- if (item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall({status: $scope.checks.checked, type: 'all'}, ids, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.loading = false;
- }, 500);
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 当前企业匹配的标准物料信息(销售)
- app.controller('ProductmatchesForSaleCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? Products.matchResultforSale : Products.newestMatchResultforSale;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- matchsize: 'asc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- if (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function (product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var ids = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.product = {
- checked: false
- };
- var checkResults = function (result) {
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function (item) {
- if (result.id == item.id) {
- if (item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
- // 单选明细
- $scope.checkItem = function (result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
- // 一键更新
- $scope.updateAll = function () {
- $scope.loading = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.checked) {
- if (product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function (item) {
- if (item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall({status: $scope.checks.checked, type: 'sale'}, ids, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.loading = false;
- }, 500);
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function (response) {
- $scope.loading = true;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- // 当前企业匹配的标准物料信息(采购)
- app.controller('ProductmatchesForPurcCtrl', ['$scope', 'ProductAll', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$rootScope', 'PurcProduct', 'GetProductInfo', function ($scope, ProductAll, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $rootScope, PurcProduct, GetProductInfo) {
- BaseService.scrollBackToTop();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? Products.matchResultforPurc : Products.newestMatchResultforPurc;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- matchsize: 'asc',
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- if (page) {
- $scope.loading = false;
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- angular.forEach(page.content, function (product) { // 每次进入判断全选状态,然后给单据赋状态
- ids = [];
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- $scope.total = page.totalElement;
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- var ids = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- ids = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.matchresults.length == 1) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- ids = [];// 每次选择时先清空,防止重复
- product.checked = !product.checked;
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.product = {
- checked: false
- };
- var checkResults = function (result) {
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.id == result.prid) {
- product.checked = false;
- angular.forEach(product.matchresults, function (item) {
- if (result.id == item.id) {
- if (item.checked) {
- product.checked = true;
- return;
- }
- } else {
- item.checked = false;
- }
- });
- }
- });
- // checkProductCheck();
- };
- var checkProductCheck = function () {
- var checked = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (!product.checked) {
- checked = false;
- }
- });
- $scope.product.checked = checked;
- }
- // 单选明细
- $scope.checkItem = function (result) {
- ids = [];
- result.checked = !result.checked;
- checkResults(result);
- }
- // 一键更新
- $scope.updateAll = function () {
- $scope.loading = true;
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.checked) {
- if (product.matchresults.length == 1) {
- ids.push(product.matchresults[0].id);
- }
- if (product.matchresults.length > 1) {
- angular.forEach(product.matchresults, function (item) {
- if (item.checked) {
- ids.push(item.id);
- }
- });
- }
- }
- });
- Products.updateall({status: $scope.checks.checked, type: 'purc'}, ids, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- $scope.loading = false;
- }, 500);
- }
- ids = []; // 清空ids,防止重复点击出现多余的数据
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- /**
- * 采购物料资料
- */
- app.controller('PurcProductCtrl', ['$scope', 'PurcProduct', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', 'Products', '$modal', 'GetProductInfo', '$rootScope', 'PurcProductNewest', 'AccountEnterprise', function ($scope, PurcProduct, ngTableParams, $filter, BaseService, toaster, $timeout, Products, $modal, GetProductInfo, $rootScope, PurcProductNewest, AccountEnterprise) {
- BaseService.scrollBackToTop();
- // 用来记录已经选择的id
- $rootScope.ids = [];
- var loadAccount = function () {
- AccountEnterprise.get({}, function (data) {
- $scope.enterprise = data;
- $scope.purcStatus = $scope.enterprise.prodpurc;
- });
- }
- loadAccount();
- $scope.active = 'all';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = typeof zone == 'undefined' ? '半年前' : (zone == 1 ? '一个月内' : '半年内');
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcProduct : PurcProductNewest;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- id: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- pageParams.searchFilter = $scope.searchFilter;
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = angular.copy(pageParams.keyword);//保存当前取值的关键词
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // //设置单据已读
- // var setOrdersRead = function () {
- // var ids = [];
- // PurcProduct.setRead({}, ids, function (message) {
- // // $scope.getUnreadIds();
- // });
- // };
- // setOrdersRead();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- //删除
- $scope.deleteById = function (id) {
- GetProductInfo.deletePurcById({}, id, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- $timeout(function () {
- $scope.tableParams.reload();
- }, 500);
- }
- }), function (response) {
- toaster.pop("error", "删除失败", response.data);
- };
- }
- // 一键开启关闭
- $scope.toggle = function (status) {
- $scope.loading = true;
- Products.toggle({status: status}, {}, function (data) {
- $scope.loading = false;
- toaster.pop('success', '提示', '操作成功');
- loadAccount();
- $scope.tableParams.reload();
- if ($scope.purcStatus == 0) {
- $scope.purcStatus = 1;
- } else {
- $scope.purcStatus = 0;
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- })
- }
- var products = [];
- $scope.checks = {
- checked: false
- };
- // 全选框
- $scope.checkAll = function () {
- products = [];// 每次选择时先清空,防止重复
- angular.forEach($scope.tableParams.data, function (product) {
- if (product.cmpUuId == null) {
- product.checked = $scope.checks.checked;
- }
- });
- };
- // 单选
- $scope.checkOne = function (product) {
- products = [];// 每次选择时先清空,防止重复
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- $scope.checks.checked = result;
- var checked = true;
- angular.forEach($scope.tableParams.data, function (message) { // 单选全部时,全选选中
- if (!message.checked) {
- checked = false;
- }
- });
- $scope.checks.checked = checked;
- };
- $scope.updateByBatch = function (updatetype) {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/updateByBatch_modal.html',
- controller: 'UpdateByBatchCtrl',
- size: 'md',
- resolve: {
- updatetype: function () {
- return updatetype;
- },
- active: function () {
- return $scope.active;
- },
- type: function () {
- return 'purchase';
- }
- }
- });
- modalInstance.result.then(function (data) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 一键匹配
- $scope.matchall = function () {
- $scope.type = "purc";
- $scope.loading = true;
- PurcProduct.matchbytype({type: $scope.type}, {}, function (data) {
- if (data.error) {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- } else {
- toaster.pop('info', '提示', '匹配成功' + data.size + '个标准器件');
- window.location.href = "#/purc/productmatches";
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- // 导出
- $scope.exportXls = function () {
- PurcProduct.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'purcProduct/xls?_state='+$scope.active+'&keyword='+ ($scope.keywordXls || "");
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 采购物料批量上传
- */
- app.controller('UploadProductCtrl', ['$scope', '$upload', 'toaster', 'BaseService', function ($scope, $upload, toaster, BaseService) {
- BaseService.scrollBackToTop();
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- $scope.fileName = file.name;
- }
- })
- // 通过excel批量上传物料
- $scope.upload = function () {
- $scope.loading = true;
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- if (file.name) {
- $scope.loading = true;
- $upload.upload({
- url: 'purcProduct/edit/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- // $scope.products = $scope.result.products;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.alters = $scope.result.alters;
- $scope.infos = $scope.result.infos;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
- // 查看范例
- $scope.showImg = function () {
- var src = "static/img/eg/uploadByBatch_example.png", box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- // 下载模板
- $scope.download = function () {
- window.location.href = 'product/baseInfo/upload/template';
- };
- }]);
- /**
- * 新增物料(采购)
- */
- app.controller('PurcNewProdInfoCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', '$modal', 'ComponentActive', 'KindAPI', '$timeout', '$filter', 'AuthenticationService', 'BaseService', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, $modal, ComponentActive, KindAPI, $timeout, $filter, AuthenticationService, BaseService, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.prodInfo = {};
- // 选择类目
- $scope.selectKind = function () {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- };
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 删除
- $scope.clearfile = function () {
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //提交
- $scope.submit = function (prodInfo) {
- $scope.loading = true;
- $scope.prodInfo.isPurchase = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'purcProduct/edit/addNewProduct',
- file: file,
- method: 'POST',
- data: {
- prodInfo: prodInfo
- },
- }).success(function (data) {
- $scope.loading = false;
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/purc/prodList/" + data.id;
- // window.location.href="#/purc/product";
- }, 500);
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $timeout(function () {
- //提交后跳转到详情页面,防止重复提交
- window.location.href = "#/purc/prodList/" + data.id;
- // window.location.href="#/purc/product";
- }, 500);
- }
- }).error(function (data, status, headers, config) {
- $scope.loading = false;
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- };
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- // 取消
- $scope.cancel = function () {
- $scope.prodInfo = angular.copy($scope.prodInfo);
- };
- // 查看大图
- $scope.showImg = function () {
- var src = imgurl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- };
- }]);
- /**
- * 物料详情(采购)
- */
- app.controller('PurcProdDetailCtrl', ['$scope', 'GetProductInfo', '$upload', 'ngTableParams', '$stateParams', 'toaster', 'AuthenticationService', '$filter', 'BaseService', '$modal', 'Products', function ($scope, GetProductInfo, $upload, ngTableParams, $stateParams, toaster, AuthenticationService, $filter, BaseService, $modal, Products) {
- BaseService.scrollBackToTop();
- // 录入人
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.user = data;
- });
- $scope.time = $filter('date')(new Date, 'yyyy-MM-dd HH:mm');
- $scope.editstatus = false;
- var loadData = function () {
- GetProductInfo.getPurcProduct({id: $stateParams.id}, function (data) {
- if (data.attach) {
- GetProductInfo.getAttach({id: data.attach.id}, function (data) {
- $scope.imgPreview = data.url;
- $scope.previewShow = true;
- })
- }
- $scope.prodInfo = data;
- if ($scope.prodInfo.isbusiness == 0) {
- $scope.editstatus = true;
- }
- if ($scope.prodInfo.standard != 1) {// 非标准的先进行匹配
- Products.matchone({id: $scope.prodInfo.id}, {}, function (data) {
- $scope.matchresults = data;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- // 联想词 start
- // 获取类目
- $scope.getSimilarKinds = function (value) {
- if (value) {
- return Products.getSimilarKind({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- };
- // 设置类目
- $scope.onAssociateKindClick = function (kind, prodInfo) {
- $scope.prodInfo.kind = kind.kindName;
- }
- // 设置名称
- $scope.onAssociateTitleClick = function (kind, prodInfo) {
- $scope.prodInfo.title = kind.kindName;
- }
- $scope.getSimilarBrands = function (value) {
- if (value) {
- return Products.getSimilarBrandByCode({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置导入品牌
- $scope.onAssociateBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.brand = brand.brandName;
- }
- // 设置标准品牌
- $scope.onAssociatePBrandClick = function (brand, prodInfo) {
- $scope.prodInfo.pbranden = brand.brandName;
- }
- $scope.getSimilarComponents = function (value) {
- if (value) {
- return Products.getSimilarComponent({keyword: value}).$promise.then(function (data) {
- return data.map(function (item) {
- return item;
- });
- });
- }
- }
- // 设置标准型号
- $scope.onAssociateComponentClick = function (cmp, prodInfo) {
- $scope.prodInfo.pcmpcode = cmp.code;
- }
- // 设置导入的型号
- $scope.onAssociateCmpClick = function (cmp, prodInfo) {
- $scope.prodInfo.cmpCode = cmp.code;
- }
- // 联想词 end
- // 选择类目
- $scope.selectKind = function (cmpcode) {
- if (cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function () {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
- // 取消
- $scope.cancel = function () {
- GetProductInfo.getOne({id: $stateParams.id}, function (data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
- // 删除
- $scope.clearfile = function () {
- $scope.prodInfo.attach = null;
- $scope.myFiles = null;
- $scope.previewShow = false;
- }
- //删除
- $scope.deleteById = function (id) {
- GetProductInfo.deletePurcById({}, id, function (data) {
- if (data.error) {
- toaster.pop("error", "提示", data.error);
- } else {
- toaster.pop("success", "提示", "删除成功");
- window.location.href = "#/purc/product";
- }
- }, function (response) {
- toaster.pop("error", "删除失败", response.data);
- });
- }
- $scope.submit = function (prodInfo) {
- $scope.prodInfo.isPurchase = 1;
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'purcProduct/edit/updateProdInfo',
- file: file,
- method: 'POST',
- data: {
- prodInfo: $scope.prodInfo
- },
- }).success(function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- // window.location.href="#/sale/prodList";
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- $scope.previewShow = false;
- $scope.pdfShow = false;
- $scope.noneFileShow = true;
- $scope.$watch('myFiles', function () {
- if ($scope.myFiles) {
- $scope.noneFileShow = false;
- var file = $scope.myFiles[0];
- if (file.name.indexOf('.pdf') != -1 || file.name.indexOf('.PDF') != -1) {//pdf文件
- $scope.pdfShow = true;
- $scope.previewShow = false;
- $scope.imgPreviewName = file.name;
- } else {
- if (typeof(Worker) !== "undefined") {//支持HTML5
- $scope.imgPreview = getObjectURL(file);
- $scope.imgPreviewName = file.name;
- } else {//不支持HTML5
- $scope.imgPreview = 'static/img/all/preview-error.jpg';
- $scope.imgPreviewName = file.name;
- }
- $scope.previewShow = true;
- $scope.pdfShow = false;
- }
- } else {
- $scope.noneFileShow = true;
- $scope.previewShow = false;
- $scope.pdfShow = false;
- }
- });
- //建立一个可存取到该file的url
- var imgurl = null;
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- imgurl = url;
- return url;
- };
- // 查看范例
- $scope.showImg = function () {
- if ($scope.prodInfo.attach) {
- GetProductInfo.getAttach({id: $scope.prodInfo.attach.id}, function (data) {
- var src = data.url, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- })
- } else if (imgurl != null) {
- var src = imgurl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- }]);
- // 供应商绩效考核
- app.controller('VendorPerformanceAssessCtrl', ['$scope', 'VendorPerformanceAssessService', 'BaseService', 'AuthenticationService', 'ngTableParams', '$modal', 'toaster', 'Vendor', 'AccountUser', 'CurrentRole', function ($scope, VendorPerformanceAssessService, BaseService, AuthenticationService, ngTableParams, $modal, toaster, Vendor, AccountUser, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.vendorPerformanceAssessParams = new ngTableParams({
- page: 1,
- count: 20
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- VendorPerformanceAssessService.get(BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.keywordXls = pageParams.keyword;
- }
- $scope.totalCount = page.totalElement;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- //设置消息已读
- var setOrdersRead = function () {
- var sourceId = [];
- VendorPerformanceAssessService.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- });
- };
- setOrdersRead();
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.vendorPerformanceAssessParams.page(1);
- $scope.vendorPerformanceAssessParams.reload();
- $scope.tip = keyword;
- };
- // 查看详情
- $scope.viewDetail = function (id) {
- window.location.hash = "#/sale/vendorPerformanceAssess/" + id;
- }
- }]);
- // 客户详情
- app.controller('VendorPerformanceAssessDetailCtrl', ['$scope', 'toaster', '$stateParams', 'VendorPerformanceAssessService', '$modal', 'ngTableParams', 'BaseService', '$rootScope', 'AuthenticationService', function ($scope, toaster, $stateParams, VendorPerformanceAssessService, $modal, ngTableParams, BaseService, $rootScope, AuthenticationService) {
- BaseService.scrollBackToTop();
- var loadData = function () {
- VendorPerformanceAssessService.getDetail({id: $stateParams.id}, {}, function (data) {
- $scope.vendorPerformanceAssess = data;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- };
- loadData();
- }]);
- /**
- * 个人产品库
- */
- app.controller('UserProductCtrl', ['$scope', 'prodUser', 'ngTableParams', '$filter', 'BaseService', 'toaster', '$timeout', '$modal', '$rootScope', function ($scope, prodUser, ngTableParams, $filter, BaseService, toaster, $timeout, $modal, $rootScope) {
- BaseService.scrollBackToTop();
- $rootScope.ids = [];// 每次加载先清空数据
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? prodUser.getInfo : prodUser.info;
- };
- $scope.tableParams = new ngTableParams({ // ng-Table参数
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc',
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) { // 获取数据的方法
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.keyword = $scope.keyword;
- $scope.tip = $scope.keyword;
- getService().call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.checkall = true;
- if(page.content.length <= 2) {
- $scope.checkall = false;
- } else {
- angular.forEach(page.content, function (prod) {
- if ($rootScope.ids.indexOf(prod.id) > -1) {
- prod.$selected = true;
- } else {
- $scope.checkall = false;
- }
- });
- }
- $scope.checkboxes = {
- checked: $scope.checkall
- };
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- $scope.tip = keyword;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 新增产品信息
- $scope.addProduct = function() {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/approvalFlow/modal/userprod_new_modal.html',
- controller: 'UserProductNewCtrl',
- }).result.then(function (data) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 导入商品信息
- $scope.uploadByBatch = function () {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/approvalFlow/modal/uplodaByBatch.html',
- controller: 'UserProdUploadCtrl',
- backdrop: 'static',
- keyboard: false,
- size: 'lg',
- resolve: {}
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function () {
- });
- }
- // 删除
- $scope.deleteById = function(id) {
- prodUser.deleteById({}, id, function(data) {
- toaster.pop('success', '提示', '删除成功');
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(res) {
- toaster.pop('error', '提示', '删除失败');
- });
- }
- $scope.checkboxes = {
- checked: false
- };
- angular.forEach($scope.tableParams.data, function (item) {
- $scope.checkboxes.checked = false;
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- $scope.checkboxes.checked = true;
- }
- });
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- angular.forEach($scope.tableParams.data, function (item) {
- item.$selected = $scope.checkboxes.checked;
- if(item.$selected) {
- if(!$rootScope.ids.in_array(item.id)) {
- $rootScope.ids.push(item.id);
- }
- } else {
- if($rootScope.ids.in_array(item.id)) {
- $rootScope.ids.remove(item.id);
- }
- }
- });
- };
- // 判断数组中是否存在某个对象
- Array.prototype.S = String.fromCharCode(2);
- Array.prototype.in_array = function(e) {
- var r = new RegExp(this.S + e + this.S);
- return (r.test(this.S + this.join(this.S) + this.S));
- }
- // 从数组中移除某个对象
- Array.prototype.remove = function(val) {
- var index = this.indexOf(val);
- if (index > -1) {
- this.splice(index, 1);
- }
- };
- // 点击其中一个明细的复选框
- $scope.checkOne = function (product) {
- var result = true;
- angular.forEach($scope.tableParams.data, function (item) {
- if (item.$selected != true) {
- result = false;
- return;
- }
- });
- if(product.$selected) {
- if(!$rootScope.ids.in_array(product.id)) {
- $rootScope.ids.push(product.id);
- }
- } else {
- if($rootScope.ids.in_array(product.id)) {
- $rootScope.ids.remove(product.id);
- }
- }
- $scope.checkboxes = {
- checked: result
- };
- };
- // 批量删除
- $scope.deleteByBatch = function() {
- var ids = angular.toJson($rootScope.ids);
- if($rootScope.ids.length > 0) {
- prodUser.deleteByBatch({ids: ids}, {}, function(data) {
- toaster.pop('success', '提示', '成功移除' + $rootScope.ids.length + '个产品');
- $rootScope.ids = [];
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }, function(res) {
- toaster.pop('error', '提示', '移除失败');
- });
- } else {
- toaster.pop('error', '提示', '请先选择产品');
- }
- }
- }]);
- /**
- * 用户产品新增产品
- */
- app.controller('UserProductNewCtrl', ['$scope', 'toaster', 'prodUser', '$modalInstance', function($scope, toaster, prodUser, $modalInstance) {
- // 确定
- $scope.submit = function(prodInfo) {
- prodUser.addProduct({}, prodInfo, function(data) {
- if(data.success) {
- toaster.pop('success', '提示', data.success);
- } else if(data.info) {
- toaster.pop('info', '提示', data.info);
- }
- $modalInstance.close('success');
- }, function(res) {
- toaster.pop('error', '提示', '添加失败');
- });
- }
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- }]);
- /**
- * 用户产品批量导入产品
- */
- app.controller('UserProdUploadCtrl', ['$scope', 'toaster', 'prodUser', '$modalInstance', '$upload', function($scope, toaster, prodUser, $modalInstance, $upload) {
- // 通过excel批量上传物料
- $scope.upload = function () {
- $scope.loading = true;
- if ($scope.myFiles) {
- var file = $scope.myFiles[0];
- if (file.name) {
- $upload.upload({
- url: 'productuser/edit/release/excel',
- file: file,
- method: 'POST'
- }).success(function (data) {
- $scope.loading = false;
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- $scope.result = data;
- $scope.success = $scope.result.success;
- $scope.total = $scope.result.total;
- $scope.myFiles[0] = "";
- $scope.fileName = "";
- }).error(function (response) {
- $scope.loading = false;
- toaster.pop('error', response.data || response);
- });
- } else {
- $scope.loading = false;
- toaster.pop('info', '提示', '当前文件不存在,请重新选择');
- }
- } else {
- $scope.loading = false;
- }
- };
- // 取消
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- // 下载模板
- $scope.download = function () {
- window.location.href = 'productuser/upload/template';
- };
- // 确定
- $scope.enSure = function() {
- $modalInstance.close('success');
- }
- }]);
- /**
- * 针对卖家,已转询价的公共询价单列表
- */
- app.controller('SalePubInquiryCtrl', ['$scope', '$filter', 'PubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', '$modal', 'AccountEnterprise', '$http', 'customer', 'AuthenticationService','$stateParams',
- function ($scope, $filter, PubInquirySearchInfo, ngTableParams, toaster, BaseService, PubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry, $modal, AccountEnterprise, $http, customer, AuthenticationService, $stateParams) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- /**
- * active 状态说明:
- * all: 客户公共询价单全部
- * done: 已报价
- * agreed: 已采纳
- * refused: 未采纳
- * invalid: 已失效
- * todo**: 待报价
- * todoAll: 所有公共询价
- * todoRemind: 个人商机
- * todoComRemind: 企业商机
- */
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'todoComRemind';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.url = null;
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- $scope.url = url;
- if ($scope.active == 'todoComRemind') {// 企业商机
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/sale/enremind',
- params: {
- pageNumber: pageParams.page,
- pageSize: pageParams.count,
- useruu: $scope.thisUser.userUU,
- enuu: $scope.currentEn.uu,
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo),
- enableOffer: 1
- }
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- } else if ($scope.active == 'todoRemind') {// 推荐报价信息
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/sale/remind',
- params: {
- pageNumber: pageParams.page,
- pageSize: pageParams.count,
- useruu: $scope.thisUser.userUU,
- enuu: $scope.currentEn.uu,
- enableOffer: 1,
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- }
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- } else if ($scope.active == 'todoAll') {// 全部
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/public',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, enUU: $scope.currentEn.uu, keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo), distribute: $scope.distribute, remind: $scope.remind}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- } else {
- var filter = {vendUU: $scope.currentEn.uu, keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)};
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/public/quotation/list',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, filter: filter, _state: $scope.active}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- }
- });
- });
- }
- });
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- // 导出
- $scope.exportXls = function () {
- PurcInquiry.exportXls({}, {}, function (data) {
- if (data.success) {
- window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- $scope.isOverDue = function (date) {
- if (date) {
- var ndate = new Date();
- ndate.setHours(23, 59, 59 ,999);
- ndate.setDate(ndate.getDate());
- var timestamp = Date.parse(ndate);
- if (date > timestamp) {
- return true;
- } else {
- return false;
- }
- } else {
- return true;
- }
- }
- $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
- customer.distribute({}, function(data) {
- $scope.customer = data;
- });
- $scope.toDetail = function (item) {
- if (item.quoted == 0) {
- window.location.hash = '#/baseInfo/inquiryList/' + item.id;
- } else {
- window.open("#/sale/pubinquiry/" + item.quteId);
- }
- };
- // 转客户询价
- $scope.qute = function (remind) {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/sale/quote',
- params: {id: remind.itemId, en_uu: $scope.currentEn.uu}
- }).success(function (response) {
- $scope.loading = false;
- if (response.inquiry != null) {
- toaster.pop('error', '该单据已报价');
- } else {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/public/findItemByItemId',
- params: {itemId: remind.itemId, enuu: $scope.currentEn.uu}
- }).success(function (response) {
- var inquiryItem = response;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }).error(function (error) {
- toaster.pop('error', '数据加载失败', error);
- });
- }
- }).error(function (err) {
- toaster.pop('error', '数据加载失败', err);
- });
- }
- // 跳转详情
- $scope.remindDetail = function(remind) {
- if (remind.newId == null) {
- window.location.hash = '#/baseInfo/inquiryList/' + remind.itemId;
- } else {
- window.open("#/sale/pubinquiry/" + remind.newId);
- }
- }
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 转客户询价
- $scope.transtoInquiry = function (inquiryItem) {
- if ($scope.currentEn.uu == inquiryItem.inquiry.enUU) {
- toaster.pop('warning', '不能对自己企业报价');
- } else {
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }
- }
- // 跳转到我的报价列表
- $scope.linkToInquiry = function () {
- window.open("#/sale/pubinquiry");
- }
- }]);
- /**
- * 针对卖家,已转询价单的客户公共询价单明细
- */
- app.controller('SalePubInquiryDetailCtrl', ['$scope', '$stateParams', 'PurcInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', 'publicInquiry', function ($scope, $stateParams, PurcInquiry, $filter, toaster, $upload, token, CurrentRole, publicInquiry) {
- // 获取当前用户是否为普通用户
- var loadData = function () {
- publicInquiry.inquiryDetail({id: $stateParams.id}, function (data) {
- $scope.inquiryItem = data;
- var inquiry = data.inquiry;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- $scope.attach = null;
- if ($scope.inquiryItem.attaches.length > 0) {
- $scope.attach = $scope.inquiryItem.attaches[0];
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.addStep = function (inquiryItem) {
- if (inquiryItem.replies.length >= 10) {
- toaster.pop('warning', '提示', '最多支持10个分段!');
- } else
- inquiryItem.replies.push({});
- };
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- publicInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,6})?$/;
- var valid = true;
- angular.forEach(inquiryItem.replies, function(reply, $index) {
- if ($index < index && reply.lapQty >= value) {
- valid = false;
- }
- });
- $scope.replylapQtys[index] = regex.test(value) && valid;
- };
- $scope.isValid = function (item, withSteps) {
- var bool = item.leadtime && item.replies && item.replies[0].price > 0;
- if (!withSteps || !bool)
- return bool;
- angular.forEach(item.replies, function (r, i) {
- $scope.verifylapQty(r.lapQty, i, item);
- bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
- });
- return bool;
- };
- $scope.deleteAttach = function (attaches, index) {
- attaches.splice(index, 1);
- };
- $scope.onReplyClick = function (item, withSteps) {
- if (item.vendFromDate instanceof Date) {
- item.vendFromDate = item.vendFromDate.getTime();
- }
- if (item.vendToDate instanceof Date) {
- item.vendToDate = item.vendToDate.getTime();
- }
- if (item.vendFromDate > item.vendToDate) {
- toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
- return;
- }
- var replies = [];
- var valid = true;
- var validLapQty = 0;
- angular.forEach(item.replies, function (r, i) {
- // 直接比较是字符串比较,需要先转换再比较 2017年9月7日 15:05:51
- if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
- valid = false;
- validLapQty = r.lapQty;
- }
- if ((i > 0 ? r.lapQty : 1) || r.price)
- replies.push(r);
- });
- item.replies = replies;
- $scope.loading = true;
- if (!valid) { // 不合法时给出提示
- if (validLapQty) {
- toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
- } else {
- toaster.pop('info', '提示', '分段数量不合法,不能保存!');
- }
- $scope.loading = false;
- } else {
- var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
- if (withSteps) {
- if(null != file) {
- $upload.upload({
- url: 'sale/pubInquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'reply'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- toaster.pop('success', '提示', '报价成功');
- loadData();
- }).error(function () {
- toaster.pop('error', '提示', '报价失败');
- });
- } else {
- publicInquiry.reply({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('success', '提示', '报价成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '询价失效', response.data);
- });
- }
- } else {
- if(null != file) {
- $upload.upload({
- url: 'sale/pubInquiry/addAttach',
- file: file,
- method: 'POST',
- data: {
- item: item,
- method: 'save'
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- toaster.pop('success', '提示', '保存成功');
- loadData();
- }).error(function () {
- toaster.pop('error', '提示', '保存失败');
- });
- } else {
- publicInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function () {
- $scope.loading = false;
- toaster.pop('info', '提示', '保存成功');
- loadData();
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '保存失败', response.data);
- });
- }
- }
- }
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- }]);
- /**
- * 针对买家,已转询价的公共询价单列表
- */
- app.controller('PurcPubInquiryCtrl', ['$scope', '$filter', 'PurcPubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PurcPubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', 'AccountEnterprise', '$http', function ($scope, $filter, PurcPubInquirySearchInfo, ngTableParams, toaster, BaseService, PurcPubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry, AccountEnterprise, $http) {
- BaseService.scrollBackToTop();
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- $rootScope.active = null;
- } else {
- $scope.active = 'all';
- }
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已采纳' : '未采纳');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.searchMethod = false;
- var getService = function () {
- return $scope.searchMethod ? PurcPubInquirySearchInfo : PurcPubInquiryNoSearchInfo;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'inquiry.date': 'desc',
- 'inquiry.enterprise.enName': 'asc',
- 'inquiry.code': 'asc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- var filter = {enUU: $scope.currentEn.uu, keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)};
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/public/quotation/list',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, filter: filter, _state: $scope.active}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- });
- }
- });
- $scope.isUnread = function (id) {
- for (var i in $scope.unreadCode) {
- if (id == $scope.unreadCode[i]) {
- return true;
- }
- }
- };
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.getHistory = function (item) {
- if (!item.history) {
- publicInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 采纳
- $scope.accept = function (id) {
- publicInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, function (response) {
- toaster.pop('error', '提示', '采纳失败');
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- publicInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- }
- }, function (response) {
- toaster.pop('error', '提示', '操作失败');
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- })
- }
- // 导出
- $scope.exportXls = function () {
- PurcInquiry.exportXls({}, {}, function (data) {
- if (data.success) {
- window.location.href = 'sale/inquiry/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- })
- }
- }]);
- /**
- * 针对买家,已转询价单的客户公共询价单明细
- */
- app.controller('PurcPubInquiryDetailCtrl', ['$scope', '$stateParams', 'publicInquiry', '$filter', 'toaster', '$upload', 'token', 'CurrentRole', 'AccountEnterprise', '$http', function ($scope, $stateParams, publicInquiry, $filter, toaster, $upload, token, CurrentRole, AccountEnterprise, $http) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- var url = data.url;
- $http({
- method: 'get',
- dataType: 'json',
- url: url + '/inquiry/buyer/detail',
- params: {id: $stateParams.id, enuu: $scope.currentEn.uu}
- }).success(function (response) {
- $scope.newinquiryItems = response;
- var inquiry = response;
- angular.forEach(inquiry.attachs, function (attach) {
- attach.type = attach.name.substr(attach.name.lastIndexOf('.') + 1);
- });
- $scope.inquiry = inquiry;
- });
- });
- });
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- $scope.getHistory = function (item) {
- if (!item.history) {
- publicInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
- $scope.verify = function (value, type) {
- var regex = /^\d+(.\d{1,6})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- // 采纳
- $scope.accept = function (id) {
- publicInquiry.accept({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- };
- // 拒绝
- $scope.refuse = function (id) {
- publicInquiry.refuse({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- loadData();
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- })
- }
- }]);
- /**
- * 公共询价模态框(供应商报价)
- */
- app.controller('QuoteInquiryCtrl', ['$scope', '$stateParams', 'toaster', 'inquiryItem', '$modalInstance', '$upload', function ($scope, $stateParams, toaster, inquiryItem, $modalInstance, $upload) {
- $scope.inquiryItem = inquiryItem;
- $scope.replyPrices = [];
- $scope.replylapQtys = [];
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- // 增加一列分段报价
- $scope.addStep = function (inquiryItem) {
- $scope.replyPrices.push(true);
- if (inquiryItem.replies.length >= 5) {
- toaster.pop('warning', '提示', '最多支持5个分段!');
- } else {
- inquiryItem.replies.push({});
- if (inquiryItem.replies.length != 1) {
- $scope.replyPrices.push(true);
- $scope.replylapQtys.push(true);
- }
- }
- };
- // 删除一列分段报价
- $scope.removeStep = function (inquiryItem, stepIndex) {
- inquiryItem.replies.splice(stepIndex, 1);
- $scope.replyPrices.splice(stepIndex, 1);
- $scope.replylapQtys.splice(stepIndex, 1);
- };
- // 取消,关闭弹出框
- $scope.cancel = function() {
- $modalInstance.dismiss();
- }
- // 保存报价信息
- $scope.save = function(inquiryItem, method) {
- var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $upload.upload({
- url: 'pubInquiry/turnToQuotation',
- file: file,
- method: 'POST',
- data: {
- item: inquiryItem,
- method: method
- }
- }).success(function (data) {
- if (data.item) {
- item = data.item;
- }
- $scope.loading = false;
- toaster.pop('info', '提示', '报价成功');
- $scope.tableParams.reload();
- }).error(function (data) {
- $scope.loading = false;
- toaster.pop('error', '报价失败');
- });
- }
- }]);
- /**
- * 首页侧边栏询价列表
- */
- app.controller('InquiryMessageListCtrl', ['$scope', 'publicInquiry', 'AccountEnterprise', '$http', function($scope, publicInquiry, AccountEnterprise, $http) {
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function (data) {
- var url = data.url;
- $http({
- method: 'get',
- url: url + '/inquiry/public/messageList',
- params: {enuu: $scope.currentEn.uu, size: 7},
- dataType: 'json'
- }).success(function(data) {
- $scope.message = data;
- }).error(function(error) {
- });
- });
- });
- }]);
- /**
- * 针对卖家,询价推荐列表
- */
- app.controller('SaleInquiryRemindCtrl', ['$scope', '$filter', 'ngTableParams', 'toaster', 'BaseService', 'publicInquiry', '$modal', 'AccountEnterprise', '$http', 'AuthenticationService', function ($scope, $filter, ngTableParams, toaster, BaseService, publicInquiry, $modal, AccountEnterprise, $http, AuthenticationService) {
- BaseService.scrollBackToTop();
- $scope.agreedText = '全部';
- $scope.dateZoneText = '最近一个月';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 3 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- 'date': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- if ($scope.active == 'overdue') {
- $scope.active = 'end';
- }
-
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- $scope.url = data.url;
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.loading = false;
- $scope.thisUser = data;
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/sale/remind',
- params: {pageNumber: pageParams.page, pageSize: pageParams.count, useruu: $scope.thisUser.userUU, enuu: $scope.currentEn.uu,
- keyword: $scope.keyword, fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)}
- }).success(function (response) {
- $scope.loading = false;
- if (response) {
- params.total(response.totalElements);
- $defer.resolve(response.content);
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- });
- });
- }
- });
- $scope.getMinDate = function (item) {
- return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- // 每次搜索重置获取数据方法
- $scope.searchMethod = false;
- if(keyword != null && keyword != '') {
- $scope.searchMethod = true;
- }
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 取消
- $scope.cancel = function () {
- $scope.tableParams.reload();
- }
- // 转客户询价
- $scope.qute = function (remind) {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/sale/quote',
- params: {id: remind.itemId, en_uu: $scope.currentEn.uu}
- }).success(function (response) {
- $scope.loading = false;
- if (response.inquiry != null) {
- toaster.pop('error', '该单据已报价');
- } else {
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.url + '/inquiry/public/findItemByItemId',
- params: {itemId: remind.itemId, enuu: $scope.currentEn.uu}
- }).success(function (response) {
- var inquiryItem = response;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
- controller: 'QuoteCtrl',
- size: 'lg',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.tableParams.reload();
- }, function () {
- });
- }).error(function (error) {
- toaster.pop('error', '数据加载失败', error);
- });
- }
- }).error(function (err) {
- toaster.pop('error', '数据加载失败', err);
- });
- }
- // 跳转详情
- $scope.toDetail = function(remind) {
- if (remind.newId == null) {
- window.location.hash = '#/baseInfo/inquiryList/' + remind.itemId;
- } else {
- window.open("#/sale/pubinquiry/" + remind.newId);
- }
- }
- }]);
- /**
- * 采购变更单列表
- *
- * @author hejq
- * @date 2018-06-25 17:13
- */
- app.controller('PurcChangeListCtrl', ['$scope', '$filter', 'change', 'ngTableParams', 'toaster', 'BaseService', 'CurrentRole', function ($scope, $filter, change, ngTableParams, toaster, BaseService, CurrentRole) {
- BaseService.scrollBackToTop();
- $scope.active = 'todo';
- $scope.agreedText = '全部';
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeAgreed = function (agreed) {
- $scope.condition.agreed = agreed;
- $scope.agreedText = typeof agreed == 'undefined' ? '全部' : (agreed == 1 ? '已同意' : '不同意');
- $scope.condition.$agreedOpen = false;
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- var getService = function () {
- return change;
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- date: 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = {
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- getService()[getState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 导出
- $scope.exportXls = function () {
- change.exportXls({}, {}, function (data) {
- if (data.success){
- window.location.href = 'purc/change/xls?_state='+$scope.active+'&searchFilter='+encodeURIComponent(angular.toJson($scope.searchFilterXls));
- }
- }, function (response) {
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- }]);
- /**
- * 新增采购变更单
- *
- * @author hejq
- * @date 2018-06-25 16:38
- */
- app.controller('PurcChangeNewCtrl', ['$scope', 'toaster', 'BaseService', 'AuthenticationService', '$modal', '$filter', 'change',
- function ($scope, toaster, BaseService, AuthenticationService, $modal, $filter, change) {
- // 获取登录人员信息
- AuthenticationService.getAuthentication().success(function (data) {
- $scope.user = data;
- initChange();
- });
- // 初始化变更单信息
- var initChange = function () {
- $scope.change = {
- date: new Date(),
- recorder: $scope.user.userName,
- orderCode: null,
- code: 'B2BPC' + $filter('date')(new Date(), 'yyMMddHHmmss_sss'),
- orderId: null,
- orderChangeItems: []
- }
- }
- $scope.getEnableOrders = function() {
- initChange();
- var modalInstance = $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/purc/modal/enableOrderList.html',
- controller: 'EnableChangeListCtrl',
- resolve: {
- }
- });
- modalInstance.result.then(function (data) {
- $scope.change.orderCode = data.code;
- $scope.change.orderId = data.id;
- $scope.orderItems = data.orderItems;
- $scope.change.oldCurrency = data.currency;
- $scope.change.oldPayments = data.payments;
- $scope.change.oldRate = data.rate;
- $scope.change.vendUU = data.vendUU;
- $scope.change.apVendorName = data.receiveName;
- $scope.change.vendUserUU = data.vendUserUU;
- $scope.change.newCurrency = data.currency != null ? data.currency :null;
- $scope.change.newPayments = data.payments != null ? data.payments :null;
- angular.forEach($scope.orderItems, function (item, index) {
- $scope.change.orderChangeItems.push({
- oldProductId: item.productId,
- orderItemId: item.id,
- orderItemNumber: item.number,
- oldQty: item.qty,
- oldPrice: item.price,
- oldTaxrate: item.taxrate,
- oldDelivery: item.delivery,
- newQty: item.qty != null ? item.qty :null,
- newPrice: item.price != null ? item.price :null,
- newTaxrate: item.taxrate != null ? item.taxrate :null,
- newDelivery: item.delivery != null ? item.delivery :null,
- oldProduct: item.product,
- number: index + 1
- });
- });
- });
- }
- // 删除明细
- $scope.del = function (index) {
- $scope.change.orderChangeItems.splice(index, 1);
- }
- $scope.getMinDate = function () {
- return $filter('date')(new Date, 'yyyy-MM-dd');
- };
- $scope.openDatePicker = function ($event, openParam, index) {
- $event.preventDefault();
- $event.stopPropagation();
- $scope.change.orderChangeItems[index].$dateOpen = !openParam;
- };
- $scope.save = function() {
- if ($scope.change.unNeedReply == null) {
- toaster.pop('error', '请选择是否需要供应商确认');
- } else if ($scope.change.orderChangeItems.length == 0) {
- toaster.pop('error', '请至少选择一条采购明细')
- } else {
- change.save({}, $scope.change, function (data) {
- window.location.hash = "/purc/change/" + data.id;
- toaster.pop('success', '采购变更单保存成功');
- }, function(res) {
- toaster.pop('error','请输入正确的信息')
- });
- }
- }
- }]);
- /**
- * 获取可以作为采购变更单的采购单
- *
- * @author hejq
- * @date 2018-06-25 18:41
- */
- app.controller('EnableChangeListCtrl', ['$scope', 'change', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance',
- function ($scope, change, BaseService, ngTableParams, toaster, $modalInstance) {
- $scope.dateZoneText = '一个月内';
- $scope.condition = {dateZone: 1};
- /* 时间筛选初始化*/
- var fromDate = new Date();
- var toDate = new Date();
- fromDate.setMonth(fromDate.getMonth() - 1);
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- $scope.condition.dateFrom = fromDate;
- $scope.condition.dateTo = toDate;
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = zone == 1 ? '最近一个月' : (zone == 3 ? '最近三个月' : (zone == 6 ? '最近六个月' : '自定义'));
- $scope.condition.$dateZoneOpen = false;
- getDateCondition(zone, $scope.condition);
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.openFilterDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
- $scope.tableParams.reload();
- }
- };
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- change.getEnableOrderList.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElement);
- $defer.resolve(page.content);
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.checkedOrder = null;
- var checkItems = [];
- // 单选
- $scope.checkOne = function (order) {
- var changeflag = false;
- order.checked = !order.checked;
- if ((order.checked) && ($scope.checkedOrder != null) && ($scope.checkedOrder != order)) {
- $scope.checkedOrder.checked = false;
- angular.forEach($scope.checkedOrder.orderItems, function (item) {
- item.checked = false;
- });
- $scope.checkedOrder = null;
- checkItems = [];
- }
- if (order.checked) {
- $scope.checkedOrder = order;
- angular.forEach(order.orderItems, function (item) {
- if (item.change) {
- item.checked = false;
- changeflag = true;
- } else {
- item.checked = true;
- checkItems.push(item);
- }
- });
- } else {
- $scope.checkedOrder = null;
- angular.forEach(order.orderItems, function (item) {
- item.checked = false;
- });
- checkItems = [];
- }
- if (checkItems.length == 0 && changeflag) {
- order.checked =false;
- toaster.pop('warning', '提示', "该采购单所有明细正在变更中,在供应商确认之前不可再次变更");
- }
- };
- // 明细
- $scope.checkItem = function (item, order) {
- // 先判断选中信息
- if (item.change) {
- toaster.pop('warning', '提示', "该明细正在变更中,在供应商确认之前不可再次变更");
- item.checked = null;
- return;
- }
- order.checked = true;
- if ($scope.checkedOrder != null && order.id != $scope.checkedOrder.id) {
- $scope.checkedOrder.checked = false;
- $scope.checkedOrder = order;
- order.checked = true;
- angular.forEach(checkItems, function (checkItem) {
- checkItem.checked = false;
- });
- checkItems = [];
- }
- item.checked = !item.checked;
- if (item.checked) {
- checkItems.push(item);
- if ($scope.checkedOrder == null) {
- $scope.checkedOrder = order;
- }
- order.checked = true;
- } else {
- angular.forEach(checkItems, function (checkItem, index) {
- if (checkItem.id == item.id) {
- checkItems.splice(index, 1);
- }
- });
- }
- if (checkItems.length == 0) {
- $scope.checkedOrder = null;
- order.checked = false;
- }
- };
- // 搜索框回车
- $scope.onSearch = function (keyword) {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.getCartTotal = function (items) {
- var sum = 0;
- angular.forEach(items, function (item) {
- sum += item.qty * item.price;
- });
- return sum;
- };
- // 选择
- $scope.choose = function () {
- if ($scope.checkedOrder == null || checkItems.length == 0) {
- toaster.pop('error', '请先选择采购单信息');
- } else {
- $scope.checkedOrder.orderItems = checkItems;
- $modalInstance.close($scope.checkedOrder);
- }
- }
- // 关闭
- $scope.close = function () {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 采购变更单详情
- */
- app.controller('PurcChangeDetailCtrl', ['$scope', '$stateParams', 'change', 'toaster', 'CurrentRole',
- function ($scope, $stateParams, change, toaster, CurrentRole) {
- // 获取当前用户是否为普通用户
- CurrentRole.isUser({}, {}, function (data) {
- $scope.isUser = data.isUser;
- });
- var loadData = function () {
- change.getItem({id: $stateParams.id}, function (data) {
- $scope.change = data;
- }, function (response) {
- toaster.pop('error', '', response.data);
- });
- };
- loadData();
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- }]);
- /**
- * B2C搜索
- */
- app.controller('SearchCtrl', ['$scope', '$http', '$rootScope', 'SessionService', 'AccountEnterprise', function($scope, $http, $rootScope, SessionService, AccountEnterprise) {
- $scope.hotwords = new Array();
- var hasBrand = false;
- var hasComponent = false;
- // 热词搜索品牌
- var hotBrand = function () {
- $http.get($scope.toB2cLink + '/api/product/brand/mostSearchBrands'
- ).success(function(data){
- hasBrand = true;
- angular.forEach(data, function (value) {
- $scope.hotwords.push({name: value.nameEn, url: $scope.toB2cLink + '/search?w='+ value.nameEn +'&type=brand'})
- })
- if (hasBrand) {
- hotComponent();
- }
- }).error(function(response) {
- console.log(response)
- });
- };
- // 热词搜索器件
- var hotComponent = function () {
- $http.get($scope.toB2cLink + '/api/product/component/mostSearchComponent'
- ).success(function(data){
- hasComponent = true;
- if (hasBrand && hasComponent) {
- angular.forEach(data, function (value) {
- $scope.hotwords.push({name: value.code, url: $scope.toB2cLink + '/search?w='+ value.code +'&type=component'})
- })
- }
- }).error(function(response) {
- console.log(response)
- });
- };
- AccountEnterprise.getB2cUrl({}, function(data) {
- $scope.toB2cLink = data.url
- hotBrand();
- });
- // 默认搜索类型
- $scope.searchType = 'component';
- $scope.placeholderSearch = '请输入型号';
- // 选搜索类型
- $scope.setTypeClick = function (type) {
- $scope.keyword = '';
- $scope.searchType = type;
- if (type === 'kind') {
- $scope.placeholderSearch = '请输入物料名称';
- } else if (type === 'store') {
- $scope.placeholderSearch = '请输入卖家名称';
- } else if (type === 'brand') {
- $scope.placeholderSearch = '请输入品牌';
- } else {
- $scope.placeholderSearch = '请输入型号';
- }
- };
- // 搜索
- $scope.search = function() {
- if($scope.keyword) {
- SessionService.set('brand', true);
- SessionService.unset('component');
- window.location.href = $scope.toB2cLink + '/search?w=' + encodeURI($scope.keyword) + '&type=' + $scope.searchType;
- }
- };
- // 搜索框获得焦点,显示联想框
- $scope.onFocus = function() {
- $scope.associate = true;
- $scope.selectIndex = -1;
- if(!$scope.keyword) $scope.keyword = '';
- };
- // 搜索框失去焦点,关闭联想框
- $scope.onBlur = function() {
- $scope.associate = false;
- };
- // 搜索框通过按键选取想要的联想词
- $scope.onKeyup = function() {
- if($scope.associates && $scope.associates.length) {
- if(event.keyCode == 40) { //监听到按下键
- $scope.selectIndex ++;
- if($scope.selectIndex >= $scope.associates.length) $scope.selectIndex = 0;
- $scope.keyword = $scope.associates[$scope.selectIndex];
- } else if(event.keyCode == 38) { //监听到按上键
- $scope.selectIndex --;
- if($scope.selectIndex < 0) $scope.selectIndex = $scope.associates.length - 1;
- $scope.keyword = $scope.keyword = $scope.associates[$scope.selectIndex];
- } else if(event.keyCode == 13) { //确定键
- $scope.search();
- }
- }
- };
- // 输入框内容变化,获取新的联想词
- $scope.onChange = function() {
- if ($scope.keyword) {
- var params = {
- keyword: $scope.keyword,
- type: $scope.searchType
- };
- $http.get($scope.toB2cLink + '/search/similarKeywords', {
- params : params
- }).success(function(data){
- $scope.associates = data.result;// 联想词数组
- }).error(function(response) {
- console.log(response)
- });
- } else {
- $scope.associates = [];// 联想词数组
- }
- };
- // 点击联想词
- $scope.onAssociateClick = function(component) {
- $scope.keyword = component;
- $scope.search();
- };
- // 鼠标进入联想词框,不能关闭联想词框
- $scope.onAssociateEnter = function() {
- $scope.associateEnter = true;
- };
- // 鼠标离开联想词框,可以关闭联想词框
- $scope.onAssociateLeave = function() {
- $scope.associateEnter = false;
- };
- // 跳转到B2C
- $scope.b2cLink = function (url) {
- if (url == '/help/home') {
- window.open($scope.toB2cLink + url)
- } else {
- window.location.href = $scope.toB2cLink + url;
- }
- };
- // 头部固定
- window.addEventListener('scroll', function () {
- var obj = document.getElementById('fixed-header');
- var scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
- $scope.$apply(function () {
- $scope.isFixed = scrolled >= obj.offsetTop;
- });
- }, false);
- }]);
- /**
- * 树结构
- */
- app.controller('treeController', ['$scope', '$location', function($scope, $location){
- $scope.roleList = [
- { "roleName" : "卖家中心(销售)", "roleId" : "role1", 'path': 'sale', level: 0, collapsed: true, "children" : [
- { "roleName" : "商机管理", "roleId" : "role1-1", collapsed: true, "children" : [
- { "roleName" : "客户采购询价", "roleId" : "role1-1-1", 'link' : '#/sale/inquiry', "children" : [] },
- { "roleName" : "客户公共询价", "roleId" : "role1-1-2", 'link' : '#/sale/pubinquiry', "children" : [] },
- { "roleName" : "客户模具询价", "roleId" : "role1-1-3", 'link' : '#/sale/mould', "children" : [] },
- { "roleName" : "主动报价", "roleId" : "role1-1-4", 'link' : '#/sale/quotation/list', "children" : [] },
- { "roleName" : "客户招标", "roleId" : "role1-1-5", 'link' : '#/sale/tender', "children" : [] }
- ] },
- { "roleName" : "订单管理", "roleId" : "role1-2", collapsed: true, "children" : [
- { "roleName" : "客户采购订单", "roleId" : "role1-2-1", 'link' : '#/sale/order', "children" : [] },
- { "roleName" : "客户采购变更单", "roleId" : "role1-2-2", 'link' : '#/sale/change', "children" : [] },
- { "roleName" : "客户委外单", "roleId" : "role1-2-3", 'link' : '#/sale/maketodo/makeorder', "children" : [] },
- { "roleName" : "委外变更单", "roleId" : "role1-2-4", 'link' : '#/sale/makechange', "children" : [] },
- { "roleName" : "客户发货提醒", "roleId" : "role1-2-5", 'link' : '#/sale/notice', "children" : [] },
- { "roleName" : "发货单", "roleId" : "role1-2-6", 'link' : '#/sale/send', "children" : [] }
- ]},
- { "roleName" : "客户出入库", "roleId" : "role1-3", collapsed: true, "children" : [
- { "roleName" : "MRB单", "roleId" : "role1211", 'link' : '#/sale/MRB', "children" : [] },
- { "roleName" : "不良品出库单", "roleId" : "role1-3-1", 'link' : '#/sale/badOut', "children" : [] },
- { "roleName" : "不良品入库单", "roleId" : "role1-3-2", 'link' : '#/sale/badIn', "children" : [] },
- { "roleName" : "客户采购验收单", "roleId" : "role1-3-3", 'link' : '#/sale/accept', "children" : [] },
- { "roleName" : "客户采购验退单", "roleId" : "role1-3-4", 'link' : '#/sale/returns', "children" : [] },
- { "roleName" : "客户委外验收单", "roleId" : "role1-3-5", 'link' : '#/sale/makeaccept', "children" : [] },
- { "roleName" : "客户委外验退单", "roleId" : "role1-3-6", 'link' : '#/sale/makereturns', "children" : [] }
- ] },
- { "roleName" : "样品管理", "roleId" : "role1-4", collapsed: true, "children" : [
- { "roleName" : "客户打样申请", "roleId" : "role1-4-1", 'link' : '#/sale/sample', "children" : [] },
- { "roleName" : "客户认定单", "roleId" : "role1-4-2", 'link' : '#/sale/approval', "children" : [] }
- ] },
- { "roleName" : "基础资料", "roleId" : "role1-5", collapsed: true, "children" : [
- { "roleName" : "客户资料", "roleId" : "role1-5-1", 'link' : '#/sale/customer', "children" : [] },
- { "roleName" : "绩效考核", "roleId" : "role1-5-2", 'link' : '#/sale/vendorPerformanceAssess', "children" : [] },
- { "roleName" : "产品导入", "roleId" : "role1-5-3", 'link' : '#/sale/prodList', "children" : [] }
- ] }
- ]},
- { "roleName" : "买家中心(采购)", "roleId" : "role2", 'path': 'purc', level: 0, collapsed: true, "children" : [
- { "roleName" : "供应商资料", "roleId" : "role2-1-1", 'link' : '#/purc/vendor', "children" : [] },
- { "roleName" : "供应商服务", "roleId" : "role2-1-2", 'link' : '#/purc/vendor/serve', "children" : [] },
- { "roleName" : "采购物料", "roleId" : "role2-1-3", 'link' : '#/purc/product', "children" : [] },
- { "roleName" : "采购招标", "roleId" : "role2-1-4", 'link' : '#/purc/tender', "children" : [] },
- { "roleName" : "采购询价", "roleId" : "role2-1-5", 'link' : '#/purc/purchaseinquiry', "children" : [] },
- { "roleName" : "公共询价", "roleId" : "role2-1-6", 'link' : '#/purc/publicInquiry', "children" : [] },
- { "roleName" : "采购订单", "roleId" : "role2-1-7", 'link' : '#/purc/order', "children" : [] },
- { "roleName" : "采购变更单", "roleId" : "role2-1-8", 'link' : '#/purc/change', "children" : [] },
- { "roleName" : "代采订单", "roleId" : "role2-1-9", 'link' : '#/purc/deputy', "children" : [] },
- { "roleName" : "委外订单", "roleId" : "role2-1-10", 'link' : '#/purc/makeoutorder', "children" : [] }
- ]},
- { "roleName" : "财务", "roleId" : "role3", 'path': 'fa', level: 0, collapsed: true, "children" : [
- { "roleName" : "应收", "roleId" : "role3-1", collapsed: true, "children" : [
- { "roleName" : "发票", "roleId" : "role3-1-1", 'link' : '#/fa/apBill', "children" : [] },
- { "roleName" : "应收对账单", "roleId" : "role3-1-2", 'link' : '#/fa/apCheck', "children" : [] }
- ] },
- { "roleName" : "应付", "roleId" : "role3-2", collapsed: true, "children" : [
- { "roleName" : "应付对账单", "roleId" : "role3-2-1", 'link' : '#/fa/arCheck', "children" : [] }
- ]}
- ]},
- { "roleName" : "企业圈", "roleId" : "role4", 'path': 'baseInfo', level: 0, collapsed: true, "children" : [
- { "roleName" : "我的合作伙伴", "roleId" : "role4-1-1", 'link' : '#/baseInfo/myRequest', "children" : [] },
- { "roleName" : "新的合作伙伴", "roleId" : "role4-1-2", 'link' : '#/baseInfo/newPartner', "children" : [] }
- ]},
- { "roleName" : "基础设置", "roleId" : "role5", 'path': 'approvalFlow', collapsed: true, level: 0, "children" : [
- { "roleName" : "企业信息", "roleId" : "role5-1-1", 'link' : '#/approvalFlow/enterprise', "children" : [] },
- { "roleName" : "物料信息", "roleId" : "role5-1-2", 'link' : '#/approvalFlow/product', "children" : [] },
- { "roleName" : "我的产品库", "roleId" : "role5-1-3", 'link' : '#/approvalFlow/userProduct', "children" : [] },
- { "roleName" : "人员信息", "roleId" : "role5-1-4", 'link' : '#/approvalFlow/user', "children" : [] },
- { "roleName" : "角色权限", "roleId" : "role5-1-5", 'link' : '#/approvalFlow/role', "children" : [] },
- { "roleName" : "审批流", "roleId" : "role5-1-6", 'link' : '#/approvalFlow/flow', "children" : [] },
- { "roleName" : "操作日志", "roleId" : "role5-1-7", 'link' : '#/approvalFlow/log', "children" : [] }
- ]}
- ];
- $scope.currentObj = {};
- var hasChildrenObj = function (target) {
- var flag = false;
- if ($scope.currentObj.roleId && target && target.children) {
- angular.forEach(target.children, function (item) {
- if (item.roleId == $scope.currentObj.roleId) {
- flag = true;
- }
- if (item.children.length && hasChildrenObj(item)) {
- flag = true;
- }
- });
- }
- return flag;
- }
- var roopCall = function (arr, callBack) {
- angular.forEach(arr, function (item) {
- if (item.children && item.children.length) {
- roopCall(item.children, callBack);
- }
- callBack(item);
- })
- }
- var initObj = function (arr, flag) {
- angular.forEach(arr, function (item) {
- if (flag) {
- item.collapsed = false;
- }
- if (item.children && item.children.length) {
- initObj(item.children, item.path && item.path == $location.$$path.split('/')[1]);
- } else {
- if (item.link && item.link.split('#')[1] == $location.$$path) {
- item.selected = 'selected';
- $scope.currentObj = item;
- }
- }
- })
- }
- initObj($scope.roleList);
- var initClose = function () {
- roopCall($scope.roleList, function (item) {
- item.collapsed = !hasChildrenObj(item);
- })
- }
- initClose();
- var closeRow = function (arr) {
- angular.forEach(arr, function (item) {
- item.selected = undefined;
- if (item.children) {
- closeRow(item.children);
- }
- })
- }
- $scope.$watch( 'myTree.currentNode', function( newObj, oldObj ) {
- if( $scope.myTree && angular.isObject($scope.myTree.currentNode) ) {
- $scope.currentObj = newObj;
- if (newObj.link) {
- window.location.href = newObj.link
- }
- roopCall($scope.roleList, function (item) {
- if (item.roleId == newObj.roleId) {
- $scope.currentObj = item;
- // item.collapsed = !item.collapsed;
- } else {
- item.collapsed = !hasChildrenObj(item) && (item.roleId != newObj.roleId);
- }
- })
- // 父级菜单不选择
- if ($scope.currentObj.link) {
- closeRow($scope.roleList);
- $scope.currentObj.selected = 'selected';
- } else {
- $scope.currentObj.selected = null;
- }
- }
- }, false);
- }])
- return app;
- });
|