t-erp-auto-test.json 332 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833
  1. {
  2. "info": {
  3. "_postman_id": "76b4c2b3-30c2-49fa-87f6-bc7e24cb223e",
  4. "name": "t-erp-auto-test(修改版)",
  5. "description": "T系列ERP自动化测试集合(整合版)\n\n包含:\n- 🔐 登录(获取LoginId)\n- 📋 基础资料(部门/员工/仓库/货品/客户厂商)\n- 🔄 示例业务流程(采购→销售完整链路,含SQL库存验证)\n- 📦 单据测试用例(35种单据,按采购/销售/库存/生产/托外/非生产领退料分类)\n\n环境变量说明:\n- t-erp-api-url: API基础地址(如 http://xxx.xxx.xxx.xxx:8080/api)\n- t-erp-api-user-no: 登录账号\n- t-erp-api-user-pwd: 登录密码\n- t-erp-api-login-id: LoginId(登录后自动写入)\n- t-erp-api-sn: ERP服务定位标识(Linker sn值)\n- t-erp-api-current-date: 当前日期(各请求前置脚本自动写入)",
  6. "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
  7. "_exporter_id": "21163044"
  8. },
  9. "item": [
  10. {
  11. "name": "🔐 登录",
  12. "item": [
  13. {
  14. "name": "登录获取LoginId",
  15. "event": [
  16. {
  17. "listen": "test",
  18. "script": {
  19. "exec": [
  20. "// 登录测试脚本",
  21. "// ===================== status:状态码 =====================",
  22. "pm.test(\"✅ 状态码 200\", () => pm.response.to.have.status(200));",
  23. "// =========================================================",
  24. "",
  25. "var jsonData = pm.response.json();",
  26. "// ===================== console:按需打印 =====================",
  27. "// 1. 单个关键值打印(按需选择)",
  28. "console.log(`📋 登录接口返回CompNo:${jsonData.CompNo}`);",
  29. "console.log(`📋 登录接口返回UserNo:${jsonData.UserNo}`);",
  30. "console.log(`📋 生成的登录令牌LoginId:${jsonData.LoginId}`);",
  31. "console.log(`📋 令牌有效期LoginIdExpiry:${jsonData.LoginIdExpiry} 秒`);",
  32. "",
  33. "// 2. 批量打印多个核心值(推荐,日志更集中,少占行数)",
  34. "console.log(\"📋 登录接口核心返回值汇总:\", {",
  35. " LoginId: jsonData.LoginId,",
  36. " CompNo: jsonData.CompNo,",
  37. " UserNo: jsonData.UserNo,",
  38. " LoginIdExpiry: jsonData.LoginIdExpiry,",
  39. " ClientType: jsonData.ClientType",
  40. "});",
  41. "",
  42. "// 3. 打印刚设置的环境变量(验证是否保存成功,可选)",
  43. "console.info(`🔧 环境变量已设置t-erp-api-login-id:${pm.environment.get(\"t-erp-api-login-id\")}`);",
  44. "// ======================================================================",
  45. "",
  46. "// ===================== test:按需验证 =====================",
  47. "pm.test(\"✅ 必需字段存在\", () => {",
  48. " pm.expect(jsonData).to.include.all.keys(",
  49. " 'LoginId', 'CompNo', 'UserNo', 'LoginIdExpiry'",
  50. " );",
  51. "});",
  52. "pm.test(\"✅ 登录信息正确\", () => {",
  53. " pm.expect(jsonData.CompNo).to.equal('TAPI');",
  54. " pm.expect(jsonData.UserNo).to.equal('API');",
  55. " pm.expect(jsonData.ClientType).to.equal('JksAutoTestApi');",
  56. " pm.expect(jsonData.LoginIdExpiry).to.equal(604800);",
  57. "});",
  58. "pm.test(\"✅ 保存登录令牌成功\", () => {",
  59. " pm.expect(jsonData.LoginId).to.be.a('string').and.not.empty;",
  60. " pm.environment.set(\"t-erp-api-login-id\", jsonData.LoginId);",
  61. "});",
  62. "// ======================================================================"
  63. ],
  64. "type": "text/javascript",
  65. "packages": {},
  66. "requests": {}
  67. }
  68. }
  69. ],
  70. "request": {
  71. "auth": {
  72. "type": "noauth"
  73. },
  74. "method": "POST",
  75. "header": [
  76. {
  77. "key": "LanguageId",
  78. "value": "{{t-erp-api-language}}",
  79. "description": "0:简体;1:繁体;2:英文"
  80. },
  81. {
  82. "key": "Authorization",
  83. "value": "{{t-erp-api-authorization}}",
  84. "description": "服务:237;账套:TAPI;用户:API"
  85. },
  86. {
  87. "key": "ClientType",
  88. "value": "{{t-erp-api-client-type}}",
  89. "description": "JksAutoTestApi"
  90. },
  91. {
  92. "key": "Content-Type",
  93. "value": "{{t-erp-api-content-type}}",
  94. "description": "application/json"
  95. },
  96. {
  97. "key": "X-Tiansi-Auth-Bypass",
  98. "value": "{{t-erp-api-x-tiansi-bypass}}",
  99. "description": "跳过接口注册检验",
  100. "type": "text"
  101. },
  102. {
  103. "key": "sn",
  104. "value": "{{t-erp-api-sn}}",
  105. "description": "用于Linker定位ERP服务",
  106. "type": "text"
  107. }
  108. ],
  109. "url": {
  110. "raw": "{{t-erp-api-url}}/User/login",
  111. "host": [
  112. "{{t-erp-api-url}}"
  113. ],
  114. "path": [
  115. "User",
  116. "login"
  117. ]
  118. },
  119. "description": "登录系统"
  120. },
  121. "response": []
  122. }
  123. ]
  124. },
  125. {
  126. "name": "📋 基础资料",
  127. "item": [
  128. {
  129. "name": "部门资料",
  130. "item": [
  131. {
  132. "name": "新增部门",
  133. "event": [
  134. {
  135. "listen": "test",
  136. "script": {
  137. "exec": [
  138. "// 完整可用的部门接口测试脚本\r",
  139. "pm.test(\"✅ 状态码 200\", () => pm.response.to.have.status(200));\r",
  140. "\r",
  141. "var requestData = JSON.parse(pm.request.body.raw);\r",
  142. "var responseData = pm.response.json();\r",
  143. "\r",
  144. "// 1. 验证响应结构\r",
  145. "pm.test(\"📋 响应结构验证\", () => {\r",
  146. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  147. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  148. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  149. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  150. "});\r",
  151. "\r",
  152. "// 2. 验证请求数据(修正后的正确写法)\r",
  153. "pm.test(\"✅ 请求部门数据验证\", () => {\r",
  154. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  155. " \r",
  156. " requestData.forEach((dept, idx) => {\r",
  157. " const deptNum = idx + 1;\r",
  158. " \r",
  159. " // 验证必填字段存在\r",
  160. " pm.expect(dept, `部门${deptNum}`).to.include.keys('DEP', 'NAME');\r",
  161. " \r",
  162. " // 验证字段类型和值\r",
  163. " pm.expect(dept.DEP, `部门${deptNum}的部门代码`).to.be.a('string').that.is.not.empty;\r",
  164. " pm.expect(dept.NAME, `部门${deptNum}的部门名称`).to.be.a('string').that.is.not.empty;\r",
  165. " \r",
  166. " // 可选字段验证\r",
  167. " if (dept.ENG_NAME !== undefined) {\r",
  168. " pm.expect(dept.ENG_NAME).to.be.a('string');\r",
  169. " }\r",
  170. " \r",
  171. " if (dept.UP !== undefined) {\r",
  172. " pm.expect(dept.UP).to.be.a('string');\r",
  173. " }\r",
  174. " });\r",
  175. "});\r",
  176. "\r",
  177. "// 3. 验证业务结果\r",
  178. "pm.test(\"📊 操作结果验证\", () => {\r",
  179. " const total = requestData.length;\r",
  180. " \r",
  181. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  182. " \r",
  183. " if (responseData.ErrorCount === 0) {\r",
  184. " pm.expect(responseData.OkCount).to.equal(total);\r",
  185. " pm.expect(responseData.ErrorData).to.eql([]);\r",
  186. " console.log(`✅ 成功处理 ${responseData.OkCount} 个部门`);\r",
  187. " } else {\r",
  188. " console.log(`⚠️ 部分失败: ${responseData.OkCount} 成功, ${responseData.ErrorCount} 失败`);\r",
  189. " \r",
  190. " // 验证错误数据\r",
  191. " responseData.ErrorData.forEach(error => {\r",
  192. " pm.expect(error).to.include.keys('Index', 'DEP', 'ErrorMessage');\r",
  193. " pm.expect(error.Index).to.be.within(0, total - 1);\r",
  194. " });\r",
  195. " }\r",
  196. "});"
  197. ],
  198. "type": "text/javascript",
  199. "packages": {},
  200. "requests": {}
  201. }
  202. }
  203. ],
  204. "request": {
  205. "method": "POST",
  206. "header": [
  207. {
  208. "key": "LoginId",
  209. "value": "{{t-erp-api-login-id}}",
  210. "type": "text"
  211. },
  212. {
  213. "key": "sn",
  214. "value": "{{t-erp-api-sn}}",
  215. "type": "text"
  216. }
  217. ],
  218. "body": {
  219. "mode": "raw",
  220. "raw": "[\r\n {\r\n \"DEP\": \"0001\", // 必须,部门代号,该部门代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"0001部门\", // 必须,部门名称\r\n \"ENG_NAME\": \"0001Dep\", // 非必须,英文名称\r\n \"UP\": \"0000\" // 非必须,上层部门代号\r\n },\r\n {\r\n \"DEP\": \"0002\", // 必须,部门代号,该部门代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"0002部门\", // 必须,部门名称\r\n \"ENG_NAME\": \"0002Dep\", // 非必须,英文名称\r\n \"UP\": \"0001\" // 非必须,上层部门代号\r\n },\r\n {\r\n \"DEP\": \"0003\", // 必须,部门代号,该部门代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"0003部门\", // 必须,部门名称\r\n \"ENG_NAME\": \"0003Dep\", // 非必须,英文名称\r\n \"UP\": \"0002\" // 非必须,上层部门代号\r\n }\r\n]",
  221. "options": {
  222. "raw": {
  223. "language": "json"
  224. }
  225. }
  226. },
  227. "url": {
  228. "raw": "{{t-erp-api-url}}/Dept/AppendToDept",
  229. "host": [
  230. "{{t-erp-api-url}}"
  231. ],
  232. "path": [
  233. "Dept",
  234. "AppendToDept"
  235. ]
  236. },
  237. "description": "新增部门资料"
  238. },
  239. "response": []
  240. },
  241. {
  242. "name": "删除部门",
  243. "event": [
  244. {
  245. "listen": "test",
  246. "script": {
  247. "exec": [
  248. "// 简化版删除部门测试脚本\r",
  249. "pm.test(\"✅ 状态码 200\", () => pm.response.to.have.status(200));\r",
  250. "\r",
  251. "var requestData = JSON.parse(pm.request.body.raw);\r",
  252. "var responseData = pm.response.json();\r",
  253. "\r",
  254. "// 基础验证\r",
  255. "pm.test(\"✅ 响应结构验证\", () => {\r",
  256. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  257. "});\r",
  258. "\r",
  259. "// 请求数据验证\r",
  260. "pm.test(\"✅ 删除请求数据验证\", () => {\r",
  261. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  262. " \r",
  263. " requestData.forEach((item, index) => {\r",
  264. " pm.expect(item).to.have.property('DEP');\r",
  265. " pm.expect(item.DEP).to.be.a('string').and.not.empty;\r",
  266. " });\r",
  267. " \r",
  268. " console.log(`🗑️ 请求删除 ${requestData.length} 个部门`);\r",
  269. "});\r",
  270. "\r",
  271. "// 业务结果验证\r",
  272. "pm.test(\"📊 删除结果验证\", () => {\r",
  273. " const total = requestData.length;\r",
  274. " \r",
  275. " // 验证计数逻辑\r",
  276. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  277. " \r",
  278. " // 根据成功示例验证\r",
  279. " pm.expect(responseData.ErrorCount).to.equal(0);\r",
  280. " pm.expect(responseData.OkCount).to.equal(total);\r",
  281. " pm.expect(responseData.ErrorData).to.eql([]);\r",
  282. " \r",
  283. " console.log(`✅ 成功删除 ${responseData.OkCount} 个部门`);\r",
  284. "});"
  285. ],
  286. "type": "text/javascript",
  287. "packages": {},
  288. "requests": {}
  289. }
  290. }
  291. ],
  292. "request": {
  293. "method": "POST",
  294. "header": [
  295. {
  296. "key": "LoginId",
  297. "value": "{{t-erp-api-login-id}}",
  298. "type": "text"
  299. },
  300. {
  301. "key": "sn",
  302. "value": "{{t-erp-api-sn}}",
  303. "type": "text"
  304. }
  305. ],
  306. "body": {
  307. "mode": "raw",
  308. "raw": "[\r\n {\r\n \"DEP\": \"0003\" // 必须,部门代号,删除该笔部门资料\r\n }\r\n]",
  309. "options": {
  310. "raw": {
  311. "language": "json"
  312. }
  313. }
  314. },
  315. "url": {
  316. "raw": "{{t-erp-api-url}}/Dept/DeleteForDept",
  317. "host": [
  318. "{{t-erp-api-url}}"
  319. ],
  320. "path": [
  321. "Dept",
  322. "DeleteForDept"
  323. ]
  324. },
  325. "description": "删除部门资料"
  326. },
  327. "response": []
  328. }
  329. ],
  330. "description": "部门资料"
  331. },
  332. {
  333. "name": "员工资料",
  334. "item": [
  335. {
  336. "name": "新增员工",
  337. "event": [
  338. {
  339. "listen": "test",
  340. "script": {
  341. "exec": [
  342. "// 1. 基础响应验证\r",
  343. "pm.test(\"✅ 状态码 200\", function() {\r",
  344. " pm.response.to.have.status(200);\r",
  345. "});\r",
  346. "\r",
  347. "// 2. 获取数据\r",
  348. "var requestData = JSON.parse(pm.request.body.raw);\r",
  349. "var responseData = pm.response.json();\r",
  350. "\r",
  351. "// 3. 响应结构验证\r",
  352. "pm.test(\"📋 响应结构验证\", function() {\r",
  353. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  354. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  355. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  356. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  357. "});\r",
  358. "\r",
  359. "// 4. 请求数据验证\r",
  360. "pm.test(\"✅ 员工数据验证\", function() {\r",
  361. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  362. " \r",
  363. " requestData.forEach((employee, index) => {\r",
  364. " const empNum = index + 1;\r",
  365. " \r",
  366. " // 必填字段验证\r",
  367. " pm.expect(employee, `员工${empNum}`).to.include.keys('SAL_NO', 'NAME', 'DEP');\r",
  368. " pm.expect(employee.SAL_NO, `员工${empNum}工号`).to.be.a('string').and.not.empty;\r",
  369. " pm.expect(employee.NAME, `员工${empNum}姓名`).to.be.a('string').and.not.empty;\r",
  370. " pm.expect(employee.DEP, `员工${empNum}部门`).to.be.a('string').and.not.empty;\r",
  371. " \r",
  372. " // 可选字段类型验证(如果存在)\r",
  373. " if (employee.POS !== undefined) {\r",
  374. " pm.expect(employee.POS).to.be.a('string');\r",
  375. " }\r",
  376. " if (employee.UP_SAL_NO !== undefined) {\r",
  377. " pm.expect(employee.UP_SAL_NO).to.be.a('string');\r",
  378. " }\r",
  379. " if (employee.TOPSWD !== undefined) {\r",
  380. " pm.expect(employee.TOPSWD).to.be.a('string');\r",
  381. " }\r",
  382. " if (employee.REM !== undefined) {\r",
  383. " pm.expect(employee.REM).to.be.a('string');\r",
  384. " }\r",
  385. " });\r",
  386. " \r",
  387. " console.log(`✅ 已验证 ${requestData.length} 个员工数据`);\r",
  388. "});\r",
  389. "\r",
  390. "// 5. 业务结果验证\r",
  391. "pm.test(\"📊 操作结果验证\", function() {\r",
  392. " const total = requestData.length;\r",
  393. " \r",
  394. " // 验证计数逻辑\r",
  395. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  396. " \r",
  397. " // 根据成功示例验证\r",
  398. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  399. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  400. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  401. " \r",
  402. " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个员工`);\r",
  403. "});"
  404. ],
  405. "type": "text/javascript",
  406. "packages": {},
  407. "requests": {}
  408. }
  409. }
  410. ],
  411. "request": {
  412. "method": "POST",
  413. "header": [
  414. {
  415. "key": "LoginId",
  416. "value": "{{t-erp-api-login-id}}",
  417. "type": "text"
  418. },
  419. {
  420. "key": "sn",
  421. "value": "{{t-erp-api-sn}}",
  422. "type": "text"
  423. }
  424. ],
  425. "body": {
  426. "mode": "raw",
  427. "raw": "[\r\n {\r\n \"SAL_NO\": \"ZS\", // 必须,员工代号,该员工代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"张三\", // 必须,员工名称 \r\n \"POS\": \"机床操作主管\", // 非必须,职称\r\n \"DEP\": \"0001\", // 部门代号\r\n \"TOPSWD\": \"T\", // 非必须,同步到登录用户\r\n \"REM\": \"机床操作主管\" // 非必须,摘要\r\n },\r\n {\r\n \"SAL_NO\": \"LS\", // 必须,员工代号,该员工代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"李四\", // 必须,员工名称 \r\n \"POS\": \"机床操作工\", // 非必须,职称\r\n \"DEP\": \"0001\", // 部门代号\r\n \"UP_SAL_NO\": \"ZS\", // 上级主管\r\n \"TOPSWD\": \"T\", // 非必须,同步到登录用户\r\n \"REM\": \"机床操作工\" // 非必须,摘要\r\n },\r\n {\r\n \"SAL_NO\": \"WW\", // 必须,员工代号,该员工代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"王五\", // 必须,员工名称 \r\n \"POS\": \"机床操作工\", // 非必须,职称\r\n \"DEP\": \"0001\", // 部门代号\r\n \"REM\": \"机床操作工\" // 非必须,摘要\r\n }\r\n]",
  428. "options": {
  429. "raw": {
  430. "language": "json"
  431. }
  432. }
  433. },
  434. "url": {
  435. "raw": "{{t-erp-api-url}}/Salm/AppendToSalm",
  436. "host": [
  437. "{{t-erp-api-url}}"
  438. ],
  439. "path": [
  440. "Salm",
  441. "AppendToSalm"
  442. ]
  443. },
  444. "description": "新增员工资料"
  445. },
  446. "response": []
  447. },
  448. {
  449. "name": "删除员工",
  450. "event": [
  451. {
  452. "listen": "test",
  453. "script": {
  454. "exec": [
  455. "// 1. 基础响应验证\r",
  456. "pm.test(\"✅ 状态码 200\", function() {\r",
  457. " pm.response.to.have.status(200);\r",
  458. "});\r",
  459. "\r",
  460. "// 2. 获取数据\r",
  461. "var requestData = JSON.parse(pm.request.body.raw);\r",
  462. "var responseData = pm.response.json();\r",
  463. "\r",
  464. "// 3. 响应结构验证\r",
  465. "pm.test(\"📋 响应结构验证\", function() {\r",
  466. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  467. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  468. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  469. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  470. "});\r",
  471. "\r",
  472. "// 4. 请求数据验证\r",
  473. "pm.test(\"✅ 删除请求验证\", function() {\r",
  474. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  475. " \r",
  476. " requestData.forEach((item, index) => {\r",
  477. " const itemNum = index + 1;\r",
  478. " \r",
  479. " // 必填字段验证\r",
  480. " pm.expect(item, `删除项${itemNum}`).to.have.property('SAL_NO');\r",
  481. " pm.expect(item.SAL_NO, `员工${itemNum}工号`).to.be.a('string').and.not.empty;\r",
  482. " });\r",
  483. " \r",
  484. " console.log(`🗑️ 请求删除 ${requestData.length} 个员工`);\r",
  485. "});\r",
  486. "\r",
  487. "// 5. 业务结果验证\r",
  488. "pm.test(\"📊 删除结果验证\", function() {\r",
  489. " const total = requestData.length;\r",
  490. " \r",
  491. " // 验证计数逻辑\r",
  492. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  493. " \r",
  494. " // 根据成功示例验证\r",
  495. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  496. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  497. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  498. " \r",
  499. " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个员工`);\r",
  500. "});"
  501. ],
  502. "type": "text/javascript",
  503. "packages": {},
  504. "requests": {}
  505. }
  506. }
  507. ],
  508. "request": {
  509. "method": "POST",
  510. "header": [
  511. {
  512. "key": "LoginId",
  513. "value": "{{t-erp-api-login-id}}",
  514. "type": "text"
  515. },
  516. {
  517. "key": "sn",
  518. "value": "{{t-erp-api-sn}}",
  519. "type": "text"
  520. }
  521. ],
  522. "body": {
  523. "mode": "raw",
  524. "raw": "[\r\n {\r\n \"SAL_NO\": \"WW\" // 必须,员工代号,删除该笔员工资料\r\n }\r\n]",
  525. "options": {
  526. "raw": {
  527. "language": "json"
  528. }
  529. }
  530. },
  531. "url": {
  532. "raw": "{{t-erp-api-url}}/Salm/DeleteForSalm",
  533. "host": [
  534. "{{t-erp-api-url}}"
  535. ],
  536. "path": [
  537. "Salm",
  538. "DeleteForSalm"
  539. ]
  540. },
  541. "description": "删除员工资料"
  542. },
  543. "response": []
  544. }
  545. ],
  546. "description": "员工资料"
  547. },
  548. {
  549. "name": "仓库资料",
  550. "item": [
  551. {
  552. "name": "新增仓库",
  553. "event": [
  554. {
  555. "listen": "test",
  556. "script": {
  557. "exec": [
  558. "// 1. 基础响应验证\r",
  559. "pm.test(\"✅ 状态码 200\", function() {\r",
  560. " pm.response.to.have.status(200);\r",
  561. "});\r",
  562. "\r",
  563. "// 2. 获取数据\r",
  564. "var requestData = JSON.parse(pm.request.body.raw);\r",
  565. "var responseData = pm.response.json();\r",
  566. "\r",
  567. "// 3. 响应结构验证\r",
  568. "pm.test(\"📋 响应结构验证\", function() {\r",
  569. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  570. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  571. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  572. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  573. "});\r",
  574. "\r",
  575. "// 4. 请求数据验证\r",
  576. "pm.test(\"✅ 仓库数据验证\", function() {\r",
  577. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  578. " \r",
  579. " requestData.forEach((warehouse, index) => {\r",
  580. " const whNum = index + 1;\r",
  581. " \r",
  582. " // 必填字段验证\r",
  583. " pm.expect(warehouse, `仓库${whNum}`).to.include.keys('WH', 'NAME');\r",
  584. " pm.expect(warehouse.WH, `仓库${whNum}代号`).to.be.a('string').and.not.empty;\r",
  585. " pm.expect(warehouse.NAME, `仓库${whNum}名称`).to.be.a('string').and.not.empty;\r",
  586. " \r",
  587. " // 可选字段类型验证(如果存在)\r",
  588. " const optionalFields = ['ATTRIB', 'UP_WH', 'INVALID', 'VMIVALID', 'LOC_ID', 'OUT_ID'];\r",
  589. " optionalFields.forEach(field => {\r",
  590. " if (warehouse[field] !== undefined) {\r",
  591. " pm.expect(warehouse[field]).to.be.a('string');\r",
  592. " }\r",
  593. " });\r",
  594. " });\r",
  595. " \r",
  596. " console.log(`✅ 已验证 ${requestData.length} 个仓库数据`);\r",
  597. "});\r",
  598. "\r",
  599. "// 5. 业务结果验证\r",
  600. "pm.test(\"📊 操作结果验证\", function() {\r",
  601. " const total = requestData.length;\r",
  602. " \r",
  603. " // 验证计数逻辑\r",
  604. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  605. " \r",
  606. " // 根据成功示例验证\r",
  607. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  608. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  609. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  610. " \r",
  611. " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个仓库`);\r",
  612. "});"
  613. ],
  614. "type": "text/javascript",
  615. "packages": {},
  616. "requests": {}
  617. }
  618. }
  619. ],
  620. "request": {
  621. "method": "POST",
  622. "header": [
  623. {
  624. "key": "LoginId",
  625. "value": "{{t-erp-api-login-id}}",
  626. "type": "text"
  627. },
  628. {
  629. "key": "sn",
  630. "value": "{{t-erp-api-sn}}",
  631. "type": "text"
  632. }
  633. ],
  634. "body": {
  635. "mode": "raw",
  636. "raw": "[\r\n {\r\n \"WH\": \"0001\", // 必须,仓库代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"原料仓\", // 必须,仓库名称 \r\n \"ATTRIB\": \"2\", // 非必须,属性\r\n \"UP_WH\": \"0000\" // 非必须,上层仓库\r\n },\r\n {\r\n \"WH\": \"0002\", // 必须,仓库代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"半成品仓\", // 必须,仓库名称 \r\n \"ATTRIB\": \"3\", // 非必须,属性\r\n \"UP_WH\": \"0001\" // 非必须,上层仓库\r\n },\r\n {\r\n \"WH\": \"0003\", // 必须,仓库代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"制成品仓\", // 必须,仓库名称 \r\n \"ATTRIB\": \"5\", // 非必须,属性\r\n \"UP_WH\": \"0002\" // 非必须,上层仓库\r\n },\r\n {\r\n \"WH\": \"0004\", // 必须,仓库代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"废品仓\", // 必须,仓库名称\r\n \"INVALID\": \"T\", // 是否勾选废品仓\r\n \"UP_WH\": \"0000\" // 非必须,上层仓库\r\n },\r\n {\r\n \"WH\": \"0005\", // 必须,仓库代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"寄售仓\", // 必须,仓库名称\r\n \"VMIVALID\": \"T\", // 是否勾选寄售仓\r\n \"UP_WH\": \"0000\" // 非必须,上层仓库\r\n },\r\n {\r\n \"WH\": \"0006\", // 必须,仓库代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"储位仓\", // 必须,仓库名称\r\n \"LOC_ID\": \"T\", // 是否勾选寄售仓\r\n \"OUT_ID\": \"1\", // 出库规则\r\n \"UP_WH\": \"0000\" // 非必须,上层仓库\r\n },\r\n {\r\n \"WH\": \"0007\", // 必须,仓库代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"原料仓2\", // 必须,仓库名称 \r\n \"ATTRIB\": \"2\", // 非必须,属性\r\n \"UP_WH\": \"0000\" // 非必须,上层仓库\r\n }\r\n]",
  637. "options": {
  638. "raw": {
  639. "language": "json"
  640. }
  641. }
  642. },
  643. "url": {
  644. "raw": "{{t-erp-api-url}}/Wh/AppendToWh",
  645. "host": [
  646. "{{t-erp-api-url}}"
  647. ],
  648. "path": [
  649. "Wh",
  650. "AppendToWh"
  651. ]
  652. },
  653. "description": "新增仓库资料"
  654. },
  655. "response": []
  656. }
  657. ],
  658. "description": "仓库资料"
  659. },
  660. {
  661. "name": "货品资料",
  662. "item": [
  663. {
  664. "name": "新增货品",
  665. "event": [
  666. {
  667. "listen": "test",
  668. "script": {
  669. "exec": [
  670. "// 1. 基础响应验证\r",
  671. "pm.test(\"✅ 状态码 200\", function() {\r",
  672. " pm.response.to.have.status(200);\r",
  673. "});\r",
  674. "\r",
  675. "// 2. 获取数据\r",
  676. "var requestData = JSON.parse(pm.request.body.raw);\r",
  677. "var responseData = pm.response.json();\r",
  678. "\r",
  679. "// 3. 响应结构验证\r",
  680. "pm.test(\"📋 响应结构验证\", function() {\r",
  681. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  682. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  683. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  684. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  685. "});\r",
  686. "\r",
  687. "// 4. 请求数据验证\r",
  688. "pm.test(\"✅ 货品数据验证\", function() {\r",
  689. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  690. " \r",
  691. " requestData.forEach((product, index) => {\r",
  692. " const prodNum = index + 1;\r",
  693. " \r",
  694. " // 必填字段验证\r",
  695. " pm.expect(product, `货品${prodNum}`).to.include.keys('PRD_NO', 'NAME', 'UT');\r",
  696. " pm.expect(product.PRD_NO, `货品${prodNum}代号`).to.be.a('string').and.not.empty;\r",
  697. " pm.expect(product.NAME, `货品${prodNum}名称`).to.be.a('string').and.not.empty;\r",
  698. " pm.expect(product.UT, `货品${prodNum}单位`).to.be.a('string').and.not.empty;\r",
  699. " \r",
  700. " // 可选字段类型验证(如果存在)\r",
  701. " const optionalFields = ['WH', 'REM', 'CHK_BAT', 'CHK_MARK'];\r",
  702. " optionalFields.forEach(field => {\r",
  703. " if (product[field] !== undefined) {\r",
  704. " pm.expect(product[field]).to.be.a('string');\r",
  705. " }\r",
  706. " });\r",
  707. " });\r",
  708. " \r",
  709. " console.log(`✅ 已验证 ${requestData.length} 个货品数据`);\r",
  710. "});\r",
  711. "\r",
  712. "// 5. 业务结果验证\r",
  713. "pm.test(\"📊 操作结果验证\", function() {\r",
  714. " const total = requestData.length;\r",
  715. " \r",
  716. " // 验证计数逻辑\r",
  717. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  718. " \r",
  719. " // 根据成功示例验证\r",
  720. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  721. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  722. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  723. " \r",
  724. " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个货品`);\r",
  725. "});"
  726. ],
  727. "type": "text/javascript",
  728. "packages": {},
  729. "requests": {}
  730. }
  731. }
  732. ],
  733. "request": {
  734. "method": "POST",
  735. "header": [
  736. {
  737. "key": "LoginId",
  738. "value": "{{t-erp-api-login-id}}",
  739. "type": "text"
  740. },
  741. {
  742. "key": "sn",
  743. "value": "{{t-erp-api-sn}}",
  744. "type": "text"
  745. }
  746. ],
  747. "body": {
  748. "mode": "raw",
  749. "raw": "[\r\n {\r\n \"PRD_NO\": \"YL0001\", // 必须,货品代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"原料0001\", // 必须,货品名称\r\n \"UT\": \"个\", // 必须,主单位\r\n \"WH\": \"0001\", // 非必须,预入仓库\r\n \"REM\": \"原料0001摘要,API测试\" // 非必须,摘要\r\n },\r\n {\r\n \"PRD_NO\": \"YL0002\", // 必须,货品代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"原料0002\", // 必须,货品名称\r\n \"UT\": \"个\", // 必须,主单位\r\n \"WH\": \"0001\", // 非必须,预入仓库\r\n \"REM\": \"原料0002摘要,API测试\" // 非必须,摘要\r\n },\r\n {\r\n \"PRD_NO\": \"BCP0001\", // 必须,货品代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"半成品0001\", // 必须,货品名称\r\n \"UT\": \"KG\", // 必须,主单位\r\n \"WH\": \"0002\", // 非必须,预入仓库\r\n \"CHK_BAT\": \"T\", // 批号管制\r\n \"REM\": \"半成品0001摘要,API测试\" // 非必须,摘要\r\n },\r\n {\r\n \"PRD_NO\": \"ZCP0001\", // 必须,货品代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"制成品0001\", // 必须,货品名称\r\n \"UT\": \"KG\", // 必须,主单位\r\n \"WH\": \"0003\", // 非必须,预入仓库\r\n \"CHK_MARK\": \"T\", // 特征管制\r\n \"REM\": \"制成品0001摘要,API测试\" // 非必须,摘要\r\n },\r\n {\r\n \"PRD_NO\": \"ZCP0002\", // 必须,货品代号,该货品代号在资料中存在即为修改原数据,不存在为新增\r\n \"NAME\": \"制成品0002\", // 必须,货品名称\r\n \"UT\": \"KG\", // 必须,主单位\r\n \"WH\": \"0003\", // 非必须,预入仓库\r\n \"CHK_BAT\": \"T\", // 批号管制\r\n \"CHK_MARK\": \"T\", // 特征管制\r\n \"REM\": \"制成品0002摘要,API测试\" // 非必须,摘要\r\n }\r\n]",
  750. "options": {
  751. "raw": {
  752. "language": "json"
  753. }
  754. }
  755. },
  756. "url": {
  757. "raw": "{{t-erp-api-url}}/Prdt/AppendToPrdt",
  758. "host": [
  759. "{{t-erp-api-url}}"
  760. ],
  761. "path": [
  762. "Prdt",
  763. "AppendToPrdt"
  764. ]
  765. },
  766. "description": "新增货品"
  767. },
  768. "response": []
  769. },
  770. {
  771. "name": "删除货品",
  772. "event": [
  773. {
  774. "listen": "test",
  775. "script": {
  776. "exec": [
  777. "// 1. 基础响应验证\r",
  778. "pm.test(\"✅ 状态码 200\", function() {\r",
  779. " pm.response.to.have.status(200);\r",
  780. "});\r",
  781. "\r",
  782. "// 2. 获取数据\r",
  783. "var requestData = JSON.parse(pm.request.body.raw);\r",
  784. "var responseData = pm.response.json();\r",
  785. "\r",
  786. "// 3. 响应结构验证\r",
  787. "pm.test(\"📋 响应结构验证\", function() {\r",
  788. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  789. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  790. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  791. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  792. "});\r",
  793. "\r",
  794. "// 4. 请求数据验证\r",
  795. "pm.test(\"✅ 删除请求验证\", function() {\r",
  796. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  797. " \r",
  798. " requestData.forEach((item, index) => {\r",
  799. " const itemNum = index + 1;\r",
  800. " \r",
  801. " // 必填字段验证\r",
  802. " pm.expect(item, `删除项${itemNum}`).to.have.property('PRD_NO');\r",
  803. " pm.expect(item.PRD_NO, `货品${itemNum}代号`).to.be.a('string').and.not.empty;\r",
  804. " });\r",
  805. " \r",
  806. " console.log(`🗑️ 请求删除 ${requestData.length} 个货品`);\r",
  807. "});\r",
  808. "\r",
  809. "// 5. 业务结果验证\r",
  810. "pm.test(\"📊 删除结果验证\", function() {\r",
  811. " const total = requestData.length;\r",
  812. " \r",
  813. " // 验证计数逻辑\r",
  814. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  815. " \r",
  816. " // 根据成功示例验证\r",
  817. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  818. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  819. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  820. " \r",
  821. " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个货品`);\r",
  822. "});"
  823. ],
  824. "type": "text/javascript",
  825. "packages": {},
  826. "requests": {}
  827. }
  828. }
  829. ],
  830. "request": {
  831. "method": "POST",
  832. "header": [
  833. {
  834. "key": "LoginId",
  835. "value": "{{t-erp-api-login-id}}",
  836. "type": "text"
  837. },
  838. {
  839. "key": "sn",
  840. "value": "{{t-erp-api-sn}}",
  841. "type": "text"
  842. }
  843. ],
  844. "body": {
  845. "mode": "raw",
  846. "raw": "[\r\n {\r\n \"PRD_NO\": \"ZCP0002\" // 必须,货品代号,删除该笔货品资料\r\n }\r\n]",
  847. "options": {
  848. "raw": {
  849. "language": "json"
  850. }
  851. }
  852. },
  853. "url": {
  854. "raw": "{{t-erp-api-url}}/Prdt/DeleteForPrdt",
  855. "host": [
  856. "{{t-erp-api-url}}"
  857. ],
  858. "path": [
  859. "Prdt",
  860. "DeleteForPrdt"
  861. ]
  862. },
  863. "description": "删除货品资料"
  864. },
  865. "response": []
  866. }
  867. ],
  868. "description": "货品资料"
  869. },
  870. {
  871. "name": "客户厂商资料",
  872. "item": [
  873. {
  874. "name": "新增客户",
  875. "event": [
  876. {
  877. "listen": "test",
  878. "script": {
  879. "exec": [
  880. "// 1. 基础响应验证\r",
  881. "pm.test(\"✅ 状态码 200\", function() {\r",
  882. " pm.response.to.have.status(200);\r",
  883. "});\r",
  884. "\r",
  885. "// 2. 获取数据\r",
  886. "var requestData = JSON.parse(pm.request.body.raw);\r",
  887. "var responseData = pm.response.json();\r",
  888. "\r",
  889. "// 3. 响应结构验证\r",
  890. "pm.test(\"📋 响应结构验证\", function() {\r",
  891. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  892. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  893. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  894. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  895. "});\r",
  896. "\r",
  897. "// 4. 请求数据验证\r",
  898. "pm.test(\"✅ 客户数据验证\", function() {\r",
  899. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  900. " \r",
  901. " requestData.forEach((customer, index) => {\r",
  902. " const custNum = index + 1;\r",
  903. " \r",
  904. " // 必填字段验证\r",
  905. " pm.expect(customer, `客户${custNum}`).to.include.keys('CUS_NO', 'OBJ_ID', 'NAME');\r",
  906. " pm.expect(customer.CUS_NO, `客户${custNum}代号`).to.be.a('string').and.not.empty;\r",
  907. " pm.expect(customer.NAME, `客户${custNum}名称`).to.be.a('string').and.not.empty;\r",
  908. " pm.expect(customer.OBJ_ID, `客户${custNum}对象别`).to.be.a('string');\r",
  909. " \r",
  910. " // 验证OBJ_ID取值范围\r",
  911. " const validObjIds = ['1', '2', '3'];\r",
  912. " if (customer.OBJ_ID && customer.OBJ_ID !== '') {\r",
  913. " pm.expect(validObjIds).to.include(\r",
  914. " customer.OBJ_ID,\r",
  915. " `客户${custNum}的OBJ_ID应为1、2或3,当前值为:${customer.OBJ_ID}`\r",
  916. " );\r",
  917. " }\r",
  918. " \r",
  919. " // 可选字段类型验证(如果存在)\r",
  920. " const optionalFields = ['SAL', 'ID1_TAX', 'MAS_CUS', 'REM'];\r",
  921. " optionalFields.forEach(field => {\r",
  922. " if (customer[field] !== undefined) {\r",
  923. " pm.expect(customer[field]).to.be.a('string');\r",
  924. " }\r",
  925. " });\r",
  926. " });\r",
  927. " \r",
  928. " console.log(`✅ 已验证 ${requestData.length} 个客户数据`);\r",
  929. "});\r",
  930. "\r",
  931. "// 5. 业务结果验证\r",
  932. "pm.test(\"📊 操作结果验证\", function() {\r",
  933. " const total = requestData.length;\r",
  934. " \r",
  935. " // 验证计数逻辑\r",
  936. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  937. " \r",
  938. " // 根据成功示例验证\r",
  939. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  940. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  941. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  942. " \r",
  943. " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个客户`);\r",
  944. "});"
  945. ],
  946. "type": "text/javascript",
  947. "packages": {},
  948. "requests": {}
  949. }
  950. }
  951. ],
  952. "request": {
  953. "method": "POST",
  954. "header": [
  955. {
  956. "key": "LoginId",
  957. "value": "{{t-erp-api-login-id}}",
  958. "type": "text"
  959. },
  960. {
  961. "key": "sn",
  962. "value": "{{t-erp-api-sn}}",
  963. "type": "text"
  964. }
  965. ],
  966. "body": {
  967. "mode": "raw",
  968. "raw": "[\r\n {\r\n \"CUS_NO\": \"KH0001\", // 必须,客户厂商代号,该客户厂商代号在资料中存在即为修改原数据,不存在为新增\r\n \"OBJ_ID\": \"1\", // 必须,对象别,1:客户,2:厂商,3 :客户厂商;为空时默认取3\r\n \"NAME\": \"客户A\", // 必须,全称\r\n \"SAL\": \"ZS\", // 非必须,责任业务\r\n \"ID1_TAX\": \"2\", // 非必须,扣税类别\r\n \"REM\": \"这是客户A备注\" // 非必须,备注\r\n },\r\n {\r\n \"CUS_NO\": \"KH0002\", // 必须,客户厂商代号,该客户厂商代号在资料中存在即为修改原数据,不存在为新增\r\n \"OBJ_ID\": \"3\", // 必须,对象别,1:客户,2:厂商,3 :客户厂商;为空时默认取3\r\n \"NAME\": \"客户B\", // 必须,全称\r\n \"SAL\": \"ZS\", // 非必须,责任业务\r\n \"ID1_TAX\": \"2\", // 非必须,扣税类别\r\n \"MAS_CUS\": \"KH0001\", // 非必须,归属客户\r\n \"REM\": \"这是客户B备注\" // 非必须,备注\r\n },\r\n {\r\n \"CUS_NO\": \"KH0003\", // 必须,客户厂商代号,该客户厂商代号在资料中存在即为修改原数据,不存在为新增\r\n \"OBJ_ID\": \"1\", // 必须,对象别,1:客户,2:厂商,3 :客户厂商;为空时默认取3\r\n \"NAME\": \"客户C\", // 必须,全称\r\n \"SAL\": \"ZS\", // 非必须,责任业务\r\n \"ID1_TAX\": \"2\", // 非必须,扣税类别\r\n \"REM\": \"这是客户C备注\" // 非必须,备注\r\n }\r\n]",
  969. "options": {
  970. "raw": {
  971. "language": "json"
  972. }
  973. }
  974. },
  975. "url": {
  976. "raw": "{{t-erp-api-url}}/Cust/AppendToCust",
  977. "host": [
  978. "{{t-erp-api-url}}"
  979. ],
  980. "path": [
  981. "Cust",
  982. "AppendToCust"
  983. ]
  984. },
  985. "description": "新增客户资料"
  986. },
  987. "response": []
  988. },
  989. {
  990. "name": "删除客户",
  991. "event": [
  992. {
  993. "listen": "test",
  994. "script": {
  995. "exec": [
  996. "// 1. 基础响应验证\r",
  997. "pm.test(\"✅ 状态码 200\", function() {\r",
  998. " pm.response.to.have.status(200);\r",
  999. "});\r",
  1000. "\r",
  1001. "// 2. 获取数据\r",
  1002. "var requestData = JSON.parse(pm.request.body.raw);\r",
  1003. "var responseData = pm.response.json();\r",
  1004. "\r",
  1005. "// 3. 响应结构验证\r",
  1006. "pm.test(\"📋 响应结构验证\", function() {\r",
  1007. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  1008. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  1009. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  1010. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  1011. "});\r",
  1012. "\r",
  1013. "// 4. 请求数据验证\r",
  1014. "pm.test(\"✅ 删除请求验证\", function() {\r",
  1015. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  1016. " \r",
  1017. " requestData.forEach((item, index) => {\r",
  1018. " const itemNum = index + 1;\r",
  1019. " \r",
  1020. " // 必填字段验证\r",
  1021. " pm.expect(item, `删除项${itemNum}`).to.have.property('CUS_NO');\r",
  1022. " pm.expect(item.CUS_NO, `客户${itemNum}代号`).to.be.a('string').and.not.empty;\r",
  1023. " });\r",
  1024. " \r",
  1025. " console.log(`🗑️ 请求删除 ${requestData.length} 个客户`);\r",
  1026. "});\r",
  1027. "\r",
  1028. "// 5. 业务结果验证\r",
  1029. "pm.test(\"📊 删除结果验证\", function() {\r",
  1030. " const total = requestData.length;\r",
  1031. " \r",
  1032. " // 验证计数逻辑\r",
  1033. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  1034. " \r",
  1035. " // 根据成功示例验证\r",
  1036. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  1037. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  1038. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  1039. " \r",
  1040. " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个客户`);\r",
  1041. "});"
  1042. ],
  1043. "type": "text/javascript",
  1044. "packages": {},
  1045. "requests": {}
  1046. }
  1047. }
  1048. ],
  1049. "request": {
  1050. "method": "POST",
  1051. "header": [
  1052. {
  1053. "key": "LoginId",
  1054. "value": "{{t-erp-api-login-id}}",
  1055. "type": "text"
  1056. },
  1057. {
  1058. "key": "sn",
  1059. "value": "{{t-erp-api-sn}}",
  1060. "type": "text"
  1061. }
  1062. ],
  1063. "body": {
  1064. "mode": "raw",
  1065. "raw": "[\r\n {\r\n \"CUS_NO\": \"KH0003\" // 必须,客户厂商代号,删除该笔客户厂商资料\r\n }\r\n]",
  1066. "options": {
  1067. "raw": {
  1068. "language": "json"
  1069. }
  1070. }
  1071. },
  1072. "url": {
  1073. "raw": "{{t-erp-api-url}}/Cust/DeleteForCust",
  1074. "host": [
  1075. "{{t-erp-api-url}}"
  1076. ],
  1077. "path": [
  1078. "Cust",
  1079. "DeleteForCust"
  1080. ]
  1081. },
  1082. "description": "删除客户资料"
  1083. },
  1084. "response": []
  1085. },
  1086. {
  1087. "name": "新增厂商",
  1088. "event": [
  1089. {
  1090. "listen": "test",
  1091. "script": {
  1092. "exec": [
  1093. "// 1. 基础响应验证\r",
  1094. "pm.test(\"✅ 状态码 200\", function() {\r",
  1095. " pm.response.to.have.status(200);\r",
  1096. "});\r",
  1097. "\r",
  1098. "// 2. 获取数据\r",
  1099. "var requestData = JSON.parse(pm.request.body.raw);\r",
  1100. "var responseData = pm.response.json();\r",
  1101. "\r",
  1102. "// 3. 响应结构验证\r",
  1103. "pm.test(\"📋 响应结构验证\", function() {\r",
  1104. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  1105. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  1106. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  1107. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  1108. "});\r",
  1109. "\r",
  1110. "// 4. 请求数据验证\r",
  1111. "pm.test(\"✅ 厂商数据验证\", function() {\r",
  1112. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  1113. " \r",
  1114. " requestData.forEach((supplier, index) => {\r",
  1115. " const supNum = index + 1;\r",
  1116. " \r",
  1117. " // 必填字段验证\r",
  1118. " pm.expect(supplier, `厂商${supNum}`).to.include.keys('CUS_NO', 'OBJ_ID', 'NAME');\r",
  1119. " pm.expect(supplier.CUS_NO, `厂商${supNum}代号`).to.be.a('string').and.not.empty;\r",
  1120. " pm.expect(supplier.NAME, `厂商${supNum}名称`).to.be.a('string').and.not.empty;\r",
  1121. " pm.expect(supplier.OBJ_ID, `厂商${supNum}对象别`).to.be.a('string');\r",
  1122. " \r",
  1123. " // 验证OBJ_ID取值范围(这里厂商应该是2或3,但根据接口说明,1、2、3都允许)\r",
  1124. " const validObjIds = ['1', '2', '3'];\r",
  1125. " if (supplier.OBJ_ID && supplier.OBJ_ID !== '') {\r",
  1126. " pm.expect(validObjIds).to.include(\r",
  1127. " supplier.OBJ_ID,\r",
  1128. " `厂商${supNum}的OBJ_ID应为1、2或3,当前值为:${supplier.OBJ_ID}`\r",
  1129. " );\r",
  1130. " }\r",
  1131. " \r",
  1132. " // 可选字段类型验证(如果存在)\r",
  1133. " const optionalFields = ['SAL', 'ID1_TAX', 'MAS_CUS', 'REM'];\r",
  1134. " optionalFields.forEach(field => {\r",
  1135. " if (supplier[field] !== undefined) {\r",
  1136. " pm.expect(supplier[field]).to.be.a('string');\r",
  1137. " }\r",
  1138. " });\r",
  1139. " });\r",
  1140. " \r",
  1141. " console.log(`✅ 已验证 ${requestData.length} 个厂商数据`);\r",
  1142. "});\r",
  1143. "\r",
  1144. "// 5. 业务结果验证\r",
  1145. "pm.test(\"📊 操作结果验证\", function() {\r",
  1146. " const total = requestData.length;\r",
  1147. " \r",
  1148. " // 验证计数逻辑\r",
  1149. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  1150. " \r",
  1151. " // 根据成功示例验证\r",
  1152. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  1153. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  1154. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  1155. " \r",
  1156. " console.log(`✅ 成功处理 ${responseData.OkCount}/${total} 个厂商`);\r",
  1157. "});"
  1158. ],
  1159. "type": "text/javascript",
  1160. "packages": {},
  1161. "requests": {}
  1162. }
  1163. }
  1164. ],
  1165. "request": {
  1166. "method": "POST",
  1167. "header": [
  1168. {
  1169. "key": "LoginId",
  1170. "value": "{{t-erp-api-login-id}}",
  1171. "type": "text"
  1172. },
  1173. {
  1174. "key": "sn",
  1175. "value": "{{t-erp-api-sn}}",
  1176. "type": "text"
  1177. }
  1178. ],
  1179. "body": {
  1180. "mode": "raw",
  1181. "raw": "[\r\n {\r\n \"CUS_NO\": \"CS0001\", // 必须,客户厂商代号,该客户厂商代号在资料中存在即为修改原数据,不存在为新增\r\n \"OBJ_ID\": \"2\", // 必须,对象别,1:客户,2:厂商,3 :客户厂商;为空时默认取3\r\n \"NAME\": \"厂商A\", // 必须,全称\r\n \"SAL\": \"ZS\", // 非必须,责任业务\r\n \"ID1_TAX\": \"2\", // 非必须,扣税类别\r\n \"REM\": \"这是厂商A备注\" // 非必须,备注\r\n },\r\n {\r\n \"CUS_NO\": \"CS0002\", // 必须,客户厂商代号,该客户厂商代号在资料中存在即为修改原数据,不存在为新增\r\n \"OBJ_ID\": \"3\", // 必须,对象别,1:客户,2:厂商,3 :客户厂商;为空时默认取3\r\n \"NAME\": \"厂商B\", // 必须,全称\r\n \"SAL\": \"ZS\", // 非必须,责任业务\r\n \"ID1_TAX\": \"2\", // 非必须,扣税类别\r\n \"MAS_CUS\": \"CS0001\", // 非必须,归属厂商\r\n \"REM\": \"这是厂商B备注\" // 非必须,备注\r\n },\r\n {\r\n \"CUS_NO\": \"CS0003\", // 必须,客户厂商代号,该客户厂商代号在资料中存在即为修改原数据,不存在为新增\r\n \"OBJ_ID\": \"2\", // 必须,对象别,1:客户,2:厂商,3 :客户厂商;为空时默认取3\r\n \"NAME\": \"厂商C\", // 必须,全称\r\n \"SAL\": \"ZS\", // 非必须,责任业务\r\n \"ID1_TAX\": \"2\", // 非必须,扣税类别\r\n \"REM\": \"这是厂商C备注\" // 非必须,备注\r\n }\r\n]",
  1182. "options": {
  1183. "raw": {
  1184. "language": "json"
  1185. }
  1186. }
  1187. },
  1188. "url": {
  1189. "raw": "{{t-erp-api-url}}/Cust/AppendToCust",
  1190. "host": [
  1191. "{{t-erp-api-url}}"
  1192. ],
  1193. "path": [
  1194. "Cust",
  1195. "AppendToCust"
  1196. ]
  1197. },
  1198. "description": "新增厂商资料"
  1199. },
  1200. "response": []
  1201. },
  1202. {
  1203. "name": "删除厂商",
  1204. "event": [
  1205. {
  1206. "listen": "test",
  1207. "script": {
  1208. "exec": [
  1209. "// 1. 基础响应验证\r",
  1210. "pm.test(\"✅ 状态码 200\", function() {\r",
  1211. " pm.response.to.have.status(200);\r",
  1212. "});\r",
  1213. "\r",
  1214. "// 2. 获取数据\r",
  1215. "var requestData = JSON.parse(pm.request.body.raw);\r",
  1216. "var responseData = pm.response.json();\r",
  1217. "\r",
  1218. "// 3. 响应结构验证\r",
  1219. "pm.test(\"📋 响应结构验证\", function() {\r",
  1220. " pm.expect(responseData).to.have.all.keys('OkCount', 'ErrorCount', 'ErrorData');\r",
  1221. " pm.expect(responseData.OkCount).to.be.a('number');\r",
  1222. " pm.expect(responseData.ErrorCount).to.be.a('number');\r",
  1223. " pm.expect(responseData.ErrorData).to.be.an('array');\r",
  1224. "});\r",
  1225. "\r",
  1226. "// 4. 请求数据验证\r",
  1227. "pm.test(\"✅ 删除请求验证\", function() {\r",
  1228. " pm.expect(requestData).to.be.an('array').that.is.not.empty;\r",
  1229. " \r",
  1230. " requestData.forEach((item, index) => {\r",
  1231. " const itemNum = index + 1;\r",
  1232. " \r",
  1233. " // 必填字段验证\r",
  1234. " pm.expect(item, `删除项${itemNum}`).to.have.property('CUS_NO');\r",
  1235. " pm.expect(item.CUS_NO, `厂商${itemNum}代号`).to.be.a('string').and.not.empty;\r",
  1236. " });\r",
  1237. " \r",
  1238. " console.log(`🗑️ 请求删除 ${requestData.length} 个厂商`);\r",
  1239. "});\r",
  1240. "\r",
  1241. "// 5. 业务结果验证\r",
  1242. "pm.test(\"📊 删除结果验证\", function() {\r",
  1243. " const total = requestData.length;\r",
  1244. " \r",
  1245. " // 验证计数逻辑\r",
  1246. " pm.expect(responseData.OkCount + responseData.ErrorCount).to.equal(total);\r",
  1247. " \r",
  1248. " // 根据成功示例验证\r",
  1249. " pm.expect(responseData.ErrorCount, \"失败数量\").to.equal(0);\r",
  1250. " pm.expect(responseData.OkCount, \"成功数量\").to.equal(total);\r",
  1251. " pm.expect(responseData.ErrorData, \"错误数据\").to.eql([]);\r",
  1252. " \r",
  1253. " console.log(`✅ 成功删除 ${responseData.OkCount}/${total} 个厂商`);\r",
  1254. "});"
  1255. ],
  1256. "type": "text/javascript",
  1257. "packages": {},
  1258. "requests": {}
  1259. }
  1260. }
  1261. ],
  1262. "request": {
  1263. "method": "POST",
  1264. "header": [
  1265. {
  1266. "key": "LoginId",
  1267. "value": "{{t-erp-api-login-id}}",
  1268. "type": "text"
  1269. },
  1270. {
  1271. "key": "sn",
  1272. "value": "{{t-erp-api-sn}}",
  1273. "type": "text"
  1274. }
  1275. ],
  1276. "body": {
  1277. "mode": "raw",
  1278. "raw": "[\r\n {\r\n \"CUS_NO\": \"CS0003\" // 必须,客户厂商代号,删除该笔客户厂商资料\r\n }\r\n]",
  1279. "options": {
  1280. "raw": {
  1281. "language": "json"
  1282. }
  1283. }
  1284. },
  1285. "url": {
  1286. "raw": "{{t-erp-api-url}}/Cust/DeleteForCust",
  1287. "host": [
  1288. "{{t-erp-api-url}}"
  1289. ],
  1290. "path": [
  1291. "Cust",
  1292. "DeleteForCust"
  1293. ]
  1294. },
  1295. "description": "删除厂商资料"
  1296. },
  1297. "response": []
  1298. }
  1299. ],
  1300. "description": "客户/厂商资料"
  1301. }
  1302. ]
  1303. },
  1304. {
  1305. "name": "🔄 示例业务流程(采购→销售完整链路)",
  1306. "item": [
  1307. {
  1308. "name": "01-新增采购订单",
  1309. "event": [
  1310. {
  1311. "listen": "test",
  1312. "script": {
  1313. "exec": [
  1314. "// 1. 解析接口顶层的JSON响应",
  1315. "var resJson = pm.response.json();",
  1316. "console.log(\"✅ 接口顶层JSON解析成功\");",
  1317. "",
  1318. "// 2. 提取Data字段",
  1319. "var dataRawStr = resJson.Data;",
  1320. "if (!dataRawStr) {",
  1321. " console.error(\"❌ Data字段为空/不存在\");",
  1322. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  1323. " return;",
  1324. "}",
  1325. "",
  1326. "// 3. 解析Data",
  1327. "var dataJson;",
  1328. "try {",
  1329. " dataJson = JSON.parse(dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \"));",
  1330. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  1331. "} catch (e) {",
  1332. " console.error(\"❌ Data解析失败:\", e.message);",
  1333. " pm.test(\"Data字段可正常解析\", () => pm.expect.fail(\"Data格式错误\"));",
  1334. " return;",
  1335. "}",
  1336. "",
  1337. "var bilNo = dataJson.BIL_NO;",
  1338. "var bilId = dataJson.BIL_ID;",
  1339. "console.log(`📌 采购订单:BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  1340. "",
  1341. "pm.test(\"✅ 新增采购订单成功\", function () {",
  1342. " pm.response.to.have.status(200);",
  1343. " pm.expect(resJson.CallOK).to.equal(\"T\");",
  1344. "});",
  1345. "",
  1346. "pm.test(\"✅ TF_TABNAME=TF_POS\", () => {",
  1347. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_POS\");",
  1348. "});",
  1349. "",
  1350. "pm.test(\"✅ 采购信息写入环境变量\", function () {",
  1351. " pm.environment.set(\"t-erp-api-po-bill-no\", bilNo);",
  1352. " console.log(`✅ 采购订单单号已写入:${bilNo}`);",
  1353. " ",
  1354. " var reqBody = JSON.parse(pm.request.body.raw);",
  1355. " var PrdNo = reqBody.BodyData[0].PrdNo;",
  1356. " var Qty = reqBody.BodyData[0].Qty;",
  1357. " pm.environment.set(\"prd-no\", PrdNo);",
  1358. " pm.environment.set(\"po-qty\", Qty);",
  1359. " ",
  1360. "});"
  1361. ],
  1362. "type": "text/javascript",
  1363. "packages": {},
  1364. "requests": {}
  1365. }
  1366. },
  1367. {
  1368. "listen": "prerequest",
  1369. "script": {
  1370. "exec": [
  1371. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  1372. "function addZero(num) {",
  1373. " return num < 10 ? '0' + num : num;",
  1374. "}",
  1375. "const now = new Date();",
  1376. "const year = now.getFullYear();",
  1377. "const month = addZero(now.getMonth() + 1);",
  1378. "const day = addZero(now.getDate());",
  1379. "const currentDate = `${year}-${month}-${day}`;",
  1380. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  1381. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  1382. ],
  1383. "type": "text/javascript",
  1384. "packages": {},
  1385. "requests": {}
  1386. }
  1387. }
  1388. ],
  1389. "request": {
  1390. "method": "POST",
  1391. "header": [
  1392. {
  1393. "key": "LoginId",
  1394. "value": "{{t-erp-api-login-id}}",
  1395. "type": "text"
  1396. },
  1397. {
  1398. "key": "sn",
  1399. "value": "{{t-erp-api-sn}}",
  1400. "type": "text"
  1401. }
  1402. ],
  1403. "body": {
  1404. "mode": "raw",
  1405. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PO\",\n \"CusNo\": \"CS0001\",\n \"DepNo\": \"0001\",\n \"SalNo\": \"LS\",\n \"EstDate\": \"{{t-erp-api-current-date}}\",\n \"Rem\": \"自动化测试-采购订单\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0002\",\n \"WhNo\": \"0001\",\n \"Qty\": 100,\n \"Up\": 100,\n \"Rem\": \"测试用原料\"\n }\n ]\n}",
  1406. "options": {
  1407. "raw": {
  1408. "language": "json"
  1409. }
  1410. }
  1411. },
  1412. "url": {
  1413. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  1414. "host": [
  1415. "{{t-erp-api-url}}"
  1416. ],
  1417. "path": [
  1418. "Bill",
  1419. "SaveBill"
  1420. ]
  1421. }
  1422. },
  1423. "response": []
  1424. },
  1425. {
  1426. "name": "02-查询在途量(新增PO后)",
  1427. "event": [
  1428. {
  1429. "listen": "test",
  1430. "script": {
  1431. "exec": [
  1432. "pm.test(\"✅ SQL查询在途量接口连通\", function () {",
  1433. " pm.response.to.have.status(200);",
  1434. " console.log(\"✅ 在途量查询成功\");",
  1435. " console.log(\"📊 查询结果:\", JSON.stringify(pm.response.json()));",
  1436. "});",
  1437. "",
  1438. "// 用例1:HTTP请求成功",
  1439. "pm.test(\"✅ 接口调用成功\", function () {",
  1440. " pm.expect(pm.response.code).to.equal(200, `异常状态码:${pm.response.code}`);",
  1441. "});",
  1442. "",
  1443. "// 解析返回JSON",
  1444. "const resp = pm.response.json();",
  1445. "",
  1446. "// 用例2:SQL业务执行成功",
  1447. "pm.test(\"✅ SQL查询成功\", function () {",
  1448. " pm.expect(resp.code).to.equal(0);",
  1449. " pm.expect(resp.result.Success).to.be.true;",
  1450. " pm.expect(resp.message).to.equal(\"SQL查询执行成功。\");",
  1451. "});",
  1452. "",
  1453. "// 用例3:校验查询到库存数据",
  1454. "pm.test(\"✅ 成功查询到产品库存数据\", function () {",
  1455. " pm.expect(resp.result.Data).to.be.an(\"array\");",
  1456. " pm.expect(resp.result.Data.length).gt(0, \"未查询到该产品\");",
  1457. "});",
  1458. "",
  1459. "// 用例4:每次新增单据,在途库存增加",
  1460. "pm.test(\"✅ 校验在途库存QTY_ON_WAY每次新增\", function () {",
  1461. " const currentQty = Number(resp.result.Data[0].QTY_ON_WAY);",
  1462. " const lastQty = pm.environment.get(\"last_qty_on_way_po\");",
  1463. " console.log(\"上次库存:\", lastQty, \"本次库存:\", currentQty);",
  1464. "",
  1465. " if (lastQty !== null && lastQty !== undefined) {",
  1466. " const addQty = Number(pm.environment.get(\"po-qty\"));",
  1467. " pm.expect(currentQty).equal(Number(lastQty) + addQty,",
  1468. " `库存校验失败:预期${Number(lastQty)+addQty},实际${currentQty}`);",
  1469. " } else {",
  1470. " console.log(\"首次执行,记录初始库存\");",
  1471. " }",
  1472. " // 保存本次库存,用于下一轮校验",
  1473. " pm.environment.set(\"last_qty_on_way_po\", currentQty);",
  1474. "});"
  1475. ],
  1476. "type": "text/javascript",
  1477. "packages": {},
  1478. "requests": {}
  1479. }
  1480. }
  1481. ],
  1482. "request": {
  1483. "method": "POST",
  1484. "header": [
  1485. {
  1486. "key": "LoginId",
  1487. "value": "{{t-erp-api-login-id}}",
  1488. "type": "text"
  1489. },
  1490. {
  1491. "key": "sn",
  1492. "value": "{{t-erp-api-sn}}",
  1493. "type": "text"
  1494. },
  1495. {
  1496. "key": "DbType",
  1497. "value": "1",
  1498. "type": "text"
  1499. }
  1500. ],
  1501. "body": {
  1502. "mode": "raw",
  1503. "raw": "{\n \"SQL\": \"SELECT PRD_NO, SUM(QTY_ON_WAY) AS QTY_ON_WAY FROM PRDT1 WHERE PRD_NO=@PRD_NO GROUP BY PRD_NO\",\n \"PARAMETERS\": {\n \"@PRD_NO\": \"{{prd-no}}\"\n }\n}\n",
  1504. "options": {
  1505. "raw": {
  1506. "language": "json"
  1507. }
  1508. }
  1509. },
  1510. "url": {
  1511. "raw": "{{t-erp-api-url}}/SqlOperation/ExecuteSql",
  1512. "host": [
  1513. "{{t-erp-api-url}}"
  1514. ],
  1515. "path": [
  1516. "SqlOperation",
  1517. "ExecuteSql"
  1518. ]
  1519. }
  1520. },
  1521. "response": []
  1522. },
  1523. {
  1524. "name": "03-新增采购入库单(转自PO)",
  1525. "event": [
  1526. {
  1527. "listen": "prerequest",
  1528. "script": {
  1529. "exec": [
  1530. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  1531. "function addZero(num) {",
  1532. " return num < 10 ? '0' + num : num;",
  1533. "}",
  1534. "const now = new Date();",
  1535. "const year = now.getFullYear();",
  1536. "const month = addZero(now.getMonth() + 1);",
  1537. "const day = addZero(now.getDate());",
  1538. "const currentDate = `${year}-${month}-${day}`;",
  1539. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  1540. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  1541. ],
  1542. "type": "text/javascript",
  1543. "packages": {},
  1544. "requests": {}
  1545. }
  1546. },
  1547. {
  1548. "listen": "test",
  1549. "script": {
  1550. "exec": [
  1551. "var resJson = pm.response.json();",
  1552. "var dataRawStr = resJson.Data;",
  1553. "var dataJson;",
  1554. "try {",
  1555. " dataJson = JSON.parse(dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \"));",
  1556. "} catch(e) { return; }",
  1557. "",
  1558. "var bilNo = dataJson.BIL_NO;",
  1559. "console.log(`📌 采购入库单:BIL_NO=${bilNo}`);",
  1560. "",
  1561. "pm.test(\"✅ 新增采购入库单成功\", function () {",
  1562. " pm.response.to.have.status(200);",
  1563. " pm.expect(resJson.CallOK).to.equal(\"T\");",
  1564. "});",
  1565. "",
  1566. "pm.test(\"✅ TF_TABNAME=TF_PSS\", () => {",
  1567. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  1568. "});",
  1569. "",
  1570. "pm.test(\"✅ 采购入库单单号写入环境变量\", function () {",
  1571. " pm.environment.set(\"t-erp-api-pc-bill-no\", bilNo);",
  1572. " console.log(`✅ 采购入库单单号已写入:${bilNo}`);",
  1573. "});"
  1574. ],
  1575. "type": "text/javascript",
  1576. "packages": {},
  1577. "requests": {}
  1578. }
  1579. }
  1580. ],
  1581. "request": {
  1582. "method": "POST",
  1583. "header": [
  1584. {
  1585. "key": "LoginId",
  1586. "value": "{{t-erp-api-login-id}}",
  1587. "type": "text"
  1588. },
  1589. {
  1590. "key": "sn",
  1591. "value": "{{t-erp-api-sn}}",
  1592. "type": "text"
  1593. }
  1594. ],
  1595. "body": {
  1596. "mode": "raw",
  1597. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PC\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"BilId\": \"PO\",\n \"BilNo\": \"{{t-erp-api-po-bill-no}}\",\n \"BilItm\": 1\n }\n ]\n}",
  1598. "options": {
  1599. "raw": {
  1600. "language": "json"
  1601. }
  1602. }
  1603. },
  1604. "url": {
  1605. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  1606. "host": [
  1607. "{{t-erp-api-url}}"
  1608. ],
  1609. "path": [
  1610. "Bill",
  1611. "SaveBill"
  1612. ]
  1613. }
  1614. },
  1615. "response": []
  1616. },
  1617. {
  1618. "name": "04-查询采购入库单信息",
  1619. "event": [
  1620. {
  1621. "listen": "test",
  1622. "script": {
  1623. "exec": [
  1624. "",
  1625. "pm.test(\"✅ 查询采购入库单成功\", function () {",
  1626. " pm.response.to.have.status(200);",
  1627. " let r = pm.response.json();",
  1628. " pm.expect(r.CallOK).to.equal(\"T\");",
  1629. " console.log(\"✅ 查询单据成功\");",
  1630. "});",
  1631. "",
  1632. "pm.test(\"✅ 获取单据信息写入变量\", () => {",
  1633. " const res = pm.response.json();",
  1634. " const pcQty = Number(res.Data.BODYDATA1[0].QTY);",
  1635. " pm.environment.set(\"pc-qty\", pcQty);",
  1636. "",
  1637. " console.log(`✅ 已抓取入库数量,pc-qty = ${pcQty}`);",
  1638. "});",
  1639. "",
  1640. "pm.test(\"✅ 校验本次入库数量与采购下单数量一致\", () => {",
  1641. " const res = pm.response.json();",
  1642. " const pcQty = Number(res.Data.BODYDATA1[0].QTY);",
  1643. " const poQty = Number(pm.environment.get(\"po-qty\"));",
  1644. " pm.expect(pcQty).to.equal(",
  1645. " poQty,",
  1646. " `数量不一致校验失败:采购下单数量PO-QTY=${poQty},本次入库数量PC-QTY=${pcQty}`",
  1647. " );",
  1648. "});"
  1649. ],
  1650. "type": "text/javascript",
  1651. "packages": {},
  1652. "requests": {}
  1653. }
  1654. }
  1655. ],
  1656. "request": {
  1657. "method": "POST",
  1658. "header": [
  1659. {
  1660. "key": "LoginId",
  1661. "value": "{{t-erp-api-login-id}}",
  1662. "type": "text"
  1663. },
  1664. {
  1665. "key": "sn",
  1666. "value": "{{t-erp-api-sn}}",
  1667. "type": "text"
  1668. }
  1669. ],
  1670. "body": {
  1671. "mode": "raw",
  1672. "raw": "{\r\n \"CallId\": \"PC\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-pc-bill-no}}\" // 必须,调用的单据号码\r\n}\r\n\r\n{\r\n \"EntryOrderId\": \"\",\r\n \"CallID\": \"PC\",\r\n \"CallNO\": \"PC20267210001\",\r\n \"CallOK\": \"T\",\r\n \"Data\": {\r\n \"HEADDATA\": {\r\n \"PS_ID\": \"PC\",\r\n \"PS_NO\": \"PC20267210001\",\r\n \"PS_DD\": \"2026/7/21 0:00:00\",\r\n \"PAY_DD\": \"2026/8/1 0:00:00\",\r\n \"CHK_DD\": \"2026/9/1 0:00:00\",\r\n \"TRAD_MTH\": \"\",\r\n \"BAT_NO\": \"\",\r\n \"CUS_NO\": \"CS0001\",\r\n \"VOH_ID\": \"\",\r\n \"VOH_NO\": \"\",\r\n \"DEP\": \"0001\",\r\n \"INV_NO\": \"\",\r\n \"TAX_ID\": \"2.00\",\r\n \"OS_ID\": \"PO\",\r\n \"OS_NO\": \"PO20267210001\",\r\n \"SEND_MTH\": \"1\",\r\n \"SEND_WH\": \"0000\",\r\n \"RP_NO\": \"\",\r\n \"ZHANG_ID\": \"1\",\r\n \"CUR_ID\": \"\",\r\n \"EXC_RTO\": \"1.00000000\",\r\n \"SAL_NO\": \"LS\",\r\n \"ARP_NO\": \"AP20267210001\",\r\n \"AMTN_IRP\": \"0.00\",\r\n \"AMT_IRP\": \"0.00\",\r\n \"RSV_PER\": \"\",\r\n \"AMTN_RSV\": \"0.00\",\r\n \"AMT_RSV\": \"0.00\",\r\n \"ADR\": \"\",\r\n \"REM\": \"自动化测试-采购订单\",\r\n \"PAY_MTH\": \"1\",\r\n \"PAY_DAYS\": \"1\",\r\n \"CHK_DAYS\": \"30\",\r\n \"INT_DAYS\": \"30\",\r\n \"PAY_REM\": \"结帐期:2026-08-01; 票据到期日:2026-09-01\",\r\n \"CLS_ID\": \"\",\r\n \"EP_NO\": \"\",\r\n \"AMTN_EP\": \"0.00\",\r\n \"TAX_IRP\": \"0.00\",\r\n \"USR\": \"API\",\r\n \"CHK_MAN\": \"API\",\r\n \"PRT_SW\": \"N\",\r\n \"CPY_SW\": \"\",\r\n \"BIL_NO\": \"\",\r\n \"DIS_CNT\": \"0.00000000\",\r\n \"CASH_ID\": \"\",\r\n \"QTY_INV\": \"0.00\",\r\n \"QTY_CASH\": \"0.00\",\r\n \"AMTN_INV\": \"0.00\",\r\n \"AMTN_CASH\": \"0.00\",\r\n \"CB_ID\": \"\",\r\n \"CONTRACT\": \"\",\r\n \"LC_NO\": \"\",\r\n \"PK_NO\": \"\",\r\n \"CLS_REM\": \"\",\r\n \"SCUS_NO\": \"\",\r\n \"SOUTYPE\": \"\",\r\n \"SGTFLAG\": \"\",\r\n \"AMT\": \"0.00\",\r\n \"VOH_MKNO\": \"\",\r\n \"POS_NO\": \"\",\r\n \"BIL_ID\": \"\",\r\n \"CLS_DATE\": \"2026/7/21 0:00:00\",\r\n \"MM_ID\": \"\",\r\n \"CUS_OS_NO\": \"\",\r\n \"PO_ID\": \"\",\r\n \"CK_CLS_ID\": \"\",\r\n \"LZ_CLS_ID\": \"F\",\r\n \"CLSCK\": \"\",\r\n \"CLSLZ\": \"\",\r\n \"BIL_TYPE\": \"\",\r\n \"IS_POS\": \"\",\r\n \"LOCK_MAN\": \"\",\r\n \"YD_ID\": \"\",\r\n \"AMTN_EP1\": \"0.00\",\r\n \"EP_NO1\": \"\",\r\n \"FC_ID\": \"F\",\r\n \"IS_PE\": \"\",\r\n \"LZ_CLS_DD\": \"\",\r\n \"EFF_DD\": \"2026/7/21 10:51:17\",\r\n \"QC_YN\": \"\",\r\n \"CLEAR_ID\": \"\",\r\n \"IJ_NO\": \"\",\r\n \"CO_NO\": \"\",\r\n \"RECORD_DD\": \"2026/7/21 10:51:17\",\r\n \"DEF_NO\": \"\",\r\n \"MAN_CK_CLS\": \"\",\r\n \"IS_TRANS\": \"\",\r\n \"IS_SP\": \"\",\r\n \"AMTN_YH\": \"0.00\",\r\n \"AMT_YH\": \"0.00\",\r\n \"CC_ID\": \"\",\r\n \"TRACE_NO\": \"\",\r\n \"SHOP_NO\": \"\",\r\n \"TRADE_ID\": \"\",\r\n \"AMTN_NET_TOT\": \"10000.00\",\r\n \"IS_SF\": \"\",\r\n \"TB_NO\": \"\",\r\n \"CONFIRMID\": \"\",\r\n \"SALERNO\": \"\",\r\n \"BUYERNO\": \"\",\r\n \"INVOICETYPE\": \"\",\r\n \"INVOICEKIND\": \"\",\r\n \"SOURCE_SYS\": \"\",\r\n \"LOCK_DD\": \"\",\r\n \"EDT_DD\": \"\",\r\n \"EDTUSR\": \"\"\r\n },\r\n \"BODYDATA1\": [\r\n {\r\n \"PS_ID\": \"PC\",\r\n \"PS_NO\": \"PC20267210001\",\r\n \"ITM\": \"1\",\r\n \"PS_DD\": \"2026/7/21 0:00:00\",\r\n \"WH\": \"0001\",\r\n \"BAT_NO\": \"\",\r\n \"OS_NO\": \"PO20267210001\",\r\n \"PRD_NO\": \"YL0002\",\r\n \"PRD_NAME\": \"原料0002\",\r\n \"PRD_MARK\": \"\",\r\n \"UNIT\": \"1\",\r\n \"QTY\": \"100.00\",\r\n \"QTY1\": \"0.00\",\r\n \"CST_SAL\": \"0.00\",\r\n \"CSTN_SAL\": \"0.00\",\r\n \"UP\": \"100.0000\",\r\n \"AMTN_NET\": \"8849.56\",\r\n \"AMT\": \"10000.00\",\r\n \"TAX\": \"1150.44\",\r\n \"DIS_CNT\": \"0.00000000\",\r\n \"QTY_RTN\": \"0.00\",\r\n \"AMTN_EP\": \"0.00\",\r\n \"PAK_UNIT\": \"\",\r\n \"PAK_EXC\": \"\",\r\n \"PAK_NW\": \"\",\r\n \"PAK_WEIGHT_UNIT\": \"\",\r\n \"PAK_GW\": \"\",\r\n \"PAK_MEAST\": \"\",\r\n \"PAK_MEAST_UNIT\": \"\",\r\n \"VALID_DD\": \"1899/12/30 0:00:00\",\r\n \"REM\": \"测试用原料\",\r\n \"AMTN_COM\": \"0.00\",\r\n \"EST_DD\": \"2026/7/21 0:00:00\",\r\n \"TAX_RTO\": \"13.00\",\r\n \"CST_STD\": \"0.00\",\r\n \"UP_QTY1\": \"0.00\",\r\n \"EST_ITM\": \"1\",\r\n \"OS_ID\": \"PO\",\r\n \"QTY_PS\": \"100.00\",\r\n \"PRE_ITM\": \"1\",\r\n \"SEND_WH\": \"\",\r\n \"QTY_LOSS\": \"0.00\",\r\n \"QTYS\": \"0.00\",\r\n \"AMTN_SNET\": \"0.00\",\r\n \"TAXS\": \"0.00\",\r\n \"UT\": \"\",\r\n \"WT\": \"\",\r\n \"AMTN\": \"0.00\",\r\n \"CODE_NO\": \"\",\r\n \"ATTR\": \"\",\r\n \"QTY_FX\": \"0.00\",\r\n \"ID_NO\": \"\",\r\n \"FREE_ID\": \"\",\r\n \"CK_NO\": \"\",\r\n \"MM_ID\": \"\",\r\n \"AMT_FP\": \"0.00\",\r\n \"AMTN_NET_FP\": \"0.00\",\r\n \"TAX_FP\": \"0.00\",\r\n \"QTY_CK\": \"0.00\",\r\n \"BZ_KND\": \"\",\r\n \"PRICE_ID\": \"\",\r\n \"OTH_ITM\": \"\",\r\n \"CUS_OS_NO\": \"\",\r\n \"QTY_RK\": \"0.00\",\r\n \"RK_NO\": \"\",\r\n \"AMT_RCV\": \"0.00\",\r\n \"AMTN_RCV\": \"0.00\",\r\n \"CLS_ID\": \"\",\r\n \"CHK_TAX\": \"\",\r\n \"FH_NO\": \"\",\r\n \"INV_NO\": \"\",\r\n \"CST_MAKE\": \"0.00\",\r\n \"CST_MAN\": \"0.00\",\r\n \"CST_PRD\": \"0.00\",\r\n \"CST_OUT\": \"0.00\",\r\n \"CST_SMAKE\": \"0.00\",\r\n \"CST_SMAN\": \"0.00\",\r\n \"CST_SPRD\": \"0.00\",\r\n \"CST_SOUT\": \"0.00\",\r\n \"QTY_FP\": \"0.00\",\r\n \"PRD_LOC\": \"\",\r\n \"SEQ_ITM\": \"0\",\r\n \"MRP_NO_SO\": \"\",\r\n \"QTY_BAD\": \"0.00\",\r\n \"UP_END\": \"100.0000\",\r\n \"QTY_NOSH\": \"0.00\",\r\n \"TY_ID\": \"\",\r\n \"TY_NO\": \"\",\r\n \"TY_EST_ITM\": \"\",\r\n \"TY1_EST_ITM\": \"\",\r\n \"UP_CST\": \"0.0000\",\r\n \"UP1_CST\": \"0.0000\",\r\n \"UP_CST_UT\": \"0.0000\",\r\n \"QTY_NOSH_FP\": \"0.00\",\r\n \"AMT_NOSH_FP\": \"0.00\",\r\n \"AMTN_NOSH_FP\": \"0.00\",\r\n \"TAX_NOSH_FP\": \"0.00\",\r\n \"QTY_NOSH_RTN\": \"0.00\",\r\n \"QTY_NOSH_FX\": \"0.00\",\r\n \"QTY_NOSH_RK\": \"0.00\",\r\n \"CO_NO\": \"\",\r\n \"EFF_DD\": \"2026/7/21 10:51:17\",\r\n \"SEFF_DATE\": \"2026/7/21 10:42:28\",\r\n \"UP_DJ\": \"0.0000\",\r\n \"UP_TC\": \"0.0000\",\r\n \"TM_ID\": \"\",\r\n \"TM_NO\": \"\",\r\n \"FORMULA_CSV\": \"\",\r\n \"OBJ_NO\": \"\",\r\n \"OBJ_CLASS\": \"\",\r\n \"SPC\": \"\",\r\n \"FREEINDEX\": \"\",\r\n \"ORDER_ID\": \"\",\r\n \"TCODE_CHK\": \"\",\r\n \"UPR\": \"0.0000\",\r\n \"QTY_TCODE\": \"0.00\",\r\n \"CONFIRMFLAG\": \"\",\r\n \"QTY1_TCODE\": \"0.00\",\r\n \"WH_TCODE\": \"\",\r\n \"PRD_LOC_TCODE\": \"\",\r\n \"PRD_MARK_TCODE\": \"\",\r\n \"BAT_NO_TCODE\": \"\",\r\n \"MFG_DD\": \"\",\r\n \"PACK_NO\": \"\",\r\n \"BC_ITM\": \"\",\r\n \"MB_NO\": \"\",\r\n \"HX_ID\": \"\",\r\n \"TB_NO\": \"\",\r\n \"TB_SUB_NO\": \"\",\r\n \"PACK_FREQUENCY\": \"\",\r\n \"CONFIRMID\": \"\",\r\n \"REV_NO\": \"\",\r\n \"COS_NO\": \"\",\r\n \"PRD_NO_SUP\": \"\",\r\n \"INVOICESPC\": \"\",\r\n \"INVOICENAME\": \"\",\r\n \"PRD_NAME_SUP\": \"\",\r\n \"AMT_ZDZK\": \"0.00\",\r\n \"AMTN_NET_ZDZK\": \"0.00\",\r\n \"TAX_ZDZK\": \"0.00\",\r\n \"AMT_DIFF_FP\": \"0.00\",\r\n \"AMTN_DIFF_FP\": \"0.00\",\r\n \"TAX_DIFF_FP\": \"0.00\",\r\n \"AMT_DIFF_NOSH_FP\": \"0.00\",\r\n \"AMTN_DIFF_NOSH_FP\": \"0.00\",\r\n \"TAX_DIFF_NOSH_FP\": \"0.00\"\r\n }\r\n ]\r\n },\r\n \"ErrorStr\": \"\"\r\n}",
  1673. "options": {
  1674. "raw": {
  1675. "language": "json"
  1676. }
  1677. }
  1678. },
  1679. "url": {
  1680. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  1681. "host": [
  1682. "{{t-erp-api-url}}"
  1683. ],
  1684. "path": [
  1685. "Bill",
  1686. "QueryBillDetail"
  1687. ]
  1688. }
  1689. },
  1690. "response": []
  1691. },
  1692. {
  1693. "name": "05-查询可用库存量(入库后)",
  1694. "event": [
  1695. {
  1696. "listen": "test",
  1697. "script": {
  1698. "exec": [
  1699. "pm.test(\"✅ SQL查询可用库存量接口连通\", function () {",
  1700. " pm.response.to.have.status(200);",
  1701. " console.log(\"✅ 可用库存量查询成功\");",
  1702. " console.log(\"📊 查询结果:\", JSON.stringify(pm.response.json()));",
  1703. "});",
  1704. "",
  1705. "// 用例1:HTTP请求成功",
  1706. "pm.test(\"✅ 接口调用成功\", function () {",
  1707. " pm.expect(pm.response.code).to.equal(200, `异常状态码:${pm.response.code}`);",
  1708. "});",
  1709. "",
  1710. "// 解析返回JSON",
  1711. "const resp = pm.response.json();",
  1712. "",
  1713. "// 用例2:SQL业务执行成功",
  1714. "pm.test(\"✅ SQL查询可用库存量成功\", function () {",
  1715. " pm.expect(resp.code).to.equal(0);",
  1716. " pm.expect(resp.result.Success).to.be.true;",
  1717. " pm.expect(resp.message).to.equal(\"SQL查询执行成功。\");",
  1718. "});",
  1719. "",
  1720. "// 用例3:校验查询到库存数据",
  1721. "pm.test(\"✅ 成功查询到产品库存数据\", function () {",
  1722. " pm.expect(resp.result.Data).to.be.an(\"array\");",
  1723. " pm.expect(resp.result.Data.length).gt(0, \"未查询到该产品\");",
  1724. "});",
  1725. "",
  1726. "// 用例4:每次新增单据,在途库存减少",
  1727. "pm.test(\"✅ 校验在途库存QTY_ON_WAY减少\", function () {",
  1728. " const currentQty_onway = Number(resp.result.Data[0].QTY_ON_WAY);",
  1729. " const lastQty_onway = pm.environment.get(\"last_qty_on_way\");",
  1730. " console.log(\"上次库存:\", lastQty_onway, \"本次库存:\", currentQty_onway);",
  1731. "",
  1732. " if (lastQty_onway !== null && lastQty_onway !== undefined) {",
  1733. " const subQty = Number(pm.environment.get(\"po-qty\"));",
  1734. " pm.expect(currentQty_onway).equal(Number(lastQty_onway) - subQty,",
  1735. " `库存校验失败:预期${Number(lastQty_onway)-subQty},实际${currentQty_onway}`);",
  1736. " } else {",
  1737. " console.log(\"首次执行,记录初始库存\");",
  1738. " }",
  1739. " // 保存本次库存,用于下一轮校验",
  1740. " pm.environment.set(\"last_qty_on_way\", currentQty_onway);",
  1741. "});",
  1742. "",
  1743. "// 用例5:每次新增单据,可用数量增加",
  1744. "pm.test(\"✅ 校验可用数量QTY增加\", function () {",
  1745. " const currentQty = Number(resp.result.Data[0].QTY);",
  1746. " const lastQty = pm.environment.get(\"last_qty\");",
  1747. " console.log(\"上次库存:\", lastQty, \"本次库存:\", currentQty);",
  1748. "",
  1749. " if (lastQty !== null && lastQty !== undefined) {",
  1750. " const addQty = Number(pm.environment.get(\"pc-qty\"));",
  1751. " pm.expect(currentQty).equal(Number(lastQty) + addQty,",
  1752. " `库存校验失败:预期${Number(lastQty)+addQty},实际${currentQty}`);",
  1753. " } else {",
  1754. " console.log(\"首次执行,记录初始库存\");",
  1755. " }",
  1756. " // 保存本次库存,用于下一轮校验",
  1757. " pm.environment.set(\"last_qty\", currentQty);",
  1758. "});"
  1759. ],
  1760. "type": "text/javascript",
  1761. "packages": {},
  1762. "requests": {}
  1763. }
  1764. }
  1765. ],
  1766. "request": {
  1767. "method": "POST",
  1768. "header": [
  1769. {
  1770. "key": "LoginId",
  1771. "value": "{{t-erp-api-login-id}}",
  1772. "type": "text"
  1773. },
  1774. {
  1775. "key": "sn",
  1776. "value": "{{t-erp-api-sn}}",
  1777. "type": "text"
  1778. },
  1779. {
  1780. "key": "DbType",
  1781. "value": "1",
  1782. "type": "text"
  1783. }
  1784. ],
  1785. "body": {
  1786. "mode": "raw",
  1787. "raw": "{\n \"SQL\": \"SELECT PRD_NO, QTY FROM PRDT1 WHERE PRD_NO=@PRD_NO\",\n \"PARAMETERS\": {\n \"@PRD_NO\": \"{{prd-no}}\"\n }\n}",
  1788. "options": {
  1789. "raw": {
  1790. "language": "json"
  1791. }
  1792. }
  1793. },
  1794. "url": {
  1795. "raw": "{{t-erp-api-url}}/SqlOperation/ExecuteSql",
  1796. "host": [
  1797. "{{t-erp-api-url}}"
  1798. ],
  1799. "path": [
  1800. "SqlOperation",
  1801. "ExecuteSql"
  1802. ]
  1803. }
  1804. },
  1805. "response": []
  1806. },
  1807. {
  1808. "name": "06-查询采购订单回写信息",
  1809. "event": [
  1810. {
  1811. "listen": "test",
  1812. "script": {
  1813. "exec": [
  1814. "pm.test(\"✅ 查询采购订单回写信息成功\", function () {",
  1815. " pm.response.to.have.status(200);",
  1816. " et r = pm.response.json();",
  1817. " pm.expect(r.CallOK).to.equal(\"T\");",
  1818. " console.log(\"✅ 查询采购订单回写信息成功\");",
  1819. "});",
  1820. "",
  1821. "// 用例1:HTTP请求成功",
  1822. "pm.test(\"✅ 接口调用成功\", function () {",
  1823. " pm.expect(pm.response.code).to.equal(200, `异常状态码:${pm.response.code}`);",
  1824. "});",
  1825. "",
  1826. "// 解析返回JSON",
  1827. "const resp = pm.response.json();",
  1828. "",
  1829. "// 用例2:SQL业务执行成功",
  1830. "pm.test(\"✅ SQL查询采购订单成功\", function () {",
  1831. " pm.expect(resp.code).to.equal(0);",
  1832. " pm.expect(resp.result.Success).to.be.true;",
  1833. " pm.expect(resp.message).to.equal(\"SQL查询执行成功。\");",
  1834. "});",
  1835. "",
  1836. "pm.test(\"✅ 获取单据信息写入变量\", () => {",
  1837. " const res = pm.response.json();",
  1838. " const psQty = Number(res.result.Data[0].QTY_PS);",
  1839. " pm.environment.set(\"ps-qty\", psQty);",
  1840. "",
  1841. " console.log(`✅ 已抓取入库数量,ps-qty = ${psQty}`);",
  1842. "});",
  1843. "",
  1844. "pm.test(\"✅ 校验已交量回写正确\", function () {",
  1845. " const res = pm.response.json();",
  1846. " const psQty = Number(res.result.Data[0].QTY_PS);",
  1847. " const pcQty = Number(pm.environment.get(\"pc-qty\"));",
  1848. "",
  1849. " if (psQty !== null && psQty !== undefined) {",
  1850. " ",
  1851. " pm.expect(psQty).equal(Number(pcQty) ,",
  1852. " `库存校验失败:预期${psQty},实际${pcQty}`);",
  1853. " } else {",
  1854. " console.log(\"首次执行,记录初始库存\");",
  1855. " }",
  1856. "",
  1857. "});"
  1858. ],
  1859. "type": "text/javascript",
  1860. "packages": {},
  1861. "requests": {}
  1862. }
  1863. }
  1864. ],
  1865. "request": {
  1866. "method": "POST",
  1867. "header": [
  1868. {
  1869. "key": "LoginId",
  1870. "value": "{{t-erp-api-login-id}}",
  1871. "type": "text"
  1872. },
  1873. {
  1874. "key": "sn",
  1875. "value": "{{t-erp-api-sn}}",
  1876. "type": "text"
  1877. },
  1878. {
  1879. "key": "DbType",
  1880. "value": "1",
  1881. "type": "text"
  1882. }
  1883. ],
  1884. "body": {
  1885. "mode": "raw",
  1886. "raw": "{\r\n \"SQL\":\"SELECT * FROM TF_POS WHERE OS_NO=@PO_NO\",\r\n \"PARAMETERS\":{\r\n \"@PO_NO\":\"{{t-erp-api-po-bill-no}}\"\r\n }\r\n\r\n\r\n}",
  1887. "options": {
  1888. "raw": {
  1889. "language": "json"
  1890. }
  1891. }
  1892. },
  1893. "url": {
  1894. "raw": "{{t-erp-api-url}}/SqlOperation/ExecuteSql",
  1895. "host": [
  1896. "{{t-erp-api-url}}"
  1897. ],
  1898. "path": [
  1899. "SqlOperation",
  1900. "ExecuteSql"
  1901. ]
  1902. }
  1903. },
  1904. "response": []
  1905. },
  1906. {
  1907. "name": "07-新增销售订单",
  1908. "event": [
  1909. {
  1910. "listen": "prerequest",
  1911. "script": {
  1912. "exec": [
  1913. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  1914. "function addZero(num) {",
  1915. " return num < 10 ? '0' + num : num;",
  1916. "}",
  1917. "const now = new Date();",
  1918. "const year = now.getFullYear();",
  1919. "const month = addZero(now.getMonth() + 1);",
  1920. "const day = addZero(now.getDate());",
  1921. "const currentDate = `${year}-${month}-${day}`;",
  1922. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  1923. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  1924. ],
  1925. "type": "text/javascript",
  1926. "packages": {},
  1927. "requests": {}
  1928. }
  1929. },
  1930. {
  1931. "listen": "test",
  1932. "script": {
  1933. "exec": [
  1934. "var resJson = pm.response.json();",
  1935. "var dataRawStr = resJson.Data;",
  1936. "var dataJson;",
  1937. "try {",
  1938. " dataJson = JSON.parse(dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \"));",
  1939. "} catch(e) { return; }",
  1940. "",
  1941. "var bilNo = dataJson.BIL_NO;",
  1942. "console.log(`📌 销售订单:BIL_NO=${bilNo}`);",
  1943. "",
  1944. "pm.test(\"✅ 新增销售订单成功\", function () {",
  1945. " pm.response.to.have.status(200);",
  1946. " pm.expect(resJson.CallOK).to.equal(\"T\");",
  1947. "});",
  1948. "",
  1949. "pm.test(\"✅ TF_TABNAME=TF_POS\", () => {",
  1950. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_POS\");",
  1951. "});",
  1952. "",
  1953. "pm.test(\"✅ 销售订单单号写入环境变量\", function () {",
  1954. " pm.environment.set(\"t-erp-api-so-bill-no\", bilNo);",
  1955. " console.log(`✅ 销售订单单号已写入:${bilNo}`);",
  1956. "",
  1957. " ",
  1958. " var reqBody = JSON.parse(pm.request.body.raw);",
  1959. " var PrdNo = reqBody.BodyData[0].PrdNo;",
  1960. " var Qty = reqBody.BodyData[0].Qty;",
  1961. " pm.environment.set(\"prd-no\", PrdNo);",
  1962. " pm.environment.set(\"so-qty\", Qty);",
  1963. " ",
  1964. "});"
  1965. ],
  1966. "type": "text/javascript",
  1967. "packages": {},
  1968. "requests": {}
  1969. }
  1970. }
  1971. ],
  1972. "request": {
  1973. "method": "POST",
  1974. "header": [
  1975. {
  1976. "key": "LoginId",
  1977. "value": "{{t-erp-api-login-id}}",
  1978. "type": "text"
  1979. },
  1980. {
  1981. "key": "sn",
  1982. "value": "{{t-erp-api-sn}}",
  1983. "type": "text"
  1984. }
  1985. ],
  1986. "body": {
  1987. "mode": "raw",
  1988. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SO\",\n \"CusNo\": \"KH0001\",\n \"DepNo\": \"0001\",\n \"SalNo\": \"LS\",\n \"EstDate\": \"{{t-erp-api-current-date}}\",\n \"Rem\": \"自动化测试-销售订单\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0002\",\n \"WhNo\": \"0001\",\n \"Qty\": 100,\n \"Up\": 100,\n \"Rem\": \"测试用原料销售\"\n }\n ]\n}",
  1989. "options": {
  1990. "raw": {
  1991. "language": "json"
  1992. }
  1993. }
  1994. },
  1995. "url": {
  1996. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  1997. "host": [
  1998. "{{t-erp-api-url}}"
  1999. ],
  2000. "path": [
  2001. "Bill",
  2002. "SaveBill"
  2003. ]
  2004. }
  2005. },
  2006. "response": []
  2007. },
  2008. {
  2009. "name": "08-查询在途量(新增SO后)",
  2010. "event": [
  2011. {
  2012. "listen": "test",
  2013. "script": {
  2014. "exec": [
  2015. "pm.test(\"✅ SQL查询在途量接口连通\", function () {",
  2016. " pm.response.to.have.status(200);",
  2017. " console.log(\"✅ 在途量查询成功\");",
  2018. " console.log(\"📊 查询结果:\", JSON.stringify(pm.response.json()));",
  2019. "});",
  2020. "",
  2021. "// 用例1:HTTP请求成功",
  2022. "pm.test(\"✅ 接口调用成功\", function () {",
  2023. " pm.expect(pm.response.code).to.equal(200, `异常状态码:${pm.response.code}`);",
  2024. "});",
  2025. "",
  2026. "// 解析返回JSON",
  2027. "const resp = pm.response.json();",
  2028. "",
  2029. "// 用例2:SQL业务执行成功",
  2030. "pm.test(\"✅ SQL查询成功\", function () {",
  2031. " pm.expect(resp.code).to.equal(0);",
  2032. " pm.expect(resp.result.Success).to.be.true;",
  2033. " pm.expect(resp.message).to.equal(\"SQL查询执行成功。\");",
  2034. "});",
  2035. "",
  2036. "// 用例3:校验查询到库存数据",
  2037. "pm.test(\"✅ 成功查询到产品库存数据\", function () {",
  2038. " pm.expect(resp.result.Data).to.be.an(\"array\");",
  2039. " pm.expect(resp.result.Data.length).gt(0, \"未查询到该产品\");",
  2040. "});",
  2041. "",
  2042. "// 用例4:每次新增单据,在途库存增加",
  2043. "pm.test(\"✅ 校验在途库存QTY_ON_WAY每次新增\", function () {",
  2044. " const currentQty = Number(resp.result.Data[0].QTY_ON_WAY);",
  2045. " const lastQty = pm.environment.get(\"last_qty_on_way_so\");",
  2046. " console.log(\"上次库存:\", lastQty, \"本次库存:\", currentQty);",
  2047. "",
  2048. " if (lastQty !== null && lastQty !== undefined) {",
  2049. " const addQty = Number(pm.environment.get(\"so-qty\"));",
  2050. " pm.expect(currentQty).equal(Number(lastQty) + addQty,",
  2051. " `库存校验失败:预期${Number(lastQty)+addQty},实际${currentQty}`);",
  2052. " } else {",
  2053. " console.log(\"首次执行,记录初始库存\");",
  2054. " }",
  2055. " // 保存本次库存,用于下一轮校验",
  2056. " pm.environment.set(\"last_qty_on_way_so\", currentQty);",
  2057. "});"
  2058. ],
  2059. "type": "text/javascript",
  2060. "packages": {},
  2061. "requests": {}
  2062. }
  2063. }
  2064. ],
  2065. "request": {
  2066. "method": "POST",
  2067. "header": [
  2068. {
  2069. "key": "LoginId",
  2070. "value": "{{t-erp-api-login-id}}",
  2071. "type": "text"
  2072. },
  2073. {
  2074. "key": "sn",
  2075. "value": "{{t-erp-api-sn}}",
  2076. "type": "text"
  2077. },
  2078. {
  2079. "key": "DbType",
  2080. "value": "1",
  2081. "type": "text"
  2082. }
  2083. ],
  2084. "body": {
  2085. "mode": "raw",
  2086. "raw": "{\n \"SQL\": \"SELECT PRD_NO, SUM(QTY) AS ON_THE_WAY FROM PRDT1 WHERE PRD_NO=@PRD_NO GROUP BY PRD_NO\",\n \"PARAMETERS\": {\n \"@PRD_NO\": \"{{prd-no}}\"\n }\n}",
  2087. "options": {
  2088. "raw": {
  2089. "language": "json"
  2090. }
  2091. }
  2092. },
  2093. "url": {
  2094. "raw": "{{t-erp-api-url}}/SqlOperation/ExecuteSql",
  2095. "host": [
  2096. "{{t-erp-api-url}}"
  2097. ],
  2098. "path": [
  2099. "SqlOperation",
  2100. "ExecuteSql"
  2101. ]
  2102. }
  2103. },
  2104. "response": []
  2105. },
  2106. {
  2107. "name": "09-新增销售出库单(转自SO)",
  2108. "event": [
  2109. {
  2110. "listen": "test",
  2111. "script": {
  2112. "exec": [
  2113. "var resJson = pm.response.json();",
  2114. "var dataRawStr = resJson.Data;",
  2115. "var dataJson;",
  2116. "try {",
  2117. " dataJson = JSON.parse(dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \"));",
  2118. "} catch(e) { return; }",
  2119. "",
  2120. "var bilNo = dataJson.BIL_NO;",
  2121. "console.log(`📌 销售出库单:BIL_NO=${bilNo}`);",
  2122. "",
  2123. "pm.test(\"✅ 新增销售出库单成功\", function () {",
  2124. " pm.response.to.have.status(200);",
  2125. " pm.expect(resJson.CallOK).to.equal(\"T\");",
  2126. "});",
  2127. "",
  2128. "pm.test(\"✅ TF_TABNAME=TF_PSS\", () => {",
  2129. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  2130. "});",
  2131. "",
  2132. "",
  2133. "pm.test(\"✅ 销售出库单号写入环境变量\", function () {",
  2134. " pm.environment.set(\"t-erp-api-sa-bill-no\", bilNo);",
  2135. " console.log(`✅ 销售出库单号已写入:${bilNo}`);",
  2136. "",
  2137. " ",
  2138. " var reqBody = JSON.parse(pm.request.body.raw);",
  2139. " var PrdNo = reqBody.BodyData[0].PrdNo;",
  2140. " var Qty = reqBody.BodyData[0].Qty;",
  2141. " pm.environment.set(\"prd-no\", PrdNo);",
  2142. " pm.environment.set(\"sa-qty\", Qty);",
  2143. " ",
  2144. "});"
  2145. ],
  2146. "type": "text/javascript",
  2147. "packages": {},
  2148. "requests": {}
  2149. }
  2150. },
  2151. {
  2152. "listen": "prerequest",
  2153. "script": {
  2154. "exec": [
  2155. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  2156. "function addZero(num) {",
  2157. " return num < 10 ? '0' + num : num;",
  2158. "}",
  2159. "const now = new Date();",
  2160. "const year = now.getFullYear();",
  2161. "const month = addZero(now.getMonth() + 1);",
  2162. "const day = addZero(now.getDate());",
  2163. "const currentDate = `${year}-${month}-${day}`;",
  2164. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  2165. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  2166. ],
  2167. "type": "text/javascript",
  2168. "packages": {},
  2169. "requests": {}
  2170. }
  2171. }
  2172. ],
  2173. "request": {
  2174. "method": "POST",
  2175. "header": [
  2176. {
  2177. "key": "LoginId",
  2178. "value": "{{t-erp-api-login-id}}",
  2179. "type": "text"
  2180. },
  2181. {
  2182. "key": "sn",
  2183. "value": "{{t-erp-api-sn}}",
  2184. "type": "text"
  2185. }
  2186. ],
  2187. "body": {
  2188. "mode": "raw",
  2189. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SA\",\n \"SalNo\": \"LS\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"BilId\": \"SO\",\n \"BilNo\": \"{{t-erp-api-so-bill-no}}\",\n \"BilItm\": 1\n }\n ]\n}",
  2190. "options": {
  2191. "raw": {
  2192. "language": "json"
  2193. }
  2194. }
  2195. },
  2196. "url": {
  2197. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  2198. "host": [
  2199. "{{t-erp-api-url}}"
  2200. ],
  2201. "path": [
  2202. "Bill",
  2203. "SaveBill"
  2204. ]
  2205. }
  2206. },
  2207. "response": []
  2208. },
  2209. {
  2210. "name": "10-查询销售出库单信息",
  2211. "event": [
  2212. {
  2213. "listen": "test",
  2214. "script": {
  2215. "exec": [
  2216. "",
  2217. "pm.test(\"✅ 查询销售出库单成功\", function () {",
  2218. " pm.response.to.have.status(200);",
  2219. " let r = pm.response.json();",
  2220. " pm.expect(r.CallOK).to.equal(\"T\");",
  2221. " console.log(\"✅ 查询单据成功\");",
  2222. "});",
  2223. "",
  2224. "pm.test(\"✅ 获取单据信息写入变量\", () => {",
  2225. " const res = pm.response.json();",
  2226. " const saQty = Number(res.Data.BODYDATA1[0].QTY);",
  2227. " pm.environment.set(\"sa-qty\", saQty);",
  2228. "",
  2229. " console.log(`✅ 已抓取入库数量,sa-qty = ${saQty}`);",
  2230. "});",
  2231. "",
  2232. "pm.test(\"✅ 校验本次入库数量与受订下单数量一致\", () => {",
  2233. " const res = pm.response.json();",
  2234. " const saQty = Number(res.Data.BODYDATA1[0].QTY);",
  2235. " const soQty = Number(pm.environment.get(\"so-qty\"));",
  2236. " pm.expect(saQty).to.equal(",
  2237. " soQty,",
  2238. " `数量不一致校验失败:受订下单数量SO-QTY=${soQty},本次出库数量SA-QTY=${saQty}`",
  2239. " );",
  2240. "});"
  2241. ],
  2242. "type": "text/javascript",
  2243. "packages": {},
  2244. "requests": {}
  2245. }
  2246. }
  2247. ],
  2248. "request": {
  2249. "method": "POST",
  2250. "header": [
  2251. {
  2252. "key": "LoginId",
  2253. "value": "{{t-erp-api-login-id}}",
  2254. "type": "text"
  2255. },
  2256. {
  2257. "key": "sn",
  2258. "value": "{{t-erp-api-sn}}",
  2259. "type": "text"
  2260. }
  2261. ],
  2262. "body": {
  2263. "mode": "raw",
  2264. "raw": "{\r\n \"CallId\": \"SO\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-so-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}\r\n\r\n",
  2265. "options": {
  2266. "raw": {
  2267. "language": "json"
  2268. }
  2269. }
  2270. },
  2271. "url": {
  2272. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  2273. "host": [
  2274. "{{t-erp-api-url}}"
  2275. ],
  2276. "path": [
  2277. "Bill",
  2278. "QueryBillDetail"
  2279. ]
  2280. }
  2281. },
  2282. "response": []
  2283. },
  2284. {
  2285. "name": "11-货品库存查询(报表)",
  2286. "request": {
  2287. "method": "GET",
  2288. "header": [
  2289. {
  2290. "key": "LoginId",
  2291. "value": "{{t-erp-api-login-id}}",
  2292. "type": "text"
  2293. },
  2294. {
  2295. "key": "PRD_NO",
  2296. "value": "YL0001",
  2297. "type": "text"
  2298. },
  2299. {
  2300. "key": "WH",
  2301. "value": "",
  2302. "type": "text"
  2303. },
  2304. {
  2305. "key": "ISGROUPBYWH",
  2306. "value": "T",
  2307. "type": "text"
  2308. }
  2309. ],
  2310. "url": {
  2311. "raw": "{{t-erp-api-url}}/TbrECC/GetPrdStockData",
  2312. "host": [
  2313. "{{t-erp-api-url}}"
  2314. ],
  2315. "path": [
  2316. "TbrECC",
  2317. "GetPrdStockData"
  2318. ]
  2319. }
  2320. },
  2321. "response": []
  2322. }
  2323. ],
  2324. "description": "采购订单→采购入库→库存验证→销售订单→销售出库 完整业务流程测试"
  2325. },
  2326. {
  2327. "name": "📦 单据测试用例(35种)",
  2328. "item": [
  2329. {
  2330. "name": "📂 采购类",
  2331. "item": [
  2332. {
  2333. "name": "PO - 采购订单",
  2334. "item": [
  2335. {
  2336. "name": "新增PO单",
  2337. "event": [
  2338. {
  2339. "listen": "prerequest",
  2340. "script": {
  2341. "exec": [
  2342. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  2343. "function addZero(num) {",
  2344. " return num < 10 ? '0' + num : num;",
  2345. "}",
  2346. "const now = new Date();",
  2347. "const year = now.getFullYear();",
  2348. "const month = addZero(now.getMonth() + 1);",
  2349. "const day = addZero(now.getDate());",
  2350. "const currentDate = `${year}-${month}-${day}`;",
  2351. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  2352. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  2353. ],
  2354. "type": "text/javascript",
  2355. "packages": {},
  2356. "requests": {}
  2357. }
  2358. },
  2359. {
  2360. "listen": "test",
  2361. "script": {
  2362. "exec": [
  2363. "// 1. 解析接口顶层的JSON响应",
  2364. "var resJson = pm.response.json();",
  2365. "console.log(\"✅ 接口顶层JSON解析成功\");",
  2366. "",
  2367. "// 2. 提取Data字段",
  2368. "var dataRawStr = resJson.Data;",
  2369. "if (!dataRawStr) {",
  2370. " console.error(\"❌ Data字段为空/不存在\");",
  2371. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  2372. " return;",
  2373. "}",
  2374. "",
  2375. "// 3. 解析Data",
  2376. "var dataJson;",
  2377. "try {",
  2378. " dataJson = JSON.parse(dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \"));",
  2379. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  2380. "} catch (e) {",
  2381. " console.error(\"❌ Data解析失败:\", e.message);",
  2382. " pm.test(\"Data字段可正常解析\", () => pm.expect.fail(\"Data格式错误\"));",
  2383. " return;",
  2384. "}",
  2385. "",
  2386. "var bilNo = dataJson.BIL_NO;",
  2387. "var bilId = dataJson.BIL_ID;",
  2388. "console.log(`📌 采购订单:BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  2389. "",
  2390. "pm.test(\"✅ 新增采购订单成功\", function () {",
  2391. " pm.response.to.have.status(200);",
  2392. " pm.expect(resJson.CallOK).to.equal(\"T\");",
  2393. "});",
  2394. "",
  2395. "pm.test(\"✅ TF_TABNAME=TF_POS\", () => {",
  2396. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_POS\");",
  2397. "});",
  2398. "",
  2399. "pm.test(\"✅ 采购订单单号写入环境变量\", function () {",
  2400. " pm.environment.set(\"t-erp-api-po-bill-no\", bilNo);",
  2401. " console.log(`✅ 采购订单单号已写入:${bilNo}`);",
  2402. "});"
  2403. ],
  2404. "type": "text/javascript",
  2405. "packages": {},
  2406. "requests": {}
  2407. }
  2408. }
  2409. ],
  2410. "request": {
  2411. "method": "POST",
  2412. "header": [
  2413. {
  2414. "key": "LoginId",
  2415. "value": "{{t-erp-api-login-id}}",
  2416. "type": "text"
  2417. },
  2418. {
  2419. "key": "sn",
  2420. "value": "{{t-erp-api-sn}}",
  2421. "type": "text"
  2422. }
  2423. ],
  2424. "body": {
  2425. "mode": "raw",
  2426. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PO\",\n \"CusNo\": \"CS0001\",\n \"DepNo\": \"0001\",\n \"SalNo\": \"LS\",\n \"EstDate\": \"{{t-erp-api-current-date}}\",\n \"Rem\": \"自动化测试-采购订单\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 100,\n \"Up\": 100,\n \"Rem\": \"测试用原料\"\n }\n ]\n}",
  2427. "options": {
  2428. "raw": {
  2429. "language": "json"
  2430. }
  2431. }
  2432. },
  2433. "url": {
  2434. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  2435. "host": [
  2436. "{{t-erp-api-url}}"
  2437. ],
  2438. "path": [
  2439. "Bill",
  2440. "SaveBill"
  2441. ]
  2442. }
  2443. },
  2444. "response": []
  2445. },
  2446. {
  2447. "name": "查询PO单",
  2448. "event": [
  2449. {
  2450. "listen": "test",
  2451. "script": {
  2452. "exec": [
  2453. "pm.test(\"✅ 查询成功校验\", function () {",
  2454. " pm.response.to.have.status(200);",
  2455. " let r = pm.response.json();",
  2456. " pm.expect(r.CallOK).to.equal(\"T\");",
  2457. " console.log(\"✅ 查询单据成功\");",
  2458. "});"
  2459. ],
  2460. "type": "text/javascript",
  2461. "packages": {},
  2462. "requests": {}
  2463. }
  2464. }
  2465. ],
  2466. "request": {
  2467. "method": "POST",
  2468. "header": [
  2469. {
  2470. "key": "LoginId",
  2471. "value": "{{t-erp-api-login-id}}",
  2472. "type": "text"
  2473. },
  2474. {
  2475. "key": "sn",
  2476. "value": "{{t-erp-api-sn}}",
  2477. "type": "text"
  2478. },
  2479. {
  2480. "key": "Content-Type",
  2481. "value": "application/json",
  2482. "type": "text"
  2483. }
  2484. ],
  2485. "body": {
  2486. "mode": "raw",
  2487. "raw": "{\r\n \"CallId\": \"PO\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-po-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  2488. "options": {
  2489. "raw": {
  2490. "language": "json"
  2491. }
  2492. }
  2493. },
  2494. "url": {
  2495. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  2496. "host": [
  2497. "{{t-erp-api-url}}"
  2498. ],
  2499. "path": [
  2500. "Bill",
  2501. "QueryBillDetail"
  2502. ]
  2503. },
  2504. "description": "查询PO单详情"
  2505. },
  2506. "response": []
  2507. }
  2508. ],
  2509. "description": "单据类型:PO(采购订单),分类:采购类"
  2510. },
  2511. {
  2512. "name": "PC - 采购入库单",
  2513. "item": [
  2514. {
  2515. "name": "新增PC单(无来源)",
  2516. "event": [
  2517. {
  2518. "listen": "prerequest",
  2519. "script": {
  2520. "exec": [
  2521. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  2522. "function addZero(num) {",
  2523. " return num < 10 ? '0' + num : num;",
  2524. "}",
  2525. "const now = new Date();",
  2526. "const year = now.getFullYear();",
  2527. "const month = addZero(now.getMonth() + 1);",
  2528. "const day = addZero(now.getDate());",
  2529. "const currentDate = `${year}-${month}-${day}`;",
  2530. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  2531. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  2532. ],
  2533. "type": "text/javascript",
  2534. "packages": {},
  2535. "requests": {}
  2536. }
  2537. },
  2538. {
  2539. "listen": "test",
  2540. "script": {
  2541. "exec": [
  2542. "// 1. 解析接口顶层的JSON响应",
  2543. "var resJson = pm.response.json();",
  2544. "console.log(\"✅ 接口顶层JSON解析成功\");",
  2545. "",
  2546. "// 2. 提取Data字段,做非空判断",
  2547. "var dataRawStr = resJson.Data;",
  2548. "if (!dataRawStr) {",
  2549. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  2550. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  2551. " return;",
  2552. "}",
  2553. "",
  2554. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  2555. "var dataJson;",
  2556. "try {",
  2557. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  2558. " dataJson = JSON.parse(dataCleanStr);",
  2559. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  2560. "} catch (e) {",
  2561. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  2562. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  2563. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  2564. " return;",
  2565. "}",
  2566. "",
  2567. "// 4. 提取关键字段",
  2568. "var tfTabNameVal = dataJson.TF_TABNAME;",
  2569. "var bilNo = dataJson.BIL_NO;",
  2570. "var bilId = dataJson.BIL_ID;",
  2571. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  2572. "",
  2573. "pm.test(\"✅ 新增成功校验\", function () {",
  2574. " pm.response.to.have.status(200);",
  2575. " let r = pm.response.json();",
  2576. " pm.expect(r.CallOK).to.equal(\"T\");",
  2577. "});",
  2578. "",
  2579. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  2580. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  2581. "});",
  2582. "",
  2583. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  2584. " pm.environment.set(\"t-erp-api-pc-bill-no\", bilNo);",
  2585. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  2586. "});"
  2587. ],
  2588. "type": "text/javascript",
  2589. "packages": {},
  2590. "requests": {}
  2591. }
  2592. }
  2593. ],
  2594. "request": {
  2595. "method": "POST",
  2596. "header": [
  2597. {
  2598. "key": "LoginId",
  2599. "value": "{{t-erp-api-login-id}}",
  2600. "type": "text"
  2601. },
  2602. {
  2603. "key": "sn",
  2604. "value": "{{t-erp-api-sn}}",
  2605. "type": "text"
  2606. }
  2607. ],
  2608. "body": {
  2609. "mode": "raw",
  2610. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PC\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"CS0001\",\n \"DepNo\": \"0001\",\n \"SalNo\": \"LS\",\n \"Rem\": \"采购入库订单测试\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10000,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  2611. "options": {
  2612. "raw": {
  2613. "language": "json"
  2614. }
  2615. }
  2616. },
  2617. "url": {
  2618. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  2619. "host": [
  2620. "{{t-erp-api-url}}"
  2621. ],
  2622. "path": [
  2623. "Bill",
  2624. "SaveBill"
  2625. ]
  2626. },
  2627. "description": "新增PC单(无来源)"
  2628. },
  2629. "response": []
  2630. },
  2631. {
  2632. "name": "新增PC单(转入PO来源)",
  2633. "event": [
  2634. {
  2635. "listen": "prerequest",
  2636. "script": {
  2637. "exec": [
  2638. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  2639. "function addZero(num) {",
  2640. " return num < 10 ? '0' + num : num;",
  2641. "}",
  2642. "const now = new Date();",
  2643. "const year = now.getFullYear();",
  2644. "const month = addZero(now.getMonth() + 1);",
  2645. "const day = addZero(now.getDate());",
  2646. "const currentDate = `${year}-${month}-${day}`;",
  2647. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  2648. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  2649. ],
  2650. "type": "text/javascript",
  2651. "packages": {},
  2652. "requests": {}
  2653. }
  2654. },
  2655. {
  2656. "listen": "test",
  2657. "script": {
  2658. "exec": [
  2659. "// 1. 解析接口顶层的JSON响应",
  2660. "var resJson = pm.response.json();",
  2661. "console.log(\"✅ 接口顶层JSON解析成功\");",
  2662. "",
  2663. "// 2. 提取Data字段,做非空判断",
  2664. "var dataRawStr = resJson.Data;",
  2665. "if (!dataRawStr) {",
  2666. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  2667. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  2668. " return;",
  2669. "}",
  2670. "",
  2671. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  2672. "var dataJson;",
  2673. "try {",
  2674. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  2675. " dataJson = JSON.parse(dataCleanStr);",
  2676. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  2677. "} catch (e) {",
  2678. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  2679. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  2680. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  2681. " return;",
  2682. "}",
  2683. "",
  2684. "// 4. 提取关键字段",
  2685. "var tfTabNameVal = dataJson.TF_TABNAME;",
  2686. "var bilNo = dataJson.BIL_NO;",
  2687. "var bilId = dataJson.BIL_ID;",
  2688. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  2689. "",
  2690. "pm.test(\"✅ 新增成功校验\", function () {",
  2691. " pm.response.to.have.status(200);",
  2692. " let r = pm.response.json();",
  2693. " pm.expect(r.CallOK).to.equal(\"T\");",
  2694. "});",
  2695. "",
  2696. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  2697. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  2698. "});",
  2699. "",
  2700. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  2701. " pm.environment.set(\"t-erp-api-pc-bill-no\", bilNo);",
  2702. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  2703. "});"
  2704. ],
  2705. "type": "text/javascript",
  2706. "packages": {},
  2707. "requests": {}
  2708. }
  2709. }
  2710. ],
  2711. "request": {
  2712. "method": "POST",
  2713. "header": [
  2714. {
  2715. "key": "LoginId",
  2716. "value": "{{t-erp-api-login-id}}",
  2717. "type": "text"
  2718. },
  2719. {
  2720. "key": "sn",
  2721. "value": "{{t-erp-api-sn}}",
  2722. "type": "text"
  2723. }
  2724. ],
  2725. "body": {
  2726. "mode": "raw",
  2727. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PC\"\n },\n \"BodyData\": [\n {\n \"BilId\": \"PO\",\n \"BilNo\": \"{{t-erp-api-po-bill-no}}\",\n \"BilItm\": 1\n }\n ]\n}",
  2728. "options": {
  2729. "raw": {
  2730. "language": "json"
  2731. }
  2732. }
  2733. },
  2734. "url": {
  2735. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  2736. "host": [
  2737. "{{t-erp-api-url}}"
  2738. ],
  2739. "path": [
  2740. "Bill",
  2741. "SaveBill"
  2742. ]
  2743. },
  2744. "description": "新增PC单(从PO单转入)"
  2745. },
  2746. "response": []
  2747. },
  2748. {
  2749. "name": "查询PC单",
  2750. "event": [
  2751. {
  2752. "listen": "test",
  2753. "script": {
  2754. "exec": [
  2755. "pm.test(\"✅ 查询成功校验\", function () {",
  2756. " pm.response.to.have.status(200);",
  2757. " let r = pm.response.json();",
  2758. " pm.expect(r.CallOK).to.equal(\"T\");",
  2759. " console.log(\"✅ 查询单据成功\");",
  2760. "});"
  2761. ],
  2762. "type": "text/javascript",
  2763. "packages": {},
  2764. "requests": {}
  2765. }
  2766. }
  2767. ],
  2768. "request": {
  2769. "method": "POST",
  2770. "header": [
  2771. {
  2772. "key": "LoginId",
  2773. "value": "{{t-erp-api-login-id}}",
  2774. "type": "text"
  2775. },
  2776. {
  2777. "key": "sn",
  2778. "value": "{{t-erp-api-sn}}",
  2779. "type": "text"
  2780. }
  2781. ],
  2782. "body": {
  2783. "mode": "raw",
  2784. "raw": "{\r\n \"CallId\": \"PC\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-pc-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  2785. "options": {
  2786. "raw": {
  2787. "language": "json"
  2788. }
  2789. }
  2790. },
  2791. "url": {
  2792. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  2793. "host": [
  2794. "{{t-erp-api-url}}"
  2795. ],
  2796. "path": [
  2797. "Bill",
  2798. "QueryBillDetail"
  2799. ]
  2800. },
  2801. "description": "查询PC单详情"
  2802. },
  2803. "response": []
  2804. }
  2805. ],
  2806. "description": "单据类型:PC(采购入库单),分类:采购类"
  2807. },
  2808. {
  2809. "name": "PB - 采购退货单",
  2810. "item": [
  2811. {
  2812. "name": "新增PB单(无来源)",
  2813. "event": [
  2814. {
  2815. "listen": "prerequest",
  2816. "script": {
  2817. "exec": [
  2818. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  2819. "function addZero(num) {",
  2820. " return num < 10 ? '0' + num : num;",
  2821. "}",
  2822. "const now = new Date();",
  2823. "const year = now.getFullYear();",
  2824. "const month = addZero(now.getMonth() + 1);",
  2825. "const day = addZero(now.getDate());",
  2826. "const currentDate = `${year}-${month}-${day}`;",
  2827. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  2828. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  2829. ],
  2830. "type": "text/javascript",
  2831. "packages": {},
  2832. "requests": {}
  2833. }
  2834. },
  2835. {
  2836. "listen": "test",
  2837. "script": {
  2838. "exec": [
  2839. "// 1. 解析接口顶层的JSON响应",
  2840. "var resJson = pm.response.json();",
  2841. "console.log(\"✅ 接口顶层JSON解析成功\");",
  2842. "",
  2843. "// 2. 提取Data字段,做非空判断",
  2844. "var dataRawStr = resJson.Data;",
  2845. "if (!dataRawStr) {",
  2846. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  2847. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  2848. " return;",
  2849. "}",
  2850. "",
  2851. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  2852. "var dataJson;",
  2853. "try {",
  2854. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  2855. " dataJson = JSON.parse(dataCleanStr);",
  2856. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  2857. "} catch (e) {",
  2858. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  2859. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  2860. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  2861. " return;",
  2862. "}",
  2863. "",
  2864. "// 4. 提取关键字段",
  2865. "var tfTabNameVal = dataJson.TF_TABNAME;",
  2866. "var bilNo = dataJson.BIL_NO;",
  2867. "var bilId = dataJson.BIL_ID;",
  2868. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  2869. "",
  2870. "pm.test(\"❌️ 需有来源单\", function () {",
  2871. " pm.response.to.have.status(200);",
  2872. " let r = pm.response.json();",
  2873. " pm.expect(r.CallOK).to.equal(\"F\");",
  2874. " ",
  2875. " // 将整个响应转为字符串检查",
  2876. " let responseText = JSON.stringify(r);",
  2877. " pm.expect(responseText).to.include(\"请输入来源单号\");",
  2878. "});"
  2879. ],
  2880. "type": "text/javascript",
  2881. "packages": {},
  2882. "requests": {}
  2883. }
  2884. }
  2885. ],
  2886. "request": {
  2887. "method": "POST",
  2888. "header": [
  2889. {
  2890. "key": "LoginId",
  2891. "value": "{{t-erp-api-login-id}}",
  2892. "type": "text"
  2893. },
  2894. {
  2895. "key": "sn",
  2896. "value": "{{t-erp-api-sn}}",
  2897. "type": "text"
  2898. }
  2899. ],
  2900. "body": {
  2901. "mode": "raw",
  2902. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PB\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"CS0001\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  2903. "options": {
  2904. "raw": {
  2905. "language": "json"
  2906. }
  2907. }
  2908. },
  2909. "url": {
  2910. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  2911. "host": [
  2912. "{{t-erp-api-url}}"
  2913. ],
  2914. "path": [
  2915. "Bill",
  2916. "SaveBill"
  2917. ]
  2918. },
  2919. "description": "新增PB单(无来源)"
  2920. },
  2921. "response": []
  2922. },
  2923. {
  2924. "name": "新增PB单(转入PC来源)",
  2925. "event": [
  2926. {
  2927. "listen": "prerequest",
  2928. "script": {
  2929. "exec": [
  2930. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  2931. "function addZero(num) {",
  2932. " return num < 10 ? '0' + num : num;",
  2933. "}",
  2934. "const now = new Date();",
  2935. "const year = now.getFullYear();",
  2936. "const month = addZero(now.getMonth() + 1);",
  2937. "const day = addZero(now.getDate());",
  2938. "const currentDate = `${year}-${month}-${day}`;",
  2939. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  2940. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  2941. ],
  2942. "type": "text/javascript",
  2943. "packages": {},
  2944. "requests": {}
  2945. }
  2946. },
  2947. {
  2948. "listen": "test",
  2949. "script": {
  2950. "exec": [
  2951. "// 1. 解析接口顶层的JSON响应",
  2952. "var resJson = pm.response.json();",
  2953. "console.log(\"✅ 接口顶层JSON解析成功\");",
  2954. "",
  2955. "// 2. 提取Data字段,做非空判断",
  2956. "var dataRawStr = resJson.Data;",
  2957. "if (!dataRawStr) {",
  2958. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  2959. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  2960. " return;",
  2961. "}",
  2962. "",
  2963. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  2964. "var dataJson;",
  2965. "try {",
  2966. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  2967. " dataJson = JSON.parse(dataCleanStr);",
  2968. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  2969. "} catch (e) {",
  2970. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  2971. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  2972. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  2973. " return;",
  2974. "}",
  2975. "",
  2976. "// 4. 提取关键字段",
  2977. "var tfTabNameVal = dataJson.TF_TABNAME;",
  2978. "var bilNo = dataJson.BIL_NO;",
  2979. "var bilId = dataJson.BIL_ID;",
  2980. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  2981. "",
  2982. "pm.test(\"✅ 新增成功校验\", function () {",
  2983. " pm.response.to.have.status(200);",
  2984. " let r = pm.response.json();",
  2985. " pm.expect(r.CallOK).to.equal(\"T\");",
  2986. "});",
  2987. "",
  2988. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  2989. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  2990. "});",
  2991. "",
  2992. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  2993. " pm.environment.set(\"t-erp-api-pb-bill-no\", bilNo);",
  2994. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  2995. "});"
  2996. ],
  2997. "type": "text/javascript",
  2998. "packages": {},
  2999. "requests": {}
  3000. }
  3001. }
  3002. ],
  3003. "request": {
  3004. "method": "POST",
  3005. "header": [
  3006. {
  3007. "key": "LoginId",
  3008. "value": "{{t-erp-api-login-id}}",
  3009. "type": "text"
  3010. },
  3011. {
  3012. "key": "sn",
  3013. "value": "{{t-erp-api-sn}}",
  3014. "type": "text"
  3015. }
  3016. ],
  3017. "body": {
  3018. "mode": "raw",
  3019. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PB\"\n },\n \"BodyData\": [\n {\n \"BilId\": \"PC\",\n \"BilNo\": \"{{t-erp-api-pc-bill-no}}\",\n \"BilItm\": 1\n }\n ]\n}",
  3020. "options": {
  3021. "raw": {
  3022. "language": "json"
  3023. }
  3024. }
  3025. },
  3026. "url": {
  3027. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  3028. "host": [
  3029. "{{t-erp-api-url}}"
  3030. ],
  3031. "path": [
  3032. "Bill",
  3033. "SaveBill"
  3034. ]
  3035. },
  3036. "description": "新增PB单(从PC单转入)"
  3037. },
  3038. "response": []
  3039. },
  3040. {
  3041. "name": "查询PB单",
  3042. "event": [
  3043. {
  3044. "listen": "test",
  3045. "script": {
  3046. "exec": [
  3047. "pm.test(\"✅ 查询成功校验\", function () {",
  3048. " pm.response.to.have.status(200);",
  3049. " let r = pm.response.json();",
  3050. " pm.expect(r.CallOK).to.equal(\"T\");",
  3051. " console.log(\"✅ 查询单据成功\");",
  3052. "});"
  3053. ],
  3054. "type": "text/javascript",
  3055. "packages": {},
  3056. "requests": {}
  3057. }
  3058. }
  3059. ],
  3060. "request": {
  3061. "method": "POST",
  3062. "header": [
  3063. {
  3064. "key": "LoginId",
  3065. "value": "{{t-erp-api-login-id}}",
  3066. "type": "text"
  3067. },
  3068. {
  3069. "key": "sn",
  3070. "value": "{{t-erp-api-sn}}",
  3071. "type": "text"
  3072. }
  3073. ],
  3074. "body": {
  3075. "mode": "raw",
  3076. "raw": "{\r\n \"CallId\": \"PB\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-pb-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  3077. "options": {
  3078. "raw": {
  3079. "language": "json"
  3080. }
  3081. }
  3082. },
  3083. "url": {
  3084. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  3085. "host": [
  3086. "{{t-erp-api-url}}"
  3087. ],
  3088. "path": [
  3089. "Bill",
  3090. "QueryBillDetail"
  3091. ]
  3092. },
  3093. "description": "查询PB单详情"
  3094. },
  3095. "response": []
  3096. }
  3097. ],
  3098. "description": "单据类型:PB(采购退货单),分类:采购类"
  3099. },
  3100. {
  3101. "name": "T6 - 采购暂估入库",
  3102. "item": [
  3103. {
  3104. "name": "新增T6单(无来源)",
  3105. "event": [
  3106. {
  3107. "listen": "prerequest",
  3108. "script": {
  3109. "exec": [
  3110. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  3111. "function addZero(num) {",
  3112. " return num < 10 ? '0' + num : num;",
  3113. "}",
  3114. "const now = new Date();",
  3115. "const year = now.getFullYear();",
  3116. "const month = addZero(now.getMonth() + 1);",
  3117. "const day = addZero(now.getDate());",
  3118. "const currentDate = `${year}-${month}-${day}`;",
  3119. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  3120. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  3121. ],
  3122. "type": "text/javascript",
  3123. "packages": {},
  3124. "requests": {}
  3125. }
  3126. },
  3127. {
  3128. "listen": "test",
  3129. "script": {
  3130. "exec": [
  3131. "// 1. 解析接口顶层的JSON响应",
  3132. "var resJson = pm.response.json();",
  3133. "console.log(\"✅ 接口顶层JSON解析成功\");",
  3134. "",
  3135. "// 2. 提取Data字段,做非空判断",
  3136. "var dataRawStr = resJson.Data;",
  3137. "if (!dataRawStr) {",
  3138. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  3139. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  3140. " return;",
  3141. "}",
  3142. "",
  3143. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  3144. "var dataJson;",
  3145. "try {",
  3146. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  3147. " dataJson = JSON.parse(dataCleanStr);",
  3148. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  3149. "} catch (e) {",
  3150. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  3151. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  3152. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  3153. " return;",
  3154. "}",
  3155. "",
  3156. "// 4. 提取关键字段",
  3157. "var tfTabNameVal = dataJson.TF_TABNAME;",
  3158. "var bilNo = dataJson.BIL_NO;",
  3159. "var bilId = dataJson.BIL_ID;",
  3160. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  3161. "",
  3162. "pm.test(\"✅ 新增成功校验\", function () {",
  3163. " pm.response.to.have.status(200);",
  3164. " let r = pm.response.json();",
  3165. " pm.expect(r.CallOK).to.equal(\"T\");",
  3166. "});",
  3167. "",
  3168. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  3169. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_TI\");",
  3170. "});",
  3171. "",
  3172. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  3173. " pm.environment.set(\"t-erp-api-t6-bill-no\", bilNo);",
  3174. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  3175. "});"
  3176. ],
  3177. "type": "text/javascript",
  3178. "packages": {},
  3179. "requests": {}
  3180. }
  3181. }
  3182. ],
  3183. "request": {
  3184. "method": "POST",
  3185. "header": [
  3186. {
  3187. "key": "LoginId",
  3188. "value": "{{t-erp-api-login-id}}",
  3189. "type": "text"
  3190. },
  3191. {
  3192. "key": "sn",
  3193. "value": "{{t-erp-api-sn}}",
  3194. "type": "text"
  3195. }
  3196. ],
  3197. "body": {
  3198. "mode": "raw",
  3199. "raw": "{\n \"HeadData\": {\n \"CallId\": \"T6\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"CS0001\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  3200. "options": {
  3201. "raw": {
  3202. "language": "json"
  3203. }
  3204. }
  3205. },
  3206. "url": {
  3207. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  3208. "host": [
  3209. "{{t-erp-api-url}}"
  3210. ],
  3211. "path": [
  3212. "Bill",
  3213. "SaveBill"
  3214. ]
  3215. },
  3216. "description": "新增T6单(无来源)"
  3217. },
  3218. "response": []
  3219. },
  3220. {
  3221. "name": "查询T6单",
  3222. "event": [
  3223. {
  3224. "listen": "test",
  3225. "script": {
  3226. "exec": [
  3227. "pm.test(\"✅ 查询成功校验\", function () {",
  3228. " pm.response.to.have.status(200);",
  3229. " let r = pm.response.json();",
  3230. " pm.expect(r.CallOK).to.equal(\"T\");",
  3231. " console.log(\"✅ 查询单据成功\");",
  3232. "});"
  3233. ],
  3234. "type": "text/javascript",
  3235. "packages": {},
  3236. "requests": {}
  3237. }
  3238. }
  3239. ],
  3240. "request": {
  3241. "method": "POST",
  3242. "header": [
  3243. {
  3244. "key": "LoginId",
  3245. "value": "{{t-erp-api-login-id}}",
  3246. "type": "text"
  3247. },
  3248. {
  3249. "key": "sn",
  3250. "value": "{{t-erp-api-sn}}",
  3251. "type": "text"
  3252. }
  3253. ],
  3254. "body": {
  3255. "mode": "raw",
  3256. "raw": "{\r\n \"CallId\": \"T6\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-t6-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  3257. "options": {
  3258. "raw": {
  3259. "language": "json"
  3260. }
  3261. }
  3262. },
  3263. "url": {
  3264. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  3265. "host": [
  3266. "{{t-erp-api-url}}"
  3267. ],
  3268. "path": [
  3269. "Bill",
  3270. "QueryBillDetail"
  3271. ]
  3272. },
  3273. "description": "查询T6单详情"
  3274. },
  3275. "response": []
  3276. }
  3277. ],
  3278. "description": "单据类型:T6(采购暂估入库),分类:采购类"
  3279. }
  3280. ],
  3281. "description": "采购类相关单据测试用例"
  3282. },
  3283. {
  3284. "name": "📂 销售类",
  3285. "item": [
  3286. {
  3287. "name": "SO - 销售订单",
  3288. "item": [
  3289. {
  3290. "name": "新增SO单(无来源)",
  3291. "event": [
  3292. {
  3293. "listen": "prerequest",
  3294. "script": {
  3295. "exec": [
  3296. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  3297. "function addZero(num) {",
  3298. " return num < 10 ? '0' + num : num;",
  3299. "}",
  3300. "const now = new Date();",
  3301. "const year = now.getFullYear();",
  3302. "const month = addZero(now.getMonth() + 1);",
  3303. "const day = addZero(now.getDate());",
  3304. "const currentDate = `${year}-${month}-${day}`;",
  3305. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  3306. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  3307. ],
  3308. "type": "text/javascript",
  3309. "packages": {},
  3310. "requests": {}
  3311. }
  3312. },
  3313. {
  3314. "listen": "test",
  3315. "script": {
  3316. "exec": [
  3317. "// 1. 解析接口顶层的JSON响应",
  3318. "var resJson = pm.response.json();",
  3319. "console.log(\"✅ 接口顶层JSON解析成功\");",
  3320. "",
  3321. "// 2. 提取Data字段,做非空判断",
  3322. "var dataRawStr = resJson.Data;",
  3323. "if (!dataRawStr) {",
  3324. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  3325. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  3326. " return;",
  3327. "}",
  3328. "",
  3329. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  3330. "var dataJson;",
  3331. "try {",
  3332. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  3333. " dataJson = JSON.parse(dataCleanStr);",
  3334. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  3335. "} catch (e) {",
  3336. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  3337. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  3338. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  3339. " return;",
  3340. "}",
  3341. "",
  3342. "// 4. 提取关键字段",
  3343. "var tfTabNameVal = dataJson.TF_TABNAME;",
  3344. "var bilNo = dataJson.BIL_NO;",
  3345. "var bilId = dataJson.BIL_ID;",
  3346. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  3347. "",
  3348. "pm.test(\"✅ 新增成功校验\", function () {",
  3349. " pm.response.to.have.status(200);",
  3350. " let r = pm.response.json();",
  3351. " pm.expect(r.CallOK).to.equal(\"T\");",
  3352. "});",
  3353. "",
  3354. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  3355. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_POS\");",
  3356. "});",
  3357. "",
  3358. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  3359. " pm.environment.set(\"t-erp-api-so-bill-no\", bilNo);",
  3360. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  3361. "});"
  3362. ],
  3363. "type": "text/javascript",
  3364. "packages": {},
  3365. "requests": {}
  3366. }
  3367. }
  3368. ],
  3369. "request": {
  3370. "method": "POST",
  3371. "header": [
  3372. {
  3373. "key": "LoginId",
  3374. "value": "{{t-erp-api-login-id}}",
  3375. "type": "text"
  3376. },
  3377. {
  3378. "key": "sn",
  3379. "value": "{{t-erp-api-sn}}",
  3380. "type": "text"
  3381. }
  3382. ],
  3383. "body": {
  3384. "mode": "raw",
  3385. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SO\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"KH0001\",\n \"DepNo\": \"0001\",\n \"SalNo\": \"LS\",\n \"EstDate\": \"{{t-erp-api-current-date}}\",\n \"Rem\": \"销售订单测试\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  3386. "options": {
  3387. "raw": {
  3388. "language": "json"
  3389. }
  3390. }
  3391. },
  3392. "url": {
  3393. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  3394. "host": [
  3395. "{{t-erp-api-url}}"
  3396. ],
  3397. "path": [
  3398. "Bill",
  3399. "SaveBill"
  3400. ]
  3401. },
  3402. "description": "新增SO单(无来源)"
  3403. },
  3404. "response": []
  3405. },
  3406. {
  3407. "name": "查询SO单",
  3408. "event": [
  3409. {
  3410. "listen": "test",
  3411. "script": {
  3412. "exec": [
  3413. "pm.test(\"✅ 查询成功校验\", function () {",
  3414. " pm.response.to.have.status(200);",
  3415. " let r = pm.response.json();",
  3416. " pm.expect(r.CallOK).to.equal(\"T\");",
  3417. " console.log(\"✅ 查询单据成功\");",
  3418. "});"
  3419. ],
  3420. "type": "text/javascript",
  3421. "packages": {},
  3422. "requests": {}
  3423. }
  3424. }
  3425. ],
  3426. "request": {
  3427. "method": "POST",
  3428. "header": [
  3429. {
  3430. "key": "LoginId",
  3431. "value": "{{t-erp-api-login-id}}",
  3432. "type": "text"
  3433. },
  3434. {
  3435. "key": "sn",
  3436. "value": "{{t-erp-api-sn}}",
  3437. "type": "text"
  3438. }
  3439. ],
  3440. "body": {
  3441. "mode": "raw",
  3442. "raw": "{\r\n \"CallId\": \"SO\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-so-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  3443. "options": {
  3444. "raw": {
  3445. "language": "json"
  3446. }
  3447. }
  3448. },
  3449. "url": {
  3450. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  3451. "host": [
  3452. "{{t-erp-api-url}}"
  3453. ],
  3454. "path": [
  3455. "Bill",
  3456. "QueryBillDetail"
  3457. ]
  3458. },
  3459. "description": "查询SO单详情"
  3460. },
  3461. "response": []
  3462. }
  3463. ],
  3464. "description": "单据类型:SO(销售订单),分类:销售类"
  3465. },
  3466. {
  3467. "name": "SA - 销售出库单",
  3468. "item": [
  3469. {
  3470. "name": "新增SA单(无来源)",
  3471. "event": [
  3472. {
  3473. "listen": "prerequest",
  3474. "script": {
  3475. "exec": [
  3476. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  3477. "function addZero(num) {",
  3478. " return num < 10 ? '0' + num : num;",
  3479. "}",
  3480. "const now = new Date();",
  3481. "const year = now.getFullYear();",
  3482. "const month = addZero(now.getMonth() + 1);",
  3483. "const day = addZero(now.getDate());",
  3484. "const currentDate = `${year}-${month}-${day}`;",
  3485. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  3486. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  3487. ],
  3488. "type": "text/javascript",
  3489. "packages": {},
  3490. "requests": {}
  3491. }
  3492. },
  3493. {
  3494. "listen": "test",
  3495. "script": {
  3496. "exec": [
  3497. "// 1. 解析接口顶层的JSON响应",
  3498. "var resJson = pm.response.json();",
  3499. "console.log(\"✅ 接口顶层JSON解析成功\");",
  3500. "",
  3501. "// 2. 提取Data字段,做非空判断",
  3502. "var dataRawStr = resJson.Data;",
  3503. "if (!dataRawStr) {",
  3504. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  3505. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  3506. " return;",
  3507. "}",
  3508. "",
  3509. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  3510. "var dataJson;",
  3511. "try {",
  3512. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  3513. " dataJson = JSON.parse(dataCleanStr);",
  3514. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  3515. "} catch (e) {",
  3516. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  3517. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  3518. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  3519. " return;",
  3520. "}",
  3521. "",
  3522. "// 4. 提取关键字段",
  3523. "var tfTabNameVal = dataJson.TF_TABNAME;",
  3524. "var bilNo = dataJson.BIL_NO;",
  3525. "var bilId = dataJson.BIL_ID;",
  3526. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  3527. "",
  3528. "pm.test(\"✅ 新增成功校验\", function () {",
  3529. " pm.response.to.have.status(200);",
  3530. " let r = pm.response.json();",
  3531. " pm.expect(r.CallOK).to.equal(\"T\");",
  3532. "});",
  3533. "",
  3534. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  3535. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  3536. "});",
  3537. "",
  3538. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  3539. " pm.environment.set(\"t-erp-api-sa-bill-no\", bilNo);",
  3540. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  3541. "});"
  3542. ],
  3543. "type": "text/javascript",
  3544. "packages": {},
  3545. "requests": {}
  3546. }
  3547. }
  3548. ],
  3549. "request": {
  3550. "method": "POST",
  3551. "header": [
  3552. {
  3553. "key": "LoginId",
  3554. "value": "{{t-erp-api-login-id}}",
  3555. "type": "text"
  3556. },
  3557. {
  3558. "key": "sn",
  3559. "value": "{{t-erp-api-sn}}",
  3560. "type": "text"
  3561. }
  3562. ],
  3563. "body": {
  3564. "mode": "raw",
  3565. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SA\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"KH0001\",\n \"DepNo\": \"0001\",\n \"SalNo\": \"LS\",\n \"EstDate\": \"{{t-erp-api-current-date}}\",\n \"Rem\": \"销售订单测试\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  3566. "options": {
  3567. "raw": {
  3568. "language": "json"
  3569. }
  3570. }
  3571. },
  3572. "url": {
  3573. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  3574. "host": [
  3575. "{{t-erp-api-url}}"
  3576. ],
  3577. "path": [
  3578. "Bill",
  3579. "SaveBill"
  3580. ]
  3581. },
  3582. "description": "新增SA单(无来源)"
  3583. },
  3584. "response": []
  3585. },
  3586. {
  3587. "name": "新增SA单(转入SO来源)",
  3588. "event": [
  3589. {
  3590. "listen": "prerequest",
  3591. "script": {
  3592. "exec": [
  3593. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  3594. "function addZero(num) {",
  3595. " return num < 10 ? '0' + num : num;",
  3596. "}",
  3597. "const now = new Date();",
  3598. "const year = now.getFullYear();",
  3599. "const month = addZero(now.getMonth() + 1);",
  3600. "const day = addZero(now.getDate());",
  3601. "const currentDate = `${year}-${month}-${day}`;",
  3602. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  3603. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  3604. ],
  3605. "type": "text/javascript"
  3606. }
  3607. },
  3608. {
  3609. "listen": "test",
  3610. "script": {
  3611. "exec": [
  3612. "// 1. 解析接口顶层的JSON响应",
  3613. "var resJson = pm.response.json();",
  3614. "console.log(\"✅ 接口顶层JSON解析成功\");",
  3615. "",
  3616. "// 2. 提取Data字段,做非空判断",
  3617. "var dataRawStr = resJson.Data;",
  3618. "if (!dataRawStr) {",
  3619. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  3620. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  3621. " return;",
  3622. "}",
  3623. "",
  3624. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  3625. "var dataJson;",
  3626. "try {",
  3627. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  3628. " dataJson = JSON.parse(dataCleanStr);",
  3629. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  3630. "} catch (e) {",
  3631. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  3632. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  3633. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  3634. " return;",
  3635. "}",
  3636. "",
  3637. "// 4. 提取关键字段",
  3638. "var tfTabNameVal = dataJson.TF_TABNAME;",
  3639. "var bilNo = dataJson.BIL_NO;",
  3640. "var bilId = dataJson.BIL_ID;",
  3641. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  3642. "",
  3643. "pm.test(\"✅ 新增成功校验\", function () {",
  3644. " pm.response.to.have.status(200);",
  3645. " let r = pm.response.json();",
  3646. " pm.expect(r.CallOK).to.equal(\"T\");",
  3647. "});",
  3648. "",
  3649. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  3650. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  3651. "});",
  3652. "",
  3653. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  3654. " pm.environment.set(\"t-erp-api-sa-bill-no\", bilNo);",
  3655. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  3656. "});"
  3657. ],
  3658. "type": "text/javascript"
  3659. }
  3660. }
  3661. ],
  3662. "request": {
  3663. "method": "POST",
  3664. "header": [
  3665. {
  3666. "key": "LoginId",
  3667. "value": "{{t-erp-api-login-id}}",
  3668. "type": "text"
  3669. },
  3670. {
  3671. "key": "sn",
  3672. "value": "{{t-erp-api-sn}}",
  3673. "type": "text"
  3674. }
  3675. ],
  3676. "body": {
  3677. "mode": "raw",
  3678. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SA\"\n },\n \"BodyData\": [\n {\n \"BilId\": \"SO\",\n \"BilNo\": \"{{t-erp-api-so-bill-no}}\",\n \"BilItm\": 1\n }\n ]\n}",
  3679. "options": {
  3680. "raw": {
  3681. "language": "json"
  3682. }
  3683. }
  3684. },
  3685. "url": {
  3686. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  3687. "host": [
  3688. "{{t-erp-api-url}}"
  3689. ],
  3690. "path": [
  3691. "Bill",
  3692. "SaveBill"
  3693. ]
  3694. },
  3695. "description": "新增SA单(从SO单转入)"
  3696. },
  3697. "response": []
  3698. },
  3699. {
  3700. "name": "查询SA单",
  3701. "event": [
  3702. {
  3703. "listen": "test",
  3704. "script": {
  3705. "exec": [
  3706. "pm.test(\"✅ 查询成功校验\", function () {",
  3707. " pm.response.to.have.status(200);",
  3708. " let r = pm.response.json();",
  3709. " pm.expect(r.CallOK).to.equal(\"T\");",
  3710. " console.log(\"✅ 查询单据成功\");",
  3711. "});"
  3712. ],
  3713. "type": "text/javascript",
  3714. "packages": {},
  3715. "requests": {}
  3716. }
  3717. }
  3718. ],
  3719. "request": {
  3720. "method": "POST",
  3721. "header": [
  3722. {
  3723. "key": "LoginId",
  3724. "value": "{{t-erp-api-login-id}}",
  3725. "type": "text"
  3726. },
  3727. {
  3728. "key": "sn",
  3729. "value": "{{t-erp-api-sn}}",
  3730. "type": "text"
  3731. }
  3732. ],
  3733. "body": {
  3734. "mode": "raw",
  3735. "raw": "{\r\n \"CallId\": \"SA\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-sa-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  3736. "options": {
  3737. "raw": {
  3738. "language": "json"
  3739. }
  3740. }
  3741. },
  3742. "url": {
  3743. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  3744. "host": [
  3745. "{{t-erp-api-url}}"
  3746. ],
  3747. "path": [
  3748. "Bill",
  3749. "QueryBillDetail"
  3750. ]
  3751. },
  3752. "description": "查询SA单详情"
  3753. },
  3754. "response": []
  3755. }
  3756. ],
  3757. "description": "单据类型:SA(销售出库单),分类:销售类"
  3758. },
  3759. {
  3760. "name": "SB - 销售退货单",
  3761. "item": [
  3762. {
  3763. "name": "新增SB单(无来源)",
  3764. "event": [
  3765. {
  3766. "listen": "prerequest",
  3767. "script": {
  3768. "exec": [
  3769. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  3770. "function addZero(num) {",
  3771. " return num < 10 ? '0' + num : num;",
  3772. "}",
  3773. "const now = new Date();",
  3774. "const year = now.getFullYear();",
  3775. "const month = addZero(now.getMonth() + 1);",
  3776. "const day = addZero(now.getDate());",
  3777. "const currentDate = `${year}-${month}-${day}`;",
  3778. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  3779. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  3780. ],
  3781. "type": "text/javascript",
  3782. "packages": {},
  3783. "requests": {}
  3784. }
  3785. },
  3786. {
  3787. "listen": "test",
  3788. "script": {
  3789. "exec": [
  3790. "// 1. 解析接口顶层的JSON响应",
  3791. "var resJson = pm.response.json();",
  3792. "console.log(\"✅ 接口顶层JSON解析成功\");",
  3793. "",
  3794. "// 2. 提取Data字段,做非空判断",
  3795. "var dataRawStr = resJson.Data;",
  3796. "if (!dataRawStr) {",
  3797. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  3798. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  3799. " return;",
  3800. "}",
  3801. "",
  3802. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  3803. "var dataJson;",
  3804. "try {",
  3805. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  3806. " dataJson = JSON.parse(dataCleanStr);",
  3807. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  3808. "} catch (e) {",
  3809. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  3810. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  3811. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  3812. " return;",
  3813. "}",
  3814. "",
  3815. "// 4. 提取关键字段",
  3816. "var tfTabNameVal = dataJson.TF_TABNAME;",
  3817. "var bilNo = dataJson.BIL_NO;",
  3818. "var bilId = dataJson.BIL_ID;",
  3819. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  3820. "",
  3821. "pm.test(\"❌️ 需有来源单\", function () {",
  3822. " pm.response.to.have.status(200);",
  3823. " let r = pm.response.json();",
  3824. " pm.expect(r.CallOK).to.equal(\"F\");",
  3825. " ",
  3826. " // 将整个响应转为字符串检查",
  3827. " let responseText = JSON.stringify(r);",
  3828. " pm.expect(responseText).to.include(\"请输入来源单号\");",
  3829. "});"
  3830. ],
  3831. "type": "text/javascript",
  3832. "packages": {},
  3833. "requests": {}
  3834. }
  3835. }
  3836. ],
  3837. "request": {
  3838. "method": "POST",
  3839. "header": [
  3840. {
  3841. "key": "LoginId",
  3842. "value": "{{t-erp-api-login-id}}",
  3843. "type": "text"
  3844. },
  3845. {
  3846. "key": "sn",
  3847. "value": "{{t-erp-api-sn}}",
  3848. "type": "text"
  3849. }
  3850. ],
  3851. "body": {
  3852. "mode": "raw",
  3853. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SB\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"KH0001\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  3854. "options": {
  3855. "raw": {
  3856. "language": "json"
  3857. }
  3858. }
  3859. },
  3860. "url": {
  3861. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  3862. "host": [
  3863. "{{t-erp-api-url}}"
  3864. ],
  3865. "path": [
  3866. "Bill",
  3867. "SaveBill"
  3868. ]
  3869. },
  3870. "description": "新增SB单(无来源)"
  3871. },
  3872. "response": []
  3873. },
  3874. {
  3875. "name": "新增SB单(转入SA来源)",
  3876. "event": [
  3877. {
  3878. "listen": "prerequest",
  3879. "script": {
  3880. "exec": [
  3881. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  3882. "function addZero(num) {",
  3883. " return num < 10 ? '0' + num : num;",
  3884. "}",
  3885. "const now = new Date();",
  3886. "const year = now.getFullYear();",
  3887. "const month = addZero(now.getMonth() + 1);",
  3888. "const day = addZero(now.getDate());",
  3889. "const currentDate = `${year}-${month}-${day}`;",
  3890. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  3891. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  3892. ],
  3893. "type": "text/javascript",
  3894. "packages": {},
  3895. "requests": {}
  3896. }
  3897. },
  3898. {
  3899. "listen": "test",
  3900. "script": {
  3901. "exec": [
  3902. "// 1. 解析接口顶层的JSON响应",
  3903. "var resJson = pm.response.json();",
  3904. "console.log(\"✅ 接口顶层JSON解析成功\");",
  3905. "",
  3906. "// 2. 提取Data字段,做非空判断",
  3907. "var dataRawStr = resJson.Data;",
  3908. "if (!dataRawStr) {",
  3909. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  3910. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  3911. " return;",
  3912. "}",
  3913. "",
  3914. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  3915. "var dataJson;",
  3916. "try {",
  3917. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  3918. " dataJson = JSON.parse(dataCleanStr);",
  3919. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  3920. "} catch (e) {",
  3921. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  3922. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  3923. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  3924. " return;",
  3925. "}",
  3926. "",
  3927. "// 4. 提取关键字段",
  3928. "var tfTabNameVal = dataJson.TF_TABNAME;",
  3929. "var bilNo = dataJson.BIL_NO;",
  3930. "var bilId = dataJson.BIL_ID;",
  3931. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  3932. "",
  3933. "pm.test(\"✅ 新增成功校验\", function () {",
  3934. " pm.response.to.have.status(200);",
  3935. " let r = pm.response.json();",
  3936. " pm.expect(r.CallOK).to.equal(\"T\");",
  3937. "});",
  3938. "",
  3939. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  3940. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  3941. "});",
  3942. "",
  3943. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  3944. " pm.environment.set(\"t-erp-api-sb-bill-no\", bilNo);",
  3945. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  3946. "});"
  3947. ],
  3948. "type": "text/javascript",
  3949. "packages": {},
  3950. "requests": {}
  3951. }
  3952. }
  3953. ],
  3954. "request": {
  3955. "method": "POST",
  3956. "header": [
  3957. {
  3958. "key": "LoginId",
  3959. "value": "{{t-erp-api-login-id}}",
  3960. "type": "text"
  3961. },
  3962. {
  3963. "key": "sn",
  3964. "value": "{{t-erp-api-sn}}",
  3965. "type": "text"
  3966. }
  3967. ],
  3968. "body": {
  3969. "mode": "raw",
  3970. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SB\"\n },\n \"BodyData\": [\n {\n \"BilId\": \"SA\",\n \"BilNo\": \"{{t-erp-api-sa-bill-no}}\",\n \"BilItm\": 1\n }\n ]\n}",
  3971. "options": {
  3972. "raw": {
  3973. "language": "json"
  3974. }
  3975. }
  3976. },
  3977. "url": {
  3978. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  3979. "host": [
  3980. "{{t-erp-api-url}}"
  3981. ],
  3982. "path": [
  3983. "Bill",
  3984. "SaveBill"
  3985. ]
  3986. },
  3987. "description": "新增SB单(从SA单转入)"
  3988. },
  3989. "response": []
  3990. },
  3991. {
  3992. "name": "查询SB单",
  3993. "event": [
  3994. {
  3995. "listen": "test",
  3996. "script": {
  3997. "exec": [
  3998. "pm.test(\"✅ 查询成功校验\", function () {",
  3999. " pm.response.to.have.status(200);",
  4000. " let r = pm.response.json();",
  4001. " pm.expect(r.CallOK).to.equal(\"T\");",
  4002. " console.log(\"✅ 查询单据成功\");",
  4003. "});"
  4004. ],
  4005. "type": "text/javascript",
  4006. "packages": {},
  4007. "requests": {}
  4008. }
  4009. }
  4010. ],
  4011. "request": {
  4012. "method": "POST",
  4013. "header": [
  4014. {
  4015. "key": "LoginId",
  4016. "value": "{{t-erp-api-login-id}}",
  4017. "type": "text"
  4018. },
  4019. {
  4020. "key": "sn",
  4021. "value": "{{t-erp-api-sn}}",
  4022. "type": "text"
  4023. }
  4024. ],
  4025. "body": {
  4026. "mode": "raw",
  4027. "raw": "{\r\n \"CallId\": \"SB\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-sb-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  4028. "options": {
  4029. "raw": {
  4030. "language": "json"
  4031. }
  4032. }
  4033. },
  4034. "url": {
  4035. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  4036. "host": [
  4037. "{{t-erp-api-url}}"
  4038. ],
  4039. "path": [
  4040. "Bill",
  4041. "QueryBillDetail"
  4042. ]
  4043. },
  4044. "description": "查询SB单详情"
  4045. },
  4046. "response": []
  4047. }
  4048. ],
  4049. "description": "单据类型:SB(销售退货单),分类:销售类"
  4050. },
  4051. {
  4052. "name": "CK - 备货单",
  4053. "item": [
  4054. {
  4055. "name": "新增CK单(无来源)",
  4056. "event": [
  4057. {
  4058. "listen": "prerequest",
  4059. "script": {
  4060. "exec": [
  4061. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  4062. "function addZero(num) {",
  4063. " return num < 10 ? '0' + num : num;",
  4064. "}",
  4065. "const now = new Date();",
  4066. "const year = now.getFullYear();",
  4067. "const month = addZero(now.getMonth() + 1);",
  4068. "const day = addZero(now.getDate());",
  4069. "const currentDate = `${year}-${month}-${day}`;",
  4070. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  4071. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  4072. ],
  4073. "type": "text/javascript",
  4074. "packages": {},
  4075. "requests": {}
  4076. }
  4077. },
  4078. {
  4079. "listen": "test",
  4080. "script": {
  4081. "exec": [
  4082. "// 1. 解析接口顶层的JSON响应",
  4083. "var resJson = pm.response.json();",
  4084. "console.log(\"✅ 接口顶层JSON解析成功\");",
  4085. "",
  4086. "// 2. 提取Data字段,做非空判断",
  4087. "var dataRawStr = resJson.Data;",
  4088. "if (!dataRawStr) {",
  4089. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  4090. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  4091. " return;",
  4092. "}",
  4093. "",
  4094. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  4095. "var dataJson;",
  4096. "try {",
  4097. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  4098. " dataJson = JSON.parse(dataCleanStr);",
  4099. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  4100. "} catch (e) {",
  4101. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  4102. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  4103. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  4104. " return;",
  4105. "}",
  4106. "",
  4107. "// 4. 提取关键字段",
  4108. "var tfTabNameVal = dataJson.TF_TABNAME;",
  4109. "var bilNo = dataJson.BIL_NO;",
  4110. "var bilId = dataJson.BIL_ID;",
  4111. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  4112. "",
  4113. "pm.test(\"✅ 新增成功校验\", function () {",
  4114. " pm.response.to.have.status(200);",
  4115. " let r = pm.response.json();",
  4116. " pm.expect(r.CallOK).to.equal(\"T\");",
  4117. "});",
  4118. "",
  4119. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  4120. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_CK\");",
  4121. "});",
  4122. "",
  4123. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  4124. " pm.environment.set(\"t-erp-api-ck-bill-no\", bilNo);",
  4125. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  4126. "});"
  4127. ],
  4128. "type": "text/javascript",
  4129. "packages": {},
  4130. "requests": {}
  4131. }
  4132. }
  4133. ],
  4134. "request": {
  4135. "method": "POST",
  4136. "header": [
  4137. {
  4138. "key": "LoginId",
  4139. "value": "{{t-erp-api-login-id}}",
  4140. "type": "text"
  4141. },
  4142. {
  4143. "key": "sn",
  4144. "value": "{{t-erp-api-sn}}",
  4145. "type": "text"
  4146. }
  4147. ],
  4148. "body": {
  4149. "mode": "raw",
  4150. "raw": "{\n \"HeadData\": {\n \"CallId\": \"CK\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"KH0001\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  4151. "options": {
  4152. "raw": {
  4153. "language": "json"
  4154. }
  4155. }
  4156. },
  4157. "url": {
  4158. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  4159. "host": [
  4160. "{{t-erp-api-url}}"
  4161. ],
  4162. "path": [
  4163. "Bill",
  4164. "SaveBill"
  4165. ]
  4166. },
  4167. "description": "新增CK单(无来源)"
  4168. },
  4169. "response": []
  4170. },
  4171. {
  4172. "name": "查询CK单",
  4173. "event": [
  4174. {
  4175. "listen": "test",
  4176. "script": {
  4177. "exec": [
  4178. "pm.test(\"✅ 查询成功校验\", function () {",
  4179. " pm.response.to.have.status(200);",
  4180. " let r = pm.response.json();",
  4181. " pm.expect(r.CallOK).to.equal(\"T\");",
  4182. " console.log(\"✅ 查询单据成功\");",
  4183. "});"
  4184. ],
  4185. "type": "text/javascript",
  4186. "packages": {},
  4187. "requests": {}
  4188. }
  4189. }
  4190. ],
  4191. "request": {
  4192. "method": "POST",
  4193. "header": [
  4194. {
  4195. "key": "LoginId",
  4196. "value": "{{t-erp-api-login-id}}",
  4197. "type": "text"
  4198. },
  4199. {
  4200. "key": "sn",
  4201. "value": "{{t-erp-api-sn}}",
  4202. "type": "text"
  4203. }
  4204. ],
  4205. "body": {
  4206. "mode": "raw",
  4207. "raw": "{\r\n \"CallId\": \"CK\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-ck-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  4208. "options": {
  4209. "raw": {
  4210. "language": "json"
  4211. }
  4212. }
  4213. },
  4214. "url": {
  4215. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  4216. "host": [
  4217. "{{t-erp-api-url}}"
  4218. ],
  4219. "path": [
  4220. "Bill",
  4221. "QueryBillDetail"
  4222. ]
  4223. },
  4224. "description": "查询CK单详情"
  4225. },
  4226. "response": []
  4227. },
  4228. {
  4229. "name": "新增SA单(转入CK来源)",
  4230. "event": [
  4231. {
  4232. "listen": "prerequest",
  4233. "script": {
  4234. "exec": [
  4235. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  4236. "function addZero(num) {",
  4237. " return num < 10 ? '0' + num : num;",
  4238. "}",
  4239. "const now = new Date();",
  4240. "const year = now.getFullYear();",
  4241. "const month = addZero(now.getMonth() + 1);",
  4242. "const day = addZero(now.getDate());",
  4243. "const currentDate = `${year}-${month}-${day}`;",
  4244. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  4245. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  4246. ],
  4247. "type": "text/javascript",
  4248. "packages": {},
  4249. "requests": {}
  4250. }
  4251. },
  4252. {
  4253. "listen": "test",
  4254. "script": {
  4255. "exec": [
  4256. "// 1. 解析接口顶层的JSON响应",
  4257. "var resJson = pm.response.json();",
  4258. "console.log(\"✅ 接口顶层JSON解析成功\");",
  4259. "",
  4260. "// 2. 提取Data字段,做非空判断",
  4261. "var dataRawStr = resJson.Data;",
  4262. "if (!dataRawStr) {",
  4263. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  4264. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  4265. " return;",
  4266. "}",
  4267. "",
  4268. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  4269. "var dataJson;",
  4270. "try {",
  4271. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  4272. " dataJson = JSON.parse(dataCleanStr);",
  4273. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  4274. "} catch (e) {",
  4275. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  4276. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  4277. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  4278. " return;",
  4279. "}",
  4280. "",
  4281. "// 4. 提取关键字段",
  4282. "var tfTabNameVal = dataJson.TF_TABNAME;",
  4283. "var bilNo = dataJson.BIL_NO;",
  4284. "var bilId = dataJson.BIL_ID;",
  4285. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  4286. "",
  4287. "pm.test(\"✅ 新增成功校验\", function () {",
  4288. " pm.response.to.have.status(200);",
  4289. " let r = pm.response.json();",
  4290. " pm.expect(r.CallOK).to.equal(\"T\");",
  4291. "});",
  4292. "",
  4293. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  4294. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PSS\");",
  4295. "});",
  4296. "",
  4297. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  4298. " pm.environment.set(\"t-erp-api-sa-bill-no\", bilNo);",
  4299. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  4300. "});"
  4301. ],
  4302. "type": "text/javascript",
  4303. "packages": {},
  4304. "requests": {}
  4305. }
  4306. }
  4307. ],
  4308. "request": {
  4309. "method": "POST",
  4310. "header": [
  4311. {
  4312. "key": "LoginId",
  4313. "value": "{{t-erp-api-login-id}}",
  4314. "type": "text"
  4315. },
  4316. {
  4317. "key": "sn",
  4318. "value": "{{t-erp-api-sn}}",
  4319. "type": "text"
  4320. }
  4321. ],
  4322. "body": {
  4323. "mode": "raw",
  4324. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SA\"\n },\n \"BodyData\": [\n {\n \"BilId\": \"CK\",\n \"BilNo\": \"{{t-erp-api-ck-bill-no}}\",\n \"BilItm\": 1\n }\n ]\n}",
  4325. "options": {
  4326. "raw": {
  4327. "language": "json"
  4328. }
  4329. }
  4330. },
  4331. "url": {
  4332. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  4333. "host": [
  4334. "{{t-erp-api-url}}"
  4335. ],
  4336. "path": [
  4337. "Bill",
  4338. "SaveBill"
  4339. ]
  4340. },
  4341. "description": "新增SA单(从SO单转入)"
  4342. },
  4343. "response": []
  4344. }
  4345. ],
  4346. "description": "单据类型:CK(销售开票),分类:销售类"
  4347. },
  4348. {
  4349. "name": "PN - 销售订单变更作业",
  4350. "item": [
  4351. {
  4352. "name": "新增SO单(后续转PN)",
  4353. "event": [
  4354. {
  4355. "listen": "prerequest",
  4356. "script": {
  4357. "exec": [
  4358. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  4359. "function addZero(num) {",
  4360. " return num < 10 ? '0' + num : num;",
  4361. "}",
  4362. "const now = new Date();",
  4363. "const year = now.getFullYear();",
  4364. "const month = addZero(now.getMonth() + 1);",
  4365. "const day = addZero(now.getDate());",
  4366. "const currentDate = `${year}-${month}-${day}`;",
  4367. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  4368. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  4369. ],
  4370. "type": "text/javascript",
  4371. "packages": {},
  4372. "requests": {}
  4373. }
  4374. },
  4375. {
  4376. "listen": "test",
  4377. "script": {
  4378. "exec": [
  4379. "// 1. 解析接口顶层的JSON响应",
  4380. "var resJson = pm.response.json();",
  4381. "console.log(\"✅ 接口顶层JSON解析成功\");",
  4382. "",
  4383. "// 2. 提取Data字段,做非空判断",
  4384. "var dataRawStr = resJson.Data;",
  4385. "if (!dataRawStr) {",
  4386. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  4387. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  4388. " return;",
  4389. "}",
  4390. "",
  4391. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  4392. "var dataJson;",
  4393. "try {",
  4394. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  4395. " dataJson = JSON.parse(dataCleanStr);",
  4396. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  4397. "} catch (e) {",
  4398. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  4399. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  4400. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  4401. " return;",
  4402. "}",
  4403. "",
  4404. "// 4. 提取关键字段",
  4405. "var tfTabNameVal = dataJson.TF_TABNAME;",
  4406. "var bilNo = dataJson.BIL_NO;",
  4407. "var bilId = dataJson.BIL_ID;",
  4408. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  4409. "",
  4410. "pm.test(\"✅ 新增成功校验\", function () {",
  4411. " pm.response.to.have.status(200);",
  4412. " let r = pm.response.json();",
  4413. " pm.expect(r.CallOK).to.equal(\"T\");",
  4414. "});",
  4415. "",
  4416. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  4417. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_POS\");",
  4418. "});",
  4419. "",
  4420. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  4421. " pm.environment.set(\"t-erp-api-so-bill-no\", bilNo);",
  4422. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  4423. "});"
  4424. ],
  4425. "type": "text/javascript",
  4426. "packages": {},
  4427. "requests": {}
  4428. }
  4429. }
  4430. ],
  4431. "request": {
  4432. "method": "POST",
  4433. "header": [
  4434. {
  4435. "key": "LoginId",
  4436. "value": "{{t-erp-api-login-id}}",
  4437. "type": "text"
  4438. },
  4439. {
  4440. "key": "sn",
  4441. "value": "{{t-erp-api-sn}}",
  4442. "type": "text"
  4443. }
  4444. ],
  4445. "body": {
  4446. "mode": "raw",
  4447. "raw": "{\n \"HeadData\": {\n \"CallId\": \"SO\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"KH0001\",\n \"DepNo\": \"0001\",\n \"SalNo\": \"LS\",\n \"EstDate\": \"{{t-erp-api-current-date}}\",\n \"Rem\": \"销售订单测试\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  4448. "options": {
  4449. "raw": {
  4450. "language": "json"
  4451. }
  4452. }
  4453. },
  4454. "url": {
  4455. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  4456. "host": [
  4457. "{{t-erp-api-url}}"
  4458. ],
  4459. "path": [
  4460. "Bill",
  4461. "SaveBill"
  4462. ]
  4463. },
  4464. "description": "新增SO单(无来源)"
  4465. },
  4466. "response": []
  4467. },
  4468. {
  4469. "name": "新增PN单(转入SO来源)",
  4470. "event": [
  4471. {
  4472. "listen": "prerequest",
  4473. "script": {
  4474. "exec": [
  4475. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  4476. "function addZero(num) {",
  4477. " return num < 10 ? '0' + num : num;",
  4478. "}",
  4479. "const now = new Date();",
  4480. "const year = now.getFullYear();",
  4481. "const month = addZero(now.getMonth() + 1);",
  4482. "const day = addZero(now.getDate());",
  4483. "const currentDate = `${year}-${month}-${day}`;",
  4484. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  4485. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  4486. ],
  4487. "type": "text/javascript",
  4488. "packages": {},
  4489. "requests": {}
  4490. }
  4491. },
  4492. {
  4493. "listen": "test",
  4494. "script": {
  4495. "exec": [
  4496. "// 1. 解析接口顶层的JSON响应",
  4497. "var resJson = pm.response.json();",
  4498. "console.log(\"✅ 接口顶层JSON解析成功\");",
  4499. "",
  4500. "// 2. 提取Data字段,做非空判断",
  4501. "var dataRawStr = resJson.Data;",
  4502. "if (!dataRawStr) {",
  4503. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  4504. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  4505. " return;",
  4506. "}",
  4507. "",
  4508. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  4509. "var dataJson;",
  4510. "try {",
  4511. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  4512. " dataJson = JSON.parse(dataCleanStr);",
  4513. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  4514. "} catch (e) {",
  4515. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  4516. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  4517. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  4518. " return;",
  4519. "}",
  4520. "",
  4521. "// 4. 提取关键字段",
  4522. "var tfTabNameVal = dataJson.TF_TABNAME;",
  4523. "var bilNo = dataJson.BIL_NO;",
  4524. "var bilId = dataJson.BIL_ID;",
  4525. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  4526. "",
  4527. "pm.test(\"✅ 新增成功校验\", function () {",
  4528. " pm.response.to.have.status(200);",
  4529. " let r = pm.response.json();",
  4530. " pm.expect(r.CallOK).to.equal(\"T\");",
  4531. "});",
  4532. "",
  4533. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  4534. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PM\");",
  4535. "});",
  4536. "",
  4537. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  4538. " pm.environment.set(\"t-erp-api-pn-bill-no\", bilNo);",
  4539. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  4540. "});"
  4541. ],
  4542. "type": "text/javascript",
  4543. "packages": {},
  4544. "requests": {}
  4545. }
  4546. }
  4547. ],
  4548. "request": {
  4549. "method": "POST",
  4550. "header": [
  4551. {
  4552. "key": "LoginId",
  4553. "value": "{{t-erp-api-login-id}}",
  4554. "type": "text"
  4555. },
  4556. {
  4557. "key": "sn",
  4558. "value": "{{t-erp-api-sn}}",
  4559. "type": "text"
  4560. }
  4561. ],
  4562. "body": {
  4563. "mode": "raw",
  4564. "raw": "{\n \"HeadData\": { // 必须,表头数据\n \"CallId\": \"PN\", // 必须,调用的单据识别号,\"PN\":表示销售订单变更作业\n \"Rem\": \"新增销售订单变更\" // 非必须,表头原因\n\n },\n \"BodyData\": [ // 必须,表身数据\n {\n\n \"ChgId\": \"3\", // 新增时必须,变更方式,\"1\":新增、\"2\":删除、\"3\":修改、\"4\":结案、\"5\":反结案\n \"BilNo\": \"{{t-erp-api-so-bill-no}}\", // 新增时必须,销售订单单据号码\n \"EstItm\": 1, // //新增时必须,销售订单表身项次,自2025-11-21后补丁包支持。传了该值无需在ExtendProps中传EST_ITM\n \"OldPrdNo\": \"YL0001\", // 新增时必须,原品号\n \"PrdNo\": \"YL0001\", // 新增时必须,现品号\n \"WhNo\": \"0001\", // 非必须,仓库代号\n \"Qty\": 20, // 必须,主数量\n \"Up\": 80, // 非必须,单价\n \"Rem\": \"这是表身摘要\", // 非必须,摘要\n \"ExtendProps\": { // 非必须,扩展功能,包括表身的其他字段以及用户自定义字段\n \"EST_DD\": \"{{t-erp-api-current-date}}\", // 字段名需与数据库表(TF_PM)中的栏位名称一致\n \"EST_ITM\": 1 // 新增时必须,销售订单表身项次,2025-11-21之前的程序通过这个方式指定销售订单表身项次\n }\n }\n ]\n}",
  4565. "options": {
  4566. "raw": {
  4567. "language": "json"
  4568. }
  4569. }
  4570. },
  4571. "url": {
  4572. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  4573. "host": [
  4574. "{{t-erp-api-url}}"
  4575. ],
  4576. "path": [
  4577. "Bill",
  4578. "SaveBill"
  4579. ]
  4580. },
  4581. "description": "新增PN单(无来源)"
  4582. },
  4583. "response": []
  4584. },
  4585. {
  4586. "name": "查询PN单",
  4587. "event": [
  4588. {
  4589. "listen": "test",
  4590. "script": {
  4591. "exec": [
  4592. "pm.test(\"✅ 查询成功校验\", function () {",
  4593. " pm.response.to.have.status(200);",
  4594. " let r = pm.response.json();",
  4595. " pm.expect(r.CallOK).to.equal(\"T\");",
  4596. " console.log(\"✅ 查询单据成功\");",
  4597. "});"
  4598. ],
  4599. "type": "text/javascript",
  4600. "packages": {},
  4601. "requests": {}
  4602. }
  4603. }
  4604. ],
  4605. "request": {
  4606. "method": "POST",
  4607. "header": [
  4608. {
  4609. "key": "LoginId",
  4610. "value": "{{t-erp-api-login-id}}",
  4611. "type": "text"
  4612. },
  4613. {
  4614. "key": "sn",
  4615. "value": "{{t-erp-api-sn}}",
  4616. "type": "text"
  4617. }
  4618. ],
  4619. "body": {
  4620. "mode": "raw",
  4621. "raw": "{\r\n \"CallId\": \"PN\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-pn-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  4622. "options": {
  4623. "raw": {
  4624. "language": "json"
  4625. }
  4626. }
  4627. },
  4628. "url": {
  4629. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  4630. "host": [
  4631. "{{t-erp-api-url}}"
  4632. ],
  4633. "path": [
  4634. "Bill",
  4635. "QueryBillDetail"
  4636. ]
  4637. },
  4638. "description": "查询PN单详情"
  4639. },
  4640. "response": []
  4641. }
  4642. ],
  4643. "description": "单据类型:PN(销售预收款),分类:销售类"
  4644. }
  4645. ],
  4646. "description": "销售类相关单据测试用例"
  4647. },
  4648. {
  4649. "name": "📂 库存类",
  4650. "item": [
  4651. {
  4652. "name": "WI - 库存入仓单",
  4653. "item": [
  4654. {
  4655. "name": "新增WI单(无来源)",
  4656. "event": [
  4657. {
  4658. "listen": "prerequest",
  4659. "script": {
  4660. "exec": [
  4661. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  4662. "function addZero(num) {",
  4663. " return num < 10 ? '0' + num : num;",
  4664. "}",
  4665. "const now = new Date();",
  4666. "const year = now.getFullYear();",
  4667. "const month = addZero(now.getMonth() + 1);",
  4668. "const day = addZero(now.getDate());",
  4669. "const currentDate = `${year}-${month}-${day}`;",
  4670. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  4671. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  4672. ],
  4673. "type": "text/javascript",
  4674. "packages": {},
  4675. "requests": {}
  4676. }
  4677. },
  4678. {
  4679. "listen": "test",
  4680. "script": {
  4681. "exec": [
  4682. "// 1. 解析接口顶层的JSON响应",
  4683. "var resJson = pm.response.json();",
  4684. "console.log(\"✅ 接口顶层JSON解析成功\");",
  4685. "",
  4686. "// 2. 提取Data字段,做非空判断",
  4687. "var dataRawStr = resJson.Data;",
  4688. "if (!dataRawStr) {",
  4689. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  4690. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  4691. " return;",
  4692. "}",
  4693. "",
  4694. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  4695. "var dataJson;",
  4696. "try {",
  4697. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  4698. " dataJson = JSON.parse(dataCleanStr);",
  4699. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  4700. "} catch (e) {",
  4701. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  4702. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  4703. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  4704. " return;",
  4705. "}",
  4706. "",
  4707. "// 4. 提取关键字段",
  4708. "var tfTabNameVal = dataJson.TF_TABNAME;",
  4709. "var bilNo = dataJson.BIL_NO;",
  4710. "var bilId = dataJson.BIL_ID;",
  4711. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  4712. "",
  4713. "pm.test(\"✅ 新增成功校验\", function () {",
  4714. " pm.response.to.have.status(200);",
  4715. " let r = pm.response.json();",
  4716. " pm.expect(r.CallOK).to.equal(\"T\");",
  4717. "});",
  4718. "",
  4719. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  4720. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_IJ\");",
  4721. "});",
  4722. "",
  4723. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  4724. " pm.environment.set(\"t-erp-api-wi-bill-no\", bilNo);",
  4725. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  4726. "});"
  4727. ],
  4728. "type": "text/javascript",
  4729. "packages": {},
  4730. "requests": {}
  4731. }
  4732. }
  4733. ],
  4734. "request": {
  4735. "method": "POST",
  4736. "header": [
  4737. {
  4738. "key": "LoginId",
  4739. "value": "{{t-erp-api-login-id}}",
  4740. "type": "text"
  4741. },
  4742. {
  4743. "key": "sn",
  4744. "value": "{{t-erp-api-sn}}",
  4745. "type": "text"
  4746. }
  4747. ],
  4748. "body": {
  4749. "mode": "raw",
  4750. "raw": "{\n \"HeadData\": {\n \"CallId\": \"WI\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"WhNo\": \"0001\",\n \"DepNo\": \"0001\",\n \"Rem\": \"库存入仓单测试\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  4751. "options": {
  4752. "raw": {
  4753. "language": "json"
  4754. }
  4755. }
  4756. },
  4757. "url": {
  4758. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  4759. "host": [
  4760. "{{t-erp-api-url}}"
  4761. ],
  4762. "path": [
  4763. "Bill",
  4764. "SaveBill"
  4765. ]
  4766. },
  4767. "description": "新增W1单(无来源)"
  4768. },
  4769. "response": []
  4770. },
  4771. {
  4772. "name": "查询WI单",
  4773. "event": [
  4774. {
  4775. "listen": "test",
  4776. "script": {
  4777. "exec": [
  4778. "pm.test(\"✅ 查询成功校验\", function () {",
  4779. " pm.response.to.have.status(200);",
  4780. " let r = pm.response.json();",
  4781. " pm.expect(r.CallOK).to.equal(\"T\");",
  4782. " console.log(\"✅ 查询单据成功\");",
  4783. "});"
  4784. ],
  4785. "type": "text/javascript",
  4786. "packages": {},
  4787. "requests": {}
  4788. }
  4789. }
  4790. ],
  4791. "request": {
  4792. "method": "POST",
  4793. "header": [
  4794. {
  4795. "key": "LoginId",
  4796. "value": "{{t-erp-api-login-id}}",
  4797. "type": "text"
  4798. },
  4799. {
  4800. "key": "sn",
  4801. "value": "{{t-erp-api-sn}}",
  4802. "type": "text"
  4803. }
  4804. ],
  4805. "body": {
  4806. "mode": "raw",
  4807. "raw": "{\r\n \"CallId\": \"WI\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-wi-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  4808. "options": {
  4809. "raw": {
  4810. "language": "json"
  4811. }
  4812. }
  4813. },
  4814. "url": {
  4815. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  4816. "host": [
  4817. "{{t-erp-api-url}}"
  4818. ],
  4819. "path": [
  4820. "Bill",
  4821. "QueryBillDetail"
  4822. ]
  4823. },
  4824. "description": "查询W1单详情"
  4825. },
  4826. "response": []
  4827. }
  4828. ],
  4829. "description": "单据类型:W1(库存入仓单),分类:库存类"
  4830. },
  4831. {
  4832. "name": "WO - 库存出仓单",
  4833. "item": [
  4834. {
  4835. "name": "新增WO单(无来源)",
  4836. "event": [
  4837. {
  4838. "listen": "prerequest",
  4839. "script": {
  4840. "exec": [
  4841. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  4842. "function addZero(num) {",
  4843. " return num < 10 ? '0' + num : num;",
  4844. "}",
  4845. "const now = new Date();",
  4846. "const year = now.getFullYear();",
  4847. "const month = addZero(now.getMonth() + 1);",
  4848. "const day = addZero(now.getDate());",
  4849. "const currentDate = `${year}-${month}-${day}`;",
  4850. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  4851. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  4852. ],
  4853. "type": "text/javascript",
  4854. "packages": {},
  4855. "requests": {}
  4856. }
  4857. },
  4858. {
  4859. "listen": "test",
  4860. "script": {
  4861. "exec": [
  4862. "// 1. 解析接口顶层的JSON响应",
  4863. "var resJson = pm.response.json();",
  4864. "console.log(\"✅ 接口顶层JSON解析成功\");",
  4865. "",
  4866. "// 2. 提取Data字段,做非空判断",
  4867. "var dataRawStr = resJson.Data;",
  4868. "if (!dataRawStr) {",
  4869. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  4870. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  4871. " return;",
  4872. "}",
  4873. "",
  4874. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  4875. "var dataJson;",
  4876. "try {",
  4877. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  4878. " dataJson = JSON.parse(dataCleanStr);",
  4879. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  4880. "} catch (e) {",
  4881. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  4882. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  4883. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  4884. " return;",
  4885. "}",
  4886. "",
  4887. "// 4. 提取关键字段",
  4888. "var tfTabNameVal = dataJson.TF_TABNAME;",
  4889. "var bilNo = dataJson.BIL_NO;",
  4890. "var bilId = dataJson.BIL_ID;",
  4891. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  4892. "",
  4893. "pm.test(\"✅ 新增成功校验\", function () {",
  4894. " pm.response.to.have.status(200);",
  4895. " let r = pm.response.json();",
  4896. " pm.expect(r.CallOK).to.equal(\"T\");",
  4897. "});",
  4898. "",
  4899. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  4900. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_IJ\");",
  4901. "});",
  4902. "",
  4903. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  4904. " pm.environment.set(\"t-erp-api-wo-bill-no\", bilNo);",
  4905. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  4906. "});"
  4907. ],
  4908. "type": "text/javascript",
  4909. "packages": {},
  4910. "requests": {}
  4911. }
  4912. }
  4913. ],
  4914. "request": {
  4915. "method": "POST",
  4916. "header": [
  4917. {
  4918. "key": "LoginId",
  4919. "value": "{{t-erp-api-login-id}}",
  4920. "type": "text"
  4921. },
  4922. {
  4923. "key": "sn",
  4924. "value": "{{t-erp-api-sn}}",
  4925. "type": "text"
  4926. }
  4927. ],
  4928. "body": {
  4929. "mode": "raw",
  4930. "raw": "{\n \"HeadData\": {\n \"CallId\": \"WO\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"WhNo\": \"0001\",\n \"DepNo\": \"0001\",\n \"Rem\": \"库存出库单测试\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  4931. "options": {
  4932. "raw": {
  4933. "language": "json"
  4934. }
  4935. }
  4936. },
  4937. "url": {
  4938. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  4939. "host": [
  4940. "{{t-erp-api-url}}"
  4941. ],
  4942. "path": [
  4943. "Bill",
  4944. "SaveBill"
  4945. ]
  4946. },
  4947. "description": "新增WO单(无来源)"
  4948. },
  4949. "response": []
  4950. },
  4951. {
  4952. "name": "查询WO单",
  4953. "event": [
  4954. {
  4955. "listen": "test",
  4956. "script": {
  4957. "exec": [
  4958. "pm.test(\"✅ 查询成功校验\", function () {",
  4959. " pm.response.to.have.status(200);",
  4960. " let r = pm.response.json();",
  4961. " pm.expect(r.CallOK).to.equal(\"T\");",
  4962. " console.log(\"✅ 查询单据成功\");",
  4963. "});"
  4964. ],
  4965. "type": "text/javascript",
  4966. "packages": {},
  4967. "requests": {}
  4968. }
  4969. }
  4970. ],
  4971. "request": {
  4972. "method": "POST",
  4973. "header": [
  4974. {
  4975. "key": "LoginId",
  4976. "value": "{{t-erp-api-login-id}}",
  4977. "type": "text"
  4978. },
  4979. {
  4980. "key": "sn",
  4981. "value": "{{t-erp-api-sn}}",
  4982. "type": "text"
  4983. }
  4984. ],
  4985. "body": {
  4986. "mode": "raw",
  4987. "raw": "{\r\n \"CallId\": \"WO\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-wo-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  4988. "options": {
  4989. "raw": {
  4990. "language": "json"
  4991. }
  4992. }
  4993. },
  4994. "url": {
  4995. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  4996. "host": [
  4997. "{{t-erp-api-url}}"
  4998. ],
  4999. "path": [
  5000. "Bill",
  5001. "QueryBillDetail"
  5002. ]
  5003. },
  5004. "description": "查询WO单详情"
  5005. },
  5006. "response": []
  5007. }
  5008. ],
  5009. "description": "单据类型:WO(库存出仓单),分类:库存类"
  5010. },
  5011. {
  5012. "name": "IC - 库存调拨单",
  5013. "item": [
  5014. {
  5015. "name": "新增IC单(无来源)",
  5016. "event": [
  5017. {
  5018. "listen": "prerequest",
  5019. "script": {
  5020. "exec": [
  5021. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  5022. "function addZero(num) {",
  5023. " return num < 10 ? '0' + num : num;",
  5024. "}",
  5025. "const now = new Date();",
  5026. "const year = now.getFullYear();",
  5027. "const month = addZero(now.getMonth() + 1);",
  5028. "const day = addZero(now.getDate());",
  5029. "const currentDate = `${year}-${month}-${day}`;",
  5030. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  5031. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  5032. ],
  5033. "type": "text/javascript",
  5034. "packages": {},
  5035. "requests": {}
  5036. }
  5037. },
  5038. {
  5039. "listen": "test",
  5040. "script": {
  5041. "exec": [
  5042. "// 1. 解析接口顶层的JSON响应",
  5043. "var resJson = pm.response.json();",
  5044. "console.log(\"✅ 接口顶层JSON解析成功\");",
  5045. "",
  5046. "// 2. 提取Data字段,做非空判断",
  5047. "var dataRawStr = resJson.Data;",
  5048. "if (!dataRawStr) {",
  5049. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  5050. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  5051. " return;",
  5052. "}",
  5053. "",
  5054. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  5055. "var dataJson;",
  5056. "try {",
  5057. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  5058. " dataJson = JSON.parse(dataCleanStr);",
  5059. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  5060. "} catch (e) {",
  5061. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  5062. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  5063. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  5064. " return;",
  5065. "}",
  5066. "",
  5067. "// 4. 提取关键字段",
  5068. "var tfTabNameVal = dataJson.TF_TABNAME;",
  5069. "var bilNo = dataJson.BIL_NO;",
  5070. "var bilId = dataJson.BIL_ID;",
  5071. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  5072. "",
  5073. "pm.test(\"✅ 新增成功校验\", function () {",
  5074. " pm.response.to.have.status(200);",
  5075. " let r = pm.response.json();",
  5076. " pm.expect(r.CallOK).to.equal(\"T\");",
  5077. "});",
  5078. "",
  5079. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  5080. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_IC\");",
  5081. "});",
  5082. "",
  5083. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  5084. " pm.environment.set(\"t-erp-api-ic-bill-no\", bilNo);",
  5085. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  5086. "});"
  5087. ],
  5088. "type": "text/javascript",
  5089. "packages": {},
  5090. "requests": {}
  5091. }
  5092. }
  5093. ],
  5094. "request": {
  5095. "method": "POST",
  5096. "header": [
  5097. {
  5098. "key": "LoginId",
  5099. "value": "{{t-erp-api-login-id}}",
  5100. "type": "text"
  5101. },
  5102. {
  5103. "key": "sn",
  5104. "value": "{{t-erp-api-sn}}",
  5105. "type": "text"
  5106. }
  5107. ],
  5108. "body": {
  5109. "mode": "raw",
  5110. "raw": "{\n \"HeadData\": {\n \"CallId\": \"IC\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"WhNo2\": \"0007\",\n \"Qty\": 10,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  5111. "options": {
  5112. "raw": {
  5113. "language": "json"
  5114. }
  5115. }
  5116. },
  5117. "url": {
  5118. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  5119. "host": [
  5120. "{{t-erp-api-url}}"
  5121. ],
  5122. "path": [
  5123. "Bill",
  5124. "SaveBill"
  5125. ]
  5126. },
  5127. "description": "新增IC单(无来源)"
  5128. },
  5129. "response": []
  5130. },
  5131. {
  5132. "name": "查询IC单",
  5133. "event": [
  5134. {
  5135. "listen": "test",
  5136. "script": {
  5137. "exec": [
  5138. "pm.test(\"✅ 查询成功校验\", function () {",
  5139. " pm.response.to.have.status(200);",
  5140. " let r = pm.response.json();",
  5141. " pm.expect(r.CallOK).to.equal(\"T\");",
  5142. " console.log(\"✅ 查询单据成功\");",
  5143. "});"
  5144. ],
  5145. "type": "text/javascript",
  5146. "packages": {},
  5147. "requests": {}
  5148. }
  5149. }
  5150. ],
  5151. "request": {
  5152. "method": "POST",
  5153. "header": [
  5154. {
  5155. "key": "LoginId",
  5156. "value": "{{t-erp-api-login-id}}",
  5157. "type": "text"
  5158. },
  5159. {
  5160. "key": "sn",
  5161. "value": "{{t-erp-api-sn}}",
  5162. "type": "text"
  5163. }
  5164. ],
  5165. "body": {
  5166. "mode": "raw",
  5167. "raw": "{\r\n \"CallId\": \"IC\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-ic-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  5168. "options": {
  5169. "raw": {
  5170. "language": "json"
  5171. }
  5172. }
  5173. },
  5174. "url": {
  5175. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  5176. "host": [
  5177. "{{t-erp-api-url}}"
  5178. ],
  5179. "path": [
  5180. "Bill",
  5181. "QueryBillDetail"
  5182. ]
  5183. },
  5184. "description": "查询IC单详情"
  5185. },
  5186. "response": []
  5187. }
  5188. ],
  5189. "description": "单据类型:IC(库存盘点单),分类:库存类"
  5190. },
  5191. {
  5192. "name": "IJ - 库存调整单",
  5193. "item": [
  5194. {
  5195. "name": "新增IJ单(无来源)",
  5196. "event": [
  5197. {
  5198. "listen": "prerequest",
  5199. "script": {
  5200. "exec": [
  5201. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  5202. "function addZero(num) {",
  5203. " return num < 10 ? '0' + num : num;",
  5204. "}",
  5205. "const now = new Date();",
  5206. "const year = now.getFullYear();",
  5207. "const month = addZero(now.getMonth() + 1);",
  5208. "const day = addZero(now.getDate());",
  5209. "const currentDate = `${year}-${month}-${day}`;",
  5210. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  5211. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  5212. ],
  5213. "type": "text/javascript",
  5214. "packages": {},
  5215. "requests": {}
  5216. }
  5217. },
  5218. {
  5219. "listen": "test",
  5220. "script": {
  5221. "exec": [
  5222. "// 1. 解析接口顶层的JSON响应",
  5223. "var resJson = pm.response.json();",
  5224. "console.log(\"✅ 接口顶层JSON解析成功\");",
  5225. "",
  5226. "// 2. 提取Data字段,做非空判断",
  5227. "var dataRawStr = resJson.Data;",
  5228. "if (!dataRawStr) {",
  5229. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  5230. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  5231. " return;",
  5232. "}",
  5233. "",
  5234. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  5235. "var dataJson;",
  5236. "try {",
  5237. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  5238. " dataJson = JSON.parse(dataCleanStr);",
  5239. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  5240. "} catch (e) {",
  5241. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  5242. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  5243. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  5244. " return;",
  5245. "}",
  5246. "",
  5247. "// 4. 提取关键字段",
  5248. "var tfTabNameVal = dataJson.TF_TABNAME;",
  5249. "var bilNo = dataJson.BIL_NO;",
  5250. "var bilId = dataJson.BIL_ID;",
  5251. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  5252. "",
  5253. "pm.test(\"✅ 新增成功校验\", function () {",
  5254. " pm.response.to.have.status(200);",
  5255. " let r = pm.response.json();",
  5256. " pm.expect(r.CallOK).to.equal(\"T\");",
  5257. "});",
  5258. "",
  5259. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  5260. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_IJ\");",
  5261. "});",
  5262. "",
  5263. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  5264. " pm.environment.set(\"t-erp-api-ij-bill-no\", bilNo);",
  5265. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  5266. "});"
  5267. ],
  5268. "type": "text/javascript",
  5269. "packages": {},
  5270. "requests": {}
  5271. }
  5272. }
  5273. ],
  5274. "request": {
  5275. "method": "POST",
  5276. "header": [
  5277. {
  5278. "key": "LoginId",
  5279. "value": "{{t-erp-api-login-id}}",
  5280. "type": "text"
  5281. },
  5282. {
  5283. "key": "sn",
  5284. "value": "{{t-erp-api-sn}}",
  5285. "type": "text"
  5286. }
  5287. ],
  5288. "body": {
  5289. "mode": "raw",
  5290. "raw": "{\n \"HeadData\": {\n \"CallId\": \"IJ\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"AddId\": \"+\",\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 1000,\n \"Rem\": \"测试用摘要\"\n },\n {\n \"AddId\": \"-\",\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0007\",\n \"Qty\": 10,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  5291. "options": {
  5292. "raw": {
  5293. "language": "json"
  5294. }
  5295. }
  5296. },
  5297. "url": {
  5298. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  5299. "host": [
  5300. "{{t-erp-api-url}}"
  5301. ],
  5302. "path": [
  5303. "Bill",
  5304. "SaveBill"
  5305. ]
  5306. },
  5307. "description": "新增IJ单(无来源)"
  5308. },
  5309. "response": []
  5310. },
  5311. {
  5312. "name": "查询IJ单",
  5313. "event": [
  5314. {
  5315. "listen": "test",
  5316. "script": {
  5317. "exec": [
  5318. "pm.test(\"✅ 查询成功校验\", function () {",
  5319. " pm.response.to.have.status(200);",
  5320. " let r = pm.response.json();",
  5321. " pm.expect(r.CallOK).to.equal(\"T\");",
  5322. " console.log(\"✅ 查询单据成功\");",
  5323. "});"
  5324. ],
  5325. "type": "text/javascript",
  5326. "packages": {},
  5327. "requests": {}
  5328. }
  5329. }
  5330. ],
  5331. "request": {
  5332. "method": "POST",
  5333. "header": [
  5334. {
  5335. "key": "LoginId",
  5336. "value": "{{t-erp-api-login-id}}",
  5337. "type": "text"
  5338. },
  5339. {
  5340. "key": "sn",
  5341. "value": "{{t-erp-api-sn}}",
  5342. "type": "text"
  5343. }
  5344. ],
  5345. "body": {
  5346. "mode": "raw",
  5347. "raw": "{\r\n \"CallId\": \"IJ\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-ij-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  5348. "options": {
  5349. "raw": {
  5350. "language": "json"
  5351. }
  5352. }
  5353. },
  5354. "url": {
  5355. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  5356. "host": [
  5357. "{{t-erp-api-url}}"
  5358. ],
  5359. "path": [
  5360. "Bill",
  5361. "QueryBillDetail"
  5362. ]
  5363. },
  5364. "description": "查询IJ单详情"
  5365. },
  5366. "response": []
  5367. }
  5368. ],
  5369. "description": "单据类型:IJ(库存调整单),分类:库存类"
  5370. },
  5371. {
  5372. "name": "MC - 原料调拨单",
  5373. "item": [
  5374. {
  5375. "name": "新增MC单(无来源)",
  5376. "event": [
  5377. {
  5378. "listen": "prerequest",
  5379. "script": {
  5380. "exec": [
  5381. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  5382. "function addZero(num) {",
  5383. " return num < 10 ? '0' + num : num;",
  5384. "}",
  5385. "const now = new Date();",
  5386. "const year = now.getFullYear();",
  5387. "const month = addZero(now.getMonth() + 1);",
  5388. "const day = addZero(now.getDate());",
  5389. "const currentDate = `${year}-${month}-${day}`;",
  5390. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  5391. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  5392. ],
  5393. "type": "text/javascript",
  5394. "packages": {},
  5395. "requests": {}
  5396. }
  5397. },
  5398. {
  5399. "listen": "test",
  5400. "script": {
  5401. "exec": [
  5402. "// 1. 解析接口顶层的JSON响应",
  5403. "var resJson = pm.response.json();",
  5404. "console.log(\"✅ 接口顶层JSON解析成功\");",
  5405. "",
  5406. "// 2. 提取Data字段,做非空判断",
  5407. "var dataRawStr = resJson.Data;",
  5408. "if (!dataRawStr) {",
  5409. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  5410. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  5411. " return;",
  5412. "}",
  5413. "",
  5414. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  5415. "var dataJson;",
  5416. "try {",
  5417. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  5418. " dataJson = JSON.parse(dataCleanStr);",
  5419. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  5420. "} catch (e) {",
  5421. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  5422. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  5423. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  5424. " return;",
  5425. "}",
  5426. "",
  5427. "// 4. 提取关键字段",
  5428. "var tfTabNameVal = dataJson.TF_TABNAME;",
  5429. "var bilNo = dataJson.BIL_NO;",
  5430. "var bilId = dataJson.BIL_ID;",
  5431. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  5432. "",
  5433. "pm.test(\"✅ 新增成功校验\", function () {",
  5434. " pm.response.to.have.status(200);",
  5435. " let r = pm.response.json();",
  5436. " pm.expect(r.CallOK).to.equal(\"T\");",
  5437. "});",
  5438. "",
  5439. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  5440. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_MC\");",
  5441. "});",
  5442. "",
  5443. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  5444. " pm.environment.set(\"t-erp-api-mc-bill-no\", bilNo);",
  5445. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  5446. "});"
  5447. ],
  5448. "type": "text/javascript",
  5449. "packages": {},
  5450. "requests": {}
  5451. }
  5452. }
  5453. ],
  5454. "request": {
  5455. "method": "POST",
  5456. "header": [
  5457. {
  5458. "key": "LoginId",
  5459. "value": "{{t-erp-api-login-id}}",
  5460. "type": "text"
  5461. },
  5462. {
  5463. "key": "sn",
  5464. "value": "{{t-erp-api-sn}}",
  5465. "type": "text"
  5466. }
  5467. ],
  5468. "body": {
  5469. "mode": "raw",
  5470. "raw": "{\n \"HeadData\": {\n \"CallId\": \"MC\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\", \n \"WhNo2\": \"0007\", \n \"Up\": 200,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  5471. "options": {
  5472. "raw": {
  5473. "language": "json"
  5474. }
  5475. }
  5476. },
  5477. "url": {
  5478. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  5479. "host": [
  5480. "{{t-erp-api-url}}"
  5481. ],
  5482. "path": [
  5483. "Bill",
  5484. "SaveBill"
  5485. ]
  5486. },
  5487. "description": "新增MC单(无来源)"
  5488. },
  5489. "response": []
  5490. },
  5491. {
  5492. "name": "查询MC单",
  5493. "event": [
  5494. {
  5495. "listen": "test",
  5496. "script": {
  5497. "exec": [
  5498. "pm.test(\"✅ 查询成功校验\", function () {",
  5499. " pm.response.to.have.status(200);",
  5500. " let r = pm.response.json();",
  5501. " pm.expect(r.CallOK).to.equal(\"T\");",
  5502. " console.log(\"✅ 查询单据成功\");",
  5503. "});"
  5504. ],
  5505. "type": "text/javascript",
  5506. "packages": {},
  5507. "requests": {}
  5508. }
  5509. }
  5510. ],
  5511. "request": {
  5512. "method": "POST",
  5513. "header": [
  5514. {
  5515. "key": "LoginId",
  5516. "value": "{{t-erp-api-login-id}}",
  5517. "type": "text"
  5518. },
  5519. {
  5520. "key": "sn",
  5521. "value": "{{t-erp-api-sn}}",
  5522. "type": "text"
  5523. }
  5524. ],
  5525. "body": {
  5526. "mode": "raw",
  5527. "raw": "{\r\n \"CallId\": \"MC\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-mc-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  5528. "options": {
  5529. "raw": {
  5530. "language": "json"
  5531. }
  5532. }
  5533. },
  5534. "url": {
  5535. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  5536. "host": [
  5537. "{{t-erp-api-url}}"
  5538. ],
  5539. "path": [
  5540. "Bill",
  5541. "QueryBillDetail"
  5542. ]
  5543. },
  5544. "description": "查询MC单详情"
  5545. },
  5546. "response": []
  5547. }
  5548. ],
  5549. "description": "单据类型:MC(原料调拨单),分类:库存类"
  5550. },
  5551. {
  5552. "name": "PI - 盘点作业",
  5553. "item": [
  5554. {
  5555. "name": "新增PI单(无来源)",
  5556. "event": [
  5557. {
  5558. "listen": "prerequest",
  5559. "script": {
  5560. "exec": [
  5561. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  5562. "function addZero(num) {",
  5563. " return num < 10 ? '0' + num : num;",
  5564. "}",
  5565. "const now = new Date();",
  5566. "const year = now.getFullYear();",
  5567. "const month = addZero(now.getMonth() + 1);",
  5568. "const day = addZero(now.getDate());",
  5569. "const currentDate = `${year}-${month}-${day}`;",
  5570. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  5571. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  5572. ],
  5573. "type": "text/javascript",
  5574. "packages": {},
  5575. "requests": {}
  5576. }
  5577. },
  5578. {
  5579. "listen": "test",
  5580. "script": {
  5581. "exec": [
  5582. "// 1. 解析接口顶层的JSON响应",
  5583. "var resJson = pm.response.json();",
  5584. "console.log(\"✅ 接口顶层JSON解析成功\");",
  5585. "",
  5586. "// 2. 提取Data字段,做非空判断",
  5587. "var dataRawStr = resJson.Data;",
  5588. "if (!dataRawStr) {",
  5589. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  5590. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  5591. " return;",
  5592. "}",
  5593. "",
  5594. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  5595. "var dataJson;",
  5596. "try {",
  5597. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  5598. " dataJson = JSON.parse(dataCleanStr);",
  5599. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  5600. "} catch (e) {",
  5601. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  5602. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  5603. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  5604. " return;",
  5605. "}",
  5606. "",
  5607. "// 4. 提取关键字段",
  5608. "var tfTabNameVal = dataJson.TF_TABNAME;",
  5609. "var bilNo = dataJson.BIL_NO;",
  5610. "var bilId = dataJson.BIL_ID;",
  5611. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  5612. "",
  5613. "pm.test(\"✅ 新增成功校验\", function () {",
  5614. " pm.response.to.have.status(200);",
  5615. " let r = pm.response.json();",
  5616. " pm.expect(r.CallOK).to.equal(\"T\");",
  5617. "});",
  5618. "",
  5619. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  5620. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_PT\");",
  5621. "});",
  5622. "",
  5623. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  5624. " pm.environment.set(\"t-erp-api-pi-bill-no\", bilNo);",
  5625. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  5626. "});"
  5627. ],
  5628. "type": "text/javascript",
  5629. "packages": {},
  5630. "requests": {}
  5631. }
  5632. }
  5633. ],
  5634. "request": {
  5635. "method": "POST",
  5636. "header": [
  5637. {
  5638. "key": "LoginId",
  5639. "value": "{{t-erp-api-login-id}}",
  5640. "type": "text"
  5641. },
  5642. {
  5643. "key": "sn",
  5644. "value": "{{t-erp-api-sn}}",
  5645. "type": "text"
  5646. }
  5647. ],
  5648. "body": {
  5649. "mode": "raw",
  5650. "raw": "{\n \"HeadData\": {\n \"CallId\": \"PI\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"SalNo\": \"LS\"\n\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"QtyBook\": 970,\n \"QtyInv\": 900,\n \"Rem\": \"测试用摘要\"\n },\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0007\",\n \"QtyBook\": 0,\n \"QtyInv\": 70,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  5651. "options": {
  5652. "raw": {
  5653. "language": "json"
  5654. }
  5655. }
  5656. },
  5657. "url": {
  5658. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  5659. "host": [
  5660. "{{t-erp-api-url}}"
  5661. ],
  5662. "path": [
  5663. "Bill",
  5664. "SaveBill"
  5665. ]
  5666. },
  5667. "description": "新增PI单(无来源)"
  5668. },
  5669. "response": []
  5670. },
  5671. {
  5672. "name": "查询PI单",
  5673. "event": [
  5674. {
  5675. "listen": "test",
  5676. "script": {
  5677. "exec": [
  5678. "pm.test(\"✅ 查询成功校验\", function () {",
  5679. " pm.response.to.have.status(200);",
  5680. " let r = pm.response.json();",
  5681. " pm.expect(r.CallOK).to.equal(\"T\");",
  5682. " console.log(\"✅ 查询单据成功\");",
  5683. "});"
  5684. ],
  5685. "type": "text/javascript",
  5686. "packages": {},
  5687. "requests": {}
  5688. }
  5689. }
  5690. ],
  5691. "request": {
  5692. "method": "POST",
  5693. "header": [
  5694. {
  5695. "key": "LoginId",
  5696. "value": "{{t-erp-api-login-id}}",
  5697. "type": "text"
  5698. },
  5699. {
  5700. "key": "sn",
  5701. "value": "{{t-erp-api-sn}}",
  5702. "type": "text"
  5703. }
  5704. ],
  5705. "body": {
  5706. "mode": "raw",
  5707. "raw": "{\r\n \"CallId\": \"PI\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-pi-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  5708. "options": {
  5709. "raw": {
  5710. "language": "json"
  5711. }
  5712. }
  5713. },
  5714. "url": {
  5715. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  5716. "host": [
  5717. "{{t-erp-api-url}}"
  5718. ],
  5719. "path": [
  5720. "Bill",
  5721. "QueryBillDetail"
  5722. ]
  5723. },
  5724. "description": "查询PI单详情"
  5725. },
  5726. "response": []
  5727. }
  5728. ],
  5729. "description": "单据类型:PI(盘点单),分类:库存类"
  5730. }
  5731. ],
  5732. "description": "库存类相关单据测试用例"
  5733. },
  5734. {
  5735. "name": "📂 托外类",
  5736. "item": [
  5737. {
  5738. "name": "0- 新增基础资料",
  5739. "item": [
  5740. {
  5741. "name": "1.1 新增货品(ZCP0011+YL0011+YL0012)",
  5742. "event": [
  5743. {
  5744. "listen": "test",
  5745. "script": {
  5746. "exec": [
  5747. "var res = pm.response.json();",
  5748. "console.log('新增货品返回:', JSON.stringify(res));",
  5749. "",
  5750. "pm.test('新增货品成功', function () {",
  5751. " pm.response.to.have.status(200);",
  5752. " if (res.OkCount !== undefined) {",
  5753. " pm.expect(res.OkCount).to.be.greaterThan(0);",
  5754. " }",
  5755. "});"
  5756. ],
  5757. "type": "text/javascript",
  5758. "packages": {},
  5759. "requests": {}
  5760. }
  5761. },
  5762. {
  5763. "listen": "prerequest",
  5764. "script": {
  5765. "exec": [
  5766. ""
  5767. ],
  5768. "type": "text/javascript",
  5769. "packages": {},
  5770. "requests": {}
  5771. }
  5772. }
  5773. ],
  5774. "request": {
  5775. "method": "POST",
  5776. "header": [
  5777. {
  5778. "key": "Content-Type",
  5779. "value": "{{t-erp-api-content-type}}"
  5780. },
  5781. {
  5782. "key": "LoginId",
  5783. "value": "{{t-erp-api-login-id}}"
  5784. },
  5785. {
  5786. "key": "Languageid",
  5787. "value": "{{t-erp-api-language}}"
  5788. }
  5789. ],
  5790. "body": {
  5791. "mode": "raw",
  5792. "raw": "[\r\n {\r\n \"PRD_NO\": \"ZCP0011\",\r\n \"NAME\": \"制成品0011\",\r\n \"UT\": \"台\",\r\n \"KND\": \"2\",\r\n \"REM\": \"制令调拨缴库倒冲领料测试\"\r\n },\r\n {\r\n \"PRD_NO\": \"YL0011\",\r\n \"NAME\": \"原料0011\",\r\n \"UT\": \"台\",\r\n \"KND\": \"4\",\r\n \"PRD_ML\": \"Y\",\r\n \"REM\": \"倒冲领料标记\"\r\n },\r\n {\r\n \"PRD_NO\": \"YL0012\",\r\n \"NAME\": \"原料0012\",\r\n \"UT\": \"台\",\r\n \"KND\": \"4\",\r\n \"PRD_ML\": \"Y\",\r\n \"REM\": \"倒冲领料标记\"\r\n }\r\n]",
  5793. "options": {
  5794. "raw": {
  5795. "language": "json"
  5796. }
  5797. }
  5798. },
  5799. "url": {
  5800. "raw": "{{t-erp-api-url}}/Prdt/AppendToPrdt",
  5801. "host": [
  5802. "{{t-erp-api-url}}"
  5803. ],
  5804. "path": [
  5805. "Prdt",
  5806. "AppendToPrdt"
  5807. ]
  5808. }
  5809. },
  5810. "response": []
  5811. },
  5812. {
  5813. "name": "1.2 新增仓库(0008中转仓)",
  5814. "event": [
  5815. {
  5816. "listen": "test",
  5817. "script": {
  5818. "exec": [
  5819. "var res = pm.response.json();",
  5820. "console.log('新增仓库返回:', JSON.stringify(res));",
  5821. "",
  5822. "pm.test('新增仓库成功', function () {",
  5823. " pm.response.to.have.status(200);",
  5824. " if (res.OkCount !== undefined) {",
  5825. " pm.expect(res.OkCount).to.be.greaterThan(0);",
  5826. " }",
  5827. "});"
  5828. ],
  5829. "type": "text/javascript",
  5830. "packages": {},
  5831. "requests": {}
  5832. }
  5833. },
  5834. {
  5835. "listen": "prerequest",
  5836. "script": {
  5837. "exec": [
  5838. ""
  5839. ],
  5840. "type": "text/javascript",
  5841. "packages": {},
  5842. "requests": {}
  5843. }
  5844. }
  5845. ],
  5846. "request": {
  5847. "method": "POST",
  5848. "header": [
  5849. {
  5850. "key": "Content-Type",
  5851. "value": "{{t-erp-api-content-type}}"
  5852. },
  5853. {
  5854. "key": "LoginId",
  5855. "value": "{{t-erp-api-login-id}}"
  5856. },
  5857. {
  5858. "key": "Languageid",
  5859. "value": "{{t-erp-api-language}}"
  5860. }
  5861. ],
  5862. "body": {
  5863. "mode": "raw",
  5864. "raw": "[\r\n {\r\n \"WH\": \"0008\",\r\n \"NAME\": \"中转仓\"\r\n }\r\n]",
  5865. "options": {
  5866. "raw": {
  5867. "language": "json"
  5868. }
  5869. }
  5870. },
  5871. "url": {
  5872. "raw": "{{t-erp-api-url}}/Wh/AppendToWh",
  5873. "host": [
  5874. "{{t-erp-api-url}}"
  5875. ],
  5876. "path": [
  5877. "Wh",
  5878. "AppendToWh"
  5879. ]
  5880. }
  5881. },
  5882. "response": []
  5883. },
  5884. {
  5885. "name": "1.3 新增BOM(ZCP0011 V1.0配方)",
  5886. "event": [
  5887. {
  5888. "listen": "test",
  5889. "script": {
  5890. "exec": [
  5891. "var res = pm.response.json();",
  5892. "console.log('新增BOM返回:', JSON.stringify(res));",
  5893. "",
  5894. "pm.test('新增BOM成功', function () {",
  5895. " pm.response.to.have.status(200);",
  5896. " if (res.OkCount !== undefined) {",
  5897. " pm.expect(res.OkCount).to.be.greaterThan(0);",
  5898. " }",
  5899. "});"
  5900. ],
  5901. "type": "text/javascript",
  5902. "packages": {},
  5903. "requests": {}
  5904. }
  5905. },
  5906. {
  5907. "listen": "prerequest",
  5908. "script": {
  5909. "exec": [
  5910. ""
  5911. ],
  5912. "type": "text/javascript",
  5913. "packages": {},
  5914. "requests": {}
  5915. }
  5916. }
  5917. ],
  5918. "request": {
  5919. "method": "POST",
  5920. "header": [
  5921. {
  5922. "key": "Content-Type",
  5923. "value": "{{t-erp-api-content-type}}"
  5924. },
  5925. {
  5926. "key": "LoginId",
  5927. "value": "{{t-erp-api-login-id}}"
  5928. },
  5929. {
  5930. "key": "Languageid",
  5931. "value": "{{t-erp-api-language}}"
  5932. }
  5933. ],
  5934. "body": {
  5935. "mode": "raw",
  5936. "raw": "[\r\n {\r\n \"PRD_NO\": \"ZCP0011\",\r\n \"PF_NO\": \"V1.0\",\r\n \"QTY\": 1,\r\n \"WH_NO\": \"0003\",\r\n \"REM\": \"制成品0011配方\",\r\n \"BodyData\": [\r\n {\r\n \"PRD_NO\": \"YL0011\",\r\n \"QTY\": 10,\r\n \"WH_NO\": \"0001\",\r\n \"REM\": \"原料0011用量\"\r\n },\r\n {\r\n \"PRD_NO\": \"YL0012\",\r\n \"QTY\": 20,\r\n \"WH_NO\": \"0001\",\r\n \"REM\": \"原料0012用量\"\r\n }\r\n ]\r\n }\r\n]",
  5937. "options": {
  5938. "raw": {
  5939. "language": "json"
  5940. }
  5941. }
  5942. },
  5943. "url": {
  5944. "raw": "{{t-erp-api-url}}/Bom/AppendToBom",
  5945. "host": [
  5946. "{{t-erp-api-url}}"
  5947. ],
  5948. "path": [
  5949. "Bom",
  5950. "AppendToBom"
  5951. ]
  5952. }
  5953. },
  5954. "response": []
  5955. }
  5956. ]
  5957. },
  5958. {
  5959. "name": "1- TW - 托外加工单",
  5960. "item": [
  5961. {
  5962. "name": "新增TW单(无来源)",
  5963. "event": [
  5964. {
  5965. "listen": "prerequest",
  5966. "script": {
  5967. "exec": [
  5968. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  5969. "function addZero(num) {",
  5970. " return num < 10 ? '0' + num : num;",
  5971. "}",
  5972. "const now = new Date();",
  5973. "const year = now.getFullYear();",
  5974. "const month = addZero(now.getMonth() + 1);",
  5975. "const day = addZero(now.getDate());",
  5976. "const currentDate = `${year}-${month}-${day}`;",
  5977. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  5978. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  5979. ],
  5980. "type": "text/javascript",
  5981. "packages": {},
  5982. "requests": {}
  5983. }
  5984. },
  5985. {
  5986. "listen": "test",
  5987. "script": {
  5988. "exec": [
  5989. "// 1. 解析接口顶层的JSON响应",
  5990. "var resJson = pm.response.json();",
  5991. "console.log(\"✅ 接口顶层JSON解析成功\");",
  5992. "",
  5993. "// 2. 提取Data字段,做非空判断",
  5994. "var dataRawStr = resJson.Data;",
  5995. "if (!dataRawStr) {",
  5996. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  5997. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  5998. " return;",
  5999. "}",
  6000. "",
  6001. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  6002. "var dataJson;",
  6003. "try {",
  6004. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  6005. " dataJson = JSON.parse(dataCleanStr);",
  6006. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  6007. "} catch (e) {",
  6008. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  6009. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  6010. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  6011. " return;",
  6012. "}",
  6013. "",
  6014. "// 4. 提取关键字段",
  6015. "var tfTabNameVal = dataJson.TF_TABNAME;",
  6016. "var bilNo = dataJson.BIL_NO;",
  6017. "var bilId = dataJson.BIL_ID;",
  6018. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  6019. "",
  6020. "pm.test(\"✅ 新增成功校验\", function () {",
  6021. " pm.response.to.have.status(200);",
  6022. " let r = pm.response.json();",
  6023. " pm.expect(r.CallOK).to.equal(\"T\");",
  6024. "});",
  6025. "",
  6026. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  6027. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_TW\");",
  6028. "});",
  6029. "",
  6030. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  6031. " pm.environment.set(\"t-erp-api-tw-bill-no\", bilNo);",
  6032. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  6033. "});"
  6034. ],
  6035. "type": "text/javascript",
  6036. "packages": {},
  6037. "requests": {}
  6038. }
  6039. }
  6040. ],
  6041. "request": {
  6042. "method": "POST",
  6043. "header": [
  6044. {
  6045. "key": "LoginId",
  6046. "value": "{{t-erp-api-login-id}}",
  6047. "type": "text"
  6048. },
  6049. {
  6050. "key": "sn",
  6051. "value": "{{t-erp-api-sn}}",
  6052. "type": "text"
  6053. }
  6054. ],
  6055. "body": {
  6056. "mode": "raw",
  6057. "raw": "{\n \"HeadData\": {\n \"CallId\": \"TW\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"CS0001\",\n \"DepNo\": \"0000\",\n \"PrdNo\": \"ZCP0011\",\n \"WhNo\": \"0003\",\n \"Qty\": 10,\n \"IdNo\": \"ZCP0011->V1.0\",\n \"CONTROL\":\"F\",\n \"CHK_SCHED\":\"F\",\n \"Rem\": \"托工倒冲领料流程-托外加工单\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0011\", // 必须,货品代号\n \"WhNo\": \"0001\", // 必须,仓库\n \"Qty\": 100 // 必须,主数量\n },\n {\n \"PrdNo\": \"YL0012\", // 必须,货品代号\n \"WhNo\": \"0001\", // 必须,仓库\n \"Qty\": 200 // 必须,主数量\n }\n ]\n}",
  6058. "options": {
  6059. "raw": {
  6060. "language": "json"
  6061. }
  6062. }
  6063. },
  6064. "url": {
  6065. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  6066. "host": [
  6067. "{{t-erp-api-url}}"
  6068. ],
  6069. "path": [
  6070. "Bill",
  6071. "SaveBill"
  6072. ]
  6073. },
  6074. "description": "新增TW单(无来源)"
  6075. },
  6076. "response": []
  6077. },
  6078. {
  6079. "name": "查询TW单",
  6080. "event": [
  6081. {
  6082. "listen": "test",
  6083. "script": {
  6084. "exec": [
  6085. "pm.test(\"✅ 查询成功校验\", function () {",
  6086. " pm.response.to.have.status(200);",
  6087. " let r = pm.response.json();",
  6088. " pm.expect(r.CallOK).to.equal(\"T\");",
  6089. " console.log(\"✅ 查询单据成功\");",
  6090. "});"
  6091. ],
  6092. "type": "text/javascript",
  6093. "packages": {},
  6094. "requests": {}
  6095. }
  6096. }
  6097. ],
  6098. "request": {
  6099. "method": "POST",
  6100. "header": [
  6101. {
  6102. "key": "LoginId",
  6103. "value": "{{t-erp-api-login-id}}",
  6104. "type": "text"
  6105. },
  6106. {
  6107. "key": "sn",
  6108. "value": "{{t-erp-api-sn}}",
  6109. "type": "text"
  6110. }
  6111. ],
  6112. "body": {
  6113. "mode": "raw",
  6114. "raw": "{\r\n \"CallId\": \"TW\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-tw-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  6115. "options": {
  6116. "raw": {
  6117. "language": "json"
  6118. }
  6119. }
  6120. },
  6121. "url": {
  6122. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  6123. "host": [
  6124. "{{t-erp-api-url}}"
  6125. ],
  6126. "path": [
  6127. "Bill",
  6128. "QueryBillDetail"
  6129. ]
  6130. },
  6131. "description": "查询TW单详情"
  6132. },
  6133. "response": []
  6134. }
  6135. ],
  6136. "description": "单据类型:TW(托外加工单),分类:托外类"
  6137. },
  6138. {
  6139. "name": "WT - 批次托外单",
  6140. "item": [
  6141. {
  6142. "name": "新增WT单(无来源)",
  6143. "event": [
  6144. {
  6145. "listen": "prerequest",
  6146. "script": {
  6147. "exec": [
  6148. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  6149. "function addZero(num) {",
  6150. " return num < 10 ? '0' + num : num;",
  6151. "}",
  6152. "const now = new Date();",
  6153. "const year = now.getFullYear();",
  6154. "const month = addZero(now.getMonth() + 1);",
  6155. "const day = addZero(now.getDate());",
  6156. "const currentDate = `${year}-${month}-${day}`;",
  6157. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  6158. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  6159. ],
  6160. "type": "text/javascript",
  6161. "packages": {},
  6162. "requests": {}
  6163. }
  6164. },
  6165. {
  6166. "listen": "test",
  6167. "script": {
  6168. "exec": [
  6169. "// 1. 解析接口顶层的JSON响应",
  6170. "var resJson = pm.response.json();",
  6171. "console.log(\"✅ 接口顶层JSON解析成功\");",
  6172. "",
  6173. "// 2. 提取Data字段,做非空判断",
  6174. "var dataRawStr = resJson.Data;",
  6175. "if (!dataRawStr) {",
  6176. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  6177. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  6178. " return;",
  6179. "}",
  6180. "",
  6181. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  6182. "var dataJson;",
  6183. "try {",
  6184. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  6185. " dataJson = JSON.parse(dataCleanStr);",
  6186. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  6187. "} catch (e) {",
  6188. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  6189. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  6190. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  6191. " return;",
  6192. "}",
  6193. "",
  6194. "// 4. 提取关键字段",
  6195. "var tfTabNameVal = dataJson.TF_TABNAME;",
  6196. "var bilNo = dataJson.BIL_NO;",
  6197. "var bilId = dataJson.BIL_ID;",
  6198. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  6199. "",
  6200. "pm.test(\"✅ 新增成功校验\", function () {",
  6201. " pm.response.to.have.status(200);",
  6202. " let r = pm.response.json();",
  6203. " pm.expect(r.CallOK).to.equal(\"T\");",
  6204. "});",
  6205. "",
  6206. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  6207. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_WT\");",
  6208. "});",
  6209. "",
  6210. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  6211. " pm.environment.set(\"t-erp-api-wt-bill-no\", bilNo);",
  6212. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  6213. "});"
  6214. ],
  6215. "type": "text/javascript",
  6216. "packages": {},
  6217. "requests": {}
  6218. }
  6219. }
  6220. ],
  6221. "request": {
  6222. "method": "POST",
  6223. "header": [
  6224. {
  6225. "key": "LoginId",
  6226. "value": "{{t-erp-api-login-id}}",
  6227. "type": "text"
  6228. },
  6229. {
  6230. "key": "sn",
  6231. "value": "{{t-erp-api-sn}}",
  6232. "type": "text"
  6233. }
  6234. ],
  6235. "body": {
  6236. "mode": "raw",
  6237. "raw": "{\n \"HeadData\": {\n \"CallId\": \"WT\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"CusNo\": \"CS0001\",\n \"DepNo\": \"0000\"\n\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"ZCP0011\",\n \"WhNo\": \"0003\",\n \"Qty\": 10,\n \"IdNo\": \"ZCP0011->V1.0\",\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  6238. "options": {
  6239. "raw": {
  6240. "language": "json"
  6241. }
  6242. }
  6243. },
  6244. "url": {
  6245. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  6246. "host": [
  6247. "{{t-erp-api-url}}"
  6248. ],
  6249. "path": [
  6250. "Bill",
  6251. "SaveBill"
  6252. ]
  6253. },
  6254. "description": "新增WT单(无来源)"
  6255. },
  6256. "response": []
  6257. },
  6258. {
  6259. "name": "查询WT单",
  6260. "event": [
  6261. {
  6262. "listen": "test",
  6263. "script": {
  6264. "exec": [
  6265. "pm.test(\"✅ 查询成功校验\", function () {",
  6266. " pm.response.to.have.status(200);",
  6267. " let r = pm.response.json();",
  6268. " pm.expect(r.CallOK).to.equal(\"T\");",
  6269. " console.log(\"✅ 查询单据成功\");",
  6270. "});",
  6271. "",
  6272. "pm.test(\"✅ BUILD_BIL字段有值\", function () {",
  6273. " const res = pm.response.json();",
  6274. " const buildBil = res.Data.HEADDATA.BUILD_BIL;",
  6275. " pm.expect(buildBil).to.exist;",
  6276. " pm.expect(buildBil).not.to.be.null;",
  6277. " pm.expect(buildBil).not.to.equal(\"\");",
  6278. "});"
  6279. ],
  6280. "type": "text/javascript",
  6281. "packages": {},
  6282. "requests": {}
  6283. }
  6284. }
  6285. ],
  6286. "request": {
  6287. "method": "POST",
  6288. "header": [
  6289. {
  6290. "key": "LoginId",
  6291. "value": "{{t-erp-api-login-id}}",
  6292. "type": "text"
  6293. },
  6294. {
  6295. "key": "sn",
  6296. "value": "{{t-erp-api-sn}}",
  6297. "type": "text"
  6298. }
  6299. ],
  6300. "body": {
  6301. "mode": "raw",
  6302. "raw": "{\r\n \"CallId\": \"WT\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-wt-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  6303. "options": {
  6304. "raw": {
  6305. "language": "json"
  6306. }
  6307. }
  6308. },
  6309. "url": {
  6310. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  6311. "host": [
  6312. "{{t-erp-api-url}}"
  6313. ],
  6314. "path": [
  6315. "Bill",
  6316. "QueryBillDetail"
  6317. ]
  6318. },
  6319. "description": "查询WT单详情"
  6320. },
  6321. "response": []
  6322. }
  6323. ],
  6324. "description": "单据类型:WT(批次托外单),分类:托外类"
  6325. }
  6326. ],
  6327. "description": "托外类相关单据测试用例"
  6328. },
  6329. {
  6330. "name": "📂 非生产领退料",
  6331. "item": [
  6332. {
  6333. "name": "M7 - 非生产领料单",
  6334. "item": [
  6335. {
  6336. "name": "新增M7单(无来源)",
  6337. "event": [
  6338. {
  6339. "listen": "prerequest",
  6340. "script": {
  6341. "exec": [
  6342. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  6343. "function addZero(num) {",
  6344. " return num < 10 ? '0' + num : num;",
  6345. "}",
  6346. "const now = new Date();",
  6347. "const year = now.getFullYear();",
  6348. "const month = addZero(now.getMonth() + 1);",
  6349. "const day = addZero(now.getDate());",
  6350. "const currentDate = `${year}-${month}-${day}`;",
  6351. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  6352. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  6353. ],
  6354. "type": "text/javascript",
  6355. "packages": {},
  6356. "requests": {}
  6357. }
  6358. },
  6359. {
  6360. "listen": "test",
  6361. "script": {
  6362. "exec": [
  6363. "// 1. 解析接口顶层的JSON响应",
  6364. "var resJson = pm.response.json();",
  6365. "console.log(\"✅ 接口顶层JSON解析成功\");",
  6366. "",
  6367. "// 2. 提取Data字段,做非空判断",
  6368. "var dataRawStr = resJson.Data;",
  6369. "if (!dataRawStr) {",
  6370. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  6371. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  6372. " return;",
  6373. "}",
  6374. "",
  6375. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  6376. "var dataJson;",
  6377. "try {",
  6378. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  6379. " dataJson = JSON.parse(dataCleanStr);",
  6380. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  6381. "} catch (e) {",
  6382. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  6383. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  6384. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  6385. " return;",
  6386. "}",
  6387. "",
  6388. "// 4. 提取关键字段",
  6389. "var tfTabNameVal = dataJson.TF_TABNAME;",
  6390. "var bilNo = dataJson.BIL_NO;",
  6391. "var bilId = dataJson.BIL_ID;",
  6392. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  6393. "",
  6394. "pm.test(\"✅ 新增成功校验\", function () {",
  6395. " pm.response.to.have.status(200);",
  6396. " let r = pm.response.json();",
  6397. " pm.expect(r.CallOK).to.equal(\"T\");",
  6398. "});",
  6399. "",
  6400. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  6401. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_FL\");",
  6402. "});",
  6403. "",
  6404. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  6405. " pm.environment.set(\"t-erp-api-m7-bill-no\", bilNo);",
  6406. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  6407. "});"
  6408. ],
  6409. "type": "text/javascript",
  6410. "packages": {},
  6411. "requests": {}
  6412. }
  6413. }
  6414. ],
  6415. "request": {
  6416. "method": "POST",
  6417. "header": [
  6418. {
  6419. "key": "LoginId",
  6420. "value": "{{t-erp-api-login-id}}",
  6421. "type": "text"
  6422. },
  6423. {
  6424. "key": "sn",
  6425. "value": "{{t-erp-api-sn}}",
  6426. "type": "text"
  6427. }
  6428. ],
  6429. "body": {
  6430. "mode": "raw",
  6431. "raw": "{\n \"HeadData\": {\n \"CallId\": \"M7\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"WhNo\": \"0001\",\n \"DepNo\": \"0001\",\n \"Rem\": \"非生产领料测试\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  6432. "options": {
  6433. "raw": {
  6434. "language": "json"
  6435. }
  6436. }
  6437. },
  6438. "url": {
  6439. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  6440. "host": [
  6441. "{{t-erp-api-url}}"
  6442. ],
  6443. "path": [
  6444. "Bill",
  6445. "SaveBill"
  6446. ]
  6447. },
  6448. "description": "新增M7单(无来源)"
  6449. },
  6450. "response": []
  6451. },
  6452. {
  6453. "name": "查询M7单",
  6454. "event": [
  6455. {
  6456. "listen": "test",
  6457. "script": {
  6458. "exec": [
  6459. "pm.test(\"✅ 查询成功校验\", function () {",
  6460. " pm.response.to.have.status(200);",
  6461. " let r = pm.response.json();",
  6462. " pm.expect(r.CallOK).to.equal(\"T\");",
  6463. " console.log(\"✅ 查询单据成功\");",
  6464. "});"
  6465. ],
  6466. "type": "text/javascript",
  6467. "packages": {},
  6468. "requests": {}
  6469. }
  6470. }
  6471. ],
  6472. "request": {
  6473. "method": "POST",
  6474. "header": [
  6475. {
  6476. "key": "LoginId",
  6477. "value": "{{t-erp-api-login-id}}",
  6478. "type": "text"
  6479. },
  6480. {
  6481. "key": "sn",
  6482. "value": "{{t-erp-api-sn}}",
  6483. "type": "text"
  6484. }
  6485. ],
  6486. "body": {
  6487. "mode": "raw",
  6488. "raw": "{\r\n \"CallId\": \"M7\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-m7-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  6489. "options": {
  6490. "raw": {
  6491. "language": "json"
  6492. }
  6493. }
  6494. },
  6495. "url": {
  6496. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  6497. "host": [
  6498. "{{t-erp-api-url}}"
  6499. ],
  6500. "path": [
  6501. "Bill",
  6502. "QueryBillDetail"
  6503. ]
  6504. },
  6505. "description": "查询M7单详情"
  6506. },
  6507. "response": []
  6508. },
  6509. {
  6510. "name": "删除M7单",
  6511. "event": [
  6512. {
  6513. "listen": "test",
  6514. "script": {
  6515. "exec": [
  6516. "pm.test(\"✅ 删除成功校验\", function () {",
  6517. " pm.response.to.have.status(200);",
  6518. " let r = pm.response.json();",
  6519. " pm.expect(r.CallOK).to.equal(\"T\");",
  6520. " console.log(\"✅ 删除单据成功\");",
  6521. "});"
  6522. ],
  6523. "type": "text/javascript",
  6524. "packages": {},
  6525. "requests": {}
  6526. }
  6527. }
  6528. ],
  6529. "request": {
  6530. "method": "POST",
  6531. "header": [
  6532. {
  6533. "key": "LoginId",
  6534. "value": "{{t-erp-api-login-id}}",
  6535. "type": "text"
  6536. },
  6537. {
  6538. "key": "sn",
  6539. "value": "{{t-erp-api-sn}}",
  6540. "type": "text"
  6541. }
  6542. ],
  6543. "body": {
  6544. "mode": "raw",
  6545. "raw": "{\n \"CallId\": \"M7\",\n \"CallNo\": \"{{t-erp-api-m7-bill-no}}\"\n}",
  6546. "options": {
  6547. "raw": {
  6548. "language": "json"
  6549. }
  6550. }
  6551. },
  6552. "url": {
  6553. "raw": "{{t-erp-api-url}}/Bill/DeleteBill",
  6554. "host": [
  6555. "{{t-erp-api-url}}"
  6556. ],
  6557. "path": [
  6558. "Bill",
  6559. "DeleteBill"
  6560. ]
  6561. },
  6562. "description": "删除M7单"
  6563. },
  6564. "response": []
  6565. }
  6566. ],
  6567. "description": "单据类型:M7(非生产领料单),分类:非生产领退料"
  6568. },
  6569. {
  6570. "name": "M8 - 非生产退料单",
  6571. "item": [
  6572. {
  6573. "name": "新增M8单(无来源)",
  6574. "event": [
  6575. {
  6576. "listen": "prerequest",
  6577. "script": {
  6578. "exec": [
  6579. "// 【前置脚本】设置当天日期为环境变量,格式:YYYY-MM-DD",
  6580. "function addZero(num) {",
  6581. " return num < 10 ? '0' + num : num;",
  6582. "}",
  6583. "const now = new Date();",
  6584. "const year = now.getFullYear();",
  6585. "const month = addZero(now.getMonth() + 1);",
  6586. "const day = addZero(now.getDate());",
  6587. "const currentDate = `${year}-${month}-${day}`;",
  6588. "pm.environment.set(\"t-erp-api-current-date\", currentDate);",
  6589. "console.log(`✅ 环境变量设置成功:t-erp-api-current-date = ${currentDate}`);"
  6590. ],
  6591. "type": "text/javascript",
  6592. "packages": {},
  6593. "requests": {}
  6594. }
  6595. },
  6596. {
  6597. "listen": "test",
  6598. "script": {
  6599. "exec": [
  6600. "// 1. 解析接口顶层的JSON响应",
  6601. "var resJson = pm.response.json();",
  6602. "console.log(\"✅ 接口顶层JSON解析成功\");",
  6603. "",
  6604. "// 2. 提取Data字段,做非空判断",
  6605. "var dataRawStr = resJson.Data;",
  6606. "if (!dataRawStr) {",
  6607. " console.error(\"❌ Data字段为空/不存在,无法解析\");",
  6608. " pm.test(\"Data字段非空\", () => pm.expect(dataRawStr).to.not.be.empty);",
  6609. " return;",
  6610. "}",
  6611. "",
  6612. "// 3. 解析Data为JSON对象(含异常捕获+清理\\r\\n)",
  6613. "var dataJson;",
  6614. "try {",
  6615. " var dataCleanStr = dataRawStr.replace(/\\r\\n/g, \"\").replace(/\\s+/g, \" \");",
  6616. " dataJson = JSON.parse(dataCleanStr);",
  6617. " console.log(\"✅ Data字段成功转为JSON对象\", dataJson);",
  6618. "} catch (e) {",
  6619. " console.error(\"❌ Data解析为JSON失败:\", e.message);",
  6620. " console.error(\"❌ Data原始字符串:\", dataRawStr);",
  6621. " pm.test(\"Data字段可正常解析为JSON\", () => pm.expect.fail(\"Data格式错误,解析失败\"));",
  6622. " return;",
  6623. "}",
  6624. "",
  6625. "// 4. 提取关键字段",
  6626. "var tfTabNameVal = dataJson.TF_TABNAME;",
  6627. "var bilNo = dataJson.BIL_NO;",
  6628. "var bilId = dataJson.BIL_ID;",
  6629. "console.log(`📌 从Data中提取:TF_TABNAME=${tfTabNameVal},BIL_NO=${bilNo},BIL_ID=${bilId}`);",
  6630. "",
  6631. "pm.test(\"✅ 新增成功校验\", function () {",
  6632. " pm.response.to.have.status(200);",
  6633. " let r = pm.response.json();",
  6634. " pm.expect(r.CallOK).to.equal(\"T\");",
  6635. "});",
  6636. "",
  6637. "pm.test(\"✅ Data中TF_TABNAME字段存在且正确\", () => {",
  6638. " pm.expect(dataJson).to.have.property(\"TF_TABNAME\", \"TF_FL\");",
  6639. "});",
  6640. "",
  6641. "pm.test(\"✅ 获取单据信息写入变量\", function () {",
  6642. " pm.environment.set(\"t-erp-api-m8-bill-no\", bilNo);",
  6643. " console.log(\"✅ 解析后的Data字段已存入环境变量\");",
  6644. "});"
  6645. ],
  6646. "type": "text/javascript",
  6647. "packages": {},
  6648. "requests": {}
  6649. }
  6650. }
  6651. ],
  6652. "request": {
  6653. "method": "POST",
  6654. "header": [
  6655. {
  6656. "key": "LoginId",
  6657. "value": "{{t-erp-api-login-id}}",
  6658. "type": "text"
  6659. },
  6660. {
  6661. "key": "sn",
  6662. "value": "{{t-erp-api-sn}}",
  6663. "type": "text"
  6664. }
  6665. ],
  6666. "body": {
  6667. "mode": "raw",
  6668. "raw": "{\n \"HeadData\": {\n \"CallId\": \"M8\",\n \"BilDate\": \"{{t-erp-api-current-date}}\",\n \"WhNo\": \"0001\",\n \"DepNo\": \"0001\"\n },\n \"BodyData\": [\n {\n \"PrdNo\": \"YL0001\",\n \"WhNo\": \"0001\",\n \"Qty\": 10,\n \"Up\": 100,\n \"Rem\": \"测试用摘要\"\n }\n ]\n}",
  6669. "options": {
  6670. "raw": {
  6671. "language": "json"
  6672. }
  6673. }
  6674. },
  6675. "url": {
  6676. "raw": "{{t-erp-api-url}}/Bill/SaveBill",
  6677. "host": [
  6678. "{{t-erp-api-url}}"
  6679. ],
  6680. "path": [
  6681. "Bill",
  6682. "SaveBill"
  6683. ]
  6684. },
  6685. "description": "新增M8单(无来源)"
  6686. },
  6687. "response": []
  6688. },
  6689. {
  6690. "name": "查询M8单",
  6691. "event": [
  6692. {
  6693. "listen": "test",
  6694. "script": {
  6695. "exec": [
  6696. "pm.test(\"✅ 查询成功校验\", function () {",
  6697. " pm.response.to.have.status(200);",
  6698. " let r = pm.response.json();",
  6699. " pm.expect(r.CallOK).to.equal(\"T\");",
  6700. " console.log(\"✅ 查询单据成功\");",
  6701. "});"
  6702. ],
  6703. "type": "text/javascript",
  6704. "packages": {},
  6705. "requests": {}
  6706. }
  6707. }
  6708. ],
  6709. "request": {
  6710. "method": "POST",
  6711. "header": [
  6712. {
  6713. "key": "LoginId",
  6714. "value": "{{t-erp-api-login-id}}",
  6715. "type": "text"
  6716. },
  6717. {
  6718. "key": "sn",
  6719. "value": "{{t-erp-api-sn}}",
  6720. "type": "text"
  6721. }
  6722. ],
  6723. "body": {
  6724. "mode": "raw",
  6725. "raw": "{\r\n \"CallId\": \"M8\", // 必须,调用的单据识别号\r\n \"CallNo\": \"{{t-erp-api-m8-bill-no}}\" // 必须,调用的单据号码\r\n\r\n}",
  6726. "options": {
  6727. "raw": {
  6728. "language": "json"
  6729. }
  6730. }
  6731. },
  6732. "url": {
  6733. "raw": "{{t-erp-api-url}}/Bill/QueryBillDetail",
  6734. "host": [
  6735. "{{t-erp-api-url}}"
  6736. ],
  6737. "path": [
  6738. "Bill",
  6739. "QueryBillDetail"
  6740. ]
  6741. },
  6742. "description": "查询M8单详情"
  6743. },
  6744. "response": []
  6745. },
  6746. {
  6747. "name": "删除M8单",
  6748. "event": [
  6749. {
  6750. "listen": "test",
  6751. "script": {
  6752. "exec": [
  6753. "pm.test(\"✅ 删除成功校验\", function () {",
  6754. " pm.response.to.have.status(200);",
  6755. " let r = pm.response.json();",
  6756. " pm.expect(r.CallOK).to.equal(\"T\");",
  6757. " console.log(\"✅ 删除单据成功\");",
  6758. "});"
  6759. ],
  6760. "type": "text/javascript",
  6761. "packages": {},
  6762. "requests": {}
  6763. }
  6764. }
  6765. ],
  6766. "request": {
  6767. "method": "POST",
  6768. "header": [
  6769. {
  6770. "key": "LoginId",
  6771. "value": "{{t-erp-api-login-id}}",
  6772. "type": "text"
  6773. },
  6774. {
  6775. "key": "sn",
  6776. "value": "{{t-erp-api-sn}}",
  6777. "type": "text"
  6778. }
  6779. ],
  6780. "body": {
  6781. "mode": "raw",
  6782. "raw": "{\n \"CallId\": \"M8\",\n \"CallNo\": \"{{t-erp-api-m8-bill-no}}\"\n}",
  6783. "options": {
  6784. "raw": {
  6785. "language": "json"
  6786. }
  6787. }
  6788. },
  6789. "url": {
  6790. "raw": "{{t-erp-api-url}}/Bill/DeleteBill",
  6791. "host": [
  6792. "{{t-erp-api-url}}"
  6793. ],
  6794. "path": [
  6795. "Bill",
  6796. "DeleteBill"
  6797. ]
  6798. },
  6799. "description": "删除M8单"
  6800. },
  6801. "response": []
  6802. }
  6803. ],
  6804. "description": "单据类型:M8(非生产退料单),分类:非生产领退料"
  6805. }
  6806. ],
  6807. "description": "非生产领退料相关单据测试用例"
  6808. }
  6809. ],
  6810. "description": "覆盖全部35种单据类型,每种单据包含:新增(无来源)、新增(有来源转入,适用有来源关系的单据)、查询、审核、打印、删除"
  6811. }
  6812. ],
  6813. "event": [
  6814. {
  6815. "listen": "prerequest",
  6816. "script": {
  6817. "type": "text/javascript",
  6818. "exec": [
  6819. ""
  6820. ]
  6821. }
  6822. },
  6823. {
  6824. "listen": "test",
  6825. "script": {
  6826. "type": "text/javascript",
  6827. "exec": [
  6828. ""
  6829. ]
  6830. }
  6831. }
  6832. ]
  6833. }