| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836 |
- 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'], 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']);
- app.init = function () {
- angular.bootstrap(document, ['myApp']);
- };
- app.config(['$httpProvider', function ($httpProvider) {
- // http拦截
- $httpProvider.interceptors.push('httpInterceptor');
- }]);
- app.factory('httpInterceptor', ['$window', '$q', '$injector', 'BaseService', function ($window, $q, $injector, BaseService) {
- var httpInterceptor = {
- 'responseError': function (response) {
- if (response.status == 401) {// UNAUTHORIZED
- // window.location.href = response.data.loginUrl || 'index';
- // window.location.href = window.location.origin + window.location.pathname + '/login';
- window.location.reload();
- return $q.reject(response);
- }
- return $q.reject(response);
- }
- }
- return httpInterceptor;
- }]);
- app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
- $stateProvider.state('index', {
- url: "/index",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/home/left.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/home/right.html",
- controller: 'RightCtrl'
- }
- }
- }).state('home', {
- url: "/",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/home/left.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/home/right.html",
- controller: 'RightCtrl'
- }
- }
- }).state('sale', {
- url: "/sale",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/sale/left.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/sale/right.html"
- }
- },
- controller: function ($scope) {
- $scope.truck = [];
- $scope.dataChanged = false;
- }
- }).state('sale.index', {
- url: "",
- templateUrl: "static/tpl/index/sale/index.html"
- }).state('sale.home', {
- url: "/",
- templateUrl: "static/tpl/index/sale/index.html"
- }).state('purc', {
- url: "/purc",
- views: {
- "left-view": {
- templateUrl: "static/tpl/index/purc/left.html",
- controller: 'LeftCtrl'
- },
- "right-view": {
- templateUrl: "static/tpl/index/purc/right.html"
- }
- },
- controller: function ($scope) {
- $scope.truck = [];
- $scope.dataChanged = false;
- }
- }).state('purc.index', {
- url: "",
- templateUrl: "static/tpl/index/purc/index.html"
- }).state('purc.home', {
- url: "/",
- templateUrl: "static/tpl/index/purc/index.html"
- }).state('purc.introduce', {
- url: "/introduce",
- templateUrl: "static/tpl/index/purc/introduce.html"
- }).state('purc.order', {
- url: "/order",
- templateUrl: "static/tpl/index/purc/order.html",
- controller: 'PurcOrderCtrl'
- }).state('purc.order_detail', {
- url: "/order/:id",
- templateUrl: "static/tpl/index/purc/order_detail.html",
- controller: 'PurcOrderDetailCtrl'
- }).state('purc.newOrder', {
- url: "/addOrder",
- templateUrl: "static/tpl/index/purc/addOrder.html",
- controller: 'PurcNewOrderCtrl'
- }).state('purc.cart', {
- url: "/cart",
- templateUrl: "static/tpl/index/purc/cart.html",
- controller: 'CartController'
- }).state('purc.cartDetail', {
- url: "/cart/:id",
- templateUrl: "static/tpl/index/purc/cart_detail.html",
- controller: 'CartDetailController'
- }).state('purc.deputy', {
- url: "/deputy",
- templateUrl: "static/tpl/index/purc/deputyOrder.html",
- controller: 'DeputyOrderCtrl'
- }).state('purc.deputylog', {
- url: "/deputylog",
- templateUrl: "static/tpl/index/purc/deputyorders_log.html",
- controller: 'DeputyOrderLogCtrl'
- }).state('purc.newdeputy', {
- url: "/deputy/add",
- templateUrl: "static/tpl/index/purc/deputyOrder_new.html",
- controller: 'NewDeputyOrderCtrl'
- }).state('purc.deputydetail', {
- url: "/deputy/:id",
- templateUrl: "static/tpl/index/purc/deputyOrder_detail.html",
- controller: 'DeputyOrderDetailCtrl'
- /* 招标列表 */
- }).state('purc.tenderlist', {
- url: "/tender",
- templateUrl: "static/tpl/index/purc/tenderlist.html",
- controller: 'PurcTenderCtrl'
- /* 招标答疑列表 */
- }).state('purc.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'
- }).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": {},
- "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/fa/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/fa/right.html"
- }
- }
- }).state('fa.index', {
- url: "",
- templateUrl: "static/tpl/index/fa/index.html"
- }).state('fa.home', {
- url: "/",
- templateUrl: "static/tpl/index/fa/index.html"
- }).state('fa.apBill', {
- url: "/apBill",
- templateUrl: "static/tpl/index/fa/apBill.html",
- controller: 'SaleApBillCtrl'
- }).state('fa.apBill_detail', {
- url: "/apBill/:id",
- templateUrl: "static/tpl/index/fa/apBill_detail.html",
- controller: 'SaleApBillDetailCtrl'
- }).state('fa.arCheck', {
- url: "/arCheck",
- templateUrl: "static/tpl/index/fa/arCheck.html",
- controller: 'SaleArCheckCtrl'
- }).state('fa.arCheck_detail', {
- url: "/arCheck/:id",
- templateUrl: "static/tpl/index/fa/arCheck_detail.html",
- controller: 'SaleArCheckDetailCtrl'
- }).state('fa.apCheck', {
- url: "/apCheck",
- params: {
- 'id': null
- },
- templateUrl: "static/tpl/index/fa/apCheck.html",
- controller: 'PurchaseApCheckCtrl'
- }).state('fa.apCheck_detail', {
- url: "/apCheck/:id",
- templateUrl: "static/tpl/index/fa/apCheck_detail.html",
- controller: 'PurchaseApCheckDetailCtrl'
- }).state('fa.apCheckList', {
- url: "/apCheckList",
- templateUrl: "static/tpl/index/fa/apCheckList.html",
- controller: 'PurchaseApCheckListCtrl'
- }).state('fa.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/approvalFlow/left.html"
- },
- "right-view": {
- templateUrl: "static/tpl/index/approvalFlow/right.html",
- }
- }
- }).state('approvalflow.flow', {
- url: "/flow",
- templateUrl: "static/tpl/index/approvalFlow/home.html",
- controller: 'approvalFlowCtrl'
- }).state('approvalflow.enterprise', {
- url: "/enterprise",
- templateUrl: "static/tpl/index/approvalFlow/enterprise.html",
- controller: 'EnterpriseCtrl'
- }).state('approvalflow.user', {
- url: "/user",
- templateUrl: "static/tpl/index/approvalFlow/user.html",
- controller: 'UserCtrl'
- }).state('approvalflow.log', {
- url: "/log",
- templateUrl: "static/tpl/index/approvalFlow/log.html",
- controller: 'LogCtrl'
- }).state('approvalflow.resource', {
- url: "/resource",
- templateUrl: "static/tpl/index/approvalFlow/resource.html",
- controller: 'ResourceCtrl'
- }).state('approvalflow.role', {
- url: "/role",
- templateUrl: "static/tpl/index/approvalFlow/role.html",
- controller: 'RoleCtrl'
- }).state('approvalflow.product', {
- url: "/product",
- templateUrl: "static/tpl/index/approvalFlow/prodList.html",
- controller: 'ProductAllCtrl'
- }).state('approvalflow.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', function ($scope, $rootScope, $modal, toaster) {
- $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";
- }
- }]);
- /**
- * 新消息提醒(调用公共服务接口) -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.switchto = function (enUU) {// 切换企业
- AuthenticationService.reSignin(enUU).success(function () {
- $window.location.reload();
- });
- };
- $scope.addFavorite = function () {
- var url = encodeURI(window.location.href);
- try {
- //ie浏览器收藏方式
- window.external.addFavorite(url, "优软商务平台");
- } catch (e) {
- try {
- //火狐浏览器收藏方式
- window.sidebar.addPanel("优软商务平台", url);
- } catch (e) {
- toaster.pop('warning', '提示', "您的浏览器不支持自动添加收藏夹,请使用Ctrl+D进行添加," +
- "或手动在浏览器里进行设置。");
- }
- }
- };
- }]);
- app.controller('LogOutCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
- $scope.close = function (confirm) {
- $modalInstance.close(confirm);
- };
- }]);
- app.controller('ImageInsertCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
- $scope.image = {src: null};
- // 图片上传成功之后
- $scope.onUploadSuccess = function (data) {
- var path = data.path;
- path = path.substring(0, path.lastIndexOf('.')) + "_150x90" + path.substr(path.lastIndexOf('.'));
- $scope.$apply(function () {
- $scope.image.src = data.path;
- $scope.image.thumb = path;
- });
- };
- $scope.close = function () {
- $modalInstance.dismiss();
- };
- $scope.confirm = function () {
- $modalInstance.close($scope.image);
- $scope.imageUrl = null;
- };
- }]);
- app.controller('TodoCtrl', ['$scope', 'SnapshotService', 'BaseService', '$rootScope', function ($scope, SnapshotService, BaseService, $rootScope) {
- BaseService.scrollBackToTop();
- SnapshotService.getTodo(function (data) {
- $scope.todo = data;
- });
- 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();
- }]);
- 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();
- }
- });
- } 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();
- }
- });
- } 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) {
- // $scope.getUnreadIds();
- });
- };
- 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', function ($scope, $modalInstance, customer, AccountUser, toaster) {
- $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 ($scope.thisUser.sys || $scope.thisUser.transfer) {
- if (user.transfer) {
- transfer.push({num: index});
- }
- } else {
- if (user.distribute) {
- 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.distribute = false;
- } else {
- userInfo.distribute = 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.isUnread(id)){
- return;
- }
- var sourceId = [];
- sourceId.push(id);
- PurcOrders.setRead({}, sourceId, function (message) {
- // $scope.getUnreadIds();
- 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', 'PurcOrderItemHis', 'PagingRelease', 'SnapshotService', 'PurcOrderItemInfo', 'token', 'CurrentRole', '$timeout', '$modal', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis, 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) {
- angular.forEach(order.orderItems, function (item) {
- str += item.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 loadData = function () {
- PurcOrder.get({id: $stateParams.id}, function (data) {
- $scope.order = data;
- var sum = 0;
- angular.forEach($scope.order.orderItems, function (item) {
- sum += item.qty * item.price;
- });
- $scope.order.total = sum;
- if ($scope.order.display == 1) {//未查看的设为已查看
- $scope.setDisplay('setRead', $scope.order.id);
- }
- $scope.loading = false;
- }, 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) {
- window.open("file/batch/" + id);
- }
- }]);
- app.controller('SaleChangeCtrl', ['$scope', '$filter', 'PurcChange', 'PurcChanges', 'ngTableParams', 'toaster', 'BaseService', 'PurcChangeHis', 'CurrentRole', function ($scope, $filter, PurcChange, PurcChanges, ngTableParams, toaster, BaseService, PurcChangeHis, 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,5})?$/;
- 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,5})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- // 搜索框回车
- $scope.onSearch = function (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,5})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,5})?$/;
- 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', function ($scope, PurchaseInquiry, toaster, BaseService, $upload, $filter, $modal, $rootScope, ngTableParams, PurcProduct, PurcProductNewest, $timeout, $http, ShipAddress, Search, ComponentActiveAPI) {
- $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);
- $timeout(function () {
- $rootScope.active = 'done';
- window.location.hash = "#/baseInfo/inquiryList";
- }, 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 {
- $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);
- $timeout(function () {
- window.location.hash = "#/baseInfo/inquiryList";
- }, 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 {
- $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();
- /**
- * 改变单据日期范围
- */
- var getTenderDateCondition = function (zone, condition) {
- var date = new Date();
- if (zone == -1) {
- condition.dateFrom = null;
- condition.dateTo = null;
- } else if (zone == 7) { // 一星期内
- date.setHours(0, 0, 0 ,0);
- date.setDate(date.getDate() - 7);
- condition.dateFrom = date;
- var ndate = new Date();
- ndate.setHours(23, 59, 59 ,999);
- ndate.setDate(ndate.getDate() - 1);
- condition.dateTo = ndate;
- } 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.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.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
- var getState = function (active) {
- var fn = 'getOpenAll';
- switch (active) {
- case 'all':
- fn = 'getOpenAll';
- break;
- case 'todo':
- fn = 'getOpenTodo';
- break;
- case 'end':
- fn = 'getOpenEnd';
- break;
- }
- return fn;
- };
- customer.distribute({}, function(data) {
- $scope.customer = data;
- });
- $scope.setActive = function (state) {
- if ($scope.active != state) {
- $scope.active = state;
- if ($scope.active == 'all') {
- $scope.distribute = null;
- $scope.remind = false;
- } else if ($scope.active == 'customer') {
- $scope.distribute = $scope.customer;
- if ($scope.distribute.length == 0) {
- $scope.distribute = [0];
- }
- $scope.remind = false;
- } else if ($scope.active == 'remind') {
- $scope.remind = true;
- }
- if ($scope.tableParams.page() == 1) {
- $scope.tableParams.reload();
- } else {
- $scope.tableParams.page(1);
- }
- }
- };
- var getService = function () {
- return publicInquiryList.getInquirylist;
- }
- $scope.tableParams = new ngTableParams({
- page: 1,
- count: 20,
- sorting: {
- // 'tender.endDate': 'desc',
- // 'tender.enterprise.enName': 'asc',
- // 'tender.code': 'asc'
- }
- }, {
- total: 0,
- counts: [10, 25, 50, 100],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- // var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- fromDate: getDateTime($scope.condition.dateFrom),
- endDate: getDateTime($scope.condition.dateTo)
- };
- AccountEnterprise.get({}, function(data) {
- $scope.currentEn = data;
- publicInquiry.getUrl({}, function(data) {
- $scope.url = data.url;
- if (!$scope.remind) {// 非推荐信息
- $http({
- method: 'get',
- dataType: 'json',
- url: $scope.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 {// 推荐报价信息
- 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);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
- }
- }).error(function (err) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', err);
- });
- });
- }
- // 顶部滚动消息
- $http({
- method: 'get',
- url: $scope.url + '/inquiry/public/messageList',
- params: {enuu: $scope.currentEn.uu, size: 10},
- dataType: 'json'
- }).success(function(data) {
- $scope.message = data;
- }).error(function(error) {
- });
- });
- });
- }
- });
- $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('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', 'PurcNoticeHis', '$modal', 'SaleTruck', 'Symbol', '$state', '$timeout', 'PurcNoticeInfo', 'token', 'CurrentRole', function ($scope, $rootScope, $filter, PurcNotice, ngTableParams, toaster, BaseService, PurcNoticeHis, $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: 1};
- $scope.searchStatus = 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.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(25);
- } 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('PurchaseApBillOutCtrl',['$scope', 'FaApBillOut', 'BaseService', 'ngTableParams', 'toaster','ReportService', 'Symbol', function ($scope, FaApBillOut, BaseService, ngTableParams, toaster, ReportService , Symbol) {
- BaseService.scrollBackToTop();
- $scope.dateZoneText = '不限';
- $scope.condition = {dateZone: 1};
- $scope.currency = Symbol.currency;//将币别转化为对应的符号
- $scope.active = 'all';
- /* 时间筛选初始化*/
- 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 (billOut) {
- FaApBillOut.printCount({id: billOut.id},function (data) {
- if(!data.error) {
- toaster.pop('success', '提示', '打印成功');
- //$scope.tableParams.reload();
- }else{
- toaster.pop('error', '提示', '打印失败');
- }
- });
- //ReportService.print(billOut.custUu, 'PURCBILLOUT', 'where purc$apbillout.pabo_id =' + billOut.id);
- };
- //状态
- $scope.setActive = function (state) {
- if($scope.active != state) {
- $scope.active = state;
- if($scope.tableParams.page() == 1)
- $scope.tableParams.reload();
- else
- $scope.tableParams.page(1);
- }
- };
- $scope.changeDateZone = function (zone) {
- $scope.condition.dateZone = zone;
- $scope.dateZoneText = 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)
- };
- FaApBillOut[getState($scope.active )](BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if(page) {
- params.total(page.totalElement);
- $scope.data = $defer.resolve(page.content);
- $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的条件
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- if($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]){
- $scope.tableParams.reload();
- }
- };
- // 计算开票数量
- $scope.getTotalProd = function (billOut) {
- var total = 0;
- if(billOut.items) {
- angular.forEach(billOut.items, function (value) {
- total += value.NowQty;
- });
- }
- return total;
- };
- // 搜索框回车
- $scope.onSearch = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- // 选择查找日期
- $scope.onDateCondition = function () {
- $scope.tableParams.page(1);
- $scope.tableParams.reload();
- };
- }]);
- //开票单详情
- app.controller('PurchaseApBillOutDetailCtrl',['$scope', 'toaster', 'FaApBillOut', 'FaApCheck', '$stateParams', 'BaseService', function ($scope, toaster, FaApBillOut, FaApCheck, $stateParams, BaseService) {
- BaseService.scrollBackToTop();
- $scope.haveSelected = true;
- $scope.data = {};
- //控制提交和删除按钮的显示
- $scope.ifShow = true;
- var loadData = function () {
- FaApBillOut.get({id:$stateParams.id},function (data) {
- $scope.data = data;
- if($scope.data.status){
- }else{
- $scope.ifShow = true;
- }
- })
- };
- if($stateParams.id){
- loadData();
- }
- $scope.haveSource = false;
- //TODO 提交开票单
- $scope.invoiceIssued = function (apBillOut) {
- $scope.loading = true;
- FaApBillOut.invoiceIssued({id:apBillOut.id},function (data) {
- $scope.loading = false;
- if(data.apBillOut) {
- $scope.haveSelected = false;
- window.location.href = '#/fa/apBillOut';
- toaster.pop('success', '提示', '提交成功');
- } else {
- $scope.loading = false;
- toaster.pop('error', '提示', data.error);
- }
- })
- }
- //删除开票单(后台同时更新对账单明细表已开票数)
- $scope.deleteApBillOut = function () {
- FaApBillOut.deleteApBillOut({id:$stateParams.id},function (data) {
- window.location.href = '#/fa/apBillOut';
- toaster.pop('success','提示','删除成功');
- },function () {
- toaster.pop('error','提示','删除失败');
- });
- $scope.haveSelected = false;
- }
- //TODO 作废开票单
- $scope.InvoiceCancel = function () {
- $scope.loading = true;
- FaApBillOut.InvoiceCancel({id:$stateParams.id},function (data) {
- $scope.loading = false;
- if(!data.error) {
- toaster.pop('success', '提示', '作废成功');
- window.location.href = '#/fa/apBillOut';
- $scope.tableParams.reload();
- }else{
- toaster.pop('error', '提示', data.error);
- }
- },function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }]);
- //航天开票单据列表
- app.controller('PurchaseApBillOutListCtrl',['$scope', 'FaApCheck', 'FaApBillOut', 'toaster', '$state','$filter', '$modal', function ($scope, FaApCheck, FaApBillOut, toaster, $state, $filter, $modal) {
- $scope.data = [];// 列表数据
- $scope.condition = {
- $fromOpened: false
- }
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- }
- //查找客户
- $scope.searchCust = function (suuorname) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/fa/custInfo.html',
- controller: 'SearchCustInfoCtrl',
- resolve: {
- suuorname: function () {
- return suuorname;
- }
- }
- });
- modalInstance.result.then(function (suuorname) {
- $scope.suuorname = suuorname;
- });
- }
- // 点击筛选根据条件选择数据
- $scope.suuorname = '';
- // 默认本月
- $scope.sdateTo = new Date();
- $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
- $scope.vuuorname = '';
- $scope.factory = '';
- $scope.prodTitle = '';
- $scope.prodSpec = '';
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodTitle = '';
- $scope.condition.prodSpec = '';
- $scope.searchOrder = function (check) {
- $scope.data = [];
- $scope.checkboxes.checked = false;
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory;
- $scope.condition.prodTitle = $scope.prodTitle;
- $scope.condition.prodSpec = $scope.prodSpec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf()) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- if($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
- $scope.fromDate =$scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.keywordXls = angular.copy(($scope.condition.uuorname == null ? "" : $scope.condition.uuorname)
- + "|"+ ($scope.condition.venduuorname == null ? "" : $scope.condition.venduuorname)
- + "|"+ ($scope.condition.factory == null ? "" : $scope.condition.factory)
- + "|"+ ($scope.condition.prodTitle == null ? "" : $scope.condition.prodTitle)
- + "|"+ ($scope.condition.prodSpec == null ? "" : $scope.condition.prodSpec));//保存当前取值的关键词
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if(!$scope.suuorname) {
- toaster.pop('warning','提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- $scope.loading = true;
- FaApBillOut.getDoneApCheckByKeywords({fromDate: $scope.fromDate, endDate: $scope.endDate, keyword:$scope.keywordXls}, function(data) {
- if(data.length > 0) {
- angular.forEach(data, function (checkItem) {
- checkItem.$selected = true;
- if(checkItem.billed) {
- checkItem.thisBilledQty = checkItem.checkQty - checkItem.billed;
- //$filter('number')(checkItem.thisBilledQty, 2);
- } else {
- checkItem.billed = 0;
- checkItem.thisBilledQty = checkItem.checkQty;
- }
- //最大最小开票数
- checkItem.maxThisBilledQty = checkItem.thisBilledQty;
- checkItem.minThisBilledQty = 0;
- });
- $scope.data = data;
- $scope.checkboxes.checked = true;
- $scope.getTotalMoney();
- } else {
- toaster.pop('info', '提示', '当前没有需要对账记录');
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- }
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.totalMoney = 0;
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- $scope.totalMoney = 0;
- $scope.filteredData = $filter('filter')($scope.data, $scope.condition.prodTitle || $scope.condition.uuorname || $scope.condition.venduuorname || $scope.condition.prodSpec || $scope.condition.factory);
- var uuorname = $scope.suuorname;
- var venduuorname = $scope.venduuorname;
- var dateFrom = $scope.condition.dateFrom;
- var dateTo = $scope.condition.dateTo;
- var prodTitle = $scope.condition.prodTitle;
- var prodSpec = $scope.condition.prodSpec;
- var factory = $scope.condition.factory;
- angular.forEach($scope.filteredData, function (item) {
- if((item.apCheck.apDate >= dateFrom || dateFrom == '') && (item.apCheck.apDate < dateTo || dateTo == '')){
- item.$selected = $scope.checkboxes.checked;
- }
- });
- $scope.getTotalMoney();
- };
- //获取已选单据总金额
- var total = true;
- $scope.getTotalMoney = function () {
- $scope.totalMoney = 0;
- angular.forEach($scope.data, function (check) {
- if(check.$selected){
- $scope.totalMoney += (check.CheckQty || 0)*(check.orderPrice || 0);
- }else{
- $scope.totalMoney += 0;
- }
- });
- }
- // 点击其中一个明细的复选框
- $scope.checkOne = function (check) {
- var result = true;
- angular.forEach($scope.data, function (item) {
- if(item.$selected != true){
- result = false;
- return;
- }
- });
- $scope.checkboxes.checked = result;
- };
- $scope.haveSelected = false;
- //生成开票单
- $scope.createApBillOut = function () {
- //保存应收对账单主记录字段
- $scope.apBillOut = {
- custUu: '',
- custName: '',
- beginDate: '',
- endDate: '',
- enUu: '',
- recordDate: '',
- checkStatus: '未开票',
- currency: '',
- rate: '',
- //billed:'',
- //apBillOutItemId:'',
- items: [],
- sourceInfos: []
- };
- //保存来源单据相关信息
- //var sourceInfos = [];
- //所允许的本次对账最大最小数量
- //$scope.data.maxThisCheckQty = 0;
- //$scope.data.minThisCheckQty = 0;
- $scope.sameCust = true;
- $scope.validQty = true;
- $scope.loading = true;
- angular.forEach($scope.data, function (checkItem) {
- //保存开票单明细行数据
- $scope.item = {
- inoutno: '',
- inoutnodetno: '',
- orderCode: '',
- orderClass: '',
- orderDetno: '',
- price: '',
- NowQty: '',
- //amount: '',
- sourceId:'',
- sourceTable:'',
- //oldYCheckQty:'',
- status: 0,
- //receiveCode:'',
- //receiveName:'',
- prodCode:'',
- //prodSpec:'',
- taxrate: '',
- //sendcode: '',
- //whname: '',
- };
- //开票单明细行来源表信息(新的已开票数)
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newBilledQty: 0
- };
- //本次开票新的开票数
- //$scope.thisBilledQty = 0;
- if(checkItem.$selected == true) {
- $scope.apBillOut.custName = checkItem.apCheck.custName;
- $scope.apBillOut.enUu = checkItem.apCheck.enUu;
- $scope.item.inoutno = checkItem.inoutno;
- $scope.item.inoutnodetno = checkItem.inoutnodetno;
- $scope.item.orderCode = checkItem.orderCode;
- $scope.item.orderClass = checkItem.orderClass;
- $scope.item.orderDetno = checkItem.orderDetno;
- $scope.item.NowQty = checkItem.thisBilledQty;
- if (typeof(checkItem.billed) == "undefined") {
- checkItem.billed = 0;
- $scope.sourceInfo.newBilledQty =checkItem.thisBilledQty;
- } else {
- //TODO 变成了字符串相加?
- $scope.sourceInfo.newBilledQty = checkItem.thisBilledQty + checkItem.billed;
- }
- //$scope.apBillOut.apBillOutItemId = check.id;
- $scope.apBillOut.recordDate = checkItem.recordDate;
- $scope.apBillOut.rate = checkItem.apCheck.rate;
- //必须是同一家客户才能生成对账单,否则提示错误
- if($scope.apBillOut.custUu == ''){
- $scope.apBillOut.custUu = checkItem.apCheck.custUu;
- }else if($scope.apBillOut.custUu !== checkItem.apCheck.custUu){
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一家客户');
- }
- //必须是相同币别才能生成对账单,否则提示错误
- if ($scope.apBillOut.currency == '') {
- $scope.apBillOut.currency = checkItem.apCheck.currency;
- } else if ($scope.apBillOut.currency !== checkItem.apCheck.currency) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一种币别');
- }
- //本次对账数量必须小于总对账数量
- if (checkItem.checkQty > 0) {
- if (checkItem.minThisBilledQty >checkItem.thisBilledQty || checkItem.maxThisBilledQty <checkItem.thisBilledQty) {
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error','本次开票数量,填写有误!');
- }
- } else if (check.qty < 0) {
- $scope.data.maxCheckQty = 0;
- $scope.data.minCheckQty = check.qty;
- if(((-check.qty)-(-check.yCheckQty) < (-check.CheckQty)) || check.CheckQty > 0 || check.CheckQty == 0){
- $scope.validQty = false;
- $scope.loading = false;
- toaster.pop('error','本次开票数量,填写有误!');
- }
- }
- //TODO
- //获取最小时间作为对账区间的起始时间
- if($scope.apBillOut.beginDate == ''){
- $scope.apBillOut.beginDate = checkItem.apCheck.apDate;
- }else{
- $scope.apBillOut.beginDate = $scope.apBillOut.beginDate>checkItem.apCheck.apDate? checkItem.apCheck.apDate : checkItem.apCheck.beginDate;
- }
- //获取最大时间作为对账区间的截止时间
- if($scope.apBillOut.endDate == ''){
- $scope.apBillOut.endDate = checkItem.apCheck.apDate;
- }else{
- $scope.apBillOut.endDate = $scope.apBillOut.endDate<checkItem.apCheck.apDate? checkItem.apCheck.apDate : checkItem.apCheck.endDate;
- }
- //应收开票单明细行数据
- $scope.item.price = checkItem.price;
- $scope.item.sourceId = checkItem.id;
- $scope.item.sourceTable = 'PURC$APCHECKITEM';//瑕疵
- $scope.item.NowQty = checkItem.thisBilledQty;
- $scope.item.prodCode = checkItem.prodCode;
- $scope.item.taxrate = checkItem.taxrate;
- //来源表相关信息
- $scope.sourceInfo.sourceId = checkItem.id;
- $scope.sourceInfo.sourceTable = 'PURC$APCHECKITEM';//瑕疵
- $scope.sourceInfo.newBilledQty = ((checkItem.billed || 0) + checkItem.thisBilledQty);
- //sourceInfos.push($scope.sourceInfo);
- $scope.apBillOut.items.push($scope.item);
- $scope.apBillOut.sourceInfos.push($scope.sourceInfo);
- $scope.haveSelected = true;
- }
- });
- //保存生成的开票单,后台同时更新对账单明细表中已开票数
- $scope.saveApBillOut = function () {
- FaApBillOut.saveApBillOut({}, $scope.apBillOut, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '生成开票单成功');
- $state.go('fa.apBillOut_detail', {id: data.id}, {reload:true});
- }, function (response) {
- toaster.pop('error', '生成开票单失败', response.data);
- });
- };
- //如果是同一家客户,生成对账单的同时,关闭模态框
- if($scope.sameCust && $scope.validQty) {
- $scope.saveApBillOut();
- }
- }
- }]);
- /**
- * 客户应付发票
- */
- 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.suuorname = '';
- // 默认本月
- $scope.sdateTo = new Date();
- $scope.sdateFrom = new Date($scope.sdateTo.getFullYear(), $scope.sdateTo.getMonth(), 1);
- $scope.vuuorname = '';
- $scope.factory = '';
- $scope.prodtitle = '';
- $scope.prodspec = '';
- $scope.condition.uuorname = '';
- $scope.condition.dateFrom = '';
- $scope.condition.dateTo = '';
- $scope.condition.venduuorname = '';
- $scope.condition.factory = '';
- $scope.condition.prodtitle = '';
- $scope.condition.prodspec = '';
- $scope.searchOrder = function (check) {
- $scope.data = [];
- $scope.checkboxes.checked = false;
- $scope.totalMoney = 0;
- $scope.condition.uuorname = $scope.suuorname;
- $scope.condition.factory = $scope.factory
- $scope.condition.prodtitle = $scope.prodtitle;
- $scope.condition.prodspec = $scope.prodspec;
- $scope.condition.dateFrom = ($scope.sdateFrom || 0);
- $scope.thisdatato = ($scope.sdateTo || 0);
- if ($scope.thisdatato != 0) {
- $scope.condition.dateTo = (new Date($scope.thisdatato.valueOf()) || 0);
- } else {
- $scope.condition.dateTo = ($scope.sdateTo || 0);
- }
- $scope.condition.venduuorname = $scope.vuuorname;
- if ($scope.condition.dateFrom != null || $scope.condition.dateTo != null || $scope.keywordXls != null) {
- $scope.fromDate = $scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null;
- $scope.endDate = $scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null;
- $scope.keywordXls = angular.copy(($scope.condition.uuorname == null ? "" : $scope.condition.uuorname)
- + "|" + ($scope.condition.venduuorname == null ? "" : $scope.condition.venduuorname)
- + "|" + ($scope.condition.factory == null ? "" : $scope.condition.factory)
- + "|" + ($scope.condition.prodtitle == null ? "" : $scope.condition.prodtitle)
- + "|" + ($scope.condition.prodspec == null ? "" : $scope.condition.prodspec));//保存当前取值的关键词
- $scope.exportKeywordXls = encodeURIComponent($scope.keywordXls);
- $scope.fromDateXls = angular.copy($scope.condition.dateFrom ? $scope.condition.dateFrom.getTime() : null);//保存当前取值的起始日期
- $scope.endDateXls = angular.copy($scope.condition.dateTo ? $scope.condition.dateTo.getTime() : null);//保存当前取值的截止日期
- if (!$scope.suuorname) {
- toaster.pop('warning', '提示', '请先选择客户');
- document.getElementById('suuorname').focus();//光标默认在客户
- } else {
- $scope.loading = true;
- FaApCheck.getAllByKeywords({
- fromDate: $scope.fromDate,
- endDate: $scope.endDate,
- keyword: $scope.keywordXls
- }, function (data) {
- if (data.length > 0) {
- angular.forEach(data, function (item) {
- item.$selected = true;
- });
- $scope.data = data;
- $scope.checkboxes.checked = true;
- $scope.getTotalMoney();
- } else {
- toaster.pop('info', '提示', '当前没有需要对账记录');
- }
- $scope.loading = false;
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '提示', response.data);
- });
- }
- }
- }
- /**
- * 点击勾选框,选中要转应收对账单的订单
- * */
- $scope.totalMoney = 0;
- $scope.checkboxes = {
- checked: false
- };
- // 点击勾选全部的复选框
- $scope.checkAll = function () {
- $scope.totalMoney = 0;
- $scope.filteredData = $filter('filter')($scope.data, $scope.condition.prodtitle || $scope.condition.uuorname || $scope.condition.venduuorname || $scope.condition.prodspec || $scope.condition.factory);
- var uuorname = $scope.suuorname;
- var venduuorname = $scope.venduuorname;
- var dateFrom = $scope.condition.dateFrom;
- var dateTo = $scope.condition.dateTo;
- var prodTitle = $scope.condition.prodtitle;
- var prodSpec = $scope.condition.prodspec;
- var factory = $scope.condition.factory;
- angular.forEach($scope.filteredData, function (item) {
- if ((item.pidate >= dateFrom || dateFrom == '') && (item.pidate < dateTo || dateTo == '')) {
- item.$selected = $scope.checkboxes.checked;
- }
- });
- $scope.getTotalMoney();
- };
- //获取已选单据总金额
- var total = true;
- $scope.getTotalMoney = function () {
- $scope.totalMoney = 0;
- angular.forEach($scope.data, function (check) {
- if (check.$selected) {
- 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: '',
- prodSpec: '',
- taxrate: '',
- sendcode: '',
- whname: '',
- };
- //应收对账单明细行来源表信息
- $scope.sourceInfo = {
- sourceId: '',
- sourceTable: '',
- newYCheckQty: ''
- };
- //此次对账后新的已转数
- $scope.newYCheckQty = 0;
- if (check.$selected == true) {
- $scope.apCheck.custName = check.custname;
- $scope.apCheck.enUu = check.enuu;
- $scope.apCheck.checkAmount += (check.thischeckqty || 0) * (check.orderprice || 0);
- $scope.apCheck.apDate = check.pidate;
- $scope.apCheck.rate = check.rate;
- //必须是同一家客户才能生成对账单,否则提示错误
- if ($scope.apCheck.custUu == '') {
- $scope.apCheck.custUu = check.custuu;
- } else if ($scope.apCheck.custUu !== check.custuu) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一家客户');
- }
- //必须是相同币别才能生成对账单,否则提示错误
- if ($scope.apCheck.currency == '') {
- $scope.apCheck.currency = check.currency;
- } else if ($scope.apCheck.currency !== check.currency) {
- $scope.sameCust = false;
- $scope.loading = false;
- toaster.pop('error', '请选择同一种币别');
- }
- //必须是相同税率才能生成对账单,否则提示错误
- if (!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', '本次对账数量,填写有误!');
- }
- }
- //获取最小时间作为对账区间的起始时间
- if ($scope.apCheck.beginDate == '') {
- $scope.apCheck.beginDate = check.pidate;
- } else {
- $scope.apCheck.beginDate = $scope.apCheck.beginDate > check.pidate ? check.pidate : $scope.apCheck.beginDate;
- }
- //获取最大时间作为对账区间的截止时间
- if ($scope.apCheck.endDate == '') {
- $scope.apCheck.endDate = check.pidate;
- } else {
- $scope.apCheck.endDate = $scope.apCheck.endDate < check.pidate ? check.pidate : $scope.apCheck.endDate;
- }
- //应收对账单明细行数据
- $scope.item.orderCode = check.ordercode;
- $scope.item.orderClass = check.piclass;
- $scope.item.orderDetno = check.orderdetno;
- $scope.item.price = check.orderprice;
- $scope.item.checkQty = check.thischeckqty;
- $scope.item.amount = (check.thischeckqty || 0) * (check.orderprice || 0);
- $scope.item.sourceId = check.sourceid;
- $scope.item.sourceTable = check.sourcetable;
- $scope.item.oldYCheckQty = check.ycheckqty;
- $scope.item.prodCode = check.prodcode;
- $scope.item.prodTitle = check.prodtitle;
- $scope.item.prodSpec = check.prodspec;
- $scope.item.inoutno = check.inoutno;
- $scope.item.inoutnodetno = check.detno;
- $scope.item.taxrate = check.taxrate;
- $scope.item.receiveCode = check.receivecode;
- $scope.item.receiveName = check.receivename;
- $scope.item.sendcode = check.sendcode;
- $scope.item.whname = check.whname;
- //来源表相关信息
- $scope.sourceInfo.sourceid = check.sourceid;
- $scope.sourceInfo.sourcetable = check.sourcetable;
- $scope.sourceInfo.newYCheckQty = ((check.ycheckqty || 0) + check.thischeckqty);
- sourceInfos.push($scope.sourceInfo);
- $scope.apCheck.items.push($scope.item);
- $scope.haveSelected = true;
- }
- });
- //保存生成的应收对账单
- $scope.saveApCheck = function () {
- FaApCheck.saveApCheck({}, $scope.apCheck, function (data) {
- $scope.loading = false;
- toaster.pop('success', '成功', '生成应收对账成功');
- $state.go('fa.apCheck_detail', {id: data.id}, {reload: true});
- }, function (response) {
- $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);
- });
- // 获取企业开票信息
- AccountEnterprise.getApBillOutInfo({enuu: $scope.enterprise.uu}, {}, function(data) {
- $scope.apBillOutInfo = 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);
- });
- };
- // 更新企业开票信息
- $scope.updateApBillOutInfo = function(uu){
- $scope.loading = true;
- $scope.apBillOutInfo.uu = uu;
- AccountEnterprise.saveApBillOutInfo($scope.apBillOutInfo, function(){
- $scope.loading = false;
- $scope.apBillOutInfoEditing = 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({}, 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 + unread.change + unread.makeOrder;
- }
- };
- $scope.getSaleInquiryCount = function (unread) {
- if (unread != undefined) {
- return unread.inquiry + unread.mould;
- }
- };
- $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.loading = false;
- $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);
- });
- }
- });
- // //设置单据已读
- // var setOrdersRead = function () {
- // var ids = [];
- // GetProductInfo.setRead({}, ids, function (message) {
- // });
- // };
- // 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) {
- $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.updateone = function (id) {
- $scope.loading = true;
- Products.updateone({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- window.location.reload();
- }
- $scope.loading = false;
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 选择类目
- $scope.selectKind = function (cmpcode) {
- if (cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function () {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
- // 取消
- $scope.cancel = function () {
- GetProductInfo.getOne({id: $stateParams.id}, function (data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
- // 删除
- $scope.clearfile = function () {
- $scope.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;
- if (data.id) {
- recentPrice.agreed({prId: data.id}, {}, function(response) {
- price = response.price;
- $scope.order.orderItems.push({
- code: data.code,
- title: data.title,
- spec: data.spec,
- unit: data.unit,
- qty: null,
- price: price,
- remark: null,
- delivery: null,
- prid: data.id,
- taxrate: $scope.order.rate,
- 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.price,
- 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 () {
- $modalInstance.close($scope.result.products);
- }
- // 点击确定时增加加载标志
- $scope.addClass = function() {
- $scope.loading = true;
- }
- $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', function ($scope, AddPartnerMyRequest, toaster, BaseService, ngTableParams, AddPartner, $timeout, $rootScope, VendorInfo, $window) {
- 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.error) {
- toaster.pop('error', '提示', '操作失败');
- }
- // $scope.tableParams.reload();
- $window.location.reload();
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- };
- AddPartnerMyRequest.requestAmount({}, function (data) {
- $scope.requestTodo = data;
- });
- // 拒绝申请
- $scope.refuse = function (id, reason) {
- AddPartner.refuseRequest({id: id, reason: reason}, {}, function (data) {
- 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('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;
- if (data.id) {
- recentPrice.agreed({prId: data.id}, {}, function(response) {
- price = response.price;
- $scope.order.orderItems.push({
- code: data.code,
- title: data.title,
- spec: data.spec,
- unit: data.unit,
- qty: null,
- price: price,
- remark: null,
- delivery: null,
- prid: data.id,
- taxrate: $scope.order.rate,
- 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.price,
- 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: '甲方承担',
- 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.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.totalpayament >= 3000000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过300万美金,');
- } 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.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.totalpayament >= 3000000) {
- toaster.pop('error', '提示', '单张订单委托采购总金额不得超过300万美金,');
- } 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', '提示', '保存成功');
- 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.updateone = function (id) {
- Products.updateone({id: id}, {}, function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- window.location.reload();
- }
- }, function (response) {
- toaster.pop('error', '提示', response.data);
- });
- }
- // 选择类目
- $scope.selectKind = function (cmpcode) {
- if (cmpcode == null) {
- $modal.open({
- animation: true,
- size: 'lg',
- templateUrl: 'static/tpl/index/baseInfo/modal/product_kindChoose_modal.html',
- controller: 'KindChooseCtrl',
- }).result.then(function (data) {
- $scope.kindId = data;
- var modalInstance = $modal.open({
- templateUrl: 'static/tpl/index/baseInfo/modal/Component_KindChoose_modal.html',
- controller: 'FindComponentCtrl',
- size: 'lg',
- resolve: {
- KindId: function () {
- return $scope.kindId;
- }
- }
- });
- modalInstance.result.then(function (data) {
- $scope.prodInfo.cmpUuId = data.uuid;
- $scope.prodInfo.pcmpcode = data.code;
- $scope.prodInfo.pbranden = data.brand.nameEn;
- $scope.prodInfo.pbrand = data.brand.nameCn;
- }, function () {
- });
- }, function () {
- });
- }
- };
- $scope.isShow = true;
- // 更新
- $scope.update = function () {
- $scope.prodInfo.$editing = true;
- $scope.isShow = true;
- };
- // 取消
- $scope.cancel = function () {
- GetProductInfo.getOne({id: $stateParams.id}, function (data) {
- $scope.prodInfo = data;
- $scope.prodInfo.$editing = false;
- $scope.isShow = false;
- $scope.loading = false;
- });
- };
- // 删除
- $scope.clearfile = function () {
- $scope.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', function ($scope, $filter, PubInquirySearchInfo, ngTableParams, toaster, BaseService, PubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry, $modal, 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 ? PubInquirySearchInfo : PubInquiryNoSearchInfo;
- };
- $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 = {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.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) {
- publicInquiry.getHistory({itemId: item.id}, function (data) {
- item.history = data;
- });
- }
- };
- // 报价
- $scope.quote = function(inquiryItem) {
- $modal.open({
- animation: true,
- templateUrl: 'static/tpl/index/sale/modal/quote_inquiry.html',
- controller: 'QuoteInquiryCtrl',
- resolve: {
- inquiryItem: function () {
- return inquiryItem
- }
- }
- }).result.then(function (data) {
- }, function () {})
- };
- $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/pubInquiry/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 {
- publicInquiry.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/pubInquiry/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 {
- publicInquiry.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,5})?$/;
- 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,5})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- // 搜索框回车
- $scope.onSearch = function (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('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,5})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- $scope.verifylapQty = function (value, index, inquiryItem) {
- value = parseInt(value);
- var regex = /^\d+(.\d{1,5})?$/;
- 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,5})?$/;//
- switch (type) {
- case 'minOrderQty':
- $scope.minOrderQtyVerify = regex.test(value);
- break;
- case 'minPackQty':
- $scope.minPackQtyVerify = regex.test(value);
- break;
- case 'leadtime':
- $scope.leadtimeVerify = regex.test(value);
- break;
- default:
- $scope.replyPrices[type] = regex.test(value);
- break;
- }
- }
- // 采纳
- $scope.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);
- }
- }
- }]);
-
- return app;
- });
|